Bug 85994

Summary: FILEOPEN: DOCX - RTL document incorrectly places frames, images, and shapes on the opposite side
Product: LibreOffice Reporter: mattip <matti.picus>
Component: WriterAssignee: Not Assigned <libreoffice-bugs>
Status: RESOLVED FIXED    
Severity: major CC: aron.budea, fmalotaibi, jluth, kaplanlior, kelemeng, lukebenes, marklh9, ofirr.dev, rb.henschel, stgohi-lobugs, telesto, vmiklos, xiscofauli, zayed.alsaidi
Priority: high Keywords: bibisected, bisected, filter:docx, regression
Version: Inherited From OOo   
Hardware: All   
OS: All   
See Also: https://bugs.documentfoundation.org/show_bug.cgi?id=43093
https://bugs.documentfoundation.org/show_bug.cgi?id=50301
https://bugs.documentfoundation.org/show_bug.cgi?id=94163
https://bugs.documentfoundation.org/show_bug.cgi?id=160833
Whiteboard:
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 104468, 136406, 155489    
Attachments: original docx right-to-left document
correctly formatted PDF document
Simple test case for this bug.
Bug85994-OLE-testcase.docx: Word2007 imports as OLE

Description mattip 2014-11-07 06:12:56 UTC
Created attachment 109074 [details]
original docx right-to-left document

The docx attatchment is not sidplayed properly, some objects are right-aligned when they should be left-aligned.
Comment 1 mattip 2014-11-07 06:14:38 UTC
Created attachment 109075 [details]
correctly formatted PDF document

The correctly formatted document as PDF
Comment 2 A (Andy) 2014-11-08 11:37:26 UTC
Buggy behaviour with severals bugs reproducible with LO 4.3.3.2, Win 8.1:

- Cloud is missing and cloud text is far right-aligned instead of left
- In some parts the text format was changed
- Number pictures are left-aligned instead of right
- Degree numbers and latin characters pictures aligned at the wrong height
- Geometric pictures are right-aligned instead of left
- Parallelogram has a solid instead of interrupted line


@Miklós: I don't know, but could this maybe be something you are interested in?
Comment 3 QA Administrators 2015-12-20 16:16:03 UTC Comment hidden (obsolete)
Comment 4 A (Andy) 2015-12-26 22:52:07 UTC
Still reproducible with LO 5.1.0.1, Win 8.1
Comment 5 Luke 2016-01-09 23:51:58 UTC
Created attachment 121825 [details]
Simple test case for this bug.

The primary issue here is that images are being horizontally flipped. Images that belong on the left are going on the right and vice versa. This is a regression, as I cannot reproduce it on Version: 4.1.0.1.

In my simplified test case, the text box labeled left belongs on the left, while right belongs on the right.
Comment 6 Justin L 2016-08-19 11:17:36 UTC Comment hidden (off-topic)
Comment 7 Justin L 2016-08-19 12:21:52 UTC
Sorry - last comment somehow unintentionally saved.

fixed between 40 and 41
# good: [5457c4d7182e205be50db8a2dacf0719e1b2f94e] source-hash-f48a576ff2c4f2ebd20b681d0c9b8233fe674a9d
# first bad commit: [49b5642bdadfcc7dbe5c8af62340a7b66410a797] source-hash-1981819e81c1ad51b607d6af19e4e3776a74c75b

Likely fixes:
https://cgit.freedesktop.org/libreoffice/core/commit/?id=d225318ead0154681982656bcd3e98011e022c34
OR
https://cgit.freedesktop.org/libreoffice/core/commit/?id=becb244b4974609b0570e8db27d74e7e1179181c


broken between 41 and 42 by:
https://cgit.freedesktop.org/libreoffice/core/commit/?id=aa52753785154f0e95fed559f613f5eae9105dcf

-        // Value should not always be 'true'
-        //OOXMLValue::Pointer_t pValue(new OOXMLBooleanValue(true));
-        bool bSet = true;
-
-        // Paragraph properties are not always 'true' by default
-        // For example - RTL layout of paragraph is by default 'false' (look in this link for 'sprmPFBiDi')
-        // http://msdn.microsoft.com/en-us/library/dd923496%28v=office.12%29.aspx
-        if (getId() == NS_sprm::LN_PFBiDi)
-        {
-                bSet = false;
-        }
-
-        OOXMLValue::Pointer_t pValue(new OOXMLBooleanValue(bSet));
+        OOXMLValue::Pointer_t pValue(new OOXMLBooleanValue(true));
Comment 8 Justin L 2016-08-20 15:56:55 UTC
Note to developers - make sure you check test1.docx frequently during development - the textbox placement is easily fixed by breaking the RTL setting. The RTL setting was NOT right in 4.1 - basically either the images/textboxes are right or RTL is right but not both simultaneously.

NS_ooxml::LN_CT_PPrBase_bidi is the current version of NS_sprm::LN_PFBiDi

I think the fix will have to be somewhere in the display, not in writerfilter. DomainMapper::getPositionOffset() seems to be the only potential modification point in writerfilter, but do we know anything about the shape itself at that point in order to adjust the Point?
Comment 9 Justin L 2016-08-22 17:52:39 UTC
Created attachment 126973 [details]
Bug85994-OLE-testcase.docx: Word2007 imports as OLE

Bug85994-testcase.docx from Comment 5 imports as a GraphicImport. I tweaked it to add some visual features in Word 2007 and saved it - now it imports as an OLE object exhibiting the same symptom.
Comment 10 Björn Michaelsen 2016-08-24 22:00:33 UTC
Assuming bisected to imply bibisected, thus adding the latter. This is to make queries for "bibisected" not miss out bisected bugs.
Comment 11 Xisco Faulí 2016-12-05 15:57:55 UTC
*** Bug 104393 has been marked as a duplicate of this bug. ***
Comment 12 Xisco Faulí 2016-12-14 11:11:51 UTC
*** Bug 104673 has been marked as a duplicate of this bug. ***
Comment 13 Xisco Faulí 2017-02-23 09:52:57 UTC
*** Bug 106138 has been marked as a duplicate of this bug. ***
Comment 14 Luke 2017-02-23 20:46:35 UTC
Based on the dupes this seems to be an issue affecting many people. Bumping the priority.
Comment 15 Lior Kaplan 2017-10-12 10:30:47 UTC Comment hidden (obsolete)
Comment 16 Omer Zak 2017-11-05 12:17:59 UTC Comment hidden (obsolete)
Comment 17 QA Administrators 2018-11-06 03:56:05 UTC Comment hidden (obsolete)
Comment 18 Luke 2018-11-06 16:29:44 UTC
still reproducible in Version: 6.2.0.0.alpha1+ (x64)
Build ID: 485efed71807ecee5ce69fa556db98dbc78a97e5

Mark,
You've been active in the RTL area recently. Is this issue something you'd be interested in looking at?
Comment 19 Regina Henschel 2019-04-06 14:08:32 UTC
*** Bug 114948 has been marked as a duplicate of this bug. ***
Comment 20 Zayed 2019-11-21 14:41:37 UTC
I have test this bug with 6.4.0.0.beta1. It has still unresolved !
Comment 21 Justin L 2021-01-14 18:39:53 UTC
(In reply to Justin L from comment #8)
> Note to developers - make sure you check test1.docx frequently 
Note that the comment 0 attachment is named test1.doc, but really it is a docx format.
Comment 22 Aron Budea 2021-01-14 20:54:48 UTC
Comment on attachment 109074 [details]
original docx right-to-left document

(In reply to Justin L from comment #21)
> Note that the comment 0 attachment is named test1.doc, but really it is a
> docx format.
Let's see if adjusting the details for it helps.
Comment 23 QA Administrators 2023-01-15 03:23:23 UTC Comment hidden (spam)
Comment 24 Gabor Kelemen (allotropia) 2024-05-16 20:43:48 UTC
These files seem to look right now, according to linux-bibisect after:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=01dcc9a652ecfc65fb674b492afa6f58b0a846db

author	Miklos Vajna <vmiklos@collabora.com>	2024-05-02 08:42:25 +0200
committer	Miklos Vajna <vmiklos@collabora.com>	2024-05-02 12:08:31 +0200
commit 01dcc9a652ecfc65fb674b492afa6f58b0a846db (patch)

tdf#160833 DOCX import: use the DoNotMirrorRtlDrawObjs compat flag