Bug 46831 - reversed bidi sheets in kspread
Summary: reversed bidi sheets in kspread
Status: RESOLVED FIXED
Alias: None
Product: calligrasheets
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Mandrake RPMs Other
: NOR wishlist
Target Milestone: ---
Assignee: Laurent Montel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-08-23 11:33 UTC by Unknown
Modified: 2004-08-29 19:09 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description iastrubn 2002-08-23 11:27:04 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           kspread
Version:           KDE 3.0.1 
Severity:          wishlist
Installed from:    Mandrake RPMs
Compiler:          Not Specified
OS:                Not Specified
OS/Compiler notes: Not Specified

When a sheets name begins with a bidi letter the UI of the sheet should be reversed: a1 will be in the right part of the screen.

(Submitted via bugs.kde.org)
Comment 1 Munzir Taha 2003-12-05 01:45:47 UTC
The reversal of the sheet shoud have nothing to do with the name because one can have the content in english and still name it in arabic or hebrew. But the bug actually is that kspread --reverse doesn't reverse the name of the sheet position nor the A   B    C   D order

the column names shoud be
                                                           ...  D  C   B  A
and the sheet tabs should come to the right with this order
                                               Sheet3  Sheet2  Sheet1

I put the bug here because I thought the description goes with my content very well, right?
Comment 2 iastrubn 2003-12-05 12:46:00 UTC
Subject: Re:  reversed bidi sheets in kspread

Actually I do not agree. 
Open kword,  write in arabic, boom! text is right aligned. I expect kspread to 
behave the same way, it should not have anything to do with the desktop 
direction.

Do you have a better idea how to trigger the reversed sheets?

ביום שישי, 5 בדצמבר 2003, 02:45, נכתב על ידי Muunzir Taha:
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
> http://bugs.kde.org/show_bug.cgi?id=46831
>
>
>
>
> ------- Additional Comments From munzirtaha@newhorizons.com.sa  2003-12-05
> 01:45 ------- The reversal of the sheet shoud have nothing to do with the
> name because one can have the content in english and still name it in
> arabic or hebrew. But the bug actually is that kspread --reverse doesn't
> reverse the name of the sheet position nor the A   B    C   D order
>
> the column names shoud be
>                                                            ...  D  C   B  A
> and the sheet tabs should come to the right with this order
>                                                Sheet3  Sheet2  Sheet1
>
> I put the bug here because I thought the description goes with my content
> very well, right?

Comment 3 Munzir Taha 2003-12-05 22:59:59 UTC
Open kword English GUI, write in Arabic, the GUI (File, Edit,...) won't be reversed. The sheets should conform with the Interface language not the typed language. Have you ever tried Excel before? If you localize it to Arabic/Hebrew, you have the sheets position to the right. Again, I agree the sheet should go to the right if kspread --reverse is used but not with the filename you open.
Comment 4 Munzir Taha 2003-12-10 02:10:43 UTC
Yea! you are speaking about the sheet name not the file name. Sorry for not reading carefully. Anyway, the same argument applies for sheet names.

MS Excel does it the right way. The sheet position will only be changed if done manually by the user via a button called Left-to-Right sheet or another called Right-to-Left sheet and both are toggle buttons. This is much better and it allows more flexibility since you have the choice to use all the variations of sheet positions irrespective of the doc content lang, sheet name, .... Automatically, the sheets should be to the right with the --reverse option but the user can change it.
Comment 5 iastrubn 2003-12-10 17:58:50 UTC
Subject: Re:  reversed bidi sheets in kspread

ביום רביעי, 10 בדצמבר 2003, 03:10, כתבת:
> MS Excel does it the right way. The sheet position will only be changed if
> done manually by the user via a button called Left-to-Right sheet or
> another called Right-to-Left sheet and both are toggle buttons. This is
> much better and it allows more flexibility since you have the choice to use
> all the variations of sheet positions irrespective of the doc content lang,
i was thinking of auto/rtl/ltr. defaults to auto (as KDE and QT do), and user 
can overwrite... do you have time to code? I was supposed to fix the RTL 
stuff there, but I dont have time.

> sheet name, .... Automatically, the sheets should be to the right with the
> --reverse option but the user can change it.
oh no... the sheet has nothing to do with QApplication::reverseLayout(), look 
at the code!

Comment 6 Arash Zeini 2003-12-15 04:28:38 UTC
I agree with Muunzir. The sheet or fiel name are irrelevant to the direction of the sheet. But the --reverse argument is not. I expect KSpread to have the sheet direction RTL when I start it with a Farsi UI and LTR when started with English for example. I would however still need a direction button to change the direction as and when I wish.
Comment 7 iastrubn 2003-12-15 18:39:20 UTC
Subject: Re:  reversed bidi sheets in kspread

Well I dont, that sux.

Imagine a screatary which uses Farsi UI, and she gets a file which contains 
information in english. 
Now imagine, you need to make a report, which must be in english. Of couse you 
see it in RTL mode.
For the punch line, image you start working with Farsi UI, and then move your 
desktop to some LTR language. The document is almost unreadable and is 
displayed differently.

Imagine konqueror displaying yahoo reversed just because your UI is  in the 
correct direction... ;-)

The direction of the content has nothing to do with the UI language you use. I 
was thinking of this:
when you rename a sheet, instead of only name, you can set the direction to 
RTL/LTR/auto. The auto will be determinnated according to 
sheetname.isRightToLeft(). 

ביום שני, 15 בדצמבר 2003, 05:28, נכתב על ידי Arash Zeini:
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
> http://bugs.kde.org/show_bug.cgi?id=46831
>
>
>
>
> ------- Additional Comments From a.zeini@farsikde.org  2003-12-15 04:28
> ------- I agree with Muunzir. The sheet or fiel name are irrelevant to the
> direction of the sheet. But the --reverse argument is not. I expect KSpread
> to have the sheet direction RTL when I start it with a Farsi UI and LTR
> when started with English for example. I would however still need a
> direction button to change the direction as and when I wish.

Comment 8 Arash Zeini 2003-12-15 23:27:28 UTC
I think, we are misunderstanding each other here. I said that we need a button to change the direction as and when we need. I.e. regardless the direction of the UI.
On the other hand, imagine a secretary that is using the Farsi UI, naming the sheet with a Farsi name, but having contect in English. Or we have the reverse quite often. We have a dozen English-named files that contain pure Farsi content. What to do in these cases? The English name would give you a LTR sheet, but the content would be in RTL. Why force the user to name a file such a way that if influences the correct direction? That doesn't sound like an efficient way.
I think the default sheet direction should go with the UI direction, with the option of changing the direction based on the user choice: i.e. a button.
Comment 9 iastrubn 2003-12-16 12:40:53 UTC
Subject: Re:  reversed bidi sheets in kspread

>------- Additional Comments From a.zeini@farsikde.org  2003-12-15 23:27 -------
>I think, we are misunderstanding each other here. I said that we need a button to change the direction as and when we need. I.e. regardless the direction of the UI.
>On the other hand, imagine a secretary that is using the Farsi UI, naming the sheet with a Farsi name, but having contect in English. Or we have the reverse quite often. We have a dozen English-named files that contain pure Farsi content. What to do in these cases? The English name would give you a LTR sheet, but the content would be in RTL. Why force the user to name a file such a way that if influences the correct direction? That doesn't sound like an efficient way.
>I think the default sheet direction should go with the UI direction, with the option of changing the direction based on the user choice: i.e. a button.
>  
>
this is why the actual implementation is quite bright. if you use a RTL 
desktop, that means that the "sheet" will be translated (if it's not and 
I am wrong I will fix it myself).  and thus the display will be RTL anyway.

In your example. all that secretary has to do is chage the name of the 
sheet to english (double click it only). which she should do anyway, if 
she wants to send the document to someone who does not know Frasi.

KOffice needs a way to overwrite this direction. I agree. Like in kword, 
it should have something on the toolbars. In current versions you can 
change the direction with ctrl shift, but there is not gui for this. I 
will add something like this in kspread also. Wait a few weeks/months. I 
am not sure if this feature can be added in a 1.3.1 version.

Please ask in koffice devel for doing this. (and cc me if you do).



Comment 10 Stephan Kulow 2004-05-25 09:25:24 UTC
Replaced iastrubn@actcom.co.il with null@kde.org due to bounces by reporter
Comment 11 Ariya Hidayat 2004-08-23 15:28:35 UTC
CVS commit by ariya: 

allow to (explicitly) specify layout direction of the worksheet
useful for right-to-left users, e.g. Arabic or Hebrew
TODO: save the setting into document

CCMAIL: 46831@bugs.kde.org
CCMAIL: koffice-devel@mail.kde.org


  M +19 -19    kspread_canvas.cc   1.411
  M +1 -1      kspread_cell.cc   1.620
  M +17 -13    kspread_sheet.cc   1.617
  M +17 -0     kspread_sheet.h   1.294
  M +10 -8     kspread_view.cc   1.781
  M +34 -1     dialogs/sheet_properties.cc   1.6
  M +5 -0      dialogs/sheet_properties.h   1.4
  M +49 -19    dialogs/sheet_properties_base.ui   1.5



Comment 12 Ariya Hidayat 2004-08-24 14:14:42 UTC
CVS commit by ariya: 

load and save sheet's layout direction

CCMAIL: 46831@bugs.kde.org
CCMAIL: koffice-devel@mail.kde.org


  M +20 -4     kspread_sheet.cc   1.618


--- koffice/kspread/kspread_sheet.cc  #1.617:1.618
@@ -6420,4 +6420,5 @@ QDomElement KSpreadSheet::saveXML( QDomD
     QDomElement table = doc.createElement( "table" );
     table.setAttribute( "name", d->name );
+    table.setAttribute( "layoutDirection", (d->layoutDirection == RightToLeft) ? "rtl" : "ltr" );
     table.setAttribute( "columnnumber", (int)d->showColumnNumber);
     table.setAttribute( "borders", (int)d->showPageBorders);
@@ -7670,4 +7671,23 @@ bool KSpreadSheet::loadXML( const QDomEl
     }
 
+    bool detectDirection = true;
+    d->layoutDirection = LeftToRight;
+    QString layoutDir = table.attribute( "layoutDirection" );
+    if( !layoutDir.isEmpty() )
+    {
+        if( layoutDir == "rtl" )
+        {
+           detectDirection = false;
+           d->layoutDirection = RightToLeft;
+        }
+        else if( layoutDir == "ltr" )
+        {
+           detectDirection = false;
+           d->layoutDirection = LeftToRight;
+        }
+    }
+    if( detectDirection )
+       checkContentDirection( d->name );
+
     /* older versions of KSpread allowed all sorts of characters that
        the parser won't actually understand.  Replace these with '_'
@@ -7962,6 +7982,4 @@ bool KSpreadSheet::loadXML( const QDomEl
     }
 
-    checkContentDirection( d->name );
-
     return true;
 }
@@ -8292,6 +8310,4 @@ bool KSpreadSheet::setTableName( const Q
     emit sig_nameChanged( this, old_name );
 
-    checkContentDirection( name );
-
     setName(name.utf8());
     (dynamic_cast<KSpreadSheetIface*>(dcopObject()))->tableNameHasChanged();


Comment 13 Ariya Hidayat 2004-08-29 19:09:21 UTC
CVS commit by ariya: 

use the new SheetPropertiesCommand
it's possible now to undo properties changes

CCMAIL: 46831-done@bugs.kde.org


  M +16 -15    kspread_view.cc   1.786


--- koffice/kspread/kspread_view.cc  #1.785:1.786
@@ -1727,5 +1727,4 @@ void KSpreadView::initView()
       this, SLOT( slotRename() ) );
 
-      
     d->viewLayout->setColStretch( 1, 10 );  
     d->viewLayout->setRowStretch( 2, 10 );  
@@ -3607,18 +3606,17 @@ void KSpreadView::sheetProperties()
     if( dlg->exec() )
     {
-        d->activeSheet->setLayoutDirection( dlg->layoutDirection() );
-        d->activeSheet->setAutoCalc( dlg->autoCalc() );
-        d->activeSheet->setShowGrid( dlg->showGrid() );
-        d->activeSheet->setShowPageBorders( dlg->showPageBorders() );
-        d->activeSheet->setShowFormula( dlg->showFormula() );
-        d->activeSheet->setHideZero( dlg->hideZero() );
-        d->activeSheet->setShowFormulaIndicator( dlg->showFormulaIndicator() );
-        d->activeSheet->setShowColumnNumber( dlg->columnAsNumber() );
-        d->activeSheet->setLcMode( dlg->lcMode() );
-        d->activeSheet->setFirstLetterUpper( dlg->capitalizeFirstLetter() );
-
-        d->doc->addDamage( new SheetDamage( d->activeSheet, SheetDamage::PropertiesChanged ) );
-
-        // FIXME create command & undo object
+        SheetPropertiesCommand* command = new SheetPropertiesCommand( d->doc, d->activeSheet );
+        command->setLayoutDirection( dlg->layoutDirection() );
+        command->setAutoCalc( dlg->autoCalc() );
+        command->setShowGrid( dlg->showGrid() );
+        command->setShowPageBorders( dlg->showPageBorders() );
+        command->setShowFormula( dlg->showFormula() );
+        command->setHideZero( dlg->hideZero() );
+        command->setShowFormulaIndicator( dlg->showFormulaIndicator() );
+        command->setColumnAsNumber( dlg->columnAsNumber() );
+        command->setLcMode( dlg->lcMode() );
+        command->setCapitalizeFirstLetter( dlg->capitalizeFirstLetter() );
+        d->doc->addCommand( command );
+        command->execute();
     }
 
@@ -6650,4 +6648,7 @@ void KSpreadView::handleDamages( const Q
                         b->cellChanged( 0 );
 
+                d->activeSheet->setRegionPaintDirty( QRect(QPoint(0,0), 
+                    QPoint(KS_colMax, KS_rowMax)));
+                    
                 paintUpdates();
                 refreshView();