[Libreoffice-commits] core.git: sw/qa sw/source xmloff/qa
sw/qa/extras/layout/data/tdf116256.docx |binary sw/qa/extras/layout/layout2.cxx | 44 +++ sw/source/core/doc/textboxhelper.cxx| 90 xmloff/qa/unit/draw.cxx |2 4 files changed, 125 insertions(+), 11 deletions(-) New commits: commit 6e8ae79176be1c34cadc833c8e521be19455fade Author: Attila Bakos (NISZ) AuthorDate: Thu Feb 17 16:00:01 2022 +0100 Commit: László Németh CommitDate: Thu Mar 10 19:50:36 2022 +0100 tdf#116256 sw: fix textbox position in floating table in case of it has to follow the text flow. Change-Id: Ic4f195c2efcc465276faa9a95362933dafa65bee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130077 Tested-by: László Németh Reviewed-by: László Németh diff --git a/sw/qa/extras/layout/data/tdf116256.docx b/sw/qa/extras/layout/data/tdf116256.docx new file mode 100644 index ..f067e04f0614 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf116256.docx differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 38451465bab0..7c8914b814d7 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -988,6 +989,49 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf69648) } } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116256) +{ +// Open bugdoc +createSwDoc(DATA_DIRECTORY, "tdf116256.docx"); +CPPUNIT_ASSERT(mxComponent); + +// Get the textbox +uno::Reference xTextBox(getShape(2), uno::UNO_QUERY_THROW); + +// Ensure that is a real textbox, and follows the text flow +CPPUNIT_ASSERT(xTextBox->getPropertyValue("TextBox").get()); + CPPUNIT_ASSERT(xTextBox->getPropertyValue("IsFollowingTextFlow").get()); + +// Parse the layout +auto pLayout = parseLayoutDump(); +// Get the position of the shape +const auto nTextBoxShapeLeft = getXPath(pLayout, + "/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/" + "anchored/SwAnchoredDrawObject/bounds", +"left") + .toInt64(); +const auto nTextBoxShapeTop = getXPath(pLayout, + "/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/" + "anchored/SwAnchoredDrawObject/bounds", + "top") + .toInt64(); +// Get the position of the textframe too. +const auto nTextBoxFrameLeft += getXPath(pLayout, + "/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/anchored/fly/infos/bounds", + "left") + .toInt64(); +const auto nTextBoxFrameTop += getXPath(pLayout, + "/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/anchored/fly/infos/bounds", + "top") + .toInt64(); + +// Without the fix in place these were less than they supposed to. +CPPUNIT_ASSERT_GREATEREQUAL(nTextBoxShapeLeft, nTextBoxFrameLeft); +CPPUNIT_ASSERT_GREATEREQUAL(nTextBoxShapeTop, nTextBoxFrameTop); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138194) { SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "xaxis-labelbreak.docx"); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 6657a5244305..21da16f5f2d8 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -26,9 +26,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -1069,6 +1071,9 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& return; const bool bInlineAnchored = rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR; +const bool bLayoutInCell += rShape.GetFollowTextFlow().GetValue() && rShape.GetAnchor().GetContentAnchor() + && rShape.GetAnchor().GetContentAnchor()->nNode.GetNode().FindTableNode(); SfxItemSet aTextBoxSet(pFormat->GetDoc()->GetAttrPool(), aFrameFormatSetRange); SfxItemIter aIter(rSet); @@ -1085,7 +1090,7 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& = mapAnchorType(rShape.GetAnchor().GetAnchorId()); syncProperty(&rShape, RES_ANCHOR, MID_ANCHOR_ANCHORTYPE, uno::Any(aNewAnchorType), pObj); -if (bInlineAnchored) +if (bInlineAnchored || bLayoutInCell) return; SwFormatVertOrient aOrient(pItem->StaticWhichCast(RES_VERT_ORIENT)); @@ -1115,7 +1120,7 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const
[Libreoffice-commits] core.git: sw/qa sw/source xmloff/qa
sw/qa/extras/uiwriter/data/tdf146449.odt |binary sw/qa/extras/uiwriter/uiwriter4.cxx | 30 ++ sw/source/core/doc/textboxhelper.cxx | 11 +-- sw/source/core/undo/undraw.cxx |5 + xmloff/qa/unit/draw.cxx |2 +- 5 files changed, 41 insertions(+), 7 deletions(-) New commits: commit a3e540304269772595439de22b54269011721bb2 Author: Attila Bakos (NISZ) AuthorDate: Wed Mar 2 14:08:14 2022 +0100 Commit: László Németh CommitDate: Wed Apr 27 16:44:09 2022 +0200 tdf#146449 sw: fix Z-order after undoing Textbox z-order synchronization was missing in case of Undo, resulting broken text boxes. Regression from 504d78acb866495fd954fcd6db22ea68f174a5ab "tdf#143574 sw: textboxes in group shapes - part 1". Change-Id: I2632b7fb40e327f083e680e10b19c8f405df1875 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130875 Tested-by: Jenkins Tested-by: László Németh Reviewed-by: Attila Bakos Reviewed-by: László Németh diff --git a/sw/qa/extras/uiwriter/data/tdf146449.odt b/sw/qa/extras/uiwriter/data/tdf146449.odt new file mode 100644 index ..c18d98e8aaec Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf146449.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index 6c3d3578ca26..d1aee7f23986 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -119,6 +119,36 @@ static OUString lcl_translitTest(SwDoc& rDoc, const SwPaM& rPaM, Transliteration return rPaM.GetNode(false).GetTextNode()->GetText(); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf146449) +{ +load(DATA_DIRECTORY, "tdf146449.odt"); + +auto pDoc = dynamic_cast(mxComponent.get()); +CPPUNIT_ASSERT(pDoc); +auto pShell = pDoc->GetDocShell()->GetFEShell(); +CPPUNIT_ASSERT(pShell); + +auto xTextBox = getShapeByName(u"Frame1"); +auto pObject = SdrObject::getSdrObjectFromXShape(xTextBox); + +CPPUNIT_ASSERT(pShell->SelectObj(Point(), 0, pObject)); + +dispatchCommand(mxComponent, ".uno:Cut", {}); +Scheduler::ProcessEventsToIdle(); + +dispatchCommand(mxComponent, ".uno:Undo", {}); +Scheduler::ProcessEventsToIdle(); + +uno::Reference xShapeProps(xTextBox, uno::UNO_QUERY); +uno::Reference xFrameProps(xShapeProps->getPropertyValue("TextBoxContent"), +uno::UNO_QUERY); + +const auto& nShapeZOrder = pObject->GetOrdNum(); +const auto& nFrameZOrder = xFrameProps->getPropertyValue("ZOrder"); + +CPPUNIT_ASSERT_MESSAGE("Wrong Zorder!", nShapeZOrder < nFrameZOrder.get()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf49033) { SwDoc* pDoc = createSwDoc(); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 74d29aad270b..3eeed981d74f 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -1329,7 +1329,6 @@ bool SwTextBoxHelper::changeAnchor(SwFrameFormat* pShape, SdrObject* pObj) bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pObj) { -bool bSuccess = false; // Set the position of the textboxes according to the position of its shape-pair const bool bIsGroupObj = (pObj != pShape->FindRealSdrObject()) && pObj; if (auto pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT, pObj)) @@ -1414,8 +1413,8 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb } } -bSuccess = pFormat->SetFormatAttr(aNewHOri); -bSuccess &= pFormat->SetFormatAttr(aNewVOri); +pFormat->SetFormatAttr(aNewHOri); +pFormat->SetFormatAttr(aNewVOri); } // Other cases when the shape has different anchor from AS_CHAR else @@ -1498,10 +1497,10 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb aNewVOri.SetPos(aNewVOri.GetPos() + nTableOffset.getY()); } -bSuccess = pFormat->SetFormatAttr(aNewHOri); -bSuccess &= pFormat->SetFormatAttr(aNewVOri); +pFormat->SetFormatAttr(aNewHOri); +pFormat->SetFormatAttr(aNewVOri); } -return bSuccess; +return true; } return false; diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index f316858c2bfd..9eb5502eceaa 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -601,6 +601,11 @@ void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & rContext) pContact->MoveObjToVisibleLayer( pObj ); SwDrawFrameFormat* pDrawFrameFormat = rSave.pFormat; +if (pDrawFrameFormat->GetOtherTextBoxFormats()) +{ +SwTextBoxHelper::synchronizeGroupTextBoxProperty( +SwTextBoxHe