Apache OpenOffice (AOO) Bugzilla – Issue 37905
Mixed Hebrew/English text rendered incorrectly (text direction "context")
Last modified: 2013-08-07 15:12:27 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.
Created attachment 19692 [details] Spreadsheet as it appears in Excel
Created attachment 19693 [details] Spreadsheet as it appears in Calc
Created attachment 19694 [details] The Excel spreadsheet
Hi Henning, Daniel told me that this seems to be a problem of the Edit engine. So it's your turn now. Frank
set target
FME->DR: As discussed, the Excel setting "text direction: context" is not equivalent to "text direction: environment" in Calc.
*** Issue 30158 has been marked as a duplicate of this issue. ***
Needs a new entry in the Cell format dialog -> incompatible from SVX -> must be set to OOo Later
ayaniger -> dr: I'm checking in m113 on Windows, and this appears to be fixed. Could you take a look?
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.
Created attachment 28664 [details] Test document for CTL text direction
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?
Created attachment 33101 [details] OOo incorrectly aligns cells to the left in this spreadsheet
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
Created attachment 40078 [details] Imports Hebrew default-aligned cells correctly
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.
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.
Created attachment 40336 [details] Solves import problem, doesn't change anything else
Created attachment 40337 [details] Solves import problem, doesn't change anything else (mime type corrected)
@dr: Did you check ayaniger's patch ? It here for a year and a half...
Look OK for me with OpenOffice.org 3.2.1 (OOO320m19) from Debian. Can anyone else confirm?
@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
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.
Created attachment 71237 [details] textdirection_import_biff8.xls with 3.2.0 on windows
Created attachment 71238 [details] textdirection_import_biff8.xls with 3.2.1 on debian
Created attachment 71239 [details] textdirection_import_biff8.xls with excel 2003
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".