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 
16 namespace sc {
17 
19  mpDP(pObj), maSelectedPages(rSelected) {}
20 
22  mpDP(pObj), maDesc(rDesc) {}
23 
25  mpDP(pObj), maDesc(rDesc) {}
26 
28  mpDP(pObj), maDesc(rDesc) {}
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, rSelected);
53 }
54 
55 namespace {
56 
57 struct 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 
81 struct PivotSheetDescSetter
82 {
83  void operator() ( sc::PivotTableSources::SheetSource& rSrc )
84  {
85  ScDPObject* pObj = rSrc.mpDP;
86  pObj->SetSheetDesc(rSrc.maDesc);
87  }
88 };
89 
90 struct PivotDBDescSetter
91 {
92  void operator() ( sc::PivotTableSources::DBSource& rSrc )
93  {
94  ScDPObject* pObj = rSrc.mpDP;
95  pObj->SetImportDesc(rSrc.maDesc);
96  }
97 };
98 
99 struct 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: */
std::vector< DBSource > maDBSources
Definition: pivotsource.hxx:64
std::vector< ServiceSource > maServiceSources
Definition: pivotsource.hxx:65
ServiceSource(ScDPObject *pObj, const ScDPServiceDesc &rDesc)
Definition: pivotsource.cxx:27
void appendSheetSource(ScDPObject *pObj, const ScSheetSourceDesc &rDesc)
Definition: pivotsource.cxx:32
void appendServiceSource(ScDPObject *pObj, const ScDPServiceDesc &rDesc)
Definition: pivotsource.cxx:42
std::vector< SheetSource > maSheetSources
Definition: pivotsource.hxx:63
void SetImportDesc(const ScImportSourceDesc &rDesc)
Definition: dpobject.cxx:438
SelectedPages(ScDPObject *pObj, const SelectedPagesType &rSelected)
Definition: pivotsource.cxx:18
void SetSheetDesc(const ScSheetSourceDesc &rDesc)
Definition: dpobject.cxx:414
std::vector< SelectedPages > maSelectedPagesList
Definition: pivotsource.hxx:62
void appendSelectedPages(ScDPObject *pObj, const SelectedPagesType &rSelected)
Definition: pivotsource.cxx:47
DBSource(ScDPObject *pObj, const ScImportSourceDesc &rDesc)
Definition: pivotsource.cxx:24
void SetCurrentPage(const OUString *pPage)
Definition: dpsave.cxx:426
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDimensionByName(const OUString &rName) const
Definition: dpsave.cxx:846
ScDPSaveData * GetSaveData() const
Definition: dpobject.hxx:141
SheetSource(ScDPObject *pObj, const ScSheetSourceDesc &rDesc)
Definition: pivotsource.cxx:21
void SetServiceData(const ScDPServiceDesc &rDesc)
Definition: dpobject.cxx:451
std::unordered_map< OUString, OUString > SelectedPagesType
Definition: pivotsource.hxx:28
void appendDBSource(ScDPObject *pObj, const ScImportSourceDesc &rDesc)
Definition: pivotsource.cxx:37
void BuildAllDimensionMembers()
Definition: dpobject.cxx:960
This class contains authoritative information on the internal reference used as the data source for d...
Definition: dpshttab.hxx:39