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