Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _XMLOFF_XMLNUMFI_HXX
21 : #define _XMLOFF_XMLNUMFI_HXX
22 :
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 <i18npool/lang.h>
31 : #include <vector>
32 : #include <unotools/localedatawrapper.hxx>
33 :
34 : #define XML_NUMBERSTYLES "NumberStyles"
35 :
36 : enum SvXMLStylesTokens
37 : {
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
45 : };
46 :
47 : enum SvXMLDateElementAttributes
48 : {
49 : XML_DEA_NONE,
50 : XML_DEA_ANY,
51 : XML_DEA_SHORT,
52 : XML_DEA_LONG,
53 : XML_DEA_TEXTSHORT,
54 : XML_DEA_TEXTLONG
55 : };
56 :
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 : }}}}
68 :
69 :
70 : // use SvXMLNumFmtHelper in the context for <office:styles> to create
71 : // child contexts for data styles
72 :
73 : class SvXMLNumFmtHelper
74 : {
75 : SvXMLNumImpData* pData;
76 :
77 : // #110680#
78 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxServiceFactory;
79 :
80 : public:
81 : // #110680#
82 : //SvXMLNumFmtHelper( const ::com::sun::star::uno::Reference<
83 : // ::com::sun::star::util::XNumberFormatsSupplier >& rSupp );
84 : //SvXMLNumFmtHelper( SvNumberFormatter* pNumberFormatter );
85 : SvXMLNumFmtHelper(
86 : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& rSupp,
87 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory );
88 :
89 : SvXMLNumFmtHelper(
90 : SvNumberFormatter* pNumberFormatter,
91 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory );
92 :
93 : ~SvXMLNumFmtHelper();
94 :
95 : SvXMLStyleContext* CreateChildContext( SvXMLImport& rImport,
96 : sal_uInt16 nPrefix, const rtl::OUString& rLocalName,
97 : const ::com::sun::star::uno::Reference<
98 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
99 : SvXMLStylesContext& rStyles);
100 :
101 0 : SvXMLNumImpData* getData() { return pData; }
102 :
103 : const SvXMLTokenMap& GetStylesElemTokenMap();
104 :
105 : // sal_uInt32 GetKeyForName( const rtl::OUString& rName );
106 : };
107 :
108 : // SvXMLNumFmtDefaults is used in import and export
109 :
110 : class SvXMLNumFmtDefaults
111 : {
112 : public:
113 : // return value is NfIndexTableOffset
114 : static sal_uInt16 GetDefaultDateFormat( SvXMLDateElementAttributes eDOW,
115 : SvXMLDateElementAttributes eDay, SvXMLDateElementAttributes eMonth,
116 : SvXMLDateElementAttributes eYear, SvXMLDateElementAttributes eHours,
117 : SvXMLDateElementAttributes eMins, SvXMLDateElementAttributes eSecs,
118 : sal_Bool bSystem );
119 : };
120 :
121 332 : struct MyCondition
122 : {
123 : rtl::OUString sCondition;
124 : rtl::OUString sMapName;
125 : };
126 :
127 : class XMLOFF_DLLPUBLIC SvXMLNumFormatContext : public SvXMLStyleContext
128 : {
129 : SvXMLNumImpData* pData;
130 : SvXMLStylesContext* pStyles;
131 : std::vector <MyCondition> aMyConditions;
132 : sal_uInt16 nType;
133 : sal_Int32 nKey;
134 : // rtl::OUString sFormatName;
135 : rtl::OUString sFormatTitle;
136 : // rtl::OUString sMapName;
137 : rtl::OUString sCalendar;
138 : rtl::OUString sFormatString;
139 : LanguageType nFormatLang;
140 : com::sun::star::lang::Locale aLocale;
141 : sal_Bool bAutoOrder;
142 : sal_Bool bFromSystem;
143 : sal_Bool bTruncate;
144 : sal_Bool bAutoDec; // set in AddNumber
145 : sal_Bool bAutoInt; // set in AddNumber
146 : sal_Bool bHasExtraText;
147 : rtl::OUStringBuffer aFormatCode;
148 : rtl::OUStringBuffer aConditions;
149 : sal_Bool bHasLongDoW;
150 : sal_Bool bHasEra;
151 : sal_Bool bHasDateTime;
152 : sal_Bool bRemoveAfterUse;
153 :
154 : // contained date elements, used to recognize default date formats
155 : SvXMLDateElementAttributes eDateDOW;
156 : SvXMLDateElementAttributes eDateDay;
157 : SvXMLDateElementAttributes eDateMonth;
158 : SvXMLDateElementAttributes eDateYear;
159 : SvXMLDateElementAttributes eDateHours;
160 : SvXMLDateElementAttributes eDateMins;
161 : SvXMLDateElementAttributes eDateSecs;
162 : sal_Bool bDateNoDefault;
163 :
164 : SAL_DLLPRIVATE sal_Int32 PrivateGetKey();
165 :
166 : public:
167 : SvXMLNumFormatContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
168 : const rtl::OUString& rLName,
169 : SvXMLNumImpData* pNewData, sal_uInt16 nNewType,
170 : const ::com::sun::star::uno::Reference<
171 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
172 : SvXMLStylesContext& rStyles );
173 : SvXMLNumFormatContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
174 : const rtl::OUString& rLName,
175 : const ::com::sun::star::uno::Reference<
176 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
177 : const sal_Int32 nKey,
178 : SvXMLStylesContext& rStyles );
179 : virtual ~SvXMLNumFormatContext();
180 :
181 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
182 : const rtl::OUString& rLocalName,
183 : const ::com::sun::star::uno::Reference<
184 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
185 : virtual void CreateAndInsert(sal_Bool bOverwrite);
186 : virtual void Finish(sal_Bool bOverwrite);
187 :
188 533 : SvXMLNumImpData* GetData() const { return pData; }
189 : sal_Int32 GetKey();
190 : sal_Int32 CreateAndInsert( SvNumberFormatter* pFormatter );
191 : sal_Int32 CreateAndInsert( com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >& xFormatsSupplier );
192 214 : sal_uInt16 GetType() const { return nType; } // SvXMLStylesTokens
193 :
194 : sal_Bool IsFromSystem() const { return bFromSystem; }
195 193 : sal_Bool HasLongDoW() const { return bHasLongDoW; }
196 0 : void SetHasLongDoW(sal_Bool bSet) { bHasLongDoW = bSet; }
197 9 : sal_Bool HasEra() const { return bHasEra; }
198 : void SetHasEra(sal_Bool bSet) { bHasEra = bSet; }
199 :
200 : void UpdateCalendar( const rtl::OUString& rNewCalendar );
201 :
202 : const LocaleDataWrapper& GetLocaleData() const;
203 :
204 : void AddToCode( const rtl::OUString& rString );
205 : void AddToCode( sal_Unicode c );
206 : void AddNumber( const SvXMLNumberInfo& rInfo );
207 : void AddCurrency( const rtl::OUString& rContent, LanguageType nLang );
208 :
209 : void AddNfKeyword( sal_uInt16 nIndex );
210 : sal_Bool ReplaceNfKeyword( sal_uInt16 nOld, sal_uInt16 nNew );
211 : void AddCondition( const sal_Int32 nIndex );
212 : void AddCondition( const rtl::OUString& rCondition, const rtl::OUString& rApplyName );
213 : void AddColor( sal_uInt32 const nColor );
214 :
215 : /// determine whether number format uses the system language
216 : sal_Bool IsSystemLanguage();
217 : };
218 :
219 : #endif
220 :
221 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|