Breeze: Add Save All & Save a Copy icons
[LibreOffice.git] / include / xmloff / xmlnumfi.hxx
blob84c6113ab80e090d493cbbf2f05f6a7f3740b045
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 .
20 #ifndef INCLUDED_XMLOFF_XMLNUMFI_HXX
21 #define INCLUDED_XMLOFF_XMLNUMFI_HXX
23 #include <sal/config.h>
24 #include <xmloff/dllapi.h>
25 #include <sal/types.h>
26 #include <xmloff/xmlstyle.hxx>
27 #include <rtl/ustrbuf.hxx>
28 #include <i18nlangtag/lang.h>
29 #include <memory>
30 #include <vector>
32 namespace com::sun::star::uno { class XComponentContext; }
33 namespace com::sun::star::util { class XNumberFormatsSupplier; }
34 namespace com::sun::star::xml::sax { class XAttributeList; }
36 #define XML_NUMBERSTYLES "NumberStyles"
38 enum class SvXMLStylesTokens
40 NUMBER_STYLE,
41 CURRENCY_STYLE,
42 PERCENTAGE_STYLE,
43 DATE_STYLE,
44 TIME_STYLE,
45 BOOLEAN_STYLE,
46 TEXT_STYLE
49 enum SvXMLDateElementAttributes
51 XML_DEA_NONE,
52 XML_DEA_ANY,
53 XML_DEA_SHORT,
54 XML_DEA_LONG,
55 XML_DEA_TEXTSHORT,
56 XML_DEA_TEXTLONG
59 class Color;
60 class SvXMLNumImpData;
61 class SvXMLImport;
62 struct SvXMLNumberInfo;
63 class SvNumberFormatter;
64 class LocaleDataWrapper;
67 // use SvXMLNumFmtHelper in the context for <office:styles> to create
68 // child contexts for data styles
70 class SvXMLNumFmtHelper
72 std::unique_ptr<SvXMLNumImpData> pData;
74 public:
75 SvXMLNumFmtHelper(
76 const css::uno::Reference< css::util::XNumberFormatsSupplier >& rSupp,
77 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
79 SvXMLNumFmtHelper(
80 SvNumberFormatter* pNumberFormatter,
81 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
83 ~SvXMLNumFmtHelper();
85 SvXMLStyleContext* CreateChildContext( SvXMLImport& rImport,
86 sal_Int32 nElement,
87 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
88 SvXMLStylesContext& rStyles);
90 SvXMLNumImpData* getData() { return pData.get(); }
92 LanguageType GetLanguageForKey(sal_Int32 nKey);
94 // sal_uInt32 GetKeyForName( const OUString& rName );
97 // SvXMLNumFmtDefaults is used in import and export
99 class SvXMLNumFmtDefaults
101 public:
102 // return value is NfIndexTableOffset
103 static sal_uInt16 GetDefaultDateFormat( SvXMLDateElementAttributes eDOW,
104 SvXMLDateElementAttributes eDay, SvXMLDateElementAttributes eMonth,
105 SvXMLDateElementAttributes eYear, SvXMLDateElementAttributes eHours,
106 SvXMLDateElementAttributes eMins, SvXMLDateElementAttributes eSecs,
107 bool bSystem );
110 struct MyCondition
112 OUString sCondition;
113 OUString sMapName;
116 class XMLOFF_DLLPUBLIC SvXMLNumFormatContext : public SvXMLStyleContext
118 public:
119 enum ImplicitCalendar
121 DEFAULT,
122 SECONDARY,
123 OTHER,
124 DEFAULT_FROM_OTHER,
125 SECONDARY_FROM_OTHER
128 private:
130 SvXMLNumImpData* pData;
131 SvXMLStylesContext* pStyles;
132 std::vector <MyCondition> aMyConditions;
133 SvXMLStylesTokens nType;
134 sal_Int32 nKey;
135 // OUString sFormatName;
136 OUString sFormatTitle;
137 // OUString sMapName;
138 OUString sCalendar;
139 OUString aImplicitCalendar[2];
140 ImplicitCalendar eImplicitCalendar;
141 LanguageType nFormatLang;
142 bool bAutoOrder;
143 bool bFromSystem;
144 bool bTruncate;
145 bool bAutoDec; // set in AddNumber
146 bool bAutoInt; // set in AddNumber
147 bool bHasExtraText;
148 OUStringBuffer aFormatCode{64};
149 OUStringBuffer aConditions{32};
150 bool bHasLongDoW;
151 bool bHasEra;
152 bool bHasDateTime;
153 bool bRemoveAfterUse;
155 // contained date elements, used to recognize default date formats
156 SvXMLDateElementAttributes eDateDOW;
157 SvXMLDateElementAttributes eDateDay;
158 SvXMLDateElementAttributes eDateMonth;
159 SvXMLDateElementAttributes eDateYear;
160 SvXMLDateElementAttributes eDateHours;
161 SvXMLDateElementAttributes eDateMins;
162 SvXMLDateElementAttributes eDateSecs;
163 bool bDateNoDefault;
165 SAL_DLLPRIVATE sal_Int32 PrivateGetKey();
167 public:
168 SvXMLNumFormatContext( SvXMLImport& rImport,
169 sal_Int32 nElement,
170 SvXMLNumImpData* pNewData,
171 SvXMLStylesTokens nNewType,
172 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
173 SvXMLStylesContext& rStyles );
174 SvXMLNumFormatContext( SvXMLImport& rImport,
175 const OUString& rName,
176 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
177 const sal_Int32 nKey,
178 LanguageType nLang,
179 SvXMLStylesContext& rStyles );
180 virtual ~SvXMLNumFormatContext() override;
182 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
183 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
184 virtual void CreateAndInsert(bool bOverwrite) override;
186 sal_Int32 GetKey();
187 sal_Int32 CreateAndInsert( SvNumberFormatter* pFormatter );
188 sal_Int32 CreateAndInsert( css::uno::Reference< css::util::XNumberFormatsSupplier > const & xFormatsSupplier );
189 SvXMLStylesTokens GetType() const { return nType; } // SvXMLStylesTokens
191 bool HasLongDoW() const { return bHasLongDoW; }
192 void SetHasLongDoW(bool bSet) { bHasLongDoW = bSet; }
194 void UpdateCalendar( const OUString& rNewCalendar );
195 ImplicitCalendar GetImplicitCalendarState() const { return eImplicitCalendar; }
197 const LocaleDataWrapper& GetLocaleData() const;
199 void AddToCode( std::u16string_view rString );
200 void AddToCode( sal_Unicode c );
201 void AddNumber( const SvXMLNumberInfo& rInfo );
202 void AddCurrency( const OUString& rContent, LanguageType nLang );
204 void AddNfKeyword( sal_uInt16 nIndex );
205 bool ReplaceNfKeyword( sal_uInt16 nOld, sal_uInt16 nNew );
206 void AddCondition( const sal_Int32 nIndex );
207 void AddCondition( const OUString& rCondition, const OUString& rApplyName );
208 void AddColor( Color nColor );
210 /// determine whether number format uses the system language
211 bool IsSystemLanguage() const;
214 #endif
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */