LibreOffice Module sc (master) 1
dpsdbtab.cxx
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#include <dpsdbtab.hxx>
21#include <globstr.hrc>
22#include <scresid.hxx>
23#include <dpfilteredcache.hxx>
24#include <document.hxx>
25#include <dpobject.hxx>
26
27#include <com/sun/star/sdb/CommandType.hpp>
28
29using namespace com::sun::star;
30
31using ::std::vector;
32using ::com::sun::star::uno::Sequence;
33using ::com::sun::star::uno::Any;
34
36{
37 sal_Int32 nSdbType = -1;
38
39 switch ( nType )
40 {
41 case sheet::DataImportMode_SQL: nSdbType = sdb::CommandType::COMMAND; break;
42 case sheet::DataImportMode_TABLE: nSdbType = sdb::CommandType::TABLE; break;
43 case sheet::DataImportMode_QUERY: nSdbType = sdb::CommandType::QUERY; break;
44 default:
45 ;
46 }
47 return nSdbType;
48}
49
51{
52 if (!mpDoc)
53 return nullptr;
54
55 sal_Int32 nSdbType = GetCommandType();
56 if (nSdbType < 0)
57 return nullptr;
58
60 return rCaches.getCache(nSdbType, aDBName, aObject, pDimData);
61}
62
64 const ScDocument* pDoc, const ScDPCache& rCache) :
65 ScDPTableData(pDoc),
66 aCacheTable(rCache)
67{
68}
69
71{
72}
73
75{
76 //TODO: use OpenDatabase here?
78}
79
81{
83 return GetCacheTable().getColSize();
84}
85
86OUString ScDatabaseDPData::getDimensionName(sal_Int32 nColumn)
87{
88 if (getIsDataLayoutDimension(nColumn))
89 {
90 //TODO: different internal and display names?
91 //return "Data";
92 return ScResId(STR_PIVOT_DATA);
93 }
94
96 return aCacheTable.getFieldName(static_cast<SCCOL>(nColumn));
97}
98
100{
101 return ( nColumn == GetCacheTable().getColSize());
102}
103
104bool ScDatabaseDPData::IsDateDimension(sal_Int32 /* nDim */)
105{
106 //TODO: later...
107 return false;
108}
109
110void ScDatabaseDPData::SetEmptyFlags( bool /* bIgnoreEmptyRows */, bool /* bRepeatIfEmpty */ )
111{
112 // not used for database data
113 //TODO: disable flags
114}
115
117{
118 if (!aCacheTable.empty())
119 // cache table already created.
120 return;
121
123}
124
125void ScDatabaseDPData::FilterCacheTable(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, std::unordered_set<sal_Int32>&& rCatDims)
126{
129 rCriteria, (IsRepeatIfEmpty() ? std::move(rCatDims) : std::unordered_set<sal_Int32>()));
130}
131
132void ScDatabaseDPData::GetDrillDownData(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, std::unordered_set<sal_Int32>&& rCatDims, Sequence< Sequence<Any> >& rData)
133{
135 sal_Int32 nRowSize = aCacheTable.getRowSize();
136 if (!nRowSize)
137 return;
138
140 rCriteria, rData, IsRepeatIfEmpty() ? std::move(rCatDims) : std::unordered_set<sal_Int32>());
141}
142
143void ScDatabaseDPData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
144{
146 CalcResultsFromCacheTable( aCacheTable, rInfo, bAutoShow);
147}
148
150{
151 return aCacheTable;
152}
153
155{
158}
159
160#if DUMP_PIVOT_TABLE
161
162void ScDatabaseDPData::Dump() const
163{
164 // TODO : Implement this.
165}
166
167#endif
168
169/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class represents the cached data part of the datapilot cache table implementation.
Definition: dpcache.hxx:48
Data caches for external database sources.
Definition: dpobject.hxx:358
const ScDPCache * getCache(sal_Int32 nSdbType, const OUString &rDBName, const OUString &rCommand, const ScDPDimensionSaveData *pDimData)
Definition: dpobject.cxx:3190
DBCaches & GetDBCaches()
Definition: dpobject.cxx:3786
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
Definition: dpdimsave.hxx:164
This class is only a wrapper to the actual cache, to provide filtering on the raw data based on the q...
sal_Int32 getColSize() const
void filterTable(const std::vector< Criterion > &rCriteria, css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &rTabData, const std::unordered_set< sal_Int32 > &rRepeatIfEmptyDims)
Filter the table based on the specified criteria, and copy the result to rTabData.
void fillTable(const ScQueryParam &rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty)
void filterByPageDimension(const std::vector< Criterion > &rCriteria, const std::unordered_set< sal_Int32 > &rRepeatIfEmptyDims)
Set filter on/off flag to each row to control visibility.
sal_Int32 getRowSize() const
OUString getFieldName(SCCOL nIndex) const
Base class that abstracts different data source types of a datapilot table.
Definition: dptabdat.hxx:57
void CalcResultsFromCacheTable(const ScDPFilteredCache &rCacheTable, CalcInfo &rInfo, bool bAutoShow)
Definition: dptabdat.cxx:199
virtual bool IsRepeatIfEmpty()
Definition: dptabdat.cxx:102
virtual void SetEmptyFlags(bool bIgnoreEmptyRows, bool bRepeatIfEmpty) override
Definition: dpsdbtab.cxx:110
virtual void GetDrillDownData(std::vector< ScDPFilteredCache::Criterion > &&rCriteria, std::unordered_set< sal_Int32 > &&rCatDims, css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &rData) override
Definition: dpsdbtab.cxx:132
virtual void CalcResults(CalcInfo &rInfo, bool bAutoShow) override
Definition: dpsdbtab.cxx:143
ScDPFilteredCache aCacheTable
Definition: dpsdbtab.hxx:60
virtual void FilterCacheTable(std::vector< ScDPFilteredCache::Criterion > &&rCriteria, std::unordered_set< sal_Int32 > &&rDataDims) override
Definition: dpsdbtab.cxx:125
virtual void DisposeData() override
Definition: dpsdbtab.cxx:74
ScDatabaseDPData(const ScDocument *pDoc, const ScDPCache &rCache)
Definition: dpsdbtab.cxx:63
virtual const ScDPFilteredCache & GetCacheTable() const override
Definition: dpsdbtab.cxx:149
virtual OUString getDimensionName(sal_Int32 nColumn) override
Definition: dpsdbtab.cxx:86
virtual bool getIsDataLayoutDimension(sal_Int32 nColumn) override
Definition: dpsdbtab.cxx:99
virtual sal_Int32 GetColumnCount() override
use (new) typed collection instead of ScStrCollection or separate Str and ValueCollection
Definition: dpsdbtab.cxx:80
virtual void ReloadCacheTable() override
Definition: dpsdbtab.cxx:154
virtual void CreateCacheTable() override
Definition: dpsdbtab.cxx:116
virtual ~ScDatabaseDPData() override
Definition: dpsdbtab.cxx:70
virtual bool IsDateDimension(sal_Int32 nDim) override
Definition: dpsdbtab.cxx:104
virtual void Dump() const override
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
Definition: documen3.cxx:371
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
This structure stores dimension information used when calculating results.
Definition: dptabdat.hxx:70
css::sheet::DataImportMode nType
Definition: dpsdbtab.hxx:37
sal_Int32 GetCommandType() const
Definition: dpsdbtab.cxx:35
const ScDPCache * CreateCache(const ScDPDimensionSaveData *pDimData) const
Definition: dpsdbtab.cxx:50
OUString aObject
Definition: dpsdbtab.hxx:36
ScDocument * mpDoc
Definition: dpsdbtab.hxx:39
OUString aDBName
Definition: dpsdbtab.hxx:35
sal_Int16 SCCOL
Definition: types.hxx:21
@ QUERY
Definition: xmldpimp.hxx:44
@ TABLE
Definition: xmldpimp.hxx:43