Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef XMLOFF_NUMEHELP_HXX
30 : : #define XMLOFF_NUMEHELP_HXX
31 : :
32 : : #include "sal/config.h"
33 : : #include "xmloff/dllapi.h"
34 : : #include <sal/types.h>
35 : : #include <com/sun/star/frame/XModel.hpp>
36 : : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
37 : :
38 : : #include <set>
39 : :
40 : : class SvXMLExport;
41 : : namespace rtl
42 : : {
43 : : class OUString;
44 : : }
45 : :
46 : 422 : struct XMLNumberFormat
47 : : {
48 : : rtl::OUString sCurrency;
49 : : sal_Int32 nNumberFormat;
50 : : sal_Int16 nType;
51 : : sal_Bool bIsStandard : 1;
52 : : XMLNumberFormat() : nNumberFormat(0), nType(0) {}
53 : 228 : XMLNumberFormat(const rtl::OUString& sTempCurrency, sal_Int32 nTempFormat,
54 : : sal_Int16 nTempType) : sCurrency(sTempCurrency), nNumberFormat(nTempFormat),
55 : 228 : nType(nTempType) {}
56 : : };
57 : :
58 : : struct LessNumberFormat
59 : : {
60 : 550 : sal_Bool operator() (const XMLNumberFormat& rValue1, const XMLNumberFormat& rValue2) const
61 : : {
62 : 550 : return rValue1.nNumberFormat < rValue2.nNumberFormat;
63 : : }
64 : : };
65 : :
66 : : typedef std::set<XMLNumberFormat, LessNumberFormat> XMLNumberFormatSet;
67 : :
68 : : class XMLOFF_DLLPUBLIC XMLNumberFormatAttributesExportHelper
69 : : {
70 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats > xNumberFormats;
71 : : SvXMLExport* pExport;
72 : : const rtl::OUString sEmpty;
73 : : const rtl::OUString sStandardFormat;
74 : : const rtl::OUString sType;
75 : : const rtl::OUString sAttrValueType;
76 : : const rtl::OUString sAttrValue;
77 : : const rtl::OUString sAttrDateValue;
78 : : const rtl::OUString sAttrTimeValue;
79 : : const rtl::OUString sAttrBooleanValue;
80 : : const rtl::OUString sAttrStringValue;
81 : : const rtl::OUString sAttrCurrency;
82 : : const rtl::OUString msCurrencySymbol;
83 : : const rtl::OUString msCurrencyAbbreviation;
84 : : XMLNumberFormatSet aNumberFormats;
85 : : public :
86 : : XMLNumberFormatAttributesExportHelper(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier);
87 : : XMLNumberFormatAttributesExportHelper(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier,
88 : : SvXMLExport& rExport );
89 : : ~XMLNumberFormatAttributesExportHelper();
90 : : void SetExport(SvXMLExport* pExp) { this->pExport = pExp; }
91 : :
92 : : sal_Int16 GetCellType(const sal_Int32 nNumberFormat, rtl::OUString& sCurrency, bool& bIsStandard);
93 : : static void WriteAttributes(SvXMLExport& rXMLExport,
94 : : const sal_Int16 nTypeKey,
95 : : const double& rValue,
96 : : const rtl::OUString& rCurrencySymbol,
97 : : sal_Bool bExportValue = sal_True);
98 : : static sal_Bool GetCurrencySymbol(const sal_Int32 nNumberFormat, rtl::OUString& rCurrencySymbol,
99 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier);
100 : : static sal_Int16 GetCellType(const sal_Int32 nNumberFormat, sal_Bool& bIsStandard,
101 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier);
102 : : static void SetNumberFormatAttributes(SvXMLExport& rXMLExport,
103 : : const sal_Int32 nNumberFormat,
104 : : const double& rValue,
105 : : sal_Bool bExportValue = sal_True);
106 : : static void SetNumberFormatAttributes(SvXMLExport& rXMLExport,
107 : : const rtl::OUString& rValue,
108 : : const rtl::OUString& rCharacters,
109 : : sal_Bool bExportValue = sal_True,
110 : : sal_Bool bExportTypeAttribute = sal_True);
111 : :
112 : : sal_Bool GetCurrencySymbol(const sal_Int32 nNumberFormat, rtl::OUString& rCurrencySymbol);
113 : : sal_Int16 GetCellType(const sal_Int32 nNumberFormat, bool& bIsStandard);
114 : : void WriteAttributes(const sal_Int16 nTypeKey,
115 : : const double& rValue,
116 : : const rtl::OUString& rCurrencySymbol,
117 : : sal_Bool bExportValue = sal_True);
118 : : void SetNumberFormatAttributes(const sal_Int32 nNumberFormat,
119 : : const double& rValue,
120 : : sal_Bool bExportValue = sal_True);
121 : : void SetNumberFormatAttributes(const rtl::OUString& rValue,
122 : : const rtl::OUString& rCharacters,
123 : : sal_Bool bExportValue = sal_True,
124 : : sal_Bool bExportTypeAttribute = sal_True);
125 : : };
126 : :
127 : : #endif
128 : :
129 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|