nss: upgrade to release 3.73
[LibreOffice.git] / sc / inc / dptabdat.hxx
blob2fd4064495aa936b58d2f13f89743ea7c99d6f80
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_INC_DPTABDAT_HXX
21 #define INCLUDED_SC_INC_DPTABDAT_HXX
23 #include "dpfilteredcache.hxx"
24 #include "calcmacros.hxx"
26 #include <svl/zforlist.hxx>
27 #include <tools/long.hxx>
29 #include <unordered_set>
30 #include <vector>
32 #define SC_DAPI_HIERARCHY_FLAT 0
33 #define SC_DAPI_HIERARCHY_QUARTER 1
34 #define SC_DAPI_HIERARCHY_WEEK 2
36 #define SC_DAPI_FLAT_LEVELS 1 // single level for flat dates
37 #define SC_DAPI_QUARTER_LEVELS 4 // levels in year/quarter/month/day hierarchy
38 #define SC_DAPI_WEEK_LEVELS 3 // levels in year/week/day hierarchy
40 #define SC_DAPI_LEVEL_YEAR 0
41 #define SC_DAPI_LEVEL_QUARTER 1
42 #define SC_DAPI_LEVEL_MONTH 2
43 #define SC_DAPI_LEVEL_DAY 3
44 #define SC_DAPI_LEVEL_WEEK 4
45 #define SC_DAPI_LEVEL_WEEKDAY 5
47 class ScDPResultMember;
48 class ScDPDimension;
49 class ScDPLevel;
50 class ScDPInitState;
51 class ScDocument;
53 /**
54 * Base class that abstracts different data source types of a datapilot
55 * table.
57 class SC_DLLPUBLIC ScDPTableData
59 // cached data for GetDatePart
60 tools::Long nLastDateVal;
61 tools::Long nLastHier;
62 tools::Long nLastLevel;
63 tools::Long nLastRet;
64 const ScDocument* mpDoc;
65 public:
67 /** This structure stores dimension information used when calculating
68 results. These data are read only during result calculation, so it
69 should be passed as a const instance. */
70 struct SAL_DLLPRIVATE CalcInfo
72 ::std::vector<sal_Int32> aColLevelDims;
73 ::std::vector<ScDPDimension*> aColDims;
74 ::std::vector<ScDPLevel*> aColLevels;
75 ::std::vector<sal_Int32> aRowLevelDims;
76 ::std::vector<ScDPDimension*> aRowDims;
77 ::std::vector<ScDPLevel*> aRowLevels;
78 ::std::vector<sal_Int32> aPageDims;
79 ::std::vector<sal_Int32> aDataSrcCols;
81 ScDPInitState* pInitState;
82 ScDPResultMember* pColRoot;
83 ScDPResultMember* pRowRoot;
85 CalcInfo();
88 ScDPTableData(const ScDPTableData&) = delete;
89 const ScDPTableData& operator=(const ScDPTableData&) = delete;
90 ScDPTableData(const ScDocument* pDoc);
91 virtual ~ScDPTableData();
93 OUString GetFormattedString(sal_Int32 nDim, const ScDPItemData& rItem, bool bLocaleIndependent) const;
95 tools::Long GetDatePart( tools::Long nDateVal, tools::Long nHierarchy, tools::Long nLevel );
97 //! use (new) typed collection instead of ScStrCollection
98 //! or separate Str and ValueCollection
100 virtual sal_Int32 GetColumnCount() = 0;
101 virtual const std::vector< SCROW >& GetColumnEntries( sal_Int32 nColumn ) ;
102 virtual OUString getDimensionName(sal_Int32 nColumn) = 0;
103 virtual bool getIsDataLayoutDimension(sal_Int32 nColumn) = 0;
104 virtual bool IsDateDimension(sal_Int32 nDim) = 0;
105 virtual sal_uInt32 GetNumberFormat(sal_Int32 nDim);
106 sal_uInt32 GetNumberFormatByIdx( NfIndexTableOffset );
107 virtual void DisposeData() = 0;
108 virtual void SetEmptyFlags( bool bIgnoreEmptyRows, bool bRepeatIfEmpty ) = 0;
110 virtual bool IsRepeatIfEmpty();
112 virtual void CreateCacheTable() = 0;
113 virtual void FilterCacheTable(const std::vector<ScDPFilteredCache::Criterion>& rCriteria, const std::unordered_set<sal_Int32>& rDataDims) = 0;
114 virtual void GetDrillDownData(const std::vector<ScDPFilteredCache::Criterion>& rCriteria,
115 const std::unordered_set<sal_Int32>& rCatDims,
116 css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& rData) = 0;
117 virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow) = 0;
118 virtual const ScDPFilteredCache& GetCacheTable() const = 0;
119 virtual void ReloadCacheTable() = 0;
121 // override in ScDPGroupTableData:
122 virtual bool IsBaseForGroup(sal_Int32 nDim) const;
123 virtual sal_Int32 GetGroupBase(sal_Int32 nGroupDim) const;
124 virtual bool IsNumOrDateGroup(sal_Int32 nDim) const;
125 virtual bool IsInGroup( const ScDPItemData& rGroupData, sal_Int32 nGroupIndex,
126 const ScDPItemData& rBaseData, sal_Int32 nBaseIndex ) const;
127 virtual bool HasCommonElement( const ScDPItemData& rFirstData, sal_Int32 nFirstIndex,
128 const ScDPItemData& rSecondData, sal_Int32 nSecondIndex ) const;
130 virtual sal_Int32 GetMembersCount( sal_Int32 nDim );
131 const ScDPItemData* GetMemberByIndex( sal_Int32 nDim, sal_Int32 nIndex );
132 virtual const ScDPItemData* GetMemberById( sal_Int32 nDim, sal_Int32 nId);
133 virtual sal_Int32 GetSourceDim( sal_Int32 nDim );
134 virtual sal_Int32 Compare( sal_Int32 nDim, sal_Int32 nDataId1, sal_Int32 nDataId2);
136 #if DUMP_PIVOT_TABLE
137 virtual void Dump() const;
138 #endif
140 protected:
141 /** This structure stores vector arrays that hold intermediate data for
142 each row during cache table iteration. */
143 struct CalcRowData
145 ::std::vector< SCROW > aColData;
146 ::std::vector< SCROW > aRowData;
147 ::std::vector< SCROW > aPageData;
148 ::std::vector<ScDPValue> aValues;
151 void FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPFilteredCache& rCacheTable, const CalcInfo& rInfo, CalcRowData& rData);
152 static void ProcessRowData(CalcInfo& rInfo, const CalcRowData& rData, bool bAutoShow);
153 void CalcResultsFromCacheTable(const ScDPFilteredCache& rCacheTable, CalcInfo& rInfo, bool bAutoShow);
155 private:
156 void GetItemData(const ScDPFilteredCache& rCacheTable, sal_Int32 nRow,
157 const ::std::vector<sal_Int32>& rDims, ::std::vector< SCROW >& rItemData);
159 #endif
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */