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 {
43  DATE_STYLE,
44  TIME_STYLE,
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_Int32 nElement,
87  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
88  SvXMLStylesContext& rStyles);
89 
90  SvXMLNumImpData* getData() { return pData.get(); }
91 
92  LanguageType GetLanguageForKey(sal_Int32 nKey);
93 
94 // sal_uInt32 GetKeyForName( const OUString& rName );
95 };
96 
97 // SvXMLNumFmtDefaults is used in import and export
98 
100 {
101 public:
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 {
120  std::vector <MyCondition> aMyConditions;
122  sal_Int32 nKey;
123 // OUString sFormatName;
124  OUString sFormatTitle;
125 // OUString sMapName;
126  OUString sCalendar;
130  bool bTruncate;
131  bool bAutoDec; // set in AddNumber
132  bool bAutoInt; // set in AddNumber
134  OUStringBuffer aFormatCode{64};
135  OUStringBuffer aConditions{32};
137  bool bHasEra;
140 
141  // contained date elements, used to recognize default date formats
150 
151  SAL_DLLPRIVATE sal_Int32 PrivateGetKey();
152 
153 public:
155  sal_Int32 nElement,
156  SvXMLNumImpData* pNewData,
157  SvXMLStylesTokens nNewType,
158  const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
159  SvXMLStylesContext& rStyles );
161  const OUString& rName,
162  const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
163  const sal_Int32 nKey,
164  LanguageType nLang,
165  SvXMLStylesContext& rStyles );
166  virtual ~SvXMLNumFormatContext() override;
167 
168  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
169  sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
170  virtual void CreateAndInsert(bool bOverwrite) override;
171 
172  sal_Int32 GetKey();
173  sal_Int32 CreateAndInsert( SvNumberFormatter* pFormatter );
174  sal_Int32 CreateAndInsert( css::uno::Reference< css::util::XNumberFormatsSupplier > const & xFormatsSupplier );
175  SvXMLStylesTokens GetType() const { return nType; } // SvXMLStylesTokens
176 
177  bool HasLongDoW() const { return bHasLongDoW; }
178  void SetHasLongDoW(bool bSet) { bHasLongDoW = bSet; }
179  bool HasEra() const { return bHasEra; }
180 
181  void UpdateCalendar( const OUString& rNewCalendar, bool bImplicitSecondaryCalendarEC = false );
182 
183  const LocaleDataWrapper& GetLocaleData() const;
184 
185  void AddToCode( const OUString& rString );
186  void AddToCode( sal_Unicode c );
187  void AddNumber( const SvXMLNumberInfo& rInfo );
188  void AddCurrency( const OUString& rContent, LanguageType nLang );
189 
190  void AddNfKeyword( sal_uInt16 nIndex );
191  bool ReplaceNfKeyword( sal_uInt16 nOld, sal_uInt16 nNew );
192  void AddCondition( const sal_Int32 nIndex );
193  void AddCondition( const OUString& rCondition, const OUString& rApplyName );
194  void AddColor( Color nColor );
195 
197  bool IsSystemLanguage() const;
198 };
199 
200 #endif
201 
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvXMLStylesTokens nType
Definition: xmlnumfi.hxx:121
LanguageType nFormatLang
Definition: xmlnumfi.hxx:127
OUString sCondition
Definition: xmlnumfi.hxx:112
SvXMLDateElementAttributes eDateSecs
Definition: xmlnumfi.hxx:148
SvXMLDateElementAttributes eDateDay
Definition: xmlnumfi.hxx:143
SvXMLStyleContext * CreateChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, SvXMLStylesContext &rStyles)
Definition: xmlnumfi.cxx:2114
sal_uInt16 sal_Unicode
SvXMLNumImpData * pData
Definition: xmlnumfi.hxx:118
std::vector< MyCondition > aMyConditions
Definition: xmlnumfi.hxx:120
SvXMLStylesContext * pStyles
Definition: xmlnumfi.hxx:119
OUString sMapName
Definition: xmlnumfi.hxx:113
LanguageType GetLanguageForKey(sal_Int32 nKey)
Definition: xmlnumfi.cxx:2151
SvXMLDateElementAttributes eDateMonth
Definition: xmlnumfi.hxx:144
SvXMLDateElementAttributes
Definition: xmlnumfi.hxx:49
void SetHasLongDoW(bool bSet)
Definition: xmlnumfi.hxx:178
SvXMLDateElementAttributes eDateDOW
Definition: xmlnumfi.hxx:142
SvXMLStylesTokens
Definition: xmlnumfi.hxx:38
bool HasEra() const
Definition: xmlnumfi.hxx:179
SvXMLDateElementAttributes eDateHours
Definition: xmlnumfi.hxx:146
SvXMLNumImpData * getData()
Definition: xmlnumfi.hxx:90
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:149
std::unique_ptr< SvXMLNumImpData > pData
Definition: xmlnumfi.hxx:72
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:128
static sal_uInt16 GetDefaultDateFormat(SvXMLDateElementAttributes eDOW, SvXMLDateElementAttributes eDay, SvXMLDateElementAttributes eMonth, SvXMLDateElementAttributes eYear, SvXMLDateElementAttributes eHours, SvXMLDateElementAttributes eMins, SvXMLDateElementAttributes eSecs, bool bSystem)
Definition: xmlnumfi.cxx:1092
SvXMLStylesTokens GetType() const
Definition: xmlnumfi.hxx:175
bool HasLongDoW() const
Definition: xmlnumfi.hxx:177
SvXMLDateElementAttributes eDateMins
Definition: xmlnumfi.hxx:147
SvXMLDateElementAttributes eDateYear
Definition: xmlnumfi.hxx:145
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
const LocaleDataWrapper & GetLocaleData()