1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SC_OUTLINETAB_HXX 29 #define SC_OUTLINETAB_HXX 30 31 32 #include "collect.hxx" 33 #include "scdllapi.h" 34 35 #define SC_OL_MAXDEPTH 7 36 37 class SvStream; 38 class ScTable; 39 40 41 class ScOutlineEntry : public ScDataObject 42 { 43 SCCOLROW nStart; 44 SCSIZE nSize; 45 bool bHidden; 46 bool bVisible; 47 48 public: 49 ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, 50 bool bNewHidden = sal_False ); 51 ScOutlineEntry( const ScOutlineEntry& rEntry ); 52 53 virtual ScDataObject* Clone() const; 54 55 SCCOLROW GetStart() const { return nStart; } 56 SCSIZE GetSize() const { return nSize; } 57 SCCOLROW GetEnd() const { return nStart+nSize-1; } 58 bool IsHidden() const { return bHidden; } // Gruppe versteckt 59 bool IsVisible() const { return bVisible; } // Control sichtbar? 60 61 void Move( SCsCOLROW nDelta ); 62 void SetSize( SCSIZE nNewSize ); 63 void SetPosSize( SCCOLROW nNewPos, SCSIZE nNewSize ); 64 void SetHidden( bool bNewHidden ); 65 void SetVisible( bool bNewVisible ); 66 }; 67 68 69 class ScOutlineCollection : public ScSortedCollection 70 { 71 public: 72 ScOutlineCollection(); 73 74 virtual short Compare(ScDataObject* pKey1, ScDataObject* pKey2) const; 75 76 sal_uInt16 FindStart( SCCOLROW nMinStart ); 77 }; 78 79 80 class SC_DLLPUBLIC ScOutlineArray 81 { 82 friend class ScSubOutlineIterator; 83 84 private: 85 sal_uInt16 nDepth; 86 ScOutlineCollection aCollections[SC_OL_MAXDEPTH]; 87 88 sal_Bool DecDepth(); 89 void FindEntry( SCCOLROW nSearchPos, sal_uInt16& rFindLevel, sal_uInt16& rFindIndex, 90 sal_uInt16 nMaxLevel = SC_OL_MAXDEPTH ); 91 void RemoveSub( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_uInt16 nLevel ); 92 void PromoteSub( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_uInt16 nStartLevel ); 93 94 public: 95 ScOutlineArray(); 96 ScOutlineArray( const ScOutlineArray& rArray ); 97 98 sal_uInt16 GetDepth() const { return nDepth; } 99 100 sal_Bool FindTouchedLevel( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, 101 sal_uInt16& rFindLevel ) const; 102 103 sal_Bool Insert( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_Bool& rSizeChanged, 104 sal_Bool bHidden = sal_False, sal_Bool bVisible = sal_True ); 105 sal_Bool Remove( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, sal_Bool& rSizeChanged ); 106 107 ScOutlineEntry* GetEntry( sal_uInt16 nLevel, sal_uInt16 nIndex ) const; 108 sal_uInt16 GetCount( sal_uInt16 nLevel ) const; 109 ScOutlineEntry* GetEntryByPos( sal_uInt16 nLevel, SCCOLROW nPos ) const; 110 111 sal_Bool GetEntryIndex( sal_uInt16 nLevel, SCCOLROW nPos, sal_uInt16& rnIndex ) const; 112 sal_Bool GetEntryIndexInRange( 113 sal_uInt16 nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd, 114 sal_uInt16& rnIndex ) const; 115 116 void SetVisibleBelow( sal_uInt16 nLevel, sal_uInt16 nEntry, sal_Bool bValue, 117 sal_Bool bSkipHidden = sal_False ); 118 119 void GetRange( SCCOLROW& rStart, SCCOLROW& rEnd ) const; 120 void ExtendBlock( sal_uInt16 nLevel, SCCOLROW& rBlkStart, SCCOLROW& rBlkEnd ); 121 122 sal_Bool TestInsertSpace( SCSIZE nSize, SCCOLROW nMaxVal ) const; 123 void InsertSpace( SCCOLROW nStartPos, SCSIZE nSize ); 124 sal_Bool DeleteSpace( SCCOLROW nStartPos, SCSIZE nSize ); 125 126 bool ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, ScTable& rTable, bool bCol ); 127 128 void RemoveAll(); 129 }; 130 131 132 class ScOutlineTable 133 { 134 private: 135 ScOutlineArray aColOutline; 136 ScOutlineArray aRowOutline; 137 138 public: 139 ScOutlineTable(); 140 ScOutlineTable( const ScOutlineTable& rOutline ); 141 142 const ScOutlineArray* GetColArray() const { return &aColOutline; } 143 ScOutlineArray* GetColArray() { return &aColOutline; } 144 const ScOutlineArray* GetRowArray() const { return &aRowOutline; } 145 ScOutlineArray* GetRowArray() { return &aRowOutline; } 146 147 sal_Bool TestInsertCol( SCSIZE nSize ); 148 void InsertCol( SCCOL nStartCol, SCSIZE nSize ); 149 sal_Bool DeleteCol( SCCOL nStartCol, SCSIZE nSize ); // TRUE: Undo nur ueber Original 150 sal_Bool TestInsertRow( SCSIZE nSize ); 151 void InsertRow( SCROW nStartRow, SCSIZE nSize ); 152 sal_Bool DeleteRow( SCROW nStartRow, SCSIZE nSize ); 153 }; 154 155 156 class ScSubOutlineIterator 157 { 158 private: 159 ScOutlineArray* pArray; 160 SCCOLROW nStart; 161 SCCOLROW nEnd; 162 sal_uInt16 nSubLevel; 163 sal_uInt16 nSubEntry; 164 sal_uInt16 nCount; 165 sal_uInt16 nDepth; 166 167 public: 168 ScSubOutlineIterator( ScOutlineArray* pOutlineArray ); 169 ScSubOutlineIterator( ScOutlineArray* pOutlineArray, 170 sal_uInt16 nLevel, sal_uInt16 nEntry ); 171 ScOutlineEntry* GetNext(); 172 sal_uInt16 LastLevel() const; 173 sal_uInt16 LastEntry() const; 174 void DeleteLast(); 175 }; 176 177 #endif 178 179 180