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 87efbfc5198727c8bf357849833e0bb120458d64 Author: Miklos Vajna <vmik...@collabora.co.uk> AuthorDate: Thu Jul 26 09:04:41 2018 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Fri Jul 27 11:26:33 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. (cherry picked from commit 11d87b35474b642e99e7aa397aa18992c1bc20c9) Conflicts: sw/qa/extras/layout/layout.cxx Change-Id: I2b591dc46ad4967edd8a1691d9b100ef0d74bed3 Reviewed-on: https://gerrit.libreoffice.org/58084 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> 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 2356832cc4ba..f9da84956c5f 100755 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -24,6 +24,7 @@ public: void testTableExtrusion2(); void testTdf116848(); void testTdf117245(); + void testTdf109077(); CPPUNIT_TEST_SUITE(SwLayoutWriter); CPPUNIT_TEST(testTdf116830); @@ -34,6 +35,7 @@ public: CPPUNIT_TEST(testTableExtrusion2); CPPUNIT_TEST(testTdf116848); CPPUNIT_TEST(testTdf117245); + CPPUNIT_TEST(testTdf109077); CPPUNIT_TEST_SUITE_END(); private: @@ -194,6 +196,18 @@ void SwLayoutWriter::testTdf117245() assertXPath(pXmlDoc, "/root/page/body/txt[2]/LineBreak", 1); } +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