summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-05-31 09:29:54 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-05-31 14:39:26 +0200
commit5f335154459e044b6035f099a3e08c98fe258d2b (patch)
tree70a133fef9b827efc0270e3c32ed864d0e7ee96c /sw/qa
parent2ad445acad66f23fe5452746835c539eaaf949b6 (diff)
sw content controls, date: add insert UI
- handle the date case in SwWrtShell::InsertContentControl() - expose this as a new .uno:InsertDateContentControl command - add the new uno command to the default & MS-compatible menus - hide the old .uno:DatePickerFormField from the menus that has the problems described in the sw::mark::DateFieldmark documentation. Change-Id: If3c1050d6a8302be0da4a11067a67805396dec48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135153 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/uibase/wrtsh/wrtsh.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx
index 706e1c6653a7..87537e887242 100644
--- a/sw/qa/uibase/wrtsh/wrtsh.cxx
+++ b/sw/qa/uibase/wrtsh/wrtsh.cxx
@@ -346,6 +346,27 @@ CPPUNIT_TEST_FIXTURE(Test, testSelectDateContentControl)
CPPUNIT_ASSERT_EQUAL(OUString("2022-05-24T00:00:00Z"),
rFormatContentControl.GetContentControl()->GetCurrentDate());
}
+
+CPPUNIT_TEST_FIXTURE(Test, testInsertDateContentControl)
+{
+ // Given an empty document:
+ SwDoc* pDoc = createSwDoc();
+
+ // When inserting a date content control:
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->InsertContentControl(SwContentControlType::DATE);
+
+ // Then make sure that the matching text attribute is added to the document model:
+ SwTextNode* pTextNode = pWrtShell->GetCursor()->GetNode().GetTextNode();
+ SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, RES_TXTATR_CONTENTCONTROL);
+ auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
+ auto& rFormatContentControl
+ = static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr());
+ std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl();
+ // Without the accompanying fix in place, this test would have failed, there was no special
+ // handling for date content control.
+ CPPUNIT_ASSERT(pContentControl->GetDate());
+}
}
CPPUNIT_PLUGIN_IMPLEMENT();