summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2024-08-24 16:50:06 -0400
committerMiklos Vajna <vmiklos@collabora.com>2024-08-26 11:54:13 +0200
commitc8e272734a8fa26d93b057d1c9def8dc6c401143 (patch)
tree9a1cc17feef0d974c725fc51efbab23df559a453 /sw/qa/extras
parent1cf86074147e89da880d539055b1804ca135b679 (diff)
tdf#162612 mso import NOT-layoutInCell: effectively are wrap-through
The way Microsoft implements the layout of in-table-anchored shapes that are NOT marked as layoutInCell is to treat them all as wrap-through. So, lets explicitly mark them as they ought to be during import. tdf154863-img-move-crash.docx is a fine example of this, although the document itself is ugly and too complex for a unit test. make CppunitTest_sw_ooxmlexport21 CPPUNIT_TEST_NAME=testTdf162612 make CppunitTest_sw_ww8export4 CPPUNIT_TEST_NAME=testTdf162541 There is a SLIGHT danger here, as shown by testTdf162541. LO looks VERY different from Microsoft's VERY WEIRD LAYOUT, but will "correct" it with a round-trip. I'm not too concerned - LO is exporting the document the way it sees it. Change-Id: I14d8ea9dcef257a3239a9601b63c04cde780cb33 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172364 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf162612_notLayoutInCell_notWrapThrough_contourOpaque.docxbin0 -> 35416 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport21.cxx21
-rw-r--r--sw/qa/extras/ww8export/ww8export4.cxx7
3 files changed, 28 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf162612_notLayoutInCell_notWrapThrough_contourOpaque.docx b/sw/qa/extras/ooxmlexport/data/tdf162612_notLayoutInCell_notWrapThrough_contourOpaque.docx
new file mode 100644
index 000000000000..dae6163b2af3
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf162612_notLayoutInCell_notWrapThrough_contourOpaque.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index f07c93a04e0e..32892540e734 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -14,6 +14,7 @@
#include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
+#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/text/XDocumentIndex.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/style/LineSpacing.hpp>
@@ -724,6 +725,26 @@ DECLARE_OOXMLEXPORT_TEST(testTdf162551, "tdf162551_notLayoutInCell_charLeft_from
CPPUNIT_ASSERT(getProperty<bool>(getShape(1), u"IsFollowingTextFlow"_ustr));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf162612,
+ "tdf162612_notLayoutInCell_notWrapThrough_contourOpaque.docx")
+{
+ // given cell B2 with a centered, tight-wrapped image that is NOT layoutInCell
+ // (but Microsoft doesn't wrap any text around it)
+ xmlDocUniquePtr pDump = parseLayoutDump();
+ CPPUNIT_ASSERT_EQUAL(OUString("-anchor point-"),
+ getXPathContent(pDump, "//tab/row[2]/cell[2]/txt"_ostr));
+ sal_Int32 nParaHeight
+ = getXPath(pDump, "//tab/row[2]/cell[2]/txt/infos/bounds"_ostr, "height"_ostr).toInt32();
+ // text should not wrap as two lines(552) beside the shape. It is one line(276) behind the shape
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(276), nParaHeight);
+
+ // the image is over top of the text
+ CPPUNIT_ASSERT(getProperty<bool>(getShape(1), u"Opaque"_ustr));
+ // image should be wrapThrough, not PARALLEL (despite being wp:wrapTight wrapText="bothSides")
+ CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH,
+ getProperty<text::WrapTextMode>(getShape(1), u"Surround"_ustr));
+}
+
CPPUNIT_TEST_FIXTURE(Test, testTdf159207_footerFramePrBorder)
{
loadFromFile(u"tdf159207_footerFramePrBorder.docx"); // re-imports as editeng Frame/Shape
diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx
index 007e7f70cac4..084eb178af6a 100644
--- a/sw/qa/extras/ww8export/ww8export4.cxx
+++ b/sw/qa/extras/ww8export/ww8export4.cxx
@@ -209,6 +209,13 @@ DECLARE_WW8EXPORT_TEST(testTdf162541, "tdf162541_notLayoutInCell_paraLeft.doc")
CPPUNIT_ASSERT(nShapeLeft < nParaLeft); // shape is located in column A, not column B
CPPUNIT_ASSERT_EQUAL(nTableLeft, nShapeLeft);
CPPUNIT_ASSERT(!getProperty<bool>(getShape(1), u"IsFollowingTextFlow"_ustr));
+
+ // tdf#162612
+ // Note that this round-trip will "fix" the weird splitting table around the image...
+
+ // image should be wrapThrough, not PARALLEL (despite being wrapTight on largest side)
+ CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH,
+ getProperty<text::WrapTextMode>(getShape(1), u"Surround"_ustr));
}
DECLARE_WW8EXPORT_TEST(testTdf162542, "tdf162542_notLayoutInCell_charLeft_wrapThrough.doc")