summaryrefslogtreecommitdiffstats
path: root/sw/qa/core/edit/edit.cxx
diff options
context:
space:
mode:
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: */