summaryrefslogtreecommitdiff
path: root/sw/qa/uibase
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-06-10 16:13:04 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-06-13 08:09:51 +0200
commitaa5824b2a6df99ef9d788a8d37bdfa77582375c8 (patch)
tree32e4e66a2426fdb3e08ff70ac0af6ad5cd178549 /sw/qa/uibase
parentc321498f915f4e8b3f4853232860ce040ab48e46 (diff)
tdf#149509 sw content controls: reject page break insertion
Similar to input fields, the intention is to keep the start and end of (inline) content controls within the same text node, so just disable the command in this context, as Word does. Change-Id: Ib797ad164a3a36b4bbde4d686cde29adf6db96bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135599 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa/uibase')
-rw-r--r--sw/qa/uibase/shells/shells.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index 902998bcdb1a..5a99b8e3c6bf 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -231,6 +231,36 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testBibliographyLocalCopyContextMenu)
CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, eState);
}
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testContentControlPageBreak)
+{
+ // Given a document with a content control and a cursor inside the content control:
+ SwDoc* pDoc = createSwDoc();
+ uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XText> xText = xTextDocument->getText();
+ uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor();
+ xText->insertString(xCursor, "test", /*bAbsorb=*/false);
+ xCursor->gotoStart(/*bExpand=*/false);
+ xCursor->gotoEnd(/*bExpand=*/true);
+ uno::Reference<text::XTextContent> xContentControl(
+ xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY);
+ xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true);
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->SttEndDoc(/*bStt=*/true);
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+
+ // When trying to insert a page break:
+ dispatchCommand(mxComponent, ".uno:InsertPagebreak", {});
+
+ // Then make sure that the document still has a single page:
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1
+ // - Actual : 2
+ // i.e. inline content control had its start and end in different text nodes, which is not
+ // allowed.
+ CPPUNIT_ASSERT_EQUAL(1, getPages());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */