Line data Source code
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 XMLOFF_NUMEHELP_HXX
21 : #define XMLOFF_NUMEHELP_HXX
22 :
23 : #include "sal/config.h"
24 : #include "xmloff/xmlnmspe.hxx"
25 : #include "xmloff/dllapi.h"
26 : #include <sal/types.h>
27 : #include <com/sun/star/frame/XModel.hpp>
28 : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
29 :
30 : #include <set>
31 :
32 : class SvXMLExport;
33 :
34 735 : struct XMLNumberFormat
35 : {
36 : OUString sCurrency;
37 : sal_Int32 nNumberFormat;
38 : sal_Int16 nType;
39 : sal_Bool bIsStandard : 1;
40 : XMLNumberFormat() : nNumberFormat(0), nType(0) {}
41 593 : XMLNumberFormat(const OUString& sTempCurrency, sal_Int32 nTempFormat,
42 : sal_Int16 nTempType) : sCurrency(sTempCurrency), nNumberFormat(nTempFormat),
43 593 : nType(nTempType) {}
44 : };
45 :
46 : struct LessNumberFormat
47 : {
48 1244 : sal_Bool operator() (const XMLNumberFormat& rValue1, const XMLNumberFormat& rValue2) const
49 : {
50 1244 : return rValue1.nNumberFormat < rValue2.nNumberFormat;
51 : }
52 : };
53 :
54 : typedef std::set<XMLNumberFormat, LessNumberFormat> XMLNumberFormatSet;
55 :
56 : class XMLOFF_DLLPUBLIC XMLNumberFormatAttributesExportHelper
57 : {
58 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats > xNumberFormats;
59 : SvXMLExport* pExport;
60 : const OUString sEmpty;
61 : const OUString sStandardFormat;
62 : const OUString sType;
63 : const OUString sAttrValue;
64 : const OUString sAttrDateValue;
65 : const OUString sAttrTimeValue;
66 : const OUString sAttrBooleanValue;
67 : const OUString sAttrStringValue;
68 : const OUString sAttrCurrency;
69 : const OUString msCurrencySymbol;
70 : const OUString msCurrencyAbbreviation;
71 : XMLNumberFormatSet aNumberFormats;
72 : public :
73 : XMLNumberFormatAttributesExportHelper(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier);
74 : XMLNumberFormatAttributesExportHelper(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier,
75 : SvXMLExport& rExport );
76 : ~XMLNumberFormatAttributesExportHelper();
77 : void SetExport(SvXMLExport* pExp) { this->pExport = pExp; }
78 :
79 : sal_Int16 GetCellType(const sal_Int32 nNumberFormat, OUString& sCurrency, bool& bIsStandard);
80 : static void WriteAttributes(SvXMLExport& rXMLExport,
81 : const sal_Int16 nTypeKey,
82 : const double& rValue,
83 : const OUString& rCurrencySymbol,
84 : sal_Bool bExportValue = sal_True);
85 : static sal_Bool GetCurrencySymbol(const sal_Int32 nNumberFormat, OUString& rCurrencySymbol,
86 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier);
87 : static sal_Int16 GetCellType(const sal_Int32 nNumberFormat, sal_Bool& bIsStandard,
88 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier);
89 : static void SetNumberFormatAttributes(SvXMLExport& rXMLExport,
90 : const sal_Int32 nNumberFormat,
91 : const double& rValue,
92 : sal_Bool bExportValue = sal_True);
93 : static void SetNumberFormatAttributes(SvXMLExport& rXMLExport,
94 : const OUString& rValue,
95 : const OUString& rCharacters,
96 : sal_Bool bExportValue = sal_True,
97 : sal_Bool bExportTypeAttribute = sal_True);
98 :
99 : sal_Bool GetCurrencySymbol(const sal_Int32 nNumberFormat, OUString& rCurrencySymbol);
100 : sal_Int16 GetCellType(const sal_Int32 nNumberFormat, bool& bIsStandard);
101 : void WriteAttributes(const sal_Int16 nTypeKey,
102 : const double& rValue,
103 : const OUString& rCurrencySymbol,
104 : sal_Bool bExportValue = sal_True, sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE);
105 : void SetNumberFormatAttributes(const sal_Int32 nNumberFormat,
106 : const double& rValue,
107 : sal_Bool bExportValue = sal_True,
108 : sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE, bool bExportCurrencySymbol = true);
109 : void SetNumberFormatAttributes(const OUString& rValue,
110 : const OUString& rCharacters,
111 : sal_Bool bExportValue = sal_True,
112 : sal_Bool bExportTypeAttribute = sal_True,
113 : sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE);
114 : };
115 :
116 : #endif
117 :
118 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|