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 
32 namespace com::sun::star::uno { class XComponentContext; }
33 namespace com::sun::star::util { class XNumberFormatsSupplier; }
34 namespace com::sun::star::xml::sax { class XAttributeList; }
35 
36 #define XML_NUMBERSTYLES "NumberStyles"
37 
39 {
47 };
48 
50 {
57 };
58 
59 class Color;
60 class SvXMLNumImpData;
61 class SvXMLImport;
62 struct SvXMLNumberInfo;
63 class SvNumberFormatter;
64 class LocaleDataWrapper;
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> pData;
73 
74 public:
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 
86  sal_uInt16 nPrefix,
87  const OUString& rLocalName,
88  const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
89  SvXMLStylesContext& rStyles);
90 
91  SvXMLNumImpData* getData() { return pData.get(); }
92 
94  LanguageType GetLanguageForKey(sal_Int32 nKey);
95 
96 // sal_uInt32 GetKeyForName( const OUString& rName );
97 };
98 
99 // SvXMLNumFmtDefaults is used in import and export
100 
102 {
103 public:
104  // return value is NfIndexTableOffset
105  static sal_uInt16 GetDefaultDateFormat( SvXMLDateElementAttributes eDOW,
109  bool bSystem );
110 };
111 
113 {
114  OUString sCondition;
115  OUString sMapName;
116 };
117 
119 {
122  std::vector <MyCondition> aMyConditions;
123  sal_uInt16 nType;
124  sal_Int32 nKey;
125 // OUString sFormatName;
126  OUString sFormatTitle;
127 // OUString sMapName;
128  OUString sCalendar;
132  bool bTruncate;
133  bool bAutoDec; // set in AddNumber
134  bool bAutoInt; // set in AddNumber
136  OUStringBuffer aFormatCode{64};
137  OUStringBuffer aConditions{32};
139  bool bHasEra;
142 
143  // contained date elements, used to recognize default date formats
152 
153  SAL_DLLPRIVATE sal_Int32 PrivateGetKey();
154 
155 public:
157  sal_uInt16 nPrfx,
158  const OUString& rLName,
159  SvXMLNumImpData* pNewData,
160  sal_uInt16 nNewType,
161  const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
162  SvXMLStylesContext& rStyles );
164  sal_uInt16 nPrfx,
165  const OUString& rLName,
166  const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
167  const sal_Int32 nKey,
168  LanguageType nLang,
169  SvXMLStylesContext& rStyles );
170  virtual ~SvXMLNumFormatContext() override;
171 
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;
176 
177  SvXMLNumImpData* GetData() const { return pData; }
178  sal_Int32 GetKey();
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
182 
183  bool HasLongDoW() const { return bHasLongDoW; }
184  void SetHasLongDoW(bool bSet) { bHasLongDoW = bSet; }
185  bool HasEra() const { return bHasEra; }
186 
187  void UpdateCalendar( const OUString& rNewCalendar, bool bImplicitSecondaryCalendarEC = false );
188 
189  const LocaleDataWrapper& GetLocaleData() const;
190 
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 );
195 
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 );
201 
203  bool IsSystemLanguage() const;
204 };
205 
206 #endif
207 
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvXMLNumImpData * GetData() const
Definition: xmlnumfi.hxx:177
LanguageType nFormatLang
Definition: xmlnumfi.hxx:129
OUString sCondition
Definition: xmlnumfi.hxx:114
SvXMLDateElementAttributes eDateSecs
Definition: xmlnumfi.hxx:150
SvXMLDateElementAttributes eDateDay
Definition: xmlnumfi.hxx:145
sal_uInt16 sal_Unicode
SvXMLNumImpData * pData
Definition: xmlnumfi.hxx:120
std::vector< MyCondition > aMyConditions
Definition: xmlnumfi.hxx:122
SvXMLStylesContext * pStyles
Definition: xmlnumfi.hxx:121
OUString sMapName
Definition: xmlnumfi.hxx:115
LanguageType GetLanguageForKey(sal_Int32 nKey)
Definition: xmlnumfi.cxx:2305
SvXMLDateElementAttributes eDateMonth
Definition: xmlnumfi.hxx:146
SvXMLDateElementAttributes
Definition: xmlnumfi.hxx:49
void SetHasLongDoW(bool bSet)
Definition: xmlnumfi.hxx:184
SvXMLDateElementAttributes eDateDOW
Definition: xmlnumfi.hxx:144
SvXMLStyleContext * CreateChildContext(SvXMLImport &rImport, sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList, SvXMLStylesContext &rStyles)
Definition: xmlnumfi.cxx:2273
SvXMLStylesTokens
Definition: xmlnumfi.hxx:38
bool HasEra() const
Definition: xmlnumfi.hxx:185
SvXMLDateElementAttributes eDateHours
Definition: xmlnumfi.hxx:148
SvXMLNumImpData * getData()
Definition: xmlnumfi.hxx:91
SvXMLNumFmtHelper(const css::uno::Reference< css::util::XNumberFormatsSupplier > &rSupp, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual void CreateAndInsert(bool bOverwrite)
Definition: xmlstyle.cxx:189
std::unique_ptr< SvXMLNumImpData > pData
Definition: xmlnumfi.hxx:72
sal_uInt16 GetType() const
Definition: xmlnumfi.hxx:181
static sal_uInt16 GetDefaultDateFormat(SvXMLDateElementAttributes eDOW, SvXMLDateElementAttributes eDay, SvXMLDateElementAttributes eMonth, SvXMLDateElementAttributes eYear, SvXMLDateElementAttributes eHours, SvXMLDateElementAttributes eMins, SvXMLDateElementAttributes eSecs, bool bSystem)
Definition: xmlnumfi.cxx:1302
const SvXMLTokenMap & GetStylesElemTokenMap()
Definition: xmlnumfi.cxx:2300
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
Create a children element context.
Definition: xmlictxt.cxx:51
bool HasLongDoW() const
Definition: xmlnumfi.hxx:183
SvXMLDateElementAttributes eDateMins
Definition: xmlnumfi.hxx:149
SvXMLDateElementAttributes eDateYear
Definition: xmlnumfi.hxx:147
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
const LocaleDataWrapper & GetLocaleData()