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