LCOV - code coverage report
Current view: top level - sc/inc - dptabdat.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 3 66.7 %
Date: 2012-08-25 Functions: 3 4 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef SC_DPTABDAT_HXX
      30                 :            : #define SC_DPTABDAT_HXX
      31                 :            : 
      32                 :            : #include "address.hxx"
      33                 :            : #include "dpoutput.hxx"
      34                 :            : #include "dpcachetable.hxx"
      35                 :            : #include "dpcache.hxx"
      36                 :            : #include "dpmacros.hxx"
      37                 :            : 
      38                 :            : #include "svl/zforlist.hxx"
      39                 :            : 
      40                 :            : #include <vector>
      41                 :            : #include <set>
      42                 :            : #include <boost/unordered_set.hpp>
      43                 :            : #include <boost/unordered_map.hpp>
      44                 :            : #include <boost/noncopyable.hpp>
      45                 :            : 
      46                 :            : namespace com { namespace sun { namespace star { namespace sheet {
      47                 :            :     struct DataPilotFieldFilter;
      48                 :            : }}}}
      49                 :            : 
      50                 :            : 
      51                 :            : #define SC_DAPI_HIERARCHY_FLAT      0
      52                 :            : #define SC_DAPI_HIERARCHY_QUARTER   1
      53                 :            : #define SC_DAPI_HIERARCHY_WEEK      2
      54                 :            : 
      55                 :            : #define SC_DAPI_FLAT_LEVELS     1       // single level for flat dates
      56                 :            : #define SC_DAPI_QUARTER_LEVELS  4       // levels in year/quarter/month/day hierarchy
      57                 :            : #define SC_DAPI_WEEK_LEVELS     3       // levels in year/week/day hierarchy
      58                 :            : 
      59                 :            : #define SC_DAPI_LEVEL_YEAR      0
      60                 :            : #define SC_DAPI_LEVEL_QUARTER   1
      61                 :            : #define SC_DAPI_LEVEL_MONTH     2
      62                 :            : #define SC_DAPI_LEVEL_DAY       3
      63                 :            : #define SC_DAPI_LEVEL_WEEK      4
      64                 :            : #define SC_DAPI_LEVEL_WEEKDAY   5
      65                 :            : 
      66                 :            : 
      67                 :            : //
      68                 :            : //  base class ScDPTableData to allow implementation with tabular data
      69                 :            : //  by deriving only of this
      70                 :            : //
      71                 :            : #define SC_VALTYPE_EMPTY    0
      72                 :            : #define SC_VALTYPE_VALUE    1
      73                 :            : #define SC_VALTYPE_STRING   2
      74                 :            : #define SC_VALTYPE_ERROR    3
      75                 :            : 
      76                 :            : struct ScDPValueData
      77                 :            : {
      78                 :            :     double  fValue;
      79                 :            :     sal_uInt8   nType;
      80                 :            : 
      81                 :          0 :     void    Set( double fV, sal_uInt8 nT ) { fValue = fV; nType = nT; }
      82                 :            : };
      83                 :            : 
      84                 :            : class ScDPResultMember;
      85                 :            : class ScDPDimension;
      86                 :            : class ScDPLevel;
      87                 :            : class ScDPInitState;
      88                 :            : class ScDPResultMember;
      89                 :            : class ScDocument;
      90                 :            : 
      91                 :            : /**
      92                 :            :  * Base class that abstracts different data source types of a datapilot
      93                 :            :  * table.
      94                 :            :  */
      95                 :            : class SC_DLLPUBLIC ScDPTableData : public ::boost::noncopyable
      96                 :            : {
      97                 :            :     //  cached data for GetDatePart
      98                 :            :     long    nLastDateVal;
      99                 :            :     long    nLastHier;
     100                 :            :     long    nLastLevel;
     101                 :            :     long    nLastRet;
     102                 :            :     const ScDocument* mpDoc;
     103                 :            : public:
     104                 :            : 
     105                 :            :     /** This structure stores dimension information used when calculating
     106                 :            :         results.  These data are read only during result calculation, so it
     107                 :            :         should be passed as a const instance. */
     108                 :        140 :     struct CalcInfo
     109                 :            :     {
     110                 :            :         ::std::vector<long>             aColLevelDims;
     111                 :            :         ::std::vector<ScDPDimension*>   aColDims;
     112                 :            :         ::std::vector<ScDPLevel*>       aColLevels;
     113                 :            :         ::std::vector<long>             aRowLevelDims;
     114                 :            :         ::std::vector<ScDPDimension*>   aRowDims;
     115                 :            :         ::std::vector<ScDPLevel*>       aRowLevels;
     116                 :            :         ::std::vector<long>             aPageDims;
     117                 :            :         ::std::vector<long>             aDataSrcCols;
     118                 :            : 
     119                 :            :         ScDPInitState*                  pInitState;
     120                 :            :         ScDPResultMember*               pColRoot;
     121                 :            :         ScDPResultMember*               pRowRoot;
     122                 :            : 
     123                 :            :         bool                            bRepeatIfEmpty;
     124                 :            : 
     125                 :            :         CalcInfo();
     126                 :            :     };
     127                 :            : 
     128                 :            :     ScDPTableData(ScDocument* pDoc);
     129                 :            :     virtual     ~ScDPTableData();
     130                 :            : 
     131                 :            :     rtl::OUString GetFormattedString(long nDim, const ScDPItemData& rItem) const;
     132                 :            : 
     133                 :            :     long        GetDatePart( long nDateVal, long nHierarchy, long nLevel );
     134                 :            : 
     135                 :            :                 //! use (new) typed collection instead of ScStrCollection
     136                 :            :                 //! or separate Str and ValueCollection
     137                 :            : 
     138                 :            :     virtual long                    GetColumnCount() = 0;
     139                 :            :     virtual   const std::vector< SCROW >& GetColumnEntries( long nColumn ) ;
     140                 :            :     virtual rtl::OUString           getDimensionName(long nColumn) = 0;
     141                 :            :     virtual sal_Bool                    getIsDataLayoutDimension(long nColumn) = 0;
     142                 :            :     virtual sal_Bool                    IsDateDimension(long nDim) = 0;
     143                 :            :     virtual sal_uLong                   GetNumberFormat(long nDim);
     144                 :            :     virtual sal_uInt32                  GetNumberFormatByIdx( NfIndexTableOffset );
     145                 :            :     virtual void                    DisposeData() = 0;
     146                 :            :     virtual void                    SetEmptyFlags( sal_Bool bIgnoreEmptyRows, sal_Bool bRepeatIfEmpty ) = 0;
     147                 :            : 
     148                 :            :     virtual bool                    IsRepeatIfEmpty();
     149                 :            : 
     150                 :            :     virtual void                    CreateCacheTable() = 0;
     151                 :            :     virtual void                    FilterCacheTable(const ::std::vector<ScDPCacheTable::Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rDataDims) = 0;
     152                 :            :     virtual void                    GetDrillDownData(const ::std::vector<ScDPCacheTable::Criterion>& rCriteria,
     153                 :            :                                                      const ::boost::unordered_set<sal_Int32>& rCatDims,
     154                 :            :                                                      ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& rData) = 0;
     155                 :            :     virtual void                    CalcResults(CalcInfo& rInfo, bool bAutoShow) = 0;
     156                 :            :     virtual const ScDPCacheTable&   GetCacheTable() const = 0;
     157                 :            :     virtual void ReloadCacheTable() = 0;
     158                 :            : 
     159                 :            :                                     // overloaded in ScDPGroupTableData:
     160                 :            :     virtual sal_Bool                    IsBaseForGroup(long nDim) const;
     161                 :            :     virtual long                      GetGroupBase(long nGroupDim) const;
     162                 :            :     virtual sal_Bool                    IsNumOrDateGroup(long nDim) const;
     163                 :            :     virtual sal_Bool                    IsInGroup( const ScDPItemData& rGroupData, long nGroupIndex,
     164                 :            :                                                const ScDPItemData& rBaseData, long nBaseIndex ) const;
     165                 :            :     virtual sal_Bool                    HasCommonElement( const ScDPItemData& rFirstData, long nFirstIndex,
     166                 :            :                                                       const ScDPItemData& rSecondData, long nSecondIndex ) const;
     167                 :            : 
     168                 :            :     virtual long                            GetMembersCount( long nDim );
     169                 :            :     virtual const ScDPItemData*   GetMemberByIndex( long nDim, long nIndex );
     170                 :            :     virtual const ScDPItemData*   GetMemberById( long nDim, long nId);
     171                 :            :     virtual SCROW                        GetIdOfItemData( long  nDim, const ScDPItemData& rData );
     172                 :            :     virtual long                GetSourceDim( long nDim );
     173                 :            :     virtual long                Compare( long nDim, long nDataId1, long nDataId2);
     174                 :            : 
     175                 :            : #if DEBUG_PIVOT_TABLE
     176                 :            :     virtual void Dump() const;
     177                 :            : #endif
     178                 :            : 
     179                 :            : protected:
     180                 :            :     /** This structure stores vector arrays that hold intermediate data for
     181                 :            :         each row during cache table iteration. */
     182 [ +  - ][ +  - ]:       1520 :     struct CalcRowData
                 [ +  - ]
     183                 :            :     {
     184                 :            :         ::std::vector< SCROW >  aColData;
     185                 :            :         ::std::vector< SCROW >  aRowData;
     186                 :            :         ::std::vector< SCROW >  aPageData;
     187                 :            :         ::std::vector<ScDPValueData> aValues;
     188                 :            :     };
     189                 :            : 
     190                 :            :     void            FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPCacheTable& rCacheTable, const CalcInfo& rInfo, CalcRowData& rData);
     191                 :            :     void            ProcessRowData(CalcInfo& rInfo, CalcRowData& rData, bool bAutoShow);
     192                 :            :     void            CalcResultsFromCacheTable(const ScDPCacheTable& rCacheTable, CalcInfo& rInfo, bool bAutoShow);
     193                 :            : 
     194                 :            : private:
     195                 :            :     void            GetItemData(const ScDPCacheTable& rCacheTable, sal_Int32 nRow,
     196                 :            :                                           const ::std::vector<long>& rDims, ::std::vector< SCROW >& rItemData);
     197                 :            : };
     198                 :            : #endif
     199                 :            : 
     200                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10