1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: numfmtsh.cxx,v $
10 * $Revision: 1.20.128.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
35 #include <tools/color.hxx>
37 #define _SVX_NUMFMTSH_CXX
38 #define _SVSTDARR_STRINGSDTOR
39 #include <tools/debug.hxx>
40 #include <i18npool/mslangid.hxx>
42 #define _ZFORLIST_DECLARE_TABLE
43 #include <svtools/zforlist.hxx>
44 #include <svtools/zformat.hxx>
46 #include <svtools/langtab.hxx>
47 #include <vcl/svapp.hxx>
48 #include <comphelper/processfactory.hxx>
50 #include <svx/numfmtsh.hxx>
51 // class SvxNumberFormatShell --------------------------------------------
53 const double SvxNumberFormatShell::DEFAULT_NUMVALUE
= 1234.56789;
55 SV_IMPL_PTRARR( NfShCurrencyEntries
, NfCurrencyEntry
* );
57 // -----------------------------------------------------------------------
61 SvxNumberFormatShell
* SvxNumberFormatShell::Create( SvNumberFormatter
* pNumFormatter
,
62 sal_uInt32 nFormatKey
,
63 SvxNumberValueType eNumValType
,
64 const String
& rNumStr
)
66 return new SvxNumberFormatShell(pNumFormatter
,nFormatKey
,
67 eNumValType
,rNumStr
);
70 SvxNumberFormatShell
* SvxNumberFormatShell::Create( SvNumberFormatter
* pNumFormatter
,
71 sal_uInt32 nFormatKey
,
72 SvxNumberValueType eNumValType
,
74 const String
* pNumStr
)
76 return new SvxNumberFormatShell(pNumFormatter
,nFormatKey
,
77 eNumValType
,nNumVal
,pNumStr
);
80 // -----------------------------------------------------------------------
83 pFormatter ( pNumFormatter ), \
84 pCurFmtTable ( NULL ), \
85 eValType ( eNumValType ), \
86 bUndoAddList ( sal_True ), \
87 nInitFormatKey ( nFormatKey ), \
88 nCurFormatKey ( nFormatKey ), \
89 pCurCurrencyEntry(NULL), \
90 bBankingSymbol (sal_False), \
91 nCurCurrencyEntryPos((sal_uInt16) SELPOS_NONE)
93 // -----------------------------------------------------------------------
95 SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter
* pNumFormatter
,
96 sal_uInt32 nFormatKey
,
97 SvxNumberValueType eNumValType
,
98 const String
& rNumStr
)
101 nValNum
= DEFAULT_NUMVALUE
;
105 case SVX_VALUE_TYPE_STRING
:
108 case SVX_VALUE_TYPE_NUMBER
:
109 case SVX_VALUE_TYPE_UNDEFINED
:
115 // -----------------------------------------------------------------------
117 SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter
* pNumFormatter
,
118 sal_uInt32 nFormatKey
,
119 SvxNumberValueType eNumValType
,
121 const String
* pNumStr
)
124 // #50441# When used in Writer, the SvxNumberInfoItem contains the
125 // original string in addition to the value
132 case SVX_VALUE_TYPE_NUMBER
:
135 case SVX_VALUE_TYPE_STRING
:
136 case SVX_VALUE_TYPE_UNDEFINED
:
138 nValNum
= DEFAULT_NUMVALUE
;
142 // -----------------------------------------------------------------------
144 SvxNumberFormatShell::~SvxNumberFormatShell()
147 * An dieser Stelle wird abhaengig davon, ob die
148 * hinzugefuegten, benutzerdefinierten als gueltig
149 * erklaert wurden (ValidateNewEntries()), die
150 * Add-Liste wieder aus dem Zahlenformatierer entfernt.
152 * Loeschen von Formaten aus dem Formatierer passiert
153 * aus Undo-Gruenden nur in der aufrufenden Instanz.
158 // Hinzugefuegte Formate sind nicht gueltig:
159 // => wieder entfernen:
161 for ( sal_uInt16 i
= 0; i
< aAddList
.Count(); ++i
)
162 pFormatter
->DeleteEntry( aAddList
[i
] );
165 //--------------------------------
166 // Add-/Remove-Listen leerraeumen:
167 //--------------------------------
168 aAddList
.Remove( 0, aAddList
.Count() );
169 aDelList
.Remove( 0, aAddList
.Count() );
171 if(aCurrencyFormatList
.Count()>0)
172 aCurrencyFormatList
.DeleteAndDestroy(0,aCurrencyFormatList
.Count());
175 // -----------------------------------------------------------------------
177 sal_uInt32
SvxNumberFormatShell::GetUpdateDataCount() const
179 return aDelList
.Count();
182 // -----------------------------------------------------------------------
184 void SvxNumberFormatShell::GetUpdateData( sal_uInt32
* pDelArray
, const sal_uInt32 nSize
)
186 const sal_uInt32 nCount
= aDelList
.Count();
188 DBG_ASSERT( pDelArray
&& ( nSize
== nCount
), "Array nicht initialisiert!" );
190 if ( pDelArray
&& ( nSize
== nCount
) )
191 for ( sal_uInt16 i
= 0; i
< aDelList
.Count(); ++i
)
192 *pDelArray
++ = aDelList
[i
];
195 // -----------------------------------------------------------------------
197 void SvxNumberFormatShell::CategoryChanged( sal_uInt16 nCatLbPos
,
199 SvStrings
& rFmtEntries
)
201 short nOldCategory
= nCurCategory
;
202 PosToCategory_Impl( nCatLbPos
, nCurCategory
);
203 pCurFmtTable
= &( pFormatter
->GetEntryTable( nCurCategory
,
206 // reinitialize currency if category newly entered
207 if ( nCurCategory
== NUMBERFORMAT_CURRENCY
&& nOldCategory
!= nCurCategory
)
208 pCurCurrencyEntry
= NULL
;
209 rFmtSelPos
= FillEntryList_Impl( rFmtEntries
);
212 // -----------------------------------------------------------------------
214 void SvxNumberFormatShell::LanguageChanged( LanguageType eLangType
,
216 SvStrings
& rFmtEntries
)
218 eCurLanguage
= eLangType
;
219 pCurFmtTable
= &(pFormatter
->ChangeCL( nCurCategory
,
222 rFmtSelPos
= FillEntryList_Impl( rFmtEntries
);
225 // -----------------------------------------------------------------------
227 void SvxNumberFormatShell::FormatChanged( sal_uInt16 nFmtLbPos
,
229 Color
*& rpFontColor
)
231 //nCurFormatKey = pCurFmtTable->GetKey( pCurFmtTable->GetObject( nFmtLbPos ) );
233 if(nFmtLbPos
<aCurEntryList
.Count())
235 nCurFormatKey
=aCurEntryList
[nFmtLbPos
];
237 if(nCurFormatKey
!=NUMBERFORMAT_ENTRY_NOT_FOUND
)
239 GetPreviewString_Impl( rPreviewStr
, rpFontColor
);
241 else if(nCurCategory
==NUMBERFORMAT_CURRENCY
)
243 if(nFmtLbPos
<aCurrencyFormatList
.Count())
245 //nCurFormatKey=nFmtLbPos;
246 MakePrevStringFromVal(*aCurrencyFormatList
[nFmtLbPos
],
247 rPreviewStr
,rpFontColor
,nValNum
);
252 // -----------------------------------------------------------------------
254 sal_Bool
SvxNumberFormatShell::AddFormat( String
& rFormat
, xub_StrLen
& rErrPos
,
255 sal_uInt16
& rCatLbSelPos
, short& rFmtSelPos
,
256 SvStrings
& rFmtEntries
)
258 sal_Bool bInserted
= sal_False
;
259 sal_uInt32 nAddKey
= pFormatter
->GetEntryKey( rFormat
, eCurLanguage
);
261 if ( nAddKey
!= NUMBERFORMAT_ENTRY_NOT_FOUND
) // bereits vorhanden?
263 if ( IsRemoved_Impl( nAddKey
) )
265 // Key suchen und loeschen
266 sal_Bool bFound
= sal_False
;
269 for ( sal_uInt16 i
= 0; !bFound
&& i
< aDelList
.Count(); ++i
)
271 if ( aDelList
[i
] == nAddKey
)
277 DBG_ASSERT( bFound
, "Key not found" );
278 aDelList
.Remove( nAt
);
279 bInserted
= sal_True
;
283 DBG_ERROR( "Doppeltes Format!" );
288 bInserted
= pFormatter
->PutEntry( rFormat
, rErrPos
,
289 nCurCategory
, nAddKey
,
293 if ( bInserted
) // eingefuegt
295 nCurFormatKey
= nAddKey
;
296 DBG_ASSERT( !IsAdded_Impl( nCurFormatKey
), "Doppeltes Format!" );
297 aAddList
.Insert( nCurFormatKey
, aAddList
.Count() );
299 // aktuelle Tabelle holen
300 pCurFmtTable
= &(pFormatter
->GetEntryTable( nCurCategory
,
303 nCurCategory
=pFormatter
->GetType(nAddKey
); //@@ ???
304 CategoryToPos_Impl( nCurCategory
, rCatLbSelPos
);
305 rFmtSelPos
= FillEntryList_Impl( rFmtEntries
);
307 else if ( rErrPos
!= 0 ) // Syntaxfehler
311 else // Doppelt einfuegen nicht moeglich
313 DBG_ERROR( "Doppeltes Format!" ); // oder doch?
319 // -----------------------------------------------------------------------
321 sal_Bool
SvxNumberFormatShell::RemoveFormat( const String
& rFormat
,
322 sal_uInt16
& rCatLbSelPos
,
324 SvStrings
& rFmtEntries
)
326 sal_uInt32 nDelKey
= pFormatter
->GetEntryKey( rFormat
, eCurLanguage
);
328 DBG_ASSERT( nDelKey
!= NUMBERFORMAT_ENTRY_NOT_FOUND
, "Eintrag nicht gefunden!" );
329 DBG_ASSERT( !IsRemoved_Impl( nDelKey
), "Eintrag bereits geloescht!" );
331 if ( (nDelKey
!= NUMBERFORMAT_ENTRY_NOT_FOUND
) && !IsRemoved_Impl( nDelKey
) )
333 aDelList
.Insert( nDelKey
, aDelList
.Count() );
335 if ( IsAdded_Impl( nDelKey
) )
337 // Key suchen und loeschen
338 sal_Bool bFound
= sal_False
;
341 for ( sal_uInt16 i
= 0; !bFound
&& i
< aAddList
.Count(); ++i
)
343 if ( aAddList
[i
] == nDelKey
)
349 DBG_ASSERT( bFound
, "Key not found" );
350 aAddList
.Remove( nAt
);
353 nCurCategory
=pFormatter
->GetType(nDelKey
); //@@ 01.10.97
354 pCurFmtTable
= &(pFormatter
->GetEntryTable( nCurCategory
,
358 nCurFormatKey
=pFormatter
->GetStandardFormat(nCurCategory
,
361 CategoryToPos_Impl( nCurCategory
, rCatLbSelPos
);
362 rFmtSelPos
= FillEntryList_Impl( rFmtEntries
);
363 //rFmtSelPos = (short) nCurFormatKey; //@@ 01.10.97
368 // -----------------------------------------------------------------------
370 void SvxNumberFormatShell::MakeFormat( String
& rFormat
,
371 sal_Bool bThousand
, sal_Bool bNegRed
,
372 sal_uInt16 nPrecision
, sal_uInt16 nLeadingZeroes
,
373 sal_uInt16 nCurrencyPos
)
375 if(aCurrencyFormatList
.Count()>nCurrencyPos
)
377 xub_StrLen rErrPos
=0;
378 sal_uInt16 rCatLbSelPos
=0;
382 sal_uInt32 nFound
= pFormatter
->TestNewString( *aCurrencyFormatList
[nCurrencyPos
], eCurLanguage
);
384 if ( nFound
== NUMBERFORMAT_ENTRY_NOT_FOUND
)
386 AddFormat( *aCurrencyFormatList
[nCurrencyPos
],rErrPos
,rCatLbSelPos
,
387 rFmtSelPos
,aFmtEList
);
392 pFormatter
->GenerateFormat( rFormat
, nCurFormatKey
,
395 nPrecision
, nLeadingZeroes
);
397 aFmtEList
.DeleteAndDestroy(0,aFmtEList
.Count());
401 pFormatter
->GenerateFormat( rFormat
, nCurFormatKey
,
404 nPrecision
, nLeadingZeroes
);
408 // -----------------------------------------------------------------------
410 void SvxNumberFormatShell::GetOptions( const String
& rFormat
,
413 sal_uInt16
& rPrecision
,
414 sal_uInt16
& rLeadingZeroes
,
415 sal_uInt16
& rCatLbPos
)
418 sal_uInt32 nFmtKey
= pFormatter
->GetEntryKey( rFormat
, eCurLanguage
);
420 if(nFmtKey
!= NUMBERFORMAT_ENTRY_NOT_FOUND
)
422 if ( nFmtKey
!= NUMBERFORMAT_ENTRY_NOT_FOUND
)
424 pFormatter
->GetFormatSpecialInfo( nFmtKey
,
426 rPrecision
, rLeadingZeroes
);
428 CategoryToPos_Impl( pFormatter
->GetType( nFmtKey
), rCatLbPos
);
431 rCatLbPos
= CAT_USERDEFINED
;
435 sal_Bool bTestBanking
=sal_False
;
436 sal_uInt16 nPos
=FindCurrencyTableEntry(rFormat
, bTestBanking
);
438 if(IsInTable(nPos
,bTestBanking
,rFormat
) &&
439 pFormatter
->GetFormatSpecialInfo( rFormat
,rThousand
, rNegRed
,
440 rPrecision
, rLeadingZeroes
,eCurLanguage
)==0)
442 rCatLbPos
= CAT_CURRENCY
;
445 rCatLbPos
= CAT_USERDEFINED
;
450 // -----------------------------------------------------------------------
452 void SvxNumberFormatShell::MakePreviewString( const String
& rFormatStr
,
454 Color
*& rpFontColor
)
458 ULONG nExistingFormat
= pFormatter
->GetEntryKey( rFormatStr
, eCurLanguage
);
459 if ( nExistingFormat
== NUMBERFORMAT_ENTRY_NOT_FOUND
)
461 // real preview - not implemented in NumberFormatter for text formats
463 pFormatter
->GetPreviewString( rFormatStr
, nValNum
, rPreviewStr
,
464 &rpFontColor
, eCurLanguage
);
470 // #50441# if a string was set in addition to the value, use it for text formats
471 BOOL bUseText
= ( eValType
== SVX_VALUE_TYPE_STRING
||
472 ( aValStr
.Len() && ( pFormatter
->GetType(nExistingFormat
) & NUMBERFORMAT_TEXT
) ) );
474 pFormatter
->GetOutputString( aValStr
, nExistingFormat
,
475 rPreviewStr
, &rpFontColor
);
477 pFormatter
->GetOutputString( nValNum
, nExistingFormat
,
478 rPreviewStr
, &rpFontColor
);
482 // -----------------------------------------------------------------------
484 sal_Bool
SvxNumberFormatShell::IsUserDefined( const String
& rFmtString
)
486 sal_uInt32 nFound
= pFormatter
->GetEntryKey( rFmtString
, eCurLanguage
);
488 sal_Bool bFlag
=sal_False
;
489 if ( nFound
!= NUMBERFORMAT_ENTRY_NOT_FOUND
)
491 bFlag
=pFormatter
->IsUserDefined( rFmtString
, eCurLanguage
);
495 const SvNumberformat
* pNumEntry
= pFormatter
->GetEntry(nFound
);
497 if(pNumEntry
!=NULL
&& pNumEntry
->HasNewCurrency())
499 sal_Bool bTestBanking
;
500 sal_uInt16 nPos
=FindCurrencyTableEntry(rFmtString
,bTestBanking
);
501 bFlag
=!IsInTable(nPos
,bTestBanking
,rFmtString
);
508 // -----------------------------------------------------------------------
510 sal_Bool
SvxNumberFormatShell::FindEntry( const String
& rFmtString
, sal_uInt32
* pAt
/* = NULL */ )
512 sal_Bool bRes
=sal_False
;
513 sal_uInt32 nFound
= pFormatter
->TestNewString( rFmtString
, eCurLanguage
);
515 if ( nFound
== NUMBERFORMAT_ENTRY_NOT_FOUND
)
517 sal_Bool bTestBanking
=sal_False
;
518 sal_uInt16 nPos
=FindCurrencyTableEntry(rFmtString
, bTestBanking
);
520 if(IsInTable(nPos
,bTestBanking
,rFmtString
))
522 nFound
=NUMBERFORMAT_ENTRY_NEW_CURRENCY
;
528 bRes
=!IsRemoved_Impl( nFound
);
538 // -----------------------------------------------------------------------
540 void SvxNumberFormatShell::GetInitSettings(
541 sal_uInt16
& nCatLbPos
,
542 LanguageType
& rLangType
,
543 sal_uInt16
& nFmtLbSelPos
,
544 SvStrings
& rFmtEntries
,
546 Color
*& rpPrevColor
)
548 // -------------------------------------------------------------------
549 // Vorbedingung: Zahlenformatierer gefunden
550 DBG_ASSERT( pFormatter
!= NULL
, "Zahlenformatierer nicht gefunden!" );
552 // sal_uInt16 nCount = 0;
553 short nSelPos
= SELPOS_NONE
;
554 // SvNumberFormatTable* pFmtTable = NULL;
556 // Sonderbehandlung fuer undefiniertes Zahlenformat:
557 if ( (eValType
== SVX_VALUE_TYPE_UNDEFINED
) && (nCurFormatKey
== 0) )
558 PosToCategory_Impl( CAT_ALL
, nCurCategory
); // Kategorie = Alle
560 nCurCategory
= NUMBERFORMAT_UNDEFINED
; // Kategorie = Undefiniert
562 pCurFmtTable
= &(pFormatter
->GetFirstEntryTable( nCurCategory
,
568 CategoryToPos_Impl( nCurCategory
, nCatLbPos
);
569 rLangType
= eCurLanguage
;
571 nSelPos
= FillEntryList_Impl( rFmtEntries
);
573 DBG_ASSERT( nSelPos
!= SELPOS_NONE
, "Leere Formatliste!" );
575 nFmtLbSelPos
= (nSelPos
!= SELPOS_NONE
) ? (sal_uInt16
)nSelPos
: 0;
576 GetPreviewString_Impl( rPrevString
, rpPrevColor
);
579 // -----------------------------------------------------------------------
581 short SvxNumberFormatShell::FillEntryList_Impl( SvStrings
& rList
)
583 /* Erstellen einer aktuellen Liste von Format-Eintraegen.
584 * Rueckgabewert ist die Listenposition des aktuellen Formates.
585 * Ist die Liste leer oder gibt es kein aktuelles Format,
586 * so wird SELPOS_NONE geliefert.
589 aCurEntryList
.Remove(nSelPos
,aCurEntryList
.Count());
590 sal_uInt16 nPrivCat
= CAT_CURRENCY
;
593 if(nCurCategory
==NUMBERFORMAT_ALL
)
595 FillEListWithStd_Impl(rList
,CAT_NUMBER
,nSelPos
);
596 FillEListWithStd_Impl(rList
,CAT_PERCENT
,nSelPos
);
597 FillEListWithStd_Impl(rList
,CAT_CURRENCY
,nSelPos
);
598 FillEListWithStd_Impl(rList
,CAT_DATE
,nSelPos
);
599 FillEListWithStd_Impl(rList
,CAT_TIME
,nSelPos
);
600 FillEListWithStd_Impl(rList
,CAT_SCIENTIFIC
,nSelPos
);
601 FillEListWithStd_Impl(rList
,CAT_FRACTION
,nSelPos
);
602 FillEListWithStd_Impl(rList
,CAT_BOOLEAN
,nSelPos
);
603 FillEListWithStd_Impl(rList
,CAT_TEXT
,nSelPos
);
607 CategoryToPos_Impl(nCurCategory
, nPrivCat
);
608 FillEListWithStd_Impl(rList
,nPrivCat
,nSelPos
);
611 if( nPrivCat
!=CAT_CURRENCY
)
612 nSelPos
=FillEListWithUsD_Impl(rList
,nPrivCat
,nSelPos
);
617 void SvxNumberFormatShell::FillEListWithStd_Impl( SvStrings
& rList
,sal_uInt16 nPrivCat
,short &nSelPos
)
619 /* Erstellen einer aktuellen Liste von Format-Eintraegen.
620 * Rueckgabewert ist die Listenposition des aktuellen Formates.
621 * Ist die Liste leer oder gibt es kein aktuelles Format,
622 * so wird SELPOS_NONE geliefert.
624 DBG_ASSERT( pCurFmtTable
!= NULL
, "Unbekanntes Zahlenformat!" );
626 if(aCurrencyFormatList
.Count()>0)
627 aCurrencyFormatList
.DeleteAndDestroy(0,aCurrencyFormatList
.Count());
629 if(nPrivCat
==CAT_CURRENCY
)
631 nSelPos
=FillEListWithCurrency_Impl(rList
,nSelPos
);
635 NfIndexTableOffset eOffsetStart
;
636 NfIndexTableOffset eOffsetEnd
;
640 case CAT_NUMBER
:eOffsetStart
=NF_NUMBER_START
;
641 eOffsetEnd
=NF_NUMBER_END
;
643 case CAT_PERCENT
:eOffsetStart
=NF_PERCENT_START
;
644 eOffsetEnd
=NF_PERCENT_END
;
646 case CAT_CURRENCY
:eOffsetStart
=NF_CURRENCY_START
;
647 eOffsetEnd
=NF_CURRENCY_END
;
649 case CAT_DATE
:eOffsetStart
=NF_DATE_START
;
650 eOffsetEnd
=NF_DATE_END
;
652 case CAT_TIME
:eOffsetStart
=NF_TIME_START
;
653 eOffsetEnd
=NF_TIME_END
;
655 case CAT_SCIENTIFIC
:eOffsetStart
=NF_SCIENTIFIC_START
;
656 eOffsetEnd
=NF_SCIENTIFIC_END
;
658 case CAT_FRACTION
:eOffsetStart
=NF_FRACTION_START
;
659 eOffsetEnd
=NF_FRACTION_END
;
661 case CAT_BOOLEAN
:eOffsetStart
=NF_BOOLEAN
;
662 eOffsetEnd
=NF_BOOLEAN
;
664 case CAT_TEXT
:eOffsetStart
=NF_TEXT
;
670 nSelPos
=FillEListWithFormats_Impl(rList
,nSelPos
,eOffsetStart
,eOffsetEnd
);
672 if(nPrivCat
==CAT_DATE
|| nPrivCat
==CAT_TIME
)
674 nSelPos
=FillEListWithDateTime_Impl(rList
,nSelPos
);
675 //if(nSelPos!=SELPOS_NONE) nSelPos=nTmpPos;
680 short SvxNumberFormatShell::FillEListWithFormats_Impl( SvStrings
& rList
,short nSelPos
,
681 NfIndexTableOffset eOffsetStart
,
682 NfIndexTableOffset eOffsetEnd
)
684 /* Erstellen einer aktuellen Liste von Format-Eintraegen.
685 * Rueckgabewert ist die Listenposition des aktuellen Formates.
686 * Ist die Liste leer oder gibt es kein aktuelles Format,
687 * so wird SELPOS_NONE geliefert.
691 DBG_ASSERT( pCurFmtTable
!= NULL
, "Unbekanntes Zahlenformat!" );
693 const SvNumberformat
* pNumEntry
= pCurFmtTable
->First();
694 // sal_uInt16 nCount = 0;
697 String aNewFormNInfo
;
701 short nMyCat
= SELPOS_NONE
;
706 for(nIndex
=eOffsetStart
;nIndex
<=eOffsetEnd
;nIndex
++)
708 nNFEntry
=pFormatter
->GetFormatIndex((NfIndexTableOffset
)nIndex
,eCurLanguage
);
710 pNumEntry
= pFormatter
->GetEntry(nNFEntry
);
712 if(pNumEntry
==NULL
) continue;
714 nMyCat
=pNumEntry
->GetType() & ~NUMBERFORMAT_DEFINED
;
715 aStrComment
=pNumEntry
->GetComment();
716 CategoryToPos_Impl(nMyCat
,nMyType
);
717 aNewFormNInfo
= pNumEntry
->GetFormatstring();
719 const StringPtr pStr
= new String(aNewFormNInfo
);
721 if ( nNFEntry
== nCurFormatKey
)
723 nSelPos
= ( !IsRemoved_Impl( nNFEntry
) ) ? aCurEntryList
.Count() : SELPOS_NONE
;
726 rList
.Insert( pStr
,rList
.Count());
727 aCurEntryList
.Insert( nNFEntry
, aCurEntryList
.Count() );
733 short SvxNumberFormatShell::FillEListWithDateTime_Impl( SvStrings
& rList
,short nSelPos
)
737 DBG_ASSERT( pCurFmtTable
!= NULL
, "Unbekanntes Zahlenformat!" );
739 const SvNumberformat
* pNumEntry
= pCurFmtTable
->First();
740 // sal_uInt16 nCount = 0;
743 String aNewFormNInfo
;
747 short nMyCat
= SELPOS_NONE
;
752 for(nIndex
=NF_DATETIME_START
;nIndex
<=NF_DATETIME_END
;nIndex
++)
754 nNFEntry
=pFormatter
->GetFormatIndex((NfIndexTableOffset
)nIndex
,eCurLanguage
);
756 pNumEntry
= pFormatter
->GetEntry(nNFEntry
);
759 nMyCat
=pNumEntry
->GetType() & ~NUMBERFORMAT_DEFINED
;
760 aStrComment
=pNumEntry
->GetComment();
761 CategoryToPos_Impl(nMyCat
,nMyType
);
762 aNewFormNInfo
= pNumEntry
->GetFormatstring();
764 const StringPtr pStr
= new String(aNewFormNInfo
);
766 if ( nNFEntry
== nCurFormatKey
)
768 nSelPos
= ( !IsRemoved_Impl( nNFEntry
) ) ? aCurEntryList
.Count() : SELPOS_NONE
;
771 rList
.Insert( pStr
,rList
.Count());
772 aCurEntryList
.Insert( nNFEntry
, aCurEntryList
.Count() );
779 short SvxNumberFormatShell::FillEListWithCurrency_Impl( SvStrings
& rList
,short nSelPos
)
781 /* Erstellen einer aktuellen Liste von Format-Eintraegen.
782 * Rueckgabewert ist die Listenposition des aktuellen Formates.
783 * Ist die Liste leer oder gibt es kein aktuelles Format,
784 * so wird SELPOS_NONE geliefert.
786 DBG_ASSERT( pCurFmtTable
!= NULL
, "Unbekanntes Zahlenformat!" );
788 const NfCurrencyEntry
* pTmpCurrencyEntry
;
789 sal_Bool bTmpBanking
;
792 sal_Bool bFlag
=pFormatter
->GetNewCurrencySymbolString(nCurFormatKey
,rSymbol
,
793 &pTmpCurrencyEntry
,&bTmpBanking
);
795 if((!bFlag
&& pCurCurrencyEntry
==NULL
) ||
796 (bFlag
&& pTmpCurrencyEntry
==NULL
&& !rSymbol
.Len()) ||
797 nCurCategory
==NUMBERFORMAT_ALL
)
799 if ( nCurCategory
== NUMBERFORMAT_ALL
)
800 FillEListWithUserCurrencys(rList
,nSelPos
);
801 nSelPos
=FillEListWithSysCurrencys(rList
,nSelPos
);
805 nSelPos
=FillEListWithUserCurrencys(rList
,nSelPos
);
812 short SvxNumberFormatShell::FillEListWithSysCurrencys( SvStrings
& rList
,short nSelPos
)
814 /* Erstellen einer aktuellen Liste von Format-Eintraegen.
815 * Rueckgabewert ist die Listenposition des aktuellen Formates.
816 * Ist die Liste leer oder gibt es kein aktuelles Format,
817 * so wird SELPOS_NONE geliefert.
821 DBG_ASSERT( pCurFmtTable
!= NULL
, "Unbekanntes Zahlenformat!" );
823 const SvNumberformat
* pNumEntry
= pCurFmtTable
->First();
824 sal_uInt16 nCount
= 0;
827 String aNewFormNInfo
;
831 nCurCurrencyEntryPos
=0;
833 short nMyCat
= SELPOS_NONE
;
836 NfIndexTableOffset eOffsetStart
=NF_CURRENCY_START
;
837 NfIndexTableOffset eOffsetEnd
=NF_CURRENCY_END
;;
840 for(nIndex
=eOffsetStart
;nIndex
<=eOffsetEnd
;nIndex
++)
842 nNFEntry
=pFormatter
->GetFormatIndex((NfIndexTableOffset
)nIndex
,eCurLanguage
);
844 pNumEntry
= pFormatter
->GetEntry(nNFEntry
);
846 if(pNumEntry
==NULL
) continue;
848 nMyCat
=pNumEntry
->GetType() & ~NUMBERFORMAT_DEFINED
;
849 aStrComment
=pNumEntry
->GetComment();
850 CategoryToPos_Impl(nMyCat
,nMyType
);
851 aNewFormNInfo
= pNumEntry
->GetFormatstring();
853 const StringPtr pStr
= new String(aNewFormNInfo
);
855 if ( nNFEntry
== nCurFormatKey
)
857 nSelPos
= ( !IsRemoved_Impl( nNFEntry
) ) ? aCurEntryList
.Count() : SELPOS_NONE
;
860 rList
.Insert( pStr
,rList
.Count());
861 aCurEntryList
.Insert( nNFEntry
, aCurEntryList
.Count() );
864 if(nCurCategory
!=NUMBERFORMAT_ALL
)
866 pNumEntry
= pCurFmtTable
->First();
870 sal_uInt32 nKey
= pCurFmtTable
->GetCurKey();
874 if ( !IsRemoved_Impl( nKey
))
876 sal_Bool bUserNewCurrency
=sal_False
;
877 if(pNumEntry
->HasNewCurrency())
879 const NfCurrencyEntry
* pTmpCurrencyEntry
;
880 sal_Bool bTmpBanking
;
883 pFormatter
->GetNewCurrencySymbolString(nKey
,rSymbol
,
884 &pTmpCurrencyEntry
,&bTmpBanking
);
886 bUserNewCurrency
=(pTmpCurrencyEntry
!=NULL
);
889 if(!bUserNewCurrency
&&(pNumEntry
->GetType() & NUMBERFORMAT_DEFINED
))
891 nMyCat
=pNumEntry
->GetType() & ~NUMBERFORMAT_DEFINED
;
892 aStrComment
=pNumEntry
->GetComment();
893 CategoryToPos_Impl(nMyCat
,nMyType
);
894 aNewFormNInfo
= pNumEntry
->GetFormatstring();
896 const StringPtr pStr
= new String(aNewFormNInfo
);
898 if ( nKey
== nCurFormatKey
) nSelPos
=aCurEntryList
.Count();
899 rList
.Insert( pStr
,rList
.Count());
900 aCurEntryList
.Insert( nKey
, aCurEntryList
.Count() );
903 pNumEntry
= pCurFmtTable
->Next();
909 short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings
& rList
,short nSelPos
)
911 /* Erstellen einer aktuellen Liste von Format-Eintraegen.
912 * Rueckgabewert ist die Listenposition des aktuellen Formates.
913 * Ist die Liste leer oder gibt es kein aktuelles Format,
914 * so wird SELPOS_NONE geliefert.
918 DBG_ASSERT( pCurFmtTable
!= NULL
, "Unbekanntes Zahlenformat!" );
920 sal_uInt16 nCount
= 0;
922 String aNewFormNInfo
;
925 short nMyCat
= SELPOS_NONE
;
928 const NfCurrencyEntry
* pTmpCurrencyEntry
;
929 sal_Bool bTmpBanking
, bAdaptSelPos
;
931 XubString rBankSymbol
;
936 /*sal_Bool bFlag=*/pFormatter
->GetNewCurrencySymbolString(nCurFormatKey
,rSymbol
,
937 &pTmpCurrencyEntry
,&bTmpBanking
);
939 XubString rShortSymbol
;
941 if(pCurCurrencyEntry
==NULL
)
943 // #110398# If no currency format was previously selected (we're not
944 // about to add another currency), try to select the initial currency
945 // format (nCurFormatKey) that was set in FormatChanged() after
946 // matching the format string entered in the dialog.
947 bAdaptSelPos
= sal_True
;
948 pCurCurrencyEntry
=(NfCurrencyEntry
*)pTmpCurrencyEntry
;
949 bBankingSymbol
=bTmpBanking
;
950 nCurCurrencyEntryPos
=FindCurrencyFormat(pTmpCurrencyEntry
,bTmpBanking
);
954 if (pTmpCurrencyEntry
== pCurCurrencyEntry
)
955 bAdaptSelPos
= sal_True
;
958 bAdaptSelPos
= sal_False
;
959 pTmpCurrencyEntry
= pCurCurrencyEntry
;
961 bTmpBanking
=bBankingSymbol
;
964 if(pTmpCurrencyEntry
!=NULL
)
966 pTmpCurrencyEntry
->BuildSymbolString(rSymbol
,sal_False
);
967 pTmpCurrencyEntry
->BuildSymbolString(rBankSymbol
,sal_True
);
968 pTmpCurrencyEntry
->BuildSymbolString(rShortSymbol
,bTmpBanking
,sal_True
);
971 const SvNumberformat
* pNumEntry
= pCurFmtTable
->First();
975 sal_uInt32 nKey
= pCurFmtTable
->GetCurKey();
979 if ( !IsRemoved_Impl( nKey
) )
981 if( pNumEntry
->GetType() & NUMBERFORMAT_DEFINED
||
982 pNumEntry
->IsAdditionalStandardDefined() )
984 nMyCat
=pNumEntry
->GetType() & ~NUMBERFORMAT_DEFINED
;
985 aStrComment
=pNumEntry
->GetComment();
986 CategoryToPos_Impl(nMyCat
,nMyType
);
987 aNewFormNInfo
= pNumEntry
->GetFormatstring();
989 sal_Bool bInsFlag
=sal_False
;
990 if ( pNumEntry
->HasNewCurrency() )
991 bInsFlag
= sal_True
; // merge locale formats into currency selection
992 else if( (!bTmpBanking
&& aNewFormNInfo
.Search(rSymbol
)!=STRING_NOTFOUND
) ||
993 (bTmpBanking
&& aNewFormNInfo
.Search(rBankSymbol
)!=STRING_NOTFOUND
) )
997 else if(aNewFormNInfo
.Search(rShortSymbol
)!=STRING_NOTFOUND
)
999 XubString rTstSymbol
;
1000 const NfCurrencyEntry
* pTstCurrencyEntry
;
1001 sal_Bool bTstBanking
;
1003 /*sal_Bool bTstFlag=*/pFormatter
->GetNewCurrencySymbolString(nKey
,rTstSymbol
,
1004 &pTstCurrencyEntry
,&bTstBanking
);
1006 if(pTmpCurrencyEntry
==pTstCurrencyEntry
&& bTstBanking
==bTmpBanking
)
1015 const StringPtr pStr
= new String(aNewFormNInfo
);
1017 aList
.Insert( pStr
,aList
.Count());
1018 aKeyList
.Insert( nKey
, aKeyList
.Count() );
1022 pNumEntry
= pCurFmtTable
->Next();
1025 NfWSStringsDtor aWSStringsDtor
;
1026 sal_uInt16 nDefault
;
1027 if ( pTmpCurrencyEntry
&& nCurCategory
!= NUMBERFORMAT_ALL
)
1029 nDefault
= pFormatter
->GetCurrencyFormatStrings(
1030 aWSStringsDtor
, *pTmpCurrencyEntry
, bTmpBanking
);
1032 pFormatter
->GetCurrencyFormatStrings(
1033 aWSStringsDtor
, *pTmpCurrencyEntry
, TRUE
);
1037 if ( !bTmpBanking
&& nCurCategory
!= NUMBERFORMAT_ALL
)
1038 { // append formats for all currencies defined in the current I18N locale
1039 const NfCurrencyTable
& rCurrencyTable
= SvNumberFormatter::GetTheCurrencyTable();
1040 sal_uInt16 nCurrCount
= rCurrencyTable
.Count();
1041 LanguageType eLang
= MsLangId::getRealLanguage( eCurLanguage
);
1042 for ( sal_uInt16 i
=0; i
< nCurrCount
; ++i
)
1044 const NfCurrencyEntry
* pCurr
= rCurrencyTable
[i
];
1045 if ( pCurr
->GetLanguage() == eLang
&& pTmpCurrencyEntry
!= pCurr
)
1047 pFormatter
->GetCurrencyFormatStrings( aWSStringsDtor
, *pCurr
, FALSE
);
1048 pFormatter
->GetCurrencyFormatStrings( aWSStringsDtor
, *pCurr
, TRUE
);
1054 sal_uInt16 nOldListCount
= rList
.Count();
1055 for( i
=0, nPos
=nOldListCount
; i
<aWSStringsDtor
.Count(); i
++)
1057 sal_Bool bFlag
=sal_True
;
1058 String
aInsStr(*aWSStringsDtor
[i
]);
1060 for(j
=0;j
<aList
.Count();j
++)
1062 const StringPtr pTestStr
=aList
[j
];
1064 if(*pTestStr
==aInsStr
)
1072 rList
.Insert(new String(aInsStr
),nPos
);
1073 aCurEntryList
.Insert( NUMBERFORMAT_ENTRY_NOT_FOUND
, nPos
++);
1077 rList
.Insert(aList
[j
],nPos
);
1079 aCurEntryList
.Insert( aKeyList
[j
],nPos
++);
1084 for(i
=0;i
<aKeyList
.Count();i
++)
1086 if(aKeyList
[i
]!=NUMBERFORMAT_ENTRY_NOT_FOUND
)
1088 rList
.Insert(aList
[i
],rList
.Count());
1089 aCurEntryList
.Insert( aKeyList
[i
],aCurEntryList
.Count());
1093 for(i
=nOldListCount
;i
<rList
.Count();i
++)
1095 aCurrencyFormatList
.Insert(new String(*rList
[i
]),aCurrencyFormatList
.Count());
1097 if ( nSelPos
== SELPOS_NONE
&& bAdaptSelPos
&& aCurEntryList
[i
] == nCurFormatKey
)
1101 if ( nSelPos
== SELPOS_NONE
&& nCurCategory
!= NUMBERFORMAT_ALL
)
1108 short SvxNumberFormatShell::FillEListWithUsD_Impl( SvStrings
& rList
, sal_uInt16 nPrivCat
, short nSelPos
)
1110 /* Erstellen einer aktuellen Liste von Format-Eintraegen.
1111 * Rueckgabewert ist die Listenposition des aktuellen Formates.
1112 * Ist die Liste leer oder gibt es kein aktuelles Format,
1113 * so wird SELPOS_NONE geliefert.
1117 DBG_ASSERT( pCurFmtTable
!= NULL
, "Unbekanntes Zahlenformat!" );
1119 const SvNumberformat
* pNumEntry
= pCurFmtTable
->First();
1120 sal_uInt16 nCount
= 0;
1122 String aNewFormNInfo
;
1124 String a2PrevString
;
1126 short nMyCat
= SELPOS_NONE
;
1128 sal_Bool bAdditional
= (nPrivCat
!= CAT_USERDEFINED
&&
1129 nCurCategory
!= NUMBERFORMAT_ALL
);
1133 sal_uInt32 nKey
= pCurFmtTable
->GetCurKey();
1137 if ( !IsRemoved_Impl( nKey
) )
1139 if( (pNumEntry
->GetType() & NUMBERFORMAT_DEFINED
) ||
1140 (bAdditional
&& pNumEntry
->IsAdditionalStandardDefined()) )
1142 nMyCat
=pNumEntry
->GetType() & ~NUMBERFORMAT_DEFINED
;
1143 aStrComment
=pNumEntry
->GetComment();
1144 CategoryToPos_Impl(nMyCat
,nMyType
);
1145 aNewFormNInfo
= pNumEntry
->GetFormatstring();
1147 sal_Bool bFlag
=sal_True
;
1148 if(pNumEntry
->HasNewCurrency())
1150 sal_Bool bTestBanking
;
1151 sal_uInt16 nPos
=FindCurrencyTableEntry(aNewFormNInfo
,bTestBanking
);
1152 bFlag
=!IsInTable(nPos
,bTestBanking
,aNewFormNInfo
);
1156 const StringPtr pStr
= new String(aNewFormNInfo
);
1158 if ( nKey
== nCurFormatKey
) nSelPos
=aCurEntryList
.Count();
1159 rList
.Insert( pStr
,rList
.Count());
1160 aCurEntryList
.Insert( nKey
, aCurEntryList
.Count() );
1164 pNumEntry
= pCurFmtTable
->Next();
1170 // -----------------------------------------------------------------------
1172 void SvxNumberFormatShell::GetPreviewString_Impl( String
& rString
, Color
*& rpColor
)
1176 // #50441# if a string was set in addition to the value, use it for text formats
1177 BOOL bUseText
= ( eValType
== SVX_VALUE_TYPE_STRING
||
1178 ( aValStr
.Len() && ( pFormatter
->GetType(nCurFormatKey
) & NUMBERFORMAT_TEXT
) ) );
1181 pFormatter
->GetOutputString( aValStr
, nCurFormatKey
, rString
, &rpColor
);
1183 pFormatter
->GetOutputString( nValNum
, nCurFormatKey
, rString
, &rpColor
);
1186 // -----------------------------------------------------------------------
1188 sal_Bool
SvxNumberFormatShell::IsRemoved_Impl( sal_uInt32 nKey
)
1190 sal_Bool bFound
= sal_False
;
1191 for ( sal_uInt16 i
= 0; !bFound
&& i
< aDelList
.Count(); ++i
)
1192 if ( aDelList
[i
] == nKey
)
1197 // -----------------------------------------------------------------------
1199 sal_Bool
SvxNumberFormatShell::IsAdded_Impl( sal_uInt32 nKey
)
1201 sal_Bool bFound
= sal_False
;
1202 for ( sal_uInt16 i
= 0; !bFound
&& i
< aAddList
.Count(); ++i
)
1203 if ( aAddList
[i
] == nKey
)
1208 // -----------------------------------------------------------------------
1209 // Konvertierungs-Routinen:
1210 // ------------------------
1212 void SvxNumberFormatShell::PosToCategory_Impl( sal_uInt16 nPos
, short& rCategory
)
1214 // Kategorie ::com::sun::star::form-Positionen abbilden (->Resource)
1217 case CAT_USERDEFINED
: rCategory
= NUMBERFORMAT_DEFINED
; break;
1218 case CAT_NUMBER
: rCategory
= NUMBERFORMAT_NUMBER
; break;
1219 case CAT_PERCENT
: rCategory
= NUMBERFORMAT_PERCENT
; break;
1220 case CAT_CURRENCY
: rCategory
= NUMBERFORMAT_CURRENCY
; break;
1221 case CAT_DATE
: rCategory
= NUMBERFORMAT_DATE
; break;
1222 case CAT_TIME
: rCategory
= NUMBERFORMAT_TIME
; break;
1223 case CAT_SCIENTIFIC
: rCategory
= NUMBERFORMAT_SCIENTIFIC
; break;
1224 case CAT_FRACTION
: rCategory
= NUMBERFORMAT_FRACTION
; break;
1225 case CAT_BOOLEAN
: rCategory
= NUMBERFORMAT_LOGICAL
; break;
1226 case CAT_TEXT
: rCategory
= NUMBERFORMAT_TEXT
; break;
1228 default: rCategory
= NUMBERFORMAT_ALL
; break;
1232 // -----------------------------------------------------------------------
1234 void SvxNumberFormatShell::CategoryToPos_Impl( short nCategory
, sal_uInt16
& rPos
)
1236 // Kategorie auf ::com::sun::star::form-Positionen abbilden (->Resource)
1237 switch ( nCategory
)
1239 case NUMBERFORMAT_DEFINED
: rPos
= CAT_USERDEFINED
; break;
1240 case NUMBERFORMAT_NUMBER
: rPos
= CAT_NUMBER
; break;
1241 case NUMBERFORMAT_PERCENT
: rPos
= CAT_PERCENT
; break;
1242 case NUMBERFORMAT_CURRENCY
: rPos
= CAT_CURRENCY
; break;
1243 case NUMBERFORMAT_DATETIME
:
1244 case NUMBERFORMAT_DATE
: rPos
= CAT_DATE
; break;
1245 case NUMBERFORMAT_TIME
: rPos
= CAT_TIME
; break;
1246 case NUMBERFORMAT_SCIENTIFIC
: rPos
= CAT_SCIENTIFIC
; break;
1247 case NUMBERFORMAT_FRACTION
: rPos
= CAT_FRACTION
; break;
1248 case NUMBERFORMAT_LOGICAL
: rPos
= CAT_BOOLEAN
; break;
1249 case NUMBERFORMAT_TEXT
: rPos
= CAT_TEXT
; break;
1250 case NUMBERFORMAT_ALL
:
1251 default: rPos
= CAT_ALL
;
1256 /*************************************************************************
1257 #* Member: MakePrevStringFromVal Datum:19.09.97
1258 #*------------------------------------------------------------------------
1260 #* Klasse: SvxNumberFormatShell
1262 #* Funktion: Formatiert die Zahl nValue abhaengig von rFormatStr
1263 #* und speichert das Ergebnis in rPreviewStr.
1265 #* Input: FormatString, Farbe, zu formatierende Zahl
1267 #* Output: Ausgabestring rPreviewStr
1269 #************************************************************************/
1271 void SvxNumberFormatShell::MakePrevStringFromVal(
1272 const String
& rFormatStr
,
1273 String
& rPreviewStr
,
1274 Color
*& rpFontColor
,
1278 pFormatter
->GetPreviewString( rFormatStr
, nValue
, rPreviewStr
, &rpFontColor
, eCurLanguage
);
1281 /*************************************************************************
1282 #* Member: GetComment4Entry Datum:30.10.97
1283 #*------------------------------------------------------------------------
1285 #* Klasse: SvxNumberFormatShell
1287 #* Funktion: Liefert den Kommentar fuer einen gegebenen
1290 #* Input: Nummer des Eintrags
1292 #* Output: Kommentar-String
1294 #************************************************************************/
1296 void SvxNumberFormatShell::SetComment4Entry(short nEntry
,String aEntStr
)
1298 SvNumberformat
*pNumEntry
;
1299 if(nEntry
<0) return;
1300 sal_uInt32 nMyNfEntry
=aCurEntryList
[nEntry
];
1301 pNumEntry
= (SvNumberformat
*)pFormatter
->GetEntry(nMyNfEntry
);
1302 if(pNumEntry
!=NULL
) pNumEntry
->SetComment(aEntStr
);
1305 /*************************************************************************
1306 #* Member: GetComment4Entry Datum:30.10.97
1307 #*------------------------------------------------------------------------
1309 #* Klasse: SvxNumberFormatShell
1311 #* Funktion: Liefert den Kommentar fuer einen gegebenen
1314 #* Input: Nummer des Eintrags
1316 #* Output: Kommentar-String
1318 #************************************************************************/
1320 String
SvxNumberFormatShell::GetComment4Entry(short nEntry
)
1322 const SvNumberformat
*pNumEntry
;
1327 if(nEntry
<aCurEntryList
.Count())
1329 sal_uInt32 nMyNfEntry
=aCurEntryList
[nEntry
];
1330 pNumEntry
= pFormatter
->GetEntry(nMyNfEntry
);
1332 return pNumEntry
->GetComment();
1338 /*************************************************************************
1339 #* Member: GetCategory4Entry Datum:30.10.97
1340 #*------------------------------------------------------------------------
1342 #* Klasse: SvxNumberFormatShell
1344 #* Funktion: Liefert die Kategorie- Nummer fuer einen gegebenen
1347 #* Input: Nummer des Eintrags
1349 #* Output: Kategorie- Nummer
1351 #************************************************************************/
1353 short SvxNumberFormatShell::GetCategory4Entry(short nEntry
)
1355 const SvNumberformat
*pNumEntry
;
1356 if(nEntry
<0) return 0;
1358 if(nEntry
<aCurEntryList
.Count())
1360 sal_uInt32 nMyNfEntry
=aCurEntryList
[nEntry
];
1362 if(nMyNfEntry
!=NUMBERFORMAT_ENTRY_NOT_FOUND
)
1364 pNumEntry
= pFormatter
->GetEntry(nMyNfEntry
);
1365 sal_uInt16 nMyCat
,nMyType
;
1368 nMyCat
=pNumEntry
->GetType() & ~NUMBERFORMAT_DEFINED
;
1369 CategoryToPos_Impl(nMyCat
,nMyType
);
1371 return (short) nMyType
;
1375 else if(aCurrencyFormatList
.Count()>0)
1377 return CAT_CURRENCY
;
1384 /*************************************************************************
1385 #* Member: GetUserDefined4Entry Datum:31.10.97
1386 #*------------------------------------------------------------------------
1388 #* Klasse: SvxNumberFormatShell
1390 #* Funktion: Liefert die Information, ob ein Eintrag
1391 #* benutzerspezifisch ist zurueck.
1393 #* Input: Nummer des Eintrags
1395 #* Output: Benutzerspezifisch?
1397 #************************************************************************/
1399 sal_Bool
SvxNumberFormatShell::GetUserDefined4Entry(short nEntry
)
1401 const SvNumberformat
*pNumEntry
;
1402 if(nEntry
<0) return 0;
1403 if(nEntry
<aCurEntryList
.Count())
1405 sal_uInt32 nMyNfEntry
=aCurEntryList
[nEntry
];
1406 pNumEntry
= pFormatter
->GetEntry(nMyNfEntry
);
1410 if((pNumEntry
->GetType() & NUMBERFORMAT_DEFINED
)>0)
1420 /*************************************************************************
1421 #* Member: GetFormat4Entry Datum:30.10.97
1422 #*------------------------------------------------------------------------
1424 #* Klasse: SvxNumberFormatShell
1426 #* Funktion: Liefert den Format- String fuer einen gegebenen
1429 #* Input: Nummer des Eintrags
1431 #* Output: Format- String
1433 #************************************************************************/
1435 String
SvxNumberFormatShell::GetFormat4Entry(short nEntry
)
1437 const SvNumberformat
*pNumEntry
;
1442 if(aCurrencyFormatList
.Count()>0)
1444 if(aCurrencyFormatList
.Count()>nEntry
)
1445 return *aCurrencyFormatList
[nEntry
];
1449 sal_uInt32 nMyNfEntry
=aCurEntryList
[nEntry
];
1450 pNumEntry
= pFormatter
->GetEntry(nMyNfEntry
);
1453 return pNumEntry
->GetFormatstring();
1458 /*************************************************************************
1459 #* Member: GetListPos4Entry Datum:31.10.97
1460 #*------------------------------------------------------------------------
1462 #* Klasse: SvxNumberFormatShell
1464 #* Funktion: Liefert die Listen- Nummer fuer einen gegebenen
1465 #* Formatindex zurueck.
1467 #* Input: Nummer des Eintrags
1469 #* Output: Kategorie- Nummer
1471 #************************************************************************/
1473 short SvxNumberFormatShell::GetListPos4Entry(sal_uInt32 nIdx
)
1475 short nSelP
=SELPOS_NONE
;
1476 if( aCurEntryList
.Count() <= 0x7fff )
1478 for(short i
=0;i
<aCurEntryList
.Count();i
++)
1480 if(aCurEntryList
[i
]==nIdx
)
1489 DBG_ERROR("svx::SvxNumberFormatShell::GetListPos4Entry(), list got to large!" );
1494 short SvxNumberFormatShell::GetListPos4Entry( const String
& rFmtString
)
1497 short nSelP
=SELPOS_NONE
;
1498 if(FindEntry(rFmtString
, &nAt
))
1500 if(NUMBERFORMAT_ENTRY_NOT_FOUND
!=nAt
&& NUMBERFORMAT_ENTRY_NEW_CURRENCY
!=nAt
)
1502 nSelP
=GetListPos4Entry(nAt
);
1506 if(aCurrencyFormatList
.Count()>0)
1508 for(sal_uInt16 i
=0;i
<aCurrencyFormatList
.Count();i
++)
1510 if (rFmtString
==*aCurrencyFormatList
[i
])
1522 String
SvxNumberFormatShell::GetStandardName() const
1524 return pFormatter
->GetStandardName( eCurLanguage
);
1527 void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor
& rList
, sal_uInt16
* pPos
)
1530 const NfCurrencyEntry
* pTmpCurrencyEntry
=SvNumberFormatter::MatchSystemCurrency();
1532 sal_Bool bFlag
=(pTmpCurrencyEntry
==NULL
);
1534 GetCurrencySymbols( rList
, bFlag
);
1538 const NfCurrencyTable
& rCurrencyTable
=SvNumberFormatter::GetTheCurrencyTable();
1539 sal_uInt16 nTableCount
=rCurrencyTable
.Count();
1542 sal_uInt16 nCount
=aCurCurrencyList
.Count();
1547 nCurCurrencyEntryPos
=1;
1551 for(sal_uInt16 i
=1;i
<nCount
;i
++)
1553 const sal_uInt16 j
= aCurCurrencyList
[i
];
1554 if (j
!= (sal_uInt16
)-1 && j
< nTableCount
&&
1555 pTmpCurrencyEntry
== rCurrencyTable
[j
])
1558 nCurCurrencyEntryPos
=i
;
1567 void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor
& rList
, sal_Bool bFlag
)
1569 aCurCurrencyList
.Remove(0,aCurCurrencyList
.Count());
1571 const NfCurrencyTable
& rCurrencyTable
=SvNumberFormatter::GetTheCurrencyTable();
1572 sal_uInt16 nCount
=rCurrencyTable
.Count();
1574 SvtLanguageTable
* pLanguageTable
=new SvtLanguageTable
;
1576 sal_uInt16 nStart
=1;
1579 XubString
aString( ApplyLreOrRleEmbedding( rCurrencyTable
[0]->GetSymbol()));
1580 aString
+= sal_Unicode(' ');
1581 aString
+= ApplyLreOrRleEmbedding( pLanguageTable
->GetString( rCurrencyTable
[0]->GetLanguage()));
1583 WSStringPtr pStr
= new XubString(aString
);
1584 rList
.Insert( pStr
,rList
.Count());
1585 sal_uInt16 nAuto
=(sal_uInt16
)-1;
1586 aCurCurrencyList
.Insert(nAuto
,aCurCurrencyList
.Count());
1590 pStr
= new XubString(aString
);
1591 rList
.Insert( pStr
,rList
.Count());
1592 aCurCurrencyList
.Insert((sal_uInt16
)0,aCurCurrencyList
.Count());
1596 CollatorWrapper
aCollator( ::comphelper::getProcessServiceFactory());
1597 aCollator
.loadDefaultCollator( Application::GetSettings().GetLocale(), 0);
1599 const String
aTwoSpace( RTL_CONSTASCII_USTRINGPARAM( " "));
1601 for(i
=1;i
<nCount
;i
++)
1603 XubString
aStr( ApplyLreOrRleEmbedding( rCurrencyTable
[i
]->GetBankSymbol()));
1605 aStr
+= ApplyLreOrRleEmbedding( rCurrencyTable
[i
]->GetSymbol());
1607 aStr
+= ApplyLreOrRleEmbedding( pLanguageTable
->GetString( rCurrencyTable
[i
]->GetLanguage()));
1609 pStr
= new XubString(aStr
);
1611 fprintf( stderr
, "currency entry: %s\n", ByteString( *pStr
, RTL_TEXTENCODING_UTF8
).GetBuffer());
1613 for(j
=nStart
;j
<rList
.Count();j
++)
1615 const StringPtr pTestStr
=rList
[j
];
1616 if (aCollator
.compareString( *pStr
, *pTestStr
) < 0)
1617 break; // insert before first greater than
1619 rList
.Insert( pStr
,j
);
1620 aCurCurrencyList
.Insert(i
,j
);
1623 // Append ISO codes to symbol list.
1624 // XXX If this is to be changed, various other places would had to be
1625 // adapted that assume this order!
1626 sal_uInt16 nCont
= rList
.Count();
1628 for(i
=1;i
<nCount
;i
++)
1630 bool bInsert
= true;
1631 pStr
= new XubString( ApplyLreOrRleEmbedding( rCurrencyTable
[i
]->GetBankSymbol()));
1633 for (j
= nCont
; j
< rList
.Count() && bInsert
; ++j
)
1635 const StringPtr pTestStr
=rList
[j
];
1637 if(*pTestStr
==*pStr
)
1640 if (aCollator
.compareString( *pStr
, *pTestStr
) < 0)
1641 break; // insert before first greater than
1645 rList
.Insert( pStr
,j
);
1646 aCurCurrencyList
.Insert(i
,j
);
1650 delete pLanguageTable
;
1653 void SvxNumberFormatShell::GetCurrencyFormats(SvStrings
& aListDtor
)
1655 if(pCurCurrencyEntry
!=NULL
)
1657 NfWSStringsDtor aWSStringsDtor
;
1658 /*sal_uInt16 nDefault = */pFormatter
->GetCurrencyFormatStrings( aWSStringsDtor
,
1659 *pCurCurrencyEntry
, bBankingSymbol
);
1661 for(sal_uInt16 i
=0;i
<aWSStringsDtor
.Count();i
++)
1663 aListDtor
.Insert(new String(*aWSStringsDtor
[i
]),aListDtor
.Count());
1668 sal_Bool
SvxNumberFormatShell::IsBankingSymbol(sal_uInt16 nPos
)
1670 const NfCurrencyTable
& rCurrencyTable
=SvNumberFormatter::GetTheCurrencyTable();
1671 sal_uInt16 nCount
=rCurrencyTable
.Count();
1673 return (nPos
>nCount
);
1676 void SvxNumberFormatShell::SetCurrencySymbol(sal_uInt16 nPos
)
1678 const NfCurrencyTable
& rCurrencyTable
=SvNumberFormatter::GetTheCurrencyTable();
1679 sal_uInt16 nCount
=rCurrencyTable
.Count();
1681 bBankingSymbol
=(nPos
>=nCount
);
1683 if(nPos
<aCurCurrencyList
.Count())
1685 sal_uInt16 nCurrencyPos
=aCurCurrencyList
[nPos
];
1686 if(nCurrencyPos
!=(sal_uInt16
)-1)
1688 pCurCurrencyEntry
=rCurrencyTable
[nCurrencyPos
];
1689 nCurCurrencyEntryPos
=nPos
;
1693 pCurCurrencyEntry
=NULL
;
1694 nCurCurrencyEntryPos
=0;
1695 nCurFormatKey
=pFormatter
->GetFormatIndex(
1696 NF_CURRENCY_1000DEC2_RED
, eCurLanguage
);
1701 sal_uInt32
SvxNumberFormatShell::GetCurrencySymbol()
1703 return nCurCurrencyEntryPos
;
1706 NfCurrencyEntry
* SvxNumberFormatShell::GetCurCurrencyEntry()
1708 return pCurCurrencyEntry
;
1711 void SvxNumberFormatShell::SetCurCurrencyEntry(NfCurrencyEntry
* pCEntry
)
1713 pCurCurrencyEntry
=pCEntry
;
1716 sal_Bool
SvxNumberFormatShell::IsTmpCurrencyFormat( const String
& rFmtString
)
1719 /*sal_Bool bRes=*/FindEntry(rFmtString
, &nFound
);
1721 if(nFound
==NUMBERFORMAT_ENTRY_NEW_CURRENCY
)
1728 sal_uInt16
SvxNumberFormatShell::FindCurrencyFormat( const String
& rFmtString
)
1730 const NfCurrencyTable
& rCurrencyTable
=SvNumberFormatter::GetTheCurrencyTable();
1731 sal_uInt16 nCount
=rCurrencyTable
.Count();
1733 sal_Bool bTestBanking
=sal_False
;
1735 sal_uInt16 nPos
=FindCurrencyTableEntry(rFmtString
, bTestBanking
);
1737 sal_uInt16 nStart
=0;
1739 if(nPos
!=(sal_uInt16
)-1)
1741 if(bTestBanking
&& aCurCurrencyList
.Count()>nPos
)
1745 for(sal_uInt16 j
=nStart
;j
<aCurCurrencyList
.Count();j
++)
1747 if(aCurCurrencyList
[j
]==nPos
) return j
;
1750 return (sal_uInt16
) -1;
1753 sal_uInt16
SvxNumberFormatShell::FindCurrencyTableEntry( const String
& rFmtString
, sal_Bool
&bTestBanking
)
1755 sal_uInt16 nPos
=(sal_uInt16
) -1;
1757 const NfCurrencyTable
& rCurrencyTable
=SvNumberFormatter::GetTheCurrencyTable();
1758 sal_uInt16 nCount
=rCurrencyTable
.Count();
1760 const SvNumberformat
* pFormat
;
1761 String aSymbol
, aExtension
;
1762 sal_uInt32 nFound
= pFormatter
->TestNewString( rFmtString
, eCurLanguage
);
1763 if ( nFound
!= NUMBERFORMAT_ENTRY_NOT_FOUND
&&
1764 ((pFormat
= pFormatter
->GetEntry( nFound
)) != 0) &&
1765 pFormat
->GetNewCurrencySymbol( aSymbol
, aExtension
) )
1766 { // eventually match with format locale
1767 const NfCurrencyEntry
* pTmpCurrencyEntry
=
1768 SvNumberFormatter::GetCurrencyEntry( bTestBanking
, aSymbol
, aExtension
,
1769 pFormat
->GetLanguage() );
1770 if ( pTmpCurrencyEntry
)
1772 for(sal_uInt16 i
=0;i
<nCount
;i
++)
1774 if(pTmpCurrencyEntry
==rCurrencyTable
[i
])
1783 { // search symbol string only
1784 for(sal_uInt16 i
=0;i
<nCount
;i
++)
1786 const NfCurrencyEntry
* pTmpCurrencyEntry
=rCurrencyTable
[i
];
1787 XubString _aSymbol
, aBankSymbol
;
1788 pTmpCurrencyEntry
->BuildSymbolString(_aSymbol
,sal_False
);
1789 pTmpCurrencyEntry
->BuildSymbolString(aBankSymbol
,sal_True
);
1791 if(rFmtString
.Search(_aSymbol
)!=STRING_NOTFOUND
)
1793 bTestBanking
=sal_False
;
1797 else if(rFmtString
.Search(aBankSymbol
)!=STRING_NOTFOUND
)
1799 bTestBanking
=sal_True
;
1809 sal_uInt16
SvxNumberFormatShell::FindCurrencyFormat(const NfCurrencyEntry
* pTmpCurrencyEntry
,sal_Bool bTmpBanking
)
1811 const NfCurrencyTable
& rCurrencyTable
=SvNumberFormatter::GetTheCurrencyTable();
1812 sal_uInt16 nCount
=rCurrencyTable
.Count();
1814 // sal_Bool bTestBanking=sal_False;
1816 for(sal_uInt16 i
=0;i
<nCount
;i
++)
1818 if(pTmpCurrencyEntry
==rCurrencyTable
[i
])
1825 sal_uInt16 nStart
=0;
1826 if(bTmpBanking
&& aCurCurrencyList
.Count()>nPos
)
1830 for(sal_uInt16 j
=nStart
;j
<aCurCurrencyList
.Count();j
++)
1832 if(aCurCurrencyList
[j
]==nPos
) return j
;
1834 return (sal_uInt16
) -1;
1837 sal_Bool
SvxNumberFormatShell::IsInTable(sal_uInt16 nPos
,sal_Bool bTmpBanking
,const String
&rFmtString
)
1839 sal_Bool bFlag
=sal_False
;
1841 if(nPos
!=(sal_uInt16
)-1)
1843 const NfCurrencyTable
& rCurrencyTable
=SvNumberFormatter::GetTheCurrencyTable();
1844 sal_uInt16 nCount
=rCurrencyTable
.Count();
1848 NfWSStringsDtor aWSStringsDtor
;
1849 sal_uInt16 nDefault
;
1851 const NfCurrencyEntry
* pTmpCurrencyEntry
=rCurrencyTable
[nPos
];
1853 if ( pTmpCurrencyEntry
!=NULL
)
1855 nDefault
= pFormatter
->GetCurrencyFormatStrings( aWSStringsDtor
,
1856 *pTmpCurrencyEntry
, bTmpBanking
);
1858 for(sal_uInt16 i
=0;i
<aWSStringsDtor
.Count();i
++)
1860 if(*aWSStringsDtor
[i
]==rFmtString
)