summaryrefslogtreecommitdiff
path: root/xmloff/source/text/XMLTextMarkImportContext.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff/source/text/XMLTextMarkImportContext.cxx')
-rw-r--r--xmloff/source/text/XMLTextMarkImportContext.cxx11
1 files changed, 10 insertions, 1 deletions
diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx
index 080009a8e6f6..505e86251650 100644
--- a/xmloff/source/text/XMLTextMarkImportContext.cxx
+++ b/xmloff/source/text/XMLTextMarkImportContext.cxx
@@ -200,7 +200,16 @@ static auto InsertFieldmark(SvXMLImport & rImport,
// setup fieldmark...
Reference<text::XFormField> const xFormField(xContent, UNO_QUERY);
assert(xFormField.is());
- xFormField->setFieldType(fieldmarkTypeName);
+ try {
+ xFormField->setFieldType(fieldmarkTypeName);
+ } catch (uno::RuntimeException const&) {
+ // tdf#140437 somehow old documents had the field code in the type
+ // attribute instead of field:param
+ SAL_INFO("xmloff.text", "invalid fieldmark type, converting to param");
+ // add without checking: FieldParamImporter::Import() catches ElementExistException
+ rHelper.addFieldParam(ODF_CODE_PARAM, fieldmarkTypeName);
+ xFormField->setFieldType(ODF_UNHANDLED);
+ }
rHelper.setCurrentFieldParamsTo(xFormField);
// move cursor after setFieldType as that may delete/re-insert
rHelper.GetCursor()->gotoRange(xContent->getAnchor()->getEnd(), false);