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 _SVX_NUMFMTSH_HXX
20 #define _SVX_NUMFMTSH_HXX
22 #include <tools/string.hxx>
23 #include <i18nlangtag/lang.h>
25 #include "svx/svxdllapi.h"
27 #include <svl/zforlist.hxx>
34 enum SvxNumberValueType
36 SVX_VALUE_TYPE_UNDEFINED
= 0,
37 SVX_VALUE_TYPE_NUMBER
,
41 // sort order of the category ListBox entries in the TabPage
43 #define CAT_USERDEFINED 1
46 #define CAT_CURRENCY 4
49 #define CAT_SCIENTIFIC 7
50 #define CAT_FRACTION 8
54 #define SELPOS_NONE -1
56 #define NUMBERFORMAT_ENTRY_NEW_CURRENCY NUMBERFORMAT_ENTRY_NOT_FOUND-1
59 class SVX_DLLPUBLIC SvxNumberFormatShell
62 SvxNumberFormatShell( SvNumberFormatter
* pNumFormatter
,
63 sal_uInt32 nFormatKey
,
64 SvxNumberValueType eNumValType
,
65 const String
& rNumStr
);
67 SvxNumberFormatShell( SvNumberFormatter
* pNumFormatter
,
68 sal_uInt32 nFormatKey
,
69 SvxNumberValueType eNumValType
,
71 const String
* pNumStr
= NULL
);
73 ~SvxNumberFormatShell();
76 static SvxNumberFormatShell
* Create( SvNumberFormatter
* pNumFormatter
,
77 sal_uInt32 nFormatKey
,
78 SvxNumberValueType eNumValType
,
79 const String
& rNumStr
);
81 static SvxNumberFormatShell
* Create( SvNumberFormatter
* pNumFormatter
,
82 sal_uInt32 nFormatKey
,
83 SvxNumberValueType eNumValType
,
85 const String
* pNumStr
= NULL
);
88 void GetInitSettings( sal_uInt16
& nCatLbPos
,
89 LanguageType
& rLangType
,
90 sal_uInt16
& nFmtLbSelPos
,
91 std::vector
<String
*>& rFmtEntries
,
93 Color
*& rpPrevColor
);
95 void CategoryChanged( sal_uInt16 nCatLbPos
,
97 std::vector
<String
*>& rFmtEntries
);
99 void LanguageChanged( LanguageType eLangType
,
101 std::vector
<String
*>& rFmtEntries
);
103 void FormatChanged( sal_uInt16 nFmtLbPos
,
105 Color
*& rpFontColor
);
107 bool AddFormat( String
& rFormat
,
109 sal_uInt16
& rCatLbSelPos
,
111 std::vector
<String
*>& rFmtEntries
);
113 bool RemoveFormat( const String
& rFormat
,
114 sal_uInt16
& rCatLbSelPos
,
116 std::vector
<String
*>& rFmtEntries
);
118 void MakeFormat( String
& rFormat
,
121 sal_uInt16 nPrecision
,
122 sal_uInt16 nLeadingZeroes
,
123 sal_uInt16 nCurrencyEntryPos
);
125 void GetOptions( const String
& rFormat
,
128 sal_uInt16
& rPrecision
,
129 sal_uInt16
& rLeadingZeroes
,
130 sal_uInt16
& rCatLbPos
);
132 void MakePreviewString( const String
& rFormatStr
,
134 Color
*& rpFontColor
);
136 void MakePrevStringFromVal( const String
& rFormatStr
,
141 bool IsUserDefined( const String
& rFmtString
);
142 bool IsTmpCurrencyFormat( const String
& rFmtString
);
143 bool FindEntry( const String
& rFmtString
, sal_uInt32
* pAt
= NULL
);
145 void ValidateNewEntries( bool bValidate
= true ) { bUndoAddList
= !bValidate
; }
146 size_t GetUpdateDataCount() const;
147 void GetUpdateData( sal_uInt32
* pDelArray
, const sal_uInt32 nSize
);
149 void SetCurNumFmtKey( sal_uInt32 nNew
) { nCurFormatKey
= nNew
; }
150 void SetCurLanguage( LanguageType eNew
) { eCurLanguage
= eNew
; }
151 sal_uInt32
GetCurNumFmtKey() const { return nCurFormatKey
; }
152 LanguageType
GetCurLanguage() const { return eCurLanguage
; }
154 /** Returns the name of Standard, General, ... for the
156 String
GetStandardName() const;
158 String
GetComment4Entry(short nEntry
);
159 short GetCategory4Entry(short nEntry
);
160 bool GetUserDefined4Entry(short nEntry
);
161 String
GetFormat4Entry(short nEntry
);
162 void SetComment4Entry(short nEntry
,String aCommentString
);
164 void SetCurrencySymbol(sal_uInt16 nPos
);
165 sal_uInt32
GetCurrencySymbol();
166 sal_uInt16
FindCurrencyFormat( const String
& rFmtString
);
167 sal_uInt16
FindCurrencyFormat(const NfCurrencyEntry
* pTmpCurrencyEntry
,bool bTmpBanking
);
168 void SetCurCurrencyEntry(NfCurrencyEntry
*);
169 short GetListPos4Entry(sal_uInt32 nIdx
);
170 short GetListPos4Entry( const String
& rFmtString
);
172 void GetCurrencySymbols(std::vector
<OUString
>& rList
, sal_uInt16
* pPos
);
173 void GetCurrencySymbols(std::vector
<OUString
>& rList
, bool bFlag
);
175 sal_uInt16
FindCurrencyTableEntry( const String
& rFmtString
, bool &bTestBanking
);
176 bool IsInTable(sal_uInt16 nPos
, bool bTmpBanking
,
177 OUString
const& rFmtString
);
179 void SetUseStarFormat( bool bUse
) { bUseStarFormat
= bUse
; }
180 bool IsUseStarFormat( void ) { return bUseStarFormat
; }
182 static const double DEFAULT_NUMVALUE
;
184 SvNumberFormatter
* pFormatter
;
185 SvNumberFormatTable
* pCurFmtTable
;
186 SvxNumberValueType eValType
;
190 std::vector
<sal_uInt32
> aAddList
;
191 std::vector
<sal_uInt32
> aDelList
;
192 std::vector
<sal_uInt32
> aCurEntryList
;
193 sal_uInt32 nCurFormatKey
;
195 LanguageType eCurLanguage
;
196 std::vector
<sal_uInt16
> aCurCurrencyList
;
197 NfCurrencyEntry
* pCurCurrencyEntry
;
199 sal_uInt16 nCurCurrencyEntryPos
;
200 std::vector
<String
*> aCurrencyFormatList
;
203 SVX_DLLPRIVATE
short FillEntryList_Impl( std::vector
<String
*>& rList
);
204 SVX_DLLPRIVATE
void FillEListWithStd_Impl( std::vector
<String
*>& rList
,sal_uInt16 aPrivCat
, short &Pos
);
205 SVX_DLLPRIVATE
short FillEListWithFormats_Impl( std::vector
<String
*>& rList
,short nSelPos
,
206 NfIndexTableOffset eOffsetStart
,
207 NfIndexTableOffset eOffsetEnd
);
208 SVX_DLLPRIVATE
short FillEListWithDateTime_Impl( std::vector
<String
*>& rList
,short nSelPos
);
209 SVX_DLLPRIVATE
short FillEListWithCurrency_Impl( std::vector
<String
*>& rList
,short nSelPos
);
210 SVX_DLLPRIVATE
short FillEListWithSysCurrencys( std::vector
<String
*>& rList
,short nSelPos
);
211 SVX_DLLPRIVATE
short FillEListWithUserCurrencys( std::vector
<String
*>& rList
,short nSelPos
);
212 SVX_DLLPRIVATE
short FillEListWithUsD_Impl( std::vector
<String
*>& rList
, sal_uInt16 nPrivCat
, short Pos
);
214 SVX_DLLPRIVATE ::std::vector
<sal_uInt32
>::iterator
GetRemoved_Impl( size_t nKey
);
215 SVX_DLLPRIVATE
bool IsRemoved_Impl( size_t nKey
);
216 SVX_DLLPRIVATE ::std::vector
<sal_uInt32
>::iterator
GetAdded_Impl( size_t nKey
);
217 SVX_DLLPRIVATE
bool IsAdded_Impl( size_t nKey
);
219 SVX_DLLPRIVATE
void GetPreviewString_Impl( String
& rString
,
221 SVX_DLLPRIVATE
void PosToCategory_Impl( sal_uInt16 nPos
, short& rCategory
);
222 SVX_DLLPRIVATE
void CategoryToPos_Impl( short nCategory
, sal_uInt16
& rPos
);
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */