1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "xerecord.hxx"
#include "xeroot.hxx"
#include <memory>
#include <map>
#include <unordered_map>
class ScDPCache;
class ScDPObject;
class XclExpXmlPivotCaches : public XclExpRecordBase, protected XclExpRoot
{
public:
struct Entry
{
const ScDPCache* mpCache;
ScRange maSrcRange;
};
XclExpXmlPivotCaches(const XclExpRoot& rRoot);
virtual void SaveXml(XclExpXmlStream& rStrm) override;
void SetCaches(std::vector<Entry>&& rCaches);
bool HasCaches() const;
const Entry* GetCache(sal_Int32 nCacheId) const;
private:
void SavePivotCacheXml(XclExpXmlStream& rStrm, const Entry& rEntry, sal_Int32 nCacheId);
private:
std::vector<Entry> maCaches;
};
class XclExpXmlPivotTables : public XclExpRecordBase, protected XclExpRoot
{
struct Entry
{
const ScDPObject* mpTable;
sal_Int32 mnCacheId;
sal_Int32 mnPivotId; /// used as [n] in pivotTable[n].xml part name.
Entry(const ScDPObject* pTable, sal_Int32 nCacheId, sal_Int32 nPivotId);
};
const XclExpXmlPivotCaches& mrCaches;
typedef std::vector<Entry> TablesType;
TablesType maTables;
public:
XclExpXmlPivotTables(const XclExpRoot& rRoot, const XclExpXmlPivotCaches& rCaches);
virtual void SaveXml(XclExpXmlStream& rStrm) override;
void AppendTable(const ScDPObject* pTable, sal_Int32 nCacheId, sal_Int32 nPivotId);
private:
void SavePivotTableXml(XclExpXmlStream& rStrm, const ScDPObject& rObj, sal_Int32 nCacheId);
};
class XclExpXmlPivotTableManager : protected XclExpRoot
{
typedef std::map<SCTAB, std::unique_ptr<XclExpXmlPivotTables>> TablesType;
typedef std::unordered_map<const ScDPObject*, sal_Int32> CacheIdMapType;
public:
XclExpXmlPivotTableManager(const XclExpRoot& rRoot);
void Initialize();
XclExpXmlPivotCaches& GetCaches();
XclExpXmlPivotTables* GetTablesBySheet(SCTAB nTab);
private:
XclExpXmlPivotCaches maCaches;
TablesType m_Tables;
CacheIdMapType maCacheIdMap;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|