summaryrefslogtreecommitdiffstats
path: root/sw/qa/core/edit/edit.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-03-08 21:06:10 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2022-06-23 18:35:46 +0200
commitb767771e505851553e80e27ebdd5ac5d7973b831 (patch)
tree83971b12c2195a7dbcaeeca160e3127864320df8 /sw/qa/core/edit/edit.cxx
parenttdf#140292: (related: tdf#133487) sw: fix ordering of virtual SdrObjects for ... (diff)
downloadcore-b767771e505851553e80e27ebdd5ac5d7973b831.tar.gz
core-b767771e505851553e80e27ebdd5ac5d7973b831.zip
tdf#140292 sw: fix z-order of textbox on undo
Regression from commit 200cd2b99bee18962a970edc5d059286f6c3ea0e (tdf#138995 DOCX import: fix handling of textbox zorders, 2021-01-11), the problem was already fixed by Michael Stahl, this just adds a test for it. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112181 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112273 (cherry picked from commit 291bc2799e4d384cb3ccbb429e82a8ea52d3ea2f) Change-Id: Id613224d5fab0c2d2a3bdfd58bff6d77a92dd374 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136310 Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw/qa/core/edit/edit.cxx')
-rw-r--r--sw/qa/core/edit/edit.cxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/sw/qa/core/edit/edit.cxx b/sw/qa/core/edit/edit.cxx
index 5f6dff479e73..c13e348ad831 100644
--- a/sw/qa/core/edit/edit.cxx
+++ b/sw/qa/core/edit/edit.cxx
@@ -12,6 +12,7 @@
#include <docsh.hxx>
#include <view.hxx>
#include <wrtsh.hxx>
+#include <textboxhelper.hxx>
#include <editeng/adjustitem.hxx>
@@ -52,6 +53,56 @@ CPPUNIT_TEST_FIXTURE(Test, testRedlineHidden)
pWrtShell->SetAttrSet(aSet, SetAttrMode::DEFAULT, nullptr, true);
}
+CPPUNIT_TEST_FIXTURE(Test, testTextboxUndoOrdNum)
+{
+ // Given a document with 5 frame formats:
+ // - picture
+ // - draw format + fly format and a picture in it
+ // - picture
+ SwDoc* pDoc = createSwDoc("textbox-undo-ordnum.docx");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats();
+ // Test the state before del + undo.
+ for (const auto& pFormat : rFormats)
+ {
+ const SwFrameFormat* pFlyFormat
+ = SwTextBoxHelper::getOtherTextBoxFormat(pFormat, RES_DRAWFRMFMT);
+ if (!pFlyFormat)
+ {
+ continue;
+ }
+
+ sal_Int32 nDrawOrdNum = pFormat->FindRealSdrObject()->GetOrdNum();
+ sal_Int32 nFlyOrdNum = pFlyFormat->FindRealSdrObject()->GetOrdNum();
+ CPPUNIT_ASSERT_EQUAL(nDrawOrdNum + 1, nFlyOrdNum);
+ }
+
+ // When selecting the first page, deleting the selection and undoing:
+ pWrtShell->Down(true, 3);
+ pWrtShell->DelLeft();
+ pWrtShell->Undo();
+
+ // Then the z-order of the fly format should be still the z-order of the draw format + 1, when
+ // the fly and draw formats form a textbox pair.
+ for (const auto& pFormat : rFormats)
+ {
+ const SwFrameFormat* pFlyFormat
+ = SwTextBoxHelper::getOtherTextBoxFormat(pFormat, RES_DRAWFRMFMT);
+ if (!pFlyFormat)
+ {
+ continue;
+ }
+
+ sal_Int32 nDrawOrdNum = pFormat->FindRealSdrObject()->GetOrdNum();
+ sal_Int32 nFlyOrdNum = pFlyFormat->FindRealSdrObject()->GetOrdNum();
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 4
+ // - Actual : 2
+ // i.e. the fly format was behind the draw format, not visible.
+ CPPUNIT_ASSERT_EQUAL(nDrawOrdNum + 1, nFlyOrdNum);
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */