summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-02-15 18:39:46 +0100
committerAndras Timar <andras.timar@collabora.com>2019-02-17 11:04:36 +0100
commitd6d64444279c408ab3c2a7bc85a00aa5fc1e454e (patch)
tree0dce3463e9225780a11c41dff47bbbaca2f08f99
parentca5e771e165038592505b2c378c743405ce45e27 (diff)
MSForms: Insert Legacy Form Fields from MS compatible Forms menu
I added a new submenu under MS compatible Forms menu called Legacy Forms. Under this submenu user can insert the three legacy form fields. These fields were already supported by DOC / DOCX filters, but were missing from the UI. When inserting text form field we insert 5 enspace to make the field visible, otherwise we use the same insertion methods what is called by DOC import. Reviewed-on: https://gerrit.libreoffice.org/67907 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> (cherry picked from commit 5a94be3e677e4b7ccb2990a3a79fbf2219322f80) Change-Id: I1fb8c03d969b4c547ca92e783ac5e216767685d5 Reviewed-on: https://gerrit.libreoffice.org/67922 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--include/xmloff/odffields.hxx1
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu29
-rw-r--r--sw/inc/cmdid.h6
-rw-r--r--sw/sdi/_textsh.sdi18
-rw-r--r--sw/sdi/swriter.sdi55
-rw-r--r--sw/source/core/doc/docbm.cxx6
-rw-r--r--sw/source/uibase/shells/textfld.cxx45
-rw-r--r--sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml7
8 files changed, 167 insertions, 0 deletions
diff --git a/include/xmloff/odffields.hxx b/include/xmloff/odffields.hxx
index 1a4bb2b623f6..bbc1becb6576 100644
--- a/include/xmloff/odffields.hxx
+++ b/include/xmloff/odffields.hxx
@@ -22,6 +22,7 @@
#define ODF_FORMTEXT "vnd.oasis.opendocument.field.FORMTEXT"
+#define ODF_FORMTEXT_DEFAULT_LENGTH 5
#define ODF_FORMCHECKBOX "vnd.oasis.opendocument.field.FORMCHECKBOX"
#define ODF_FORMCHECKBOX_HELPTEXT "Checkbox_HelpText"
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index eb0dfc04a909..f146a63caa56 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -6131,6 +6131,30 @@
<value xml:lang="en-US">Synony~ms</value>
</prop>
</node>
+ <node oor:name=".uno:TextFormField" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Text Form Field</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
+ <node oor:name=".uno:CheckBoxFormField" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Check Box Form Field</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
+ <node oor:name=".uno:DropDownFormField" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Drop-Down Form Field</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">
@@ -6552,6 +6576,11 @@
<value xml:lang="en-US">ActiveX Controls</value>
</prop>
</node>
+ <node oor:name=".uno:MSCompatLegacyControls" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Legacy Forms</value>
+ </prop>
+ </node>
</node>
</node>
</oor:component-data>
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 651c72082eff..471db4f40353 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -271,6 +271,12 @@
#define FN_INSERT_MULTI_TOX (FN_INSERT2 + 20) /* insert any TOX */
#define FN_INSERT_AUTH_ENTRY_DLG (FN_INSERT2 + 21) /* insert entry for table of authorities*/
+// MSO legacy form fields
+#define FN_INSERT_TEXT_FORMFIELD (FN_INSERT2 + 22)
+#define FN_INSERT_CHECKBOX_FORMFIELD (FN_INSERT2 + 23)
+#define FN_INSERT_DROPDOWN_FORMFIELD (FN_INSERT2 + 24)
+
+
// Region: Format
#define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */
#define FN_AUTOFORMAT_AUTO (FN_FORMAT + 2 ) /* apply autoformat during user input */
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index e9c35b2d24dd..e5c260cc5f49 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -1676,5 +1676,23 @@ interface BaseText
DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; // e.g. disable for read-only documents
]
+ FN_INSERT_TEXT_FORMFIELD
+ [
+ ExecMethod = ExecField ;
+ StateMethod = StateField ;
+ ]
+
+ FN_INSERT_CHECKBOX_FORMFIELD
+ [
+ ExecMethod = ExecField ;
+ StateMethod = StateField ;
+ ]
+
+ FN_INSERT_DROPDOWN_FORMFIELD
+ [
+ ExecMethod = ExecField ;
+ StateMethod = StateField ;
+ ]
+
} //ende interface text
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 2f0d5d9ec45a..5fcf1e53ef87 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -7649,3 +7649,58 @@ SfxVoidItem NavElement FN_NAV_ELEMENT
ToolBoxConfig = TRUE,
GroupId = SfxGroupId::Navigator;
]
+
+
+SfxVoidItem TextFormField FN_INSERT_TEXT_FORMFIELD
+
+[
+ AutoUpdate = TRUE,
+ FastCall = FALSE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+
+
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ ToolBoxConfig = TRUE,
+ GroupId = SfxGroupId::Controls;
+]
+
+SfxVoidItem CheckBoxFormField FN_INSERT_CHECKBOX_FORMFIELD
+
+[
+ AutoUpdate = TRUE,
+ FastCall = FALSE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+
+
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ ToolBoxConfig = TRUE,
+ GroupId = SfxGroupId::Controls;
+]
+
+SfxVoidItem DropDownFormField FN_INSERT_DROPDOWN_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/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index c76fb55a6313..dc9ebb40ed72 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -506,6 +506,9 @@ namespace sw { namespace mark
const OUString& rName,
const OUString& rType)
{
+ bool bEnableSetModified = m_pDoc->getIDocumentState().IsEnableSetModified();
+ m_pDoc->getIDocumentState().SetEnableSetModified(false);
+
sw::mark::IMark* pMark = makeMark( rPaM, rName,
IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK,
sw::mark::InsertMode::New);
@@ -513,6 +516,9 @@ namespace sw { namespace mark
if (pFieldMark)
pFieldMark->SetFieldname( rType );
+ m_pDoc->getIDocumentState().SetEnableSetModified(bEnableSetModified);
+ m_pDoc->getIDocumentState().SetModified();
+
return pFieldMark;
}
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index 5e4dfeaef768..4b6735b1e998 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -71,6 +71,9 @@
#include <cstddef>
#include <memory>
#include <swmodule.hxx>
+#include <MarkManager.hxx>
+#include <xmloff/odffields.hxx>
+#include <IDocumentContentOperations.hxx>
using namespace nsSwDocInfoSubType;
@@ -725,6 +728,45 @@ FIELD_INSERT:
rReq.Done();
}
break;
+
+ case FN_INSERT_TEXT_FORMFIELD:
+ {
+ SwPaM* pCursorPos = rSh.GetCursor();
+ if(pCursorPos)
+ {
+ // Insert five enspace into the text field so the field has extent
+ sal_Unicode vEnSpaces[ODF_FORMTEXT_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194};
+ bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, OUString(vEnSpaces, ODF_FORMTEXT_DEFAULT_LENGTH));
+ if(bSuccess)
+ {
+ IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
+ SwPaM aFieldPam(pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex()-5,
+ pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex());
+ pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMTEXT);
+ }
+ }
+ }
+ break;
+ case FN_INSERT_CHECKBOX_FORMFIELD:
+ {
+ SwPaM* pCursorPos = rSh.GetCursor();
+ if(pCursorPos)
+ {
+ IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
+ pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMCHECKBOX);
+ }
+ }
+ break;
+ case FN_INSERT_DROPDOWN_FORMFIELD:
+ {
+ SwPaM* pCursorPos = rSh.GetCursor();
+ if(pCursorPos)
+ {
+ IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
+ pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMDROPDOWN);
+ }
+ }
+ break;
default:
OSL_FAIL("wrong dispatcher");
return;
@@ -875,6 +917,9 @@ void SwTextShell::StateField( SfxItemSet &rSet )
case FN_INSERT_FLD_TITLE:
case FN_INSERT_FLD_TOPIC:
case FN_INSERT_DBFIELD:
+ case FN_INSERT_TEXT_FORMFIELD:
+ case FN_INSERT_CHECKBOX_FORMFIELD:
+ case FN_INSERT_DROPDOWN_FORMFIELD:
if ( rSh.CursorInsideInputField() )
{
rSet.DisableItem(nWhich);
diff --git a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
index 4b8f5ea0e714..4c8e34467d3e 100644
--- a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
+++ b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
@@ -24,6 +24,13 @@
<menu:menuitem menu:id=".uno:DateField"/>
</menu:menupopup>
</menu:menu>
+ <menu:menu menu:id=".uno:MSCompatLegacyControls">
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:TextFormField"/>
+ <menu:menuitem menu:id=".uno:CheckBoxFormField"/>
+ <menu:menuitem menu:id=".uno:DropDownFormField"/>
+ </menu:menupopup>
+ </menu:menu>
</menu:menupopup>
</menu:menu>
</menu:menubar>