Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / inc / xepivotxml.hxx
blobe068a777386686eeccb99714656a024148722bb0
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_FILTER_XEPIVOTXML_HXX
11 #define INCLUDED_SC_FILTER_XEPIVOTXML_HXX
13 #include "xerecord.hxx"
14 #include "xeroot.hxx"
16 #include <memory>
17 #include <map>
18 #include <unordered_map>
20 class ScDPCache;
21 class ScDPObject;
23 class XclExpXmlPivotCaches : public XclExpRecordBase, protected XclExpRoot
25 public:
26 struct Entry
28 const ScDPCache* mpCache;
29 ScRange maSrcRange;
32 XclExpXmlPivotCaches( const XclExpRoot& rRoot );
33 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
35 void SetCaches( const std::vector<Entry>& rCaches );
36 bool HasCaches() const;
37 const Entry* GetCache( sal_Int32 nCacheId ) const;
39 private:
40 void SavePivotCacheXml( XclExpXmlStream& rStrm, const Entry& rEntry, sal_Int32 nCacheId );
42 private:
43 std::vector<Entry> maCaches;
46 class XclExpXmlPivotTables : public XclExpRecordBase, protected XclExpRoot
48 struct Entry
50 const ScDPObject* mpTable;
51 sal_Int32 const mnCacheId;
52 sal_Int32 const mnPivotId; /// used as [n] in pivotTable[n].xml part name.
54 Entry( const ScDPObject* pTable, sal_Int32 nCacheId, sal_Int32 nPivotId );
57 const XclExpXmlPivotCaches& mrCaches;
58 typedef std::vector<Entry> TablesType;
59 TablesType maTables;
61 public:
62 XclExpXmlPivotTables( const XclExpRoot& rRoot, const XclExpXmlPivotCaches& rCaches );
64 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
66 void AppendTable( const ScDPObject* pTable, sal_Int32 nCacheId, sal_Int32 nPivotId );
68 private:
69 void SavePivotTableXml( XclExpXmlStream& rStrm, const ScDPObject& rObj, sal_Int32 nCacheId );
72 class XclExpXmlPivotTableManager : protected XclExpRoot
74 typedef std::map<SCTAB, std::unique_ptr<XclExpXmlPivotTables>> TablesType;
75 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 #endif
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */