Revert "tdf#110987: type detection, binary Office formats > templates"
[LibreOffice.git] / sc / inc / PivotTableDataProvider.hxx
blob1403dfdad3d204164004f66df789e8083abd7f24
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 <com/sun/star/chart2/data/XDataProvider.hpp>
14 #include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
15 #include <com/sun/star/chart2/data/PivotTableFieldEntry.hpp>
16 #include <com/sun/star/lang/XServiceInfo.hpp>
17 #include <com/sun/star/beans/XPropertySet.hpp>
18 #include <com/sun/star/util/XModifyBroadcaster.hpp>
20 #include <svl/lstner.hxx>
21 #include <cppuhelper/implbase.hxx>
22 #include <rtl/ustring.hxx>
23 #include <svl/itemprop.hxx>
25 #include <vector>
26 #include <unordered_map>
28 namespace com { namespace sun { namespace star { namespace chart2 { namespace data { class XDataSequence; } } } } }
29 namespace com { namespace sun { namespace star { namespace chart2 { namespace data { class XDataSource; } } } } }
30 namespace com { namespace sun { namespace star { namespace chart2 { namespace data { class XLabeledDataSequence; } } } } }
31 namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } } } }
33 class ScDocument;
35 namespace sc
38 struct ValueAndFormat;
40 typedef cppu::WeakImplHelper<css::chart2::data::XDataProvider,
41 css::chart2::data::XPivotTableDataProvider,
42 css::beans::XPropertySet,
43 css::lang::XServiceInfo,
44 css::util::XModifyBroadcaster>
45 PivotTableDataProvider_Base;
47 class PivotTableDataProvider : public PivotTableDataProvider_Base, public SfxListener
49 public:
51 explicit PivotTableDataProvider(ScDocument* pDoc);
52 virtual ~PivotTableDataProvider() override;
53 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
55 // XDataProvider
56 virtual sal_Bool SAL_CALL
57 createDataSourcePossible(const css::uno::Sequence<css::beans::PropertyValue>& aArguments) override;
59 virtual css::uno::Reference<css::chart2::data::XDataSource> SAL_CALL
60 createDataSource(const css::uno::Sequence<css::beans::PropertyValue>& aArguments) override;
62 virtual css::uno::Sequence<css::beans::PropertyValue> SAL_CALL
63 detectArguments(const css::uno::Reference<css::chart2::data::XDataSource>& xDataSource) override;
65 virtual sal_Bool SAL_CALL
66 createDataSequenceByRangeRepresentationPossible(const OUString& aRangeRepresentation) override;
68 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
69 createDataSequenceByRangeRepresentation(const OUString& aRangeRepresentation) override;
71 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
72 createDataSequenceByValueArray(const OUString& aRole, const OUString& aRangeRepresentation) 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 #endif // INCLUDED_SC_INC_PIVOTTABLEDATAPROVIDER_HXX
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */