diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-05-03 13:54:02 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-05-03 16:28:04 +0200 |
commit | 9d95eb980ef12678f6fb978badcbe1cacbe0c4dc (patch) | |
tree | 98dedcaec34daceb674159d8c31c2877987ad9ef | |
parent | 83c2ef7c78d1453cc0419fd27a8c1418f90c12a3 (diff) |
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 <vmiklos@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | sw/qa/extras/ww8export/data/draw-obj-rtl-no-mirror-vml.docx | bin | 0 -> 14534 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export4.cxx | 24 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 6 |
3 files changed, 30 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 000000000000..3b291901f72d --- /dev/null +++ b/sw/qa/extras/ww8export/data/draw-obj-rtl-no-mirror-vml.docx 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); |