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

Laurent Balland-Poirier laurent.balland-poirier at laposte.net
Mon May 30 10:34:40 UTC 2016


 xmloff/source/style/xmlnumfe.cxx |   40 +++++++++++++++++++++++++++------------
 xmloff/source/style/xmlnumfi.cxx |    2 +
 2 files changed, 30 insertions(+), 12 deletions(-)

New commits:
commit e0c8c5b711e4cacb3f666a939f285289479d3d20
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date:   Sat May 28 19:53:12 2016 +0200

    Choose ODF version for min-decimal-place and force-exponent-sign
    
    Change-Id: I873dbf53bbb865577fd51ee70142c1b45ea54ce2
    Reviewed-on: https://gerrit.libreoffice.org/25588
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index b1637f8..229237c 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -569,8 +569,16 @@ void SvXMLNumFmtExport::WriteNumberElement_Impl(
 
     if ( nMinDecimals >= 0 )   // negative = automatic
     {
-        rExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_MIN_DECIMAL_PLACES,
-                              OUString::number( nMinDecimals ) );
+        // Export only for 1.2 with extensions or 1.3 and later.
+        SvtSaveOptions::ODFSaneDefaultVersion eVersion = rExport.getSaneDefaultVersion();
+        if (eVersion > SvtSaveOptions::ODFSVER_012)
+        {
+            // For 1.2+ use loext namespace, for 1.3 use number namespace.
+            rExport.AddAttribute(
+                ((eVersion < SvtSaveOptions::ODFSVER_013) ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
+                                 XML_MIN_DECIMAL_PLACES,
+                                 OUString::number( nMinDecimals ) );
+        }
     }
 
     //  integer digits
@@ -648,10 +656,18 @@ void SvXMLNumFmtExport::WriteScientificElement_Impl(
                               OUString::number( nDecimals ) );
     }
 
+    SvtSaveOptions::ODFSaneDefaultVersion eVersion = rExport.getSaneDefaultVersion();
     if ( nMinDecimals >= 0 )   // negative = automatic
     {
-        rExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_MIN_DECIMAL_PLACES,
-                              OUString::number( nMinDecimals ) );
+        // Export only for 1.2 with extensions or 1.3 and later.
+        if (eVersion > SvtSaveOptions::ODFSVER_012)
+        {
+            // For 1.2+ use loext namespace, for 1.3 use number namespace.
+            rExport.AddAttribute(
+                ((eVersion < SvtSaveOptions::ODFSVER_013) ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
+                                 XML_MIN_DECIMAL_PLACES,
+                                 OUString::number( nMinDecimals ) );
+        }
     }
 
     //  integer digits
@@ -678,7 +694,6 @@ void SvXMLNumFmtExport::WriteScientificElement_Impl(
     if ( nExpInterval >= 0 )
     {
         // Export only for 1.2 with extensions or 1.3 and later.
-        SvtSaveOptions::ODFSaneDefaultVersion eVersion = rExport.getSaneDefaultVersion();
         if (eVersion > SvtSaveOptions::ODFSVER_012)
         {
             // For 1.2+ use loext namespace, for 1.3 use number namespace.
@@ -689,13 +704,14 @@ void SvXMLNumFmtExport::WriteScientificElement_Impl(
     }
 
     //  exponent sign
-    if ( bExpSign )
-    {
-        rExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_FORCED_EXPONENT_SIGN, XML_TRUE );
-    }
-    else
-    {
-        rExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_FORCED_EXPONENT_SIGN, XML_FALSE );
+    // Export only for 1.2 with extensions or 1.3 and later.
+    if (eVersion > SvtSaveOptions::ODFSVER_012)
+    {
+        // For 1.2+ use loext namespace, for 1.3 use number namespace.
+        rExport.AddAttribute(
+            ((eVersion < SvtSaveOptions::ODFSVER_013) ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
+                             XML_FORCED_EXPONENT_SIGN,
+                             bExpSign? XML_TRUE : XML_FALSE );
     }
 
     SvXMLElementExport aElem( rExport,
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index dbf7864..ddd925c 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -549,6 +549,7 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStyleElemAttrTokenMap()
             //  attributes for an element within a style
             { XML_NAMESPACE_NUMBER, XML_DECIMAL_PLACES,          XML_TOK_ELEM_ATTR_DECIMAL_PLACES       },
             { XML_NAMESPACE_LO_EXT, XML_MIN_DECIMAL_PLACES,      XML_TOK_ELEM_ATTR_MIN_DECIMAL_PLACES   },
+            { XML_NAMESPACE_NUMBER, XML_MIN_DECIMAL_PLACES,      XML_TOK_ELEM_ATTR_MIN_DECIMAL_PLACES   },
             { XML_NAMESPACE_NUMBER, XML_MIN_INTEGER_DIGITS,      XML_TOK_ELEM_ATTR_MIN_INTEGER_DIGITS   },
             { XML_NAMESPACE_NUMBER, XML_GROUPING,                XML_TOK_ELEM_ATTR_GROUPING             },
             { XML_NAMESPACE_NUMBER, XML_DISPLAY_FACTOR,          XML_TOK_ELEM_ATTR_DISPLAY_FACTOR       },
@@ -558,6 +559,7 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStyleElemAttrTokenMap()
             { XML_NAMESPACE_LO_EXT, XML_EXPONENT_INTERVAL,       XML_TOK_ELEM_ATTR_EXPONENT_INTERVAL    },
             { XML_NAMESPACE_NUMBER, XML_EXPONENT_INTERVAL,       XML_TOK_ELEM_ATTR_EXPONENT_INTERVAL    },
             { XML_NAMESPACE_LO_EXT, XML_FORCED_EXPONENT_SIGN,    XML_TOK_ELEM_ATTR_FORCED_EXPONENT_SIGN },
+            { XML_NAMESPACE_NUMBER, XML_FORCED_EXPONENT_SIGN,    XML_TOK_ELEM_ATTR_FORCED_EXPONENT_SIGN },
             { XML_NAMESPACE_NUMBER, XML_MIN_NUMERATOR_DIGITS,    XML_TOK_ELEM_ATTR_MIN_NUMERATOR_DIGITS },
             { XML_NAMESPACE_NUMBER, XML_MIN_DENOMINATOR_DIGITS,  XML_TOK_ELEM_ATTR_MIN_DENOMINATOR_DIGITS },
             { XML_NAMESPACE_NUMBER, XML_RFC_LANGUAGE_TAG,        XML_TOK_ELEM_ATTR_RFC_LANGUAGE_TAG     },


More information about the Libreoffice-commits mailing list