LCOV - code coverage report
Current view: top level - sc/inc - dpgroup.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 9 10 90.0 %
Date: 2015-06-13 12:38:46 Functions: 9 11 81.8 %
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 INCLUDED_SC_INC_DPGROUP_HXX
      21             : #define INCLUDED_SC_INC_DPGROUP_HXX
      22             : 
      23             : #include <unordered_set>
      24             : #include <vector>
      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          22 : 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          43 :     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         444 :     long        GetSourceDim() const    { return nSourceDim; }
      75         290 :     long        GetGroupDim() const     { return nGroupDim; }
      76         288 :     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         150 :     bool IsDateDimension() const { return mbDateDimension;}
      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         280 :     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          59 :     bool IsDateDimension() const { return mbDateDimension;}
     116             : };
     117             : 
     118             : //  proxy implementation of ScDPTableData to add grouped items
     119             : 
     120             : class ScDPGroupTableData : public ScDPTableData
     121             : {
     122             :     typedef std::unordered_set< OUString, OUStringHash, ::std::equal_to< OUString > > StringHashSet;
     123             : 
     124             :     ::boost::shared_ptr<ScDPTableData> pSourceData;
     125             :     long                    nSourceCount;
     126             :     ScDPGroupDimensionVec   aGroups;
     127             :     ScDPNumGroupDimension*  pNumGroups;     // array[nSourceCount]
     128             :     ScDocument*             pDoc;
     129             :     StringHashSet           aGroupNames;
     130             : 
     131             :     void FillGroupValues(std::vector<SCROW>& rItems, const std::vector<long>& rDims);
     132             :     virtual long                GetSourceDim( long nDim ) SAL_OVERRIDE;
     133             : 
     134             :     bool        IsNumGroupDimension( long nDimension ) const;
     135             :     void GetNumGroupInfo(long nDimension, ScDPNumGroupInfo& rInfo);
     136             : 
     137             :     void        ModifyFilterCriteria(::std::vector<ScDPFilteredCache::Criterion>& rCriteria);
     138             : 
     139             : public:
     140             :                 // takes ownership of pSource
     141             :                 ScDPGroupTableData( const ::boost::shared_ptr<ScDPTableData>& pSource, ScDocument* pDocument );
     142             :     virtual     ~ScDPGroupTableData();
     143             : 
     144           3 :     boost::shared_ptr<ScDPTableData> GetSourceTableData() { return pSourceData;}
     145             : 
     146             :     void        AddGroupDimension( const ScDPGroupDimension& rGroup );
     147             :     void        SetNumGroupDimension( long nIndex, const ScDPNumGroupDimension& rGroup );
     148             :     long        GetDimensionIndex( const OUString& rName );
     149             : 
     150             :     ScDocument* GetDocument()   { return pDoc; }
     151             : 
     152             :     virtual long                    GetColumnCount() SAL_OVERRIDE;
     153             :     virtual long                    GetMembersCount( long nDim ) SAL_OVERRIDE;
     154             :     virtual const std::vector< SCROW >& GetColumnEntries( long nColumn ) SAL_OVERRIDE ;
     155             :     virtual const ScDPItemData* GetMemberById( long nDim, long nId) SAL_OVERRIDE;
     156             :     virtual long Compare( long nDim, long nDataId1, long nDataId2) SAL_OVERRIDE;
     157             : 
     158             :     virtual OUString                getDimensionName(long nColumn) SAL_OVERRIDE;
     159             :     virtual bool                    getIsDataLayoutDimension(long nColumn) SAL_OVERRIDE;
     160             :     virtual bool                    IsDateDimension(long nDim) SAL_OVERRIDE;
     161             :     virtual sal_uLong               GetNumberFormat(long nDim) SAL_OVERRIDE;
     162             :     virtual void                    DisposeData() SAL_OVERRIDE;
     163             :     virtual void                    SetEmptyFlags( bool bIgnoreEmptyRows, bool bRepeatIfEmpty ) SAL_OVERRIDE;
     164             : 
     165             :     virtual bool                    IsRepeatIfEmpty() SAL_OVERRIDE;
     166             : 
     167             :     virtual void                    CreateCacheTable() SAL_OVERRIDE;
     168             :     virtual void                    FilterCacheTable(const std::vector<ScDPFilteredCache::Criterion>& rCriteria, const std::unordered_set<sal_Int32>& rDataDims) SAL_OVERRIDE;
     169             :     virtual void                    GetDrillDownData(const std::vector<ScDPFilteredCache::Criterion>& rCriteria,
     170             :                                                      const std::unordered_set<sal_Int32>& rCatDims,
     171             :                                                      ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& rData) SAL_OVERRIDE;
     172             :     virtual void                    CalcResults(CalcInfo& rInfo, bool bAutoShow) SAL_OVERRIDE;
     173             :     virtual const ScDPFilteredCache&   GetCacheTable() const SAL_OVERRIDE;
     174             :     virtual void ReloadCacheTable() SAL_OVERRIDE;
     175             : 
     176             :     virtual bool                    IsBaseForGroup(long nDim) const SAL_OVERRIDE;
     177             :     virtual long                    GetGroupBase(long nGroupDim) const SAL_OVERRIDE;
     178             :     virtual bool                    IsNumOrDateGroup(long nDim) const SAL_OVERRIDE;
     179             :     virtual bool                    IsInGroup( const ScDPItemData& rGroupData, long nGroupIndex,
     180             :                                                const ScDPItemData& rBaseData, long nBaseIndex ) const SAL_OVERRIDE;
     181             :     virtual bool                    HasCommonElement( const ScDPItemData& rFirstData, long nFirstIndex,
     182             :                                                       const ScDPItemData& rSecondData, long nSecondIndex ) const SAL_OVERRIDE;
     183             : 
     184             : #if DEBUG_PIVOT_TABLE
     185             :     virtual void Dump() const;
     186             : #endif
     187             : };
     188             : 
     189             : #endif
     190             : 
     191             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11