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 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>
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
60 class SvXMLNumImpData
;
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
;
76 const css::uno::Reference
< css::util::XNumberFormatsSupplier
>& rSupp
,
77 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
80 SvNumberFormatter
* pNumberFormatter
,
81 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
85 SvXMLStyleContext
* CreateChildContext( SvXMLImport
& rImport
,
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
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
,
118 class XMLOFF_DLLPUBLIC SvXMLNumFormatContext
: public SvXMLStyleContext
120 SvXMLNumImpData
* pData
;
121 SvXMLStylesContext
* const pStyles
;
122 std::vector
<MyCondition
> aMyConditions
;
123 sal_uInt16
const nType
;
125 // OUString sFormatName;
126 OUString sFormatTitle
;
127 // OUString sMapName;
129 LanguageType nFormatLang
;
133 bool bAutoDec
; // set in AddNumber
134 bool bAutoInt
; // set in AddNumber
136 OUStringBuffer aFormatCode
{64};
137 OUStringBuffer aConditions
{32};
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
;
153 SAL_DLLPRIVATE sal_Int32
PrivateGetKey();
156 SvXMLNumFormatContext( SvXMLImport
& rImport
,
158 const OUString
& rLName
,
159 SvXMLNumImpData
* pNewData
,
161 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
162 SvXMLStylesContext
& rStyles
);
163 SvXMLNumFormatContext( SvXMLImport
& rImport
,
165 const OUString
& rLName
,
166 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
167 const sal_Int32 nKey
,
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
; }
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;
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */