summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-03-12 21:44:57 +0300
committerMiklos Vajna <vmiklos@collabora.com>2020-03-16 14:01:08 +0100
commit53f099c842d39266a0b4786a1af3db5628746634 (patch)
tree567b177882bcae104227da7956b92fbf2d441524
parentef08f18e926f0627b51a529910aaade4353be9af (diff)
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@sil.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport5.cxx6
-rw-r--r--writerfilter/source/dmapper/SettingsTable.cxx17
2 files changed, 23 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 2e7fa5962fb8..470e47714940 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1007,6 +1007,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 7028f06e7fe9..71bff9b68dab 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -29,6 +29,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"
@@ -683,6 +684,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);
}