Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sc / inc / PivotTableDataProvider.hxx
blobb1924753ece3a58d0cfeddbe56dbbf111cb25abe
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 #ifndef INCLUDED_SC_INC_PIVOTTABLEDATAPROVIDER_HXX
11 #define INCLUDED_SC_INC_PIVOTTABLEDATAPROVIDER_HXX
13 #include "cellsuno.hxx"
14 #include "externalrefmgr.hxx"
15 #include "types.hxx"
17 #include <com/sun/star/chart2/data/XDataProvider.hpp>
18 #include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
19 #include <com/sun/star/chart2/data/XDataSource.hpp>
20 #include <com/sun/star/chart2/data/XDataSequence.hpp>
21 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
22 #include <com/sun/star/chart2/data/PivotTableFieldEntry.hpp>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/util/XCloneable.hpp>
26 #include <com/sun/star/util/XModifyBroadcaster.hpp>
28 #include <svl/lstner.hxx>
29 #include <cppuhelper/implbase.hxx>
30 #include <rtl/ustring.hxx>
31 #include <svl/itemprop.hxx>
33 #include <memory>
34 #include <vector>
36 namespace sc
39 struct ValueAndFormat;
41 typedef cppu::WeakImplHelper<css::chart2::data::XDataProvider,
42 css::chart2::data::XPivotTableDataProvider,
43 css::beans::XPropertySet,
44 css::lang::XServiceInfo,
45 css::util::XModifyBroadcaster>
46 PivotTableDataProvider_Base;
48 class PivotTableDataProvider : public PivotTableDataProvider_Base, public SfxListener
50 public:
52 explicit PivotTableDataProvider(ScDocument* pDoc);
53 virtual ~PivotTableDataProvider() override;
54 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
56 // XDataProvider
57 virtual sal_Bool SAL_CALL
58 createDataSourcePossible(const css::uno::Sequence<css::beans::PropertyValue>& aArguments) override;
60 virtual css::uno::Reference<css::chart2::data::XDataSource> SAL_CALL
61 createDataSource(const css::uno::Sequence<css::beans::PropertyValue>& aArguments) override;
63 virtual css::uno::Sequence<css::beans::PropertyValue> SAL_CALL
64 detectArguments(const css::uno::Reference<css::chart2::data::XDataSource>& xDataSource) override;
66 virtual sal_Bool SAL_CALL
67 createDataSequenceByRangeRepresentationPossible(const OUString& aRangeRepresentation) override;
69 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
70 createDataSequenceByRangeRepresentation(const OUString& aRangeRepresentation) override;
72 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
73 createDataSequenceByValueArray(const OUString& aRole, const OUString& aRangeRepresentation) override;
75 virtual css::uno::Reference<css::sheet::XRangeSelection> SAL_CALL getRangeSelection() override;
77 // XPivotTableDataProvider
78 virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL
79 getColumnFields() override;
80 virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL
81 getRowFields() override;
82 virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL
83 getPageFields() override;
84 virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL
85 getDataFields() override;
87 virtual OUString SAL_CALL getPivotTableName() override;
89 virtual void SAL_CALL setPivotTableName(const OUString& sPivotTableName) override;
91 virtual sal_Bool SAL_CALL hasPivotTable() override;
93 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
94 createDataSequenceOfValuesByIndex(sal_Int32 nIndex) override;
95 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
96 createDataSequenceOfLabelsByIndex(sal_Int32 nIndex) override;
97 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
98 createDataSequenceOfCategories() override;
100 virtual OUString SAL_CALL getFieldOutputDescription(sal_Int32 nPageFieldIndex) override;
102 // XPropertySet
103 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
105 virtual void SAL_CALL
106 setPropertyValue(const OUString& rPropertyName, const css::uno::Any& rValue) override;
108 virtual css::uno::Any SAL_CALL
109 getPropertyValue(const OUString& rPropertyName) override;
111 virtual void SAL_CALL addPropertyChangeListener(
112 const OUString& rPropertyName,
113 const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener) override;
115 virtual void SAL_CALL removePropertyChangeListener(
116 const OUString& rPropertyName,
117 const css::uno::Reference<css::beans::XPropertyChangeListener>& rListener) override;
119 virtual void SAL_CALL addVetoableChangeListener(
120 const OUString& rPropertyName,
121 const css::uno::Reference<css::beans::XVetoableChangeListener>& rListener) override;
123 virtual void SAL_CALL removeVetoableChangeListener(
124 const OUString& rPropertyName,
125 const css::uno::Reference<css::beans::XVetoableChangeListener>& rListener) override;
127 // XModifyBroadcaster
128 virtual void SAL_CALL
129 addModifyListener(const css::uno::Reference<css::util::XModifyListener>& aListener) override;
131 virtual void SAL_CALL
132 removeModifyListener(const css::uno::Reference<css::util::XModifyListener>& aListener) override;
134 // XServiceInfo
135 virtual OUString SAL_CALL getImplementationName() override;
137 virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
139 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
141 private:
143 css::uno::Reference<css::chart2::data::XDataSource>
144 createValuesDataSource();
146 css::uno::Reference<css::chart2::data::XDataSource>
147 createCategoriesDataSource(bool bOrientationIsColumn);
149 css::uno::Reference<css::chart2::data::XLabeledDataSequence> newLabeledDataSequence();
151 css::uno::Reference<css::chart2::data::XDataSequence> assignLabelsToDataSequence(size_t nIndex);
153 css::uno::Reference<css::chart2::data::XDataSequence> assignValuesToDataSequence(size_t nIndex);
155 css::uno::Reference<css::chart2::data::XDataSequence> assignFirstCategoriesToDataSequence();
157 void collectPivotTableData();
159 ScDocument* m_pDocument;
160 OUString m_sPivotTableName;
161 SfxItemPropertySet m_aPropSet;
162 bool m_bIncludeHiddenCells;
164 std::vector<std::vector<ValueAndFormat>> m_aCategoriesColumnOrientation;
165 std::vector<std::vector<ValueAndFormat>> m_aCategoriesRowOrientation;
166 std::vector<std::vector<ValueAndFormat>> m_aLabels;
167 std::vector<std::vector<ValueAndFormat>> m_aDataRowVector;
169 std::vector<css::chart2::data::PivotTableFieldEntry> m_aColumnFields;
170 std::vector<css::chart2::data::PivotTableFieldEntry> m_aRowFields;
171 std::vector<css::chart2::data::PivotTableFieldEntry> m_aPageFields;
172 std::vector<css::chart2::data::PivotTableFieldEntry> m_aDataFields;
174 std::unordered_map<sal_Int32, OUString> m_aFieldOutputDescriptionMap;
176 bool m_bNeedsUpdate;
178 css::uno::Reference<css::uno::XComponentContext> m_xContext;
180 std::vector<css::uno::Reference<css::util::XModifyListener>> m_aValueListeners;
185 #endif // INCLUDED_SC_INC_PIVOTTABLEDATAPROVIDER_HXX
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */