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 
30 class Color;
31 
33 {
34  Undefined,
35  Number,
36  String
37 };
38 
39 // sort order of the category ListBox entries in the TabPage
40 #define CAT_ALL 0
41 #define CAT_USERDEFINED 1
42 #define CAT_NUMBER 2
43 #define CAT_PERCENT 3
44 #define CAT_CURRENCY 4
45 #define CAT_DATE 5
46 #define CAT_TIME 6
47 #define CAT_SCIENTIFIC 7
48 #define CAT_FRACTION 8
49 #define CAT_BOOLEAN 9
50 #define CAT_TEXT 10
51 
52 #define SELPOS_NONE -1
53 
54 #define NUMBERFORMAT_ENTRY_NEW_CURRENCY NUMBERFORMAT_ENTRY_NOT_FOUND-1
55 
56 
58 {
59 public:
61  sal_uInt32 nFormatKey,
62  SvxNumberValueType eNumValType,
63  const OUString& rNumStr );
64 
66  sal_uInt32 nFormatKey,
67  SvxNumberValueType eNumValType,
68  double nNumVal,
69  const OUString* pNumStr );
70 
72 
73 
74  static SvxNumberFormatShell* Create( SvNumberFormatter* pNumFormatter,
75  sal_uInt32 nFormatKey,
76  SvxNumberValueType eNumValType,
77  const OUString& rNumStr );
78 
79  static SvxNumberFormatShell* Create( SvNumberFormatter* pNumFormatter,
80  sal_uInt32 nFormatKey,
81  SvxNumberValueType eNumValType,
82  double nNumVal,
83  const OUString* pNumStr );
84 
85 
86  void GetInitSettings( sal_uInt16& nCatLbPos,
87  LanguageType& rLangType,
88  sal_uInt16& nFmtLbSelPos,
89  std::vector<OUString>& rFmtEntries,
90  OUString& rPrevString,
91  const Color*& rpPrevColor );
92 
93  void CategoryChanged( sal_uInt16 nCatLbPos,
94  short& rFmtSelPos,
95  std::vector<OUString>& rFmtEntries );
96 
97  void LanguageChanged( LanguageType eLangType,
98  short& rFmtSelPos,
99  std::vector<OUString>& rFmtEntries );
100 
101  void FormatChanged( sal_uInt16 nFmtLbPos,
102  OUString& rPreviewStr,
103  const Color*& rpFontColor );
104 
105  bool AddFormat( OUString& rFormat,
106  sal_Int32& rErrPos,
107  sal_uInt16& rCatLbSelPos,
108  short& rFmtSelPos,
109  std::vector<OUString>& rFmtEntries );
110 
111  void RemoveFormat( std::u16string_view rFormat,
112  sal_uInt16& rCatLbSelPos,
113  short& rFmtSelPos,
114  std::vector<OUString>& rFmtEntries );
115 
116  void MakeFormat( OUString& rFormat,
117  bool bThousand,
118  bool bNegRed,
119  sal_uInt16 nPrecision,
120  sal_uInt16 nLeadingZeroes,
121  sal_uInt16 nCurrencyEntryPos);
122 
123  void GetOptions( const OUString& rFormat,
124  bool& rThousand,
125  bool& rNegRed,
126  sal_uInt16& rPrecision,
127  sal_uInt16& rLeadingZeroes,
128  sal_uInt16& rCatLbPos );
129 
130  sal_uInt16 GetFormatIntegerDigits( std::u16string_view rFormat ) const;
131 
132  void MakePreviewString( const OUString& rFormatStr,
133  OUString& rPreviewStr,
134  const Color*& rpFontColor );
135 
136  void MakePrevStringFromVal( const OUString& rFormatStr,
137  OUString& rPreviewStr,
138  const Color*& rpFontColor,
139  double nValue);
140 
141  bool IsUserDefined( const OUString& rFmtString );
142  bool IsTmpCurrencyFormat( const OUString& rFmtString );
143  bool FindEntry( const OUString& rFmtString, sal_uInt32* pAt = nullptr );
144 
145  void ValidateNewEntries() { bUndoAddList = false; }
146  std::vector<sal_uInt32> const & GetUpdateData() const;
147 
148  void SetCurNumFmtKey( sal_uInt32 nNew ) { nCurFormatKey = nNew; }
149  sal_uInt32 GetCurNumFmtKey() const { return nCurFormatKey; }
150  LanguageType GetCurLanguage() const { return eCurLanguage; }
151 
154  OUString GetStandardName() const;
155 
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);
161 
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, std::u16string_view rFmtString );
168 
169  void GetCurrencySymbols(std::vector<OUString>& rList, sal_uInt16* pPos );
170 
171  sal_uInt16 FindCurrencyTableEntry( const OUString& rFmtString, bool &bTestBanking );
172  bool IsInTable(sal_uInt16 nPos, bool bTmpBanking,
173  std::u16string_view rFmtString);
174 
175  void SetUseStarFormat( bool bUse ) { bUseStarFormat = bUse; }
176 private:
180  OUString aValStr;
181  double nValNum;
183  std::vector<sal_uInt32> aAddList;
184  std::vector<sal_uInt32> aDelList;
185  std::vector<sal_uInt32> aCurEntryList;
186  sal_uInt32 nCurFormatKey;
189  std::vector<sal_uInt16> aCurCurrencyList;
190  NfCurrencyEntry* pCurCurrencyEntry;
193  std::vector<OUString> aCurrencyFormatList;
196 
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 void FillEListWithOneFormat_Impl( std::vector<OUString>& rList, short & nSelPos,
207  bool bSuppressDuplicates, NfIndexTableOffset nOffset,
208  bool bSuppressIsoDateTime );
209  SVX_DLLPRIVATE short FillEListWithCurrency_Impl( std::vector<OUString>& rList,short nSelPos);
210  SVX_DLLPRIVATE short FillEListWithSysCurrencys( std::vector<OUString>& rList,short nSelPos);
211  SVX_DLLPRIVATE short FillEListWithUserCurrencys( std::vector<OUString>& rList,short nSelPos);
212  SVX_DLLPRIVATE short FillEListWithUsD_Impl( std::vector<OUString>& rList, SvNumFormatType eCategory, short Pos );
213 
214  SVX_DLLPRIVATE bool IsEssentialFormat_Impl( SvNumFormatType eType, sal_uInt32 nKey );
215 
216  SVX_DLLPRIVATE ::std::vector<sal_uInt32>::iterator GetRemoved_Impl( size_t nKey );
217  SVX_DLLPRIVATE bool IsRemoved_Impl( size_t nKey );
218  SVX_DLLPRIVATE ::std::vector<sal_uInt32>::iterator GetAdded_Impl( size_t nKey );
219 
220  SVX_DLLPRIVATE void GetPreviewString_Impl( OUString& rString,
221  const Color*& rpColor );
222  SVX_DLLPRIVATE static void PosToCategory_Impl(sal_uInt16 nPos, SvNumFormatType& rCategory);
223  SVX_DLLPRIVATE static void CategoryToPos_Impl(SvNumFormatType nCategory, sal_uInt16& rPos);
224 };
225 
226 #endif
227 
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvNumberFormatTable * pCurFmtTable
Definition: numfmtsh.hxx:178
SvxNumberValueType eValType
Definition: numfmtsh.hxx:179
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
std::vector< sal_uInt16 > aCurCurrencyList
Definition: numfmtsh.hxx:189
std::vector< OUString > aCurrencyFormatList
Definition: numfmtsh.hxx:193
SvNumberFormatter * pFormatter
Definition: numfmtsh.hxx:177
SvxNumberValueType
Definition: numfmtsh.hxx:32
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
sal_uInt32 GetCurNumFmtKey() const
Definition: numfmtsh.hxx:149
NfIndexTableOffset
sal_uInt32 nCurCurrencyEntryPos
Definition: numfmtsh.hxx:192
DocumentType eType
void SetUseStarFormat(bool bUse)
Definition: numfmtsh.hxx:175
void SetCurNumFmtKey(sal_uInt32 nNew)
Definition: numfmtsh.hxx:148
std::map< sal_uInt32, SvNumberformat * > SvNumberFormatTable
SvNumFormatType
std::vector< sal_uInt32 > aDelList
Definition: numfmtsh.hxx:184
sal_uInt32 GetCurrencySymbol() const
Definition: numfmtsh.hxx:163
std::vector< sal_uInt32 > aAddList
Definition: numfmtsh.hxx:183
std::vector< sal_uInt32 > aCurEntryList
Definition: numfmtsh.hxx:185
SvNumFormatType nCurCategory
Definition: numfmtsh.hxx:187
sal_uInt32 nCurFormatKey
Definition: numfmtsh.hxx:186
NfCurrencyEntry * pCurCurrencyEntry
Definition: numfmtsh.hxx:190
LanguageType eCurLanguage
Definition: numfmtsh.hxx:188
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
LanguageType GetCurLanguage() const
Definition: numfmtsh.hxx:150
sal_Int16 nValue
Definition: fmsrccfg.cxx:81