Issue 37905

Summary: Mixed Hebrew/English text rendered incorrectly (text direction "context")
Product: Calc Reporter: alan
Component: open-importAssignee: AOO issues mailing list <issues>
Status: ACCEPTED --- QA Contact:
Severity: Trivial    
Priority: P3 CC: issues, kaplanlior, khirano, xslf, yba
Version: 680m62   
Target Milestone: ---   
Hardware: All   
OS: Windows XP   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---
Attachments:
Description Flags
Spreadsheet as it appears in Excel
none
Spreadsheet as it appears in Calc
none
The Excel spreadsheet
none
Test document for CTL text direction
none
OOo incorrectly aligns cells to the left in this spreadsheet
none
Imports Hebrew default-aligned cells correctly
none
Solves import problem, doesn't change anything else
none
Solves import problem, doesn't change anything else (mime type corrected)
none
textdirection_import_biff8.xls with 3.2.0 on windows
none
textdirection_import_biff8.xls with 3.2.1 on debian
none
textdirection_import_biff8.xls with excel 2003 none

Description alan 2004-11-25 19:21:20 UTC
After importing an Excel spreadsheet with mixed Hebrew/English text, the Hebrew 
text which should be on the right appears on the left, and vice versa. Note the 
English letter "k" in the middle of the text. The Hebrew word to its right in 
Excel has moved to the left, and the space between the word and the "k" has 
disappeared.
Comment 1 alan 2004-11-25 19:22:01 UTC
Created attachment 19692 [details]
Spreadsheet as it appears in Excel
Comment 2 alan 2004-11-25 19:22:33 UTC
Created attachment 19693 [details]
Spreadsheet as it appears in Calc
Comment 3 alan 2004-11-25 19:23:27 UTC
Created attachment 19694 [details]
The Excel spreadsheet
Comment 4 frank 2005-01-14 11:01:05 UTC
Hi Henning,

Daniel told me that this seems to be a problem of the Edit engine.

So it's your turn now.

Frank
Comment 5 openoffice 2005-01-20 09:32:30 UTC
set target
Comment 6 frank.meies 2005-02-03 09:55:19 UTC
FME->DR: As discussed, the Excel setting "text direction: context" is not
equivalent to "text direction: environment" in Calc.
Comment 7 oc 2005-02-16 11:53:03 UTC
*** Issue 30158 has been marked as a duplicate of this issue. ***
Comment 8 daniel.rentz 2005-04-19 15:56:23 UTC
Needs a new entry in the Cell format dialog -> incompatible from SVX -> must be 
set to OOo Later
Comment 9 alan 2005-08-01 11:07:56 UTC
ayaniger -> dr: I'm checking in m113 on Windows, and this appears to be fixed.
Could you take a look?
Comment 10 daniel.rentz 2005-08-11 14:32:24 UTC
Looks better now, but not perfect.

Calc still cannot handle the text direction "Context" known form Excel. This setting 
simply sets the cell to right-to-left, if the string starts with a character from a CTL 
script (hebrew, arabic), and sets the cell to left-to-right, if the string starts with 
another character.

I will attach one of my test documents. Note the 2 cells that have "Context" set as 
text direction.
Comment 11 daniel.rentz 2005-08-11 14:33:47 UTC
Created attachment 28664 [details]
Test document for CTL text direction
Comment 12 alan 2006-01-11 07:58:30 UTC
In the attached Excel spreadsheet tmp_dan.xls, cells which should be aligned to
left are aligned to right. This seems is similar to the problem of Issue 30158,
which was closed as a duplicate of this issue. 
This is a problem that RTL users see very frequently. Since over a year has
passed since this issue was filed, and almost two years since Issue 30158 was
filed, can we raise the priority and the target milestone?
Comment 13 alan 2006-01-11 08:00:24 UTC
Created attachment 33101 [details]
OOo incorrectly aligns cells to the left in this spreadsheet
Comment 14 alan 2006-10-26 14:32:47 UTC
With the attached patch, all of the sample documents attached to this issue and
to issue 30158 import correctly.

The code makes two changes on OO's behavior:

1. The default alignment of cells which begin with a Hebrew letter is to the
right, like Excel, and unlike the distributed OOo. I don't know whether Excel
behaves this way for all RTL languages, but this is Excel's behavior for Hebrew,
so the patch tests only for Hebrew.

2. In an imported Excel document, mixed-text cells beginning with a non-Hebrew
char and with "Context" text-direction will have the text direction set to LTR.
This is the case in cell C5 of the sample document "textdirection_import_biff8.xls".

There is still a problem - when editing a cell with default alignment, the text
in the grid becomes left-aligned even for Hebrew, for the duration of the edit.
(This is only a problem on the grid, not in the input edit box above the grid.)
Once the editing is finished, the alignment reverts back to the correct form.

For more discussion, see the thread at:
http://sc.openoffice.org/servlets/BrowseList?list=dev&by=thread&from=1546467
Comment 15 alan 2006-10-26 14:37:13 UTC
Created attachment 40078 [details]
Imports Hebrew default-aligned cells correctly
Comment 16 alan 2006-10-29 16:50:55 UTC
I received a comment asking for justification in changing OOo's default
alignment based on content. As "dr" pointed out in his comment of April 2005,
what is needed is a new type of SVX alignment, and this is not a simple matter
to implement. Since there hasn't been movement on the issue since then, and the
target remains "OOo Later", I assume that the change is not likely to happen
soon. Under the current circumstances, any Hebrew Excel spreadsheet that uses
Excel's default alignment (which is probably most of them) will be distorted if
not unreadable. This is why I thought that changing the behavior of
"ENVIRONMENT" for RTL was the best way to go. I would appreciate it if you would
review and integrate the patch, or implement an alternative, since at present
import of Hebrew Excel spreadsheets is usually broken.
Comment 17 alan 2006-11-05 08:01:31 UTC
I reviewed my own patch, and decide that it's better not to change the default
alignment of RTL cells. Here's a simpler patch, which solves the import problem,
but doesn't change the behavior of RTL cells in Calc.
Comment 18 alan 2006-11-05 08:06:46 UTC
Created attachment 40336 [details]
Solves import problem, doesn't change anything else
Comment 19 alan 2006-11-05 08:07:53 UTC
Created attachment 40337 [details]
Solves import problem, doesn't change anything else (mime type corrected)
Comment 20 kaplanlior 2008-05-08 20:21:57 UTC
@dr: Did you check ayaniger's patch ? It here for a year and a half...
Comment 21 kaplanlior 2010-08-14 21:54:43 UTC
Look OK for me with OpenOffice.org 3.2.1 (OOO320m19) from Debian. Can anyone
else confirm?
Comment 22 shlomif 2010-08-20 21:52:46 UTC
@kaplan: on Mandriva Linux Cooker with openoffice.org-common-3.2-4mdv2010.1 ,
I'm getting the offending behaviour upon typing:

$ ooffice3.2 Mixed\ Text.xls

I.e: I'm getting "He{Eivarim} La{k} He{Behirath}" instead of "He{Behirath} La{k}
He{Eivarim}".

This can be fixed by pressing the "Right-To-Left" button.

Regards,

-- Shlomi Fish
Comment 23 kaplanlior 2010-08-21 12:32:33 UTC
Update:
Checking Mixed Text.xls which oo.org 3.2.0 (windows) on windows and 2.3.1
(debian) both look as excel 2003 on windows.

Checking textdirection_import_biff8.xls doesn't looks the same comparing to
Excel 2003. The funny thing is that 3.2.0 on windows looks different from 3.2.1
on debian. And they both differ from Excel. Weird.
Comment 24 kaplanlior 2010-08-21 12:34:15 UTC
Created attachment 71237 [details]
textdirection_import_biff8.xls with 3.2.0 on windows
Comment 25 kaplanlior 2010-08-21 12:34:53 UTC
Created attachment 71238 [details]
textdirection_import_biff8.xls with 3.2.1 on debian
Comment 26 kaplanlior 2010-08-21 12:35:19 UTC
Created attachment 71239 [details]
textdirection_import_biff8.xls with excel 2003
Comment 27 netanel 2010-08-22 14:13:08 UTC
The screenshot of textdirection_import_biff8.xls with 3.2.0 on windows is also
the same for OO3.3-Beta1.

According to the screenshots, "OS:" has to be changed from "Windows XP" to "all".