Branch libreoffice-5-0-4
[LibreOffice.git] / include / xmloff / xmlnumfi.hxx
blobe3426ac72dd7dae71a2bfd462eb56afdba619e34
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 <vector>
32 #include <unotools/localedatawrapper.hxx>
34 #define XML_NUMBERSTYLES "NumberStyles"
36 enum SvXMLStylesTokens
38 XML_TOK_STYLES_NUMBER_STYLE,
39 XML_TOK_STYLES_CURRENCY_STYLE,
40 XML_TOK_STYLES_PERCENTAGE_STYLE,
41 XML_TOK_STYLES_DATE_STYLE,
42 XML_TOK_STYLES_TIME_STYLE,
43 XML_TOK_STYLES_BOOLEAN_STYLE,
44 XML_TOK_STYLES_TEXT_STYLE
47 enum SvXMLDateElementAttributes
49 XML_DEA_NONE,
50 XML_DEA_ANY,
51 XML_DEA_SHORT,
52 XML_DEA_LONG,
53 XML_DEA_TEXTSHORT,
54 XML_DEA_TEXTLONG
57 class Color;
58 class SvXMLNumImpData;
59 class SvXMLImport;
60 class SvXMLStyleContext;
61 class SvXMLStylesContext;
62 struct SvXMLNumberInfo;
63 class SvNumberFormatter;
64 class SvtSysLocale;
65 namespace com { namespace sun { namespace star { namespace lang {
66 class XMultiServiceFactory;
67 }}}}
70 // use SvXMLNumFmtHelper in the context for <office:styles> to create
71 // child contexts for data styles
73 class SvXMLNumFmtHelper
75 SvXMLNumImpData* pData;
77 public:
78 SvXMLNumFmtHelper(
79 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& rSupp,
80 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
82 SvXMLNumFmtHelper(
83 SvNumberFormatter* pNumberFormatter,
84 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
86 ~SvXMLNumFmtHelper();
88 SvXMLStyleContext* CreateChildContext( SvXMLImport& rImport,
89 sal_uInt16 nPrefix, const OUString& rLocalName,
90 const ::com::sun::star::uno::Reference<
91 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
92 SvXMLStylesContext& rStyles);
94 SvXMLNumImpData* getData() { return pData; }
96 const SvXMLTokenMap& GetStylesElemTokenMap();
98 // sal_uInt32 GetKeyForName( const OUString& rName );
101 // SvXMLNumFmtDefaults is used in import and export
103 class SvXMLNumFmtDefaults
105 public:
106 // return value is NfIndexTableOffset
107 static sal_uInt16 GetDefaultDateFormat( SvXMLDateElementAttributes eDOW,
108 SvXMLDateElementAttributes eDay, SvXMLDateElementAttributes eMonth,
109 SvXMLDateElementAttributes eYear, SvXMLDateElementAttributes eHours,
110 SvXMLDateElementAttributes eMins, SvXMLDateElementAttributes eSecs,
111 bool bSystem );
114 struct MyCondition
116 OUString sCondition;
117 OUString sMapName;
120 class XMLOFF_DLLPUBLIC SvXMLNumFormatContext : public SvXMLStyleContext
122 SvXMLNumImpData* pData;
123 SvXMLStylesContext* pStyles;
124 std::vector <MyCondition> aMyConditions;
125 sal_uInt16 nType;
126 sal_Int32 nKey;
127 // OUString sFormatName;
128 OUString sFormatTitle;
129 // OUString sMapName;
130 OUString sCalendar;
131 LanguageType nFormatLang;
132 com::sun::star::lang::Locale aLocale;
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, sal_uInt16 nPrfx,
160 const OUString& rLName,
161 SvXMLNumImpData* pNewData, sal_uInt16 nNewType,
162 const ::com::sun::star::uno::Reference<
163 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
164 SvXMLStylesContext& rStyles );
165 SvXMLNumFormatContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
166 const OUString& rLName,
167 const ::com::sun::star::uno::Reference<
168 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
169 const sal_Int32 nKey,
170 SvXMLStylesContext& rStyles );
171 virtual ~SvXMLNumFormatContext();
173 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
174 const OUString& rLocalName,
175 const ::com::sun::star::uno::Reference<
176 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
177 virtual void CreateAndInsert(bool bOverwrite) SAL_OVERRIDE;
178 virtual void Finish(bool bOverwrite) SAL_OVERRIDE;
180 SvXMLNumImpData* GetData() const { return pData; }
181 sal_Int32 GetKey();
182 sal_Int32 CreateAndInsert( SvNumberFormatter* pFormatter );
183 sal_Int32 CreateAndInsert( com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >& xFormatsSupplier );
184 sal_uInt16 GetType() const { return nType; } // SvXMLStylesTokens
186 bool IsFromSystem() const { return bFromSystem; }
187 bool HasLongDoW() const { return bHasLongDoW; }
188 void SetHasLongDoW(bool bSet) { bHasLongDoW = bSet; }
189 bool HasEra() const { return bHasEra; }
190 void SetHasEra(bool bSet) { bHasEra = bSet; }
192 void UpdateCalendar( const OUString& rNewCalendar );
194 const LocaleDataWrapper& GetLocaleData() const;
196 void AddToCode( const OUString& rString );
197 void AddToCode( sal_Unicode c );
198 void AddNumber( const SvXMLNumberInfo& rInfo );
199 void AddCurrency( const OUString& rContent, LanguageType nLang );
201 void AddNfKeyword( sal_uInt16 nIndex );
202 bool ReplaceNfKeyword( sal_uInt16 nOld, sal_uInt16 nNew );
203 void AddCondition( const sal_Int32 nIndex );
204 void AddCondition( const OUString& rCondition, const OUString& rApplyName );
205 void AddColor( sal_uInt32 const nColor );
207 /// determine whether number format uses the system language
208 bool IsSystemLanguage();
211 #endif
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */