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