summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-04-15 14:59:15 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-04-27 10:14:41 +0200
commit66331ed8f549cd9fad331b7d2a1d7dcf3498a553 (patch)
tree68fcd54d421e4883142edee7b92a5c713d4d879b /oox
parent5e845e5230ed6982bfef761e86d552f1c96b67ad (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> (cherry picked from commit ff93e4977cb1e23f355d248a77e8d0e56bb0f4b9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92766 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/core/filterdetect.cxx32
-rw-r--r--oox/source/core/xmlfilterbase.cxx4
2 files changed, 34 insertions, 2 deletions
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index c83dab9d6f74..f51dae3d07e4 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -56,6 +56,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 );
@@ -144,6 +145,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
{
@@ -171,14 +181,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 48e1ad66f079..5808fdc6f234 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -625,7 +625,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";