Fix build
[LibreOffice.git] / sc / inc / PivotTableDataProvider.hxx
bloba1df012ccad156b939ac86e55fd403b49439569f
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/XDataProvider.hpp>
13 #include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
14 #include <com/sun/star/chart2/data/PivotTableFieldEntry.hpp>
15 #include <com/sun/star/lang/XServiceInfo.hpp>
16 #include <com/sun/star/beans/XPropertySet.hpp>
17 #include <com/sun/star/util/XModifyBroadcaster.hpp>
19 #include <svl/lstner.hxx>
20 #include <cppuhelper/implbase.hxx>
21 #include <rtl/ustring.hxx>
22 #include <svl/itemprop.hxx>
24 #include <vector>
25 #include <unordered_map>
27 namespace com::sun::star::chart2::data { class XDataSequence; }
28 namespace com::sun::star::chart2::data { class XDataSource; }
29 namespace com::sun::star::chart2::data { class XLabeledDataSequence; }
30 namespace com::sun::star::uno { class XComponentContext; }
32 class ScDocument;
34 namespace sc
37 struct ValueAndFormat;
39 typedef cppu::WeakImplHelper<css::chart2::data::XDataProvider,
40 css::chart2::data::XPivotTableDataProvider,
41 css::beans::XPropertySet,
42 css::lang::XServiceInfo,
43 css::util::XModifyBroadcaster>
44 PivotTableDataProvider_Base;
46 class PivotTableDataProvider final : public PivotTableDataProvider_Base, public SfxListener
48 public:
50 explicit PivotTableDataProvider(ScDocument& rDoc);
51 virtual ~PivotTableDataProvider() override;
52 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
54 // XDataProvider
55 virtual sal_Bool SAL_CALL
56 createDataSourcePossible(const css::uno::Sequence<css::beans::PropertyValue>& aArguments) override;
58 virtual css::uno::Reference<css::chart2::data::XDataSource> SAL_CALL
59 createDataSource(const css::uno::Sequence<css::beans::PropertyValue>& aArguments) override;
61 virtual css::uno::Sequence<css::beans::PropertyValue> SAL_CALL
62 detectArguments(const css::uno::Reference<css::chart2::data::XDataSource>& xDataSource) override;
64 virtual sal_Bool SAL_CALL
65 createDataSequenceByRangeRepresentationPossible(const OUString& aRangeRepresentation) override;
67 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
68 createDataSequenceByRangeRepresentation(const OUString& aRangeRepresentation) override;
70 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
71 createDataSequenceByValueArray(const OUString& aRole, const OUString& aRangeRepresentation,
72 const OUString& aRoleQualifier) override;
74 virtual css::uno::Reference<css::sheet::XRangeSelection> SAL_CALL getRangeSelection() override;
76 // XPivotTableDataProvider
77 virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL
78 getColumnFields() override;
79 virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL
80 getRowFields() override;
81 virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL
82 getPageFields() override;
83 virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL
84 getDataFields() override;
86 virtual OUString SAL_CALL getPivotTableName() override;
88 virtual void SAL_CALL setPivotTableName(const OUString& sPivotTableName) override;
90 virtual sal_Bool SAL_CALL hasPivotTable() override;
92 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
93 createDataSequenceOfValuesByIndex(sal_Int32 nIndex) override;
94 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
95 createDataSequenceOfLabelsByIndex(sal_Int32 nIndex) override;
96 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
97 createDataSequenceOfCategories() override;
99 virtual OUString SAL_CALL getFieldOutputDescription(sal_Int32 nPageFieldIndex) override;
101 // XPropertySet
102 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
104 virtual void SAL_CALL
105 setPropertyValue(const OUString& rPropertyName, const css::uno::Any& rValue) override;
107 virtual css::uno::Any SAL_CALL
108 getPropertyValue(const OUString& rPropertyName) override;
110 virtual void SAL_CALL addPropertyChangeListener(
111 const OUString& rPropertyName,
112 const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener) override;
114 virtual void SAL_CALL removePropertyChangeListener(
115 const OUString& rPropertyName,
116 const css::uno::Reference<css::beans::XPropertyChangeListener>& rListener) override;
118 virtual void SAL_CALL addVetoableChangeListener(
119 const OUString& rPropertyName,
120 const css::uno::Reference<css::beans::XVetoableChangeListener>& rListener) override;
122 virtual void SAL_CALL removeVetoableChangeListener(
123 const OUString& rPropertyName,
124 const css::uno::Reference<css::beans::XVetoableChangeListener>& rListener) override;
126 // XModifyBroadcaster
127 virtual void SAL_CALL
128 addModifyListener(const css::uno::Reference<css::util::XModifyListener>& aListener) override;
130 virtual void SAL_CALL
131 removeModifyListener(const css::uno::Reference<css::util::XModifyListener>& aListener) override;
133 // XServiceInfo
134 virtual OUString SAL_CALL getImplementationName() override;
136 virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
138 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
140 private:
142 css::uno::Reference<css::chart2::data::XDataSource>
143 createValuesDataSource();
145 css::uno::Reference<css::chart2::data::XDataSource>
146 createCategoriesDataSource(bool bOrientationIsColumn);
148 css::uno::Reference<css::chart2::data::XLabeledDataSequence> newLabeledDataSequence();
150 css::uno::Reference<css::chart2::data::XDataSequence> assignLabelsToDataSequence(size_t nIndex);
152 css::uno::Reference<css::chart2::data::XDataSequence> assignValuesToDataSequence(size_t nIndex);
154 css::uno::Reference<css::chart2::data::XDataSequence> assignFirstCategoriesToDataSequence();
156 void collectPivotTableData();
158 ScDocument* m_pDocument;
159 OUString m_sPivotTableName;
160 SfxItemPropertySet m_aPropSet;
161 bool m_bIncludeHiddenCells;
163 std::vector<std::vector<ValueAndFormat>> m_aCategoriesColumnOrientation;
164 std::vector<std::vector<ValueAndFormat>> m_aCategoriesRowOrientation;
165 std::vector<std::vector<ValueAndFormat>> m_aLabels;
166 std::vector<std::vector<ValueAndFormat>> m_aDataRowVector;
168 std::vector<css::chart2::data::PivotTableFieldEntry> m_aColumnFields;
169 std::vector<css::chart2::data::PivotTableFieldEntry> m_aRowFields;
170 std::vector<css::chart2::data::PivotTableFieldEntry> m_aPageFields;
171 std::vector<css::chart2::data::PivotTableFieldEntry> m_aDataFields;
173 std::unordered_map<sal_Int32, OUString> m_aFieldOutputDescriptionMap;
175 bool m_bNeedsUpdate;
177 css::uno::Reference<css::uno::XComponentContext> m_xContext;
179 std::vector<css::uno::Reference<css::util::XModifyListener>> m_aValueListeners;
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */