1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SVX_NUMFMTSH_HXX
20 #define INCLUDED_SVX_NUMFMTSH_HXX
22 #include <i18nlangtag/lang.h>
24 #include <svx/svxdllapi.h>
26 #include <svl/zforlist.hxx>
33 enum SvxNumberValueType
35 SVX_VALUE_TYPE_UNDEFINED
= 0,
36 SVX_VALUE_TYPE_NUMBER
,
40 // sort order of the category ListBox entries in the TabPage
42 #define CAT_USERDEFINED 1
45 #define CAT_CURRENCY 4
48 #define CAT_SCIENTIFIC 7
49 #define CAT_FRACTION 8
53 #define SELPOS_NONE -1
55 #define NUMBERFORMAT_ENTRY_NEW_CURRENCY NUMBERFORMAT_ENTRY_NOT_FOUND-1
58 class SVX_DLLPUBLIC SvxNumberFormatShell
61 SvxNumberFormatShell( SvNumberFormatter
* pNumFormatter
,
62 sal_uInt32 nFormatKey
,
63 SvxNumberValueType eNumValType
,
64 const OUString
& rNumStr
);
66 SvxNumberFormatShell( SvNumberFormatter
* pNumFormatter
,
67 sal_uInt32 nFormatKey
,
68 SvxNumberValueType eNumValType
,
70 const OUString
* pNumStr
= NULL
);
72 ~SvxNumberFormatShell();
75 static SvxNumberFormatShell
* Create( SvNumberFormatter
* pNumFormatter
,
76 sal_uInt32 nFormatKey
,
77 SvxNumberValueType eNumValType
,
78 const OUString
& rNumStr
);
80 static SvxNumberFormatShell
* Create( SvNumberFormatter
* pNumFormatter
,
81 sal_uInt32 nFormatKey
,
82 SvxNumberValueType eNumValType
,
84 const OUString
* pNumStr
= NULL
);
87 void GetInitSettings( sal_uInt16
& nCatLbPos
,
88 LanguageType
& rLangType
,
89 sal_uInt16
& nFmtLbSelPos
,
90 std::vector
<OUString
>& rFmtEntries
,
91 OUString
& rPrevString
,
92 Color
*& rpPrevColor
);
94 void CategoryChanged( sal_uInt16 nCatLbPos
,
96 std::vector
<OUString
>& rFmtEntries
);
98 void LanguageChanged( LanguageType eLangType
,
100 std::vector
<OUString
>& rFmtEntries
);
102 void FormatChanged( sal_uInt16 nFmtLbPos
,
103 OUString
& rPreviewStr
,
104 Color
*& rpFontColor
);
106 bool AddFormat( OUString
& rFormat
,
108 sal_uInt16
& rCatLbSelPos
,
110 std::vector
<OUString
>& rFmtEntries
);
112 bool RemoveFormat( const OUString
& rFormat
,
113 sal_uInt16
& rCatLbSelPos
,
115 std::vector
<OUString
>& rFmtEntries
);
117 void MakeFormat( OUString
& rFormat
,
120 sal_uInt16 nPrecision
,
121 sal_uInt16 nLeadingZeroes
,
122 sal_uInt16 nCurrencyEntryPos
);
124 void GetOptions( const OUString
& rFormat
,
127 sal_uInt16
& rPrecision
,
128 sal_uInt16
& rLeadingZeroes
,
129 sal_uInt16
& rCatLbPos
);
131 void MakePreviewString( const OUString
& rFormatStr
,
132 OUString
& rPreviewStr
,
133 Color
*& rpFontColor
);
135 void MakePrevStringFromVal( const OUString
& rFormatStr
,
136 OUString
& rPreviewStr
,
140 bool IsUserDefined( const OUString
& rFmtString
);
141 bool IsTmpCurrencyFormat( const OUString
& rFmtString
);
142 bool FindEntry( const OUString
& rFmtString
, sal_uInt32
* pAt
= NULL
);
144 void ValidateNewEntries( bool bValidate
= true ) { bUndoAddList
= !bValidate
; }
145 size_t GetUpdateDataCount() const;
146 void GetUpdateData( sal_uInt32
* pDelArray
, const sal_uInt32 nSize
);
148 void SetCurNumFmtKey( sal_uInt32 nNew
) { nCurFormatKey
= nNew
; }
149 void SetCurLanguage( LanguageType eNew
) { eCurLanguage
= eNew
; }
150 sal_uInt32
GetCurNumFmtKey() const { return nCurFormatKey
; }
151 LanguageType
GetCurLanguage() const { return eCurLanguage
; }
153 /** Returns the name of Standard, General, ... for the
155 OUString
GetStandardName() const;
157 OUString
GetComment4Entry(short nEntry
);
158 short GetCategory4Entry(short nEntry
);
159 bool GetUserDefined4Entry(short nEntry
);
160 OUString
GetFormat4Entry(short nEntry
);
161 void SetComment4Entry(short nEntry
, const OUString
& aCommentString
);
163 void SetCurrencySymbol(sal_uInt32 nPos
);
164 sal_uInt32
GetCurrencySymbol();
165 sal_uInt16
FindCurrencyFormat( const OUString
& rFmtString
);
166 sal_uInt16
FindCurrencyFormat(const NfCurrencyEntry
* pTmpCurrencyEntry
,bool bTmpBanking
);
167 void SetCurCurrencyEntry(NfCurrencyEntry
*);
168 short GetListPos4Entry(sal_uInt32 nIdx
);
169 short GetListPos4Entry( const OUString
& rFmtString
);
171 void GetCurrencySymbols(std::vector
<OUString
>& rList
, sal_uInt16
* pPos
);
172 void GetCurrencySymbols(std::vector
<OUString
>& rList
, bool bFlag
);
174 sal_uInt16
FindCurrencyTableEntry( const OUString
& rFmtString
, bool &bTestBanking
);
175 bool IsInTable(sal_uInt16 nPos
, bool bTmpBanking
,
176 OUString
const& rFmtString
);
178 void SetUseStarFormat( bool bUse
) { bUseStarFormat
= bUse
; }
179 bool IsUseStarFormat( void ) { return bUseStarFormat
; }
181 static const double DEFAULT_NUMVALUE
;
183 SvNumberFormatter
* pFormatter
;
184 SvNumberFormatTable
* pCurFmtTable
;
185 SvxNumberValueType eValType
;
189 std::vector
<sal_uInt32
> aAddList
;
190 std::vector
<sal_uInt32
> aDelList
;
191 std::vector
<sal_uInt32
> aCurEntryList
;
192 sal_uInt32 nCurFormatKey
;
194 LanguageType eCurLanguage
;
195 std::vector
<sal_uInt16
> aCurCurrencyList
;
196 NfCurrencyEntry
* pCurCurrencyEntry
;
198 sal_uInt32 nCurCurrencyEntryPos
;
199 std::vector
<OUString
> aCurrencyFormatList
;
202 SVX_DLLPRIVATE
short FillEntryList_Impl( std::vector
<OUString
>& rList
);
203 SVX_DLLPRIVATE
void FillEListWithStd_Impl( std::vector
<OUString
>& rList
,sal_uInt16 aPrivCat
, short &Pos
);
204 SVX_DLLPRIVATE
short FillEListWithFormats_Impl( std::vector
<OUString
>& rList
,short nSelPos
,
205 NfIndexTableOffset eOffsetStart
,
206 NfIndexTableOffset eOffsetEnd
);
207 SVX_DLLPRIVATE
short FillEListWithDateTime_Impl( std::vector
<OUString
>& rList
,short nSelPos
);
208 SVX_DLLPRIVATE
short FillEListWithCurrency_Impl( std::vector
<OUString
>& rList
,short nSelPos
);
209 SVX_DLLPRIVATE
short FillEListWithSysCurrencys( std::vector
<OUString
>& rList
,short nSelPos
);
210 SVX_DLLPRIVATE
short FillEListWithUserCurrencys( std::vector
<OUString
>& rList
,short nSelPos
);
211 SVX_DLLPRIVATE
short FillEListWithUsD_Impl( std::vector
<OUString
>& rList
, sal_uInt16 nPrivCat
, short Pos
);
213 SVX_DLLPRIVATE ::std::vector
<sal_uInt32
>::iterator
GetRemoved_Impl( size_t nKey
);
214 SVX_DLLPRIVATE
bool IsRemoved_Impl( size_t nKey
);
215 SVX_DLLPRIVATE ::std::vector
<sal_uInt32
>::iterator
GetAdded_Impl( size_t nKey
);
216 SVX_DLLPRIVATE
bool IsAdded_Impl( size_t nKey
);
218 SVX_DLLPRIVATE
void GetPreviewString_Impl( OUString
& rString
,
220 SVX_DLLPRIVATE
void PosToCategory_Impl( sal_uInt16 nPos
, short& rCategory
);
221 SVX_DLLPRIVATE
void CategoryToPos_Impl( short nCategory
, sal_uInt16
& rPos
);
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */