1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/xmlnamespace.hxx>
25 #include <xmloff/dllapi.h>
26 #include <sal/types.h>
27 #include <com/sun/star/uno/Reference.hxx>
30 #include <string_view>
32 namespace com::sun::star::util
{ class XNumberFormats
; }
33 namespace com::sun::star::util
{ class XNumberFormatsSupplier
; }
37 struct XMLNumberFormat
40 sal_Int32 nNumberFormat
;
44 XMLNumberFormat(sal_Int32 nTempFormat
)
45 : nNumberFormat(nTempFormat
)
52 struct LessNumberFormat
54 bool operator() (const XMLNumberFormat
& rValue1
, const XMLNumberFormat
& rValue2
) const
56 return rValue1
.nNumberFormat
< rValue2
.nNumberFormat
;
60 typedef std::set
<XMLNumberFormat
, LessNumberFormat
> XMLNumberFormatSet
;
62 class XMLOFF_DLLPUBLIC XMLNumberFormatAttributesExportHelper
64 css::uno::Reference
< css::util::XNumberFormats
> m_xNumberFormats
;
65 SvXMLExport
* m_pExport
;
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
;
72 XMLNumberFormatSet m_aNumberFormats
;
74 XMLNumberFormatAttributesExportHelper(css::uno::Reference
< css::util::XNumberFormatsSupplier
> const & xNumberFormatsSupplier
);
75 XMLNumberFormatAttributesExportHelper(css::uno::Reference
< css::util::XNumberFormatsSupplier
> const & xNumberFormatsSupplier
,
76 SvXMLExport
& rExport
);
77 ~XMLNumberFormatAttributesExportHelper();
79 sal_Int16
GetCellType(const sal_Int32 nNumberFormat
, OUString
& sCurrency
, bool& bIsStandard
);
80 static void WriteAttributes(SvXMLExport
& rXMLExport
,
81 const sal_Int16 nTypeKey
,
83 const OUString
& rCurrencySymbol
,
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
,
92 bool bExportValue
= true);
93 static void SetNumberFormatAttributes(SvXMLExport
& rXMLExport
,
94 const OUString
& rValue
,
95 std::u16string_view rCharacters
,
97 bool bExportTypeAttribute
= true);
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
);
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */