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
42{
54};
55
56#define SELPOS_NONE -1
57
58#define NUMBERFORMAT_ENTRY_NEW_CURRENCY NUMBERFORMAT_ENTRY_NOT_FOUND-1
59
60
62{
63public:
65 sal_uInt32 nFormatKey,
66 SvxNumberValueType eNumValType,
67 const OUString& rNumStr );
68
70 sal_uInt32 nFormatKey,
71 SvxNumberValueType eNumValType,
72 double nNumVal,
73 const OUString* pNumStr );
74
76
77
78 static SvxNumberFormatShell* Create( SvNumberFormatter* pNumFormatter,
79 sal_uInt32 nFormatKey,
80 SvxNumberValueType eNumValType,
81 const OUString& rNumStr );
82
83 static SvxNumberFormatShell* Create( SvNumberFormatter* pNumFormatter,
84 sal_uInt32 nFormatKey,
85 SvxNumberValueType eNumValType,
86 double nNumVal,
87 const OUString* pNumStr );
88
89
90 void GetInitSettings( sal_uInt16& nCatLbPos,
91 LanguageType& rLangType,
92 sal_uInt16& nFmtLbSelPos,
93 std::vector<OUString>& rFmtEntries,
94 OUString& rPrevString,
95 const Color*& rpPrevColor );
96
97 void CategoryChanged( sal_uInt16 nCatLbPos,
98 short& rFmtSelPos,
99 std::vector<OUString>& rFmtEntries );
100
101 void LanguageChanged( LanguageType eLangType,
102 short& rFmtSelPos,
103 std::vector<OUString>& rFmtEntries );
104
105 void FormatChanged( sal_uInt16 nFmtLbPos,
106 OUString& rPreviewStr,
107 const Color*& rpFontColor );
108
109 bool AddFormat( OUString& rFormat,
110 sal_Int32& rErrPos,
111 sal_uInt16& rCatLbSelPos,
112 short& rFmtSelPos,
113 std::vector<OUString>& rFmtEntries );
114
115 void RemoveFormat( std::u16string_view rFormat,
116 sal_uInt16& rCatLbSelPos,
117 short& rFmtSelPos,
118 std::vector<OUString>& rFmtEntries );
119
120 void MakeFormat( OUString& rFormat,
121 bool bThousand,
122 bool bNegRed,
123 sal_uInt16 nPrecision,
124 sal_uInt16 nLeadingZeroes,
125 sal_uInt16 nCurrencyEntryPos);
126
127 void GetOptions( const OUString& rFormat,
128 bool& rThousand,
129 bool& rNegRed,
130 sal_uInt16& rPrecision,
131 sal_uInt16& rLeadingZeroes,
132 sal_uInt16& rCatLbPos );
133
134 sal_uInt16 GetFormatIntegerDigits( std::u16string_view rFormat ) const;
135
136 bool IsNatNum12( std::u16string_view rFormat ) const;
137
138 void MakePreviewString( const OUString& rFormatStr,
139 OUString& rPreviewStr,
140 const Color*& rpFontColor );
141
142 void MakePrevStringFromVal( const OUString& rFormatStr,
143 OUString& rPreviewStr,
144 const Color*& rpFontColor,
145 double nValue);
146
147 bool IsUserDefined( const OUString& rFmtString );
148 bool IsTmpCurrencyFormat( const OUString& rFmtString );
149 bool FindEntry( const OUString& rFmtString, sal_uInt32* pAt = nullptr );
150
151 void ValidateNewEntries() { bUndoAddList = false; }
152 std::vector<sal_uInt32> const & GetUpdateData() const;
153
154 void SetCurNumFmtKey( sal_uInt32 nNew ) { nCurFormatKey = nNew; }
155 sal_uInt32 GetCurNumFmtKey() const { return nCurFormatKey; }
156 LanguageType GetCurLanguage() const { return eCurLanguage; }
157
160 OUString GetStandardName() const;
161
162 OUString GetComment4Entry(short nEntry);
163 short GetCategory4Entry(short nEntry) const;
164 bool GetUserDefined4Entry(short nEntry);
165 OUString GetFormat4Entry(short nEntry);
166 void SetComment4Entry(short nEntry, const OUString& aCommentString);
167
168 void SetCurrencySymbol(sal_uInt32 nPos);
169 sal_uInt32 GetCurrencySymbol() const { return nCurCurrencyEntryPos;}
170 sal_uInt16 FindCurrencyFormat( const OUString& rFmtString );
171 sal_uInt16 FindCurrencyFormat(const NfCurrencyEntry* pTmpCurrencyEntry,bool bTmpBanking);
172 void SetCurCurrencyEntry(NfCurrencyEntry*);
173 short GetListPos4Entry( sal_uInt32 nIdx, std::u16string_view rFmtString );
174
175 void GetCurrencySymbols(std::vector<OUString>& rList, sal_uInt16* pPos );
176
177 sal_uInt16 FindCurrencyTableEntry( const OUString& rFmtString, bool &bTestBanking );
178 bool IsInTable(sal_uInt16 nPos, bool bTmpBanking,
179 std::u16string_view rFmtString) const;
180
181 void SetUseStarFormat( bool bUse ) { bUseStarFormat = bUse; }
182private:
186 OUString aValStr;
187 double nValNum;
189 std::vector<sal_uInt32> aAddList;
190 std::vector<sal_uInt32> aDelList;
191 std::vector<sal_uInt32> aCurEntryList;
192 sal_uInt32 nCurFormatKey;
195 std::vector<sal_uInt16> aCurCurrencyList;
196 NfCurrencyEntry* pCurCurrencyEntry;
199 std::vector<OUString> aCurrencyFormatList;
202
203 SVX_DLLPRIVATE short FillEntryList_Impl( std::vector<OUString>& rList );
204 SVX_DLLPRIVATE void FillEListWithStd_Impl( std::vector<OUString>& rList, SvNumFormatType eCategory, short &Pos,
205 bool bSuppressDuplicates = false );
206 SVX_DLLPRIVATE short FillEListWithFormats_Impl( std::vector<OUString>& rList,short nSelPos,
207 NfIndexTableOffset eOffsetStart,
208 NfIndexTableOffset eOffsetEnd,
209 bool bSuppressDuplicates );
210 SVX_DLLPRIVATE short FillEListWithDateTime_Impl( std::vector<OUString>& rList,short nSelPos,
211 bool bSuppressDuplicates );
212 SVX_DLLPRIVATE void FillEListWithOneFormat_Impl( std::vector<OUString>& rList, short & nSelPos,
213 bool bSuppressDuplicates, NfIndexTableOffset nOffset,
214 bool bSuppressIsoDateTime );
215 SVX_DLLPRIVATE short FillEListWithCurrency_Impl( std::vector<OUString>& rList,short nSelPos);
216 SVX_DLLPRIVATE short FillEListWithSysCurrencys( std::vector<OUString>& rList,short nSelPos);
217 SVX_DLLPRIVATE short FillEListWithUserCurrencys( std::vector<OUString>& rList,short nSelPos);
218 SVX_DLLPRIVATE short FillEListWithUsD_Impl( std::vector<OUString>& rList, SvNumFormatType eCategory, short Pos );
219
220 SVX_DLLPRIVATE bool IsEssentialFormat_Impl( SvNumFormatType eType, sal_uInt32 nKey );
221
222 SVX_DLLPRIVATE ::std::vector<sal_uInt32>::iterator GetRemoved_Impl( size_t nKey );
223 SVX_DLLPRIVATE bool IsRemoved_Impl( size_t nKey );
224 SVX_DLLPRIVATE ::std::vector<sal_uInt32>::iterator GetAdded_Impl( size_t nKey );
225
226 SVX_DLLPRIVATE void GetPreviewString_Impl( OUString& rString,
227 const Color*& rpColor );
228 SVX_DLLPRIVATE static void PosToCategory_Impl(sal_uInt16 nPos, SvNumFormatType& rCategory);
229 SVX_DLLPRIVATE static void CategoryToPos_Impl(SvNumFormatType nCategory, sal_uInt16& rPos);
230};
231
232#endif
233
234/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 GetCurrencySymbol() const
Definition: numfmtsh.hxx:169
SvxNumberValueType eValType
Definition: numfmtsh.hxx:185
sal_uInt32 nCurFormatKey
Definition: numfmtsh.hxx:192
LanguageType eCurLanguage
Definition: numfmtsh.hxx:194
void SetCurNumFmtKey(sal_uInt32 nNew)
Definition: numfmtsh.hxx:154
std::vector< sal_uInt16 > aCurCurrencyList
Definition: numfmtsh.hxx:195
std::vector< sal_uInt32 > aCurEntryList
Definition: numfmtsh.hxx:191
std::vector< sal_uInt32 > aAddList
Definition: numfmtsh.hxx:189
std::vector< OUString > aCurrencyFormatList
Definition: numfmtsh.hxx:199
sal_uInt32 nCurCurrencyEntryPos
Definition: numfmtsh.hxx:198
SvNumberFormatter * pFormatter
Definition: numfmtsh.hxx:183
NfCurrencyEntry * pCurCurrencyEntry
Definition: numfmtsh.hxx:196
LanguageType GetCurLanguage() const
Definition: numfmtsh.hxx:156
std::vector< sal_uInt32 > aDelList
Definition: numfmtsh.hxx:190
sal_uInt32 GetCurNumFmtKey() const
Definition: numfmtsh.hxx:155
SvNumberFormatTable * pCurFmtTable
Definition: numfmtsh.hxx:184
void SetUseStarFormat(bool bUse)
Definition: numfmtsh.hxx:181
SvNumFormatType nCurCategory
Definition: numfmtsh.hxx:193
DocumentType eType
sal_Int16 nValue
Definition: fmsrccfg.cxx:81
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
SvxNumberFormatCategory
Definition: numfmtsh.hxx:42
@ CAT_TIME
Definition: numfmtsh.hxx:49
@ CAT_USERDEFINED
Definition: numfmtsh.hxx:44
@ CAT_TEXT
Definition: numfmtsh.hxx:53
@ CAT_NUMBER
Definition: numfmtsh.hxx:45
@ CAT_DATE
Definition: numfmtsh.hxx:48
@ CAT_ALL
Definition: numfmtsh.hxx:43
@ CAT_CURRENCY
Definition: numfmtsh.hxx:47
@ CAT_PERCENT
Definition: numfmtsh.hxx:46
@ CAT_BOOLEAN
Definition: numfmtsh.hxx:52
@ CAT_SCIENTIFIC
Definition: numfmtsh.hxx:50
@ CAT_FRACTION
Definition: numfmtsh.hxx:51
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