Bug 32530 - Text alignment should be inferred from text directionality
Summary: Text alignment should be inferred from text directionality
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: medium normal
Assignee: Kohei Yoshida
QA Contact:
URL:
Whiteboard: target:3.5 target:4.3.0
Keywords:
Depends on:
Blocks: RTL-CTL
  Show dependency treegraph
 
Reported: 2010-12-20 10:56 UTC by Eyal
Modified: 2014-04-10 16:37 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample output from Excel and LibreOffice (3.70 KB, image/gif)
2010-12-20 10:56 UTC, Eyal
Details
Calc sheet with both LTR and RTL text (8.76 KB, application/vnd.oasis.opendocument.spreadsheet)
2010-12-21 23:11 UTC, Eyal
Details
still the same problem if the tab is rtl (2.11 KB, image/png)
2014-01-12 11:50 UTC, Abdulaziz Ayed
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eyal 2010-12-20 10:56:28 UTC
Created attachment 41302 [details]
Sample output from Excel and LibreOffice

Currently when text is entered into an empty cell, it is aligned to the left of the cell. This is correct for text in Left to Right (LTR) languages such as English, but wrong for text in Right to Left (RTL) languages such as Hebrew.

The alignment of text should be inferred from the directionality of the entered text, specifically from the directionality of the first character (as text may contain a mix of RTL and LTR characters).

As RTL text is mis-aligned by default, users need to manually correct the alignment of all affected cells. It's of course possible to set the alignment of all cells to the Right, but then cells containing LTR text must be manually corrected.

For reference, Excel does align the text correctly.

Eyal.
Comment 1 Netanel_H 2010-12-21 08:03:59 UTC
This is 
http://www.openoffice.org/issues/show_bug.cgi?id=72028
It also has a patch upstream, but no progress since 2007.
Comment 2 Jan Holesovsky 2010-12-21 08:53:27 UTC
Kohei: Can you please review the patch from the OOo bugzilla, and apply if OK?
Comment 3 Kohei Yoshida 2010-12-21 11:35:52 UTC
Hmm.... I don't think that patch is the right approach, because that would only work when the system locale is RTL, not when the sheet is set to RTL (cf. Format - Sheet - Right-to-Left).  Also, that would set the horizontal alignment for the default cell style to right.  But what I *think* we need to do is to render text right-aligned when

* the text direction of the sheet is right-to-left, and
* the horizontal alignment is set to 'Default'.
Comment 4 Kohei Yoshida 2010-12-21 11:37:51 UTC
Eyal, could you attach a small sample document with some RTL text in a cell?  Thanks.
Comment 5 Eyal 2010-12-21 23:10:18 UTC
The sheet direction should not determine the alignment. Even when the sheet is RTL, many cells still contain left-to-right values such as numbers, Latin text, email addresses, etc.

I suggest to align text as follows:

* When horizontal alignment is default -
* If the first char is RTL (eg. Hebrew letter) - align to right.
* Otherwise (eg. English letter, digit) - align to left.

I've attached a file with both English and Hebrew text. Note that you need to have support for complex scripts and/or RTL langauges enabled in your operating system.

Eyal
Comment 6 Eyal 2010-12-21 23:11:12 UTC
Created attachment 41360 [details]
Calc sheet with both LTR and RTL text
Comment 7 Kohei Yoshida 2011-11-30 14:13:59 UTC
I'd like to take a look at this for 3.5 if possible.
Comment 8 Kohei Yoshida 2011-12-12 12:50:49 UTC
Hopefully I got it right.

http://cgit.freedesktop.org/libreoffice/core/commit/?id=66778dd58d69426d527edd6ea5d847ce62c950ac

The fix landed on master and libreoffice-3-5 branch.  3.5 Beta2 will have the fix incorporated.
Comment 9 Lior Kaplan 2011-12-24 07:11:33 UTC
Verified in 3.5.0 beta2. Thanks for the fix (:
Comment 10 Abdulaziz Ayed 2014-01-12 11:50:18 UTC
Created attachment 91895 [details]
still the same problem if the tab is rtl
Comment 11 Abdulaziz Ayed 2014-01-12 12:14:31 UTC
change status based on comment 10
Comment 12 Commit Notification 2014-01-12 13:42:07 UTC
Abdulaziz A Alayed committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f08c1edc0a99e0c29fb1614162d3e88c5660e092

fdo#32530 calc:alignment depend on 1st char direct



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 13 Kohei Yoshida 2014-01-12 16:05:37 UTC
Please do not reopen such an old bug report. Create a new one and work there please.
Comment 14 Commit Notification 2014-01-13 12:35:40 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c6d5433c673f592c3fda4270df66fff6c667d021

Revert "fdo#32530 calc:alignment depend on 1st char direct"



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 15 Eike Rathke 2014-04-10 16:37:55 UTC
For the records, the follow-up appears to be bug 73588 (fixed).