Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sc / inc / PivotTableDataSequence.hxx
blob470a7a5b2f0c0c4b23016d5b563d194e750c2834
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/.
8 */
10 #ifndef INCLUDED_SC_INC_PIVOTTABLEDATASEQUENCE_HXX
11 #define INCLUDED_SC_INC_PIVOTTABLEDATASEQUENCE_HXX
13 #include <com/sun/star/chart2/data/XDataSequence.hpp>
14 #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
15 #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
16 #include <com/sun/star/chart2/data/DataSequenceRole.hpp>
17 #include <com/sun/star/lang/XServiceInfo.hpp>
18 #include <com/sun/star/beans/XPropertySet.hpp>
19 #include <com/sun/star/util/XCloneable.hpp>
20 #include <com/sun/star/util/XModifyBroadcaster.hpp>
23 #include <svl/lstner.hxx>
24 #include <svl/itemprop.hxx>
25 #include <cppuhelper/implbase.hxx>
26 #include <rtl/math.hxx>
28 #include "unonames.hxx"
29 #include "document.hxx"
31 #include "dpsave.hxx"
33 namespace sc
36 enum class ValueType
38 Empty,
39 String,
40 Numeric
43 struct ValueAndFormat
45 double m_fValue;
46 OUString m_aString;
47 ValueType m_eType;
48 sal_uInt32 m_nNumberFormat;
50 explicit ValueAndFormat()
51 : m_fValue(0.0)
52 , m_aString()
53 , m_eType(ValueType::Empty)
54 , m_nNumberFormat(0)
56 rtl::math::setNan(&m_fValue);
59 explicit ValueAndFormat(double fValue, sal_uInt32 nNumberFormat)
60 : m_fValue(fValue)
61 , m_aString()
62 , m_eType(ValueType::Numeric)
63 , m_nNumberFormat(nNumberFormat)
66 explicit ValueAndFormat(OUString const & rString)
67 : m_fValue(0.0)
68 , m_aString(rString)
69 , m_eType(ValueType::String)
70 , m_nNumberFormat(0)
72 rtl::math::setNan(&m_fValue);
76 typedef cppu::WeakImplHelper<css::chart2::data::XDataSequence,
77 css::chart2::data::XTextualDataSequence,
78 css::chart2::data::XNumericalDataSequence,
79 css::util::XCloneable,
80 css::util::XModifyBroadcaster,
81 css::beans::XPropertySet,
82 css::lang::XServiceInfo>
83 PivotTableDataSequence_Base;
85 class PivotTableDataSequence : public PivotTableDataSequence_Base, public SfxListener
87 public:
88 explicit PivotTableDataSequence(ScDocument* pDocument, OUString const & sPivotTableName,
89 OUString const & sID, std::vector<ValueAndFormat> const & rData);
91 virtual ~PivotTableDataSequence() override;
92 PivotTableDataSequence(const PivotTableDataSequence&) = delete;
93 PivotTableDataSequence& operator=(const PivotTableDataSequence&) = delete;
95 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
97 // XDataSequence
98 virtual css::uno::Sequence<css::uno::Any> SAL_CALL getData() override;
99 virtual OUString SAL_CALL getSourceRangeRepresentation() override;
100 virtual css::uno::Sequence<OUString> SAL_CALL
101 generateLabel(css::chart2::data::LabelOrigin nOrigin) override;
103 virtual sal_Int32 SAL_CALL getNumberFormatKeyByIndex(sal_Int32 nIndex) override;
105 // XNumericalDataSequence
106 virtual css::uno::Sequence<double> SAL_CALL getNumericalData() override;
108 // XTextualDataSequence
109 virtual css::uno::Sequence<OUString> SAL_CALL getTextualData() override;
111 // XPropertySet
112 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL
113 getPropertySetInfo() override;
115 virtual void SAL_CALL setPropertyValue(const OUString& rPropertyName,
116 const css::uno::Any& rValue) override;
118 virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& rPropertyName) override;
120 virtual void SAL_CALL addPropertyChangeListener(
121 const OUString& rPropertyName,
122 const css::uno::Reference< css::beans::XPropertyChangeListener>& xListener) override;
124 virtual void SAL_CALL removePropertyChangeListener(
125 const OUString& rPropertyName,
126 const css::uno::Reference< css::beans::XPropertyChangeListener>& rListener) override;
128 virtual void SAL_CALL addVetoableChangeListener(
129 const OUString& rPropertyName,
130 const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override;
132 virtual void SAL_CALL removeVetoableChangeListener(
133 const OUString& rPropertyName,
134 const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override;
136 // XCloneable
137 virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override;
139 // XModifyBroadcaster
140 virtual void SAL_CALL addModifyListener(
141 const css::uno::Reference<css::util::XModifyListener>& aListener) override;
143 virtual void SAL_CALL removeModifyListener(
144 const css::uno::Reference<css::util::XModifyListener>& aListener) override;
146 // XServiceInfo
147 virtual OUString SAL_CALL getImplementationName() override;
149 virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
151 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
153 // Other
155 void setRole(css::chart2::data::DataSequenceRole const & aRole)
157 m_aRole = aRole;
160 private:
161 ScDocument* m_pDocument;
162 OUString m_sPivotTableName;
163 OUString m_aID;
164 std::vector<ValueAndFormat> m_aData;
165 SfxItemPropertySet m_aPropSet;
166 css::chart2::data::DataSequenceRole m_aRole;
167 std::vector<css::uno::Reference<css::util::XModifyListener>> m_aValueListeners;
172 #endif
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */