Bump version to 6.4-15
[LibreOffice.git] / include / xmloff / xmlnumfi.hxx
blobf772a54b4d28f3ce40b3dc8a78eff4361008dfe5
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 { namespace sun { namespace star { namespace uno { class XComponentContext; } } } }
33 namespace com { namespace sun { namespace star { namespace util { class XNumberFormatsSupplier; } } } }
34 namespace com { namespace sun { namespace star { namespace xml { namespace sax { class XAttributeList; } } } } }
36 #define XML_NUMBERSTYLES "NumberStyles"
38 enum SvXMLStylesTokens
40 XML_TOK_STYLES_NUMBER_STYLE,
41 XML_TOK_STYLES_CURRENCY_STYLE,
42 XML_TOK_STYLES_PERCENTAGE_STYLE,
43 XML_TOK_STYLES_DATE_STYLE,
44 XML_TOK_STYLES_TIME_STYLE,
45 XML_TOK_STYLES_BOOLEAN_STYLE,
46 XML_TOK_STYLES_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_uInt16 nPrefix,
87 const OUString& rLocalName,
88 const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
89 SvXMLStylesContext& rStyles);
91 SvXMLNumImpData* getData() { return pData.get(); }
93 const SvXMLTokenMap& GetStylesElemTokenMap();
94 LanguageType GetLanguageForKey(sal_Int32 nKey);
96 // sal_uInt32 GetKeyForName( const OUString& rName );
99 // SvXMLNumFmtDefaults is used in import and export
101 class SvXMLNumFmtDefaults
103 public:
104 // return value is NfIndexTableOffset
105 static sal_uInt16 GetDefaultDateFormat( SvXMLDateElementAttributes eDOW,
106 SvXMLDateElementAttributes eDay, SvXMLDateElementAttributes eMonth,
107 SvXMLDateElementAttributes eYear, SvXMLDateElementAttributes eHours,
108 SvXMLDateElementAttributes eMins, SvXMLDateElementAttributes eSecs,
109 bool bSystem );
112 struct MyCondition
114 OUString sCondition;
115 OUString sMapName;
118 class XMLOFF_DLLPUBLIC SvXMLNumFormatContext : public SvXMLStyleContext
120 SvXMLNumImpData* pData;
121 SvXMLStylesContext* const pStyles;
122 std::vector <MyCondition> aMyConditions;
123 sal_uInt16 const nType;
124 sal_Int32 nKey;
125 // OUString sFormatName;
126 OUString sFormatTitle;
127 // OUString sMapName;
128 OUString sCalendar;
129 LanguageType nFormatLang;
130 bool bAutoOrder;
131 bool bFromSystem;
132 bool bTruncate;
133 bool bAutoDec; // set in AddNumber
134 bool bAutoInt; // set in AddNumber
135 bool bHasExtraText;
136 OUStringBuffer aFormatCode{64};
137 OUStringBuffer aConditions{32};
138 bool bHasLongDoW;
139 bool bHasEra;
140 bool bHasDateTime;
141 bool bRemoveAfterUse;
143 // contained date elements, used to recognize default date formats
144 SvXMLDateElementAttributes eDateDOW;
145 SvXMLDateElementAttributes eDateDay;
146 SvXMLDateElementAttributes eDateMonth;
147 SvXMLDateElementAttributes eDateYear;
148 SvXMLDateElementAttributes eDateHours;
149 SvXMLDateElementAttributes eDateMins;
150 SvXMLDateElementAttributes eDateSecs;
151 bool bDateNoDefault;
153 SAL_DLLPRIVATE sal_Int32 PrivateGetKey();
155 public:
156 SvXMLNumFormatContext( SvXMLImport& rImport,
157 sal_uInt16 nPrfx,
158 const OUString& rLName,
159 SvXMLNumImpData* pNewData,
160 sal_uInt16 nNewType,
161 const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
162 SvXMLStylesContext& rStyles );
163 SvXMLNumFormatContext( SvXMLImport& rImport,
164 sal_uInt16 nPrfx,
165 const OUString& rLName,
166 const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
167 const sal_Int32 nKey,
168 LanguageType nLang,
169 SvXMLStylesContext& rStyles );
170 virtual ~SvXMLNumFormatContext() override;
172 virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
173 const OUString& rLocalName,
174 const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
175 virtual void CreateAndInsert(bool bOverwrite) override;
177 SvXMLNumImpData* GetData() const { return pData; }
178 sal_Int32 GetKey();
179 sal_Int32 CreateAndInsert( SvNumberFormatter* pFormatter );
180 sal_Int32 CreateAndInsert( css::uno::Reference< css::util::XNumberFormatsSupplier > const & xFormatsSupplier );
181 sal_uInt16 GetType() const { return nType; } // SvXMLStylesTokens
183 bool HasLongDoW() const { return bHasLongDoW; }
184 void SetHasLongDoW(bool bSet) { bHasLongDoW = bSet; }
185 bool HasEra() const { return bHasEra; }
187 void UpdateCalendar( const OUString& rNewCalendar, bool bImplicitSecondaryCalendarEC = false );
189 const LocaleDataWrapper& GetLocaleData() const;
191 void AddToCode( const OUString& rString );
192 void AddToCode( sal_Unicode c );
193 void AddNumber( const SvXMLNumberInfo& rInfo );
194 void AddCurrency( const OUString& rContent, LanguageType nLang );
196 void AddNfKeyword( sal_uInt16 nIndex );
197 bool ReplaceNfKeyword( sal_uInt16 nOld, sal_uInt16 nNew );
198 void AddCondition( const sal_Int32 nIndex );
199 void AddCondition( const OUString& rCondition, const OUString& rApplyName );
200 void AddColor( Color nColor );
202 /// determine whether number format uses the system language
203 bool IsSystemLanguage() const;
206 #endif
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */