/src/libreoffice/sc/inc/PivotTableDataSequence.hxx
Line | Count | Source |
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 | | |
10 | | #pragma once |
11 | | |
12 | | #include <com/sun/star/chart2/data/XDataSequence.hpp> |
13 | | #include <com/sun/star/chart2/data/XTextualDataSequence.hpp> |
14 | | #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> |
15 | | #include <com/sun/star/chart2/data/DataSequenceRole.hpp> |
16 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
17 | | #include <com/sun/star/beans/XPropertySet.hpp> |
18 | | #include <com/sun/star/util/XCloneable.hpp> |
19 | | #include <com/sun/star/util/XModifyBroadcaster.hpp> |
20 | | |
21 | | |
22 | | #include <svl/lstner.hxx> |
23 | | #include <svl/itemprop.hxx> |
24 | | #include <cppuhelper/implbase.hxx> |
25 | | |
26 | | #include <limits> |
27 | | #include <utility> |
28 | | |
29 | | class ScDocument; |
30 | | |
31 | | namespace sc |
32 | | { |
33 | | |
34 | | enum class ValueType |
35 | | { |
36 | | Empty, |
37 | | String, |
38 | | Numeric |
39 | | }; |
40 | | |
41 | | struct ValueAndFormat |
42 | | { |
43 | | double m_fValue; |
44 | | OUString m_aString; |
45 | | ValueType m_eType; |
46 | | sal_uInt32 m_nNumberFormat; |
47 | | |
48 | | explicit ValueAndFormat() |
49 | 0 | : m_fValue(std::numeric_limits<double>::quiet_NaN()) |
50 | 0 | , m_aString() |
51 | 0 | , m_eType(ValueType::Empty) |
52 | 0 | , m_nNumberFormat(0) |
53 | 0 | { |
54 | 0 | } |
55 | | |
56 | | explicit ValueAndFormat(double fValue, sal_uInt32 nNumberFormat) |
57 | 0 | : m_fValue(fValue) |
58 | 0 | , m_aString() |
59 | 0 | , m_eType(ValueType::Numeric) |
60 | 0 | , m_nNumberFormat(nNumberFormat) |
61 | 0 | {} |
62 | | |
63 | | explicit ValueAndFormat(OUString aString) |
64 | 0 | : m_fValue(std::numeric_limits<double>::quiet_NaN()) |
65 | 0 | , m_aString(std::move(aString)) |
66 | 0 | , m_eType(ValueType::String) |
67 | 0 | , m_nNumberFormat(0) |
68 | 0 | { |
69 | 0 | } |
70 | | }; |
71 | | |
72 | | typedef cppu::WeakImplHelper<css::chart2::data::XDataSequence, |
73 | | css::chart2::data::XTextualDataSequence, |
74 | | css::chart2::data::XNumericalDataSequence, |
75 | | css::util::XCloneable, |
76 | | css::util::XModifyBroadcaster, |
77 | | css::beans::XPropertySet, |
78 | | css::lang::XServiceInfo> |
79 | | PivotTableDataSequence_Base; |
80 | | |
81 | | class PivotTableDataSequence final : public PivotTableDataSequence_Base, public SfxListener |
82 | | { |
83 | | public: |
84 | | explicit PivotTableDataSequence(ScDocument* pDocument, |
85 | | OUString sID, std::vector<ValueAndFormat>&& rData); |
86 | | |
87 | | virtual ~PivotTableDataSequence() override; |
88 | | PivotTableDataSequence(const PivotTableDataSequence&) = delete; |
89 | | PivotTableDataSequence& operator=(const PivotTableDataSequence&) = delete; |
90 | | |
91 | | virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; |
92 | | |
93 | | // XDataSequence |
94 | | virtual css::uno::Sequence<css::uno::Any> SAL_CALL getData() override; |
95 | | virtual OUString SAL_CALL getSourceRangeRepresentation() override; |
96 | | virtual css::uno::Sequence<OUString> SAL_CALL |
97 | | generateLabel(css::chart2::data::LabelOrigin nOrigin) override; |
98 | | |
99 | | virtual sal_Int32 SAL_CALL getNumberFormatKeyByIndex(sal_Int32 nIndex) override; |
100 | | |
101 | | // XNumericalDataSequence |
102 | | virtual css::uno::Sequence<double> SAL_CALL getNumericalData() override; |
103 | | |
104 | | // XTextualDataSequence |
105 | | virtual css::uno::Sequence<OUString> SAL_CALL getTextualData() override; |
106 | | |
107 | | // XPropertySet |
108 | | virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL |
109 | | getPropertySetInfo() override; |
110 | | |
111 | | virtual void SAL_CALL setPropertyValue(const OUString& rPropertyName, |
112 | | const css::uno::Any& rValue) override; |
113 | | |
114 | | virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& rPropertyName) override; |
115 | | |
116 | | virtual void SAL_CALL addPropertyChangeListener( |
117 | | const OUString& rPropertyName, |
118 | | const css::uno::Reference< css::beans::XPropertyChangeListener>& xListener) override; |
119 | | |
120 | | virtual void SAL_CALL removePropertyChangeListener( |
121 | | const OUString& rPropertyName, |
122 | | const css::uno::Reference< css::beans::XPropertyChangeListener>& rListener) override; |
123 | | |
124 | | virtual void SAL_CALL addVetoableChangeListener( |
125 | | const OUString& rPropertyName, |
126 | | const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override; |
127 | | |
128 | | virtual void SAL_CALL removeVetoableChangeListener( |
129 | | const OUString& rPropertyName, |
130 | | const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override; |
131 | | |
132 | | // XCloneable |
133 | | virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override; |
134 | | |
135 | | // XModifyBroadcaster |
136 | | virtual void SAL_CALL addModifyListener( |
137 | | const css::uno::Reference<css::util::XModifyListener>& aListener) override; |
138 | | |
139 | | virtual void SAL_CALL removeModifyListener( |
140 | | const css::uno::Reference<css::util::XModifyListener>& aListener) override; |
141 | | |
142 | | // XServiceInfo |
143 | | virtual OUString SAL_CALL getImplementationName() override; |
144 | | |
145 | | virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; |
146 | | |
147 | | virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; |
148 | | |
149 | | // Other |
150 | | |
151 | | void setRole(css::chart2::data::DataSequenceRole const & aRole) |
152 | 0 | { |
153 | 0 | m_aRole = aRole; |
154 | 0 | } |
155 | | |
156 | | private: |
157 | | ScDocument* m_pDocument; |
158 | | OUString m_aID; |
159 | | std::vector<ValueAndFormat> m_aData; |
160 | | SfxItemPropertySet m_aPropSet; |
161 | | css::chart2::data::DataSequenceRole m_aRole; |
162 | | std::vector<css::uno::Reference<css::util::XModifyListener>> m_aValueListeners; |
163 | | }; |
164 | | |
165 | | } |
166 | | |
167 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |