xmloff/source/text/XMLTextMarkImportContext.cxx | 49 ++++++++++++++++-------- 1 file changed, 34 insertions(+), 15 deletions(-)
New commits: commit b903e2a7ac730865d9a6ee48fb0392ecff2c7d30 Author: Michael Stahl <mst...@redhat.com> Date: Fri Dec 5 18:04:39 2014 +0100 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 <vmik...@collabora.co.uk> Tested-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index 8aaa952..d8f8bef 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); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits