LibreOffice Module xmloff (master) 1
xmlnumfi.hxx
Go to the documentation of this file.
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 INCLUDED_XMLOFF_XMLNUMFI_HXX
21#define INCLUDED_XMLOFF_XMLNUMFI_HXX
22
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>
29#include <memory>
30#include <vector>
31
32namespace com::sun::star::uno { class XComponentContext; }
33namespace com::sun::star::util { class XNumberFormatsSupplier; }
34namespace com::sun::star::xml::sax { class XAttributeList; }
35
36inline constexpr OUStringLiteral XML_NUMBERSTYLES = u"NumberStyles";
37
39{
47};
48
50{
57};
58
59class Color;
60class SvXMLNumImpData;
61class SvXMLImport;
62struct SvXMLNumberInfo;
65
66
67// use SvXMLNumFmtHelper in the context for <office:styles> to create
68// child contexts for data styles
69
71{
72 std::unique_ptr<SvXMLNumImpData> m_pData;
73
74public:
76 const css::uno::Reference< css::util::XNumberFormatsSupplier >& rSupp,
77 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
78
80 SvNumberFormatter* pNumberFormatter,
81 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
82
84
85 SvXMLStyleContext* CreateChildContext( SvXMLImport& rImport,
86 sal_Int32 nElement,
87 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
88 SvXMLStylesContext& rStyles);
89
90 SvXMLNumImpData* getData() { return m_pData.get(); }
91
92 LanguageType GetLanguageForKey(sal_Int32 nKey) const;
93
94// sal_uInt32 GetKeyForName( const OUString& rName );
95};
96
97// SvXMLNumFmtDefaults is used in import and export
98
100{
101public:
102 // return value is NfIndexTableOffset
103 static sal_uInt16 GetDefaultDateFormat( SvXMLDateElementAttributes eDOW,
107 bool bSystem );
108};
109
111{
112 OUString sCondition;
113 OUString sMapName;
114};
115
117{
118public:
120 {
125 SECONDARY_FROM_OTHER
126 };
127
128private:
129
132 std::vector <MyCondition> m_aMyConditions;
134 sal_Int32 m_nKey;
135// OUString sFormatName;
137// OUString sMapName;
138 OUString m_sCalendar;
139 OUString m_aImplicitCalendar[2];
145 bool m_bAutoDec; // set in AddNumber
146 bool m_bAutoInt; // set in AddNumber
149 OUStringBuffer m_aFormatCode{64};
150 OUStringBuffer m_aConditions{32};
154
155 // contained date elements, used to recognize default date formats
164
165 SAL_DLLPRIVATE sal_Int32 PrivateGetKey();
166
167public:
168 SvXMLNumFormatContext( SvXMLImport& rImport,
169 sal_Int32 nElement,
170 SvXMLNumImpData* pNewData,
171 SvXMLStylesTokens nNewType,
172 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
173 SvXMLStylesContext& rStyles );
174 SvXMLNumFormatContext( SvXMLImport& rImport,
175 const OUString& rName,
176 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
177 const sal_Int32 nKey,
178 LanguageType nLang,
179 SvXMLStylesContext& rStyles );
180 virtual ~SvXMLNumFormatContext() override;
181
182 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
183 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
184 virtual void CreateAndInsert(bool bOverwrite) override;
185
186 sal_Int32 GetKey();
187 sal_Int32 CreateAndInsert( SvNumberFormatter* pFormatter );
188 sal_Int32 CreateAndInsert( css::uno::Reference< css::util::XNumberFormatsSupplier > const & xFormatsSupplier );
189 SvXMLStylesTokens GetType() const { return m_nType; } // SvXMLStylesTokens
190
191 bool HasLongDoW() const { return m_bHasLongDoW; }
192 void SetHasLongDoW(bool bSet) { m_bHasLongDoW = bSet; }
193 void SetHasTrailingEmptyText(bool bSet) { m_bHasTrailingEmptyText = bSet; }
194
195 void UpdateCalendar( const OUString& rNewCalendar );
196 ImplicitCalendar GetImplicitCalendarState() const { return m_eImplicitCalendar; }
197
198 const LocaleDataWrapper& GetLocaleData() const;
199
200 void AddToCode( std::u16string_view rString );
201 void AddToCode( sal_Unicode c );
202 void AddNumber( const SvXMLNumberInfo& rInfo );
203 void AddCurrency( const OUString& rContent, LanguageType nLang );
204
205 void AddNfKeyword( sal_uInt16 nIndex );
206 bool ReplaceNfKeyword( sal_uInt16 nOld, sal_uInt16 nNew );
207 void AddCondition( const sal_Int32 nIndex );
208 void AddCondition( const OUString& rCondition, const OUString& rApplyName );
209 void AddColor( Color nColor );
210
212 bool IsSystemLanguage() const;
213};
214
215#endif
216
217/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:59
static sal_uInt16 GetDefaultDateFormat(SvXMLDateElementAttributes eDOW, SvXMLDateElementAttributes eDay, SvXMLDateElementAttributes eMonth, SvXMLDateElementAttributes eYear, SvXMLDateElementAttributes eHours, SvXMLDateElementAttributes eMins, SvXMLDateElementAttributes eSecs, bool bSystem)
Definition: xmlnumfi.cxx:1110
SvXMLNumFmtHelper(SvNumberFormatter *pNumberFormatter, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
LanguageType GetLanguageForKey(sal_Int32 nKey) const
Definition: xmlnumfi.cxx:2245
std::unique_ptr< SvXMLNumImpData > m_pData
Definition: xmlnumfi.hxx:72
SvXMLStyleContext * CreateChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, SvXMLStylesContext &rStyles)
Definition: xmlnumfi.cxx:2208
SvXMLNumImpData * getData()
Definition: xmlnumfi.hxx:90
SvXMLNumFmtHelper(const css::uno::Reference< css::util::XNumberFormatsSupplier > &rSupp, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
SvXMLDateElementAttributes m_eDateSecs
Definition: xmlnumfi.hxx:162
ImplicitCalendar m_eImplicitCalendar
Definition: xmlnumfi.hxx:140
SvXMLStylesContext * m_pStyles
Definition: xmlnumfi.hxx:131
SvXMLNumImpData * m_pData
Definition: xmlnumfi.hxx:130
std::vector< MyCondition > m_aMyConditions
Definition: xmlnumfi.hxx:132
SvXMLNumFormatContext(SvXMLImport &rImport, const OUString &rName, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, const sal_Int32 nKey, LanguageType nLang, SvXMLStylesContext &rStyles)
void SetHasTrailingEmptyText(bool bSet)
Definition: xmlnumfi.hxx:193
SvXMLNumFormatContext(SvXMLImport &rImport, sal_Int32 nElement, SvXMLNumImpData *pNewData, SvXMLStylesTokens nNewType, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, SvXMLStylesContext &rStyles)
SvXMLDateElementAttributes m_eDateDOW
Definition: xmlnumfi.hxx:156
SvXMLDateElementAttributes m_eDateDay
Definition: xmlnumfi.hxx:157
SvXMLStylesTokens m_nType
Definition: xmlnumfi.hxx:133
SvXMLDateElementAttributes m_eDateMonth
Definition: xmlnumfi.hxx:158
void SetHasLongDoW(bool bSet)
Definition: xmlnumfi.hxx:192
SvXMLDateElementAttributes m_eDateHours
Definition: xmlnumfi.hxx:160
ImplicitCalendar GetImplicitCalendarState() const
Definition: xmlnumfi.hxx:196
bool HasLongDoW() const
Definition: xmlnumfi.hxx:191
SvXMLDateElementAttributes m_eDateYear
Definition: xmlnumfi.hxx:159
SvXMLDateElementAttributes m_eDateMins
Definition: xmlnumfi.hxx:161
LanguageType m_nFormatLang
Definition: xmlnumfi.hxx:141
SvXMLStylesTokens GetType() const
Definition: xmlnumfi.hxx:189
virtual void CreateAndInsert(bool bOverwrite)
Definition: xmlstyle.cxx:139
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
float u
const LocaleDataWrapper & GetLocaleData()
OUString sCondition
Definition: xmlnumfi.hxx:112
OUString sMapName
Definition: xmlnumfi.hxx:113
sal_uInt16 sal_Unicode
SvXMLDateElementAttributes
Definition: xmlnumfi.hxx:50
@ XML_DEA_SHORT
Definition: xmlnumfi.hxx:53
@ XML_DEA_ANY
Definition: xmlnumfi.hxx:52
@ XML_DEA_TEXTLONG
Definition: xmlnumfi.hxx:56
@ XML_DEA_TEXTSHORT
Definition: xmlnumfi.hxx:55
@ XML_DEA_LONG
Definition: xmlnumfi.hxx:54
@ XML_DEA_NONE
Definition: xmlnumfi.hxx:51
constexpr OUStringLiteral XML_NUMBERSTYLES
Definition: xmlnumfi.hxx:36
SvXMLStylesTokens
Definition: xmlnumfi.hxx:39