fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / data / dpsdbtab.cxx
blob460fdabe522cb3610ffdfb6112089f89f25a9aba
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 #include "dpsdbtab.hxx"
21 #include "global.hxx"
22 #include "globstr.hrc"
23 #include "dpfilteredcache.hxx"
24 #include "dptabres.hxx"
25 #include "document.hxx"
26 #include "dpobject.hxx"
28 #include <com/sun/star/sheet/DataImportMode.hpp>
29 #include <com/sun/star/sdb/CommandType.hpp>
31 using namespace com::sun::star;
33 using ::std::vector;
34 using ::com::sun::star::uno::Sequence;
35 using ::com::sun::star::uno::Any;
37 sal_Int32 ScImportSourceDesc::GetCommandType() const
39 sal_Int32 nSdbType = -1;
41 switch ( nType )
43 case sheet::DataImportMode_SQL: nSdbType = sdb::CommandType::COMMAND; break;
44 case sheet::DataImportMode_TABLE: nSdbType = sdb::CommandType::TABLE; break;
45 case sheet::DataImportMode_QUERY: nSdbType = sdb::CommandType::QUERY; break;
46 default:
49 return nSdbType;
52 const ScDPCache* ScImportSourceDesc::CreateCache(const ScDPDimensionSaveData* pDimData) const
54 if (!mpDoc)
55 return NULL;
57 sal_Int32 nSdbType = GetCommandType();
58 if (nSdbType < 0)
59 return NULL;
61 ScDPCollection::DBCaches& rCaches = mpDoc->GetDPCollection()->GetDBCaches();
62 return rCaches.getCache(nSdbType, aDBName, aObject, pDimData);
65 ScDatabaseDPData::ScDatabaseDPData(
66 ScDocument* pDoc, const ScDPCache& rCache) :
67 ScDPTableData(pDoc),
68 aCacheTable(rCache)
72 ScDatabaseDPData::~ScDatabaseDPData()
76 void ScDatabaseDPData::DisposeData()
78 //TODO: use OpenDatabase here?
79 aCacheTable.clear();
82 long ScDatabaseDPData::GetColumnCount()
84 CreateCacheTable();
85 return GetCacheTable().getColSize();
88 OUString ScDatabaseDPData::getDimensionName(long nColumn)
90 if (getIsDataLayoutDimension(nColumn))
92 //TODO: different internal and display names?
93 //return "Data";
94 return ScGlobal::GetRscString(STR_PIVOT_DATA);
97 CreateCacheTable();
98 return aCacheTable.getFieldName(static_cast<SCCOL>(nColumn));
101 bool ScDatabaseDPData::getIsDataLayoutDimension(long nColumn)
103 return ( nColumn == GetCacheTable().getColSize());
106 bool ScDatabaseDPData::IsDateDimension(long /* nDim */)
108 //TODO: later...
109 return false;
112 void ScDatabaseDPData::SetEmptyFlags( bool /* bIgnoreEmptyRows */, bool /* bRepeatIfEmpty */ )
114 // not used for database data
115 //TODO: disable flags
118 void ScDatabaseDPData::CreateCacheTable()
120 if (!aCacheTable.empty())
121 // cache table already created.
122 return;
124 aCacheTable.fillTable();
127 void ScDatabaseDPData::FilterCacheTable(const vector<ScDPFilteredCache::Criterion>& rCriteria, const std::unordered_set<sal_Int32>& rCatDims)
129 CreateCacheTable();
130 aCacheTable.filterByPageDimension(
131 rCriteria, (IsRepeatIfEmpty() ? rCatDims : std::unordered_set<sal_Int32>()));
134 void ScDatabaseDPData::GetDrillDownData(const vector<ScDPFilteredCache::Criterion>& rCriteria, const std::unordered_set<sal_Int32>& rCatDims, Sequence< Sequence<Any> >& rData)
136 CreateCacheTable();
137 sal_Int32 nRowSize = aCacheTable.getRowSize();
138 if (!nRowSize)
139 return;
141 aCacheTable.filterTable(
142 rCriteria, rData, IsRepeatIfEmpty() ? rCatDims : std::unordered_set<sal_Int32>());
145 void ScDatabaseDPData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
147 CreateCacheTable();
148 CalcResultsFromCacheTable( aCacheTable, rInfo, bAutoShow);
151 const ScDPFilteredCache& ScDatabaseDPData::GetCacheTable() const
153 return aCacheTable;
156 void ScDatabaseDPData::ReloadCacheTable()
158 aCacheTable.clear();
159 CreateCacheTable();
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */