LCOV - code coverage report
Current view: top level - sc/inc - dpgroup.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 7 0.0 %
Date: 2014-04-14 Functions: 0 8 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             : #ifndef SC_DPGROUP_HXX
      21             : #define SC_DPGROUP_HXX
      22             : 
      23             : #include <vector>
      24             : #include <boost/unordered_set.hpp>
      25             : #include <boost/shared_ptr.hpp>
      26             : 
      27             : #include "dptabdat.hxx"
      28             : #include "scdllapi.h"
      29             : #include "dpitemdata.hxx"
      30             : #include "dpnumgroupinfo.hxx"
      31             : 
      32             : class ScDocument;
      33             : 
      34             : typedef ::std::vector<ScDPItemData> ScDPItemDataVec;
      35             : 
      36           0 : class ScDPGroupItem
      37             : {
      38             :     ScDPItemData    aGroupName;     // name of group item
      39             :     ScDPItemDataVec aElements;      // names of items in original dimension
      40             : 
      41             : public:
      42             :                 ScDPGroupItem( const ScDPItemData& rName );
      43             :                 ~ScDPGroupItem();
      44             : 
      45             :     void        AddElement( const ScDPItemData& rName );
      46             : 
      47           0 :     const ScDPItemData& GetName() const     { return aGroupName; }
      48             :     bool        HasElement( const ScDPItemData& rData ) const;
      49             :     bool        HasCommonElement( const ScDPGroupItem& rOther ) const;
      50             : 
      51             :     void        FillGroupFilter( ScDPFilteredCache::GroupFilter& rFilter ) const;
      52             : };
      53             : 
      54             : typedef ::std::vector<ScDPGroupItem> ScDPGroupItemVec;
      55             : 
      56             : class ScDPGroupDimension
      57             : {
      58             :     long                        nSourceDim;
      59             :     long                        nGroupDim;
      60             :     OUString               aGroupName;
      61             :     ScDPGroupItemVec            aItems;
      62             :     mutable std::vector<SCROW> maMemberEntries;
      63             :     bool mbDateDimension;
      64             : public:
      65             :                 ScDPGroupDimension( long nSource, const OUString& rNewName );
      66             :                 ScDPGroupDimension( const ScDPGroupDimension& rOther );
      67             :                 ~ScDPGroupDimension();
      68             : 
      69             :     ScDPGroupDimension& operator=( const ScDPGroupDimension& rOther );
      70             : 
      71             :     void        AddItem( const ScDPGroupItem& rItem );
      72             :     void        SetGroupDim( long nDim );           // called from AddGroupDimension
      73             : 
      74           0 :     long        GetSourceDim() const    { return nSourceDim; }
      75           0 :     long        GetGroupDim() const     { return nGroupDim; }
      76           0 :     const OUString& GetName() const { return aGroupName; }
      77             : 
      78             :     const std::vector< SCROW >&  GetColumnEntries( const ScDPFilteredCache&  rCacheTable ) const;
      79             :     const ScDPGroupItem* GetGroupForData( const ScDPItemData& rData ) const;  // rData = entry in original dim.
      80             :     const ScDPGroupItem* GetGroupForName( const ScDPItemData& rName ) const;  // rName = entry in group dim.
      81             :     const ScDPGroupItem* GetGroupByIndex( size_t nIndex ) const;
      82             : 
      83             :     void        DisposeData();
      84             : 
      85           0 :     size_t      GetItemCount() const { return aItems.size(); }
      86             : 
      87             :     void SetDateDimension();
      88             :     bool IsDateDimension() const;
      89             : };
      90             : 
      91             : typedef ::std::vector<ScDPGroupDimension> ScDPGroupDimensionVec;
      92             : 
      93             : class SC_DLLPUBLIC ScDPNumGroupDimension
      94             : {
      95             :     mutable ScDPNumGroupInfo    aGroupInfo;         // settings
      96             :     mutable std::vector<SCROW>  maMemberEntries;
      97             :     bool mbDateDimension;
      98             : 
      99             : public:
     100             :                 ScDPNumGroupDimension();
     101             :                 ScDPNumGroupDimension( const ScDPNumGroupInfo& rInfo );
     102             :                 ScDPNumGroupDimension( const ScDPNumGroupDimension& rOther );
     103             :                 ~ScDPNumGroupDimension();
     104             : 
     105             :     ScDPNumGroupDimension&  operator=( const ScDPNumGroupDimension& rOther );
     106             : 
     107           0 :     const ScDPNumGroupInfo& GetInfo() const     { return aGroupInfo; }
     108             : 
     109             :     const std::vector<SCROW>& GetNumEntries(SCCOL nSourceDim, const ScDPCache* pCache) const;
     110             : 
     111             :     void SetDateDimension();
     112             : 
     113             :     void        DisposeData();
     114             : 
     115             :     bool IsDateDimension() const;
     116             : };
     117             : 
     118             : 
     119             : //  proxy implementation of ScDPTableData to add grouped items
     120             : 
     121             : 
     122             : class ScDPGroupTableData : public ScDPTableData
     123             : {
     124             :     typedef ::boost::unordered_set< OUString, OUStringHash, ::std::equal_to< OUString > > StringHashSet;
     125             : 
     126             :     ::boost::shared_ptr<ScDPTableData> pSourceData;
     127             :     long                    nSourceCount;
     128             :     ScDPGroupDimensionVec   aGroups;
     129             :     ScDPNumGroupDimension*  pNumGroups;     // array[nSourceCount]
     130             :     ScDocument*             pDoc;
     131             :     StringHashSet           aGroupNames;
     132             : 
     133             :     void FillGroupValues(std::vector<SCROW>& rItems, const std::vector<long>& rDims);
     134             :     virtual long                GetSourceDim( long nDim ) SAL_OVERRIDE;
     135             : 
     136             :     bool        IsNumGroupDimension( long nDimension ) const;
     137             :     void GetNumGroupInfo(long nDimension, ScDPNumGroupInfo& rInfo);
     138             : 
     139             :     void        ModifyFilterCriteria(::std::vector<ScDPFilteredCache::Criterion>& rCriteria);
     140             : 
     141             : public:
     142             :                 // takes ownership of pSource
     143             :                 ScDPGroupTableData( const ::boost::shared_ptr<ScDPTableData>& pSource, ScDocument* pDocument );
     144             :     virtual     ~ScDPGroupTableData();
     145             : 
     146             :     boost::shared_ptr<ScDPTableData> GetSourceTableData();
     147             : 
     148             :     void        AddGroupDimension( const ScDPGroupDimension& rGroup );
     149             :     void        SetNumGroupDimension( long nIndex, const ScDPNumGroupDimension& rGroup );
     150             :     long        GetDimensionIndex( const OUString& rName );
     151             : 
     152             :     ScDocument* GetDocument()   { return pDoc; }
     153             : 
     154             :     virtual long                    GetColumnCount() SAL_OVERRIDE;
     155             :     virtual long                    GetMembersCount( long nDim ) SAL_OVERRIDE;
     156             :     virtual const std::vector< SCROW >& GetColumnEntries( long nColumn ) SAL_OVERRIDE ;
     157             :     virtual const ScDPItemData* GetMemberById( long nDim, long nId) SAL_OVERRIDE;
     158             :     virtual long Compare( long nDim, long nDataId1, long nDataId2) SAL_OVERRIDE;
     159             : 
     160             :     virtual OUString                getDimensionName(long nColumn) SAL_OVERRIDE;
     161             :     virtual bool                    getIsDataLayoutDimension(long nColumn) SAL_OVERRIDE;
     162             :     virtual bool                    IsDateDimension(long nDim) SAL_OVERRIDE;
     163             :     virtual sal_uLong               GetNumberFormat(long nDim) SAL_OVERRIDE;
     164             :     virtual void                    DisposeData() SAL_OVERRIDE;
     165             :     virtual void                    SetEmptyFlags( bool bIgnoreEmptyRows, bool bRepeatIfEmpty ) SAL_OVERRIDE;
     166             : 
     167             :     virtual bool                    IsRepeatIfEmpty() SAL_OVERRIDE;
     168             : 
     169             :     virtual void                    CreateCacheTable() SAL_OVERRIDE;
     170             :     virtual void                    FilterCacheTable(const ::std::vector<ScDPFilteredCache::Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rDataDims) SAL_OVERRIDE;
     171             :     virtual void                    GetDrillDownData(const ::std::vector<ScDPFilteredCache::Criterion>& rCriteria,
     172             :                                                      const ::boost::unordered_set<sal_Int32>& rCatDims,
     173             :                                                      ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& rData) SAL_OVERRIDE;
     174             :     virtual void                    CalcResults(CalcInfo& rInfo, bool bAutoShow) SAL_OVERRIDE;
     175             :     virtual const ScDPFilteredCache&   GetCacheTable() const SAL_OVERRIDE;
     176             :     virtual void ReloadCacheTable() SAL_OVERRIDE;
     177             : 
     178             :     virtual bool                    IsBaseForGroup(long nDim) const SAL_OVERRIDE;
     179             :     virtual long                    GetGroupBase(long nGroupDim) const SAL_OVERRIDE;
     180             :     virtual bool                    IsNumOrDateGroup(long nDim) const SAL_OVERRIDE;
     181             :     virtual bool                    IsInGroup( const ScDPItemData& rGroupData, long nGroupIndex,
     182             :                                                const ScDPItemData& rBaseData, long nBaseIndex ) const SAL_OVERRIDE;
     183             :     virtual bool                    HasCommonElement( const ScDPItemData& rFirstData, long nFirstIndex,
     184             :                                                       const ScDPItemData& rSecondData, long nSecondIndex ) const SAL_OVERRIDE;
     185             : 
     186             : #if DEBUG_PIVOT_TABLE
     187             :     virtual void Dump() const;
     188             : #endif
     189             : };
     190             : 
     191             : 
     192             : #endif
     193             : 
     194             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10