sfx2/source/doc/sfxbasemodel.cxx | 13 +++++++++++++ sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 16 ++++++++++++++++ 2 files changed, 29 insertions(+)
New commits: commit 60acbb8f513705b19bf5070c6f7bdaf3c677a3fe Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Sat Dec 7 11:42:39 2024 -0500 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Mon Mar 3 03:48:09 2025 +0100 tdf#164201 docx import: compat14+ cannot be ECMA_376_1ST_EDITION This fixes a 7.6 regression from commit e66ddcd4b66923bc835bd7c5f5c784a809a420a2. At import, the base filter was treating too many documents as if they were limited to Word 2007 format, and thus reducing their compatibilityMode to 12 on export. This import case is matched in a LOT of unit tests. However, it doesn't manifest itself in saveAndReload(mpFilter) (or DECLARE_OOXMLEXPORT_TEST) because the mpFilter string set in the Test class with SwModelTestBase(..."ooxmlexport/data/", "Office Open XML Text"), forces saving in ISOIEC_29500_2008 mode and thus unit tests basically NEVER round-trip as "MS Word 2007 XML". However, the general user was almost always round-tripping these as MS Word 2007 XML / compat12 since LO 7.6. make CppunitTest_sw_ooxmlexport20 CPPUNIT_TEST_NAME=testTdf158855 Change-Id: If635866cc816e7b4734443f87b30410ac3bba951 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178048 Reviewed-by: Justin Luth <jl...@mail.com> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit d97085cc6cd2bdc3b6723d1960d0ec5fa0a48165) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182411 Tested-by: Aron Budea <aron.bu...@collabora.com> Reviewed-by: Aron Budea <aron.bu...@collabora.com> diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 2d9518530416..17dc962a4370 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -1188,6 +1188,19 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs) pMedium->GetItemSet().Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, rArg.Value)); ok = true; } + else if (rArg.Name == "FilterName") + { + // HACK: Needed a way to tweak the filter after loading has started, + // but changing this must be avoided unless clearly intentional. + if (aArgs.size() == 1) + { + if (rArg.Value >>= sValue) + { + pMedium->GetItemSet().Put(SfxStringItem(SID_FILTER_NAME, sValue)); + ok = true; + } + } + } if (!ok) { throw lang::IllegalArgumentException("Setting property not supported: " + rArg.Name, diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index acf64cb7cdbc..3e1855e4ff23 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -9863,6 +9863,22 @@ void DomainMapper_Impl::ApplySettingsTable() // i.e. it typesets the same text with less lines and pages. if (m_pSettingsTable->GetWordCompatibilityMode() >= 15) xSettings->setPropertyValue(u"JustifyLinesWithShrinking"_ustr, uno::Any( true )); + + if (m_pSettingsTable->GetWordCompatibilityMode() > 12) + { + // impossible to be importing as a 2007-only format when compat mode is not equal to 12, + // so change from ECMA_376_1ST_EDITION to ISOIEC_29500_2008 + // so that at export time it will not be forced into compat12 mode. + OUString sFilterName; + comphelper::SequenceAsHashMap aMap(m_xTextDocument->getArgs()); + aMap["FilterName"] >>= sFilterName; + if (sFilterName == "MS Word 2007 XML") + { + m_xTextDocument->setArgs( + { comphelper::makePropertyValue("FilterName", OUString("Office Open XML Text")) }); + } + } + if (m_pSettingsTable->GetUsePrinterMetrics()) xSettings->setPropertyValue(u"PrinterIndependentLayout"_ustr, uno::Any(document::PrinterIndependentLayout::DISABLED)); if( m_pSettingsTable->GetEmbedTrueTypeFonts())