[Libreoffice-commits] core.git: 2 commits - chart2/source

Eike Rathke erack at redhat.com
Mon Aug 10 08:13:44 PDT 2015


 chart2/source/tools/DiagramHelper.cxx |   56 ++++++++++++++++++++--------------
 1 file changed, 33 insertions(+), 23 deletions(-)

New commits:
commit 0f4b3cb7d3d68906de316a64dcec281da2a641bd
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Aug 10 17:04:13 2015 +0200

    if we have a number formatter then use it, dammit..
    
    Change-Id: I2d70bed4d9cf6f0ef4556a327c51fc5c10fcd2be

diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index c77c9a5..3dcbf4b 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -1243,16 +1243,25 @@ sal_Int32 DiagramHelper::getDateTimeInputNumberFormat( const Reference< util::XN
 sal_Int32 DiagramHelper::getPercentNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier )
 {
     sal_Int32 nRet=-1;
-    Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() );
-    if( xNumberFormats.is() )
+    const LanguageTag& rLanguageTag = Application::GetSettings().GetLanguageTag();
+    NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier );
+    SvNumberFormatter* pNumFormatter = aNumberFormatterWrapper.getSvNumberFormatter();
+    if( pNumFormatter )
     {
-        bool bCreate = true;
-        const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper();
-        Sequence<sal_Int32> aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::PERCENT,
-            rLocaleDataWrapper.getLanguageTag().getLocale(), bCreate );
-        if( aKeySeq.getLength() )
+        nRet = pNumFormatter->GetStandardFormat( util::NumberFormat::PERCENT, rLanguageTag.getLanguageType() );
+    }
+    else
+    {
+        Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() );
+        if( xNumberFormats.is() )
         {
-            nRet = aKeySeq[0];
+            bool bCreate = true;
+            Sequence<sal_Int32> aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::PERCENT,
+                    rLanguageTag.getLocale(), bCreate );
+            if( aKeySeq.getLength() )
+            {
+                nRet = aKeySeq[0];
+            }
         }
     }
     return nRet;
commit ae9a59382f11166da44512a01ae38fc4790ac0d4
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Aug 10 16:40:39 2015 +0200

    if we have a number formatter then use it, dammit..
    
    Change-Id: I43b777bb0b3f53682bab7af4643b29e2bd313caa

diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 2b522b1..c77c9a5 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -1165,27 +1165,28 @@ bool DiagramHelper::isDateNumberFormat( sal_Int32 nNumberFormat, const Reference
 sal_Int32 DiagramHelper::getDateNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier )
 {
     sal_Int32 nRet=-1;
-    Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() );
-    if( xNumberFormats.is() )
-    {
-        bool bCreate = true;
-        const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper();
-        Sequence<sal_Int32> aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::DATE,
-            rLocaleDataWrapper.getLanguageTag().getLocale(), bCreate );
-        if( aKeySeq.getLength() )
-        {
-            nRet = aKeySeq[0];
-        }
-    }
 
     //try to get a date format with full year display
+    const LanguageTag& rLanguageTag = Application::GetSettings().GetLanguageTag();
     NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier );
     SvNumberFormatter* pNumFormatter = aNumberFormatterWrapper.getSvNumberFormatter();
     if( pNumFormatter )
     {
-        const SvNumberformat* pFormat = pNumFormatter->GetEntry( nRet );
-        if( pFormat )
-            nRet = pNumFormatter->GetFormatIndex( NF_DATE_SYS_DDMMYYYY, pFormat->GetLanguage() );
+        nRet = pNumFormatter->GetFormatIndex( NF_DATE_SYS_DDMMYYYY, rLanguageTag.getLanguageType() );
+    }
+    else
+    {
+        Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() );
+        if( xNumberFormats.is() )
+        {
+            bool bCreate = true;
+            Sequence<sal_Int32> aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::DATE,
+                    rLanguageTag.getLocale(), bCreate );
+            if( aKeySeq.getLength() )
+            {
+                nRet = aKeySeq[0];
+            }
+        }
     }
     return nRet;
 }


More information about the Libreoffice-commits mailing list