summaryrefslogtreecommitdiff
path: root/sw/qa/core/txtnode/txtnode.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/qa/core/txtnode/txtnode.cxx')
-rw-r--r--sw/qa/core/txtnode/txtnode.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index bd9bcd66d6fc..5a88a2225846 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -30,6 +30,7 @@
#include <txatbase.hxx>
#include <ndtxt.hxx>
#include <textcontentcontrol.hxx>
+#include <swdtflvr.hxx>
constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/core/txtnode/data/";
@@ -318,6 +319,35 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testDateContentControlKeyboard)
CPPUNIT_ASSERT(bShouldOpen);
}
+CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testContentControlCopy)
+{
+ // Given a document with a content control:
+ SwDoc* pDoc = createSwDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->InsertContentControl(SwContentControlType::CHECKBOX);
+
+ // When copying that content control:
+ pWrtShell->SelAll();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Copy();
+ // Kill the selection, go to the end of the document:
+ pWrtShell->EndOfSection();
+ TransferableDataHelper aHelper(xTransfer);
+ SwTransferable::Paste(*pWrtShell, aHelper);
+
+ // Then make sure that the copy is also a checkbox:
+ SwContentControlManager& rManager = pDoc->GetContentControlManager();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rManager.GetCount());
+ const SwFormatContentControl& rFormat1 = rManager.Get(0)->GetContentControl();
+ CPPUNIT_ASSERT_EQUAL(SwContentControlType::CHECKBOX, rFormat1.GetContentControl()->GetType());
+ const SwFormatContentControl& rFormat2 = rManager.Get(1)->GetContentControl();
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1 (CHECKBOX)
+ // - Actual : 0 (RICH_TEXT)
+ // i.e. properties were not copied from the source to the destination content control.
+ CPPUNIT_ASSERT_EQUAL(SwContentControlType::CHECKBOX, rFormat2.GetContentControl()->GetType());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */