Update ooo320-m1
[ooovba.git] / xmloff / inc / numehelp.hxx
blob60cc27698afea84cc42f775459ae54df71b1145c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: numehelp.hxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef XMLOFF_NUMEHELP_HXX
32 #define XMLOFF_NUMEHELP_HXX
34 #include "sal/config.h"
35 #include "xmloff/dllapi.h"
36 #include <sal/types.h>
37 #include <com/sun/star/frame/XModel.hpp>
38 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
40 #ifndef __SGI_STL_SET
41 #include <set>
42 #endif
44 class SvXMLExport;
45 namespace rtl
47 class OUString;
50 struct XMLNumberFormat
52 rtl::OUString sCurrency;
53 sal_Int32 nNumberFormat;
54 sal_Int16 nType;
55 sal_Bool bIsStandard : 1;
56 XMLNumberFormat() : nNumberFormat(0), nType(0) {}
57 XMLNumberFormat(const rtl::OUString& sTempCurrency, sal_Int32 nTempFormat,
58 sal_Int16 nTempType) : sCurrency(sTempCurrency), nNumberFormat(nTempFormat),
59 nType(nTempType) {}
62 struct LessNumberFormat
64 sal_Bool operator() (const XMLNumberFormat& rValue1, const XMLNumberFormat& rValue2) const
66 return rValue1.nNumberFormat < rValue2.nNumberFormat;
70 typedef std::set<XMLNumberFormat, LessNumberFormat> XMLNumberFormatSet;
72 class XMLOFF_DLLPUBLIC XMLNumberFormatAttributesExportHelper
74 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats > xNumberFormats;
75 SvXMLExport* pExport;
76 const rtl::OUString sEmpty;
77 const rtl::OUString sStandardFormat;
78 const rtl::OUString sType;
79 const rtl::OUString sAttrValueType;
80 const rtl::OUString sAttrValue;
81 const rtl::OUString sAttrDateValue;
82 const rtl::OUString sAttrTimeValue;
83 const rtl::OUString sAttrBooleanValue;
84 const rtl::OUString sAttrStringValue;
85 const rtl::OUString sAttrCurrency;
86 const rtl::OUString msCurrencySymbol;
87 const rtl::OUString msCurrencyAbbreviation;
88 XMLNumberFormatSet aNumberFormats;
89 public :
90 XMLNumberFormatAttributesExportHelper(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier);
91 XMLNumberFormatAttributesExportHelper(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier,
92 SvXMLExport& rExport );
93 ~XMLNumberFormatAttributesExportHelper();
94 void SetExport(SvXMLExport* pExp) { this->pExport = pExp; }
96 sal_Int16 GetCellType(const sal_Int32 nNumberFormat, rtl::OUString& sCurrency, sal_Bool& bIsStandard);
97 static void WriteAttributes(SvXMLExport& rXMLExport,
98 const sal_Int16 nTypeKey,
99 const double& rValue,
100 const rtl::OUString& rCurrencySymbol,
101 sal_Bool bExportValue = sal_True);
102 static sal_Bool GetCurrencySymbol(const sal_Int32 nNumberFormat, rtl::OUString& rCurrencySymbol,
103 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier);
104 static sal_Int16 GetCellType(const sal_Int32 nNumberFormat, sal_Bool& bIsStandard,
105 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier);
106 static void SetNumberFormatAttributes(SvXMLExport& rXMLExport,
107 const sal_Int32 nNumberFormat,
108 const double& rValue,
109 sal_Bool bExportValue = sal_True);
110 static void SetNumberFormatAttributes(SvXMLExport& rXMLExport,
111 const rtl::OUString& rValue,
112 const rtl::OUString& rCharacters,
113 sal_Bool bExportValue = sal_True,
114 sal_Bool bExportTypeAttribute = sal_True);
116 sal_Bool GetCurrencySymbol(const sal_Int32 nNumberFormat, rtl::OUString& rCurrencySymbol);
117 sal_Int16 GetCellType(const sal_Int32 nNumberFormat, sal_Bool& bIsStandard);
118 void WriteAttributes(const sal_Int16 nTypeKey,
119 const double& rValue,
120 const rtl::OUString& rCurrencySymbol,
121 sal_Bool bExportValue = sal_True);
122 void SetNumberFormatAttributes(const sal_Int32 nNumberFormat,
123 const double& rValue,
124 sal_Bool bExportValue = sal_True);
125 void SetNumberFormatAttributes(const rtl::OUString& rValue,
126 const rtl::OUString& rCharacters,
127 sal_Bool bExportValue = sal_True,
128 sal_Bool bExportTypeAttribute = sal_True);
131 #endif