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>
32 enum class SvxNumberValueType
39 // sort order of the category ListBox entries in the TabPage
41 #define CAT_USERDEFINED 1
44 #define CAT_CURRENCY 4
47 #define CAT_SCIENTIFIC 7
48 #define CAT_FRACTION 8
52 #define SELPOS_NONE -1
54 #define NUMBERFORMAT_ENTRY_NEW_CURRENCY NUMBERFORMAT_ENTRY_NOT_FOUND-1
57 class SVX_DLLPUBLIC SvxNumberFormatShell
60 SvxNumberFormatShell( SvNumberFormatter
* pNumFormatter
,
61 sal_uInt32 nFormatKey
,
62 SvxNumberValueType eNumValType
,
63 const OUString
& rNumStr
);
65 SvxNumberFormatShell( SvNumberFormatter
* pNumFormatter
,
66 sal_uInt32 nFormatKey
,
67 SvxNumberValueType eNumValType
,
69 const OUString
* pNumStr
);
71 ~SvxNumberFormatShell();
74 static SvxNumberFormatShell
* Create( SvNumberFormatter
* pNumFormatter
,
75 sal_uInt32 nFormatKey
,
76 SvxNumberValueType eNumValType
,
77 const OUString
& rNumStr
);
79 static SvxNumberFormatShell
* Create( SvNumberFormatter
* pNumFormatter
,
80 sal_uInt32 nFormatKey
,
81 SvxNumberValueType eNumValType
,
83 const OUString
* pNumStr
);
86 void GetInitSettings( sal_uInt16
& nCatLbPos
,
87 LanguageType
& rLangType
,
88 sal_uInt16
& nFmtLbSelPos
,
89 std::vector
<OUString
>& rFmtEntries
,
90 OUString
& rPrevString
,
91 Color
*& rpPrevColor
);
93 void CategoryChanged( sal_uInt16 nCatLbPos
,
95 std::vector
<OUString
>& rFmtEntries
);
97 void LanguageChanged( LanguageType eLangType
,
99 std::vector
<OUString
>& rFmtEntries
);
101 void FormatChanged( sal_uInt16 nFmtLbPos
,
102 OUString
& rPreviewStr
,
103 Color
*& rpFontColor
);
105 bool AddFormat( OUString
& rFormat
,
107 sal_uInt16
& rCatLbSelPos
,
109 std::vector
<OUString
>& rFmtEntries
);
111 void RemoveFormat( const OUString
& rFormat
,
112 sal_uInt16
& rCatLbSelPos
,
114 std::vector
<OUString
>& rFmtEntries
);
116 void MakeFormat( OUString
& rFormat
,
119 sal_uInt16 nPrecision
,
120 sal_uInt16 nLeadingZeroes
,
121 sal_uInt16 nCurrencyEntryPos
);
123 void GetOptions( const OUString
& rFormat
,
126 sal_uInt16
& rPrecision
,
127 sal_uInt16
& rLeadingZeroes
,
128 sal_uInt16
& rCatLbPos
);
130 sal_uInt16
GetFormatIntegerDigits( const OUString
& rFormat
) const;
132 void MakePreviewString( const OUString
& rFormatStr
,
133 OUString
& rPreviewStr
,
134 Color
*& rpFontColor
);
136 void MakePrevStringFromVal( const OUString
& rFormatStr
,
137 OUString
& rPreviewStr
,
141 bool IsUserDefined( const OUString
& rFmtString
);
142 bool IsTmpCurrencyFormat( const OUString
& rFmtString
);
143 bool FindEntry( const OUString
& rFmtString
, sal_uInt32
* pAt
= nullptr );
145 void ValidateNewEntries() { bUndoAddList
= false; }
146 std::vector
<sal_uInt32
> const & GetUpdateData() const;
148 void SetCurNumFmtKey( sal_uInt32 nNew
) { nCurFormatKey
= nNew
; }
149 sal_uInt32
GetCurNumFmtKey() const { return nCurFormatKey
; }
150 LanguageType
GetCurLanguage() const { return eCurLanguage
; }
152 /** Returns the name of Standard, General, ... for the
154 OUString
GetStandardName() const;
156 OUString
GetComment4Entry(short nEntry
);
157 short GetCategory4Entry(short nEntry
) const;
158 bool GetUserDefined4Entry(short nEntry
);
159 OUString
GetFormat4Entry(short nEntry
);
160 void SetComment4Entry(short nEntry
, const OUString
& aCommentString
);
162 void SetCurrencySymbol(sal_uInt32 nPos
);
163 sal_uInt32
GetCurrencySymbol() const { return nCurCurrencyEntryPos
;}
164 sal_uInt16
FindCurrencyFormat( const OUString
& rFmtString
);
165 sal_uInt16
FindCurrencyFormat(const NfCurrencyEntry
* pTmpCurrencyEntry
,bool bTmpBanking
);
166 void SetCurCurrencyEntry(NfCurrencyEntry
*);
167 short GetListPos4Entry( sal_uInt32 nIdx
, const OUString
& rFmtString
);
169 void GetCurrencySymbols(std::vector
<OUString
>& rList
, sal_uInt16
* pPos
);
171 sal_uInt16
FindCurrencyTableEntry( const OUString
& rFmtString
, bool &bTestBanking
);
172 bool IsInTable(sal_uInt16 nPos
, bool bTmpBanking
,
173 OUString
const& rFmtString
);
175 void SetUseStarFormat( bool bUse
) { bUseStarFormat
= bUse
; }
177 SvNumberFormatter
* pFormatter
;
178 SvNumberFormatTable
* pCurFmtTable
;
179 SvxNumberValueType
const eValType
;
183 std::vector
<sal_uInt32
> aAddList
;
184 std::vector
<sal_uInt32
> aDelList
;
185 std::vector
<sal_uInt32
> aCurEntryList
;
186 sal_uInt32 nCurFormatKey
;
187 SvNumFormatType nCurCategory
;
188 LanguageType eCurLanguage
;
189 std::vector
<sal_uInt16
> aCurCurrencyList
;
190 NfCurrencyEntry
* pCurCurrencyEntry
;
192 sal_uInt32 nCurCurrencyEntryPos
;
193 std::vector
<OUString
> aCurrencyFormatList
;
195 bool bIsDefaultValNum
;
197 SVX_DLLPRIVATE
short FillEntryList_Impl( std::vector
<OUString
>& rList
);
198 SVX_DLLPRIVATE
void FillEListWithStd_Impl( std::vector
<OUString
>& rList
, SvNumFormatType eCategory
, short &Pos
,
199 bool bSuppressDuplicates
= false );
200 SVX_DLLPRIVATE
short FillEListWithFormats_Impl( std::vector
<OUString
>& rList
,short nSelPos
,
201 NfIndexTableOffset eOffsetStart
,
202 NfIndexTableOffset eOffsetEnd
,
203 bool bSuppressDuplicates
);
204 SVX_DLLPRIVATE
short FillEListWithDateTime_Impl( std::vector
<OUString
>& rList
,short nSelPos
,
205 bool bSuppressDuplicates
);
206 SVX_DLLPRIVATE
short FillEListWithCurrency_Impl( std::vector
<OUString
>& rList
,short nSelPos
);
207 SVX_DLLPRIVATE
short FillEListWithSysCurrencys( std::vector
<OUString
>& rList
,short nSelPos
);
208 SVX_DLLPRIVATE
short FillEListWithUserCurrencys( std::vector
<OUString
>& rList
,short nSelPos
);
209 SVX_DLLPRIVATE
short FillEListWithUsD_Impl( std::vector
<OUString
>& rList
, SvNumFormatType eCategory
, short Pos
);
211 SVX_DLLPRIVATE
bool IsEssentialFormat_Impl( SvNumFormatType eType
, sal_uInt32 nKey
);
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
);
217 SVX_DLLPRIVATE
void GetPreviewString_Impl( OUString
& rString
,
219 SVX_DLLPRIVATE
static void PosToCategory_Impl(sal_uInt16 nPos
, SvNumFormatType
& rCategory
);
220 SVX_DLLPRIVATE
static void CategoryToPos_Impl(SvNumFormatType nCategory
, sal_uInt16
& rPos
);
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */