diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2020-04-15 14:59:15 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2020-04-23 12:00:28 +0200 |
commit | ff93e4977cb1e23f355d248a77e8d0e56bb0f4b9 (patch) | |
tree | 549a091f0aaf8acd6b61f38b0df0a604421a1ae9 /oox | |
parent | 5b7561e758d3552d41bd65149f1fcbb6650e0887 (diff) |
tdf#131936 Correctly detect OOXML variant on import
Change-Id: I29a6b0454bf741ce8ad49078597b3412a83dedb9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92278
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/core/filterdetect.cxx | 32 | ||||
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 4 |
2 files changed, 34 insertions, 2 deletions
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index c8ce03acb75c..4a6edbdd7658 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -54,6 +54,7 @@ using comphelper::DocPasswordVerifierResult; FilterDetectDocHandler::FilterDetectDocHandler( const Reference< XComponentContext >& rxContext, OUString& rFilterName, const OUString& rFileName ) : mrFilterName( rFilterName ), maFileName(rFileName), + maOOXMLVariant( OOXMLVariant::ECMA_Transitional ), mxContext( rxContext ) { maContextStack.reserve( 2 ); @@ -142,6 +143,15 @@ void SAL_CALL FilterDetectDocHandler::characters( const OUString& /*aChars*/ ) void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs ) { OUString aType = rAttribs.getString( XML_Type, OUString() ); + + // tdf#131936 Remember filter when opening file as 'Office Open XML Text' + if (aType.startsWithIgnoreAsciiCase("http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties")) + maOOXMLVariant = OOXMLVariant::ISO_Transitional; + else if (aType.startsWithIgnoreAsciiCase("http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties")) + maOOXMLVariant = OOXMLVariant::ECMA_Transitional; + else if (aType.startsWithIgnoreAsciiCase("http://purl.oclc.org/ooxml/officeDocument")) + maOOXMLVariant = OOXMLVariant::ISO_Strict; + if ( !(aType == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" // OOXML Transitional || aType == "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument") ) //OOXML strict return; @@ -169,14 +179,32 @@ OUString FilterDetectDocHandler::getFilterNameFromContentType( const OUString& r bool bDocm = rFileName.endsWithIgnoreAsciiCase(".docm"); if( rContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" && !bDocm ) - return "writer_MS_Word_2007"; + { + switch (maOOXMLVariant) + { + case OOXMLVariant::ISO_Transitional: + case OOXMLVariant::ISO_Strict: // Not supported, map to ISO transitional + return "writer_OOXML"; + case OOXMLVariant::ECMA_Transitional: + return "writer_MS_Word_2007"; + } + } if( rContentType == "application/vnd.ms-word.document.macroEnabled.main+xml" || bDocm ) return "writer_MS_Word_2007_VBA"; if( rContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml" || rContentType == "application/vnd.ms-word.template.macroEnabledTemplate.main+xml" ) - return "writer_MS_Word_2007_Template"; + { + switch (maOOXMLVariant) + { + case OOXMLVariant::ISO_Transitional: + case OOXMLVariant::ISO_Strict: // Not supported, map to ISO transitional + return "writer_OOXML_Text_Template"; + case OOXMLVariant::ECMA_Transitional: + return "writer_MS_Word_2007_Template"; + } + } if( rContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml") return "MS Excel 2007 XML"; diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 84aaef6af9db..a8dfbb194843 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -620,7 +620,11 @@ writeCoreProperties( XmlFilterBase& rSelf, const Reference< XDocumentProperties { OUString sValue; if( rSelf.getVersion() == oox::core::ISOIEC_29500_2008 ) + { + // The lowercase "officedocument" is intentional and according to the spec + // (although most other places are written "officeDocument") sValue = "http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties"; + } else sValue = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"; |