LibreOffice Module sc (master)  1
dptabdat.hxx
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  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SC_INC_DPTABDAT_HXX
21 #define INCLUDED_SC_INC_DPTABDAT_HXX
22 
23 #include "dpfilteredcache.hxx"
24 #include "calcmacros.hxx"
25 
26 #include <svl/zforlist.hxx>
27 #include <tools/long.hxx>
28 
29 #include <unordered_set>
30 #include <vector>
31 
32 #define SC_DAPI_HIERARCHY_FLAT 0
33 #define SC_DAPI_HIERARCHY_QUARTER 1
34 #define SC_DAPI_HIERARCHY_WEEK 2
35 
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
39 
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
46 
47 class ScDPResultMember;
48 class ScDPDimension;
49 class ScDPLevel;
50 class ScDPInitState;
51 class ScDocument;
52 
58 {
59  // cached data for GetDatePart
64  const ScDocument* mpDoc;
65 public:
66 
70  struct SAL_DLLPRIVATE CalcInfo
71  {
72  ::std::vector<long> aColLevelDims;
73  ::std::vector<ScDPDimension*> aColDims;
74  ::std::vector<ScDPLevel*> aColLevels;
75  ::std::vector<long> aRowLevelDims;
76  ::std::vector<ScDPDimension*> aRowDims;
77  ::std::vector<ScDPLevel*> aRowLevels;
78  ::std::vector<long> aPageDims;
79  ::std::vector<long> aDataSrcCols;
80 
84 
85  CalcInfo();
86  };
87 
88  ScDPTableData(const ScDPTableData&) = delete;
89  const ScDPTableData& operator=(const ScDPTableData&) = delete;
90  ScDPTableData(const ScDocument* pDoc);
91  virtual ~ScDPTableData();
92 
93  OUString GetFormattedString(tools::Long nDim, const ScDPItemData& rItem, bool bLocaleIndependent) const;
94 
95  tools::Long GetDatePart( tools::Long nDateVal, tools::Long nHierarchy, tools::Long nLevel );
96 
99 
100  virtual tools::Long GetColumnCount() = 0;
101  virtual const std::vector< SCROW >& GetColumnEntries( tools::Long nColumn ) ;
102  virtual OUString getDimensionName(tools::Long nColumn) = 0;
103  virtual bool getIsDataLayoutDimension(tools::Long nColumn) = 0;
104  virtual bool IsDateDimension(tools::Long nDim) = 0;
105  virtual sal_uInt32 GetNumberFormat(tools::Long nDim);
106  sal_uInt32 GetNumberFormatByIdx( NfIndexTableOffset );
107  virtual void DisposeData() = 0;
108  virtual void SetEmptyFlags( bool bIgnoreEmptyRows, bool bRepeatIfEmpty ) = 0;
109 
110  virtual bool IsRepeatIfEmpty();
111 
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;
120 
121  // override in ScDPGroupTableData:
122  virtual bool IsBaseForGroup(tools::Long nDim) const;
123  virtual tools::Long GetGroupBase(tools::Long nGroupDim) const;
124  virtual bool IsNumOrDateGroup(tools::Long nDim) const;
125  virtual bool IsInGroup( const ScDPItemData& rGroupData, tools::Long nGroupIndex,
126  const ScDPItemData& rBaseData, tools::Long nBaseIndex ) const;
127  virtual bool HasCommonElement( const ScDPItemData& rFirstData, tools::Long nFirstIndex,
128  const ScDPItemData& rSecondData, tools::Long nSecondIndex ) const;
129 
130  virtual tools::Long GetMembersCount( tools::Long nDim );
131  const ScDPItemData* GetMemberByIndex( tools::Long nDim, tools::Long nIndex );
132  virtual const ScDPItemData* GetMemberById( tools::Long nDim, tools::Long nId);
133  virtual tools::Long GetSourceDim( tools::Long nDim );
134  virtual tools::Long Compare( tools::Long nDim, tools::Long nDataId1, tools::Long nDataId2);
135 
136 #if DUMP_PIVOT_TABLE
137  virtual void Dump() const;
138 #endif
139 
140 protected:
143  struct CalcRowData
144  {
145  ::std::vector< SCROW > aColData;
146  ::std::vector< SCROW > aRowData;
147  ::std::vector< SCROW > aPageData;
148  ::std::vector<ScDPValue> aValues;
149  };
150 
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);
154 
155 private:
156  void GetItemData(const ScDPFilteredCache& rCacheTable, sal_Int32 nRow,
157  const ::std::vector<long>& rDims, ::std::vector< SCROW >& rItemData);
158 };
159 #endif
160 
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::vector< long > aColLevelDims
Definition: dptabdat.hxx:72
long Long
::std::vector< ScDPValue > aValues
Definition: dptabdat.hxx:148
Member names that are being processed for InitFrom/LateInitFrom (needed for initialization of grouped...
Definition: dptabres.hxx:56
tools::Long nLastRet
Definition: dptabdat.hxx:63
::std::vector< ScDPDimension * > aColDims
Definition: dptabdat.hxx:73
tools::Long nLastLevel
Definition: dptabdat.hxx:62
NfIndexTableOffset
tools::Long nLastHier
Definition: dptabdat.hxx:61
::std::vector< ScDPLevel * > aColLevels
Definition: dptabdat.hxx:74
const ScDocument * mpDoc
Definition: dptabdat.hxx:64
::std::vector< long > aRowLevelDims
Definition: dptabdat.hxx:75
::std::vector< ScDPDimension * > aRowDims
Definition: dptabdat.hxx:76
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
Definition: dpitemdata.hxx:29
This structure stores dimension information used when calculating results.
Definition: dptabdat.hxx:70
::std::vector< SCROW > aRowData
Definition: dptabdat.hxx:146
tools::Long nLastDateVal
Definition: dptabdat.hxx:60
static short Compare(const OUString &sInput1, const OUString &sInput2, const bool bCaseSens, const ScUserListData *pData, const CollatorWrapper *pCW)
Naturally compares two given strings.
Definition: table3.cxx:163
ScDPResultMember * pColRoot
Definition: dptabdat.hxx:82
::std::vector< SCROW > aColData
Definition: dptabdat.hxx:145
::std::vector< long > aPageDims
Definition: dptabdat.hxx:78
Base class that abstracts different data source types of a datapilot table.
Definition: dptabdat.hxx:57
This structure stores vector arrays that hold intermediate data for each row during cache table itera...
Definition: dptabdat.hxx:143
ScDPInitState * pInitState
Definition: dptabdat.hxx:81
::std::vector< SCROW > aPageData
Definition: dptabdat.hxx:147
::std::vector< ScDPLevel * > aRowLevels
Definition: dptabdat.hxx:77
::std::vector< long > aDataSrcCols
Definition: dptabdat.hxx:79
ScDPResultMember * pRowRoot
Definition: dptabdat.hxx:83
This class is only a wrapper to the actual cache, to provide filtering on the raw data based on the q...
#define SC_DLLPUBLIC
Definition: scdllapi.h:28