LibreOffice Module xmloff (master) 1
numehelp.hxx
Go to the documentation of this file.
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 INCLUDED_XMLOFF_NUMEHELP_HXX
21#define INCLUDED_XMLOFF_NUMEHELP_HXX
22
23#include <sal/config.h>
25#include <xmloff/dllapi.h>
26#include <sal/types.h>
27#include <com/sun/star/uno/Reference.hxx>
28
29#include <set>
30#include <string_view>
31
32namespace com::sun::star::util { class XNumberFormats; }
33namespace com::sun::star::util { class XNumberFormatsSupplier; }
34
35class SvXMLExport;
36
38{
39 OUString sCurrency;
40 sal_Int32 nNumberFormat;
41 sal_Int16 nType;
42 bool bIsStandard : 1;
43
44 XMLNumberFormat(sal_Int32 nTempFormat)
45 : nNumberFormat(nTempFormat)
46 , nType(0)
47 , bIsStandard(false)
48 {
49 }
50};
51
53{
54 bool operator() (const XMLNumberFormat& rValue1, const XMLNumberFormat& rValue2) const
55 {
56 return rValue1.nNumberFormat < rValue2.nNumberFormat;
57 }
58};
59
60typedef std::set<XMLNumberFormat, LessNumberFormat> XMLNumberFormatSet;
61
63{
64 css::uno::Reference< css::util::XNumberFormats > m_xNumberFormats;
66 const OUString m_sAttrValue;
67 const OUString m_sAttrDateValue;
68 const OUString m_sAttrTimeValue;
69 const OUString m_sAttrBooleanValue;
70 const OUString m_sAttrStringValue;
71 const OUString m_sAttrCurrency;
73public:
74 XMLNumberFormatAttributesExportHelper(css::uno::Reference< css::util::XNumberFormatsSupplier > const & xNumberFormatsSupplier);
75 XMLNumberFormatAttributesExportHelper(css::uno::Reference< css::util::XNumberFormatsSupplier > const & xNumberFormatsSupplier,
76 SvXMLExport& rExport );
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 bool bExportValue);
85 static bool GetCurrencySymbol(const sal_Int32 nNumberFormat, OUString& rCurrencySymbol,
86 css::uno::Reference< css::util::XNumberFormatsSupplier > const & xNumberFormatsSupplier);
87 static sal_Int16 GetCellType(const sal_Int32 nNumberFormat, bool& bIsStandard,
88 css::uno::Reference< css::util::XNumberFormatsSupplier > const & xNumberFormatsSupplier);
89 static void SetNumberFormatAttributes(SvXMLExport& rXMLExport,
90 const sal_Int32 nNumberFormat,
91 const double& rValue,
92 bool bExportValue = true);
93 static void SetNumberFormatAttributes(SvXMLExport& rXMLExport,
94 const OUString& rValue,
95 std::u16string_view rCharacters,
96 bool bExportValue,
97 bool bExportTypeAttribute = true);
98
99 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 bool bExportValue, sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE);
105 void SetNumberFormatAttributes(const sal_Int32 nNumberFormat,
106 const double& rValue,
107 bool bExportValue = true,
108 sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE, bool bExportCurrencySymbol = true);
109 void SetNumberFormatAttributes(const OUString& rValue,
110 std::u16string_view rCharacters,
111 bool bExportValue = true,
112 sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE);
113};
114
115#endif
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool GetCurrencySymbol(const sal_Int32 nNumberFormat, OUString &rCurrencySymbol, css::uno::Reference< css::util::XNumberFormatsSupplier > const &xNumberFormatsSupplier)
XMLNumberFormatSet m_aNumberFormats
Definition: numehelp.hxx:72
static sal_Int16 GetCellType(const sal_Int32 nNumberFormat, bool &bIsStandard, css::uno::Reference< css::util::XNumberFormatsSupplier > const &xNumberFormatsSupplier)
css::uno::Reference< css::util::XNumberFormats > m_xNumberFormats
Definition: numehelp.hxx:64
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
std::set< XMLNumberFormat, LessNumberFormat > XMLNumberFormatSet
Definition: numehelp.hxx:60
bool operator()(const XMLNumberFormat &rValue1, const XMLNumberFormat &rValue2) const
Definition: numehelp.hxx:54
sal_Int32 nNumberFormat
Definition: numehelp.hxx:40
sal_Int16 nType
Definition: numehelp.hxx:41
OUString sCurrency
Definition: numehelp.hxx:39
XMLNumberFormat(sal_Int32 nTempFormat)
Definition: numehelp.hxx:44
constexpr sal_uInt16 XML_NAMESPACE_OFFICE