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 #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 
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(std::numeric_limits<double>::quiet_NaN())
49  , m_aString()
50  , m_eType(ValueType::Empty)
51  , m_nNumberFormat(0)
52  {
53  }
54 
55  explicit ValueAndFormat(double fValue, sal_uInt32 nNumberFormat)
56  : m_fValue(fValue)
57  , m_aString()
58  , m_eType(ValueType::Numeric)
59  , m_nNumberFormat(nNumberFormat)
60  {}
61 
62  explicit ValueAndFormat(OUString const & rString)
63  : m_fValue(std::numeric_limits<double>::quiet_NaN())
64  , m_aString(rString)
65  , m_eType(ValueType::String)
66  , m_nNumberFormat(0)
67  {
68  }
69 };
70 
71 typedef cppu::WeakImplHelper<css::chart2::data::XDataSequence,
72  css::chart2::data::XTextualDataSequence,
73  css::chart2::data::XNumericalDataSequence,
74  css::util::XCloneable,
75  css::util::XModifyBroadcaster,
76  css::beans::XPropertySet,
77  css::lang::XServiceInfo>
79 
81 {
82 public:
83  explicit PivotTableDataSequence(ScDocument* pDocument,
84  OUString const & sID, std::vector<ValueAndFormat>&& rData);
85 
86  virtual ~PivotTableDataSequence() override;
89 
90  virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
91 
92  // XDataSequence
93  virtual css::uno::Sequence<css::uno::Any> SAL_CALL getData() override;
94  virtual OUString SAL_CALL getSourceRangeRepresentation() override;
95  virtual css::uno::Sequence<OUString> SAL_CALL
96  generateLabel(css::chart2::data::LabelOrigin nOrigin) override;
97 
98  virtual sal_Int32 SAL_CALL getNumberFormatKeyByIndex(sal_Int32 nIndex) override;
99 
100  // XNumericalDataSequence
101  virtual css::uno::Sequence<double> SAL_CALL getNumericalData() override;
102 
103  // XTextualDataSequence
104  virtual css::uno::Sequence<OUString> SAL_CALL getTextualData() override;
105 
106  // XPropertySet
107  virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL
108  getPropertySetInfo() override;
109 
110  virtual void SAL_CALL setPropertyValue(const OUString& rPropertyName,
111  const css::uno::Any& rValue) override;
112 
113  virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& rPropertyName) override;
114 
115  virtual void SAL_CALL addPropertyChangeListener(
116  const OUString& rPropertyName,
117  const css::uno::Reference< css::beans::XPropertyChangeListener>& xListener) override;
118 
119  virtual void SAL_CALL removePropertyChangeListener(
120  const OUString& rPropertyName,
121  const css::uno::Reference< css::beans::XPropertyChangeListener>& rListener) override;
122 
123  virtual void SAL_CALL addVetoableChangeListener(
124  const OUString& rPropertyName,
125  const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override;
126 
127  virtual void SAL_CALL removeVetoableChangeListener(
128  const OUString& rPropertyName,
129  const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override;
130 
131  // XCloneable
132  virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override;
133 
134  // XModifyBroadcaster
135  virtual void SAL_CALL addModifyListener(
136  const css::uno::Reference<css::util::XModifyListener>& aListener) override;
137 
138  virtual void SAL_CALL removeModifyListener(
139  const css::uno::Reference<css::util::XModifyListener>& aListener) override;
140 
141  // XServiceInfo
142  virtual OUString SAL_CALL getImplementationName() override;
143 
144  virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
145 
146  virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
147 
148  // Other
149 
150  void setRole(css::chart2::data::DataSequenceRole const & aRole)
151  {
152  m_aRole = aRole;
153  }
154 
155 private:
157  OUString m_aID;
158  std::vector<ValueAndFormat> m_aData;
160  css::chart2::data::DataSequenceRole m_aRole;
161  std::vector<css::uno::Reference<css::util::XModifyListener>> m_aValueListeners;
162 };
163 
164 }
165 
166 /* 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
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
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
PivotTableDataSequence(ScDocument *pDocument, OUString const &sID, std::vector< ValueAndFormat > &&rData)
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