Branch libreoffice-5-0-4
[LibreOffice.git] / include / xmloff / numehelp.hxx
bloba2a7d75f4a7f79b880e388562c24bc39f3404544
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_XMLOFF_NUMEHELP_HXX
21 #define INCLUDED_XMLOFF_NUMEHELP_HXX
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>
30 #include <set>
32 class SvXMLExport;
34 struct XMLNumberFormat
36 OUString sCurrency;
37 sal_Int32 nNumberFormat;
38 sal_Int16 nType;
39 bool bIsStandard : 1;
40 XMLNumberFormat()
41 : nNumberFormat(0)
42 , nType(0)
43 , bIsStandard(false)
47 XMLNumberFormat(const OUString& sTempCurrency, sal_Int32 nTempFormat, sal_Int16 nTempType)
48 : sCurrency(sTempCurrency)
49 , nNumberFormat(nTempFormat)
50 , nType(nTempType)
51 , bIsStandard(false)
56 struct LessNumberFormat
58 bool operator() (const XMLNumberFormat& rValue1, const XMLNumberFormat& rValue2) const
60 return rValue1.nNumberFormat < rValue2.nNumberFormat;
64 typedef std::set<XMLNumberFormat, LessNumberFormat> XMLNumberFormatSet;
66 class XMLOFF_DLLPUBLIC XMLNumberFormatAttributesExportHelper
68 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats > xNumberFormats;
69 SvXMLExport* pExport;
70 const OUString sEmpty;
71 const OUString sStandardFormat;
72 const OUString sType;
73 const OUString sAttrValue;
74 const OUString sAttrDateValue;
75 const OUString sAttrTimeValue;
76 const OUString sAttrBooleanValue;
77 const OUString sAttrStringValue;
78 const OUString sAttrCurrency;
79 const OUString msCurrencySymbol;
80 const 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();
87 void SetExport(SvXMLExport* pExp) { this->pExport = pExp; }
89 sal_Int16 GetCellType(const sal_Int32 nNumberFormat, OUString& sCurrency, bool& bIsStandard);
90 static void WriteAttributes(SvXMLExport& rXMLExport,
91 const sal_Int16 nTypeKey,
92 const double& rValue,
93 const OUString& rCurrencySymbol,
94 bool bExportValue = true);
95 static bool GetCurrencySymbol(const sal_Int32 nNumberFormat, OUString& rCurrencySymbol,
96 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier);
97 static sal_Int16 GetCellType(const sal_Int32 nNumberFormat, 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 bool bExportValue = true);
103 static void SetNumberFormatAttributes(SvXMLExport& rXMLExport,
104 const OUString& rValue,
105 const OUString& rCharacters,
106 bool bExportValue = true,
107 bool bExportTypeAttribute = true);
109 bool GetCurrencySymbol(const sal_Int32 nNumberFormat, OUString& rCurrencySymbol);
110 sal_Int16 GetCellType(const sal_Int32 nNumberFormat, bool& bIsStandard);
111 void WriteAttributes(const sal_Int16 nTypeKey,
112 const double& rValue,
113 const OUString& rCurrencySymbol,
114 bool bExportValue = true, sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE);
115 void SetNumberFormatAttributes(const sal_Int32 nNumberFormat,
116 const double& rValue,
117 bool bExportValue = true,
118 sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE, bool bExportCurrencySymbol = true);
119 void SetNumberFormatAttributes(const OUString& rValue,
120 const OUString& rCharacters,
121 bool bExportValue = true,
122 bool bExportTypeAttribute = true,
123 sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE);
126 #endif
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */