LCOV - code coverage report
Current view: top level - sc/inc - dpcache.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 4 0.0 %
Date: 2014-04-14 Functions: 0 5 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             : #ifndef SC_DPTABLECACHE_HXX
      20             : #define SC_DPTABLECACHE_HXX
      21             : 
      22             : #include "global.hxx"
      23             : #include "dpnumgroupinfo.hxx"
      24             : #include "calcmacros.hxx"
      25             : #include "tools/date.hxx"
      26             : 
      27             : #include <boost/noncopyable.hpp>
      28             : #include <boost/scoped_ptr.hpp>
      29             : #include <boost/ptr_container/ptr_vector.hpp>
      30             : #include <boost/unordered_set.hpp>
      31             : #include <mdds/flat_segment_tree.hpp>
      32             : 
      33             : #include <vector>
      34             : #include <set>
      35             : 
      36             : struct ScQueryParam;
      37             : class ScDPObject;
      38             : class ScDPItemData;
      39             : struct ScDPNumGroupInfo;
      40             : 
      41             : /**
      42             :  * This class represents the cached data part of the datapilot cache table
      43             :  * implementation.
      44             :  */
      45             : class SC_DLLPUBLIC ScDPCache : boost::noncopyable
      46             : {
      47             :     typedef boost::unordered_set<OUString, OUStringHash> StringSetType;
      48             : 
      49             : public:
      50             :     typedef std::vector<ScDPItemData> ItemsType;
      51             :     typedef std::set<ScDPObject*> ObjectSetType;
      52             :     typedef std::vector<OUString> LabelsType;
      53             :     typedef std::vector<SCROW> IndexArrayType;
      54             : 
      55           0 :     struct GroupItems : boost::noncopyable
      56             :     {
      57             :         ItemsType maItems;
      58             :         ScDPNumGroupInfo maInfo;
      59             :         sal_Int32 mnGroupType;
      60             : 
      61             :         GroupItems();
      62             :         GroupItems(const ScDPNumGroupInfo& rInfo, sal_Int32 nGroupType);
      63             :     };
      64             : 
      65           0 :     struct Field : boost::noncopyable
      66             :     {
      67             :         /**
      68             :          * Optional items for grouped field.
      69             :          */
      70             :         boost::scoped_ptr<GroupItems> mpGroup;
      71             : 
      72             :         /**
      73             :          * Unique values in the field, stored in ascending order.
      74             :          */
      75             :         ItemsType maItems;
      76             : 
      77             :         /**
      78             :          * Original source data represented as indices to the unique value
      79             :          * list.  The order of the data is as they appear in the original
      80             :          * data source.
      81             :          */
      82             :         IndexArrayType maData;
      83             : 
      84             :         sal_uLong mnNumFormat;
      85             : 
      86             :         Field();
      87             :     };
      88             : 
      89             :     /**
      90             :      * Interface for connecting to database source.  Column index is 0-based.
      91             :      */
      92           0 :     class DBConnector
      93             :     {
      94             :     public:
      95             :         virtual long getColumnCount() const = 0;
      96             :         virtual OUString getColumnLabel(long nCol) const = 0;
      97             :         virtual bool first() = 0;
      98             :         virtual bool next() = 0;
      99             :         virtual void finish() = 0;
     100             :         virtual void getValue(long nCol, ScDPItemData& rData, short& rNumType) const = 0;
     101           0 :         virtual ~DBConnector() {}
     102             :     };
     103             : 
     104             : private:
     105             : 
     106             :     ScDocument* mpDoc;
     107             :     long mnColumnCount;
     108             : 
     109             :     /**
     110             :      * All pivot table objects that references this cache.
     111             :      */
     112             :     mutable ObjectSetType maRefObjects;
     113             : 
     114             :     typedef boost::ptr_vector<Field> FieldsType;
     115             :     typedef boost::ptr_vector<GroupItems> GroupFieldsType;
     116             : 
     117             :     FieldsType maFields;
     118             :     GroupFieldsType maGroupFields;
     119             :     mutable StringSetType maStringPool;
     120             : 
     121             :     LabelsType maLabelNames;    // Stores dimension names.
     122             :     mdds::flat_segment_tree<SCROW, bool> maEmptyRows;
     123             :     SCROW mnDataSize;
     124             :     SCROW mnRowCount;
     125             : 
     126             :     bool mbDisposing;
     127             : 
     128             : public:
     129             :     const OUString* InternString(const OUString& rStr) const;
     130             :     void AddReference(ScDPObject* pObj) const;
     131             :     void RemoveReference(ScDPObject* pObj) const;
     132             :     const ObjectSetType& GetAllReferences() const;
     133             : 
     134             :     SCROW GetIdByItemData(long nDim, const ScDPItemData& rItem) const;
     135             :     OUString GetFormattedString(long nDim, const ScDPItemData& rItem) const;
     136             :     long AppendGroupField();
     137             :     void ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo, sal_Int32 nGroupType);
     138             :     SCROW SetGroupItem(long nDim, const ScDPItemData& rData);
     139             :     void GetGroupDimMemberIds(long nDim, std::vector<SCROW>& rIds) const;
     140             :     void ClearGroupFields();
     141             :     const ScDPNumGroupInfo* GetNumGroupInfo(long nDim) const;
     142             : 
     143             :     /**
     144             :      * Return a group type identifier.  The values correspond with
     145             :      * com::sun::star::sheet::DataPilotFieldGroupBy constant values.
     146             :      *
     147             :      * @param nDim 0-based dimension index.
     148             :      *
     149             :      * @return group type identifier, or 0 on failure.
     150             :      */
     151             :     sal_Int32 GetGroupType(long nDim) const;
     152             : 
     153             :     SCCOL GetDimensionIndex(const OUString& sName) const;
     154             :     sal_uLong GetNumberFormat( long nDim ) const;
     155             :     bool  IsDateDimension( long nDim ) const ;
     156             :     long GetDimMemberCount(long nDim) const;
     157             :     SCROW GetOrder( long nDim, SCROW nIndex ) const;
     158             : 
     159             :     const ItemsType& GetDimMemberValues( SCCOL nDim ) const;
     160             :     bool InitFromDoc(ScDocument* pDoc, const ScRange& rRange);
     161             :     bool InitFromDataBase(DBConnector& rDB);
     162             : 
     163             :     SCROW GetRowCount() const;
     164             :     SCROW GetDataSize() const;
     165             :     SCROW GetItemDataId( sal_uInt16 nDim, SCROW nRow, bool bRepeatIfEmpty ) const;
     166             :     OUString GetDimensionName(LabelsType::size_type nDim) const;
     167             :     bool IsRowEmpty(SCROW nRow) const;
     168             :     bool ValidQuery(SCROW nRow, const ScQueryParam& rQueryParam) const;
     169             : 
     170             :     ScDocument* GetDoc() const;
     171             :     long GetColumnCount() const;
     172             : 
     173             :     const ScDPItemData* GetItemDataById( long nDim, SCROW nId ) const;
     174             : 
     175             :     size_t GetFieldCount() const;
     176             :     size_t GetGroupFieldCount() const;
     177             : 
     178             :     ScDPCache(ScDocument* pDoc);
     179             :     ~ScDPCache();
     180             : 
     181             : #if DEBUG_PIVOT_TABLE
     182             :     void Dump() const;
     183             : #endif
     184             : 
     185             : private:
     186             :     void PostInit();
     187             :     void Clear();
     188             :     void AddLabel(const OUString& rLabel);
     189             :     const GroupItems* GetGroupItems(long nDim) const;
     190             : };
     191             : 
     192             : #endif
     193             : 
     194             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10