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 #pragma once
21 
22 #include "dpfilteredcache.hxx"
23 #include "calcmacros.hxx"
24 
25 #include <svl/zforlist.hxx>
26 #include <tools/long.hxx>
27 
28 #include <unordered_set>
29 #include <vector>
30 
31 #define SC_DAPI_HIERARCHY_FLAT 0
32 #define SC_DAPI_HIERARCHY_QUARTER 1
33 #define SC_DAPI_HIERARCHY_WEEK 2
34 
35 #define SC_DAPI_FLAT_LEVELS 1 // single level for flat dates
36 #define SC_DAPI_QUARTER_LEVELS 4 // levels in year/quarter/month/day hierarchy
37 #define SC_DAPI_WEEK_LEVELS 3 // levels in year/week/day hierarchy
38 
39 #define SC_DAPI_LEVEL_YEAR 0
40 #define SC_DAPI_LEVEL_QUARTER 1
41 #define SC_DAPI_LEVEL_MONTH 2
42 #define SC_DAPI_LEVEL_DAY 3
43 #define SC_DAPI_LEVEL_WEEK 4
44 #define SC_DAPI_LEVEL_WEEKDAY 5
45 
46 class ScDPResultMember;
47 class ScDPDimension;
48 class ScDPLevel;
49 class ScDPInitState;
50 class ScDocument;
51 
57 {
58  // cached data for GetDatePart
63  const ScDocument* mpDoc;
64 public:
65 
69  struct SAL_DLLPRIVATE CalcInfo
70  {
71  ::std::vector<sal_Int32> aColLevelDims;
72  ::std::vector<ScDPDimension*> aColDims;
73  ::std::vector<ScDPLevel*> aColLevels;
74  ::std::vector<sal_Int32> aRowLevelDims;
75  ::std::vector<ScDPDimension*> aRowDims;
76  ::std::vector<ScDPLevel*> aRowLevels;
77  ::std::vector<sal_Int32> aPageDims;
78  ::std::vector<sal_Int32> aDataSrcCols;
79 
83 
84  CalcInfo();
85  };
86 
87  ScDPTableData(const ScDPTableData&) = delete;
88  const ScDPTableData& operator=(const ScDPTableData&) = delete;
89  ScDPTableData(const ScDocument* pDoc);
90  virtual ~ScDPTableData();
91 
92  OUString GetFormattedString(sal_Int32 nDim, const ScDPItemData& rItem, bool bLocaleIndependent) const;
93 
94  tools::Long GetDatePart( tools::Long nDateVal, tools::Long nHierarchy, tools::Long nLevel );
95 
98 
99  virtual sal_Int32 GetColumnCount() = 0;
100  virtual const std::vector< SCROW >& GetColumnEntries( sal_Int32 nColumn ) ;
101  virtual OUString getDimensionName(sal_Int32 nColumn) = 0;
102  virtual bool getIsDataLayoutDimension(sal_Int32 nColumn) = 0;
103  virtual bool IsDateDimension(sal_Int32 nDim) = 0;
104  virtual sal_uInt32 GetNumberFormat(sal_Int32 nDim);
105  sal_uInt32 GetNumberFormatByIdx( NfIndexTableOffset );
106  virtual void DisposeData() = 0;
107  virtual void SetEmptyFlags( bool bIgnoreEmptyRows, bool bRepeatIfEmpty ) = 0;
108 
109  virtual bool IsRepeatIfEmpty();
110 
111  virtual void CreateCacheTable() = 0;
112  virtual void FilterCacheTable(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, std::unordered_set<sal_Int32>&& rDataDims) = 0;
113  virtual void GetDrillDownData(std::vector<ScDPFilteredCache::Criterion>&& rCriteria,
114  std::unordered_set<sal_Int32>&& rCatDims,
115  css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& rData) = 0;
116  virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow) = 0;
117  virtual const ScDPFilteredCache& GetCacheTable() const = 0;
118  virtual void ReloadCacheTable() = 0;
119 
120  // override in ScDPGroupTableData:
121  virtual bool IsBaseForGroup(sal_Int32 nDim) const;
122  virtual sal_Int32 GetGroupBase(sal_Int32 nGroupDim) const;
123  virtual bool IsNumOrDateGroup(sal_Int32 nDim) const;
124  virtual bool IsInGroup( const ScDPItemData& rGroupData, sal_Int32 nGroupIndex,
125  const ScDPItemData& rBaseData, sal_Int32 nBaseIndex ) const;
126  virtual bool HasCommonElement( const ScDPItemData& rFirstData, sal_Int32 nFirstIndex,
127  const ScDPItemData& rSecondData, sal_Int32 nSecondIndex ) const;
128 
129  virtual sal_Int32 GetMembersCount( sal_Int32 nDim );
130  const ScDPItemData* GetMemberByIndex( sal_Int32 nDim, sal_Int32 nIndex );
131  virtual const ScDPItemData* GetMemberById( sal_Int32 nDim, sal_Int32 nId);
132  virtual sal_Int32 GetSourceDim( sal_Int32 nDim );
133  virtual sal_Int32 Compare( sal_Int32 nDim, sal_Int32 nDataId1, sal_Int32 nDataId2);
134 
135 #if DUMP_PIVOT_TABLE
136  virtual void Dump() const;
137 #endif
138 
139 protected:
142  struct CalcRowData
143  {
144  ::std::vector< SCROW > aColData;
145  ::std::vector< SCROW > aRowData;
146  ::std::vector< SCROW > aPageData;
147  ::std::vector<ScDPValue> aValues;
148  };
149 
150  void FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPFilteredCache& rCacheTable, const CalcInfo& rInfo, CalcRowData& rData);
151  static void ProcessRowData(CalcInfo& rInfo, const CalcRowData& rData, bool bAutoShow);
152  void CalcResultsFromCacheTable(const ScDPFilteredCache& rCacheTable, CalcInfo& rInfo, bool bAutoShow);
153 
154 private:
155  void GetItemData(const ScDPFilteredCache& rCacheTable, sal_Int32 nRow,
156  const ::std::vector<sal_Int32>& rDims, ::std::vector< SCROW >& rItemData);
157 };
158 
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long Long
::std::vector< ScDPValue > aValues
Definition: dptabdat.hxx:147
Member names that are being processed for InitFrom/LateInitFrom (needed for initialization of grouped...
Definition: dptabres.hxx:55
::std::vector< sal_Int32 > aRowLevelDims
Definition: dptabdat.hxx:74
tools::Long nLastRet
Definition: dptabdat.hxx:62
::std::vector< ScDPDimension * > aColDims
Definition: dptabdat.hxx:72
tools::Long nLastLevel
Definition: dptabdat.hxx:61
NfIndexTableOffset
tools::Long nLastHier
Definition: dptabdat.hxx:60
::std::vector< ScDPLevel * > aColLevels
Definition: dptabdat.hxx:73
::std::vector< sal_Int32 > aColLevelDims
Definition: dptabdat.hxx:71
const ScDocument * mpDoc
Definition: dptabdat.hxx:63
::std::vector< ScDPDimension * > aRowDims
Definition: dptabdat.hxx:75
::std::vector< sal_Int32 > aPageDims
Definition: dptabdat.hxx:77
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
Definition: dpitemdata.hxx:28
This structure stores dimension information used when calculating results.
Definition: dptabdat.hxx:69
::std::vector< sal_Int32 > aDataSrcCols
Definition: dptabdat.hxx:78
::std::vector< SCROW > aRowData
Definition: dptabdat.hxx:145
tools::Long nLastDateVal
Definition: dptabdat.hxx:59
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:169
ScDPResultMember * pColRoot
Definition: dptabdat.hxx:81
::std::vector< SCROW > aColData
Definition: dptabdat.hxx:144
Base class that abstracts different data source types of a datapilot table.
Definition: dptabdat.hxx:56
This structure stores vector arrays that hold intermediate data for each row during cache table itera...
Definition: dptabdat.hxx:142
ScDPInitState * pInitState
Definition: dptabdat.hxx:80
::std::vector< SCROW > aPageData
Definition: dptabdat.hxx:146
::std::vector< ScDPLevel * > aRowLevels
Definition: dptabdat.hxx:76
ScDPResultMember * pRowRoot
Definition: dptabdat.hxx:82
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:27