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

Laurent Balland-Poirier laurent.balland-poirier at laposte.net
Mon Apr 27 16:24:51 PDT 2015


 include/xmloff/xmlnumfe.hxx      |    2 +-
 include/xmloff/xmltoken.hxx      |    1 +
 xmloff/source/core/xmltoken.cxx  |    1 +
 xmloff/source/style/xmlnumfe.cxx |   17 +++++++++++++++--
 xmloff/source/style/xmlnumfi.cxx |   13 ++++++++++++-
 5 files changed, 30 insertions(+), 4 deletions(-)

New commits:
commit 38992b419a4655eba9b85d337edbb208fd2fff95
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date:   Sun Mar 22 22:01:53 2015 +0100

    tdf#90133 Extend ODF: exponent sign of scientific format
    
    Scientific Format without sign in exponent, such as 0.00E0,
    are managed by LibO, and can be saved in XLS format
    This commit allows to save in ODF
    
    Change-Id: Ia0c4589e2af942543ea296f970d163bc1d1d6f05
    Reviewed-on: https://gerrit.libreoffice.org/14955
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/include/xmloff/xmlnumfe.hxx b/include/xmloff/xmlnumfe.hxx
index ceffa35..1f4198a 100644
--- a/include/xmloff/xmlnumfe.hxx
+++ b/include/xmloff/xmlnumfe.hxx
@@ -67,7 +67,7 @@ private:
                                         bool bGrouping, sal_Int32 nTrailingThousands,
                                         const SvXMLEmbeddedTextEntryArr& rEmbeddedEntries );
     SAL_DLLPRIVATE void WriteScientificElement_Impl( sal_Int32 nDecimals, sal_Int32 nInteger,
-                                        bool bGrouping, sal_Int32 nExp, sal_Int32 nExpInterval );
+                                        bool bGrouping, sal_Int32 nExp, sal_Int32 nExpInterval, bool bExpSign );
     SAL_DLLPRIVATE void WriteFractionElement_Impl( sal_Int32 nInteger, bool bGrouping,
                                         sal_Int32 nNumeratorDigits, sal_Int32 nDenominatorDigits, sal_Int32 nDenominator );
     SAL_DLLPRIVATE void WriteCurrencyElement_Impl( const OUString& rString,
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index a4f026d..af2fcdb 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3250,6 +3250,7 @@ namespace xmloff { namespace token {
         XML_EXTERNALDATA,
 
         XML_EXPONENT_INTERVAL,
+        XML_EXPONENT_SIGN,
 
         XML_TOKEN_END
     };
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 27d4c32..5a853e7 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3248,6 +3248,7 @@ namespace xmloff { namespace token {
         TOKEN( "external-data", XML_EXTERNALDATA),
 
         TOKEN( "exponent-interval",               XML_EXPONENT_INTERVAL ),
+        TOKEN( "exponent-sign",                   XML_EXPONENT_SIGN ),
 
 #if OSL_DEBUG_LEVEL > 0
         { 0, NULL, NULL,                       XML_TOKEN_END }
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 91c78e4..2c0bab4 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -634,7 +634,7 @@ void SvXMLNumFmtExport::WriteNumberElement_Impl(
 
 void SvXMLNumFmtExport::WriteScientificElement_Impl(
                             sal_Int32 nDecimals, sal_Int32 nInteger,
-                            bool bGrouping, sal_Int32 nExp, sal_Int32 nExpInterval )
+                            bool bGrouping, sal_Int32 nExp, sal_Int32 nExpInterval, bool bExpSign )
 {
     FinishTextElement_Impl();
 
@@ -679,6 +679,16 @@ void SvXMLNumFmtExport::WriteScientificElement_Impl(
         }
     }
 
+    //  exponent sign
+    if ( bExpSign )
+    {
+        rExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_EXPONENT_SIGN, XML_TRUE );
+    }
+    else
+    {
+        rExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_EXPONENT_SIGN, XML_FALSE );
+    }
+
     SvXMLElementExport aElem( rExport,
                               XML_NAMESPACE_NUMBER, XML_SCIENTIFIC_NUMBER,
                               true, false );
@@ -1162,6 +1172,7 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
         bool bExpFound   = false;
         bool bCurrFound  = false;
         bool bInInteger  = true;
+        bool bExpSign = true;
         sal_Int32 nExpDigits = 0;
         sal_Int32 nIntegerSymbols = 0;          // for embedded-text, including "#"
         sal_Int32 nTrailingThousands = 0;       // thousands-separators after all digits
@@ -1204,6 +1215,8 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
                 case NF_SYMBOLTYPE_EXP:
                     bExpFound = true;           // following digits are exponent digits
                     bInInteger = false;
+                    if ( pElemStr && pElemStr->getLength() == 1 )
+                        bExpSign = false;       // for 0.00E0
                     break;
                 case NF_SYMBOLTYPE_CURRENCY:
                     bCurrFound = true;
@@ -1415,7 +1428,7 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
                                 // #i43959# for scientific numbers, count all integer symbols ("0" and "#")
                                 // as integer digits: use nIntegerSymbols instead of nLeading
                                 // nIntegerSymbols represents exponent interval (for engineering notation)
-                                WriteScientificElement_Impl( nPrecision, nLeading, bThousand, nExpDigits, nIntegerSymbols );
+                                WriteScientificElement_Impl( nPrecision, nLeading, bThousand, nExpDigits, nIntegerSymbols, bExpSign );
                                 bAnyContent = true;
                                 break;
                             case css::util::NumberFormat::FRACTION:
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index f7b9e82..02f31cd 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -117,6 +117,7 @@ struct SvXMLNumberInfo
     bool        bGrouping;
     bool        bDecReplace;
     bool        bVarDecimals;
+    bool        bExpSign;
     double      fDisplayFactor;
     SvXMLEmbeddedElementArr aEmbeddedElements;
 
@@ -124,6 +125,7 @@ struct SvXMLNumberInfo
     {
         nDecimals = nInteger = nExpDigits = nExpInterval = nNumerDigits = nDenomDigits = nFracDenominator = -1;
         bGrouping = bDecReplace = bVarDecimals = false;
+        bExpSign = true;
         fDisplayFactor = 1.0;
     }
 };
@@ -278,6 +280,7 @@ enum SvXMLStyleElemAttrTokens
     XML_TOK_ELEM_ATTR_DENOMINATOR_VALUE,
     XML_TOK_ELEM_ATTR_MIN_EXPONENT_DIGITS,
     XML_TOK_ELEM_ATTR_EXPONENT_INTERVAL,
+    XML_TOK_ELEM_ATTR_EXPONENT_SIGN,
     XML_TOK_ELEM_ATTR_MIN_NUMERATOR_DIGITS,
     XML_TOK_ELEM_ATTR_MIN_DENOMINATOR_DIGITS,
     XML_TOK_ELEM_ATTR_RFC_LANGUAGE_TAG,
@@ -575,6 +578,7 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStyleElemAttrTokenMap()
             { XML_NAMESPACE_NUMBER, XML_MIN_EXPONENT_DIGITS,     XML_TOK_ELEM_ATTR_MIN_EXPONENT_DIGITS  },
             { 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_EXPONENT_SIGN,           XML_TOK_ELEM_ATTR_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     },
@@ -966,6 +970,10 @@ SvXMLNumFmtElementContext::SvXMLNumFmtElementContext( SvXMLImport& rImport,
                 if (::sax::Converter::convertNumber( nAttrVal, sValue, 0 ))
                     aNumInfo.nExpInterval = nAttrVal;
                 break;
+            case XML_TOK_ELEM_ATTR_EXPONENT_SIGN:
+                if (::sax::Converter::convertBool( bAttrBool, sValue ))
+                    aNumInfo.bExpSign = bAttrBool;
+                break;
             case XML_TOK_ELEM_ATTR_MIN_NUMERATOR_DIGITS:
                 if (::sax::Converter::convertNumber( nAttrVal, sValue, 0 ))
                     aNumInfo.nNumerDigits = nAttrVal;
@@ -1237,7 +1245,10 @@ void SvXMLNumFmtElementContext::EndElement()
                 }
                 rParent.AddNumber( aNumInfo );      // simple number
 
-                rParent.AddToCode( OUString("E+") );
+                if ( aNumInfo.bExpSign )
+                    rParent.AddToCode( OUString("E+") );
+                else
+                    rParent.AddToCode( OUString("E") );
                 for (sal_Int32 i=0; i<aNumInfo.nExpDigits; i++)
                 {
                     rParent.AddToCode( '0' );


More information about the Libreoffice-commits mailing list