diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-12-05 18:04:39 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-12-05 18:17:42 +0100 |
commit | 25fd11e78279aef5a6b7656347758e5c67a9c45a (patch) | |
tree | 20e2b5566d67ef8cee0266d25801e67f0eeeba3c | |
parent | e5992c481c01f6c85e43192ef83e384a035d9bf1 (diff) |
fdo#86795: xmloff: ODF import: do not import checkbox fieldmark ...
... if it has start/end, because Writer will become grumpy and crash.
Change-Id: I6024051249eeac6ed9e43856fa77db969287f888
-rw-r--r-- | xmloff/source/text/XMLTextMarkImportContext.cxx | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index 63bb7e237bf3..b4e5e15afa92 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -144,7 +144,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") || @@ -289,19 +289,40 @@ void XMLTextMarkImportContext::EndElement() bool bImportAsField=((lcl_MarkType)nTmp==TypeFieldmarkEnd && m_rHelper.hasCurrentFieldCtx()); - // insert reference - const Reference<XInterface> xContent( - CreateAndInsertMark(GetImport(), - (bImportAsField ? OUString(sAPI_fieldmark) : OUString(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) { @@ -309,8 +330,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); |