LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/inc - dpdimsave.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 13 76.9 %
Date: 2013-07-09 Functions: 11 16 68.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 SC_DPDIMSAVE_HXX
      21             : #define SC_DPDIMSAVE_HXX
      22             : 
      23             : #include <vector>
      24             : #include <map>
      25             : #include <tools/string.hxx>
      26             : #include "dpgroup.hxx"      ///< for ScDPNumGroupInfo
      27             : #include "scdllapi.h"
      28             : #include "dptypes.hxx"
      29             : 
      30             : class ScDPGroupTableData;
      31             : class ScDPGroupDimension;
      32             : class ScDPObject;
      33             : class ScDPCache;
      34             : class SvNumberFormatter;
      35             : 
      36             : class ScDPSaveGroupDimension;
      37             : 
      38             : /**
      39             :  * Classes to save Data Pilot settings that create new dimensions (fields).
      40             :  * These have to be applied before the other ScDPSaveData settings.
      41             :  */
      42             : 
      43          20 : class SC_DLLPUBLIC ScDPSaveGroupItem
      44             : {
      45             :     OUString aGroupName;                        ///< name of group
      46             :     std::vector<OUString> aElements;            ///< names of items in original dimension
      47             :     mutable std::vector<ScDPItemData> maItems;  ///< items converted from the strings.
      48             : 
      49             : public:
      50             :     ScDPSaveGroupItem( const OUString& rName );
      51             :     ~ScDPSaveGroupItem();
      52             : 
      53             :     void AddToData(ScDPGroupDimension& rDataDim) const;
      54             : 
      55             :     void    AddElement( const OUString& rName );
      56             :     void    AddElementsFromGroup( const ScDPSaveGroupItem& rGroup );
      57          12 :     const OUString& GetGroupName() const { return aGroupName; }
      58             : 
      59             :     /// @return true if found (removed)
      60             :     bool    RemoveElement( const OUString& rName );
      61             : 
      62             :     bool    IsEmpty() const;
      63             :     size_t  GetElementCount() const;
      64             :     const OUString* GetElementByIndex(size_t nIndex) const;
      65             : 
      66             :     void Rename( const OUString& rNewName );
      67             : 
      68             :     /** remove this group's elements from their groups in rDimension
      69             :      (rDimension must be a different dimension from the one which contains this)*/
      70             :     void    RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const;
      71             : 
      72             :     void ConvertElementsToItems(SvNumberFormatter* pFormatter) const;
      73             :     bool HasInGroup(const ScDPItemData& rItem) const;
      74             : };
      75             : 
      76             : typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec;
      77             : 
      78             : /**
      79             :  * Represents a new group dimension whose dimension ID is higher than the
      80             :  * highest source dimension ID.
      81             :  */
      82          17 : class SC_DLLPUBLIC ScDPSaveGroupDimension
      83             : {
      84             :     OUString           aSourceDim;     ///< always the real source from the original data
      85             :     OUString           aGroupDimName;
      86             :     ScDPSaveGroupItemVec    aGroups;
      87             :     mutable ScDPNumGroupInfo aDateInfo;
      88             :     sal_Int32               nDatePart;
      89             : 
      90             : public:
      91             :                 ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName );
      92             :                 ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
      93             :                 ~ScDPSaveGroupDimension();
      94             : 
      95             :     void    AddToData( ScDPGroupTableData& rData ) const;
      96             :     void AddToCache(ScDPCache& rCache) const;
      97             :     void    SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
      98             : 
      99             :     void    AddGroupItem( const ScDPSaveGroupItem& rItem );
     100          27 :     const OUString& GetGroupDimName() const { return aGroupDimName; }
     101           6 :     const OUString& GetSourceDimName() const { return aSourceDim; }
     102             : 
     103           6 :     sal_Int32   GetDatePart() const             { return nDatePart; }
     104           3 :     const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
     105             : 
     106             :     OUString CreateGroupName( const OUString& rPrefix );
     107             :     const ScDPSaveGroupItem* GetNamedGroup( const OUString& rGroupName ) const;
     108             :     ScDPSaveGroupItem* GetNamedGroupAcc( const OUString& rGroupName );
     109             :     void    RemoveFromGroups( const OUString& rItemName );
     110             :     void RemoveGroup(const OUString& rGroupName);
     111             :     bool    IsEmpty() const;
     112             :     bool HasOnlyHidden(const ScDPUniqueStringSet& rVisible);
     113             : 
     114             :     long    GetGroupCount() const;
     115             :     const ScDPSaveGroupItem* GetGroupByIndex( long nIndex ) const;
     116             :     ScDPSaveGroupItem* GetGroupAccByIndex( long nIndex );
     117             : 
     118             :     void    Rename( const OUString& rNewName );
     119             : 
     120             : private:
     121             :     bool IsInGroup(const ScDPItemData& rItem) const;
     122             : };
     123             : 
     124             : /**
     125             :  * Represents a group dimension that introduces a new hierarchy for an
     126             :  * existing dimension.  Unlike the ScDPSaveGroupDimension counterpart, it
     127             :  * re-uses the source dimension name and ID.
     128             :  */
     129           4 : class SC_DLLPUBLIC ScDPSaveNumGroupDimension
     130             : {
     131             :     OUString       aDimensionName;
     132             :     mutable ScDPNumGroupInfo aGroupInfo;
     133             :     mutable ScDPNumGroupInfo aDateInfo;
     134             :     sal_Int32           nDatePart;
     135             : 
     136             : public:
     137             :                 ScDPSaveNumGroupDimension( const OUString& rName, const ScDPNumGroupInfo& rInfo );
     138             :                 ScDPSaveNumGroupDimension( const OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
     139             :                 ~ScDPSaveNumGroupDimension();
     140             : 
     141             :     void        AddToData( ScDPGroupTableData& rData ) const;
     142             :     void AddToCache(ScDPCache& rCache) const;
     143             : 
     144           4 :     const OUString& GetDimensionName() const  { return aDimensionName; }
     145           0 :     const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
     146             : 
     147           0 :     sal_Int32   GetDatePart() const             { return nDatePart; }
     148           0 :     const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
     149             : 
     150             :     void        SetGroupInfo( const ScDPNumGroupInfo& rNew );
     151             :     void        SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
     152             : };
     153             : 
     154             : /**
     155             :  * This class has to do with handling exclusively grouped dimensions?  TODO:
     156             :  * Find out what this class does and document it here.
     157             :  */
     158           8 : class SC_DLLPUBLIC ScDPDimensionSaveData
     159             : {
     160             : public:
     161             :             ScDPDimensionSaveData();
     162             :             ~ScDPDimensionSaveData();
     163             : 
     164             :     bool    operator==( const ScDPDimensionSaveData& r ) const;
     165             : 
     166             :     void    WriteToData( ScDPGroupTableData& rData ) const;
     167             : 
     168             :     void WriteToCache(ScDPCache& rCache) const;
     169             : 
     170             :     OUString CreateGroupDimName(
     171             :         const OUString& rSourceName, const ScDPObject& rObject, bool bAllowSource,
     172             :         const ::std::vector<OUString>* pDeletedNames );
     173             : 
     174             :     OUString CreateDateGroupDimName(
     175             :         sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource,
     176             :         const ::std::vector<OUString>* pDeletedNames );
     177             : 
     178             :     void    AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
     179             :     void    ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
     180             :     void    RemoveGroupDimension( const OUString& rGroupDimName );
     181             : 
     182             :     void    AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
     183             :     void    ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
     184             :     void    RemoveNumGroupDimension( const OUString& rGroupDimName );
     185             : 
     186             :     const ScDPSaveGroupDimension* GetGroupDimForBase( const OUString& rBaseDimName ) const;
     187             :     const ScDPSaveGroupDimension* GetNamedGroupDim( const OUString& rGroupDimName ) const;
     188             :     const ScDPSaveGroupDimension* GetFirstNamedGroupDim( const OUString& rBaseDimName ) const;
     189             :     const ScDPSaveGroupDimension* GetNextNamedGroupDim( const OUString& rGroupDimName ) const;
     190             :     const ScDPSaveNumGroupDimension* GetNumGroupDim( const OUString& rGroupDimName ) const;
     191             : 
     192             :     ScDPSaveGroupDimension* GetGroupDimAccForBase( const OUString& rBaseDimName );
     193             :     ScDPSaveGroupDimension* GetNamedGroupDimAcc( const OUString& rGroupDimName );
     194             :     ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const OUString& rBaseDimName );
     195             :     ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const OUString& rGroupDimName );
     196             : 
     197             :     ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const OUString& rGroupDimName );
     198             : 
     199             :     bool    HasGroupDimensions() const;
     200             : 
     201             :     sal_Int32 CollectDateParts( const OUString& rBaseDimName ) const;
     202             : 
     203             : private:
     204             :     typedef ::std::vector< ScDPSaveGroupDimension >         ScDPSaveGroupDimVec;
     205             :     typedef ::std::map<OUString, ScDPSaveNumGroupDimension> ScDPSaveNumGroupDimMap;
     206             : 
     207             :     ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& );
     208             : 
     209             :     ScDPSaveGroupDimVec maGroupDims;
     210             :     ScDPSaveNumGroupDimMap maNumGroupDims;
     211             : };
     212             : 
     213             : #endif
     214             : 
     215             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10