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

Generated by: LCOV version 1.10