diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index 3088170c241a..b48df147673b 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -168,12 +168,11 @@ void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs ) { OUString aType = rAttribs.getStringDefaulted( XML_Type); - // 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")) + // Although the spec says that ISO_Transitional uses the "officedocument" URI for core.xml, + // MS errata admits that MS Office just uses the old "package" URI from ECMA_376_1ST_EDITION. + // So core-properties can't be used to identify a non-ECMA_376_1ST_EDITION document... + + 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 diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 173b60d8ac7b..e96ae4fc7d27 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -683,21 +683,12 @@ writeCoreProperties( XmlFilterBase& rSelf, const Reference< XDocumentProperties = bRemovePersonalInfo && !SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnKeepDocUserInfo); - // Although the spec says that ISOIEC_29500_2008 must use the "officedocument" URI, - // in MS errata they admit that DOCX just uses the old "package" URI from ECMA_376_1ST_EDITION. - - OUString sValue; - const bool bDocx = dynamic_cast(rSelf.getModel().get()); - if (!bDocx && 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"; - - rSelf.addRelation( sValue, u"docProps/core.xml" ); + // Although the spec says that ISOIEC_29500_2008 must use the "officedocument" URI for core.xml, + // MS errata admits that MS Office just uses the old "package" URI from ECMA_376_1ST_EDITION. + // Tested with Office 2024 - and even "Strict Open XML" uses "package". + rSelf.addRelation( + u"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"_ustr, + u"docProps/core.xml"); FSHelperPtr pCoreProps = rSelf.openFragmentStreamWithSerializer( u"docProps/core.xml"_ustr, u"application/vnd.openxmlformats-package.core-properties+xml"_ustr ); diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx index a34cc7e4473b..34e48bbb16b0 100644 --- a/test/source/bootstrapfixture.cxx +++ b/test/source/bootstrapfixture.cxx @@ -166,7 +166,7 @@ OUString filterOut(const OUString& s, std::u16string_view excludedSubstr) return result; } -OUString filterValidationResults(const OUString& s, std::u16string_view rFilter) +OUString filterValidationResults(const OUString& s) { OUString result = s; // In ECMA-376-1 Second Edition, 2008, there is the following restriction for oleObj: @@ -190,11 +190,10 @@ OUString filterValidationResults(const OUString& s, std::u16string_view rFilter) // But officeotron only knows the old version... result = filterOut(result, u"Invalid content was found starting with element 'p:pic'. No child element is expected at this point."); - if (rFilter == u"Office Open XML Text") { /* While the spec says the core-properties relationship must be * officedocument/2006/relationships/metadata/core-properties - * MS Word actually just writes the ECMA-376-1ST EDITION version + * MS Office actually just writes the ECMA-376-1ST EDITION version * for both ECMA_Transitional and ISO_Transitional formats. * * officeotron doesn't care that clause 15.2.12.1 fails on all MSWord-produced output. @@ -308,7 +307,7 @@ void test::BootstrapFixture::validate(const OUString& rPath, std::u16string_view if( eFormat == test::OOXML && !aContentOUString.isEmpty() ) { - aContentOUString = filterValidationResults(aContentOUString, rFilter); + aContentOUString = filterValidationResults(aContentOUString); // check for validation errors here sal_Int32 nIndex = aContentOUString.lastIndexOf(grand_total); if(nIndex == -1)