summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2024-03-06 18:56:55 -0500
committerMiklos Vajna <vmiklos@collabora.com>2024-03-08 10:59:36 +0100
commitd210667c72ff821b8cb50b386a83ed55d65ae9bf (patch)
tree20b0fedf8ed9f9a3ecf6bc2a345adfef2977e169 /sw
parent34daf30c7a02208408b83a8ff872736b98a732e0 (diff)
tdf#160077 writerfilter: shape vertRelation is FRAME for layoutinCell
When layoutInCell is active, then the offset must be applied against the paragraph instead of the page or page margins. There were only two unit tests that matched this, and both were off-sheet positioned. -tdf151704_thinColumnHeight.docx -tdf92157.docx make CppunitTest_sw_ooxmlexport21 \ CPPUNIT_TEST_NAME=testTdf160077_layoutInCell Change-Id: I28241136c0c0be12d3f2dd876550ecdf91b0009c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164514 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf160077_layoutInCell.docxbin0 -> 22479 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport21.cxx27
2 files changed, 27 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf160077_layoutInCell.docx b/sw/qa/extras/ooxmlexport/data/tdf160077_layoutInCell.docx
new file mode 100644
index 000000000000..811fc47e184c
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf160077_layoutInCell.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index fcb2eea321c9..5e320bb6d743 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -354,6 +354,33 @@ DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMargin15, "tdf160049_anchorMargin15
getProperty<sal_Int16>(getShape(1), "HoriOrientRelation"));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf160077_layoutInCell, "tdf160077_layoutInCell.docx")
+{
+ // given an in-table, slightly rotated image vertically aligned -1cm (above) the top page margin
+ // (which is actually forced to layoutInCell, so that becomes 1cm above the paragraph instead)
+
+ xmlDocUniquePtr pDump = parseLayoutDump();
+ const sal_Int32 nCellTop
+ = getXPath(pDump, "//row[1]/cell[1]/infos/bounds"_ostr, "top"_ostr).toInt32();
+ const sal_Int32 nParaTop
+ = getXPath(pDump, "//row[1]/cell[1]/txt/infos/bounds"_ostr, "top"_ostr).toInt32();
+ const sal_Int32 nImageTop
+ = getXPath(pDump, "//row[1]/cell[1]/txt/anchored/SwAnchoredDrawObject/bounds"_ostr,
+ "top"_ostr)
+ .toInt32();
+ // The image is approximately half-way between cell top and the start of the text
+ // correct ImageTop: 3588, while incorrect value was 1117. Cell top is 3051, ParaTop is 4195
+ const sal_Int32 nHalfway = nCellTop + (nParaTop - nCellTop) / 2;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(nHalfway, nImageTop, 50); // +/- 4.4%
+
+ // The effect is implemented by forcing "Entire paragraph area"/FRAME/0
+ // instead of "Page text area"/PAGE_PRINT_AREA/8
+ CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::FRAME,
+ getProperty<sal_Int16>(getShape(1), "VertOrientRelation"));
+ // since layoutInCell had been turned off. If the implementation changes, check the layout.
+ CPPUNIT_ASSERT(!getProperty<bool>(getShape(1), "IsFollowingTextFlow"));
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf153909_followTextFlow, "tdf153909_followTextFlow.docx")
{
// Although MSO's UI reports "layoutInCell" for the rectangle, it isn't specified or honored