[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/qa writerfilter/source

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 2 19:22:54 UTC 2020


 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx     |    6 ++++++
 writerfilter/source/dmapper/SettingsTable.cxx |   17 +++++++++++++++++
 2 files changed, 23 insertions(+)

New commits:
commit 3c92bceceea49f4a4449395ef0cf1c7d27e13d50
Author:     Justin Luth <justin.luth at collabora.com>
AuthorDate: Thu Mar 12 21:44:57 2020 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Thu Apr 2 21:22:21 2020 +0200

    tdf#131304 .docx: provide default compatibilityMode value
    
    When a docx is imported without specifying a compat mode,
    populate the appropriate compatibilityMode setting,
    which will be written out at save time.
    
    "12: Use word processing features specified in ECMA-376.
    This is the default."
    
    The immediate benefit for LO is that this will provide a
    cacheable result - instead of repeated lookup attempts
    for something that doesn't exist.
    Perhaps more importantly, it paves the way
    for allowing LO to export new documents
    as compatible with 2013, while leaving existing
    documents at their current level.
    
    Both Word and LO treat the missing compatSetting
    correctly as mode 12, so this should not have any
    affect on layout or any other compatibility aspect.
    Therefore I can't see any reason why
    it shouldn't be explicitly written.
    MS Word also writes it out on a round-trip.
    
    Writing it out doesn't limit us in any way either.
    As soon as it is in docx format, it will be treated
    as mode 12 anyway, so why not make it explicit?
    Well, I guess that since MS Word has
    been filling this in since 2010 at least, we
    could "assume" that if it is missing and has been
    modified in the past 5 years it was
    created by LO and thus treat it differently,
    contrary to standard. But that doesn't seem
    like a very good idea at all.
    
    Change-Id: If68cecc14bf4446c5ca25fd2dd6eebddf8d954a1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90439
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    (cherry picked from commit 53f099c842d39266a0b4786a1af3db5628746634)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90919
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 87795d6ba6c6..ee64589d0305 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1122,6 +1122,12 @@ DECLARE_OOXMLEXPORT_TEST(tdf89991_revisionView, "tdf89991.docx")
     {
         assertXPath(pXmlSettings, "/w:settings/w:revisionView", "insDel",     "0");
         assertXPath(pXmlSettings, "/w:settings/w:revisionView", "formatting", "0");
+
+        // There was no compatibilityMode defined.
+        // 12: Use word processing features specified in ECMA-376. This is the default.
+        assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "name", "compatibilityMode");
+        assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "uri", "http://schemas.microsoft.com/office/word");
+        assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "val", "12");
     }
 }
 
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index 58399cf0a151..f875bdd70523 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/style/XStyle.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <comphelper/propertysequence.hxx>
 #include <comphelper/sequence.hxx>
 #include <ooxml/resourceids.hxx>
 #include "ConversionHelper.hxx"
@@ -679,6 +680,22 @@ uno::Sequence<beans::PropertyValue> const & SettingsTable::GetThemeFontLangPrope
 
 uno::Sequence<beans::PropertyValue> SettingsTable::GetCompatSettings() const
 {
+    if ( GetWordCompatibilityMode() == -1 )
+    {
+        // the default value for an undefined compatibilityMode is 12 (Word 2007)
+        uno::Sequence<beans::PropertyValue> aCompatSetting( comphelper::InitPropertySequence({
+            { "name", uno::Any(OUString("compatibilityMode")) },
+            { "uri", uno::Any(OUString("http://schemas.microsoft.com/office/word")) },
+            { "val", uno::Any(OUString("12")) } //12: Use word processing features specified in ECMA-376. This is the default.
+        }));
+
+        beans::PropertyValue aValue;
+        aValue.Name = "compatSetting";
+        aValue.Value <<= aCompatSetting;
+
+        m_pImpl->m_aCompatSettings.push_back(aValue);
+    }
+
     return comphelper::containerToSequence(m_pImpl->m_aCompatSettings);
 }
 


More information about the Libreoffice-commits mailing list