summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-06-07 14:30:10 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-06-07 16:50:41 +0200
commit95f40ec1cdfe5c9db3e86c1092538dba8a129a72 (patch)
treeb89c26432180ca4e160423060868b77dbf0cb97f /sw/qa
parent9f0484c2bca8e7ec5e0d83289fae9b474b8598e0 (diff)
uiwriter: keep CPPUNIT_TEST_FIXTURE tests together
Change-Id: I19162c6e6868dc9eb57444f5b33dc2bad299c230 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116783 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx263
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx274
2 files changed, 274 insertions, 263 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index c47e5402304e..a70cab6cd394 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -1182,116 +1182,6 @@ void SwUiWriterTest::testWatermarkDOCX()
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), pWatermark->GetTransparency());
}
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134252)
-{
- load(DATA_DIRECTORY, "tdf134252.fodt");
-
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
-
- uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xCursor(xTextViewCursorSupplier->getViewCursor());
- uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
- uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
-
- // select all with section
- dispatchCommand(mxComponent, ".uno:SelectAll", {});
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING), xCursor->getString());
-
- dispatchCommand(mxComponent, ".uno:Delete", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString(""), xCursor->getString());
-
- // this would crash
- dispatchCommand(mxComponent, ".uno:Undo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING), xCursor->getString());
-
- dispatchCommand(mxComponent, ".uno:Redo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString(""), xCursor->getString());
-
- dispatchCommand(mxComponent, ".uno:Undo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING), xCursor->getString());
-
- dispatchCommand(mxComponent, ".uno:Redo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString(""), xCursor->getString());
-}
-
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf136453)
-{
- load(DATA_DIRECTORY, "tdf136453.fodt");
-
- SwXTextDocument *const pTextDoc(dynamic_cast<SwXTextDocument*>(mxComponent.get()));
- CPPUNIT_ASSERT(pTextDoc);
- SwDoc* const pDoc(pTextDoc->GetDocShell()->GetDoc());
- SwWrtShell *const pWrtShell(pDoc->GetDocShell()->GetWrtShell());
-
- sal_uLong const nNodes(pDoc->GetNodes().Count());
-
- pWrtShell->SttEndDoc(false);
- pWrtShell->SetMark();
- pWrtShell->Up(true, 1);
- pWrtShell->SttPara(true);
- pWrtShell->Delete();
-
- // one paragraph deleted, section is gone
- CPPUNIT_ASSERT_EQUAL(nNodes - 3, pDoc->GetNodes().Count());
-
- pWrtShell->Undo();
-
- CPPUNIT_ASSERT_EQUAL(nNodes, pDoc->GetNodes().Count());
-
- // check that every node has 1 frame
- xmlDocUniquePtr pXmlDoc = parseLayoutDump();
- assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3);
- assertXPath(pXmlDoc, "/root/page[1]/body/section", 1);
- assertXPath(pXmlDoc, "/root/page[1]/body/section/txt", 1);
-
- pWrtShell->Redo();
-
- // one paragraph deleted, section is gone
- CPPUNIT_ASSERT_EQUAL(nNodes - 3, pDoc->GetNodes().Count());
-
- discardDumpedLayout();
- pXmlDoc = parseLayoutDump();
- assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3);
- assertXPath(pXmlDoc, "/root/page[1]/body/section", 0);
-
- pWrtShell->Undo();
-
- CPPUNIT_ASSERT_EQUAL(nNodes, pDoc->GetNodes().Count());
-
- discardDumpedLayout();
- pXmlDoc = parseLayoutDump();
- assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3);
- assertXPath(pXmlDoc, "/root/page[1]/body/section", 1);
- assertXPath(pXmlDoc, "/root/page[1]/body/section/txt", 1);
-}
-
void SwUiWriterTest::testWatermarkPosition()
{
// tdf#108494 Watermark inserted in the document with page break was outside the first page
@@ -1369,78 +1259,6 @@ void SwUiWriterTest::testWatermarkPosition()
}
}
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134250)
-{
- load(DATA_DIRECTORY, "tdf134250.fodt");
-
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
-
- uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
- uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
-
- uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
-
- uno::Reference<text::XTextContent> xTextContent(xSections->getByIndex(0), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(OUString("foo" SAL_NEWLINE_STRING "bar"),
- xTextContent->getAnchor()->getString());
-
- // select all with table at start -> 3 times
- dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:SelectAll", {});
-
- // .uno:Copy without touching shared clipboard
- SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
- rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
- xTransfer->Copy();
-
- // .uno:Paste without touching shared clipboard
- TransferableDataHelper aHelper(xTransfer);
- SwTransferable::Paste(*pWrtShell, aHelper);
-
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
-
- // this would crash in 2 different ways
- dispatchCommand(mxComponent, ".uno:Undo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
-
- // Without the fix in place, section's content would have been gone after undo
- CPPUNIT_ASSERT_EQUAL(OUString("foo" SAL_NEWLINE_STRING "bar"),
- xTextContent->getAnchor()->getString());
-
- dispatchCommand(mxComponent, ".uno:Redo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
-
- dispatchCommand(mxComponent, ".uno:Undo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString("foo" SAL_NEWLINE_STRING "bar"),
- xTextContent->getAnchor()->getString());
-
- dispatchCommand(mxComponent, ".uno:Redo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
-}
-
void SwUiWriterTest::testFdo74981()
{
// create a document with an input field
@@ -5836,87 +5654,6 @@ void SwUiWriterTest::testRedlineCopyPaste()
CPPUNIT_ASSERT_EQUAL(OUString("abcdefgh"), pTextNode->GetText());
}
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134436)
-{
- load(DATA_DIRECTORY, "tdf134436.fodt");
-
- SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pXTextDocument);
- SwDoc * pDoc = pXTextDocument->GetDocShell()->GetDoc();
- CPPUNIT_ASSERT(pDoc);
- SwWrtShell * pWrtShell = pDoc->GetDocShell()->GetWrtShell();
- CPPUNIT_ASSERT(pWrtShell);
-
- uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
- uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
- uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
-
- // select all 3 times, table at the start
- dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:SelectAll", {});
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
- // the stupid SwXTextView::getString doesn't work "for symmetry" so use CursorShell
- CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText());
-
- // first, the section doesn't get deleted
- dispatchCommand(mxComponent, ".uno:Delete", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText());
-
- dispatchCommand(mxComponent, ".uno:Undo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText());
-
- // second, the section does get deleted because point is at the end
- dispatchCommand(mxComponent, ".uno:Delete", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText());
-
- dispatchCommand(mxComponent, ".uno:Undo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText());
-
- // the problem was that the section was not deleted on Redo
- dispatchCommand(mxComponent, ".uno:Redo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText());
-
- dispatchCommand(mxComponent, ".uno:Undo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText());
-
- dispatchCommand(mxComponent, ".uno:Redo", {});
- Scheduler::ProcessEventsToIdle();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xSections->getCount());
- CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText());
-}
-
void SwUiWriterTest::testTdf135260()
{
SwDoc* pDoc = createDoc();
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index de0c06f5d6bb..c87d0bdd19a9 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/text/TableColumnSeparator.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/text/XTextTable.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/table/XTableRows.hpp>
#include <comphelper/propertysequence.hxx>
#include <comphelper/configuration.hxx>
@@ -378,6 +379,279 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf136704)
getProperty<OUString>(getParagraph(1), "ParaStyleName"));
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf134250)
+{
+ load(DATA_DIRECTORY, "tdf134250.fodt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+
+ uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(),
+ uno::UNO_QUERY);
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+
+ uno::Reference<text::XTextContent> xTextContent(xSections->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("foo" SAL_NEWLINE_STRING "bar"),
+ xTextContent->getAnchor()->getString());
+
+ // select all with table at start -> 3 times
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+
+ // .uno:Copy without touching shared clipboard
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Copy();
+
+ // .uno:Paste without touching shared clipboard
+ TransferableDataHelper aHelper(xTransfer);
+ SwTransferable::Paste(*pWrtShell, aHelper);
+
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+
+ // this would crash in 2 different ways
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+
+ // Without the fix in place, section's content would have been gone after undo
+ CPPUNIT_ASSERT_EQUAL(OUString("foo" SAL_NEWLINE_STRING "bar"),
+ xTextContent->getAnchor()->getString());
+
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("foo" SAL_NEWLINE_STRING "bar"),
+ xTextContent->getAnchor()->getString());
+
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf134436)
+{
+ load(DATA_DIRECTORY, "tdf134436.fodt");
+
+ SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pXTextDocument);
+ SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
+ CPPUNIT_ASSERT(pDoc);
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
+ xModel->getCurrentController(), uno::UNO_QUERY);
+ uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
+ uno::UNO_QUERY);
+ uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(),
+ uno::UNO_QUERY);
+
+ // select all 3 times, table at the start
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+ // the stupid SwXTextView::getString doesn't work "for symmetry" so use CursorShell
+ CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText());
+
+ // first, the section doesn't get deleted
+ dispatchCommand(mxComponent, ".uno:Delete", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText());
+
+ // second, the section does get deleted because point is at the end
+ dispatchCommand(mxComponent, ".uno:Delete", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText());
+
+ // the problem was that the section was not deleted on Redo
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText());
+
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText());
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf134252)
+{
+ load(DATA_DIRECTORY, "tdf134252.fodt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
+ xModel->getCurrentController(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xCursor(xTextViewCursorSupplier->getViewCursor());
+ uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
+ uno::UNO_QUERY);
+ uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(),
+ uno::UNO_QUERY);
+
+ // select all with section
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING),
+ xCursor->getString());
+
+ dispatchCommand(mxComponent, ".uno:Delete", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString(""), xCursor->getString());
+
+ // this would crash
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING),
+ xCursor->getString());
+
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString(""), xCursor->getString());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING),
+ xCursor->getString());
+
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString(""), xCursor->getString());
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf136453)
+{
+ load(DATA_DIRECTORY, "tdf136453.fodt");
+
+ SwXTextDocument* const pTextDoc(dynamic_cast<SwXTextDocument*>(mxComponent.get()));
+ CPPUNIT_ASSERT(pTextDoc);
+ SwDoc* const pDoc(pTextDoc->GetDocShell()->GetDoc());
+ SwWrtShell* const pWrtShell(pDoc->GetDocShell()->GetWrtShell());
+
+ sal_uLong const nNodes(pDoc->GetNodes().Count());
+
+ pWrtShell->SttEndDoc(false);
+ pWrtShell->SetMark();
+ pWrtShell->Up(true, 1);
+ pWrtShell->SttPara(true);
+ pWrtShell->Delete();
+
+ // one paragraph deleted, section is gone
+ CPPUNIT_ASSERT_EQUAL(nNodes - 3, pDoc->GetNodes().Count());
+
+ pWrtShell->Undo();
+
+ CPPUNIT_ASSERT_EQUAL(nNodes, pDoc->GetNodes().Count());
+
+ // check that every node has 1 frame
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3);
+ assertXPath(pXmlDoc, "/root/page[1]/body/section", 1);
+ assertXPath(pXmlDoc, "/root/page[1]/body/section/txt", 1);
+
+ pWrtShell->Redo();
+
+ // one paragraph deleted, section is gone
+ CPPUNIT_ASSERT_EQUAL(nNodes - 3, pDoc->GetNodes().Count());
+
+ discardDumpedLayout();
+ pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3);
+ assertXPath(pXmlDoc, "/root/page[1]/body/section", 0);
+
+ pWrtShell->Undo();
+
+ CPPUNIT_ASSERT_EQUAL(nNodes, pDoc->GetNodes().Count());
+
+ discardDumpedLayout();
+ pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3);
+ assertXPath(pXmlDoc, "/root/page[1]/body/section", 1);
+ assertXPath(pXmlDoc, "/root/page[1]/body/section/txt", 1);
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf137245)
{
SwDoc* const pDoc(createDoc());