LibreOffice Module sc (master) 1
pivotsource.cxx
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#include "pivotsource.hxx"
11
12#include <dpsave.hxx>
13
14#include <algorithm>
15
16namespace sc {
17
19 mpDP(pObj), maSelectedPages(std::move(rSelected)) {}
20
22 mpDP(pObj), maDesc(std::move(aDesc)) {}
23
25 mpDP(pObj), maDesc(std::move(aDesc)) {}
26
28 mpDP(pObj), maDesc(std::move(aDesc)) {}
29
31
33{
34 maSheetSources.emplace_back(pObj, rDesc);
35}
36
38{
39 maDBSources.emplace_back(pObj, rDesc);
40}
41
43{
44 maServiceSources.emplace_back(pObj, rDesc);
45}
46
48{
49 if (rSelected.empty())
50 return;
51
52 maSelectedPagesList.emplace_back(pObj, std::move(rSelected));
53}
54
55namespace {
56
57struct SelectedPageProcessor
58{
59 void operator() ( PivotTableSources::SelectedPages& rItem )
60 {
61 // Set selected pages after building all dimension members.
62 if (!rItem.mpDP)
63 return;
64
66 ScDPSaveData* pSaveData = rItem.mpDP->GetSaveData();
67 if (!pSaveData)
68 return;
69
70 for (const auto& [rDimName, rSelected] : rItem.maSelectedPages)
71 {
72 ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName(rDimName);
73 if (!pDim)
74 continue;
75
76 pDim->SetCurrentPage(&rSelected);
77 }
78 }
79};
80
81struct PivotSheetDescSetter
82{
83 void operator() ( sc::PivotTableSources::SheetSource& rSrc )
84 {
85 ScDPObject* pObj = rSrc.mpDP;
86 pObj->SetSheetDesc(rSrc.maDesc);
87 }
88};
89
90struct PivotDBDescSetter
91{
92 void operator() ( sc::PivotTableSources::DBSource& rSrc )
93 {
94 ScDPObject* pObj = rSrc.mpDP;
95 pObj->SetImportDesc(rSrc.maDesc);
96 }
97};
98
99struct PivotServiceDataSetter
100{
101 void operator() ( sc::PivotTableSources::ServiceSource& rSrc )
102 {
103 ScDPObject* pObj = rSrc.mpDP;
104 pObj->SetServiceData(rSrc.maDesc);
105 }
106};
107
108}
109
111{
112 std::for_each(maSheetSources.begin(), maSheetSources.end(), PivotSheetDescSetter());
113 std::for_each(maDBSources.begin(), maDBSources.end(), PivotDBDescSetter());
114 std::for_each(maServiceSources.begin(), maServiceSources.end(), PivotServiceDataSetter());
115 std::for_each(maSelectedPagesList.begin(), maSelectedPagesList.end(), SelectedPageProcessor());
116}
117
118}
119
120/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetImportDesc(const ScImportSourceDesc &rDesc)
Definition: dpobject.cxx:439
void BuildAllDimensionMembers()
Definition: dpobject.cxx:960
void SetSheetDesc(const ScSheetSourceDesc &rDesc)
Definition: dpobject.cxx:415
void SetServiceData(const ScDPServiceDesc &rDesc)
Definition: dpobject.cxx:452
ScDPSaveData * GetSaveData() const
Definition: dpobject.hxx:141
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDimensionByName(std::u16string_view rName) const
Definition: dpsave.cxx:849
void SetCurrentPage(const OUString *pPage)
Definition: dpsave.cxx:428
This class contains authoritative information on the internal reference used as the data source for d...
Definition: dpshttab.hxx:40
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
DBSource(ScDPObject *pObj, ScImportSourceDesc aDesc)
Definition: pivotsource.cxx:24
SelectedPages(ScDPObject *pObj, SelectedPagesType &&rSelected)
Definition: pivotsource.cxx:18
ServiceSource(ScDPObject *pObj, ScDPServiceDesc aDesc)
Definition: pivotsource.cxx:27
SheetSource(ScDPObject *pObj, ScSheetSourceDesc aDesc)
Definition: pivotsource.cxx:21
void appendSelectedPages(ScDPObject *pObj, SelectedPagesType &&rSelected)
Definition: pivotsource.cxx:47
void appendSheetSource(ScDPObject *pObj, const ScSheetSourceDesc &rDesc)
Definition: pivotsource.cxx:32
std::vector< ServiceSource > maServiceSources
Definition: pivotsource.hxx:64
std::vector< SelectedPages > maSelectedPagesList
Definition: pivotsource.hxx:61
void appendDBSource(ScDPObject *pObj, const ScImportSourceDesc &rDesc)
Definition: pivotsource.cxx:37
std::vector< DBSource > maDBSources
Definition: pivotsource.hxx:63
std::unordered_map< OUString, OUString > SelectedPagesType
Definition: pivotsource.hxx:27
std::vector< SheetSource > maSheetSources
Definition: pivotsource.hxx:62
void appendServiceSource(ScDPObject *pObj, const ScDPServiceDesc &rDesc)
Definition: pivotsource.cxx:42