Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / inc / xepivotxml.hxx
blob30fb25a30f48a4085c07e69b9170d1eee219e04b
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 #pragma once
12 #include "xerecord.hxx"
13 #include "xeroot.hxx"
15 #include <memory>
16 #include <map>
17 #include <unordered_map>
19 class ScDPCache;
20 class ScDPObject;
22 class XclExpXmlPivotCaches : public XclExpRecordBase, protected XclExpRoot
24 public:
25 struct Entry
27 const ScDPCache* mpCache;
28 ScRange maSrcRange;
31 XclExpXmlPivotCaches(const XclExpRoot& rRoot);
32 virtual void SaveXml(XclExpXmlStream& rStrm) override;
34 void SetCaches(std::vector<Entry>&& rCaches);
35 bool HasCaches() const;
36 const Entry* GetCache(sal_Int32 nCacheId) const;
38 private:
39 void SavePivotCacheXml(XclExpXmlStream& rStrm, const Entry& rEntry, sal_Int32 nCacheId);
41 private:
42 std::vector<Entry> maCaches;
45 class XclExpXmlPivotTables : public XclExpRecordBase, protected XclExpRoot
47 struct Entry
49 const ScDPObject* mpTable;
50 sal_Int32 mnCacheId;
51 sal_Int32 mnPivotId; /// used as [n] in pivotTable[n].xml part name.
53 Entry(const ScDPObject* pTable, sal_Int32 nCacheId, sal_Int32 nPivotId);
56 const XclExpXmlPivotCaches& mrCaches;
57 typedef std::vector<Entry> TablesType;
58 TablesType maTables;
60 public:
61 XclExpXmlPivotTables(const XclExpRoot& rRoot, const XclExpXmlPivotCaches& rCaches);
63 virtual void SaveXml(XclExpXmlStream& rStrm) override;
65 void AppendTable(const ScDPObject* pTable, sal_Int32 nCacheId, sal_Int32 nPivotId);
67 private:
68 void SavePivotTableXml(XclExpXmlStream& rStrm, const ScDPObject& rObj, sal_Int32 nCacheId);
71 class XclExpXmlPivotTableManager : protected XclExpRoot
73 typedef std::map<SCTAB, std::unique_ptr<XclExpXmlPivotTables>> TablesType;
74 typedef std::unordered_map<const ScDPObject*, sal_Int32> CacheIdMapType;
76 public:
77 XclExpXmlPivotTableManager(const XclExpRoot& rRoot);
79 void Initialize();
81 XclExpXmlPivotCaches& GetCaches();
82 XclExpXmlPivotTables* GetTablesBySheet(SCTAB nTab);
84 private:
85 XclExpXmlPivotCaches maCaches;
86 TablesType m_Tables;
87 CacheIdMapType maCacheIdMap;
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */