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

Generated by: LCOV version 1.10