1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef SC_DPDIMSAVE_HXX 29*cdf0e10cSrcweir #define SC_DPDIMSAVE_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <vector> 32*cdf0e10cSrcweir #include <map> 33*cdf0e10cSrcweir #include <tools/string.hxx> 34*cdf0e10cSrcweir #include "dpgroup.hxx" // for ScDPNumGroupInfo 35*cdf0e10cSrcweir #include "scdllapi.h" 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir class ScDPGroupTableData; 38*cdf0e10cSrcweir class ScDPGroupDimension; 39*cdf0e10cSrcweir class ScDPObject; 40*cdf0e10cSrcweir class ScStrCollection; 41*cdf0e10cSrcweir class SvNumberFormatter; 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir class ScDPSaveGroupDimension; 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir // -------------------------------------------------------------------- 46*cdf0e10cSrcweir // 47*cdf0e10cSrcweir // Classes to save Data Pilot settings that create new dimensions (fields). 48*cdf0e10cSrcweir // These have to be applied before the other ScDPSaveData settings. 49*cdf0e10cSrcweir // 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir // ============================================================================ 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir class SC_DLLPUBLIC ScDPSaveGroupItem 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir String aGroupName; // name of group 56*cdf0e10cSrcweir ::std::vector<String> aElements; // names of items in original dimension 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir public: 59*cdf0e10cSrcweir ScDPSaveGroupItem( const String& rName ); 60*cdf0e10cSrcweir ~ScDPSaveGroupItem(); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir void AddToData( ScDPGroupDimension& rDataDim, SvNumberFormatter* pFormatter ) const; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir void AddElement( const String& rName ); 65*cdf0e10cSrcweir void AddElementsFromGroup( const ScDPSaveGroupItem& rGroup ); 66*cdf0e10cSrcweir const String& GetGroupName() const { return aGroupName; } 67*cdf0e10cSrcweir bool RemoveElement( const String& rName ); // returns true if found (removed) 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir bool IsEmpty() const; 70*cdf0e10cSrcweir size_t GetElementCount() const; 71*cdf0e10cSrcweir const String* GetElementByIndex( size_t nIndex ) const; 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir void Rename( const String& rNewName ); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir // remove this group's elements from their groups in rDimension 76*cdf0e10cSrcweir // (rDimension must be a different dimension from the one which contains this) 77*cdf0e10cSrcweir void RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const; 78*cdf0e10cSrcweir }; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir // ============================================================================ 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir class SC_DLLPUBLIC ScDPSaveGroupDimension 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir String aSourceDim; // always the real source from the original data 87*cdf0e10cSrcweir String aGroupDimName; 88*cdf0e10cSrcweir ScDPSaveGroupItemVec aGroups; 89*cdf0e10cSrcweir ScDPNumGroupInfo aDateInfo; 90*cdf0e10cSrcweir sal_Int32 nDatePart; 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir public: 93*cdf0e10cSrcweir ScDPSaveGroupDimension( const String& rSource, const String& rName ); 94*cdf0e10cSrcweir ScDPSaveGroupDimension( const String& rSource, const String& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart ); 95*cdf0e10cSrcweir ~ScDPSaveGroupDimension(); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir void AddToData( ScDPGroupTableData& rData ) const; 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart ); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir void AddGroupItem( const ScDPSaveGroupItem& rItem ); 102*cdf0e10cSrcweir const String& GetGroupDimName() const { return aGroupDimName; } 103*cdf0e10cSrcweir const String& GetSourceDimName() const { return aSourceDim; } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir sal_Int32 GetDatePart() const { return nDatePart; } 106*cdf0e10cSrcweir const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; } 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir String CreateGroupName( const String& rPrefix ); 109*cdf0e10cSrcweir const ScDPSaveGroupItem* GetNamedGroup( const String& rGroupName ) const; 110*cdf0e10cSrcweir ScDPSaveGroupItem* GetNamedGroupAcc( const String& rGroupName ); 111*cdf0e10cSrcweir void RemoveFromGroups( const String& rItemName ); 112*cdf0e10cSrcweir void RemoveGroup( const String& rGroupName ); 113*cdf0e10cSrcweir bool IsEmpty() const; 114*cdf0e10cSrcweir bool HasOnlyHidden( const ScStrCollection& rVisible ); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir long GetGroupCount() const; 117*cdf0e10cSrcweir const ScDPSaveGroupItem* GetGroupByIndex( long nIndex ) const; 118*cdf0e10cSrcweir ScDPSaveGroupItem* GetGroupAccByIndex( long nIndex ); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir void Rename( const String& rNewName ); 121*cdf0e10cSrcweir }; 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir // ============================================================================ 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir class SC_DLLPUBLIC ScDPSaveNumGroupDimension 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir String aDimensionName; 128*cdf0e10cSrcweir ScDPNumGroupInfo aGroupInfo; 129*cdf0e10cSrcweir ScDPNumGroupInfo aDateInfo; 130*cdf0e10cSrcweir sal_Int32 nDatePart; 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir public: 133*cdf0e10cSrcweir ScDPSaveNumGroupDimension( const String& rName, const ScDPNumGroupInfo& rInfo ); 134*cdf0e10cSrcweir ScDPSaveNumGroupDimension( const String& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart ); 135*cdf0e10cSrcweir ~ScDPSaveNumGroupDimension(); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir void AddToData( ScDPGroupTableData& rData ) const; 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir const String& GetDimensionName() const { return aDimensionName; } 140*cdf0e10cSrcweir const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir sal_Int32 GetDatePart() const { return nDatePart; } 143*cdf0e10cSrcweir const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir void SetGroupInfo( const ScDPNumGroupInfo& rNew ); 146*cdf0e10cSrcweir void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart ); 147*cdf0e10cSrcweir }; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir // ============================================================================ 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir class SC_DLLPUBLIC ScDPDimensionSaveData 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir public: 154*cdf0e10cSrcweir ScDPDimensionSaveData(); 155*cdf0e10cSrcweir ~ScDPDimensionSaveData(); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir bool operator==( const ScDPDimensionSaveData& r ) const; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir void WriteToData( ScDPGroupTableData& rData ) const; 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir String CreateGroupDimName( const String& rSourceName, const ScDPObject& rObject, bool bAllowSource, const ::std::vector< String >* pDeletedNames ); 162*cdf0e10cSrcweir String CreateDateGroupDimName( sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource, const ::std::vector< String >* pDeletedNames ); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir void AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim ); 165*cdf0e10cSrcweir void ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim ); 166*cdf0e10cSrcweir void RemoveGroupDimension( const String& rGroupDimName ); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir void AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim ); 169*cdf0e10cSrcweir void ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim ); 170*cdf0e10cSrcweir void RemoveNumGroupDimension( const String& rGroupDimName ); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir const ScDPSaveGroupDimension* GetGroupDimForBase( const String& rBaseDimName ) const; 173*cdf0e10cSrcweir const ScDPSaveGroupDimension* GetNamedGroupDim( const String& rGroupDimName ) const; 174*cdf0e10cSrcweir const ScDPSaveGroupDimension* GetFirstNamedGroupDim( const String& rBaseDimName ) const; 175*cdf0e10cSrcweir const ScDPSaveGroupDimension* GetNextNamedGroupDim( const String& rGroupDimName ) const; 176*cdf0e10cSrcweir const ScDPSaveNumGroupDimension* GetNumGroupDim( const String& rGroupDimName ) const; 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir ScDPSaveGroupDimension* GetGroupDimAccForBase( const String& rBaseDimName ); 179*cdf0e10cSrcweir ScDPSaveGroupDimension* GetNamedGroupDimAcc( const String& rGroupDimName ); 180*cdf0e10cSrcweir ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const String& rBaseDimName ); 181*cdf0e10cSrcweir ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const String& rGroupDimName ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const String& rGroupDimName ); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir bool HasGroupDimensions() const; 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir sal_Int32 CollectDateParts( const String& rBaseDimName ) const; 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir private: 190*cdf0e10cSrcweir typedef ::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec; 191*cdf0e10cSrcweir typedef ::std::map< String, ScDPSaveNumGroupDimension > ScDPSaveNumGroupDimMap; 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& ); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir ScDPSaveGroupDimVec maGroupDims; 196*cdf0e10cSrcweir ScDPSaveNumGroupDimMap maNumGroupDims; 197*cdf0e10cSrcweir }; 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir // ============================================================================ 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir #endif 202*cdf0e10cSrcweir 203