sw/qa/extras/layout/data/tdf109077.docx |binary sw/qa/extras/layout/layout.cxx | 14 ++++++++++++++ sw/source/core/text/porfly.cxx | 8 ++++++-- 3 files changed, 20 insertions(+), 2 deletions(-)
New commits: commit 11d87b35474b642e99e7aa397aa18992c1bc20c9 Author: Miklos Vajna <vmik...@collabora.co.uk> AuthorDate: Thu Jul 26 09:04:41 2018 +0200 Commit: Miklos Vajna <vmik...@collabora.co.uk> CommitDate: Thu Jul 26 11:47:13 2018 +0200 tdf#109077 sw textbox: fix as-char shapes with custom print area in para Regression from d379d18666aa42031359ca8eb34b0021960347ae (oox: import WPS shape with text as shape with textbox, 2014-06-18), the position of the textbox should be relative to the print area of the text frame, not to the text frame itself. Change-Id: I2b591dc46ad4967edd8a1691d9b100ef0d74bed3 Reviewed-on: https://gerrit.libreoffice.org/58009 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/qa/extras/layout/data/tdf109077.docx b/sw/qa/extras/layout/data/tdf109077.docx new file mode 100644 index 000000000000..c0a67d2765c0 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf109077.docx differ diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index ea2e24f06b75..96dfcc0a2757 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -27,6 +27,7 @@ public: void testTdf117245(); void testTdf118672(); void testTdf117923(); + void testTdf109077(); CPPUNIT_TEST_SUITE(SwLayoutWriter); CPPUNIT_TEST(testTdf116830); @@ -39,6 +40,7 @@ public: CPPUNIT_TEST(testTdf117245); CPPUNIT_TEST(testTdf118672); CPPUNIT_TEST(testTdf117923); + CPPUNIT_TEST(testTdf109077); CPPUNIT_TEST_SUITE_END(); private: @@ -236,6 +238,18 @@ void SwLayoutWriter::testTdf117923() assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "220"); } +void SwLayoutWriter::testTdf109077() +{ + createDoc("tdf109077.docx"); + xmlDocPtr pXmlDoc = parseLayoutDump(); + sal_Int32 nShapeTop + = getXPath(pXmlDoc, "//anchored/SwAnchoredDrawObject/bounds", "top").toInt32(); + sal_Int32 nTextBoxTop = getXPath(pXmlDoc, "//anchored/fly/infos/bounds", "top").toInt32(); + // This was 281: the top of the shape and its textbox should match, though + // tolerate differences <= 1px (about 15 twips). + CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(15), nTextBoxTop - nShapeTop); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index 19084dfe8379..b74c28d8ec7a 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -351,16 +351,20 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase, { // It has, so look up its text rectangle, and adjust the position // of the textbox accordingly. + // Both rectangles are absolute, SwFormatHori/VertOrient's position + // is relative to the print area of the anchor text frame. tools::Rectangle aTextRectangle = SwTextBoxHelper::getTextRectangle(pShape); SwFormatHoriOrient aHori(pTextBox->GetHoriOrient()); aHori.SetHoriOrient(css::text::HoriOrientation::NONE); - sal_Int32 nLeft = aTextRectangle.getX() - rFrame.getFrameArea().Left(); + sal_Int32 nLeft = aTextRectangle.getX() - rFrame.getFrameArea().Left() + - rFrame.getFramePrintArea().Left(); aHori.SetPos(nLeft); SwFormatVertOrient aVert(pTextBox->GetVertOrient()); aVert.SetVertOrient(css::text::VertOrientation::NONE); - sal_Int32 const nTop = aTextRectangle.getY() - rFrame.getFrameArea().Top(); + sal_Int32 const nTop = aTextRectangle.getY() - rFrame.getFrameArea().Top() + - rFrame.getFramePrintArea().Top(); aVert.SetPos(nTop); pTextBox->LockModify(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits