diff options
-rw-r--r-- | officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 8 | ||||
-rw-r--r-- | sw/inc/cmdid.h | 2 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 32 | ||||
-rw-r--r-- | sw/sdi/_textsh.sdi | 6 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 18 | ||||
-rw-r--r-- | sw/source/uibase/shells/textfld.cxx | 16 | ||||
-rw-r--r-- | sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml | 2 |
7 files changed, 83 insertions, 1 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 1cb1a4f76d98..44654837f894 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -6395,6 +6395,14 @@ <value>1</value> </prop> </node> + <node oor:name=".uno:DatePickerFormField" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Date Picker Content Control</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> </node> <node oor:name="Popups"> <node oor:name=".uno:PasteSpecialMenu" oor:op="replace"> diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 9ad470acddc2..0a8191ce59bd 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -277,6 +277,8 @@ #define FN_INSERT_CHECKBOX_FORMFIELD (FN_INSERT2 + 23) #define FN_INSERT_DROPDOWN_FORMFIELD (FN_INSERT2 + 24) +// MSO content controls +#define FN_INSERT_DATE_FORMFIELD (FN_INSERT2 + 25) // Region: Format #define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */ diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index b9244ac94d46..887e59e73b06 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1765,4 +1765,36 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testShapePageMove) CPPUNIT_ASSERT_EQUAL(nNodeIndex, pAnchor->nNode.GetIndex()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDateFormFieldInsertion) +{ + SwDoc* pDoc = createDoc(); + CPPUNIT_ASSERT(pDoc); + IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess(); + CPPUNIT_ASSERT(pMarkAccess); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); + + // Insert a date form field + lcl_dispatchCommand(mxComponent, ".uno:DatePickerFormField", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); + + // Check whether the fieldmark is created + auto aIter = pMarkAccess->getAllMarksBegin(); + CPPUNIT_ASSERT(aIter != pMarkAccess->getAllMarksEnd()); + ::sw::mark::IFieldmark* pFieldmark = dynamic_cast<::sw::mark::IFieldmark*>(*aIter); + CPPUNIT_ASSERT(pFieldmark); + CPPUNIT_ASSERT_EQUAL(OUString(ODF_FORMDATE), pFieldmark->GetFieldname()); + + // Undo insertion + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); + + // Redo insertion + lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + aIter = pMarkAccess->getAllMarksBegin(); + CPPUNIT_ASSERT(aIter != pMarkAccess->getAllMarksEnd()); + pFieldmark = dynamic_cast<::sw::mark::IFieldmark*>(*aIter); + CPPUNIT_ASSERT(pFieldmark); + CPPUNIT_ASSERT_EQUAL(OUString(ODF_FORMDATE), pFieldmark->GetFieldname()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index e90b752eec17..7884565ad03a 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -1705,6 +1705,12 @@ interface BaseText StateMethod = StateField ; ] + FN_INSERT_DATE_FORMFIELD + [ + ExecMethod = ExecField ; + StateMethod = StateField ; + ] + SID_FM_CTL_PROPERTIES [ ExecMethod = Execute ; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 9ccc84af77ff..6e04a0a0884f 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -7771,3 +7771,21 @@ SfxVoidItem DropDownFormField FN_INSERT_DROPDOWN_FORMFIELD ToolBoxConfig = TRUE, GroupId = SfxGroupId::Controls; ] + +SfxVoidItem DatePickerFormField FN_INSERT_DATE_FORMFIELD + +[ + AutoUpdate = TRUE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Controls; +] diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index fa5afebd6c59..27c28daabbf2 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -717,6 +717,21 @@ FIELD_INSERT: rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); } break; + case FN_INSERT_DATE_FORMFIELD: + { + rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + + SwPaM* pCursorPos = rSh.GetCursor(); + if(pCursorPos) + { + IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); + pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMDATE); + } + + rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); + } + break; default: OSL_FAIL("wrong dispatcher"); return; @@ -880,6 +895,7 @@ void SwTextShell::StateField( SfxItemSet &rSet ) case FN_INSERT_TEXT_FORMFIELD: case FN_INSERT_CHECKBOX_FORMFIELD: case FN_INSERT_DROPDOWN_FORMFIELD: + case FN_INSERT_DATE_FORMFIELD: if ( rSh.CursorInsideInputField() ) { rSet.DisableItem(nWhich); diff --git a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml index 4d157908dd71..c9f2c0884754 100644 --- a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml +++ b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml @@ -32,7 +32,7 @@ </menu:menu> <menu:menu menu:id=".uno:MSCompatContentControls"> <menu:menupopup> - <menu:menuitem menu:id=".uno:DateField"/> + <menu:menuitem menu:id=".uno:DatePickerFormField"/> </menu:menupopup> </menu:menu> </menu:menupopup> |