diff options
author | Daniel Arato (NISZ) <arato.daniel@nisz.hu> | 2020-11-03 11:22:40 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-11-09 19:05:20 +0100 |
commit | f2eef84ff03660cbb46a76c317e640e054ed0a56 (patch) | |
tree | f92ef8082e5b2cf545f9f675d545b437c0a52e75 | |
parent | tdf#137993 ensure the toplevel vcl::Window is activated (diff) | |
download | core-f2eef84ff03660cbb46a76c317e640e054ed0a56.tar.gz core-f2eef84ff03660cbb46a76c317e640e054ed0a56.zip |
tdf#137881 sw: fix text box size regression
from commit c9eb53f200225f2ee6ca695e1326843a487aee51
(tdf#135198 sw editing: text box fell out of its shape).
The height of the bottom text box frame from the tdf#117921 sample
file grew unreasonably large. This is countered by only activating
the previous fix if it is strictly needed, i.e. when a shape and
its text box drift apart from each other.
The test file is derived from the one used for tdf#117921.
Change-Id: Ied01c6089efe586b73de559f89f08b958f4b62d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105238
Tested-by: László Németh <nemeth@numbertext.org>
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | sw/qa/core/layout/data/bottom-textbox-size.docx | bin | 0 -> 14919 bytes | |||
-rw-r--r-- | sw/qa/core/layout/layout.cxx | 15 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/layout/objectformattertxtfrm.cxx | 29 |
4 files changed, 33 insertions, 14 deletions
diff --git a/sw/qa/core/layout/data/bottom-textbox-size.docx b/sw/qa/core/layout/data/bottom-textbox-size.docx Binary files differnew file mode 100644 index 000000000000..a1c700f28ae9 --- /dev/null +++ b/sw/qa/core/layout/data/bottom-textbox-size.docx diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx index a992a32ae7d4..ff339322fe70 100644 --- a/sw/qa/core/layout/layout.cxx +++ b/sw/qa/core/layout/layout.cxx @@ -196,6 +196,21 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxStaysInsideShape) nTextBoxTopAfter < nTextBoxTopBefore); } +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxSizeAtBottomOfPage) +{ + // tdf#137881: check whether text box at the bottom of the page stays the right size + load(DATA_DIRECTORY, "bottom-textbox-size.docx"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pTextBoxObj = pPage->GetObj(0); + + uno::Reference<drawing::XShape> xShape(pTextBoxObj->getUnoShape(), uno::UNO_QUERY_THROW); + const sal_Int32 nHeight = xShape->getSize().Height; + CPPUNIT_ASSERT_EQUAL_MESSAGE("text box was not supposed to be resized on fileopen", + static_cast<sal_Int32>(2200), nHeight); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index ec680a69a6ad..5919d1a6f76d 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1065,8 +1065,7 @@ DECLARE_OOXMLIMPORT_TEST(textboxWpsOnly, "textbox-wps-only.docx") if ( nsScreen.frame.size.width * scaleFactor > 4000 ) return; #endif - // Vertically oriented to page due to tdf#135198 - CPPUNIT_ASSERT_EQUAL(sal_Int32(5304), getProperty<sal_Int32>(xFrame, "VertOrientPosition")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2805), getProperty<sal_Int32>(xFrame, "VertOrientPosition")); } DECLARE_OOXMLIMPORT_TEST(testGroupshapeRelsize, "groupshape-relsize.docx") diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx index 2109835ba841..6b0e910fb113 100644 --- a/sw/source/core/layout/objectformattertxtfrm.cxx +++ b/sw/source/core/layout/objectformattertxtfrm.cxx @@ -355,23 +355,28 @@ bool SwObjectFormatterTextFrame::DoFormatObjs() SwFrameFormat& rFormat = pObj->GetFrameFormat(); if (SwTextBoxHelper::isTextBox(&rFormat, RES_DRAWFRMFMT)) { - if (const SwPageFrame* pPageFrame = pObj->GetPageFrame()) + const SwFrameFormat* pOtherFormat = SwTextBoxHelper::getOtherTextBoxFormat(&rFormat, RES_DRAWFRMFMT); + if (rFormat.GetVertOrient().GetPos() != pOtherFormat->GetVertOrient().GetPos() || + rFormat.GetAnchor().GetAnchorId() != pOtherFormat->GetAnchor().GetAnchorId()) { - SwDoc* pDoc = rFormat.GetDoc(); + if (const SwPageFrame* pPageFrame = pObj->GetPageFrame()) + { + SwDoc* pDoc = rFormat.GetDoc(); - // avoid Undo creation, - ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); + // avoid Undo creation, + ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); - SfxItemSet aSet(pDoc->GetAttrPool(), - svl::Items<RES_VERT_ORIENT, RES_ANCHOR>{}); + SfxItemSet aSet(pDoc->GetAttrPool(), + svl::Items<RES_VERT_ORIENT, RES_ANCHOR>{}); - const SwRect& rPageFrameArea = pPageFrame->getFrameArea(); - aSet.Put(SwFormatVertOrient(pObj->GetObjRect().Top() - rPageFrameArea.Top(), - text::VertOrientation::NONE, - text::RelOrientation::PAGE_FRAME)); - aSet.Put(SwFormatAnchor(RndStdIds::FLY_AT_PAGE, pObj->GetPageFrame()->GetPhyPageNum())); + const SwRect& rPageFrameArea = pPageFrame->getFrameArea(); + aSet.Put(SwFormatVertOrient(pObj->GetObjRect().Top() - rPageFrameArea.Top(), + text::VertOrientation::NONE, + text::RelOrientation::PAGE_FRAME)); + aSet.Put(SwFormatAnchor(RndStdIds::FLY_AT_PAGE, pObj->GetPageFrame()->GetPhyPageNum())); - SwTextBoxHelper::syncFlyFrameAttr(rFormat, aSet); + SwTextBoxHelper::syncFlyFrameAttr(rFormat, aSet); + } } } } |