1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 _XMLOFF_XMLNUMFI_HXX
21 #define _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>
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
58 class SvXMLNumImpData
;
60 class SvXMLStyleContext
;
61 class SvXMLStylesContext
;
62 struct SvXMLNumberInfo
;
63 class SvNumberFormatter
;
65 namespace com
{ namespace sun
{ namespace star
{ namespace lang
{
66 class XMultiServiceFactory
;
70 // use SvXMLNumFmtHelper in the context for <office:styles> to create
71 // child contexts for data styles
73 class SvXMLNumFmtHelper
75 SvXMLNumImpData
* pData
;
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
);
83 SvNumberFormatter
* pNumberFormatter
,
84 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
);
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
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
,
120 class XMLOFF_DLLPUBLIC SvXMLNumFormatContext
: public SvXMLStyleContext
122 SvXMLNumImpData
* pData
;
123 SvXMLStylesContext
* pStyles
;
124 std::vector
<MyCondition
> aMyConditions
;
127 // OUString sFormatName;
128 OUString sFormatTitle
;
129 // OUString sMapName;
131 OUString sFormatString
;
132 LanguageType nFormatLang
;
133 com::sun::star::lang::Locale aLocale
;
135 sal_Bool bFromSystem
;
137 sal_Bool bAutoDec
; // set in AddNumber
138 sal_Bool bAutoInt
; // set in AddNumber
139 sal_Bool bHasExtraText
;
140 OUStringBuffer aFormatCode
;
141 OUStringBuffer aConditions
;
142 sal_Bool bHasLongDoW
;
144 sal_Bool bHasDateTime
;
145 sal_Bool bRemoveAfterUse
;
147 // contained date elements, used to recognize default date formats
148 SvXMLDateElementAttributes eDateDOW
;
149 SvXMLDateElementAttributes eDateDay
;
150 SvXMLDateElementAttributes eDateMonth
;
151 SvXMLDateElementAttributes eDateYear
;
152 SvXMLDateElementAttributes eDateHours
;
153 SvXMLDateElementAttributes eDateMins
;
154 SvXMLDateElementAttributes eDateSecs
;
155 sal_Bool bDateNoDefault
;
157 SAL_DLLPRIVATE sal_Int32
PrivateGetKey();
160 SvXMLNumFormatContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
161 const OUString
& rLName
,
162 SvXMLNumImpData
* pNewData
, sal_uInt16 nNewType
,
163 const ::com::sun::star::uno::Reference
<
164 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
165 SvXMLStylesContext
& rStyles
);
166 SvXMLNumFormatContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
167 const OUString
& rLName
,
168 const ::com::sun::star::uno::Reference
<
169 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
170 const sal_Int32 nKey
,
171 SvXMLStylesContext
& rStyles
);
172 virtual ~SvXMLNumFormatContext();
174 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
175 const OUString
& rLocalName
,
176 const ::com::sun::star::uno::Reference
<
177 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
178 virtual void CreateAndInsert(sal_Bool bOverwrite
);
179 virtual void Finish(sal_Bool bOverwrite
);
181 SvXMLNumImpData
* GetData() const { return pData
; }
183 sal_Int32
CreateAndInsert( SvNumberFormatter
* pFormatter
);
184 sal_Int32
CreateAndInsert( com::sun::star::uno::Reference
< com::sun::star::util::XNumberFormatsSupplier
>& xFormatsSupplier
);
185 sal_uInt16
GetType() const { return nType
; } // SvXMLStylesTokens
187 sal_Bool
IsFromSystem() const { return bFromSystem
; }
188 sal_Bool
HasLongDoW() const { return bHasLongDoW
; }
189 void SetHasLongDoW(sal_Bool bSet
) { bHasLongDoW
= bSet
; }
190 sal_Bool
HasEra() const { return bHasEra
; }
191 void SetHasEra(sal_Bool bSet
) { bHasEra
= bSet
; }
193 void UpdateCalendar( const OUString
& rNewCalendar
);
195 const LocaleDataWrapper
& GetLocaleData() const;
197 void AddToCode( const OUString
& rString
);
198 void AddToCode( sal_Unicode c
);
199 void AddNumber( const SvXMLNumberInfo
& rInfo
);
200 void AddCurrency( const OUString
& rContent
, LanguageType nLang
);
202 void AddNfKeyword( sal_uInt16 nIndex
);
203 sal_Bool
ReplaceNfKeyword( sal_uInt16 nOld
, sal_uInt16 nNew
);
204 void AddCondition( const sal_Int32 nIndex
);
205 void AddCondition( const OUString
& rCondition
, const OUString
& rApplyName
);
206 void AddColor( sal_uInt32
const nColor
);
208 /// determine whether number format uses the system language
209 sal_Bool
IsSystemLanguage();
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */