Bug 154450 - Incorrect symbol for images in RTL languages
Summary: Incorrect symbol for images in RTL languages
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.5.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: needsDevAdvice
Depends on:
Blocks: RTL-CTL RTL-UI
  Show dependency treegraph
 
Reported: 2023-03-29 15:04 UTC by Kurosh Tavassoli
Modified: 2023-11-25 00:50 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
The bug indication (118.44 KB, image/png)
2023-03-29 15:31 UTC, Kurosh Tavassoli
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kurosh Tavassoli 2023-03-29 15:04:40 UTC
Description:
Wrong symbol for placing images which can be misleading specially for beginners.

Steps to Reproduce:
1. Try to place an image "After text" while selecting the "image after text" option from menu. Its impossible! You should actually select "image before text"! 

Actual Results:
I got confused for some time.

Expected Results:
Swap "image after text" and "image before text"


Reproducible: Always


User Profile Reset: No

Additional Info:
Look at the attached screenshot!
Comment 1 Kurosh Tavassoli 2023-03-29 15:31:14 UTC
Created attachment 186291 [details]
The bug indication
Comment 2 Eyal Rozenberg 2023-04-04 22:57:37 UTC
Well, actually, "After" seems like "Text after image" in LTR mode...

but it's true that the graphic doesn't change when the paragraph direction is flipped.

However - the problem is even worse than you think. It's possible for the same object to overlap more than one paragraph - and one might be LTR while the other is RTL. What image would be used then? And what is the user's intent w.r.t. wrapping in that case?

So, this is not just a problem with the icon on the toolbar or in the dialog (which is an issue of course), but a deeper one as well.
Comment 3 Heiko Tietze 2023-04-05 07:43:16 UTC
Rizal, what do you think?
Comment 4 Kurosh Tavassoli 2023-04-05 08:57:49 UTC
@Eyal Rozenberg

I think we can look at where the image in anchored. If it is anchored to a RTL paragraph or RTL character then the icons need to be swapped. What do you think?
Comment 5 Rizal Muttaqin 2023-06-23 23:21:19 UTC
(In reply to Heiko Tietze from comment #3)
> Rizal, what do you think?

Generally speaking, current non LTR icon behaviour is suboptimal. I would like to see proper RTL support for icon themes from coding point of view. Currently, many icons just flipped horizontally for RTL text and 90 degrees clockwise for top to bottom text. See tdf#149956. 

Instead of using the flipping method above, I suggest that LibreOffice intelligently recognizes the RTL content and then instructs it to use a separate RTL version of the icon file. Say for example lc_defaultnumbering.<png|svg> for LTR content, then there's lc_defaultnumberingrtl.<png|svg> for RTL one.


The only way I as an icon designer can change the appearance of an icon from LTR to RTL is to use a localized variant. For example I created some RTL icons in cmd/ar/ and cmd/32/ar directories for Arabic (and linking it for Hebrew, Urdu and Parsi). This is actually quite problematic, however, because there is no guarantee that users of Arabic RTL text will definitely use the Arabic interface. It is possible that the interface used is American English while the content produced is RTL text.

Then the localized icons that I made became even more messy when given the flipping treatment.
Comment 6 Rizal Muttaqin 2023-06-23 23:25:35 UTC
Apologize, I should probably refer to tdf#70102

(In reply to Rizal Muttaqin from comment #5)
> See tdf#149956.
Comment 7 Rizal Muttaqin 2023-06-23 23:28:16 UTC
(In reply to Rizal Muttaqin from comment #5)

> lc_defaultnumberingrtl.<png|svg> for RTL one.

or maybe lc_defaultnumbering-rtl.<png|svg> / lc_defaultnumbering_rtl.<.png|svg> for reading convenience
Comment 8 Heiko Tietze 2023-11-22 09:39:09 UTC
Let's add RTL specific icons (in addition to the language specific).

Caolan, easyhack or GSoC project?
Comment 9 Caolán McNamara 2023-11-22 10:00:48 UTC
We do have some places where we swap the images depending on RTL. But as far as I know we do it based on the UI language and not the "current" direction of text. So see:

framework/source/fwe/xml/toolboxdocumenthandler.cxx sfx2/source/sidebar/SidebarToolBox.cxx sfx2/source/toolbox/weldutils.cxx sfx2/source/toolbox/weldutils.cxx

and search for uno:ParaLeftToRight and see the swap to ParaRightToLeft (etc) when AllSettings::GetLayoutRTL is true and references to bug #39370 as an example.

So I think it could be:

a) An easy hack to at least centralize those existing different places into one piece of code so we have just one copy of the swapping image name logic

b) Assuming that the current swapping images idea is a good thing, then the question is if we should be changing those images depending on the current language/direction context. Some competitive comparison might be helpful to find out there, what do other similar products do, or anything seen as "doing the right thing".

We do have QueryState which decides if a given toolbox item is enabled/disabled etc in the current context. I could see us adding another thing that can be queried (Or maybe we already have one, isn't there some paragraph direction toolbox item somewhere, does that generally give a single result, or how does it handle ambiguity right now?) to get an answer for the RTL in the context that could be used to do this swapping basically dynamically instead of just the UI direction.
Comment 10 Heiko Tietze 2023-11-22 10:41:58 UTC
(In reply to Caolán McNamara from comment #9)
> We do have some places where we swap the images depending on RTL.
But we mirror the existing image and do not use some special icon, right? The proposal is to have this opportunity.
Comment 11 Caolán McNamara 2023-11-22 11:58:38 UTC
Yes we currently use a different icon from a equivalent command for the other direction so we look for something that will appear flipped IIRC. In either case of the existing hackery or new proposal I don't think we currently take current context into account, only the UI mode
Comment 12 Rizal Muttaqin 2023-11-25 00:50:01 UTC
My proposal:

Change the behavior. When detecting RTL content switch icons to proper icon files instead of flipping them and remove unnecessary RTL icons that resides in all RTL UI languages (Arabic, Hebrew, Parsi, Urdu).