1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <globstr.hrc>
22 #include <scresid.hxx>
23 #include <dpfilteredcache.hxx>
24 #include <document.hxx>
25 #include <dpobject.hxx>
27 #include <com/sun/star/sdb/CommandType.hpp>
29 using namespace com::sun::star
;
32 using ::com::sun::star::uno::Sequence
;
33 using ::com::sun::star::uno::Any
;
35 sal_Int32
ScImportSourceDesc::GetCommandType() const
37 sal_Int32 nSdbType
= -1;
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;
50 const ScDPCache
* ScImportSourceDesc::CreateCache(const ScDPDimensionSaveData
* pDimData
) const
55 sal_Int32 nSdbType
= GetCommandType();
59 ScDPCollection::DBCaches
& rCaches
= mpDoc
->GetDPCollection()->GetDBCaches();
60 return rCaches
.getCache(nSdbType
, aDBName
, aObject
, pDimData
);
63 ScDatabaseDPData::ScDatabaseDPData(
64 const ScDocument
* pDoc
, const ScDPCache
& rCache
) :
70 ScDatabaseDPData::~ScDatabaseDPData()
74 void ScDatabaseDPData::DisposeData()
76 //TODO: use OpenDatabase here?
80 sal_Int32
ScDatabaseDPData::GetColumnCount()
83 return GetCacheTable().getColSize();
86 OUString
ScDatabaseDPData::getDimensionName(sal_Int32 nColumn
)
88 if (getIsDataLayoutDimension(nColumn
))
90 //TODO: different internal and display names?
92 return ScResId(STR_PIVOT_DATA
);
96 return aCacheTable
.getFieldName(static_cast<SCCOL
>(nColumn
));
99 bool ScDatabaseDPData::getIsDataLayoutDimension(sal_Int32 nColumn
)
101 return ( nColumn
== GetCacheTable().getColSize());
104 bool ScDatabaseDPData::IsDateDimension(sal_Int32
/* nDim */)
110 void ScDatabaseDPData::SetEmptyFlags( bool /* bIgnoreEmptyRows */, bool /* bRepeatIfEmpty */ )
112 // not used for database data
113 //TODO: disable flags
116 void ScDatabaseDPData::CreateCacheTable()
118 if (!aCacheTable
.empty())
119 // cache table already created.
122 aCacheTable
.fillTable();
125 void ScDatabaseDPData::FilterCacheTable(std::vector
<ScDPFilteredCache::Criterion
>&& rCriteria
, std::unordered_set
<sal_Int32
>&& rCatDims
)
128 aCacheTable
.filterByPageDimension(
129 rCriteria
, (IsRepeatIfEmpty() ? std::move(rCatDims
) : std::unordered_set
<sal_Int32
>()));
132 void ScDatabaseDPData::GetDrillDownData(std::vector
<ScDPFilteredCache::Criterion
>&& rCriteria
, std::unordered_set
<sal_Int32
>&& rCatDims
, Sequence
< Sequence
<Any
> >& rData
)
135 sal_Int32 nRowSize
= aCacheTable
.getRowSize();
139 aCacheTable
.filterTable(
140 rCriteria
, rData
, IsRepeatIfEmpty() ? std::move(rCatDims
) : std::unordered_set
<sal_Int32
>());
143 void ScDatabaseDPData::CalcResults(CalcInfo
& rInfo
, bool bAutoShow
)
146 CalcResultsFromCacheTable( aCacheTable
, rInfo
, bAutoShow
);
149 const ScDPFilteredCache
& ScDatabaseDPData::GetCacheTable() const
154 void ScDatabaseDPData::ReloadCacheTable()
162 void ScDatabaseDPData::Dump() const
164 // TODO : Implement this.
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */