LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / PivotTableDataSequence.hxx
bloba5723725297eff01fed5a9e4d1f85b9c20ae0221
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 #pragma once
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>
22 #include <svl/lstner.hxx>
23 #include <svl/itemprop.hxx>
24 #include <cppuhelper/implbase.hxx>
26 #include <limits>
28 class ScDocument;
30 namespace sc
33 enum class ValueType
35 Empty,
36 String,
37 Numeric
40 struct ValueAndFormat
42 double m_fValue;
43 OUString m_aString;
44 ValueType m_eType;
45 sal_uInt32 m_nNumberFormat;
47 explicit ValueAndFormat()
48 : m_fValue(std::numeric_limits<double>::quiet_NaN())
49 , m_aString()
50 , m_eType(ValueType::Empty)
51 , m_nNumberFormat(0)
55 explicit ValueAndFormat(double fValue, sal_uInt32 nNumberFormat)
56 : m_fValue(fValue)
57 , m_aString()
58 , m_eType(ValueType::Numeric)
59 , m_nNumberFormat(nNumberFormat)
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)
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>
78 PivotTableDataSequence_Base;
80 class PivotTableDataSequence final : public PivotTableDataSequence_Base, public SfxListener
82 public:
83 explicit PivotTableDataSequence(ScDocument* pDocument,
84 OUString const & sID, std::vector<ValueAndFormat>&& rData);
86 virtual ~PivotTableDataSequence() override;
87 PivotTableDataSequence(const PivotTableDataSequence&) = delete;
88 PivotTableDataSequence& operator=(const PivotTableDataSequence&) = delete;
90 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
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;
98 virtual sal_Int32 SAL_CALL getNumberFormatKeyByIndex(sal_Int32 nIndex) override;
100 // XNumericalDataSequence
101 virtual css::uno::Sequence<double> SAL_CALL getNumericalData() override;
103 // XTextualDataSequence
104 virtual css::uno::Sequence<OUString> SAL_CALL getTextualData() override;
106 // XPropertySet
107 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL
108 getPropertySetInfo() override;
110 virtual void SAL_CALL setPropertyValue(const OUString& rPropertyName,
111 const css::uno::Any& rValue) override;
113 virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& rPropertyName) override;
115 virtual void SAL_CALL addPropertyChangeListener(
116 const OUString& rPropertyName,
117 const css::uno::Reference< css::beans::XPropertyChangeListener>& xListener) override;
119 virtual void SAL_CALL removePropertyChangeListener(
120 const OUString& rPropertyName,
121 const css::uno::Reference< css::beans::XPropertyChangeListener>& rListener) override;
123 virtual void SAL_CALL addVetoableChangeListener(
124 const OUString& rPropertyName,
125 const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override;
127 virtual void SAL_CALL removeVetoableChangeListener(
128 const OUString& rPropertyName,
129 const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override;
131 // XCloneable
132 virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override;
134 // XModifyBroadcaster
135 virtual void SAL_CALL addModifyListener(
136 const css::uno::Reference<css::util::XModifyListener>& aListener) override;
138 virtual void SAL_CALL removeModifyListener(
139 const css::uno::Reference<css::util::XModifyListener>& aListener) override;
141 // XServiceInfo
142 virtual OUString SAL_CALL getImplementationName() override;
144 virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
146 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
148 // Other
150 void setRole(css::chart2::data::DataSequenceRole const & aRole)
152 m_aRole = aRole;
155 private:
156 ScDocument* m_pDocument;
157 OUString m_aID;
158 std::vector<ValueAndFormat> m_aData;
159 SfxItemPropertySet m_aPropSet;
160 css::chart2::data::DataSequenceRole m_aRole;
161 std::vector<css::uno::Reference<css::util::XModifyListener>> m_aValueListeners;
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */