LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/items - numfmtsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 750 0.1 %
Date: 2013-07-09 Functions: 2 54 3.7 %
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             : 
      22             : #include <tools/debug.hxx>
      23             : #include <i18nlangtag/mslangid.hxx>
      24             : 
      25             : #include <svl/zforlist.hxx>
      26             : #include <svl/zformat.hxx>
      27             : 
      28             : #include <svtools/langtab.hxx>
      29             : #include <vcl/svapp.hxx>
      30             : #include <comphelper/processfactory.hxx>
      31             : 
      32             : #include <svx/numfmtsh.hxx>
      33             : 
      34             : #include <limits>
      35             : 
      36             : // class SvxNumberFormatShell --------------------------------------------
      37             : 
      38             : const double SvxNumberFormatShell::DEFAULT_NUMVALUE = 1234.56789;
      39             : 
      40             : // -----------------------------------------------------------------------
      41             : 
      42             : 
      43             : 
      44           0 : SvxNumberFormatShell* SvxNumberFormatShell::Create( SvNumberFormatter* pNumFormatter,
      45             :                                               sal_uInt32              nFormatKey,
      46             :                                               SvxNumberValueType eNumValType,
      47             :                                               const String&      rNumStr )
      48             : {
      49             :     return new SvxNumberFormatShell(pNumFormatter,nFormatKey,
      50           0 :                                     eNumValType,rNumStr );
      51             : }
      52             : 
      53           0 : SvxNumberFormatShell* SvxNumberFormatShell::Create( SvNumberFormatter* pNumFormatter,
      54             :                                               sal_uInt32                 nFormatKey,
      55             :                                               SvxNumberValueType eNumValType,
      56             :                                               double             nNumVal,
      57             :                                               const String*      pNumStr )
      58             : {
      59             :     return new SvxNumberFormatShell(pNumFormatter,nFormatKey,
      60           0 :                                     eNumValType,nNumVal,pNumStr );
      61             : }
      62             : 
      63             : // -----------------------------------------------------------------------
      64             : 
      65           0 : SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter*  pNumFormatter,
      66             :                                             sal_uInt32              nFormatKey,
      67             :                                             SvxNumberValueType  eNumValType,
      68             :                                             const String&       rNumStr ) :
      69             :     pFormatter      ( pNumFormatter ),
      70             :     pCurFmtTable    ( NULL ),
      71             :     eValType        ( eNumValType ),
      72             :     bUndoAddList    ( true ),
      73             :     nCurFormatKey   ( nFormatKey ),
      74             :     pCurCurrencyEntry(NULL),
      75             :     bBankingSymbol  (false),
      76             :     nCurCurrencyEntryPos((sal_uInt16) SELPOS_NONE),
      77           0 :     bUseStarFormat  (false)
      78             : {
      79           0 :     nValNum = DEFAULT_NUMVALUE;
      80             : 
      81           0 :     switch ( eValType )
      82             :     {
      83             :         case SVX_VALUE_TYPE_STRING:
      84           0 :             aValStr = rNumStr;
      85           0 :             break;
      86             :         case SVX_VALUE_TYPE_NUMBER:
      87             :         case SVX_VALUE_TYPE_UNDEFINED:
      88             :         default:
      89           0 :             aValStr.Erase();
      90             :     }
      91           0 : }
      92             : 
      93             : // -----------------------------------------------------------------------
      94             : 
      95           0 : SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter*  pNumFormatter,
      96             :                                             sal_uInt32              nFormatKey,
      97             :                                             SvxNumberValueType  eNumValType,
      98             :                                             double              nNumVal,
      99             :                                             const String*       pNumStr ) :
     100             :     pFormatter      ( pNumFormatter ),
     101             :     pCurFmtTable    ( NULL ),
     102             :     eValType        ( eNumValType ),
     103             :     bUndoAddList    ( true ),
     104             :     nCurFormatKey   ( nFormatKey ),
     105             :     pCurCurrencyEntry(NULL),
     106             :     bBankingSymbol  (false),
     107             :     nCurCurrencyEntryPos((sal_uInt16) SELPOS_NONE),
     108           0 :     bUseStarFormat  (false)
     109             : {
     110             :     //  #50441# When used in Writer, the SvxNumberInfoItem contains the
     111             :     //  original string in addition to the value
     112             : 
     113           0 :     if ( pNumStr )
     114           0 :         aValStr = *pNumStr;
     115             : 
     116           0 :     switch ( eValType )
     117             :     {
     118             :         case SVX_VALUE_TYPE_NUMBER:
     119           0 :             nValNum = nNumVal;
     120           0 :             break;
     121             :         case SVX_VALUE_TYPE_STRING:
     122             :         case SVX_VALUE_TYPE_UNDEFINED:
     123             :         default:
     124           0 :             nValNum = DEFAULT_NUMVALUE;
     125             :     }
     126           0 : }
     127             : 
     128             : // -----------------------------------------------------------------------
     129             : 
     130           0 : SvxNumberFormatShell::~SvxNumberFormatShell()
     131             : {
     132             :     /*
     133             :      * An dieser Stelle wird abhaengig davon, ob die
     134             :      * hinzugefuegten, benutzerdefinierten als gueltig
     135             :      * erklaert wurden (ValidateNewEntries()), die
     136             :      * Add-Liste wieder aus dem Zahlenformatierer entfernt.
     137             :      *
     138             :      * Loeschen von Formaten aus dem Formatierer passiert
     139             :      * aus Undo-Gruenden nur in der aufrufenden Instanz.
     140             :      */
     141             : 
     142           0 :     if ( bUndoAddList )
     143             :     {
     144             :         // Hinzugefuegte Formate sind nicht gueltig:
     145             :         // => wieder entfernen:
     146             : 
     147           0 :         for ( std::vector<sal_uInt32>::const_iterator it(aAddList.begin()); it != aAddList.end(); ++it )
     148           0 :             pFormatter->DeleteEntry( *it );
     149             :     }
     150             : 
     151           0 :     for ( std::vector<String*>::const_iterator it(aCurrencyFormatList.begin());
     152           0 :           it != aCurrencyFormatList.end(); ++it )
     153           0 :         delete *it;
     154           0 : }
     155             : 
     156             : // -----------------------------------------------------------------------
     157             : 
     158           0 : size_t SvxNumberFormatShell::GetUpdateDataCount() const
     159             : {
     160           0 :     return aDelList.size();
     161             : }
     162             : 
     163             : // -----------------------------------------------------------------------
     164             : 
     165           0 : void SvxNumberFormatShell::GetUpdateData( sal_uInt32* pDelArray, const sal_uInt32 nSize )
     166             : {
     167           0 :     const size_t nListSize = aDelList.size();
     168             : 
     169             :     DBG_ASSERT( pDelArray && ( nSize == nListSize ), "Array nicht initialisiert!" );
     170             : 
     171           0 :     if ( pDelArray && ( nSize == nListSize ) )
     172           0 :         for (std::vector<sal_uInt32>::const_iterator it(aDelList.begin()); it != aDelList.end(); ++it )
     173           0 :             *pDelArray++ = *it;
     174           0 : }
     175             : 
     176             : // -----------------------------------------------------------------------
     177             : 
     178           0 : void SvxNumberFormatShell::CategoryChanged( sal_uInt16 nCatLbPos,
     179             :                                             short& rFmtSelPos,
     180             :                                             std::vector<String*>& rFmtEntries )
     181             : {
     182           0 :     short nOldCategory = nCurCategory;
     183           0 :     PosToCategory_Impl( nCatLbPos, nCurCategory );
     184             :     pCurFmtTable = &( pFormatter->GetEntryTable( nCurCategory,
     185             :                                                  nCurFormatKey,
     186           0 :                                                  eCurLanguage ) );
     187             :     // reinitialize currency if category newly entered
     188           0 :     if ( nCurCategory == NUMBERFORMAT_CURRENCY && nOldCategory != nCurCategory )
     189           0 :         pCurCurrencyEntry = NULL;
     190           0 :     rFmtSelPos = FillEntryList_Impl( rFmtEntries );
     191           0 : }
     192             : 
     193             : // -----------------------------------------------------------------------
     194             : 
     195           0 : void SvxNumberFormatShell::LanguageChanged( LanguageType eLangType,
     196             :                                             short& rFmtSelPos,
     197             :                                             std::vector<String*>& rFmtEntries )
     198             : {
     199           0 :     eCurLanguage = eLangType;
     200             :     pCurFmtTable = &(pFormatter->ChangeCL( nCurCategory,
     201             :                                            nCurFormatKey,
     202           0 :                                            eCurLanguage ) );
     203           0 :     rFmtSelPos = FillEntryList_Impl( rFmtEntries );
     204           0 : }
     205             : 
     206             : // -----------------------------------------------------------------------
     207             : 
     208           0 : void SvxNumberFormatShell::FormatChanged( sal_uInt16  nFmtLbPos,
     209             :                                           String& rPreviewStr,
     210             :                                           Color*& rpFontColor )
     211             : {
     212           0 :     if( static_cast<size_t>(nFmtLbPos) < aCurEntryList.size() )
     213             :     {
     214           0 :         nCurFormatKey = aCurEntryList[nFmtLbPos];
     215             : 
     216           0 :         if( nCurFormatKey != NUMBERFORMAT_ENTRY_NOT_FOUND )
     217             :         {
     218           0 :             GetPreviewString_Impl( rPreviewStr, rpFontColor );
     219             :         }
     220           0 :         else if( nCurCategory == NUMBERFORMAT_CURRENCY )
     221             :         {
     222           0 :             if( static_cast<size_t>(nFmtLbPos) < aCurrencyFormatList.size() )
     223             :             {
     224           0 :                 MakePrevStringFromVal(*aCurrencyFormatList[nFmtLbPos],
     225           0 :                                     rPreviewStr,rpFontColor,nValNum);
     226             :             }
     227             :         }
     228             :     }
     229           0 : }
     230             : // -----------------------------------------------------------------------
     231             : 
     232           0 : bool SvxNumberFormatShell::AddFormat( String& rFormat,  xub_StrLen& rErrPos,
     233             :                                       sal_uInt16& rCatLbSelPos, short& rFmtSelPos,
     234             :                                       std::vector<String*>& rFmtEntries )
     235             : {
     236           0 :     bool        bInserted   = false;
     237           0 :     sal_uInt32  nAddKey     = pFormatter->GetEntryKey( rFormat, eCurLanguage );
     238             : 
     239           0 :     if ( nAddKey != NUMBERFORMAT_ENTRY_NOT_FOUND ) // bereits vorhanden?
     240             :     {
     241           0 :         ::std::vector<sal_uInt32>::iterator nAt = GetRemoved_Impl( nAddKey );
     242           0 :         if ( nAt != aDelList.end() )
     243             :         {
     244           0 :             aDelList.erase( nAt );
     245           0 :             bInserted = true;
     246             :         }
     247             :         else
     248             :         {
     249             :             OSL_FAIL( "Doppeltes Format!" );
     250             :         }
     251             :     }
     252             :     else // neues Format
     253             :     {
     254           0 :         OUString sTemp(rFormat);
     255             :         sal_Int32 nPos;
     256             :         bInserted = pFormatter->PutEntry( sTemp, nPos,
     257             :                                           nCurCategory, nAddKey,
     258           0 :                                           eCurLanguage );
     259           0 :         rErrPos = (nPos >= 0) ? (xub_StrLen)nPos : 0xFFFF;
     260           0 :         rFormat = sTemp;
     261             : 
     262           0 :         if (bInserted)
     263             :         {
     264             :             // May be sorted under a different locale if LCID was parsed.
     265           0 :             const SvNumberformat* pEntry = pFormatter->GetEntry( nAddKey);
     266           0 :             if (pEntry)
     267             :             {
     268           0 :                 LanguageType nLang = pEntry->GetLanguage();
     269           0 :                 if (eCurLanguage != nLang)
     270             :                 {
     271             :                     // Current language's list would not show entry, adapt.
     272           0 :                     eCurLanguage = nLang;
     273             :                 }
     274             :             }
     275           0 :         }
     276             :     }
     277             : 
     278           0 :     if ( bInserted ) // eingefuegt
     279             :     {
     280           0 :         nCurFormatKey = nAddKey;
     281             :         DBG_ASSERT( !IsAdded_Impl( nCurFormatKey ), "Doppeltes Format!" );
     282           0 :         aAddList.push_back( nCurFormatKey );
     283             : 
     284             :         // aktuelle Tabelle holen
     285             :         pCurFmtTable = &(pFormatter->GetEntryTable( nCurCategory,
     286             :                                                     nCurFormatKey,
     287           0 :                                                     eCurLanguage ));
     288           0 :         nCurCategory=pFormatter->GetType(nAddKey); //@@ ???
     289           0 :         CategoryToPos_Impl( nCurCategory, rCatLbSelPos );
     290           0 :         rFmtSelPos = FillEntryList_Impl( rFmtEntries );
     291             :     }
     292           0 :     else if ( rErrPos != 0 ) // Syntaxfehler
     293             :     {
     294             :         ;
     295             :     }
     296             :     else // Doppelt einfuegen nicht moeglich
     297             :     {
     298             :         OSL_FAIL( "Doppeltes Format!" ); // oder doch?
     299             :     }
     300             : 
     301           0 :     return bInserted;
     302             : }
     303             : 
     304             : // -----------------------------------------------------------------------
     305             : 
     306           0 : bool SvxNumberFormatShell::RemoveFormat( const String& rFormat,
     307             :                                          sal_uInt16& rCatLbSelPos,
     308             :                                          short& rFmtSelPos,
     309             :                                          std::vector<String*>& rFmtEntries )
     310             : {
     311           0 :     sal_uInt32 nDelKey = pFormatter->GetEntryKey( rFormat, eCurLanguage );
     312             : 
     313             :     DBG_ASSERT( nDelKey != NUMBERFORMAT_ENTRY_NOT_FOUND, "Eintrag nicht gefunden!" );
     314             :     DBG_ASSERT( !IsRemoved_Impl( nDelKey ), "Eintrag bereits geloescht!" );
     315             : 
     316           0 :     if ( (nDelKey != NUMBERFORMAT_ENTRY_NOT_FOUND) && !IsRemoved_Impl( nDelKey ) )
     317             :     {
     318           0 :         aDelList.push_back( nDelKey );
     319             : 
     320           0 :         ::std::vector<sal_uInt32>::iterator nAt = GetAdded_Impl( nDelKey );
     321           0 :         if( nAt != aAddList.end() )
     322             :         {
     323           0 :             aAddList.erase( nAt );
     324             :         }
     325             : 
     326           0 :         nCurCategory=pFormatter->GetType(nDelKey);
     327             :         pCurFmtTable = &(pFormatter->GetEntryTable( nCurCategory,
     328             :                                                     nCurFormatKey,
     329           0 :                                                     eCurLanguage ));
     330             : 
     331             :         nCurFormatKey=pFormatter->GetStandardFormat(nCurCategory,
     332           0 :                                             eCurLanguage );
     333             : 
     334           0 :         CategoryToPos_Impl( nCurCategory, rCatLbSelPos );
     335           0 :         rFmtSelPos = FillEntryList_Impl( rFmtEntries );
     336             :     }
     337           0 :     return true;
     338             : }
     339             : 
     340             : // -----------------------------------------------------------------------
     341             : 
     342           0 : void SvxNumberFormatShell::MakeFormat( String& rFormat,
     343             :                                        bool bThousand, bool bNegRed,
     344             :                                        sal_uInt16 nPrecision, sal_uInt16 nLeadingZeroes,
     345             :                                        sal_uInt16 nCurrencyPos)
     346             : {
     347           0 :     if( aCurrencyFormatList.size() > static_cast<size_t>(nCurrencyPos) )
     348             :     {
     349           0 :         xub_StrLen rErrPos=0;
     350           0 :         std::vector<String*> aFmtEList;
     351             : 
     352           0 :         sal_uInt32 nFound = pFormatter->TestNewString( *aCurrencyFormatList[nCurrencyPos], eCurLanguage );
     353             : 
     354           0 :         if ( nFound == NUMBERFORMAT_ENTRY_NOT_FOUND )
     355             :         {
     356           0 :             sal_uInt16 rCatLbSelPos=0;
     357           0 :             short  rFmtSelPos=0;
     358           0 :             AddFormat( *aCurrencyFormatList[nCurrencyPos],rErrPos,rCatLbSelPos,
     359           0 :                     rFmtSelPos,aFmtEList);
     360             :         }
     361             : 
     362           0 :         if(rErrPos==0)
     363             :         {
     364           0 :             rFormat = pFormatter->GenerateFormat(nCurFormatKey,
     365             :                                                  eCurLanguage,
     366             :                                                  bThousand, bNegRed,
     367           0 :                                                  nPrecision, nLeadingZeroes);
     368             :         }
     369           0 :         for ( std::vector<String*>::const_iterator it(aFmtEList.begin()); it != aFmtEList.end(); ++it )
     370           0 :             delete *it;
     371             :     }
     372             :     else
     373             :     {
     374           0 :         rFormat = pFormatter->GenerateFormat(nCurFormatKey,
     375             :                                              eCurLanguage,
     376             :                                              bThousand, bNegRed,
     377           0 :                                              nPrecision, nLeadingZeroes);
     378             :     }
     379           0 : }
     380             : 
     381             : // -----------------------------------------------------------------------
     382             : 
     383           0 : void SvxNumberFormatShell::GetOptions( const String&    rFormat,
     384             :                                        bool&            rThousand,
     385             :                                        bool&            rNegRed,
     386             :                                        sal_uInt16&      rPrecision,
     387             :                                        sal_uInt16&      rLeadingZeroes,
     388             :                                        sal_uInt16&      rCatLbPos )
     389             : {
     390             : 
     391           0 :     sal_uInt32 nFmtKey = pFormatter->GetEntryKey( rFormat, eCurLanguage );
     392             : 
     393           0 :     if(nFmtKey != NUMBERFORMAT_ENTRY_NOT_FOUND)
     394             :     {
     395           0 :         if ( nFmtKey != NUMBERFORMAT_ENTRY_NOT_FOUND )
     396             :         {
     397             :             pFormatter->GetFormatSpecialInfo( nFmtKey,
     398             :                                               rThousand, rNegRed,
     399           0 :                                               rPrecision, rLeadingZeroes );
     400             : 
     401           0 :             CategoryToPos_Impl( pFormatter->GetType( nFmtKey ), rCatLbPos );
     402             :         }
     403             :         else
     404           0 :             rCatLbPos = CAT_USERDEFINED;
     405             :     }
     406             :     else
     407             :     {
     408           0 :         bool bTestBanking = false;
     409           0 :         sal_uInt16 nPos=FindCurrencyTableEntry(rFormat, bTestBanking );
     410             : 
     411           0 :         if(IsInTable(nPos,bTestBanking,rFormat) &&
     412             :             pFormatter->GetFormatSpecialInfo( rFormat,rThousand, rNegRed,
     413           0 :                                   rPrecision, rLeadingZeroes,eCurLanguage)==0)
     414             :         {
     415           0 :             rCatLbPos = CAT_CURRENCY;
     416             :         }
     417             :         else
     418           0 :             rCatLbPos = CAT_USERDEFINED;
     419             :     }
     420             : 
     421           0 : }
     422             : 
     423             : // -----------------------------------------------------------------------
     424             : 
     425           0 : void SvxNumberFormatShell::MakePreviewString( const String& rFormatStr,
     426             :                                               String&       rPreviewStr,
     427             :                                               Color*&       rpFontColor )
     428             : {
     429           0 :     rpFontColor = NULL;
     430             : 
     431           0 :     sal_uIntPtr nExistingFormat = pFormatter->GetEntryKey( rFormatStr, eCurLanguage );
     432           0 :     if ( nExistingFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
     433             :     {
     434             :         //  real preview - not implemented in NumberFormatter for text formats
     435           0 :         OUString sTempOut(rPreviewStr);
     436             : 
     437             :         pFormatter->GetPreviewString( rFormatStr, nValNum, sTempOut,
     438           0 :                                       &rpFontColor, eCurLanguage, bUseStarFormat );
     439           0 :         rPreviewStr = sTempOut;
     440             :     }
     441             :     else
     442             :     {
     443             :         //  format exists
     444             : 
     445             :         //  #50441# if a string was set in addition to the value, use it for text formats
     446           0 :         bool bUseText = ( eValType == SVX_VALUE_TYPE_STRING ||
     447           0 :                             ( aValStr.Len() && ( pFormatter->GetType(nExistingFormat) & NUMBERFORMAT_TEXT ) ) );
     448           0 :         if ( bUseText )
     449             :         {
     450           0 :             OUString sTempIn(aValStr);
     451           0 :             OUString sTempOut(rPreviewStr);
     452             :             pFormatter->GetOutputString( sTempIn, nExistingFormat,
     453           0 :                                          sTempOut, &rpFontColor );
     454           0 :             aValStr = sTempIn;
     455           0 :             rPreviewStr = sTempOut;
     456             :         }
     457             :         else
     458             :         {
     459           0 :             OUString sTemp(rPreviewStr);
     460             :             pFormatter->GetOutputString( nValNum, nExistingFormat,
     461           0 :                                          sTemp, &rpFontColor, bUseStarFormat );
     462           0 :             rPreviewStr = sTemp;
     463             :         }
     464             :     }
     465           0 : }
     466             : 
     467             : // -----------------------------------------------------------------------
     468             : 
     469           0 : bool SvxNumberFormatShell::IsUserDefined( const String& rFmtString )
     470             : {
     471           0 :     sal_uInt32 nFound = pFormatter->GetEntryKey( rFmtString, eCurLanguage );
     472             : 
     473           0 :     bool bFlag=false;
     474           0 :     if ( nFound != NUMBERFORMAT_ENTRY_NOT_FOUND )
     475             :     {
     476           0 :         bFlag=pFormatter->IsUserDefined( rFmtString, eCurLanguage );
     477             : 
     478           0 :         if(bFlag)
     479             :         {
     480           0 :             const SvNumberformat* pNumEntry = pFormatter->GetEntry(nFound);
     481             : 
     482           0 :             if(pNumEntry!=NULL && pNumEntry->HasNewCurrency())
     483             :             {
     484             :                 bool bTestBanking;
     485           0 :                 sal_uInt16 nPos=FindCurrencyTableEntry(rFmtString,bTestBanking);
     486           0 :                 bFlag=!IsInTable(nPos,bTestBanking,rFmtString);
     487             :             }
     488             :         }
     489             :     }
     490           0 :     return bFlag;
     491             : }
     492             : 
     493             : // -----------------------------------------------------------------------
     494             : 
     495           0 : bool SvxNumberFormatShell::FindEntry( const String& rFmtString, sal_uInt32* pAt /* = NULL */ )
     496             : {
     497           0 :     bool bRes=false;
     498           0 :     sal_uInt32 nFound = pFormatter->TestNewString( rFmtString, eCurLanguage );
     499             : 
     500           0 :     if ( nFound == NUMBERFORMAT_ENTRY_NOT_FOUND )
     501             :     {
     502           0 :         bool bTestBanking=false;
     503           0 :         sal_uInt16 nPos=FindCurrencyTableEntry(rFmtString, bTestBanking );
     504             : 
     505           0 :         if(IsInTable(nPos,bTestBanking,rFmtString))
     506             :         {
     507           0 :             nFound=NUMBERFORMAT_ENTRY_NEW_CURRENCY;
     508           0 :             bRes=true;
     509             :         }
     510             :     }
     511             :     else
     512             :     {
     513           0 :         bRes=!IsRemoved_Impl( nFound );
     514             :     }
     515             : 
     516           0 :     if ( pAt )
     517           0 :         *pAt = nFound;
     518             : 
     519           0 :     return bRes;
     520             : }
     521             : 
     522             : 
     523             : // -----------------------------------------------------------------------
     524             : 
     525           0 : void SvxNumberFormatShell::GetInitSettings( sal_uInt16& nCatLbPos,
     526             :                                             LanguageType& rLangType,
     527             :                                             sal_uInt16& nFmtLbSelPos,
     528             :                                             std::vector<String*>& rFmtEntries,
     529             :                                             String& rPrevString,
     530             :                                             Color*& rpPrevColor )
     531             : {
     532             :     // -------------------------------------------------------------------
     533             :     // Vorbedingung: Zahlenformatierer gefunden
     534             :     DBG_ASSERT( pFormatter != NULL, "Zahlenformatierer nicht gefunden!" );
     535             : 
     536             : //  sal_uInt16                  nCount      = 0;
     537           0 :     short                   nSelPos     = SELPOS_NONE;
     538             : //  SvNumberFormatTable*    pFmtTable   = NULL;
     539             : 
     540             :     // Sonderbehandlung fuer undefiniertes Zahlenformat:
     541           0 :     if ( (eValType == SVX_VALUE_TYPE_UNDEFINED) && (nCurFormatKey == 0) )
     542           0 :         PosToCategory_Impl( CAT_ALL, nCurCategory );        // Kategorie = Alle
     543             :     else
     544           0 :         nCurCategory = NUMBERFORMAT_UNDEFINED;      // Kategorie = Undefiniert
     545             : 
     546             :     pCurFmtTable =  &(pFormatter->GetFirstEntryTable( nCurCategory,
     547             :                                                       nCurFormatKey,
     548           0 :                                                       eCurLanguage ));
     549             : 
     550             : 
     551             : 
     552           0 :     CategoryToPos_Impl( nCurCategory, nCatLbPos );
     553           0 :     rLangType = eCurLanguage;
     554             : 
     555           0 :     nSelPos = FillEntryList_Impl( rFmtEntries );
     556             : 
     557             :     DBG_ASSERT( nSelPos != SELPOS_NONE, "Leere Formatliste!" );
     558             : 
     559           0 :     nFmtLbSelPos = (nSelPos != SELPOS_NONE) ? (sal_uInt16)nSelPos : 0;
     560           0 :     GetPreviewString_Impl( rPrevString, rpPrevColor );
     561           0 : }
     562             : 
     563             : // -----------------------------------------------------------------------
     564             : 
     565           0 : short SvxNumberFormatShell::FillEntryList_Impl( std::vector<String*>& rList )
     566             : {
     567             :     /* Erstellen einer aktuellen Liste von Format-Eintraegen.
     568             :      * Rueckgabewert ist die Listenposition des aktuellen Formates.
     569             :      * Ist die Liste leer oder gibt es kein aktuelles Format,
     570             :      * so wird SELPOS_NONE geliefert.
     571             :      */
     572           0 :     short nSelPos=0;
     573           0 :     sal_uInt16 nPrivCat = CAT_CURRENCY;
     574           0 :     nSelPos=SELPOS_NONE;
     575             : 
     576           0 :     aCurEntryList.clear();
     577             : 
     578           0 :     if(nCurCategory==NUMBERFORMAT_ALL)
     579             :     {
     580           0 :         FillEListWithStd_Impl(rList,CAT_NUMBER,nSelPos);
     581           0 :         FillEListWithStd_Impl(rList,CAT_PERCENT,nSelPos);
     582           0 :         FillEListWithStd_Impl(rList,CAT_CURRENCY,nSelPos);
     583           0 :         FillEListWithStd_Impl(rList,CAT_DATE,nSelPos);
     584           0 :         FillEListWithStd_Impl(rList,CAT_TIME,nSelPos);
     585           0 :         FillEListWithStd_Impl(rList,CAT_SCIENTIFIC,nSelPos);
     586           0 :         FillEListWithStd_Impl(rList,CAT_FRACTION,nSelPos);
     587           0 :         FillEListWithStd_Impl(rList,CAT_BOOLEAN,nSelPos);
     588           0 :         FillEListWithStd_Impl(rList,CAT_TEXT,nSelPos);
     589             :     }
     590             :     else
     591             :     {
     592           0 :         CategoryToPos_Impl(nCurCategory, nPrivCat);
     593           0 :         FillEListWithStd_Impl(rList,nPrivCat,nSelPos);
     594             :     }
     595             : 
     596           0 :     if( nPrivCat!=CAT_CURRENCY)
     597           0 :         nSelPos=FillEListWithUsD_Impl(rList,nPrivCat,nSelPos);
     598             : 
     599           0 :     return nSelPos;
     600             : }
     601             : 
     602           0 : void SvxNumberFormatShell::FillEListWithStd_Impl( std::vector<String*>& rList,
     603             :                                                   sal_uInt16 nPrivCat,short &nSelPos )
     604             : {
     605             :     /* Erstellen einer aktuellen Liste von Format-Eintraegen.
     606             :      * Rueckgabewert ist die Listenposition des aktuellen Formates.
     607             :      * Ist die Liste leer oder gibt es kein aktuelles Format,
     608             :      * so wird SELPOS_NONE geliefert.
     609             :      */
     610             :     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
     611             : 
     612           0 :     for ( std::vector<String*>::const_iterator it(aCurrencyFormatList.begin());
     613           0 :           it != aCurrencyFormatList.end(); ++it )
     614           0 :         delete *it;
     615           0 :     aCurrencyFormatList.clear();
     616             : 
     617           0 :     if(nPrivCat==CAT_CURRENCY)
     618             :     {
     619           0 :         nSelPos=FillEListWithCurrency_Impl(rList,nSelPos);
     620             :     }
     621             :     else
     622             :     {
     623             :         NfIndexTableOffset eOffsetStart;
     624             :         NfIndexTableOffset eOffsetEnd;
     625             : 
     626           0 :         switch(nPrivCat)
     627             :         {
     628           0 :             case CAT_NUMBER         :eOffsetStart=NF_NUMBER_START;
     629           0 :                                      eOffsetEnd=NF_NUMBER_END;
     630           0 :                                      break;
     631           0 :             case CAT_PERCENT        :eOffsetStart=NF_PERCENT_START;
     632           0 :                                      eOffsetEnd=NF_PERCENT_END;
     633           0 :                                      break;
     634           0 :             case CAT_CURRENCY       :eOffsetStart=NF_CURRENCY_START;
     635           0 :                                      eOffsetEnd=NF_CURRENCY_END;
     636           0 :                                      break;
     637           0 :             case CAT_DATE           :eOffsetStart=NF_DATE_START;
     638           0 :                                      eOffsetEnd=NF_DATE_END;
     639           0 :                                      break;
     640           0 :             case CAT_TIME           :eOffsetStart=NF_TIME_START;
     641           0 :                                      eOffsetEnd=NF_TIME_END;
     642           0 :                                      break;
     643           0 :             case CAT_SCIENTIFIC     :eOffsetStart=NF_SCIENTIFIC_START;
     644           0 :                                      eOffsetEnd=NF_SCIENTIFIC_END;
     645           0 :                                      break;
     646           0 :             case CAT_FRACTION       :eOffsetStart=NF_FRACTION_START;
     647           0 :                                      eOffsetEnd=NF_FRACTION_END;
     648           0 :                                      break;
     649           0 :             case CAT_BOOLEAN        :eOffsetStart=NF_BOOLEAN;
     650           0 :                                      eOffsetEnd=NF_BOOLEAN;
     651           0 :                                      break;
     652           0 :             case CAT_TEXT           :eOffsetStart=NF_TEXT;
     653           0 :                                      eOffsetEnd=NF_TEXT;
     654           0 :                                      break;
     655           0 :             default                 :return;
     656             :         }
     657             : 
     658           0 :         nSelPos=FillEListWithFormats_Impl(rList,nSelPos,eOffsetStart,eOffsetEnd);
     659             : 
     660           0 :         if(nPrivCat==CAT_DATE || nPrivCat==CAT_TIME)
     661             :         {
     662           0 :             nSelPos=FillEListWithDateTime_Impl(rList,nSelPos);
     663             :             //if(nSelPos!=SELPOS_NONE) nSelPos=nTmpPos;
     664             :         }
     665             :     }
     666             : }
     667             : 
     668           0 : short SvxNumberFormatShell::FillEListWithFormats_Impl( std::vector<String*>& rList,
     669             :                                                        short nSelPos,
     670             :                                                        NfIndexTableOffset eOffsetStart,
     671             :                                                        NfIndexTableOffset eOffsetEnd)
     672             : {
     673             :     /* Erstellen einer aktuellen Liste von Format-Eintraegen.
     674             :      * Rueckgabewert ist die Listenposition des aktuellen Formates.
     675             :      * Ist die Liste leer oder gibt es kein aktuelles Format,
     676             :      * so wird SELPOS_NONE geliefert.
     677             :      */
     678             :     sal_uInt16  nMyType;
     679             : 
     680             :     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
     681             : 
     682           0 :     const SvNumberformat*   pNumEntry   = pCurFmtTable->empty() ? 0 : pCurFmtTable->begin()->second;
     683             :     sal_uInt32          nNFEntry;
     684           0 :     String          aStrComment;
     685           0 :     String          aNewFormNInfo;
     686             : 
     687           0 :     short           nMyCat      = SELPOS_NONE;
     688             : 
     689             :     long nIndex;
     690             : 
     691           0 :     for(nIndex=eOffsetStart;nIndex<=eOffsetEnd;nIndex++)
     692             :     {
     693           0 :         nNFEntry=pFormatter->GetFormatIndex((NfIndexTableOffset)nIndex,eCurLanguage);
     694             : 
     695           0 :         pNumEntry   = pFormatter->GetEntry(nNFEntry);
     696             : 
     697           0 :         if(pNumEntry==NULL) continue;
     698             : 
     699           0 :         nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
     700           0 :         aStrComment=pNumEntry->GetComment();
     701           0 :         CategoryToPos_Impl(nMyCat,nMyType);
     702           0 :         aNewFormNInfo=  pNumEntry->GetFormatstring();
     703             : 
     704           0 :         String *const pStr = new String(aNewFormNInfo);
     705             : 
     706           0 :         if ( nNFEntry == nCurFormatKey )
     707             :         {
     708           0 :             nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.size() : SELPOS_NONE;
     709             :         }
     710             : 
     711           0 :         rList.push_back( pStr );
     712           0 :         aCurEntryList.push_back( nNFEntry );
     713             :     }
     714             : 
     715           0 :     return nSelPos;
     716             : }
     717             : 
     718           0 : short SvxNumberFormatShell::FillEListWithDateTime_Impl( std::vector<String*>& rList,
     719             :                                                         short nSelPos)
     720             : {
     721             :     sal_uInt16  nMyType;
     722             : 
     723             :     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
     724             : 
     725           0 :     const SvNumberformat*   pNumEntry   = pCurFmtTable->empty() ? 0 : pCurFmtTable->begin()->second;
     726             :     sal_uInt32          nNFEntry;
     727           0 :     String          aStrComment;
     728           0 :     String          aNewFormNInfo;
     729             : 
     730           0 :     short           nMyCat      = SELPOS_NONE;
     731             : 
     732             :     long nIndex;
     733             : 
     734           0 :     for(nIndex=NF_DATETIME_START;nIndex<=NF_DATETIME_END;nIndex++)
     735             :     {
     736           0 :         nNFEntry=pFormatter->GetFormatIndex((NfIndexTableOffset)nIndex,eCurLanguage);
     737             : 
     738           0 :         pNumEntry   = pFormatter->GetEntry(nNFEntry);
     739           0 :         if(pNumEntry!=NULL)
     740             :         {
     741           0 :             nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
     742           0 :             aStrComment=pNumEntry->GetComment();
     743           0 :             CategoryToPos_Impl(nMyCat,nMyType);
     744           0 :             aNewFormNInfo=  pNumEntry->GetFormatstring();
     745             : 
     746           0 :             String *const pStr = new String(aNewFormNInfo);
     747             : 
     748           0 :             if ( nNFEntry == nCurFormatKey )
     749             :             {
     750           0 :                 nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.size() : SELPOS_NONE;
     751             :             }
     752             : 
     753           0 :             rList.push_back( pStr );
     754           0 :             aCurEntryList.push_back( nNFEntry );
     755             :         }
     756             :     }
     757             : 
     758           0 :     return nSelPos;
     759             : }
     760             : 
     761           0 : short SvxNumberFormatShell::FillEListWithCurrency_Impl( std::vector<String*>& rList,
     762             :                                                         short nSelPos)
     763             : {
     764             :     /* Erstellen einer aktuellen Liste von Format-Eintraegen.
     765             :      * Rueckgabewert ist die Listenposition des aktuellen Formates.
     766             :      * Ist die Liste leer oder gibt es kein aktuelles Format,
     767             :      * so wird SELPOS_NONE geliefert.
     768             :      */
     769             :     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
     770             : 
     771             :     const NfCurrencyEntry* pTmpCurrencyEntry;
     772             :     bool             bTmpBanking;
     773           0 :     OUString        rSymbol;
     774             : 
     775             :     bool bFlag=pFormatter->GetNewCurrencySymbolString(nCurFormatKey,rSymbol,
     776           0 :                                                       &pTmpCurrencyEntry,&bTmpBanking);
     777             : 
     778           0 :     if( (!bFlag && pCurCurrencyEntry==NULL) ||
     779           0 :         (bFlag && pTmpCurrencyEntry==NULL && rSymbol.isEmpty()) ||
     780           0 :         (nCurCategory==NUMBERFORMAT_ALL))
     781             :     {
     782           0 :         if ( nCurCategory == NUMBERFORMAT_ALL )
     783           0 :             FillEListWithUserCurrencys(rList,nSelPos);
     784           0 :         nSelPos=FillEListWithSysCurrencys(rList,nSelPos);
     785             :     }
     786             :     else
     787             :     {
     788           0 :         nSelPos=FillEListWithUserCurrencys(rList,nSelPos);
     789             :     }
     790             : 
     791           0 :     return nSelPos;
     792             : }
     793             : 
     794             : 
     795           0 : short SvxNumberFormatShell::FillEListWithSysCurrencys( std::vector<String*>& rList,
     796             :                                                        short nSelPos)
     797             : {
     798             :     /* Erstellen einer aktuellen Liste von Format-Eintraegen.
     799             :      * Rueckgabewert ist die Listenposition des aktuellen Formates.
     800             :      * Ist die Liste leer oder gibt es kein aktuelles Format,
     801             :      * so wird SELPOS_NONE geliefert.
     802             :      */
     803             :     sal_uInt16  nMyType;
     804             : 
     805             :     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
     806             : 
     807           0 :     const SvNumberformat*   pNumEntry   = pCurFmtTable->empty() ? 0 : pCurFmtTable->begin()->second;
     808             :     sal_uInt32          nNFEntry;
     809           0 :     String          aStrComment;
     810           0 :     String          aNewFormNInfo;
     811             : 
     812           0 :     nCurCurrencyEntryPos=0;
     813             : 
     814           0 :     short           nMyCat      = SELPOS_NONE;
     815             : 
     816           0 :     NfIndexTableOffset eOffsetStart=NF_CURRENCY_START;
     817           0 :     NfIndexTableOffset eOffsetEnd=NF_CURRENCY_END;
     818             :     long nIndex;
     819             : 
     820           0 :     for(nIndex=eOffsetStart;nIndex<=eOffsetEnd;nIndex++)
     821             :     {
     822           0 :         nNFEntry=pFormatter->GetFormatIndex((NfIndexTableOffset)nIndex,eCurLanguage);
     823             : 
     824           0 :         pNumEntry   = pFormatter->GetEntry(nNFEntry);
     825             : 
     826           0 :         if(pNumEntry==NULL) continue;
     827             : 
     828           0 :         nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
     829           0 :         aStrComment=pNumEntry->GetComment();
     830           0 :         CategoryToPos_Impl(nMyCat,nMyType);
     831           0 :         aNewFormNInfo=  pNumEntry->GetFormatstring();
     832             : 
     833           0 :         String *const pStr = new String(aNewFormNInfo);
     834             : 
     835           0 :         if ( nNFEntry == nCurFormatKey )
     836             :         {
     837           0 :             nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.size() : SELPOS_NONE;
     838             :         }
     839             : 
     840           0 :         rList.push_back( pStr );
     841           0 :         aCurEntryList.push_back( nNFEntry );
     842             :     }
     843             : 
     844           0 :     if(nCurCategory!=NUMBERFORMAT_ALL)
     845             :     {
     846           0 :         SvNumberFormatTable::iterator it = pCurFmtTable->begin();
     847             : 
     848           0 :         while ( it != pCurFmtTable->end() )
     849             :         {
     850           0 :             sal_uInt32 nKey = it->first;
     851           0 :             pNumEntry   = it->second;
     852             : 
     853           0 :             if ( !IsRemoved_Impl( nKey ))
     854             :             {
     855           0 :                 bool bUserNewCurrency=false;
     856           0 :                 if(pNumEntry->HasNewCurrency())
     857             :                 {
     858             :                     const NfCurrencyEntry* pTmpCurrencyEntry;
     859             :                     bool            bTmpBanking;
     860           0 :                     OUString       rSymbol;
     861             : 
     862             :                     pFormatter->GetNewCurrencySymbolString(nKey,rSymbol,
     863             :                                                            &pTmpCurrencyEntry,
     864           0 :                                                            &bTmpBanking);
     865             : 
     866           0 :                     bUserNewCurrency=(pTmpCurrencyEntry!=NULL);
     867             :                 }
     868             : 
     869           0 :                 if(!bUserNewCurrency &&(pNumEntry->GetType() & NUMBERFORMAT_DEFINED))
     870             :                 {
     871           0 :                     nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
     872           0 :                     aStrComment=pNumEntry->GetComment();
     873           0 :                     CategoryToPos_Impl(nMyCat,nMyType);
     874           0 :                     aNewFormNInfo=  pNumEntry->GetFormatstring();
     875             : 
     876           0 :                     String *const pStr = new String(aNewFormNInfo);
     877             : 
     878           0 :                     if ( nKey == nCurFormatKey ) nSelPos =aCurEntryList.size();
     879           0 :                     rList.push_back( pStr );
     880           0 :                     aCurEntryList.push_back( nKey );
     881             :                 }
     882             :             }
     883           0 :             ++it;
     884             :         }
     885             :     }
     886           0 :     return nSelPos;
     887             : }
     888             : 
     889           0 : short SvxNumberFormatShell::FillEListWithUserCurrencys( std::vector<String*>& rList,
     890             :                                                         short nSelPos)
     891             : {
     892             :     /* Erstellen einer aktuellen Liste von Format-Eintraegen.
     893             :      * Rueckgabewert ist die Listenposition des aktuellen Formates.
     894             :      * Ist die Liste leer oder gibt es kein aktuelles Format,
     895             :      * so wird SELPOS_NONE geliefert.
     896             :      */
     897             :     sal_uInt16 nMyType;
     898             : 
     899             :     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
     900             : 
     901           0 :     String          aStrComment;
     902           0 :     OUString        aNewFormNInfo;
     903           0 :     short           nMyCat = SELPOS_NONE;
     904             : 
     905             :     const NfCurrencyEntry* pTmpCurrencyEntry;
     906             :     bool            bTmpBanking, bAdaptSelPos;
     907           0 :     OUString        rSymbol;
     908           0 :     OUString       rBankSymbol;
     909             : 
     910           0 :     std::vector<String*>    aList;
     911           0 :     std::vector<sal_uInt32> aKeyList;
     912             : 
     913             :     pFormatter->GetNewCurrencySymbolString(nCurFormatKey,rSymbol,
     914             :                                            &pTmpCurrencyEntry,
     915           0 :                                            &bTmpBanking);
     916             : 
     917           0 :     XubString rShortSymbol;
     918             : 
     919           0 :     if(pCurCurrencyEntry==NULL)
     920             :     {
     921             :         // #110398# If no currency format was previously selected (we're not
     922             :         // about to add another currency), try to select the initial currency
     923             :         // format (nCurFormatKey) that was set in FormatChanged() after
     924             :         // matching the format string entered in the dialog.
     925           0 :         bAdaptSelPos = true;
     926           0 :         pCurCurrencyEntry = (NfCurrencyEntry*)pTmpCurrencyEntry;
     927           0 :         bBankingSymbol = bTmpBanking;
     928           0 :         nCurCurrencyEntryPos = FindCurrencyFormat(pTmpCurrencyEntry,bTmpBanking);
     929             :     }
     930             :     else
     931             :     {
     932           0 :         if (pTmpCurrencyEntry == pCurCurrencyEntry)
     933           0 :             bAdaptSelPos = true;
     934             :         else
     935             :         {
     936           0 :             bAdaptSelPos = false;
     937           0 :             pTmpCurrencyEntry = pCurCurrencyEntry;
     938             :         }
     939           0 :         bTmpBanking=bBankingSymbol;
     940             :     }
     941             : 
     942           0 :     if(pTmpCurrencyEntry!=NULL)
     943             :     {
     944           0 :         rSymbol = pTmpCurrencyEntry->BuildSymbolString(false);
     945           0 :         rBankSymbol = pTmpCurrencyEntry->BuildSymbolString(true);
     946           0 :         rShortSymbol = pTmpCurrencyEntry->BuildSymbolString(bTmpBanking,true);
     947             :     }
     948             : 
     949           0 :     SvNumberFormatTable::iterator it = pCurFmtTable->begin();
     950           0 :     while ( it != pCurFmtTable->end() )
     951             :     {
     952           0 :         sal_uInt32 nKey = it->first;
     953           0 :         const SvNumberformat* pNumEntry = it->second;
     954             : 
     955           0 :         if ( !IsRemoved_Impl( nKey ) )
     956             :         {
     957           0 :             if( pNumEntry->GetType() & NUMBERFORMAT_DEFINED ||
     958           0 :                 pNumEntry->IsAdditionalStandardDefined() )
     959             :             {
     960           0 :                 nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
     961           0 :                 aStrComment = pNumEntry->GetComment();
     962           0 :                 CategoryToPos_Impl(nMyCat,nMyType);
     963           0 :                 aNewFormNInfo =  pNumEntry->GetFormatstring();
     964             : 
     965           0 :                 bool bInsFlag = false;
     966           0 :                 if ( pNumEntry->HasNewCurrency() )
     967             :                 {
     968           0 :                     bInsFlag = true;    // merge locale formats into currency selection
     969             :                 }
     970           0 :                 else if( (!bTmpBanking && aNewFormNInfo.indexOf(rSymbol) >= 0) ||
     971           0 :                          (bTmpBanking && aNewFormNInfo.indexOf(rBankSymbol) >= 0) )
     972             :                 {
     973           0 :                     bInsFlag = true;
     974             :                 }
     975           0 :                 else if(aNewFormNInfo.indexOf(rShortSymbol) >= 0)
     976             :                 {
     977           0 :                     OUString rTstSymbol;
     978             :                     const NfCurrencyEntry* pTstCurrencyEntry;
     979             :                     bool bTstBanking;
     980             : 
     981             :                     pFormatter->GetNewCurrencySymbolString(nKey,rTstSymbol,
     982             :                                                            &pTstCurrencyEntry,
     983           0 :                                                            &bTstBanking);
     984             : 
     985           0 :                     if(pTmpCurrencyEntry == pTstCurrencyEntry &&
     986           0 :                        bTstBanking == bTmpBanking)
     987             :                     {
     988           0 :                         bInsFlag = true;
     989           0 :                     }
     990             : 
     991             :                 }
     992             : 
     993           0 :                 if(bInsFlag)
     994             :                 {
     995           0 :                     aList.push_back( new String(aNewFormNInfo) );
     996           0 :                     aKeyList.push_back( nKey );
     997             :                 }
     998             :             }
     999             :         }
    1000           0 :         ++it;
    1001             :     }
    1002             : 
    1003           0 :     NfWSStringsDtor aWSStringsDtor;
    1004             :     sal_uInt16 nDefault;
    1005           0 :     if ( pTmpCurrencyEntry && nCurCategory != NUMBERFORMAT_ALL )
    1006             :     {
    1007             :         nDefault = pFormatter->GetCurrencyFormatStrings(
    1008           0 :             aWSStringsDtor, *pTmpCurrencyEntry, bTmpBanking );
    1009           0 :         if ( !bTmpBanking )
    1010             :             pFormatter->GetCurrencyFormatStrings(
    1011           0 :                 aWSStringsDtor, *pTmpCurrencyEntry, true );
    1012             :     }
    1013             :     else
    1014           0 :         nDefault = 0;
    1015           0 :     if ( !bTmpBanking && nCurCategory != NUMBERFORMAT_ALL )
    1016             :     {   // append formats for all currencies defined in the current I18N locale
    1017           0 :         const NfCurrencyTable& rCurrencyTable = SvNumberFormatter::GetTheCurrencyTable();
    1018           0 :         sal_uInt16 nCurrCount = rCurrencyTable.size();
    1019           0 :         LanguageType eLang = MsLangId::getRealLanguage( eCurLanguage );
    1020           0 :         for ( sal_uInt16 i=0; i < nCurrCount; ++i )
    1021             :         {
    1022           0 :             const NfCurrencyEntry* pCurr = &rCurrencyTable[i];
    1023           0 :             if ( pCurr->GetLanguage() == eLang && pTmpCurrencyEntry != pCurr )
    1024             :             {
    1025           0 :                 pFormatter->GetCurrencyFormatStrings( aWSStringsDtor, *pCurr, false );
    1026           0 :                 pFormatter->GetCurrencyFormatStrings( aWSStringsDtor, *pCurr, true );
    1027             :             }
    1028             :         }
    1029             :     }
    1030             : 
    1031           0 :     size_t nOldListCount = rList.size();
    1032           0 :     for( size_t i = 0, nPos = nOldListCount; i < aWSStringsDtor.size(); ++i )
    1033             :     {
    1034           0 :         bool bFlag = true;
    1035           0 :         String aInsStr(aWSStringsDtor[i]);
    1036             :         size_t j;
    1037           0 :         for( j=0; j < aList.size(); ++j )
    1038             :         {
    1039           0 :             const String * pTestStr=aList[j];
    1040             : 
    1041           0 :             if(*pTestStr==aInsStr)
    1042             :             {
    1043           0 :                 bFlag = false;
    1044           0 :                 break;
    1045             :             }
    1046             :         }
    1047           0 :         if(bFlag)
    1048             :         {
    1049           0 :             rList.push_back( new String(aInsStr) );
    1050           0 :             aCurEntryList.insert( aCurEntryList.begin() + (nPos++), NUMBERFORMAT_ENTRY_NOT_FOUND);
    1051             :         }
    1052             :         else
    1053             :         {
    1054           0 :             rList.push_back( aList[j] );
    1055           0 :             aList.erase( aList.begin()+j );
    1056           0 :             aCurEntryList.insert( aCurEntryList.begin() + (nPos++), aKeyList[j]);
    1057           0 :             aKeyList.erase( aKeyList.begin()+j );
    1058             :         }
    1059           0 :     }
    1060             : 
    1061           0 :     for( size_t i = 0; i < aKeyList.size(); ++i )
    1062             :     {
    1063           0 :         if( aKeyList[i] != NUMBERFORMAT_ENTRY_NOT_FOUND )
    1064             :         {
    1065           0 :             rList.push_back( aList[i] );
    1066           0 :             aCurEntryList.push_back( aKeyList[i] );
    1067             :         }
    1068             :     }
    1069             : 
    1070           0 :     for( size_t i = nOldListCount; i < rList.size(); ++i )
    1071             :     {
    1072           0 :         aCurrencyFormatList.push_back( new String(*rList[i]) );
    1073             : 
    1074           0 :         if ( nSelPos == SELPOS_NONE && bAdaptSelPos && aCurEntryList[i] == nCurFormatKey )
    1075           0 :             nSelPos = i;
    1076             :     }
    1077             : 
    1078           0 :     if ( nSelPos == SELPOS_NONE && nCurCategory != NUMBERFORMAT_ALL )
    1079           0 :         nSelPos = nDefault;
    1080             : 
    1081           0 :     return nSelPos;
    1082             : }
    1083             : 
    1084             : 
    1085           0 : short SvxNumberFormatShell::FillEListWithUsD_Impl( std::vector<String*>& rList,
    1086             :                                                    sal_uInt16 nPrivCat, short nSelPos )
    1087             : {
    1088             :     /* Erstellen einer aktuellen Liste von Format-Eintraegen.
    1089             :      * Rueckgabewert ist die Listenposition des aktuellen Formates.
    1090             :      * Ist die Liste leer oder gibt es kein aktuelles Format,
    1091             :      * so wird SELPOS_NONE geliefert.
    1092             :      */
    1093             :     sal_uInt16 nMyType;
    1094             : 
    1095             :     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
    1096             : 
    1097           0 :     String          aStrComment;
    1098           0 :     String          aNewFormNInfo;
    1099             : 
    1100           0 :     short           nMyCat      = SELPOS_NONE;
    1101           0 :     bool            bAdditional = (nPrivCat != CAT_USERDEFINED &&
    1102           0 :                                     nCurCategory != NUMBERFORMAT_ALL);
    1103             : 
    1104           0 :     SvNumberFormatTable::iterator it = pCurFmtTable->begin();
    1105           0 :     while ( it != pCurFmtTable->end() )
    1106             :     {
    1107           0 :         sal_uInt32 nKey = it->first;
    1108           0 :         const SvNumberformat* pNumEntry = it->second;
    1109             : 
    1110           0 :         if ( !IsRemoved_Impl( nKey ) )
    1111             :         {
    1112           0 :             if( (pNumEntry->GetType() & NUMBERFORMAT_DEFINED) ||
    1113           0 :                     (bAdditional && pNumEntry->IsAdditionalStandardDefined()) )
    1114             :             {
    1115           0 :                 nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
    1116           0 :                 aStrComment=pNumEntry->GetComment();
    1117           0 :                 CategoryToPos_Impl(nMyCat,nMyType);
    1118           0 :                 aNewFormNInfo=  pNumEntry->GetFormatstring();
    1119             : 
    1120           0 :                 bool bFlag=true;
    1121           0 :                 if(pNumEntry->HasNewCurrency())
    1122             :                 {
    1123             :                     bool bTestBanking;
    1124           0 :                     sal_uInt16 nPos=FindCurrencyTableEntry(aNewFormNInfo,bTestBanking);
    1125           0 :                     bFlag=!IsInTable(nPos,bTestBanking,aNewFormNInfo);
    1126             :                 }
    1127           0 :                 if(bFlag)
    1128             :                 {
    1129           0 :                     String *const pStr = new String(aNewFormNInfo);
    1130             : 
    1131           0 :                     if ( nKey == nCurFormatKey ) nSelPos = aCurEntryList.size();
    1132           0 :                     rList.push_back( pStr );
    1133           0 :                     aCurEntryList.push_back( nKey );
    1134             :                 }
    1135             :             }
    1136             :         }
    1137           0 :         ++it;
    1138             :     }
    1139           0 :     return nSelPos;
    1140             : }
    1141             : 
    1142             : 
    1143             : // -----------------------------------------------------------------------
    1144             : 
    1145           0 : void SvxNumberFormatShell::GetPreviewString_Impl( String& rString, Color*& rpColor )
    1146             : {
    1147           0 :     rpColor = NULL;
    1148             : 
    1149             :     //  #50441# if a string was set in addition to the value, use it for text formats
    1150           0 :     bool bUseText = ( eValType == SVX_VALUE_TYPE_STRING ||
    1151           0 :                         ( aValStr.Len() && ( pFormatter->GetType(nCurFormatKey) & NUMBERFORMAT_TEXT ) ) );
    1152             : 
    1153           0 :     if ( bUseText )
    1154             :     {
    1155           0 :         OUString sTempIn(aValStr);
    1156           0 :         OUString sTempOut(rString);
    1157           0 :         pFormatter->GetOutputString( sTempIn, nCurFormatKey, sTempOut, &rpColor );
    1158           0 :         aValStr = sTempIn;
    1159           0 :         rString = sTempOut;
    1160             :     }
    1161             :     else
    1162             :     {
    1163           0 :         OUString sTemp(rString);
    1164           0 :         pFormatter->GetOutputString( nValNum, nCurFormatKey, sTemp, &rpColor, bUseStarFormat );
    1165           0 :         rString = sTemp;
    1166             :     }
    1167           0 : }
    1168             : 
    1169             : // -----------------------------------------------------------------------
    1170             : 
    1171           0 : ::std::vector<sal_uInt32>::iterator SvxNumberFormatShell::GetRemoved_Impl( size_t nKey )
    1172             : {
    1173           0 :     return ::std::find(aDelList.begin(), aDelList.end(), nKey);
    1174             : }
    1175             : 
    1176             : // -----------------------------------------------------------------------
    1177             : 
    1178           0 : bool SvxNumberFormatShell::IsRemoved_Impl( size_t nKey )
    1179             : {
    1180           0 :     return GetRemoved_Impl( nKey ) != aDelList.end();
    1181             : }
    1182             : 
    1183             : // -----------------------------------------------------------------------
    1184             : 
    1185           0 : ::std::vector<sal_uInt32>::iterator SvxNumberFormatShell::GetAdded_Impl( size_t nKey )
    1186             : {
    1187           0 :     return ::std::find(aAddList.begin(), aAddList.end(), nKey);
    1188             : }
    1189             : 
    1190             : //------------------------------------------------------------------------
    1191             : 
    1192           0 : bool SvxNumberFormatShell::IsAdded_Impl( size_t nKey )
    1193             : {
    1194           0 :     return GetAdded_Impl( nKey ) != aAddList.end();
    1195             : }
    1196             : 
    1197             : // -----------------------------------------------------------------------
    1198             : // Konvertierungs-Routinen:
    1199             : // ------------------------
    1200             : 
    1201           0 : void SvxNumberFormatShell::PosToCategory_Impl( sal_uInt16 nPos, short& rCategory )
    1202             : {
    1203             :     // Kategorie ::com::sun::star::form-Positionen abbilden (->Resource)
    1204           0 :     switch ( nPos )
    1205             :     {
    1206           0 :         case CAT_USERDEFINED:   rCategory = NUMBERFORMAT_DEFINED;       break;
    1207           0 :         case CAT_NUMBER:        rCategory = NUMBERFORMAT_NUMBER;        break;
    1208           0 :         case CAT_PERCENT:       rCategory = NUMBERFORMAT_PERCENT;       break;
    1209           0 :         case CAT_CURRENCY:      rCategory = NUMBERFORMAT_CURRENCY;      break;
    1210           0 :         case CAT_DATE:          rCategory = NUMBERFORMAT_DATE;          break;
    1211           0 :         case CAT_TIME:          rCategory = NUMBERFORMAT_TIME;          break;
    1212           0 :         case CAT_SCIENTIFIC:    rCategory = NUMBERFORMAT_SCIENTIFIC;    break;
    1213           0 :         case CAT_FRACTION:      rCategory = NUMBERFORMAT_FRACTION;      break;
    1214           0 :         case CAT_BOOLEAN:       rCategory = NUMBERFORMAT_LOGICAL;       break;
    1215           0 :         case CAT_TEXT:          rCategory = NUMBERFORMAT_TEXT;          break;
    1216             :         case CAT_ALL:
    1217           0 :         default:    rCategory = NUMBERFORMAT_ALL; break;
    1218             :     }
    1219           0 : }
    1220             : 
    1221             : // -----------------------------------------------------------------------
    1222             : 
    1223           0 : void SvxNumberFormatShell::CategoryToPos_Impl( short nCategory, sal_uInt16& rPos )
    1224             : {
    1225             :     // Kategorie auf ::com::sun::star::form-Positionen abbilden (->Resource)
    1226           0 :     switch ( nCategory )
    1227             :     {
    1228           0 :         case NUMBERFORMAT_DEFINED:      rPos = CAT_USERDEFINED; break;
    1229           0 :         case NUMBERFORMAT_NUMBER:       rPos = CAT_NUMBER;      break;
    1230           0 :         case NUMBERFORMAT_PERCENT:      rPos = CAT_PERCENT;     break;
    1231           0 :         case NUMBERFORMAT_CURRENCY:     rPos = CAT_CURRENCY;    break;
    1232             :         case NUMBERFORMAT_DATETIME:
    1233           0 :         case NUMBERFORMAT_DATE:         rPos = CAT_DATE;        break;
    1234           0 :         case NUMBERFORMAT_TIME:         rPos = CAT_TIME;        break;
    1235           0 :         case NUMBERFORMAT_SCIENTIFIC:   rPos = CAT_SCIENTIFIC;  break;
    1236           0 :         case NUMBERFORMAT_FRACTION:     rPos = CAT_FRACTION;    break;
    1237           0 :         case NUMBERFORMAT_LOGICAL:      rPos = CAT_BOOLEAN;     break;
    1238           0 :         case NUMBERFORMAT_TEXT:         rPos = CAT_TEXT;        break;
    1239             :         case NUMBERFORMAT_ALL:
    1240           0 :         default:                        rPos = CAT_ALL;
    1241             :     }
    1242           0 : }
    1243             : 
    1244             : 
    1245             : /*************************************************************************
    1246             : #*  Member:     MakePrevStringFromVal                       Datum:19.09.97
    1247             : #*------------------------------------------------------------------------
    1248             : #*
    1249             : #*  Klasse:     SvxNumberFormatShell
    1250             : #*
    1251             : #*  Funktion:   Formatiert die Zahl nValue abhaengig von rFormatStr
    1252             : #*              und speichert das Ergebnis in rPreviewStr.
    1253             : #*
    1254             : #*  Input:      FormatString, Farbe, zu formatierende Zahl
    1255             : #*
    1256             : #*  Output:     Ausgabestring rPreviewStr
    1257             : #*
    1258             : #************************************************************************/
    1259             : 
    1260           0 : void SvxNumberFormatShell::MakePrevStringFromVal(
    1261             :         const String& rFormatStr,
    1262             :         String& rPreviewStr,
    1263             :         Color*& rpFontColor,
    1264             :         double  nValue)
    1265             : {
    1266           0 :     rpFontColor = NULL;
    1267           0 :     OUString sTempOut(rPreviewStr);
    1268           0 :     pFormatter->GetPreviewString( rFormatStr, nValue, sTempOut, &rpFontColor, eCurLanguage );
    1269           0 :     rPreviewStr = sTempOut;
    1270           0 : }
    1271             : 
    1272             : /*************************************************************************
    1273             : #*  Member:     GetComment4Entry                            Datum:30.10.97
    1274             : #*------------------------------------------------------------------------
    1275             : #*
    1276             : #*  Klasse:     SvxNumberFormatShell
    1277             : #*
    1278             : #*  Funktion:   Liefert den Kommentar fuer einen gegebenen
    1279             : #*              Eintrag zurueck.
    1280             : #*
    1281             : #*  Input:      Nummer des Eintrags
    1282             : #*
    1283             : #*  Output:     Kommentar-String
    1284             : #*
    1285             : #************************************************************************/
    1286             : 
    1287           0 : void SvxNumberFormatShell::SetComment4Entry(short nEntry,String aEntStr)
    1288             : {
    1289             :     SvNumberformat *pNumEntry;
    1290           0 :     if(nEntry<0) return;
    1291           0 :     sal_uInt32  nMyNfEntry=aCurEntryList[nEntry];
    1292           0 :     pNumEntry = (SvNumberformat*)pFormatter->GetEntry(nMyNfEntry);
    1293           0 :     if(pNumEntry!=NULL) pNumEntry->SetComment(aEntStr);
    1294             : }
    1295             : 
    1296             : /*************************************************************************
    1297             : #*  Member:     GetComment4Entry                            Datum:30.10.97
    1298             : #*------------------------------------------------------------------------
    1299             : #*
    1300             : #*  Klasse:     SvxNumberFormatShell
    1301             : #*
    1302             : #*  Funktion:   Liefert den Kommentar fuer einen gegebenen
    1303             : #*              Eintrag zurueck.
    1304             : #*
    1305             : #*  Input:      Nummer des Eintrags
    1306             : #*
    1307             : #*  Output:     Kommentar-String
    1308             : #*
    1309             : #************************************************************************/
    1310             : 
    1311           0 : String SvxNumberFormatShell::GetComment4Entry(short nEntry)
    1312             : {
    1313           0 :     if(nEntry < 0)
    1314           0 :         return String();
    1315             : 
    1316           0 :     if( static_cast<size_t>(nEntry) < aCurEntryList.size())
    1317             :     {
    1318           0 :         sal_uInt32  nMyNfEntry=aCurEntryList[nEntry];
    1319           0 :         const SvNumberformat *pNumEntry = pFormatter->GetEntry(nMyNfEntry);
    1320           0 :         if(pNumEntry!=NULL)
    1321           0 :             return pNumEntry->GetComment();
    1322             :     }
    1323             : 
    1324           0 :     return String();
    1325             : }
    1326             : 
    1327             : /*************************************************************************
    1328             : #*  Member:     GetCategory4Entry                           Datum:30.10.97
    1329             : #*------------------------------------------------------------------------
    1330             : #*
    1331             : #*  Klasse:     SvxNumberFormatShell
    1332             : #*
    1333             : #*  Funktion:   Liefert die Kategorie- Nummer fuer einen gegebenen
    1334             : #*              Eintrag zurueck.
    1335             : #*
    1336             : #*  Input:      Nummer des Eintrags
    1337             : #*
    1338             : #*  Output:     Kategorie- Nummer
    1339             : #*
    1340             : #************************************************************************/
    1341             : 
    1342           0 : short SvxNumberFormatShell::GetCategory4Entry(short nEntry)
    1343             : {
    1344           0 :     if(nEntry<0) return 0;
    1345             : 
    1346           0 :     if( static_cast<size_t>(nEntry) < aCurEntryList.size() )
    1347             :     {
    1348           0 :         sal_uInt32  nMyNfEntry=aCurEntryList[nEntry];
    1349             : 
    1350           0 :         if(nMyNfEntry!=NUMBERFORMAT_ENTRY_NOT_FOUND)
    1351             :         {
    1352           0 :             const SvNumberformat *pNumEntry = pFormatter->GetEntry(nMyNfEntry);
    1353             :             sal_uInt16 nMyCat,nMyType;
    1354           0 :             if(pNumEntry!=NULL)
    1355             :             {
    1356           0 :                 nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
    1357           0 :                 CategoryToPos_Impl(nMyCat,nMyType);
    1358             : 
    1359           0 :                 return (short) nMyType;
    1360             :             }
    1361           0 :             return 0;
    1362             :         }
    1363           0 :         else if( !aCurrencyFormatList.empty() )
    1364             :         {
    1365           0 :             return CAT_CURRENCY;
    1366             :         }
    1367             :     }
    1368           0 :     return 0;
    1369             : 
    1370             : }
    1371             : 
    1372             : /*************************************************************************
    1373             : #*  Member:     GetUserDefined4Entry                        Datum:31.10.97
    1374             : #*------------------------------------------------------------------------
    1375             : #*
    1376             : #*  Klasse:     SvxNumberFormatShell
    1377             : #*
    1378             : #*  Funktion:   Liefert die Information, ob ein Eintrag
    1379             : #*              benutzerspezifisch ist zurueck.
    1380             : #*
    1381             : #*  Input:      Nummer des Eintrags
    1382             : #*
    1383             : #*  Output:     Benutzerspezifisch?
    1384             : #*
    1385             : #************************************************************************/
    1386             : 
    1387           0 : bool SvxNumberFormatShell::GetUserDefined4Entry(short nEntry)
    1388             : {
    1389           0 :     if(nEntry<0) return false;
    1390             : 
    1391           0 :     if( static_cast<size_t>(nEntry) < aCurEntryList.size())
    1392             :     {
    1393           0 :         sal_uInt32  nMyNfEntry=aCurEntryList[nEntry];
    1394           0 :         const SvNumberformat *pNumEntry = pFormatter->GetEntry(nMyNfEntry);
    1395             : 
    1396           0 :         if(pNumEntry!=NULL)
    1397             :         {
    1398           0 :             if((pNumEntry->GetType() & NUMBERFORMAT_DEFINED)>0)
    1399             :             {
    1400           0 :                 return true;
    1401             :             }
    1402             :         }
    1403             :     }
    1404           0 :     return false;
    1405             : }
    1406             : 
    1407             : 
    1408             : /*************************************************************************
    1409             : #*  Member:     GetFormat4Entry                             Datum:30.10.97
    1410             : #*------------------------------------------------------------------------
    1411             : #*
    1412             : #*  Klasse:     SvxNumberFormatShell
    1413             : #*
    1414             : #*  Funktion:   Liefert den Format- String fuer einen gegebenen
    1415             : #*              Eintrag zurueck.
    1416             : #*
    1417             : #*  Input:      Nummer des Eintrags
    1418             : #*
    1419             : #*  Output:     Format- String
    1420             : #*
    1421             : #************************************************************************/
    1422             : 
    1423           0 : String SvxNumberFormatShell::GetFormat4Entry(short nEntry)
    1424             : {
    1425           0 :     if(nEntry < 0)
    1426           0 :         return String();
    1427             : 
    1428           0 :     if( !aCurrencyFormatList.empty() )
    1429             :     {
    1430           0 :         if( aCurrencyFormatList.size() > static_cast<size_t>(nEntry) )
    1431           0 :             return *aCurrencyFormatList[nEntry];
    1432             :     }
    1433             :     else
    1434             :     {
    1435           0 :         sal_uInt32  nMyNfEntry=aCurEntryList[nEntry];
    1436           0 :         const SvNumberformat *pNumEntry = pFormatter->GetEntry(nMyNfEntry);
    1437             : 
    1438           0 :         if(pNumEntry!=NULL)
    1439           0 :             return pNumEntry->GetFormatstring();
    1440             :     }
    1441           0 :     return String();
    1442             : }
    1443             : 
    1444             : /*************************************************************************
    1445             : #*  Member:     GetListPos4Entry                            Datum:31.10.97
    1446             : #*------------------------------------------------------------------------
    1447             : #*
    1448             : #*  Klasse:     SvxNumberFormatShell
    1449             : #*
    1450             : #*  Funktion:   Liefert die Listen- Nummer fuer einen gegebenen
    1451             : #*              Formatindex zurueck.
    1452             : #*
    1453             : #*  Input:      Nummer des Eintrags
    1454             : #*
    1455             : #*  Output:     Kategorie- Nummer
    1456             : #*
    1457             : #************************************************************************/
    1458             : 
    1459           0 : short SvxNumberFormatShell::GetListPos4Entry(sal_uInt32 nIdx)
    1460             : {
    1461           0 :     short nSelP=SELPOS_NONE;
    1462             : 
    1463             :     // Check list size against return type limit.
    1464           0 :     if( aCurEntryList.size() <= static_cast<size_t>(::std::numeric_limits< short >::max()) )
    1465             :     {
    1466           0 :         for(size_t i=0; i < aCurEntryList.size(); ++i)
    1467             :         {
    1468           0 :             if(aCurEntryList[i]==nIdx)
    1469             :             {
    1470           0 :                 nSelP=i;
    1471           0 :                 break;
    1472             :             }
    1473             :         }
    1474             :     }
    1475             :     else
    1476             :     {
    1477             :         OSL_FAIL("svx::SvxNumberFormatShell::GetListPos4Entry(), list got too large!" );
    1478             :     }
    1479           0 :     return nSelP;
    1480             : }
    1481             : 
    1482           0 : short SvxNumberFormatShell::GetListPos4Entry( const String& rFmtString )
    1483             : {
    1484           0 :     sal_uInt32 nAt=0;
    1485           0 :     short nSelP=SELPOS_NONE;
    1486           0 :     if(FindEntry(rFmtString, &nAt))
    1487             :     {
    1488           0 :         if(NUMBERFORMAT_ENTRY_NOT_FOUND!=nAt && NUMBERFORMAT_ENTRY_NEW_CURRENCY!=nAt)
    1489             :         {
    1490           0 :             nSelP=GetListPos4Entry(nAt);
    1491             :         }
    1492             :         else
    1493             :         {
    1494           0 :             for( size_t i=0; i<aCurrencyFormatList.size(); i++ )
    1495             :             {
    1496           0 :                 if (rFmtString==*aCurrencyFormatList[i])
    1497             :                 {
    1498           0 :                     nSelP = static_cast<short>(i);
    1499           0 :                     break;
    1500             :                 }
    1501             :             }
    1502             :         }
    1503             :     }
    1504           0 :     return nSelP;
    1505             : }
    1506             : 
    1507           0 : String SvxNumberFormatShell::GetStandardName() const
    1508             : {
    1509           0 :     return pFormatter->GetStandardName( eCurLanguage);
    1510             : }
    1511             : 
    1512           0 : void SvxNumberFormatShell::GetCurrencySymbols(std::vector<OUString>& rList, sal_uInt16* pPos)
    1513             : {
    1514           0 :     const NfCurrencyEntry* pTmpCurrencyEntry=SvNumberFormatter::MatchSystemCurrency();
    1515             : 
    1516           0 :     bool bFlag=(pTmpCurrencyEntry==NULL);
    1517             : 
    1518           0 :     GetCurrencySymbols(rList, bFlag);
    1519             : 
    1520           0 :     if(pPos!=NULL)
    1521             :     {
    1522           0 :         const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
    1523           0 :         sal_uInt16 nTableCount=rCurrencyTable.size();
    1524             : 
    1525           0 :         *pPos=0;
    1526           0 :         size_t nCount=aCurCurrencyList.size();
    1527             : 
    1528           0 :         if(bFlag)
    1529             :         {
    1530           0 :             *pPos=1;
    1531           0 :             nCurCurrencyEntryPos=1;
    1532             :         }
    1533             :         else
    1534             :         {
    1535           0 :             for(size_t i=1;i<nCount;i++)
    1536             :             {
    1537           0 :                 const sal_uInt16 j = aCurCurrencyList[i];
    1538           0 :                 if (j != (sal_uInt16)-1 && j < nTableCount &&
    1539           0 :                         pTmpCurrencyEntry == &rCurrencyTable[j])
    1540             :                 {
    1541           0 :                     *pPos=static_cast<sal_uInt16>(i);
    1542           0 :                     nCurCurrencyEntryPos=static_cast<sal_uInt16>(i);
    1543           0 :                     break;
    1544             :                 }
    1545             :             }
    1546             :         }
    1547             :     }
    1548             : 
    1549           0 : }
    1550             : 
    1551           0 : void SvxNumberFormatShell::GetCurrencySymbols(std::vector<OUString>& rList, bool bFlag)
    1552             : {
    1553           0 :     aCurCurrencyList.clear();
    1554             : 
    1555           0 :     const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
    1556           0 :     sal_uInt16 nCount=rCurrencyTable.size();
    1557             : 
    1558           0 :     SvtLanguageTable* pLanguageTable=new SvtLanguageTable;
    1559             : 
    1560           0 :     sal_uInt16 nStart=1;
    1561             : 
    1562           0 :     XubString aString( ApplyLreOrRleEmbedding( rCurrencyTable[0].GetSymbol()));
    1563           0 :     aString += sal_Unicode(' ');
    1564           0 :     aString += ApplyLreOrRleEmbedding( pLanguageTable->GetString( rCurrencyTable[0].GetLanguage()));
    1565             : 
    1566           0 :     rList.push_back(aString);
    1567           0 :     sal_uInt16 nAuto=(sal_uInt16)-1;
    1568           0 :     aCurCurrencyList.push_back(nAuto);
    1569             : 
    1570           0 :     if(bFlag)
    1571             :     {
    1572           0 :         rList.push_back(aString);
    1573           0 :         aCurCurrencyList.push_back(0);
    1574           0 :         ++nStart;
    1575             :     }
    1576             : 
    1577           0 :     CollatorWrapper aCollator( ::comphelper::getProcessComponentContext());
    1578           0 :     aCollator.loadDefaultCollator( Application::GetSettings().GetLanguageTag().getLocale(), 0);
    1579             : 
    1580           0 :     const String aTwoSpace( RTL_CONSTASCII_USTRINGPARAM( "  "));
    1581             : 
    1582           0 :     for(sal_uInt16 i = 1; i < nCount; ++i)
    1583             :     {
    1584           0 :         XubString aStr( ApplyLreOrRleEmbedding( rCurrencyTable[i].GetBankSymbol()));
    1585           0 :         aStr += aTwoSpace;
    1586           0 :         aStr += ApplyLreOrRleEmbedding( rCurrencyTable[i].GetSymbol());
    1587           0 :         aStr += aTwoSpace;
    1588           0 :         aStr += ApplyLreOrRleEmbedding( pLanguageTable->GetString( rCurrencyTable[i].GetLanguage()));
    1589             : 
    1590           0 :         sal_uInt16 j = nStart;
    1591           0 :         for(; j < rList.size(); ++j)
    1592           0 :             if (aCollator.compareString(aStr, rList[j]) < 0)
    1593           0 :                 break;  // insert before first greater than
    1594             : 
    1595           0 :         rList.insert(rList.begin() + j, aStr);
    1596           0 :         aCurCurrencyList.insert(aCurCurrencyList.begin() + j, i);
    1597           0 :     }
    1598             : 
    1599             :     // Append ISO codes to symbol list.
    1600             :     // XXX If this is to be changed, various other places would had to be
    1601             :     // adapted that assume this order!
    1602           0 :     sal_uInt16 nCont = rList.size();
    1603             : 
    1604           0 :     for(sal_uInt16 i = 1; i < nCount; ++i)
    1605             :     {
    1606           0 :         bool bInsert = true;
    1607           0 :         OUString aStr(ApplyLreOrRleEmbedding(rCurrencyTable[i].GetBankSymbol()));
    1608             : 
    1609           0 :         sal_uInt16 j = nCont;
    1610           0 :         for(; j < rList.size() && bInsert; ++j)
    1611             :         {
    1612           0 :             if(rList[j] == aStr)
    1613           0 :                 bInsert = false;
    1614           0 :             else if (aCollator.compareString(aStr, rList[j]) < 0)
    1615           0 :                 break;  // insert before first greater than
    1616             :         }
    1617           0 :         if(bInsert)
    1618             :         {
    1619           0 :             rList.insert(rList.begin() + j, aStr);
    1620           0 :             aCurCurrencyList.insert(aCurCurrencyList.begin()+j, i);
    1621             :         }
    1622           0 :     }
    1623             : 
    1624           0 :     delete pLanguageTable;
    1625           0 : }
    1626             : 
    1627           0 : void SvxNumberFormatShell::SetCurrencySymbol(sal_uInt16 nPos)
    1628             : {
    1629           0 :     const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
    1630           0 :     sal_uInt16 nCount=rCurrencyTable.size();
    1631             : 
    1632           0 :     bBankingSymbol=(nPos>=nCount);
    1633             : 
    1634           0 :     if(nPos<aCurCurrencyList.size())
    1635             :     {
    1636           0 :         sal_uInt16 nCurrencyPos=aCurCurrencyList[nPos];
    1637           0 :         if(nCurrencyPos!=(sal_uInt16)-1)
    1638             :         {
    1639           0 :             pCurCurrencyEntry=(NfCurrencyEntry*)&rCurrencyTable[nCurrencyPos];
    1640           0 :             nCurCurrencyEntryPos=nPos;
    1641             :         }
    1642             :         else
    1643             :         {
    1644           0 :             pCurCurrencyEntry=NULL;
    1645           0 :             nCurCurrencyEntryPos=0;
    1646             :             nCurFormatKey=pFormatter->GetFormatIndex(
    1647           0 :                          NF_CURRENCY_1000DEC2_RED, eCurLanguage);
    1648             :         }
    1649             :     }
    1650           0 : }
    1651             : 
    1652           0 : sal_uInt32 SvxNumberFormatShell::GetCurrencySymbol()
    1653             : {
    1654           0 :     return nCurCurrencyEntryPos;
    1655             : }
    1656             : 
    1657           0 : void SvxNumberFormatShell::SetCurCurrencyEntry(NfCurrencyEntry* pCEntry)
    1658             : {
    1659           0 :     pCurCurrencyEntry=pCEntry;
    1660           0 : }
    1661             : 
    1662           0 : bool SvxNumberFormatShell::IsTmpCurrencyFormat( const String& rFmtString )
    1663             : {
    1664             :     sal_uInt32 nFound;
    1665           0 :     FindEntry(rFmtString, &nFound);
    1666             : 
    1667           0 :     if(nFound==NUMBERFORMAT_ENTRY_NEW_CURRENCY)
    1668             :     {
    1669           0 :         return true;
    1670             :     }
    1671           0 :     return false;
    1672             : }
    1673             : 
    1674           0 : sal_uInt16 SvxNumberFormatShell::FindCurrencyFormat( const String& rFmtString )
    1675             : {
    1676           0 :     const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
    1677           0 :     sal_uInt16 nCount=rCurrencyTable.size();
    1678             : 
    1679           0 :     bool bTestBanking=false;
    1680             : 
    1681           0 :     sal_uInt16 nPos=FindCurrencyTableEntry(rFmtString, bTestBanking);
    1682             : 
    1683           0 :     if(nPos!=(sal_uInt16)-1)
    1684             :     {
    1685           0 :         sal_uInt16 nStart=0;
    1686           0 :         if(bTestBanking && aCurCurrencyList.size()>nPos)
    1687             :         {
    1688           0 :             nStart=nCount;
    1689             :         }
    1690           0 :         for(sal_uInt16 j=nStart;j<aCurCurrencyList.size();j++)
    1691             :         {
    1692           0 :             if(aCurCurrencyList[j]==nPos) return j;
    1693             :         }
    1694             :     }
    1695           0 :     return (sal_uInt16) -1;
    1696             : }
    1697             : 
    1698           0 : sal_uInt16 SvxNumberFormatShell::FindCurrencyTableEntry( const String& rFmtString, bool &bTestBanking )
    1699             : {
    1700           0 :     sal_uInt16 nPos=(sal_uInt16) -1;
    1701             : 
    1702           0 :     const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
    1703           0 :     sal_uInt16 nCount=rCurrencyTable.size();
    1704             : 
    1705             :     const SvNumberformat* pFormat;
    1706           0 :     OUString aSymbol, aExtension;
    1707           0 :     sal_uInt32 nFound = pFormatter->TestNewString( rFmtString, eCurLanguage );
    1708           0 :     if ( nFound != NUMBERFORMAT_ENTRY_NOT_FOUND &&
    1709           0 :             ((pFormat = pFormatter->GetEntry( nFound )) != 0) &&
    1710           0 :             pFormat->GetNewCurrencySymbol( aSymbol, aExtension ) )
    1711             :     {   // eventually match with format locale
    1712             :         const NfCurrencyEntry* pTmpCurrencyEntry =
    1713             :             SvNumberFormatter::GetCurrencyEntry( bTestBanking, aSymbol, aExtension,
    1714           0 :             pFormat->GetLanguage() );
    1715           0 :         if ( pTmpCurrencyEntry )
    1716             :         {
    1717           0 :             for(sal_uInt16 i=0;i<nCount;i++)
    1718             :             {
    1719           0 :                 if(pTmpCurrencyEntry==&rCurrencyTable[i])
    1720             :                 {
    1721           0 :                     nPos=i;
    1722           0 :                     break;
    1723             :                 }
    1724             :             }
    1725             :         }
    1726             :     }
    1727             :     else
    1728             :     {   // search symbol string only
    1729           0 :         for(sal_uInt16 i=0;i<nCount;i++)
    1730             :         {
    1731           0 :             const NfCurrencyEntry* pTmpCurrencyEntry=&rCurrencyTable[i];
    1732           0 :             OUString _aSymbol = pTmpCurrencyEntry->BuildSymbolString(false);
    1733           0 :             OUString aBankSymbol = pTmpCurrencyEntry->BuildSymbolString(true);
    1734             : 
    1735           0 :             if(rFmtString.Search(_aSymbol)!=STRING_NOTFOUND)
    1736             :             {
    1737           0 :                 bTestBanking=false;
    1738           0 :                 nPos=i;
    1739           0 :                 break;
    1740             :             }
    1741           0 :             else if(rFmtString.Search(aBankSymbol)!=STRING_NOTFOUND)
    1742             :             {
    1743           0 :                 bTestBanking=true;
    1744           0 :                 nPos=i;
    1745           0 :                 break;
    1746             :             }
    1747           0 :         }
    1748             :     }
    1749             : 
    1750           0 :     return nPos;
    1751             : }
    1752             : 
    1753           0 : sal_uInt16 SvxNumberFormatShell::FindCurrencyFormat(const NfCurrencyEntry* pTmpCurrencyEntry,bool bTmpBanking)
    1754             : {
    1755           0 :     const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
    1756           0 :     sal_uInt16 nCount=rCurrencyTable.size();
    1757             : 
    1758           0 :     sal_uInt16 nPos=0;
    1759           0 :     for(sal_uInt16 i=0;i<nCount;i++)
    1760             :     {
    1761           0 :         if(pTmpCurrencyEntry==&rCurrencyTable[i])
    1762             :         {
    1763           0 :             nPos=i;
    1764           0 :             break;
    1765             :         }
    1766             :     }
    1767             : 
    1768           0 :     sal_uInt16 nStart=0;
    1769           0 :     if(bTmpBanking && aCurCurrencyList.size()>nPos)
    1770             :     {
    1771           0 :         nStart=nCount;
    1772             :     }
    1773           0 :     for(sal_uInt16 j=nStart;j<aCurCurrencyList.size();j++)
    1774             :     {
    1775           0 :         if(aCurCurrencyList[j]==nPos) return j;
    1776             :     }
    1777           0 :     return (sal_uInt16) -1;
    1778             : }
    1779             : 
    1780           0 : bool SvxNumberFormatShell::IsInTable(sal_uInt16 const nPos,
    1781             :         bool const bTmpBanking, OUString const& rFmtString)
    1782             : {
    1783           0 :     bool bFlag=false;
    1784             : 
    1785           0 :     if(nPos!=(sal_uInt16)-1)
    1786             :     {
    1787           0 :         const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
    1788           0 :         sal_uInt16 nCount=rCurrencyTable.size();
    1789             : 
    1790           0 :         if(nPos<nCount)
    1791             :         {
    1792           0 :             NfWSStringsDtor aWSStringsDtor;
    1793             : 
    1794           0 :             const NfCurrencyEntry* pTmpCurrencyEntry=&rCurrencyTable[nPos];
    1795             : 
    1796           0 :             if ( pTmpCurrencyEntry!=NULL)
    1797             :             {
    1798             :                 pFormatter->GetCurrencyFormatStrings( aWSStringsDtor,
    1799           0 :                                 *pTmpCurrencyEntry, bTmpBanking );
    1800             : 
    1801           0 :                 for(sal_uInt16 i=0;i<aWSStringsDtor.size();i++)
    1802             :                 {
    1803           0 :                     if (aWSStringsDtor[i] == rFmtString)
    1804             :                     {
    1805           0 :                         bFlag=true;
    1806           0 :                         break;
    1807             :                     }
    1808             :                 }
    1809           0 :             }
    1810             :         }
    1811             :     }
    1812             : 
    1813           0 :     return bFlag;
    1814         216 : }
    1815             : 
    1816             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10