Kaydet (Commit) d6d64444 authored tarafından Tamás Zolnai's avatar Tamás Zolnai Kaydeden (comit) Andras Timar

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: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit 5a94be3e)

Change-Id: I1fb8c03d969b4c547ca92e783ac5e216767685d5
Reviewed-on: https://gerrit.libreoffice.org/67922Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
Tested-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst ca5e771e
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#define ODF_FORMTEXT "vnd.oasis.opendocument.field.FORMTEXT" #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 "vnd.oasis.opendocument.field.FORMCHECKBOX"
#define ODF_FORMCHECKBOX_HELPTEXT "Checkbox_HelpText" #define ODF_FORMCHECKBOX_HELPTEXT "Checkbox_HelpText"
......
...@@ -6131,6 +6131,30 @@ ...@@ -6131,6 +6131,30 @@
<value xml:lang="en-US">Synony~ms</value> <value xml:lang="en-US">Synony~ms</value>
</prop> </prop>
</node> </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>
<node oor:name="Popups"> <node oor:name="Popups">
<node oor:name=".uno:PasteSpecialMenu" oor:op="replace"> <node oor:name=".uno:PasteSpecialMenu" oor:op="replace">
...@@ -6552,6 +6576,11 @@ ...@@ -6552,6 +6576,11 @@
<value xml:lang="en-US">ActiveX Controls</value> <value xml:lang="en-US">ActiveX Controls</value>
</prop> </prop>
</node> </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>
</node> </node>
</oor:component-data> </oor:component-data>
...@@ -271,6 +271,12 @@ ...@@ -271,6 +271,12 @@
#define FN_INSERT_MULTI_TOX (FN_INSERT2 + 20) /* insert any TOX */ #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*/ #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 // Region: Format
#define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */ #define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */
#define FN_AUTOFORMAT_AUTO (FN_FORMAT + 2 ) /* apply autoformat during user input */ #define FN_AUTOFORMAT_AUTO (FN_FORMAT + 2 ) /* apply autoformat during user input */
......
...@@ -1676,5 +1676,23 @@ interface BaseText ...@@ -1676,5 +1676,23 @@ interface BaseText
DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; // e.g. disable for read-only documents 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 } //ende interface text
...@@ -7649,3 +7649,58 @@ SfxVoidItem NavElement FN_NAV_ELEMENT ...@@ -7649,3 +7649,58 @@ SfxVoidItem NavElement FN_NAV_ELEMENT
ToolBoxConfig = TRUE, ToolBoxConfig = TRUE,
GroupId = SfxGroupId::Navigator; 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;
]
...@@ -506,6 +506,9 @@ namespace sw { namespace mark ...@@ -506,6 +506,9 @@ namespace sw { namespace mark
const OUString& rName, const OUString& rName,
const OUString& rType) const OUString& rType)
{ {
bool bEnableSetModified = m_pDoc->getIDocumentState().IsEnableSetModified();
m_pDoc->getIDocumentState().SetEnableSetModified(false);
sw::mark::IMark* pMark = makeMark( rPaM, rName, sw::mark::IMark* pMark = makeMark( rPaM, rName,
IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK, IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK,
sw::mark::InsertMode::New); sw::mark::InsertMode::New);
...@@ -513,6 +516,9 @@ namespace sw { namespace mark ...@@ -513,6 +516,9 @@ namespace sw { namespace mark
if (pFieldMark) if (pFieldMark)
pFieldMark->SetFieldname( rType ); pFieldMark->SetFieldname( rType );
m_pDoc->getIDocumentState().SetEnableSetModified(bEnableSetModified);
m_pDoc->getIDocumentState().SetModified();
return pFieldMark; return pFieldMark;
} }
......
...@@ -71,6 +71,9 @@ ...@@ -71,6 +71,9 @@
#include <cstddef> #include <cstddef>
#include <memory> #include <memory>
#include <swmodule.hxx> #include <swmodule.hxx>
#include <MarkManager.hxx>
#include <xmloff/odffields.hxx>
#include <IDocumentContentOperations.hxx>
using namespace nsSwDocInfoSubType; using namespace nsSwDocInfoSubType;
...@@ -725,6 +728,45 @@ FIELD_INSERT: ...@@ -725,6 +728,45 @@ FIELD_INSERT:
rReq.Done(); rReq.Done();
} }
break; 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: default:
OSL_FAIL("wrong dispatcher"); OSL_FAIL("wrong dispatcher");
return; return;
...@@ -875,6 +917,9 @@ void SwTextShell::StateField( SfxItemSet &rSet ) ...@@ -875,6 +917,9 @@ void SwTextShell::StateField( SfxItemSet &rSet )
case FN_INSERT_FLD_TITLE: case FN_INSERT_FLD_TITLE:
case FN_INSERT_FLD_TOPIC: case FN_INSERT_FLD_TOPIC:
case FN_INSERT_DBFIELD: case FN_INSERT_DBFIELD:
case FN_INSERT_TEXT_FORMFIELD:
case FN_INSERT_CHECKBOX_FORMFIELD:
case FN_INSERT_DROPDOWN_FORMFIELD:
if ( rSh.CursorInsideInputField() ) if ( rSh.CursorInsideInputField() )
{ {
rSet.DisableItem(nWhich); rSet.DisableItem(nWhich);
......
...@@ -24,6 +24,13 @@ ...@@ -24,6 +24,13 @@
<menu:menuitem menu:id=".uno:DateField"/> <menu:menuitem menu:id=".uno:DateField"/>
</menu:menupopup> </menu:menupopup>
</menu:menu> </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:menupopup>
</menu:menu> </menu:menu>
</menu:menubar> </menu:menubar>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment