sw/qa/extras/ww8export/data/draw-obj-rtl-no-mirror-vml.docx |binary sw/qa/extras/ww8export/ww8export4.cxx | 24 ++++++++++++ sw/source/filter/ww8/wrtw8esh.cxx | 6 +++ 3 files changed, 30 insertions(+)
New commits: commit 9d95eb980ef12678f6fb978badcbe1cacbe0c4dc Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri May 3 13:54:02 2024 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri May 3 16:28:04 2024 +0200 Related: tdf#160833 teach DOC export about DoNotMirrorRtlDrawObjs See <https://gerrit.libreoffice.org/c/core/+/167033/1#message-e1df9bf60b7b8b2acdf0c062484ddc572939a3d9>, no need to undo the import-time mapping in case we know that the mirroring is avoided at a layout level. Change-Id: Idbdc10ad327540dc5045e9b19dd42160b5139470 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167049 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/extras/ww8export/data/draw-obj-rtl-no-mirror-vml.docx b/sw/qa/extras/ww8export/data/draw-obj-rtl-no-mirror-vml.docx new file mode 100644 index 000000000000..3b291901f72d Binary files /dev/null and b/sw/qa/extras/ww8export/data/draw-obj-rtl-no-mirror-vml.docx differ diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx index d3bc9c4071d9..6caffceffa00 100644 --- a/sw/qa/extras/ww8export/ww8export4.cxx +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -267,6 +267,30 @@ CPPUNIT_TEST_FIXTURE(Test, testLegalNumbering) verify(); } +CPPUNIT_TEST_FIXTURE(Test, testDOCExportDoNotMirrorRtlDrawObjs) +{ + // Given a document with a shape, anchored in an RTL paragraph, loaded from DOCX: + createSwDoc("draw-obj-rtl-no-mirror-vml.docx"); + + // When saving that to DOC: + saveAndReload(mpFilter); + + // Then make sure the shape is on the right margin: + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nPageRight = getXPath(pXmlDoc, "//page/infos/bounds"_ostr, "right"_ostr).toInt32(); + sal_Int32 nBodyRight = getXPath(pXmlDoc, "//body/infos/bounds"_ostr, "right"_ostr).toInt32(); + sal_Int32 nShapeLeft + = getXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds"_ostr, "left"_ostr).toInt32(); + CPPUNIT_ASSERT_GREATER(nBodyRight, nShapeLeft); + sal_Int32 nShapeRight + = getXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds"_ostr, "right"_ostr).toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected less than: 12523 + // - Actual : 12536 + // i.e. the shape was outside of the page right margin area, due to an unwanted mapping. + CPPUNIT_ASSERT_LESS(nPageRight, nShapeRight); +} + DECLARE_WW8EXPORT_TEST(testNonInlinePageBreakFirstLine, "nonInlinePageBreakFirstLine.doc") { SwDoc* pDoc = getSwDoc(); diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index c13d06106286..21afd78cce1d 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -576,6 +576,12 @@ void WW8Export::MiserableRTLFrameFormatHack(SwTwips &rLeft, SwTwips &rRight, if (SvxFrameDirection::Horizontal_RL_TB != m_rDoc.GetTextDirection(rFrameFormat.GetPosition())) return; + if (m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_MIRROR_RTL_DRAW_OBJS)) + { + // Swap is handled at a layout-level, no need to compensate for it at export time. + return; + } + SwTwips nWidth = rRight - rLeft; SwTwips nPageLeft, nPageRight; SwTwips nPageSize = CurrentPageWidth(nPageLeft, nPageRight);