fix build
[LibreOffice.git] / include / svx / numfmtsh.hxx
blobdb593eb8b77dfef8989f44204957308acf3fb80c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
28 #include <vector>
30 class Color;
31 class SvNumberFormatter;
33 enum class SvxNumberValueType
35 Undefined,
36 Number,
37 String
40 // sort order of the category ListBox entries in the TabPage
41 enum SvxNumberFormatCategory
43 CAT_ALL = 0,
44 CAT_USERDEFINED,
45 CAT_NUMBER,
46 CAT_PERCENT,
47 CAT_CURRENCY,
48 CAT_DATE,
49 CAT_TIME,
50 CAT_SCIENTIFIC,
51 CAT_FRACTION,
52 CAT_BOOLEAN,
53 CAT_TEXT
56 #define SELPOS_NONE -1
58 #define NUMBERFORMAT_ENTRY_NEW_CURRENCY NUMBERFORMAT_ENTRY_NOT_FOUND-1
61 class SVX_DLLPUBLIC SvxNumberFormatShell
63 public:
64 SvxNumberFormatShell( SvNumberFormatter* pNumFormatter,
65 sal_uInt32 nFormatKey,
66 SvxNumberValueType eNumValType,
67 const OUString& rNumStr );
69 SvxNumberFormatShell( SvNumberFormatter* pNumFormatter,
70 sal_uInt32 nFormatKey,
71 SvxNumberValueType eNumValType,
72 double nNumVal,
73 const OUString* pNumStr );
75 ~SvxNumberFormatShell();
78 static SvxNumberFormatShell* Create( SvNumberFormatter* pNumFormatter,
79 sal_uInt32 nFormatKey,
80 SvxNumberValueType eNumValType,
81 const OUString& rNumStr );
83 static SvxNumberFormatShell* Create( SvNumberFormatter* pNumFormatter,
84 sal_uInt32 nFormatKey,
85 SvxNumberValueType eNumValType,
86 double nNumVal,
87 const OUString* pNumStr );
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 );
97 void CategoryChanged( sal_uInt16 nCatLbPos,
98 short& rFmtSelPos,
99 std::vector<OUString>& rFmtEntries );
101 void LanguageChanged( LanguageType eLangType,
102 short& rFmtSelPos,
103 std::vector<OUString>& rFmtEntries );
105 void FormatChanged( sal_uInt16 nFmtLbPos,
106 OUString& rPreviewStr,
107 const Color*& rpFontColor );
109 bool AddFormat( OUString& rFormat,
110 sal_Int32& rErrPos,
111 sal_uInt16& rCatLbSelPos,
112 short& rFmtSelPos,
113 std::vector<OUString>& rFmtEntries );
115 void RemoveFormat( std::u16string_view rFormat,
116 sal_uInt16& rCatLbSelPos,
117 short& rFmtSelPos,
118 std::vector<OUString>& rFmtEntries );
120 void MakeFormat( OUString& rFormat,
121 bool bThousand,
122 bool bNegRed,
123 sal_uInt16 nPrecision,
124 sal_uInt16 nLeadingZeroes,
125 sal_uInt16 nCurrencyEntryPos);
127 void GetOptions( const OUString& rFormat,
128 bool& rThousand,
129 bool& rNegRed,
130 sal_uInt16& rPrecision,
131 sal_uInt16& rLeadingZeroes,
132 sal_uInt16& rCatLbPos );
134 sal_uInt16 GetFormatIntegerDigits( std::u16string_view rFormat ) const;
136 bool IsNatNum12( std::u16string_view rFormat ) const;
138 void MakePreviewString( const OUString& rFormatStr,
139 OUString& rPreviewStr,
140 const Color*& rpFontColor );
142 void MakePrevStringFromVal( const OUString& rFormatStr,
143 OUString& rPreviewStr,
144 const Color*& rpFontColor,
145 double nValue);
147 bool IsUserDefined( const OUString& rFmtString );
148 bool IsTmpCurrencyFormat( const OUString& rFmtString );
149 bool FindEntry( const OUString& rFmtString, sal_uInt32* pAt = nullptr );
151 void ValidateNewEntries() { bUndoAddList = false; }
152 std::vector<sal_uInt32> const & GetUpdateData() const;
154 void SetCurNumFmtKey( sal_uInt32 nNew ) { nCurFormatKey = nNew; }
155 sal_uInt32 GetCurNumFmtKey() const { return nCurFormatKey; }
156 LanguageType GetCurLanguage() const { return eCurLanguage; }
158 /** Returns the name of Standard, General, ... for the
159 current language. */
160 OUString GetStandardName() const;
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);
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 );
175 void GetCurrencySymbols(std::vector<OUString>& rList, sal_uInt16* pPos );
177 sal_uInt16 FindCurrencyTableEntry( const OUString& rFmtString, bool &bTestBanking );
178 bool IsInTable(sal_uInt16 nPos, bool bTmpBanking,
179 std::u16string_view rFmtString) const;
181 void SetUseStarFormat( bool bUse ) { bUseStarFormat = bUse; }
182 private:
183 SvNumberFormatter* pFormatter;
184 SvNumberFormatTable* pCurFmtTable;
185 SvxNumberValueType eValType;
186 OUString aValStr;
187 double nValNum;
188 bool bUndoAddList;
189 std::vector<sal_uInt32> aAddList;
190 std::vector<sal_uInt32> aDelList;
191 std::vector<sal_uInt32> aCurEntryList;
192 sal_uInt32 nCurFormatKey;
193 SvNumFormatType nCurCategory;
194 LanguageType eCurLanguage;
195 std::vector<sal_uInt16> aCurCurrencyList;
196 NfCurrencyEntry* pCurCurrencyEntry;
197 bool bBankingSymbol;
198 sal_uInt32 nCurCurrencyEntryPos;
199 std::vector<OUString> aCurrencyFormatList;
200 bool bUseStarFormat;
201 bool bIsDefaultValNum;
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 );
220 SVX_DLLPRIVATE bool IsEssentialFormat_Impl( SvNumFormatType eType, sal_uInt32 nKey );
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 );
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);
232 #endif
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */