diff options
author | Jaume Pujantell <jaume.pujantell@collabora.com> | 2023-03-21 16:03:54 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-03-22 16:49:49 +0000 |
commit | 826b20b049449c9c335ce00c781cdb52e4ee0512 (patch) | |
tree | 74902e86499d02698c9efdc3d9535b3744698f74 | |
parent | fc9126c3cb84d6b53c1d6daa10814ae25f863056 (diff) |
Fix wrong layout of textbox in header
In some cases the text box wasn't properly moved afeter it's position
had been calculated. Also now when the shape and text element are
brought together in the Z ordering, the one with higher Z moves down.
Change-Id: I0512db4b6466532b5af4e3c091fd65bd0a416381
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149221
Tested-by: Jenkins
Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | sw/qa/core/layout/data/header-textbox.docx | bin | 0 -> 5778 bytes | |||
-rw-r--r-- | sw/qa/core/layout/layout.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/draw/dcontact.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/layout/anchoreddrawobject.cxx | 8 |
4 files changed, 31 insertions, 1 deletions
diff --git a/sw/qa/core/layout/data/header-textbox.docx b/sw/qa/core/layout/data/header-textbox.docx Binary files differnew file mode 100644 index 000000000000..4df72cccd3e7 --- /dev/null +++ b/sw/qa/core/layout/data/header-textbox.docx diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx index 2669b05fb2a2..f8878ef77bb4 100644 --- a/sw/qa/core/layout/layout.cxx +++ b/sw/qa/core/layout/layout.cxx @@ -258,6 +258,21 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextboxModification) CPPUNIT_ASSERT(!pDocShell->IsModified()); } +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxInHeaderIsPositioned) +{ + // Load a document with a floating text box in the header + createSwDoc("header-textbox.docx"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + + // Without the fix in place, this test would have failed with + // - Expected: 8051 + // - Actual : 1418 + // Comparison with 7000 chosen due to variability between devices + CPPUNIT_ASSERT_GREATEREQUAL( + double(7000), getXPath(pXmlDoc, "//anchored/fly/infos/bounds", "left").toDouble()); +} + CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testBtlrNestedCell) { // Load a document with a nested table, the inner A1 cell has a btlr text direction. diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index a7c57ec0d609..8675f62e72c9 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1975,7 +1975,14 @@ void SwDrawContact::ConnectToLayout( const SwFormatAnchor* pAnch ) if (pDrawPage) { sal_uInt32 nOrdNum = pAnchoredObj->GetDrawObj()->GetOrdNum(); - pDrawPage->SetObjectOrdNum(maAnchoredDrawObj.GetDrawObj()->GetOrdNumDirect(), nOrdNum); + if (maAnchoredDrawObj.GetDrawObj()->GetOrdNum() >= nOrdNum) + { + pDrawPage->SetObjectOrdNum(maAnchoredDrawObj.GetDrawObj()->GetOrdNumDirect(), nOrdNum); + } + else + { + pDrawPage->SetObjectOrdNum(nOrdNum, maAnchoredDrawObj.GetDrawObj()->GetOrdNumDirect() + 1); + } break; } } diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index 491e860014f2..6dc6cac5d1b2 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -32,6 +32,7 @@ #include <tools/fract.hxx> #include <DocumentSettingManager.hxx> #include <IDocumentState.hxx> +#include <IDocumentLayoutAccess.hxx> #include <txtfly.hxx> #include <viewimp.hxx> #include <textboxhelper.hxx> @@ -516,6 +517,13 @@ void SwAnchoredDrawObject::SetDrawObjAnchor() DrawObj()->SetAnchorPos( aNewAnchorPos ); // correct object position, caused by setting new anchor position DrawObj()->Move( aMove ); + // Sync textbox if it wasn't done at move + if ( SwTextBoxHelper::isTextBox(&GetFrameFormat(), RES_DRAWFRMFMT) && GetFrameFormat().GetDoc() && + GetFrameFormat().GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() && + GetFrameFormat().GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell()->IsInConstructor()) + { + SwTextBoxHelper::changeAnchor(&GetFrameFormat(), GetFrameFormat().FindRealSdrObject()); + } // --> #i70122# - missing invalidation InvalidateObjRectWithSpaces(); } |