LCOV - code coverage report
Current view: top level - sc/source/core/data - dpsdbtab.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 61 0.0 %
Date: 2014-04-14 Functions: 0 19 0.0 %
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             :     //! 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             : 
      89           0 : OUString ScDatabaseDPData::getDimensionName(long nColumn)
      90             : {
      91           0 :     if (getIsDataLayoutDimension(nColumn))
      92             :     {
      93             :         //! different internal and display names?
      94             :         //return "Data";
      95           0 :         return ScGlobal::GetRscString(STR_PIVOT_DATA);
      96             :     }
      97             : 
      98           0 :     CreateCacheTable();
      99           0 :     return aCacheTable.getFieldName(static_cast<SCCOL>(nColumn));
     100             : }
     101             : 
     102           0 : bool ScDatabaseDPData::getIsDataLayoutDimension(long nColumn)
     103             : {
     104           0 :     return ( nColumn == GetCacheTable().getColSize());
     105             : }
     106             : 
     107           0 : bool ScDatabaseDPData::IsDateDimension(long /* nDim */)
     108             : {
     109             :     //! later...
     110           0 :     return false;
     111             : }
     112             : 
     113           0 : void ScDatabaseDPData::SetEmptyFlags( bool /* bIgnoreEmptyRows */, bool /* bRepeatIfEmpty */ )
     114             : {
     115             :     //  not used for database data
     116             :     //! disable flags
     117           0 : }
     118             : 
     119           0 : void ScDatabaseDPData::CreateCacheTable()
     120             : {
     121           0 :     if (!aCacheTable.empty())
     122             :         // cache table already created.
     123           0 :         return;
     124             : 
     125           0 :     aCacheTable.fillTable();
     126             : }
     127             : 
     128           0 : void ScDatabaseDPData::FilterCacheTable(const vector<ScDPFilteredCache::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims)
     129             : {
     130           0 :     CreateCacheTable();
     131             :     aCacheTable.filterByPageDimension(
     132           0 :         rCriteria, (IsRepeatIfEmpty() ? rCatDims : boost::unordered_set<sal_Int32>()));
     133           0 : }
     134             : 
     135           0 : void ScDatabaseDPData::GetDrillDownData(const vector<ScDPFilteredCache::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims, Sequence< Sequence<Any> >& rData)
     136             : {
     137           0 :     CreateCacheTable();
     138           0 :     sal_Int32 nRowSize = aCacheTable.getRowSize();
     139           0 :     if (!nRowSize)
     140           0 :         return;
     141             : 
     142             :     aCacheTable.filterTable(
     143           0 :         rCriteria, rData, IsRepeatIfEmpty() ? rCatDims : boost::unordered_set<sal_Int32>());
     144             : }
     145             : 
     146           0 : void ScDatabaseDPData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
     147             : {
     148           0 :     CreateCacheTable();
     149           0 :     CalcResultsFromCacheTable( aCacheTable, rInfo, bAutoShow);
     150           0 : }
     151             : 
     152           0 : const ScDPFilteredCache& ScDatabaseDPData::GetCacheTable() const
     153             : {
     154           0 :     return aCacheTable;
     155             : }
     156             : 
     157           0 : void ScDatabaseDPData::ReloadCacheTable()
     158             : {
     159           0 :     aCacheTable.clear();
     160           0 :     CreateCacheTable();
     161           0 : }
     162             : 
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10