[Libreoffice-commits] core.git: include/xmloff xmloff/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Fri May 15 15:52:52 UTC 2020


 include/xmloff/xmlexp.hxx                  |    3 ++
 xmloff/source/core/xmlexp.cxx              |   34 +++++++++++++++++------------
 xmloff/source/meta/MetaExportComponent.cxx |   13 -----------
 3 files changed, 24 insertions(+), 26 deletions(-)

New commits:
commit 86cd3af48f8c00300d9826f3b7364e8447adb34e
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Apr 28 15:02:08 2020 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Fri May 15 17:52:10 2020 +0200

    xmloff: ODF export: produce office:version="1.3"
    
    Change-Id: I422743c6eacf112046141e017d42d78165c36cf2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93089
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/include/xmloff/xmlexp.hxx b/include/xmloff/xmlexp.hxx
index 75595d35ea29..58ff24299cec 100644
--- a/include/xmloff/xmlexp.hxx
+++ b/include/xmloff/xmlexp.hxx
@@ -531,6 +531,9 @@ public:
 
     css::uno::Reference< css::embed::XStorage > const & GetTargetStorage() const;
 
+    /// returns value of ODF version attribute
+    char const* GetODFVersionAttributeValue() const;
+
     /// returns the currently configured default version for odf export
     SvtSaveOptions::ODFDefaultVersion getDefaultVersion() const;
 
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index b22b7b58b5c4..a9e49a5a8e34 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -107,8 +107,6 @@ using namespace ::com::sun::star::xml::sax;
 using namespace ::com::sun::star::io;
 using namespace ::xmloff::token;
 
-char const sXML_1_2[] = "1.2";
-
 #define XML_MODEL_SERVICE_WRITER    "com.sun.star.text.TextDocument"
 #define XML_MODEL_SERVICE_CALC      "com.sun.star.sheet.SpreadsheetDocument"
 #define XML_MODEL_SERVICE_DRAW      "com.sun.star.drawing.DrawingDocument"
@@ -1229,6 +1227,25 @@ void SvXMLExport::addChaffWhenEncryptedStorage()
     }
 }
 
+auto SvXMLExport::GetODFVersionAttributeValue() const -> char const*
+{
+    char const* pVersion(nullptr);
+    switch (getSaneDefaultVersion())
+    {
+    case SvtSaveOptions::ODFSVER_013_EXTENDED: [[fallthrough]];
+    case SvtSaveOptions::ODFSVER_013: pVersion = "1.3"; break;
+    case SvtSaveOptions::ODFSVER_012_EXTENDED: [[fallthrough]];
+    case SvtSaveOptions::ODFSVER_012_EXT_COMPAT: [[fallthrough]];
+    case SvtSaveOptions::ODFSVER_012: pVersion = "1.2"; break;
+    case SvtSaveOptions::ODFSVER_011: pVersion = "1.1"; break;
+    case SvtSaveOptions::ODFSVER_010: break;
+
+    default:
+        assert(!"xmloff::SvXMLExport::exportDoc(), unexpected odf default version!");
+    }
+    return pVersion;
+}
+
 ErrCode SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass )
 {
     bool bOwnGraphicResolver = false;
@@ -1323,18 +1340,7 @@ ErrCode SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass )
     }
 
     // office:version = ...
-    const char* pVersion = nullptr;
-    switch (getDefaultVersion())
-    {
-    case SvtSaveOptions::ODFVER_LATEST: pVersion = sXML_1_2; break;
-    case SvtSaveOptions::ODFVER_012_EXT_COMPAT: pVersion = sXML_1_2; break;
-    case SvtSaveOptions::ODFVER_012: pVersion = sXML_1_2; break;
-    case SvtSaveOptions::ODFVER_011: pVersion = "1.1"; break;
-    case SvtSaveOptions::ODFVER_010: break;
-
-    default:
-        SAL_WARN("xmloff.core", "xmloff::SvXMLExport::exportDoc(), unexpected odf default version!");
-    }
+    const char*const pVersion = GetODFVersionAttributeValue();
 
     if (pVersion)
     {
diff --git a/xmloff/source/meta/MetaExportComponent.cxx b/xmloff/source/meta/MetaExportComponent.cxx
index 44620578f1c7..61b6e9a85629 100644
--- a/xmloff/source/meta/MetaExportComponent.cxx
+++ b/xmloff/source/meta/MetaExportComponent.cxx
@@ -134,18 +134,7 @@ ErrCode XMLMetaExportComponent::exportDoc( enum XMLTokenEnum )
             nPos = GetNamespaceMap().GetNextKey( nPos );
         }
 
-        const char* pVersion = nullptr;
-        switch( getDefaultVersion() )
-        {
-        case SvtSaveOptions::ODFVER_LATEST: pVersion = "1.2"; break;
-        case SvtSaveOptions::ODFVER_012_EXT_COMPAT: pVersion = "1.2"; break;
-        case SvtSaveOptions::ODFVER_012: pVersion = "1.2"; break;
-        case SvtSaveOptions::ODFVER_011: pVersion = "1.1"; break;
-        case SvtSaveOptions::ODFVER_010: break;
-
-        default:
-            OSL_FAIL("xmloff::XMLMetaExportComponent::exportDoc(), unexpected odf default version!");
-        }
+        const char*const pVersion = GetODFVersionAttributeValue();
 
         if( pVersion )
             AddAttribute( XML_NAMESPACE_OFFICE, XML_VERSION,


More information about the Libreoffice-commits mailing list