Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / xmloff / xmlnumfi.hxx
blob8a9d7d589d0e0cbe8648a6933d9aba66ea18da79
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 <com/sun/star/util/XNumberFormatsSupplier.hpp>
27 #include <com/sun/star/xml/sax/XAttributeList.hpp>
28 #include <xmloff/xmlstyle.hxx>
29 #include <rtl/ustrbuf.hxx>
30 #include <i18nlangtag/lang.h>
31 #include <memory>
32 #include <vector>
33 #include <unotools/localedatawrapper.hxx>
35 #define XML_NUMBERSTYLES "NumberStyles"
37 enum SvXMLStylesTokens
39 XML_TOK_STYLES_NUMBER_STYLE,
40 XML_TOK_STYLES_CURRENCY_STYLE,
41 XML_TOK_STYLES_PERCENTAGE_STYLE,
42 XML_TOK_STYLES_DATE_STYLE,
43 XML_TOK_STYLES_TIME_STYLE,
44 XML_TOK_STYLES_BOOLEAN_STYLE,
45 XML_TOK_STYLES_TEXT_STYLE
48 enum SvXMLDateElementAttributes
50 XML_DEA_NONE,
51 XML_DEA_ANY,
52 XML_DEA_SHORT,
53 XML_DEA_LONG,
54 XML_DEA_TEXTSHORT,
55 XML_DEA_TEXTLONG
58 class Color;
59 class SvXMLNumImpData;
60 class SvXMLImport;
61 class SvXMLStyleContext;
62 class SvXMLStylesContext;
63 struct SvXMLNumberInfo;
64 class SvNumberFormatter;
65 class SvtSysLocale;
66 namespace com { namespace sun { namespace star { namespace lang {
67 class XMultiServiceFactory;
68 }}}}
71 // use SvXMLNumFmtHelper in the context for <office:styles> to create
72 // child contexts for data styles
74 class SvXMLNumFmtHelper
76 std::unique_ptr<SvXMLNumImpData> pData;
78 public:
79 SvXMLNumFmtHelper(
80 const css::uno::Reference< css::util::XNumberFormatsSupplier >& rSupp,
81 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
83 SvXMLNumFmtHelper(
84 SvNumberFormatter* pNumberFormatter,
85 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
87 ~SvXMLNumFmtHelper();
89 SvXMLStyleContext* CreateChildContext( SvXMLImport& rImport,
90 sal_uInt16 nPrefix,
91 const OUString& rLocalName,
92 const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
93 SvXMLStylesContext& rStyles);
95 SvXMLNumImpData* getData() { return pData.get(); }
97 const SvXMLTokenMap& GetStylesElemTokenMap();
99 // sal_uInt32 GetKeyForName( const OUString& rName );
102 // SvXMLNumFmtDefaults is used in import and export
104 class SvXMLNumFmtDefaults
106 public:
107 // return value is NfIndexTableOffset
108 static sal_uInt16 GetDefaultDateFormat( SvXMLDateElementAttributes eDOW,
109 SvXMLDateElementAttributes eDay, SvXMLDateElementAttributes eMonth,
110 SvXMLDateElementAttributes eYear, SvXMLDateElementAttributes eHours,
111 SvXMLDateElementAttributes eMins, SvXMLDateElementAttributes eSecs,
112 bool bSystem );
115 struct MyCondition
117 OUString sCondition;
118 OUString sMapName;
121 class XMLOFF_DLLPUBLIC SvXMLNumFormatContext : public SvXMLStyleContext
123 SvXMLNumImpData* pData;
124 SvXMLStylesContext* pStyles;
125 std::vector <MyCondition> aMyConditions;
126 sal_uInt16 nType;
127 sal_Int32 nKey;
128 // OUString sFormatName;
129 OUString sFormatTitle;
130 // OUString sMapName;
131 OUString sCalendar;
132 LanguageType nFormatLang;
133 bool bAutoOrder;
134 bool bFromSystem;
135 bool bTruncate;
136 bool bAutoDec; // set in AddNumber
137 bool bAutoInt; // set in AddNumber
138 bool bHasExtraText;
139 OUStringBuffer aFormatCode;
140 OUStringBuffer aConditions;
141 bool bHasLongDoW;
142 bool bHasEra;
143 bool bHasDateTime;
144 bool bRemoveAfterUse;
146 // contained date elements, used to recognize default date formats
147 SvXMLDateElementAttributes eDateDOW;
148 SvXMLDateElementAttributes eDateDay;
149 SvXMLDateElementAttributes eDateMonth;
150 SvXMLDateElementAttributes eDateYear;
151 SvXMLDateElementAttributes eDateHours;
152 SvXMLDateElementAttributes eDateMins;
153 SvXMLDateElementAttributes eDateSecs;
154 bool bDateNoDefault;
156 SAL_DLLPRIVATE sal_Int32 PrivateGetKey();
158 public:
159 SvXMLNumFormatContext( SvXMLImport& rImport,
160 sal_uInt16 nPrfx,
161 const OUString& rLName,
162 SvXMLNumImpData* pNewData,
163 sal_uInt16 nNewType,
164 const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
165 SvXMLStylesContext& rStyles );
166 SvXMLNumFormatContext( SvXMLImport& rImport,
167 sal_uInt16 nPrfx,
168 const OUString& rLName,
169 const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
170 const sal_Int32 nKey,
171 SvXMLStylesContext& rStyles );
172 virtual ~SvXMLNumFormatContext() override;
174 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
175 const OUString& rLocalName,
176 const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
177 virtual void CreateAndInsert(bool bOverwrite) override;
179 SvXMLNumImpData* GetData() const { return pData; }
180 sal_Int32 GetKey();
181 sal_Int32 CreateAndInsert( SvNumberFormatter* pFormatter );
182 sal_Int32 CreateAndInsert( css::uno::Reference< css::util::XNumberFormatsSupplier >& xFormatsSupplier );
183 sal_uInt16 GetType() const { return nType; } // SvXMLStylesTokens
185 bool HasLongDoW() const { return bHasLongDoW; }
186 void SetHasLongDoW(bool bSet) { bHasLongDoW = bSet; }
187 bool HasEra() const { return bHasEra; }
189 void UpdateCalendar( const OUString& rNewCalendar, bool bImplicitSecondaryCalendarEC = false );
191 const LocaleDataWrapper& GetLocaleData() const;
193 void AddToCode( const OUString& rString );
194 void AddToCode( sal_Unicode c );
195 void AddNumber( const SvXMLNumberInfo& rInfo );
196 void AddCurrency( const OUString& rContent, LanguageType nLang );
198 void AddNfKeyword( sal_uInt16 nIndex );
199 bool ReplaceNfKeyword( sal_uInt16 nOld, sal_uInt16 nNew );
200 void AddCondition( const sal_Int32 nIndex );
201 void AddCondition( const OUString& rCondition, const OUString& rApplyName );
202 void AddColor( sal_uInt32 const nColor );
204 /// determine whether number format uses the system language
205 bool IsSystemLanguage();
208 #endif
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */