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