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