LCOV - code coverage report
Current view: top level - libreoffice/sc/inc - dpgroup.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 7 85.7 %
Date: 2012-12-27 Functions: 6 8 75.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          10 : 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          18 :     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             :     rtl::OUString               aGroupName;
      61             :     ScDPGroupItemVec            aItems;
      62             :     mutable std::vector<SCROW> maMemberEntries;
      63             :     bool mbDateDimension;
      64             : public:
      65             :                 ScDPGroupDimension( long nSource, const String& 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         308 :     long        GetSourceDim() const    { return nSourceDim; }
      75         220 :     long        GetGroupDim() const     { return nGroupDim; }
      76         136 :     const rtl::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         118 :     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< ::rtl::OUString, ::rtl::OUStringHash, ::std::equal_to< ::rtl::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 );
     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 rtl::OUString& rName );
     151             : 
     152             :     ScDocument* GetDocument()   { return pDoc; }
     153             : 
     154             :     virtual long                    GetColumnCount();
     155             :     virtual   long                                          GetMembersCount( long nDim );
     156             :     virtual    const std::vector< SCROW >& GetColumnEntries( long nColumn ) ;
     157             :     virtual const ScDPItemData* GetMemberById( long nDim, long nId);
     158             :     virtual long Compare( long nDim, long nDataId1, long nDataId2);
     159             : 
     160             :     virtual rtl::OUString           getDimensionName(long nColumn);
     161             :     virtual sal_Bool                    getIsDataLayoutDimension(long nColumn);
     162             :     virtual sal_Bool                    IsDateDimension(long nDim);
     163             :     virtual sal_uLong                  GetNumberFormat(long nDim);
     164             :     virtual void                    DisposeData();
     165             :     virtual void                    SetEmptyFlags( sal_Bool bIgnoreEmptyRows, sal_Bool bRepeatIfEmpty );
     166             : 
     167             :     virtual bool                    IsRepeatIfEmpty();
     168             : 
     169             :     virtual void                    CreateCacheTable();
     170             :     virtual void                    FilterCacheTable(const ::std::vector<ScDPFilteredCache::Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rDataDims);
     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);
     174             :     virtual void                    CalcResults(CalcInfo& rInfo, bool bAutoShow);
     175             :     virtual const ScDPFilteredCache&   GetCacheTable() const;
     176             :     virtual void ReloadCacheTable();
     177             : 
     178             :     virtual sal_Bool                    IsBaseForGroup(long nDim) const;
     179             :     virtual long                    GetGroupBase(long nGroupDim) const;
     180             :     virtual sal_Bool                    IsNumOrDateGroup(long nDim) const;
     181             :     virtual sal_Bool                    IsInGroup( const ScDPItemData& rGroupData, long nGroupIndex,
     182             :                                                const ScDPItemData& rBaseData, long nBaseIndex ) const;
     183             :     virtual sal_Bool                    HasCommonElement( const ScDPItemData& rFirstData, long nFirstIndex,
     184             :                                                       const ScDPItemData& rSecondData, long nSecondIndex ) const;
     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