xref: /aoo4110/main/xmloff/inc/xmloff/numehelp.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef XMLOFF_NUMEHELP_HXX
25 #define XMLOFF_NUMEHELP_HXX
26 
27 #include "sal/config.h"
28 #include "xmloff/dllapi.h"
29 #include <sal/types.h>
30 #include <com/sun/star/frame/XModel.hpp>
31 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
32 
33 #ifndef __SGI_STL_SET
34 #include <set>
35 #endif
36 
37 class SvXMLExport;
38 namespace rtl
39 {
40 	class OUString;
41 }
42 
43 struct XMLNumberFormat
44 {
45 	rtl::OUString	sCurrency;
46 	sal_Int32		nNumberFormat;
47 	sal_Int16		nType;
48 	sal_Bool		bIsStandard : 1;
XMLNumberFormatXMLNumberFormat49 	XMLNumberFormat() : nNumberFormat(0), nType(0) {}
XMLNumberFormatXMLNumberFormat50 	XMLNumberFormat(const rtl::OUString& sTempCurrency, sal_Int32 nTempFormat,
51 		sal_Int16 nTempType) : sCurrency(sTempCurrency), nNumberFormat(nTempFormat),
52 			nType(nTempType) {}
53 };
54 
55 struct LessNumberFormat
56 {
operator ()LessNumberFormat57 	sal_Bool operator() (const XMLNumberFormat& rValue1, const XMLNumberFormat& rValue2) const
58 	{
59 		return rValue1.nNumberFormat < rValue2.nNumberFormat;
60 	}
61 };
62 
63 typedef std::set<XMLNumberFormat, LessNumberFormat>	XMLNumberFormatSet;
64 
65 class XMLOFF_DLLPUBLIC XMLNumberFormatAttributesExportHelper
66 {
67 	::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats > xNumberFormats;
68 	SvXMLExport*		pExport;
69     const rtl::OUString sEmpty;
70     const rtl::OUString sStandardFormat;
71     const rtl::OUString sType;
72     const rtl::OUString sAttrValueType;
73     const rtl::OUString sAttrValue;
74     const rtl::OUString sAttrDateValue;
75     const rtl::OUString sAttrTimeValue;
76     const rtl::OUString sAttrBooleanValue;
77     const rtl::OUString sAttrStringValue;
78     const rtl::OUString sAttrCurrency;
79     const rtl::OUString msCurrencySymbol;
80     const rtl::OUString msCurrencyAbbreviation;
81     XMLNumberFormatSet	aNumberFormats;
82 public :
83 	XMLNumberFormatAttributesExportHelper(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier);
84 	XMLNumberFormatAttributesExportHelper(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier,
85                                             SvXMLExport& rExport );
86 	~XMLNumberFormatAttributesExportHelper();
SetExport(SvXMLExport * pExp)87     void SetExport(SvXMLExport* pExp) { this->pExport = pExp; }
88 
89 	sal_Int16 GetCellType(const sal_Int32 nNumberFormat, rtl::OUString& sCurrency, sal_Bool& bIsStandard);
90 	static void WriteAttributes(SvXMLExport& rXMLExport,
91 								const sal_Int16 nTypeKey,
92 								const double& rValue,
93 								const rtl::OUString& rCurrencySymbol,
94 								sal_Bool bExportValue = sal_True);
95 	static sal_Bool GetCurrencySymbol(const sal_Int32 nNumberFormat, rtl::OUString& rCurrencySymbol,
96 		::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier);
97 	static sal_Int16 GetCellType(const sal_Int32 nNumberFormat, sal_Bool& bIsStandard,
98 		::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier);
99 	static void SetNumberFormatAttributes(SvXMLExport& rXMLExport,
100 										  const sal_Int32 nNumberFormat,
101 										  const double& rValue,
102 										  sal_Bool bExportValue = sal_True);
103 	static void SetNumberFormatAttributes(SvXMLExport& rXMLExport,
104 										  const rtl::OUString& rValue,
105 										  const rtl::OUString& rCharacters,
106 										  sal_Bool bExportValue = sal_True,
107 										  sal_Bool bExportTypeAttribute = sal_True);
108 
109     sal_Bool GetCurrencySymbol(const sal_Int32 nNumberFormat, rtl::OUString& rCurrencySymbol);
110     sal_Int16 GetCellType(const sal_Int32 nNumberFormat, sal_Bool& bIsStandard);
111     void WriteAttributes(const sal_Int16 nTypeKey,
112                                           const double& rValue,
113                                           const rtl::OUString& rCurrencySymbol,
114                                           sal_Bool bExportValue = sal_True);
115     void SetNumberFormatAttributes(const sal_Int32 nNumberFormat,
116                                           const double& rValue,
117                                           sal_Bool bExportValue = sal_True);
118     void SetNumberFormatAttributes(const rtl::OUString& rValue,
119                                           const rtl::OUString& rCharacters,
120                                           sal_Bool bExportValue = sal_True,
121                                           sal_Bool bExportTypeAttribute = sal_True);
122 };
123 
124 #endif
125 
126