LCOV - code coverage report
Current view: top level - sc/source/core/data - dpsdbtab.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 61 1.6 %
Date: 2015-06-13 12:38:46 Functions: 2 19 10.5 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "global.hxx"
      22             : #include "globstr.hrc"
      23             : #include "dpfilteredcache.hxx"
      24             : #include "dptabres.hxx"
      25             : #include "document.hxx"
      26             : #include "dpobject.hxx"
      27             : 
      28             : #include <com/sun/star/sheet/DataImportMode.hpp>
      29             : #include <com/sun/star/sdb/CommandType.hpp>
      30             : 
      31             : using namespace com::sun::star;
      32             : 
      33             : using ::std::vector;
      34             : using ::com::sun::star::uno::Sequence;
      35             : using ::com::sun::star::uno::Any;
      36             : 
      37           0 : sal_Int32 ScImportSourceDesc::GetCommandType() const
      38             : {
      39           0 :     sal_Int32 nSdbType = -1;
      40             : 
      41           0 :     switch ( nType )
      42             :     {
      43           0 :         case sheet::DataImportMode_SQL:   nSdbType = sdb::CommandType::COMMAND; break;
      44           0 :         case sheet::DataImportMode_TABLE: nSdbType = sdb::CommandType::TABLE;   break;
      45           0 :         case sheet::DataImportMode_QUERY: nSdbType = sdb::CommandType::QUERY;   break;
      46             :         default:
      47             :             ;
      48             :     }
      49           0 :     return nSdbType;
      50             : }
      51             : 
      52           0 : const ScDPCache* ScImportSourceDesc::CreateCache(const ScDPDimensionSaveData* pDimData) const
      53             : {
      54           0 :     if (!mpDoc)
      55           0 :         return NULL;
      56             : 
      57           0 :     sal_Int32 nSdbType = GetCommandType();
      58           0 :     if (nSdbType < 0)
      59           0 :         return NULL;
      60             : 
      61           0 :     ScDPCollection::DBCaches& rCaches = mpDoc->GetDPCollection()->GetDBCaches();
      62           0 :     return rCaches.getCache(nSdbType, aDBName, aObject, pDimData);
      63             : }
      64             : 
      65           0 : ScDatabaseDPData::ScDatabaseDPData(
      66             :     ScDocument* pDoc, const ScDPCache& rCache) :
      67             :     ScDPTableData(pDoc),
      68           0 :     aCacheTable(rCache)
      69             : {
      70           0 : }
      71             : 
      72           0 : ScDatabaseDPData::~ScDatabaseDPData()
      73             : {
      74           0 : }
      75             : 
      76           0 : void ScDatabaseDPData::DisposeData()
      77             : {
      78             :     //TODO: use OpenDatabase here?
      79           0 :     aCacheTable.clear();
      80           0 : }
      81             : 
      82           0 : long ScDatabaseDPData::GetColumnCount()
      83             : {
      84           0 :     CreateCacheTable();
      85           0 :     return GetCacheTable().getColSize();
      86             : }
      87             : 
      88           0 : OUString ScDatabaseDPData::getDimensionName(long nColumn)
      89             : {
      90           0 :     if (getIsDataLayoutDimension(nColumn))
      91             :     {
      92             :         //TODO: different internal and display names?
      93             :         //return "Data";
      94           0 :         return ScGlobal::GetRscString(STR_PIVOT_DATA);
      95             :     }
      96             : 
      97           0 :     CreateCacheTable();
      98           0 :     return aCacheTable.getFieldName(static_cast<SCCOL>(nColumn));
      99             : }
     100             : 
     101           0 : bool ScDatabaseDPData::getIsDataLayoutDimension(long nColumn)
     102             : {
     103           0 :     return ( nColumn == GetCacheTable().getColSize());
     104             : }
     105             : 
     106           0 : bool ScDatabaseDPData::IsDateDimension(long /* nDim */)
     107             : {
     108             :     //TODO: later...
     109           0 :     return false;
     110             : }
     111             : 
     112           0 : void ScDatabaseDPData::SetEmptyFlags( bool /* bIgnoreEmptyRows */, bool /* bRepeatIfEmpty */ )
     113             : {
     114             :     //  not used for database data
     115             :     //TODO: disable flags
     116           0 : }
     117             : 
     118           0 : void ScDatabaseDPData::CreateCacheTable()
     119             : {
     120           0 :     if (!aCacheTable.empty())
     121             :         // cache table already created.
     122           0 :         return;
     123             : 
     124           0 :     aCacheTable.fillTable();
     125             : }
     126             : 
     127           0 : void ScDatabaseDPData::FilterCacheTable(const vector<ScDPFilteredCache::Criterion>& rCriteria, const std::unordered_set<sal_Int32>& rCatDims)
     128             : {
     129           0 :     CreateCacheTable();
     130             :     aCacheTable.filterByPageDimension(
     131           0 :         rCriteria, (IsRepeatIfEmpty() ? rCatDims : std::unordered_set<sal_Int32>()));
     132           0 : }
     133             : 
     134           0 : void ScDatabaseDPData::GetDrillDownData(const vector<ScDPFilteredCache::Criterion>& rCriteria, const std::unordered_set<sal_Int32>& rCatDims, Sequence< Sequence<Any> >& rData)
     135             : {
     136           0 :     CreateCacheTable();
     137           0 :     sal_Int32 nRowSize = aCacheTable.getRowSize();
     138           0 :     if (!nRowSize)
     139           0 :         return;
     140             : 
     141             :     aCacheTable.filterTable(
     142           0 :         rCriteria, rData, IsRepeatIfEmpty() ? rCatDims : std::unordered_set<sal_Int32>());
     143             : }
     144             : 
     145           0 : void ScDatabaseDPData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
     146             : {
     147           0 :     CreateCacheTable();
     148           0 :     CalcResultsFromCacheTable( aCacheTable, rInfo, bAutoShow);
     149           0 : }
     150             : 
     151           0 : const ScDPFilteredCache& ScDatabaseDPData::GetCacheTable() const
     152             : {
     153           0 :     return aCacheTable;
     154             : }
     155             : 
     156           0 : void ScDatabaseDPData::ReloadCacheTable()
     157             : {
     158           0 :     aCacheTable.clear();
     159           0 :     CreateCacheTable();
     160         156 : }
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11