summaryrefslogtreecommitdiff
path: root/xmloff/source/text
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-12-05 18:04:39 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-12-08 10:21:27 +0000
commitb903e2a7ac730865d9a6ee48fb0392ecff2c7d30 (patch)
tree21b7897b759762ebfceb43993621663ef1145989 /xmloff/source/text
parentaddb0bb5bb197808146811a024f6b79ce5cb57d3 (diff)
fdo#86795: xmloff: ODF import: do not import checkbox fieldmark ...
... if it has start/end, because Writer will become grumpy and crash. (cherry picked from commit 25fd11e78279aef5a6b7656347758e5c67a9c45a) Conflicts: xmloff/source/text/XMLTextMarkImportContext.cxx Change-Id: I6024051249eeac6ed9e43856fa77db969287f888 Reviewed-on: https://gerrit.libreoffice.org/13319 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'xmloff/source/text')
-rw-r--r--xmloff/source/text/XMLTextMarkImportContext.cxx49
1 files changed, 34 insertions, 15 deletions
diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx
index 8aaa952bbba9..d8f8bef30297 100644
--- a/xmloff/source/text/XMLTextMarkImportContext.cxx
+++ b/xmloff/source/text/XMLTextMarkImportContext.cxx
@@ -143,7 +143,7 @@ static const char *lcl_getFormFieldmarkName(OUString &name)
return NULL;
}
-static OUString lcl_getFieldmarkName(OUString &name)
+static OUString lcl_getFieldmarkName(OUString const& name)
{
static const char sFormtext[]=ODF_FORMTEXT;
if (name.equalsAscii("msoffice.field.FORMTEXT") ||
@@ -288,19 +288,40 @@ void XMLTextMarkImportContext::EndElement()
bool bImportAsField=((lcl_MarkType)nTmp==TypeFieldmarkEnd && m_rHelper.hasCurrentFieldCtx());
- // insert reference
- const Reference<XInterface> xContent(
- CreateAndInsertMark(GetImport(),
- (bImportAsField?sAPI_fieldmark:sAPI_bookmark),
- m_sBookmarkName,
- xInsertionCursor,
- m_sXmlId) );
- if (pRDFaAttributes)
+ // fdo#86795 check if it's actually a checkbox first
+ bool isInvalid(false);
+ OUString fieldmarkTypeName;
+ if (bImportAsField && m_rHelper.hasCurrentFieldCtx())
{
- const Reference<rdf::XMetadatable>
- xMeta(xContent, UNO_QUERY);
- GetImport().GetRDFaImportHelper().AddRDFa(
- xMeta, pRDFaAttributes);
+
+ OUString const type(m_rHelper.getCurrentFieldType());
+ fieldmarkTypeName = lcl_getFieldmarkName(type);
+ if (fieldmarkTypeName == ODF_FORMCHECKBOX ||
+ fieldmarkTypeName == ODF_FORMDROPDOWN)
+ { // sw can't handle checkbox with start+end
+ SAL_INFO("xmloff.text", "invalid fieldmark-start/fieldmark-end ignored");
+ isInvalid = true;
+ }
+ }
+
+ Reference<XInterface> xContent;
+ if (!isInvalid)
+ {
+ // insert reference
+ xContent = CreateAndInsertMark(GetImport(),
+ (bImportAsField
+ ? OUString(sAPI_fieldmark)
+ : OUString(sAPI_bookmark)),
+ m_sBookmarkName,
+ xInsertionCursor,
+ m_sXmlId);
+ if (pRDFaAttributes)
+ {
+ const Reference<rdf::XMetadatable>
+ xMeta(xContent, UNO_QUERY);
+ GetImport().GetRDFaImportHelper().AddRDFa(
+ xMeta, pRDFaAttributes);
+ }
}
if ((lcl_MarkType)nTmp==TypeFieldmarkEnd) {
@@ -308,8 +329,6 @@ void XMLTextMarkImportContext::EndElement()
// setup fieldmark...
Reference< ::com::sun::star::text::XFormField> xFormField(xContent, UNO_QUERY);
if (xFormField.is() && m_rHelper.hasCurrentFieldCtx()) {
- OUString givenTypeName=m_rHelper.getCurrentFieldType();
- OUString fieldmarkTypeName=lcl_getFieldmarkName(givenTypeName);
xFormField->setFieldType(fieldmarkTypeName);
m_rHelper.setCurrentFieldParamsTo(xFormField);