LibreOffice Module svx (master) 1
numfmtsh.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SVX_NUMFMTSH_HXX
20#define INCLUDED_SVX_NUMFMTSH_HXX
21
22#include <i18nlangtag/lang.h>
23
24#include <svx/svxdllapi.h>
25
26#include <svl/zforlist.hxx>
27
28#include <vector>
29
30class Color;
32
34{
36 Number,
37 String
38};
39
40// sort order of the category ListBox entries in the TabPage
41#define CAT_ALL 0
42#define CAT_USERDEFINED 1
43#define CAT_NUMBER 2
44#define CAT_PERCENT 3
45#define CAT_CURRENCY 4
46#define CAT_DATE 5
47#define CAT_TIME 6
48#define CAT_SCIENTIFIC 7
49#define CAT_FRACTION 8
50#define CAT_BOOLEAN 9
51#define CAT_TEXT 10
52
53#define SELPOS_NONE -1
54
55#define NUMBERFORMAT_ENTRY_NEW_CURRENCY NUMBERFORMAT_ENTRY_NOT_FOUND-1
56
57
59{
60public:
62 sal_uInt32 nFormatKey,
63 SvxNumberValueType eNumValType,
64 const OUString& rNumStr );
65
67 sal_uInt32 nFormatKey,
68 SvxNumberValueType eNumValType,
69 double nNumVal,
70 const OUString* pNumStr );
71
73
74
75 static SvxNumberFormatShell* Create( SvNumberFormatter* pNumFormatter,
76 sal_uInt32 nFormatKey,
77 SvxNumberValueType eNumValType,
78 const OUString& rNumStr );
79
80 static SvxNumberFormatShell* Create( SvNumberFormatter* pNumFormatter,
81 sal_uInt32 nFormatKey,
82 SvxNumberValueType eNumValType,
83 double nNumVal,
84 const OUString* pNumStr );
85
86
87 void GetInitSettings( sal_uInt16& nCatLbPos,
88 LanguageType& rLangType,
89 sal_uInt16& nFmtLbSelPos,
90 std::vector<OUString>& rFmtEntries,
91 OUString& rPrevString,
92 const Color*& rpPrevColor );
93
94 void CategoryChanged( sal_uInt16 nCatLbPos,
95 short& rFmtSelPos,
96 std::vector<OUString>& rFmtEntries );
97
98 void LanguageChanged( LanguageType eLangType,
99 short& rFmtSelPos,
100 std::vector<OUString>& rFmtEntries );
101
102 void FormatChanged( sal_uInt16 nFmtLbPos,
103 OUString& rPreviewStr,
104 const Color*& rpFontColor );
105
106 bool AddFormat( OUString& rFormat,
107 sal_Int32& rErrPos,
108 sal_uInt16& rCatLbSelPos,
109 short& rFmtSelPos,
110 std::vector<OUString>& rFmtEntries );
111
112 void RemoveFormat( std::u16string_view rFormat,
113 sal_uInt16& rCatLbSelPos,
114 short& rFmtSelPos,
115 std::vector<OUString>& rFmtEntries );
116
117 void MakeFormat( OUString& rFormat,
118 bool bThousand,
119 bool bNegRed,
120 sal_uInt16 nPrecision,
121 sal_uInt16 nLeadingZeroes,
122 sal_uInt16 nCurrencyEntryPos);
123
124 void GetOptions( const OUString& rFormat,
125 bool& rThousand,
126 bool& rNegRed,
127 sal_uInt16& rPrecision,
128 sal_uInt16& rLeadingZeroes,
129 sal_uInt16& rCatLbPos );
130
131 sal_uInt16 GetFormatIntegerDigits( std::u16string_view rFormat ) const;
132
133 void MakePreviewString( const OUString& rFormatStr,
134 OUString& rPreviewStr,
135 const Color*& rpFontColor );
136
137 void MakePrevStringFromVal( const OUString& rFormatStr,
138 OUString& rPreviewStr,
139 const Color*& rpFontColor,
140 double nValue);
141
142 bool IsUserDefined( const OUString& rFmtString );
143 bool IsTmpCurrencyFormat( const OUString& rFmtString );
144 bool FindEntry( const OUString& rFmtString, sal_uInt32* pAt = nullptr );
145
146 void ValidateNewEntries() { bUndoAddList = false; }
147 std::vector<sal_uInt32> const & GetUpdateData() const;
148
149 void SetCurNumFmtKey( sal_uInt32 nNew ) { nCurFormatKey = nNew; }
150 sal_uInt32 GetCurNumFmtKey() const { return nCurFormatKey; }
151 LanguageType GetCurLanguage() const { return eCurLanguage; }
152
155 OUString GetStandardName() const;
156
157 OUString GetComment4Entry(short nEntry);
158 short GetCategory4Entry(short nEntry) const;
159 bool GetUserDefined4Entry(short nEntry);
160 OUString GetFormat4Entry(short nEntry);
161 void SetComment4Entry(short nEntry, const OUString& aCommentString);
162
163 void SetCurrencySymbol(sal_uInt32 nPos);
164 sal_uInt32 GetCurrencySymbol() const { return nCurCurrencyEntryPos;}
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, std::u16string_view rFmtString );
169
170 void GetCurrencySymbols(std::vector<OUString>& rList, sal_uInt16* pPos );
171
172 sal_uInt16 FindCurrencyTableEntry( const OUString& rFmtString, bool &bTestBanking );
173 bool IsInTable(sal_uInt16 nPos, bool bTmpBanking,
174 std::u16string_view rFmtString) const;
175
176 void SetUseStarFormat( bool bUse ) { bUseStarFormat = bUse; }
177private:
181 OUString aValStr;
182 double nValNum;
184 std::vector<sal_uInt32> aAddList;
185 std::vector<sal_uInt32> aDelList;
186 std::vector<sal_uInt32> aCurEntryList;
187 sal_uInt32 nCurFormatKey;
190 std::vector<sal_uInt16> aCurCurrencyList;
191 NfCurrencyEntry* pCurCurrencyEntry;
194 std::vector<OUString> aCurrencyFormatList;
197
198 SVX_DLLPRIVATE short FillEntryList_Impl( std::vector<OUString>& rList );
199 SVX_DLLPRIVATE void FillEListWithStd_Impl( std::vector<OUString>& rList, SvNumFormatType eCategory, short &Pos,
200 bool bSuppressDuplicates = false );
201 SVX_DLLPRIVATE short FillEListWithFormats_Impl( std::vector<OUString>& rList,short nSelPos,
202 NfIndexTableOffset eOffsetStart,
203 NfIndexTableOffset eOffsetEnd,
204 bool bSuppressDuplicates );
205 SVX_DLLPRIVATE short FillEListWithDateTime_Impl( std::vector<OUString>& rList,short nSelPos,
206 bool bSuppressDuplicates );
207 SVX_DLLPRIVATE void FillEListWithOneFormat_Impl( std::vector<OUString>& rList, short & nSelPos,
208 bool bSuppressDuplicates, NfIndexTableOffset nOffset,
209 bool bSuppressIsoDateTime );
210 SVX_DLLPRIVATE short FillEListWithCurrency_Impl( std::vector<OUString>& rList,short nSelPos);
211 SVX_DLLPRIVATE short FillEListWithSysCurrencys( std::vector<OUString>& rList,short nSelPos);
212 SVX_DLLPRIVATE short FillEListWithUserCurrencys( std::vector<OUString>& rList,short nSelPos);
213 SVX_DLLPRIVATE short FillEListWithUsD_Impl( std::vector<OUString>& rList, SvNumFormatType eCategory, short Pos );
214
215 SVX_DLLPRIVATE bool IsEssentialFormat_Impl( SvNumFormatType eType, sal_uInt32 nKey );
216
217 SVX_DLLPRIVATE ::std::vector<sal_uInt32>::iterator GetRemoved_Impl( size_t nKey );
218 SVX_DLLPRIVATE bool IsRemoved_Impl( size_t nKey );
219 SVX_DLLPRIVATE ::std::vector<sal_uInt32>::iterator GetAdded_Impl( size_t nKey );
220
221 SVX_DLLPRIVATE void GetPreviewString_Impl( OUString& rString,
222 const Color*& rpColor );
223 SVX_DLLPRIVATE static void PosToCategory_Impl(sal_uInt16 nPos, SvNumFormatType& rCategory);
224 SVX_DLLPRIVATE static void CategoryToPos_Impl(SvNumFormatType nCategory, sal_uInt16& rPos);
225};
226
227#endif
228
229/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 GetCurrencySymbol() const
Definition: numfmtsh.hxx:164
SvxNumberValueType eValType
Definition: numfmtsh.hxx:180
sal_uInt32 nCurFormatKey
Definition: numfmtsh.hxx:187
LanguageType eCurLanguage
Definition: numfmtsh.hxx:189
void SetCurNumFmtKey(sal_uInt32 nNew)
Definition: numfmtsh.hxx:149
std::vector< sal_uInt16 > aCurCurrencyList
Definition: numfmtsh.hxx:190
std::vector< sal_uInt32 > aCurEntryList
Definition: numfmtsh.hxx:186
std::vector< sal_uInt32 > aAddList
Definition: numfmtsh.hxx:184
std::vector< OUString > aCurrencyFormatList
Definition: numfmtsh.hxx:194
sal_uInt32 nCurCurrencyEntryPos
Definition: numfmtsh.hxx:193
SvNumberFormatter * pFormatter
Definition: numfmtsh.hxx:178
NfCurrencyEntry * pCurCurrencyEntry
Definition: numfmtsh.hxx:191
LanguageType GetCurLanguage() const
Definition: numfmtsh.hxx:151
std::vector< sal_uInt32 > aDelList
Definition: numfmtsh.hxx:185
sal_uInt32 GetCurNumFmtKey() const
Definition: numfmtsh.hxx:150
SvNumberFormatTable * pCurFmtTable
Definition: numfmtsh.hxx:179
void SetUseStarFormat(bool bUse)
Definition: numfmtsh.hxx:176
SvNumFormatType nCurCategory
Definition: numfmtsh.hxx:188
DocumentType eType
sal_Int16 nValue
Definition: fmsrccfg.cxx:81
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
SvxNumberValueType
Definition: numfmtsh.hxx:34
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
std::map< sal_uInt32, SvNumberformat * > SvNumberFormatTable
SvNumFormatType
NfIndexTableOffset