Kaydet (Commit) 5a94be3e authored tarafından Tamás Zolnai's avatar Tamás Zolnai

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: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst 54b2615e
......@@ -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"
......
......@@ -6296,6 +6296,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">
......@@ -6814,6 +6838,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>
......@@ -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 */
......
......@@ -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
......@@ -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;
]
......@@ -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;
}
......
......@@ -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);
......
......@@ -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>
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