xref: /trunk/main/sc/inc/olinetab.hxx (revision 38d50f7b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_OUTLINETAB_HXX
25 #define SC_OUTLINETAB_HXX
26 
27 
28 #include "collect.hxx"
29 #include "scdllapi.h"
30 
31 #define SC_OL_MAXDEPTH      7
32 
33 class SvStream;
34 class ScTable;
35 
36 
37 class ScOutlineEntry : public ScDataObject
38 {
39     SCCOLROW    nStart;
40     SCSIZE      nSize;
41     bool        bHidden;
42     bool        bVisible;
43 
44 public:
45                             ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize,
46                                                 bool bNewHidden = sal_False );
47                             ScOutlineEntry( const ScOutlineEntry& rEntry );
48 
49     virtual ScDataObject*       Clone() const;
50 
GetStart() const51     SCCOLROW                GetStart() const    { return nStart; }
GetSize() const52     SCSIZE                  GetSize() const     { return nSize; }
GetEnd() const53     SCCOLROW                GetEnd() const      { return nStart+nSize-1; }
IsHidden() const54     bool                    IsHidden() const    { return bHidden; }             // Gruppe versteckt
IsVisible() const55     bool                    IsVisible() const   { return bVisible; }            // Control sichtbar?
56 
57     void                    Move( SCsCOLROW nDelta );
58     void                    SetSize( SCSIZE nNewSize );
59     void                    SetPosSize( SCCOLROW nNewPos, SCSIZE nNewSize );
60     void                    SetHidden( bool bNewHidden );
61     void                    SetVisible( bool bNewVisible );
62 };
63 
64 
65 class ScOutlineCollection : public ScSortedCollection
66 {
67 public:
68                             ScOutlineCollection();
69 
70     virtual short           Compare(ScDataObject* pKey1, ScDataObject* pKey2) const;
71 
72     sal_uInt16                  FindStart( SCCOLROW nMinStart );
73 };
74 
75 
76 class SC_DLLPUBLIC ScOutlineArray
77 {
78 friend class ScSubOutlineIterator;
79 
80 private:
81     sal_uInt16                  nDepth;
82     ScOutlineCollection     aCollections[SC_OL_MAXDEPTH];
83 
84     sal_Bool                    DecDepth();
85     void                    FindEntry( SCCOLROW nSearchPos, sal_uInt16& rFindLevel, sal_uInt16& rFindIndex,
86                                         sal_uInt16 nMaxLevel = SC_OL_MAXDEPTH );
87     void                    RemoveSub( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_uInt16 nLevel );
88     void                    PromoteSub( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_uInt16 nStartLevel );
89 
90 public:
91                             ScOutlineArray();
92                             ScOutlineArray( const ScOutlineArray& rArray );
93 
GetDepth() const94     sal_uInt16                  GetDepth() const         { return nDepth; }
95 
96     sal_Bool                    FindTouchedLevel( SCCOLROW nBlockStart, SCCOLROW nBlockEnd,
97                                                 sal_uInt16& rFindLevel ) const;
98 
99     sal_Bool                    Insert( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_Bool& rSizeChanged,
100                                     sal_Bool bHidden = sal_False, sal_Bool bVisible = sal_True );
101     sal_Bool                    Remove( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, sal_Bool& rSizeChanged );
102 
103     ScOutlineEntry*         GetEntry( sal_uInt16 nLevel, sal_uInt16 nIndex ) const;
104     sal_uInt16                  GetCount( sal_uInt16 nLevel ) const;
105     ScOutlineEntry*         GetEntryByPos( sal_uInt16 nLevel, SCCOLROW nPos ) const;
106 
107     sal_Bool                    GetEntryIndex( sal_uInt16 nLevel, SCCOLROW nPos, sal_uInt16& rnIndex ) const;
108     sal_Bool                    GetEntryIndexInRange(
109                                 sal_uInt16 nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd,
110                                 sal_uInt16& rnIndex ) const;
111 
112     void                    SetVisibleBelow( sal_uInt16 nLevel, sal_uInt16 nEntry, sal_Bool bValue,
113                                                 sal_Bool bSkipHidden = sal_False );
114 
115     void                    GetRange( SCCOLROW& rStart, SCCOLROW& rEnd ) const;
116     void                    ExtendBlock( sal_uInt16 nLevel, SCCOLROW& rBlkStart, SCCOLROW& rBlkEnd );
117 
118     sal_Bool                    TestInsertSpace( SCSIZE nSize, SCCOLROW nMaxVal ) const;
119     void                    InsertSpace( SCCOLROW nStartPos, SCSIZE nSize );
120     sal_Bool                    DeleteSpace( SCCOLROW nStartPos, SCSIZE nSize );
121 
122     bool                    ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, ScTable& rTable, bool bCol );
123 
124     void                    RemoveAll();
125 };
126 
127 
128 class ScOutlineTable
129 {
130 private:
131     ScOutlineArray          aColOutline;
132     ScOutlineArray          aRowOutline;
133 
134 public:
135                             ScOutlineTable();
136                             ScOutlineTable( const ScOutlineTable& rOutline );
137 
GetColArray() const138     const ScOutlineArray*   GetColArray() const     { return &aColOutline; }
GetColArray()139     ScOutlineArray*         GetColArray()           { return &aColOutline; }
GetRowArray() const140     const ScOutlineArray*   GetRowArray() const     { return &aRowOutline; }
GetRowArray()141     ScOutlineArray*         GetRowArray()           { return &aRowOutline; }
142 
143     sal_Bool                    TestInsertCol( SCSIZE nSize );
144     void                    InsertCol( SCCOL nStartCol, SCSIZE nSize );
145     sal_Bool                    DeleteCol( SCCOL nStartCol, SCSIZE nSize ); // TRUE: Undo nur ueber Original
146     sal_Bool                    TestInsertRow( SCSIZE nSize );
147     void                    InsertRow( SCROW nStartRow, SCSIZE nSize );
148     sal_Bool                    DeleteRow( SCROW nStartRow, SCSIZE nSize );
149 };
150 
151 
152 class ScSubOutlineIterator
153 {
154 private:
155     ScOutlineArray*         pArray;
156     SCCOLROW                nStart;
157     SCCOLROW                nEnd;
158     sal_uInt16                  nSubLevel;
159     sal_uInt16                  nSubEntry;
160     sal_uInt16                  nCount;
161     sal_uInt16                  nDepth;
162 
163 public:
164                             ScSubOutlineIterator( ScOutlineArray* pOutlineArray );
165                             ScSubOutlineIterator( ScOutlineArray* pOutlineArray,
166                                                     sal_uInt16 nLevel, sal_uInt16 nEntry );
167     ScOutlineEntry*         GetNext();
168     sal_uInt16                  LastLevel() const;
169     sal_uInt16                  LastEntry() const;
170     void                    DeleteLast();
171 };
172 
173 #endif
174 
175 
176