LCOV - code coverage report
Current view: top level - svl/source/numbers - numfmuno.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 252 513 49.1 %
Date: 2015-06-13 12:38:46 Functions: 36 69 52.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <tools/color.hxx>
      21             : #include <i18nlangtag/mslangid.hxx>
      22             : #include <osl/mutex.hxx>
      23             : #include <osl/diagnose.h>
      24             : #include <rtl/ustring.hxx>
      25             : 
      26             : #include <com/sun/star/util/Date.hpp>
      27             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      28             : #include <cppuhelper/supportsservice.hxx>
      29             : 
      30             : #include "numfmuno.hxx"
      31             : #include <svl/numuno.hxx>
      32             : #include <svl/zforlist.hxx>
      33             : #include <svl/zformat.hxx>
      34             : #include <svl/itemprop.hxx>
      35             : 
      36             : using namespace com::sun::star;
      37             : 
      38             : #define PROPERTYNAME_FMTSTR     "FormatString"
      39             : #define PROPERTYNAME_LOCALE     "Locale"
      40             : #define PROPERTYNAME_TYPE       "Type"
      41             : #define PROPERTYNAME_COMMENT    "Comment"
      42             : #define PROPERTYNAME_CURREXT    "CurrencyExtension"
      43             : #define PROPERTYNAME_CURRSYM    "CurrencySymbol"
      44             : #define PROPERTYNAME_CURRABB    "CurrencyAbbreviation"
      45             : #define PROPERTYNAME_DECIMALS   "Decimals"
      46             : #define PROPERTYNAME_LEADING    "LeadingZeros"
      47             : #define PROPERTYNAME_NEGRED     "NegativeRed"
      48             : #define PROPERTYNAME_STDFORM    "StandardFormat"
      49             : #define PROPERTYNAME_THOUS      "ThousandsSeparator"
      50             : #define PROPERTYNAME_USERDEF    "UserDefined"
      51             : 
      52             : #define PROPERTYNAME_NOZERO     "NoZero"
      53             : #define PROPERTYNAME_NULLDATE   "NullDate"
      54             : #define PROPERTYNAME_STDDEC     "StandardDecimals"
      55             : #define PROPERTYNAME_TWODIGIT   "TwoDigitDateStart"
      56             : 
      57             : // All without a Which-ID, Map only for PropertySetInfo
      58             : 
      59           0 : static const SfxItemPropertyMapEntry* lcl_GetNumberFormatPropertyMap()
      60             : {
      61             :     static const SfxItemPropertyMapEntry aNumberFormatPropertyMap_Impl[] =
      62             :     {
      63           0 :         {OUString(PROPERTYNAME_FMTSTR),   0, cppu::UnoType<OUString>::get(),    beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      64           0 :         {OUString(PROPERTYNAME_LOCALE),   0, cppu::UnoType<lang::Locale>::get(),beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      65           0 :         {OUString(PROPERTYNAME_TYPE),     0, cppu::UnoType<sal_Int16>::get(),   beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      66           0 :         {OUString(PROPERTYNAME_COMMENT),  0, cppu::UnoType<OUString>::get(),    beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      67           0 :         {OUString(PROPERTYNAME_CURREXT),  0, cppu::UnoType<OUString>::get(),    beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      68           0 :         {OUString(PROPERTYNAME_CURRSYM),  0, cppu::UnoType<OUString>::get(),    beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      69           0 :         {OUString(PROPERTYNAME_DECIMALS), 0, cppu::UnoType<sal_Int16>::get(),   beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      70           0 :         {OUString(PROPERTYNAME_LEADING),  0, cppu::UnoType<sal_Int16>::get(),   beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      71           0 :         {OUString(PROPERTYNAME_NEGRED),   0, cppu::UnoType<bool>::get(),         beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      72           0 :         {OUString(PROPERTYNAME_STDFORM),  0, cppu::UnoType<bool>::get(),         beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      73           0 :         {OUString(PROPERTYNAME_THOUS),    0, cppu::UnoType<bool>::get(),         beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      74           0 :         {OUString(PROPERTYNAME_USERDEF),  0, cppu::UnoType<bool>::get(),         beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      75           0 :         {OUString(PROPERTYNAME_CURRABB),  0, cppu::UnoType<OUString>::get(),    beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
      76             :         { OUString(), 0, css::uno::Type(), 0, 0 }
      77           0 :     };
      78           0 :     return aNumberFormatPropertyMap_Impl;
      79             : }
      80             : 
      81           5 : static const SfxItemPropertyMapEntry* lcl_GetNumberSettingsPropertyMap()
      82             : {
      83             :     static const SfxItemPropertyMapEntry aNumberSettingsPropertyMap_Impl[] =
      84             :     {
      85           5 :         {OUString(PROPERTYNAME_NOZERO),   0, cppu::UnoType<bool>::get(),         beans::PropertyAttribute::BOUND, 0},
      86           5 :         {OUString(PROPERTYNAME_NULLDATE), 0, cppu::UnoType<util::Date>::get(),  beans::PropertyAttribute::BOUND, 0},
      87           5 :         {OUString(PROPERTYNAME_STDDEC),   0, cppu::UnoType<sal_Int16>::get(),   beans::PropertyAttribute::BOUND, 0},
      88           5 :         {OUString(PROPERTYNAME_TWODIGIT), 0, cppu::UnoType<sal_Int16>::get(),   beans::PropertyAttribute::BOUND, 0},
      89             :         { OUString(), 0, css::uno::Type(), 0, 0 }
      90          30 :     };
      91           5 :     return aNumberSettingsPropertyMap_Impl;
      92             : }
      93             : 
      94       26428 : static LanguageType lcl_GetLanguage( const lang::Locale& rLocale )
      95             : {
      96             :     //  empty language -> LANGUAGE_SYSTEM
      97       26428 :     if ( rLocale.Language.isEmpty() )
      98        5230 :         return LANGUAGE_SYSTEM;
      99             : 
     100       21198 :     LanguageType eRet = LanguageTag::convertToLanguageType( rLocale, false);
     101       21198 :     if ( eRet == LANGUAGE_NONE )
     102           0 :         eRet = LANGUAGE_SYSTEM; //! or throw an exception?
     103             : 
     104       21198 :     return eRet;
     105             : }
     106             : 
     107          96 : SvNumberFormatterServiceObj::SvNumberFormatterServiceObj()
     108          96 :     :m_aMutex()
     109             : {
     110          96 : }
     111             : 
     112         176 : SvNumberFormatterServiceObj::~SvNumberFormatterServiceObj()
     113             : {
     114         176 : }
     115             : 
     116             : // XNumberFormatter
     117             : 
     118         174 : void SAL_CALL SvNumberFormatterServiceObj::attachNumberFormatsSupplier( const uno::Reference<util::XNumberFormatsSupplier>& _xSupplier )
     119             :     throw(uno::RuntimeException, std::exception)
     120             : {
     121         174 :     ::rtl::Reference< SvNumberFormatsSupplierObj > xAutoReleaseOld;
     122             : 
     123             :     // SYNCHRONIZED ->
     124             :     {
     125         174 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     126             : 
     127         174 :         SvNumberFormatsSupplierObj* pNew = SvNumberFormatsSupplierObj::getImplementation( _xSupplier );
     128         174 :         if (!pNew)
     129           0 :             throw uno::RuntimeException(); // wrong object
     130             : 
     131         174 :         xAutoReleaseOld = xSupplier;
     132             : 
     133         174 :         xSupplier = pNew;
     134         174 :         m_aMutex = xSupplier->getSharedMutex();
     135         174 :     }
     136             :     // <- SYNCHRONIZED
     137         174 : }
     138             : 
     139         151 : uno::Reference<util::XNumberFormatsSupplier> SAL_CALL SvNumberFormatterServiceObj::getNumberFormatsSupplier()
     140             :     throw(uno::RuntimeException, std::exception)
     141             : {
     142         151 :     ::osl::MutexGuard aGuard( m_aMutex );
     143         151 :     return xSupplier.get();
     144             : }
     145             : 
     146           2 : sal_Int32 SAL_CALL SvNumberFormatterServiceObj::detectNumberFormat( sal_Int32 nKey, const OUString& aString )
     147             :     throw(util::NotNumericException, uno::RuntimeException, std::exception)
     148             : {
     149           2 :     ::osl::MutexGuard aGuard( m_aMutex );
     150             : 
     151           2 :     sal_Int32 nRet = 0;
     152           2 :     SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
     153           2 :     if (pFormatter)
     154             :     {
     155           2 :         sal_uInt32 nUKey = nKey;
     156           2 :         double fValue = 0.0;
     157           2 :         if ( pFormatter->IsNumberFormat(aString, nUKey, fValue) )
     158           1 :             nRet = nUKey;
     159             :         else
     160           1 :             throw util::NotNumericException();
     161             :     }
     162             :     else
     163           0 :         throw uno::RuntimeException();
     164             : 
     165           2 :     return nRet;
     166             : }
     167             : 
     168           6 : double SAL_CALL SvNumberFormatterServiceObj::convertStringToNumber( sal_Int32 nKey, const OUString& aString )
     169             :     throw(util::NotNumericException, uno::RuntimeException, std::exception)
     170             : {
     171           6 :     ::osl::MutexGuard aGuard( m_aMutex );
     172             : 
     173           6 :     double fRet = 0.0;
     174           6 :     SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
     175           6 :     if (pFormatter)
     176             :     {
     177           6 :         sal_uInt32 nUKey = nKey;
     178           6 :         double fValue = 0.0;
     179           6 :         if ( pFormatter->IsNumberFormat(aString, nUKey, fValue) )
     180           6 :             fRet = fValue;
     181             :         else
     182           0 :             throw util::NotNumericException();
     183             :     }
     184             :     else
     185           0 :         throw uno::RuntimeException();
     186             : 
     187           6 :     return fRet;
     188             : }
     189             : 
     190          57 : OUString SAL_CALL SvNumberFormatterServiceObj::convertNumberToString( sal_Int32 nKey, double fValue )
     191             :     throw(uno::RuntimeException, std::exception)
     192             : {
     193          57 :     ::osl::MutexGuard aGuard( m_aMutex );
     194             : 
     195          57 :     OUString aRet;
     196          57 :     SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
     197          57 :     if (pFormatter)
     198             :     {
     199          57 :         Color* pColor = NULL;
     200          57 :         pFormatter->GetOutputString(fValue, nKey, aRet, &pColor);
     201             :     }
     202             :     else
     203           0 :         throw uno::RuntimeException();
     204             : 
     205          57 :     return aRet;
     206             : }
     207             : 
     208           0 : util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForNumber( sal_Int32 nKey,
     209             :                                                                        double fValue,
     210             :                                                                        util::Color aDefaultColor )
     211             :     throw(uno::RuntimeException, std::exception)
     212             : {
     213           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     214             : 
     215           0 :     util::Color nRet = aDefaultColor; // color = sal_Int32
     216           0 :     SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
     217           0 :     if (pFormatter)
     218             :     {
     219           0 :         OUString aStr;
     220           0 :         Color* pColor = NULL;
     221           0 :         pFormatter->GetOutputString(fValue, nKey, aStr, &pColor);
     222           0 :         if (pColor)
     223           0 :             nRet = pColor->GetColor();
     224             :         // Else keep Default
     225             :     }
     226             :     else
     227           0 :         throw uno::RuntimeException();
     228             : 
     229           0 :     return nRet;
     230             : }
     231             : 
     232           0 : OUString SAL_CALL SvNumberFormatterServiceObj::formatString( sal_Int32 nKey,
     233             :                                                              const OUString& aString )
     234             :     throw(uno::RuntimeException, std::exception)
     235             : {
     236           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     237             : 
     238           0 :     OUString aRet;
     239           0 :     SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
     240           0 :     if (pFormatter)
     241             :     {
     242           0 :         Color* pColor = NULL;
     243           0 :         pFormatter->GetOutputString(aString, nKey, aRet, &pColor);
     244             :     }
     245             :     else
     246             :     {
     247           0 :         throw uno::RuntimeException();
     248             :     }
     249           0 :     return aRet;
     250             : }
     251             : 
     252           0 : util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForString( sal_Int32 nKey,
     253             :                                                                        const OUString& aString,
     254             :                                                                        util::Color aDefaultColor )
     255             :     throw(uno::RuntimeException, std::exception)
     256             : {
     257           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     258             : 
     259           0 :     util::Color nRet = aDefaultColor; // color = sal_Int32
     260           0 :     SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
     261           0 :     if (pFormatter)
     262             :     {
     263           0 :         OUString aStr;
     264           0 :         Color* pColor = NULL;
     265           0 :         pFormatter->GetOutputString(aString, nKey, aStr, &pColor);
     266           0 :         if (pColor)
     267             :         {
     268           0 :             nRet = pColor->GetColor();
     269           0 :         }
     270             :         // Else keep Default
     271             :     }
     272             :     else
     273             :     {
     274           0 :         throw uno::RuntimeException();
     275             :     }
     276             : 
     277           0 :     return nRet;
     278             : }
     279             : 
     280           0 : OUString SAL_CALL SvNumberFormatterServiceObj::getInputString( sal_Int32 nKey, double fValue )
     281             :     throw(uno::RuntimeException, std::exception)
     282             : {
     283           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     284             : 
     285           0 :     OUString aRet;
     286           0 :     SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
     287           0 :     if (pFormatter)
     288           0 :         pFormatter->GetInputLineString(fValue, nKey, aRet);
     289             :     else
     290           0 :         throw uno::RuntimeException();
     291             : 
     292           0 :     return aRet;
     293             : }
     294             : 
     295             : // XNumberFormatPreviewer
     296             : 
     297           0 : OUString SAL_CALL SvNumberFormatterServiceObj::convertNumberToPreviewString( const OUString& aFormat,
     298             :                                                                              double fValue,
     299             :                                                                              const lang::Locale& nLocale,
     300             :                                                                              sal_Bool bAllowEnglish )
     301             :     throw(util::MalformedNumberFormatException, uno::RuntimeException, std::exception)
     302             : {
     303           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     304             : 
     305           0 :     OUString aRet;
     306           0 :     SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
     307           0 :     if (pFormatter)
     308             :     {
     309           0 :         LanguageType eLang = lcl_GetLanguage( nLocale );
     310           0 :         Color* pColor = NULL;
     311             : 
     312             :         bool bOk;
     313           0 :         if ( bAllowEnglish )
     314           0 :             bOk = pFormatter->GetPreviewStringGuess( aFormat, fValue, aRet, &pColor, eLang );
     315             :         else
     316           0 :             bOk = pFormatter->GetPreviewString( aFormat, fValue, aRet, &pColor, eLang );
     317             : 
     318           0 :         if (!bOk)
     319           0 :             throw util::MalformedNumberFormatException();
     320             :     }
     321             :     else
     322           0 :         throw uno::RuntimeException();
     323             : 
     324           0 :     return aRet;
     325             : }
     326             : 
     327           0 : util::Color SAL_CALL SvNumberFormatterServiceObj::queryPreviewColorForNumber( const OUString& aFormat,
     328             :                                                                               double fValue,
     329             :                                                                               const lang::Locale& nLocale,
     330             :                                                                               sal_Bool bAllowEnglish,
     331             :                                                                               util::Color aDefaultColor )
     332             :     throw(util::MalformedNumberFormatException, uno::RuntimeException, std::exception)
     333             : {
     334           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     335             : 
     336           0 :     util::Color nRet = aDefaultColor; // color = sal_Int32
     337           0 :     SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
     338           0 :     if (pFormatter)
     339             :     {
     340           0 :         OUString aOutString;
     341           0 :         LanguageType eLang = lcl_GetLanguage( nLocale );
     342           0 :         Color* pColor = NULL;
     343             : 
     344             :         bool bOk;
     345           0 :         if ( bAllowEnglish )
     346           0 :             bOk = pFormatter->GetPreviewStringGuess( aFormat, fValue, aOutString, &pColor, eLang );
     347             :         else
     348           0 :             bOk = pFormatter->GetPreviewString( aFormat, fValue, aOutString, &pColor, eLang );
     349             : 
     350           0 :         if (bOk)
     351             :         {
     352           0 :             if (pColor)
     353           0 :                 nRet = pColor->GetColor();
     354             :             // Else keep Default
     355             :         }
     356             :         else
     357           0 :             throw util::MalformedNumberFormatException();
     358             :     }
     359             :     else
     360           0 :         throw uno::RuntimeException();
     361             : 
     362           0 :     return nRet;
     363             : }
     364             : 
     365             : // XServiceInfo
     366             : 
     367           1 : OUString SAL_CALL SvNumberFormatterServiceObj::getImplementationName()
     368             :     throw(uno::RuntimeException, std::exception)
     369             : {
     370           1 :     return OUString("com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject");
     371             : }
     372             : 
     373           0 : sal_Bool SAL_CALL SvNumberFormatterServiceObj::supportsService( const OUString& ServiceName )
     374             :     throw(uno::RuntimeException, std::exception)
     375             : {
     376           0 :     return cppu::supportsService( this, ServiceName );
     377             : }
     378             : 
     379           1 : uno::Sequence<OUString> SAL_CALL SvNumberFormatterServiceObj::getSupportedServiceNames()
     380             :     throw(uno::RuntimeException, std::exception)
     381             : {
     382           1 :     uno::Sequence<OUString> aRet(1);
     383           1 :     OUString* pArray = aRet.getArray();
     384           1 :     pArray[0] = "com.sun.star.util.NumberFormatter";
     385           1 :     return aRet;
     386             : }
     387             : 
     388       13264 : SvNumberFormatsObj::SvNumberFormatsObj( SvNumberFormatsSupplierObj& _rParent, ::comphelper::SharedMutex& _rMutex )
     389             :     :rSupplier( _rParent )
     390       13264 :     ,m_aMutex( _rMutex )
     391             : {
     392       13264 :     rSupplier.acquire();
     393       13264 : }
     394             : 
     395       39792 : SvNumberFormatsObj::~SvNumberFormatsObj()
     396             : {
     397       13264 :     rSupplier.release();
     398       26528 : }
     399             : 
     400             : // XNumberFormats
     401             : 
     402       12351 : uno::Reference<beans::XPropertySet> SAL_CALL SvNumberFormatsObj::getByKey( sal_Int32 nKey )
     403             :     throw(uno::RuntimeException, std::exception)
     404             : {
     405       12351 :     ::osl::MutexGuard aGuard( m_aMutex );
     406             : 
     407       12351 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     408       12351 :     const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL;
     409       12351 :     if (pFormat)
     410       24702 :         return new SvNumberFormatObj( rSupplier, nKey, m_aMutex );
     411             :     else
     412           0 :         throw uno::RuntimeException();
     413             : }
     414             : 
     415        2735 : uno::Sequence<sal_Int32> SAL_CALL SvNumberFormatsObj::queryKeys( sal_Int16 nType,
     416             :                                                                  const lang::Locale& nLocale,
     417             :                                                                  sal_Bool bCreate )
     418             :     throw(uno::RuntimeException, std::exception)
     419             : {
     420        2735 :     ::osl::MutexGuard aGuard( m_aMutex );
     421             : 
     422        2735 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     423        2735 :     if ( pFormatter )
     424             :     {
     425        2735 :         sal_uInt32 nIndex = 0;
     426        2735 :         LanguageType eLang = lcl_GetLanguage( nLocale );
     427             :         SvNumberFormatTable& rTable = bCreate ?
     428        2735 :                                         pFormatter->ChangeCL( nType, nIndex, eLang ) :
     429        5470 :                                         pFormatter->GetEntryTable( nType, nIndex, eLang );
     430        2735 :         sal_uInt32 nCount = rTable.size();
     431        2735 :         uno::Sequence<sal_Int32> aSeq(nCount);
     432        2735 :         sal_Int32* pAry = aSeq.getArray();
     433        2735 :         sal_uInt32 i=0;
     434       88495 :         for (SvNumberFormatTable::iterator it = rTable.begin(); it != rTable.end(); ++it, ++i)
     435       85760 :             pAry[i] = it->first;
     436             : 
     437        5470 :         return aSeq;
     438             :     }
     439             :     else
     440        2735 :         throw uno::RuntimeException();
     441             : }
     442             : 
     443        1009 : sal_Int32 SAL_CALL SvNumberFormatsObj::queryKey( const OUString& aFormat,
     444             :                                                  const lang::Locale& nLocale,
     445             :                                                  sal_Bool bScan )
     446             :     throw(uno::RuntimeException, std::exception)
     447             : {
     448        1009 :     ::osl::MutexGuard aGuard( m_aMutex );
     449             : 
     450        1009 :     sal_Int32 nRet = 0;
     451        1009 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     452        1009 :     if (pFormatter)
     453             :     {
     454        1009 :         LanguageType eLang = lcl_GetLanguage( nLocale );
     455             :         if (bScan)
     456             :         {
     457             :             //! FIXME: Something still needs to happen here ...
     458             :         }
     459        1009 :         nRet = pFormatter->GetEntryKey( aFormat, eLang );
     460             :     }
     461             :     else
     462           0 :         throw uno::RuntimeException();
     463             : 
     464        1009 :     return nRet;
     465             : }
     466             : 
     467         155 : sal_Int32 SAL_CALL SvNumberFormatsObj::addNew( const OUString& aFormat,
     468             :                                                const lang::Locale& nLocale )
     469             :     throw(util::MalformedNumberFormatException, uno::RuntimeException, std::exception)
     470             : {
     471         155 :     ::osl::MutexGuard aGuard( m_aMutex );
     472             : 
     473         155 :     sal_Int32 nRet = 0;
     474         155 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     475         155 :     if (pFormatter)
     476             :     {
     477         155 :         OUString aFormStr = aFormat;
     478         155 :         LanguageType eLang = lcl_GetLanguage( nLocale );
     479         155 :         sal_uInt32 nKey = 0;
     480         155 :         sal_Int32 nCheckPos = 0;
     481         155 :         short nType = 0;
     482         155 :         bool bOk = pFormatter->PutEntry( aFormStr, nCheckPos, nType, nKey, eLang );
     483         155 :         if (bOk)
     484         155 :             nRet = nKey;
     485           0 :         else if (nCheckPos)
     486             :         {
     487           0 :             throw util::MalformedNumberFormatException(); // Invalid Format
     488             :         }
     489             :         else
     490           0 :             throw uno::RuntimeException(); // Other error (e.g. already added)
     491             :     }
     492             :     else
     493           0 :         throw uno::RuntimeException();
     494             : 
     495         155 :     return nRet;
     496             : }
     497             : 
     498        8790 : sal_Int32 SAL_CALL SvNumberFormatsObj::addNewConverted( const OUString& aFormat,
     499             :                                                         const lang::Locale& nLocale,
     500             :                                                         const lang::Locale& nNewLocale )
     501             :     throw(util::MalformedNumberFormatException, uno::RuntimeException, std::exception)
     502             : {
     503        8790 :     ::osl::MutexGuard aGuard( m_aMutex );
     504             : 
     505        8790 :     sal_Int32 nRet = 0;
     506        8790 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     507        8790 :     if (pFormatter)
     508             :     {
     509        8790 :         OUString aFormStr = aFormat;
     510        8790 :         LanguageType eLang = lcl_GetLanguage( nLocale );
     511        8790 :         LanguageType eNewLang = lcl_GetLanguage( nNewLocale );
     512        8790 :         sal_uInt32 nKey = 0;
     513        8790 :         sal_Int32 nCheckPos = 0;
     514        8790 :         short nType = 0;
     515        8790 :         bool bOk = pFormatter->PutandConvertEntry( aFormStr, nCheckPos, nType, nKey, eLang, eNewLang );
     516        8790 :         if (bOk || nKey > 0)
     517        8694 :             nRet = nKey;
     518          96 :         else if (nCheckPos)
     519             :         {
     520          37 :             throw util::MalformedNumberFormatException();       // Invalid format
     521             :         }
     522             :         else
     523        8753 :             throw uno::RuntimeException(); // Other error (e.g. already added)
     524             :     }
     525             :     else
     526           0 :         throw uno::RuntimeException();
     527             : 
     528        8790 :     return nRet;
     529             : }
     530             : 
     531           0 : void SAL_CALL SvNumberFormatsObj::removeByKey( sal_Int32 nKey ) throw(uno::RuntimeException, std::exception)
     532             : {
     533           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     534           0 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     535             : 
     536           0 :     if (pFormatter)
     537             :     {
     538           0 :         pFormatter->DeleteEntry(nKey);
     539           0 :     }
     540           0 : }
     541             : 
     542          80 : OUString SAL_CALL SvNumberFormatsObj::generateFormat( sal_Int32 nBaseKey,
     543             :                                                       const lang::Locale& nLocale,
     544             :                                                       sal_Bool bThousands,
     545             :                                                       sal_Bool bRed, sal_Int16 nDecimals,
     546             :                                                       sal_Int16 nLeading )
     547             :     throw(uno::RuntimeException, std::exception)
     548             : {
     549          80 :     ::osl::MutexGuard aGuard( m_aMutex );
     550             : 
     551          80 :     OUString aRet;
     552          80 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     553          80 :     if (pFormatter)
     554             :     {
     555          80 :         LanguageType eLang = lcl_GetLanguage( nLocale );
     556          80 :         aRet = pFormatter->GenerateFormat(nBaseKey, eLang, bThousands, bRed, nDecimals, nLeading);
     557             :     }
     558             :     else
     559           0 :         throw uno::RuntimeException();
     560             : 
     561          80 :     return aRet;
     562             : }
     563             : 
     564             : // XNumberFormatTypes
     565             : 
     566         594 : sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardIndex( const lang::Locale& nLocale )
     567             :                             throw(uno::RuntimeException, std::exception)
     568             : {
     569         594 :     ::osl::MutexGuard aGuard( m_aMutex );
     570             : 
     571         594 :     sal_Int32 nRet = 0;
     572         594 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     573         594 :     if (pFormatter)
     574             :     {
     575         594 :         LanguageType eLang = lcl_GetLanguage( nLocale );
     576         594 :         nRet = pFormatter->GetStandardIndex(eLang);
     577             :     }
     578             :     else
     579           0 :         throw uno::RuntimeException();
     580             : 
     581         594 :     return nRet;
     582             : }
     583             : 
     584         881 : sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardFormat( sal_Int16 nType, const lang::Locale& nLocale )
     585             :     throw(uno::RuntimeException, std::exception)
     586             : {
     587         881 :     ::osl::MutexGuard aGuard( m_aMutex );
     588             : 
     589         881 :     sal_Int32 nRet = 0;
     590         881 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     591         881 :     if (pFormatter)
     592             :     {
     593         881 :         LanguageType eLang = lcl_GetLanguage( nLocale );
     594             :         // Mask out "defined" bit, so type from an existing number format
     595             :         // can directly be used for getStandardFormat
     596         881 :         nType &= ~css::util::NumberFormat::DEFINED;
     597         881 :         nRet = pFormatter->GetStandardFormat(nType, eLang);
     598             :     }
     599             :     else
     600           0 :         throw uno::RuntimeException();
     601             : 
     602         881 :     return nRet;
     603             : }
     604             : 
     605        3394 : sal_Int32 SAL_CALL SvNumberFormatsObj::getFormatIndex( sal_Int16 nIndex, const lang::Locale& nLocale )
     606             :     throw(uno::RuntimeException, std::exception)
     607             : {
     608        3394 :     ::osl::MutexGuard aGuard( m_aMutex );
     609             : 
     610        3394 :     sal_Int32 nRet = 0;
     611        3394 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     612        3394 :     if (pFormatter)
     613             :     {
     614        3394 :         LanguageType eLang = lcl_GetLanguage( nLocale );
     615        3394 :         nRet = pFormatter->GetFormatIndex( (NfIndexTableOffset)nIndex, eLang );
     616             :     }
     617             :     else
     618           0 :         throw uno::RuntimeException();
     619             : 
     620        3394 :     return nRet;
     621             : }
     622             : 
     623           0 : sal_Bool SAL_CALL SvNumberFormatsObj::isTypeCompatible( sal_Int16 nOldType, sal_Int16 nNewType )
     624             :     throw(uno::RuntimeException, std::exception)
     625             : {
     626           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     627             : 
     628           0 :     bool bRet = false;
     629           0 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     630           0 :     if (pFormatter)
     631           0 :         bRet = pFormatter->IsCompatible( nOldType, nNewType );
     632             :     else
     633           0 :         throw uno::RuntimeException();
     634             : 
     635           0 :     return bRet;
     636             : }
     637             : 
     638           0 : sal_Int32 SAL_CALL SvNumberFormatsObj::getFormatForLocale( sal_Int32 nKey, const lang::Locale& nLocale )
     639             :     throw(uno::RuntimeException, std::exception)
     640             : {
     641           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     642             : 
     643           0 :     sal_Int32 nRet = 0;
     644           0 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     645           0 :     if (pFormatter)
     646             :     {
     647           0 :         LanguageType eLang = lcl_GetLanguage( nLocale );
     648           0 :         nRet = pFormatter->GetFormatForLanguageIfBuiltIn(nKey, eLang);
     649             :     }
     650             :     else
     651           0 :         throw uno::RuntimeException();
     652             : 
     653           0 :     return nRet;
     654             : }
     655             : 
     656             : // XServiceInfo
     657             : 
     658           0 : OUString SAL_CALL SvNumberFormatsObj::getImplementationName()
     659             :     throw(uno::RuntimeException, std::exception)
     660             : {
     661           0 :     return OUString("SvNumberFormatsObj");
     662             : }
     663             : 
     664           0 : sal_Bool SAL_CALL SvNumberFormatsObj::supportsService( const OUString& ServiceName )
     665             :     throw(uno::RuntimeException, std::exception)
     666             : {
     667           0 :     return cppu::supportsService( this, ServiceName );
     668             : }
     669             : 
     670           0 : uno::Sequence<OUString> SAL_CALL SvNumberFormatsObj::getSupportedServiceNames()
     671             :     throw(uno::RuntimeException, std::exception)
     672             : {
     673           0 :     uno::Sequence<OUString> aRet(1);
     674           0 :     OUString* pArray = aRet.getArray();
     675           0 :     pArray[0] = "com.sun.star.util.NumberFormats";
     676           0 :     return aRet;
     677             : }
     678             : 
     679       12351 : SvNumberFormatObj::SvNumberFormatObj( SvNumberFormatsSupplierObj& rParent, sal_uLong nK, const ::comphelper::SharedMutex& _rMutex )
     680             :     :rSupplier( rParent )
     681             :     ,nKey( nK )
     682       12351 :     ,m_aMutex( _rMutex )
     683             : {
     684       12351 :     rSupplier.acquire();
     685       12351 : }
     686             : 
     687       37053 : SvNumberFormatObj::~SvNumberFormatObj()
     688             : {
     689       12351 :     rSupplier.release();
     690       24702 : }
     691             : 
     692             : // XPropertySet
     693             : 
     694           0 : uno::Reference<beans::XPropertySetInfo> SAL_CALL SvNumberFormatObj::getPropertySetInfo()
     695             :     throw(uno::RuntimeException, std::exception)
     696             : {
     697           0 :     ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     698             :     static uno::Reference<beans::XPropertySetInfo> aRef =
     699           0 :         new SfxItemPropertySetInfo( lcl_GetNumberFormatPropertyMap() );
     700           0 :     return aRef;
     701             : }
     702             : 
     703           0 : void SAL_CALL SvNumberFormatObj::setPropertyValue( const OUString&,
     704             :                                                    const uno::Any& )
     705             :     throw(beans::UnknownPropertyException, beans::PropertyVetoException,
     706             :           lang::IllegalArgumentException, lang::WrappedTargetException,
     707             :           uno::RuntimeException, std::exception)
     708             : {
     709           0 :     throw beans::UnknownPropertyException(); // Everything is read-only
     710             : }
     711             : 
     712       13351 : uno::Any SAL_CALL SvNumberFormatObj::getPropertyValue( const OUString& aPropertyName )
     713             :     throw(beans::UnknownPropertyException, lang::WrappedTargetException,
     714             :           uno::RuntimeException, std::exception)
     715             : {
     716       13351 :     ::osl::MutexGuard aGuard( m_aMutex );
     717             : 
     718       13351 :     uno::Any aRet;
     719       13351 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     720       13351 :     const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL;
     721       13351 :     if (pFormat)
     722             :     {
     723             :         bool bThousand, bRed;
     724             :         sal_uInt16 nDecimals, nLeading;
     725             : 
     726       13351 :         if (aPropertyName == PROPERTYNAME_FMTSTR)
     727             :         {
     728         738 :             aRet <<= OUString( pFormat->GetFormatstring() );
     729             :         }
     730       12613 :         else if (aPropertyName == PROPERTYNAME_LOCALE)
     731             :         {
     732         626 :             lang::Locale aLocale( LanguageTag( pFormat->GetLanguage()).getLocale());
     733         626 :             aRet <<= aLocale;
     734             :         }
     735       11987 :         else if (aPropertyName == PROPERTYNAME_TYPE)
     736             :         {
     737       11580 :             aRet <<= (sal_Int16)( pFormat->GetType() );
     738             :         }
     739         407 :         else if (aPropertyName == PROPERTYNAME_COMMENT)
     740             :         {
     741           0 :             aRet <<= OUString( pFormat->GetComment() );
     742             :         }
     743         407 :         else if (aPropertyName == PROPERTYNAME_STDFORM)
     744             :         {
     745             :             //! Pass through SvNumberformat Member bStandard?
     746         355 :             sal_Bool bStandard = ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 );
     747         355 :             aRet.setValue( &bStandard, cppu::UnoType<bool>::get() );
     748             :         }
     749          52 :         else if (aPropertyName == PROPERTYNAME_USERDEF)
     750             :         {
     751           0 :             sal_Bool bUserDef = ( ( pFormat->GetType() & css::util::NumberFormat::DEFINED ) != 0 );
     752           0 :             aRet.setValue( &bUserDef, cppu::UnoType<bool>::get() );
     753             :         }
     754          52 :         else if (aPropertyName == PROPERTYNAME_DECIMALS)
     755             :         {
     756           0 :             pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
     757           0 :             aRet <<= (sal_Int16)( nDecimals );
     758             :         }
     759          52 :         else if (aPropertyName == PROPERTYNAME_LEADING)
     760             :         {
     761           0 :             pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
     762           0 :             aRet <<= (sal_Int16)( nLeading );
     763             :         }
     764          52 :         else if (aPropertyName == PROPERTYNAME_NEGRED)
     765             :         {
     766           0 :             pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
     767           0 :             aRet.setValue( &bRed, cppu::UnoType<bool>::get() );
     768             :         }
     769          52 :         else if (aPropertyName == PROPERTYNAME_THOUS)
     770             :         {
     771           0 :             pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
     772           0 :             aRet.setValue( &bThousand, cppu::UnoType<bool>::get() );
     773             :         }
     774          52 :         else if (aPropertyName == PROPERTYNAME_CURRSYM)
     775             :         {
     776          52 :             OUString aSymbol, aExt;
     777          26 :             pFormat->GetNewCurrencySymbol( aSymbol, aExt );
     778          52 :             aRet <<= aSymbol;
     779             :         }
     780          26 :         else if (aPropertyName == PROPERTYNAME_CURREXT)
     781             :         {
     782           0 :             OUString aSymbol, aExt;
     783           0 :             pFormat->GetNewCurrencySymbol( aSymbol, aExt );
     784           0 :             aRet <<= aExt;
     785             :         }
     786          26 :         else if (aPropertyName == PROPERTYNAME_CURRABB)
     787             :         {
     788          52 :             OUString aSymbol, aExt;
     789          26 :             bool bBank = false;
     790          26 :             pFormat->GetNewCurrencySymbol( aSymbol, aExt );
     791             :             const NfCurrencyEntry* pCurr = SvNumberFormatter::GetCurrencyEntry( bBank,
     792          26 :                 aSymbol, aExt, pFormat->GetLanguage() );
     793          26 :             if ( pCurr )
     794          26 :                 aRet <<= OUString( pCurr->GetBankSymbol() );
     795             :             else
     796          26 :                 aRet <<= OUString();
     797             :         }
     798             :         else
     799           0 :             throw beans::UnknownPropertyException();
     800             :     }
     801             :     else
     802           0 :         throw uno::RuntimeException();
     803             : 
     804       13351 :     return aRet;
     805             : }
     806             : 
     807           0 : void SAL_CALL SvNumberFormatObj::addPropertyChangeListener( const OUString&,
     808             :                                                             const uno::Reference<beans::XPropertyChangeListener>&)
     809             :     throw(beans::UnknownPropertyException,
     810             :           lang::WrappedTargetException, uno::RuntimeException, std::exception)
     811             : {
     812             :     OSL_FAIL("not implemented");
     813           0 : }
     814             : 
     815           0 : void SAL_CALL SvNumberFormatObj::removePropertyChangeListener( const OUString&,
     816             :                                                                const uno::Reference<beans::XPropertyChangeListener>&)
     817             :     throw(beans::UnknownPropertyException,
     818             :           lang::WrappedTargetException, uno::RuntimeException, std::exception)
     819             : {
     820             :     OSL_FAIL("not implemented");
     821           0 : }
     822             : 
     823           0 : void SAL_CALL SvNumberFormatObj::addVetoableChangeListener( const OUString&,
     824             :                                                             const uno::Reference<beans::XVetoableChangeListener>&)
     825             :     throw(beans::UnknownPropertyException,
     826             :           lang::WrappedTargetException, uno::RuntimeException, std::exception)
     827             : {
     828             :     OSL_FAIL("not implemented");
     829           0 : }
     830             : 
     831           0 : void SAL_CALL SvNumberFormatObj::removeVetoableChangeListener( const OUString&,
     832             :                                                                const uno::Reference<beans::XVetoableChangeListener>&)
     833             :     throw(beans::UnknownPropertyException,
     834             :           lang::WrappedTargetException, uno::RuntimeException, std::exception)
     835             : {
     836             :     OSL_FAIL("not implemented");
     837           0 : }
     838             : 
     839             : // XPropertyAccess
     840             : 
     841           0 : uno::Sequence<beans::PropertyValue> SAL_CALL SvNumberFormatObj::getPropertyValues()
     842             :     throw(uno::RuntimeException, std::exception)
     843             : {
     844           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     845             : 
     846           0 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     847           0 :     const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL;
     848           0 :     if (pFormat)
     849             :     {
     850           0 :         OUString aSymbol, aExt;
     851           0 :         OUString aAbb;
     852           0 :         bool bBank = false;
     853           0 :         pFormat->GetNewCurrencySymbol( aSymbol, aExt );
     854             :         const NfCurrencyEntry* pCurr = SvNumberFormatter::GetCurrencyEntry( bBank,
     855           0 :             aSymbol, aExt, pFormat->GetLanguage() );
     856           0 :         if ( pCurr )
     857           0 :             aAbb = pCurr->GetBankSymbol();
     858             : 
     859           0 :         OUString aFmtStr = pFormat->GetFormatstring();
     860           0 :         OUString aComment = pFormat->GetComment();
     861           0 :         sal_Bool bStandard = ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 );
     862             :         //! Pass through SvNumberformat Member bStandard?
     863           0 :         sal_Bool bUserDef = ( ( pFormat->GetType() & css::util::NumberFormat::DEFINED ) != 0 );
     864             :         bool bThousand, bRed;
     865             :         sal_uInt16 nDecimals, nLeading;
     866           0 :         pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
     867           0 :         lang::Locale aLocale( LanguageTag( pFormat->GetLanguage()).getLocale());
     868             : 
     869           0 :         uno::Sequence<beans::PropertyValue> aSeq(13);
     870           0 :         beans::PropertyValue* pArray = aSeq.getArray();
     871             : 
     872           0 :         pArray[0].Name = PROPERTYNAME_FMTSTR;
     873           0 :         pArray[0].Value <<= aFmtStr;
     874           0 :         pArray[1].Name = PROPERTYNAME_LOCALE;
     875           0 :         pArray[1].Value <<= aLocale;
     876           0 :         pArray[2].Name = PROPERTYNAME_TYPE;
     877           0 :         pArray[2].Value <<= (sal_Int16)( pFormat->GetType() );
     878           0 :         pArray[3].Name = PROPERTYNAME_COMMENT;
     879           0 :         pArray[3].Value <<= aComment;
     880           0 :         pArray[4].Name = PROPERTYNAME_STDFORM;
     881           0 :         pArray[4].Value.setValue( &bStandard, cppu::UnoType<bool>::get() );
     882           0 :         pArray[5].Name = PROPERTYNAME_USERDEF;
     883           0 :         pArray[5].Value.setValue( &bUserDef, cppu::UnoType<bool>::get() );
     884           0 :         pArray[6].Name = PROPERTYNAME_DECIMALS;
     885           0 :         pArray[6].Value <<= (sal_Int16)( nDecimals );
     886           0 :         pArray[7].Name = PROPERTYNAME_LEADING;
     887           0 :         pArray[7].Value <<= (sal_Int16)( nLeading );
     888           0 :         pArray[8].Name = PROPERTYNAME_NEGRED;
     889           0 :         pArray[8].Value.setValue( &bRed, cppu::UnoType<bool>::get() );
     890           0 :         pArray[9].Name = PROPERTYNAME_THOUS;
     891           0 :         pArray[9].Value.setValue( &bThousand, cppu::UnoType<bool>::get() );
     892           0 :         pArray[10].Name = PROPERTYNAME_CURRSYM;
     893           0 :         pArray[10].Value <<= aSymbol;
     894           0 :         pArray[11].Name = PROPERTYNAME_CURREXT;
     895           0 :         pArray[11].Value <<= aExt;
     896           0 :         pArray[12].Name = PROPERTYNAME_CURRABB;
     897           0 :         pArray[12].Value <<= aAbb;
     898             : 
     899           0 :         return aSeq;
     900             :     }
     901             :     else
     902           0 :         throw uno::RuntimeException();
     903             : }
     904             : 
     905           0 : void SAL_CALL SvNumberFormatObj::setPropertyValues( const uno::Sequence<beans::PropertyValue>& )
     906             :     throw(beans::UnknownPropertyException, beans::PropertyVetoException,
     907             :           lang::IllegalArgumentException, lang::WrappedTargetException,
     908             :           uno::RuntimeException, std::exception)
     909             : {
     910           0 :     throw beans::UnknownPropertyException(); // Everything is read-only
     911             : }
     912             : 
     913             : // XServiceInfo
     914             : 
     915           0 : OUString SAL_CALL SvNumberFormatObj::getImplementationName()
     916             :     throw(uno::RuntimeException, std::exception)
     917             : {
     918           0 :     return OUString("SvNumberFormatObj");
     919             : }
     920             : 
     921           0 : sal_Bool SAL_CALL SvNumberFormatObj::supportsService( const OUString& ServiceName )
     922             :     throw(uno::RuntimeException, std::exception)
     923             : {
     924           0 :     return cppu::supportsService( this, ServiceName );
     925             : }
     926             : 
     927           0 : uno::Sequence<OUString> SAL_CALL SvNumberFormatObj::getSupportedServiceNames()
     928             :     throw(uno::RuntimeException, std::exception)
     929             : {
     930           0 :     uno::Sequence<OUString> aRet(1);
     931           0 :     OUString* pArray = aRet.getArray();
     932           0 :     pArray[0] = "com.sun.star.util.NumberFormatProperties";
     933           0 :     return aRet;
     934             : }
     935             : 
     936         327 : SvNumberFormatSettingsObj::SvNumberFormatSettingsObj( SvNumberFormatsSupplierObj& rParent, const ::comphelper::SharedMutex& _rMutex )
     937             :     :rSupplier( rParent )
     938         327 :     ,m_aMutex( _rMutex )
     939             : {
     940         327 :     rSupplier.acquire();
     941         327 : }
     942             : 
     943         981 : SvNumberFormatSettingsObj::~SvNumberFormatSettingsObj()
     944             : {
     945         327 :     rSupplier.release();
     946         654 : }
     947             : 
     948             : // XPropertySet
     949             : 
     950         145 : uno::Reference<beans::XPropertySetInfo> SAL_CALL SvNumberFormatSettingsObj::getPropertySetInfo()
     951             :     throw(uno::RuntimeException, std::exception)
     952             : {
     953         145 :     ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     954             :     static uno::Reference<beans::XPropertySetInfo> aRef =
     955         145 :         new SfxItemPropertySetInfo( lcl_GetNumberSettingsPropertyMap() );
     956         145 :     return aRef;
     957             : }
     958             : 
     959         146 : void SAL_CALL SvNumberFormatSettingsObj::setPropertyValue( const OUString& aPropertyName,
     960             :                                                            const uno::Any& aValue )
     961             :     throw(beans::UnknownPropertyException, beans::PropertyVetoException,
     962             :           lang::IllegalArgumentException, lang::WrappedTargetException,
     963             :           uno::RuntimeException, std::exception)
     964             : {
     965         146 :     ::osl::MutexGuard aGuard( m_aMutex );
     966             : 
     967         146 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
     968         146 :     if (pFormatter)
     969             :     {
     970         146 :         if (aPropertyName == PROPERTYNAME_NOZERO)
     971             :         {
     972             :             //  operator >>= shouldn't be used for bool (?)
     973           0 :             if ( aValue.getValueTypeClass() == uno::TypeClass_BOOLEAN )
     974           0 :                 pFormatter->SetNoZero( *static_cast<sal_Bool const *>(aValue.getValue()) );
     975             :         }
     976         146 :         else if (aPropertyName == PROPERTYNAME_NULLDATE)
     977             :         {
     978         146 :             util::Date aDate;
     979         146 :             if ( aValue >>= aDate )
     980         146 :                 pFormatter->ChangeNullDate( aDate.Day, aDate.Month, aDate.Year );
     981             :         }
     982           0 :         else if (aPropertyName == PROPERTYNAME_STDDEC)
     983             :         {
     984           0 :             sal_Int16 nInt16 = sal_Int16();
     985           0 :             if ( aValue >>= nInt16 )
     986           0 :                 pFormatter->ChangeStandardPrec( nInt16 );
     987             :         }
     988           0 :         else if (aPropertyName == PROPERTYNAME_TWODIGIT)
     989             :         {
     990           0 :             sal_Int16 nInt16 = sal_Int16();
     991           0 :             if ( aValue >>= nInt16 )
     992           0 :                 pFormatter->SetYear2000( nInt16 );
     993             :         }
     994             :         else
     995           0 :             throw beans::UnknownPropertyException();
     996             :     }
     997             :     else
     998           0 :         throw uno::RuntimeException();
     999         146 : }
    1000             : 
    1001         184 : uno::Any SAL_CALL SvNumberFormatSettingsObj::getPropertyValue( const OUString& aPropertyName )
    1002             :     throw(beans::UnknownPropertyException, lang::WrappedTargetException,
    1003             :           uno::RuntimeException, std::exception)
    1004             : {
    1005         184 :     ::osl::MutexGuard aGuard( m_aMutex );
    1006             : 
    1007         184 :     uno::Any aRet;
    1008         184 :     SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
    1009         184 :     if (pFormatter)
    1010             :     {
    1011         184 :         if (aPropertyName == PROPERTYNAME_NOZERO)
    1012             :         {
    1013           1 :             sal_Bool bNoZero = pFormatter->GetNoZero();
    1014           1 :             aRet.setValue( &bNoZero, cppu::UnoType<bool>::get() );
    1015             :         }
    1016         183 :         else if (aPropertyName == PROPERTYNAME_NULLDATE)
    1017             :         {
    1018         181 :             Date* pDate = pFormatter->GetNullDate();
    1019         181 :             if (pDate)
    1020             :             {
    1021         181 :                 aRet <<= pDate->GetUNODate();
    1022             :             }
    1023             :         }
    1024           2 :         else if (aPropertyName == PROPERTYNAME_STDDEC)
    1025           1 :             aRet <<= (sal_Int16)( pFormatter->GetStandardPrec() );
    1026           1 :         else if (aPropertyName == PROPERTYNAME_TWODIGIT)
    1027           1 :             aRet <<= (sal_Int16)( pFormatter->GetYear2000() );
    1028             :         else
    1029           0 :             throw beans::UnknownPropertyException();
    1030             :     }
    1031             :     else
    1032           0 :         throw uno::RuntimeException();
    1033             : 
    1034         184 :     return aRet;
    1035             : }
    1036             : 
    1037           0 : void SAL_CALL SvNumberFormatSettingsObj::addPropertyChangeListener( const OUString&,
    1038             :                                                                     const uno::Reference<beans::XPropertyChangeListener>&)
    1039             :     throw(beans::UnknownPropertyException,
    1040             :           lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1041             : {
    1042             :     OSL_FAIL("not implemented");
    1043           0 : }
    1044             : 
    1045           0 : void SAL_CALL SvNumberFormatSettingsObj::removePropertyChangeListener( const OUString&,
    1046             :                                                                        const uno::Reference<beans::XPropertyChangeListener>&)
    1047             :     throw(beans::UnknownPropertyException,
    1048             :           lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1049             : {
    1050             :     OSL_FAIL("not implemented");
    1051           0 : }
    1052             : 
    1053           0 : void SAL_CALL SvNumberFormatSettingsObj::addVetoableChangeListener( const OUString&,
    1054             :                                                                     const uno::Reference<beans::XVetoableChangeListener>&)
    1055             :     throw(beans::UnknownPropertyException,
    1056             :           lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1057             : {
    1058             :     OSL_FAIL("not implemented");
    1059           0 : }
    1060             : 
    1061           0 : void SAL_CALL SvNumberFormatSettingsObj::removeVetoableChangeListener( const OUString&,
    1062             :                                                                        const uno::Reference<beans::XVetoableChangeListener>&)
    1063             :     throw(beans::UnknownPropertyException,
    1064             :           lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1065             : {
    1066             :     OSL_FAIL("not implemented");
    1067           0 : }
    1068             : 
    1069             : // XServiceInfo
    1070             : 
    1071           0 : OUString SAL_CALL SvNumberFormatSettingsObj::getImplementationName()
    1072             :     throw(uno::RuntimeException, std::exception)
    1073             : {
    1074           0 :     return OUString("SvNumberFormatSettingsObj");
    1075             : }
    1076             : 
    1077           0 : sal_Bool SAL_CALL SvNumberFormatSettingsObj::supportsService( const OUString& ServiceName )
    1078             :     throw(uno::RuntimeException, std::exception)
    1079             : {
    1080           0 :     return cppu::supportsService( this, ServiceName );
    1081             : }
    1082             : 
    1083           0 : uno::Sequence<OUString> SAL_CALL SvNumberFormatSettingsObj::getSupportedServiceNames()
    1084             :     throw(uno::RuntimeException, std::exception)
    1085             : {
    1086           0 :     uno::Sequence<OUString> aRet(1);
    1087           0 :     OUString* pArray = aRet.getArray();
    1088           0 :     pArray[0] = "com.sun.star.util.NumberFormatSettings";
    1089           0 :     return aRet;
    1090             : }
    1091             : 
    1092             : 
    1093             : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
    1094          96 : com_sun_star_uno_util_numbers_SvNumberFormatterServiceObject_get_implementation(::com::sun::star::uno::XComponentContext*,
    1095             :                                                                                 ::com::sun::star::uno::Sequence<css::uno::Any> const &)
    1096             : {
    1097          96 :     return cppu::acquire(new SvNumberFormatterServiceObj());
    1098             : }
    1099             : 
    1100             : 
    1101             : 
    1102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11