diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-02-15 18:39:46 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-02-16 17:17:11 +0100 |
commit | 5a94be3e677e4b7ccb2990a3a79fbf2219322f80 (patch) | |
tree | 70baf854e793232bcb4b1ed145b85ce570071c2a /sw | |
parent | 54b2615e0d209f815b3d503523fd4c517dc6b5cd (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.
Change-Id: I1fb8c03d969b4c547ca92e783ac5e216767685d5
Reviewed-on: https://gerrit.libreoffice.org/67907
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/cmdid.h | 6 | ||||
-rw-r--r-- | sw/sdi/_textsh.sdi | 18 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 53 | ||||
-rw-r--r-- | sw/source/core/doc/docbm.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/shells/textfld.cxx | 45 | ||||
-rw-r--r-- | sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml | 7 |
6 files changed, 135 insertions, 0 deletions
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index b7076905d66f..30b0f44b0e23 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -272,6 +272,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 463738966dea..f8c2daee6d65 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 ; + ] + } // end of interface text diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 416b596965e4..5f1ae9e9e09e 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -7701,3 +7701,56 @@ SfxBoolItem UseHeaderFooterMenu FN_USE_HEADERFOOTERMENU ToolBoxConfig = TRUE, GroupId = SfxGroupId::View; ] +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 ff1c3e59d0eb..bc429b9486d3 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -505,6 +505,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); @@ -512,6 +515,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 5a278df6dd01..0e05aae0602d 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; @@ -715,6 +718,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; @@ -865,6 +907,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> |