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

Eike Rathke erack at redhat.com
Sun Mar 22 12:31:34 PDT 2015


 include/unotools/saveopt.hxx       |   24 ++++++++++++++++++++++--
 include/xmloff/xmlexp.hxx          |    3 +++
 unotools/source/config/saveopt.cxx |   24 ++++++++++++++++++++++++
 xmloff/source/core/xmlexp.cxx      |    9 +++++++++
 xmloff/source/style/xmlnumfe.cxx   |   15 +++------------
 5 files changed, 61 insertions(+), 14 deletions(-)

New commits:
commit 7b7f5c70c650c2c74e0f266b57630d033fcf27a3
Author: Eike Rathke <erack at redhat.com>
Date:   Sun Mar 22 19:27:33 2015 +0000

    use ODFSaneDefaultVersion to determine if and how to store exponent-interval
    
    Change-Id: I58d4c75806d656cb3f8bf971efecba6f775e05a9

diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index dbfed8c..91c78e4 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -669,22 +669,13 @@ void SvXMLNumFmtExport::WriteScientificElement_Impl(
     if ( nExpInterval >= 0 )
     {
         // Export only for 1.2 with extensions or 1.3 and later.
-        SvtSaveOptions::ODFDefaultVersion eVersion = rExport.getDefaultVersion();
-        if (eVersion > SvtSaveOptions::ODFVER_012)
+        SvtSaveOptions::ODFSaneDefaultVersion eVersion = rExport.getSaneDefaultVersion();
+        if (eVersion > SvtSaveOptions::ODFSVER_012)
         {
-            // TODO: change this once the fouled up ODFVER_LATEST is a real
-            // 1.2+ or 1.3 or 1.3+ ... and only in configuration means latest.
-#if 1
-            // Currently 1.2+ is ODFVER_LATEST which is >ODFVER_012 and
-            // >ODFVER_013 and prevents correct handling..
-            rExport.AddAttribute( XML_NAMESPACE_LO_EXT,
-                    XML_EXPONENT_INTERVAL, OUString::number( nExpInterval ) );
-#else
             // For 1.2+ use loext namespace, for 1.3 use number namespace.
             rExport.AddAttribute(
-                    ((eVersion < SvtSaveOptions::ODFVER_013) ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
+                    ((eVersion < SvtSaveOptions::ODFSVER_013) ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
                     XML_EXPONENT_INTERVAL, OUString::number( nExpInterval ) );
-#endif
         }
     }
 
commit de6f1651326da9cc44b137779e5d3131cab5133e
Author: Eike Rathke <erack at redhat.com>
Date:   Sun Mar 22 19:22:55 2015 +0000

    introduce SvXMLExport::getSaneDefaultVersion()
    
    Change-Id: I1b73b4850e78f4ec0823894b93b8bc1cbadf0d0d

diff --git a/include/xmloff/xmlexp.hxx b/include/xmloff/xmlexp.hxx
index b8fab9f..dc47596 100644
--- a/include/xmloff/xmlexp.hxx
+++ b/include/xmloff/xmlexp.hxx
@@ -566,6 +566,9 @@ public:
     /// returns the currently configured default version for odf export
     SvtSaveOptions::ODFDefaultVersion getDefaultVersion() const;
 
+    /// returns the deterministic version for odf export
+    SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const;
+
     /// name of stream in package, e.g., "content.xml"
     OUString GetStreamName() const;
 
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index c751b7c..e6ef5df 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -2428,6 +2428,15 @@ SvtSaveOptions::ODFDefaultVersion SvXMLExport::getDefaultVersion() const
     return SvtSaveOptions::ODFVER_012;
 }
 
+SvtSaveOptions::ODFSaneDefaultVersion SvXMLExport::getSaneDefaultVersion() const
+{
+    if( mpImpl )
+        return mpImpl->maSaveOptions.GetODFSaneDefaultVersion();
+
+    // fatal error, use current version as default
+    return SvtSaveOptions::ODFSVER_012;
+}
+
 OUString SvXMLExport::GetStreamName() const
 {
     return mpImpl->mStreamName;
commit dd8c23522f9123bdf02c366e2abb7b1439028848
Author: Eike Rathke <erack at redhat.com>
Date:   Sun Mar 22 19:14:32 2015 +0000

    introduce ODFSaneDefaultVersion; ODFDefaultVersion is a mess, mess, mess..
    
    A running ODFVER_LATEST is fine for configuration purposes, but not for
    determining how to store a feature.
    
    Change-Id: I8ebc13f900f62f8c36d2cdc50a18855fc6693527

diff --git a/include/unotools/saveopt.hxx b/include/unotools/saveopt.hxx
index 207ad42..c9d793d 100644
--- a/include/unotools/saveopt.hxx
+++ b/include/unotools/saveopt.hxx
@@ -51,7 +51,14 @@ public:
         E_USERAUTOSAVE,
     };
 
-    // keep enum values sorted that a less or greater compare maps to older and newer versions!
+    /** Keep enum values sorted that a less or greater compare maps to older
+        and newer versions.
+        Do not change values, they are stored in the configuration.
+        ODFVER_LATEST designates the "current greatest and latest".
+        When adding a new value or ODFVER_LATEST designates a new real version
+        (plus extensions) adjust the mapping in
+        SvtSaveOptions::GetODFSaneDefaultVersion().
+     */
     enum ODFDefaultVersion
     {
         ODFVER_UNKNOWN = 0, // unknown
@@ -60,11 +67,23 @@ public:
         DO_NOT_USE = 3,         // Do not use this, only here for compatibility with pre OOo 3.2 configuration
         ODFVER_012 = 4,         // ODF 1.2
         ODFVER_012_EXT_COMPAT = 8, // ODF 1.2 extended, but with compatibility fallbacks
-        ODFVER_013 = 9,         // ODF 1.3
 
         ODFVER_LATEST = SAL_MAX_ENUM,      // ODF latest version with enhancements
     };
 
+    /// Enums that allow a sane comparison of versions, without LATEST.
+    enum ODFSaneDefaultVersion
+    {
+        ODFSVER_EXTENDED = 1,       // bit designating extensions are allowed
+        ODFSVER_010 = 2,            // ODF 1.0
+        ODFSVER_011 = 4,            // ODF 1.1
+        ODFSVER_012 = 6,            // ODF 1.2
+        ODFSVER_012_EXT_COMPAT = 9, // ODF 1.2 extended, but with compatibility fallbacks
+        ODFSVER_012_EXTENDED = 11,  // ODF 1.2 extended
+        ODFSVER_013 = 12,           // ODF 1.3
+        ODFSVER_013_EXTENDED = 13   // ODF 1.3 extended
+    };
+
     SvtSaveOptions();
     virtual ~SvtSaveOptions();
 
@@ -117,6 +136,7 @@ public:
 
     void                    SetODFDefaultVersion( ODFDefaultVersion eVersion );
     ODFDefaultVersion       GetODFDefaultVersion() const;
+    ODFSaneDefaultVersion   GetODFSaneDefaultVersion() const;
 
     bool                IsUseSHA1InODF12() const;
 
diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx
index 57b0aec..18f9581 100644
--- a/unotools/source/config/saveopt.cxx
+++ b/unotools/source/config/saveopt.cxx
@@ -1005,6 +1005,30 @@ SvtSaveOptions::ODFDefaultVersion SvtSaveOptions::GetODFDefaultVersion() const
     return pImp->pSaveOpt->GetODFDefaultVersion();
 }
 
+SvtSaveOptions::ODFSaneDefaultVersion SvtSaveOptions::GetODFSaneDefaultVersion() const
+{
+    const ODFSaneDefaultVersion NOW_CURRENT_LATEST = ODFSVER_012_EXTENDED;
+
+    switch (pImp->pSaveOpt->GetODFDefaultVersion())
+    {
+        default:
+            assert(!"map new ODFDefaultVersion to ODFSaneDefaultVersion");
+            break;
+        case ODFVER_UNKNOWN:
+        case ODFVER_LATEST:
+            return NOW_CURRENT_LATEST;
+        case ODFVER_010:
+            return ODFSVER_010;
+        case ODFVER_011:
+            return ODFSVER_011;
+        case ODFVER_012:
+            return ODFSVER_012;
+        case ODFVER_012_EXT_COMPAT:
+            return ODFSVER_012_EXT_COMPAT;
+    }
+    return NOW_CURRENT_LATEST;
+}
+
 bool SvtSaveOptions::IsUseSHA1InODF12() const
 {
     return pImp->pSaveOpt->IsUseSHA1InODF12();


More information about the Libreoffice-commits mailing list