101aa44aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
301aa44aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
401aa44aaSAndrew Rist * or more contributor license agreements. See the NOTICE file
501aa44aaSAndrew Rist * distributed with this work for additional information
601aa44aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file
701aa44aaSAndrew Rist * to you under the Apache License, Version 2.0 (the
801aa44aaSAndrew Rist * "License"); you may not use this file except in compliance
901aa44aaSAndrew Rist * with the License. You may obtain a copy of the License at
1001aa44aaSAndrew Rist *
1101aa44aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
1201aa44aaSAndrew Rist *
1301aa44aaSAndrew Rist * Unless required by applicable law or agreed to in writing,
1401aa44aaSAndrew Rist * software distributed under the License is distributed on an
1501aa44aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1601aa44aaSAndrew Rist * KIND, either express or implied. See the License for the
1701aa44aaSAndrew Rist * specific language governing permissions and limitations
1801aa44aaSAndrew Rist * under the License.
1901aa44aaSAndrew Rist *
2001aa44aaSAndrew Rist *************************************************************/
2101aa44aaSAndrew Rist
2201aa44aaSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _SVTREELIST_HXX
25cdf0e10cSrcweir #define _SVTREELIST_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "svtools/svtdllapi.h"
28cdf0e10cSrcweir #include <tools/solar.h>
29cdf0e10cSrcweir #include <tools/list.hxx>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #ifndef _TABLE_HXX
32cdf0e10cSrcweir #include <tools/table.hxx>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include <tools/link.hxx>
35cdf0e10cSrcweir #include <tools/string.hxx>
36cdf0e10cSrcweir #include <tools/debug.hxx>
37cdf0e10cSrcweir
38cdf0e10cSrcweir #define LISTACTION_INSERTED 1
39cdf0e10cSrcweir #define LISTACTION_REMOVING 2
40cdf0e10cSrcweir #define LISTACTION_REMOVED 3
41cdf0e10cSrcweir #define LISTACTION_MOVING 4
42cdf0e10cSrcweir #define LISTACTION_MOVED 5
43cdf0e10cSrcweir #define LISTACTION_CLEARING 6
44cdf0e10cSrcweir #define LISTACTION_INSERTED_TREE 7
45cdf0e10cSrcweir #define LISTACTION_INVALIDATE_ENTRY 8
46cdf0e10cSrcweir #define LISTACTION_RESORTING 9
47cdf0e10cSrcweir #define LISTACTION_RESORTED 10
48cdf0e10cSrcweir #define LISTACTION_CLEARED 11
49cdf0e10cSrcweir
50cdf0e10cSrcweir #define SV_TREELIST_ROOT_ENTRY (SvListEntry*)0
51cdf0e10cSrcweir #define SV_TREELIST_ERROR 0xFFFFFFFF
52cdf0e10cSrcweir
53cdf0e10cSrcweir // Entryflags, die an der View haengen
54cdf0e10cSrcweir #define SVLISTENTRYFLAG_SELECTED 0x0001
55cdf0e10cSrcweir #define SVLISTENTRYFLAG_EXPANDED 0x0002
56cdf0e10cSrcweir #define SVLISTENTRYFLAG_FOCUSED 0x0004
57cdf0e10cSrcweir #define SVLISTENTRYFLAG_CURSORED 0x0008
58cdf0e10cSrcweir #define SVLISTENTRYFLAG_NOT_SELECTABLE 0x0010
592bfcd321SSteve Yin // IAccessible2 implementation
602bfcd321SSteve Yin #define SVLISTENTRYFLAG_OBJSELECTED 0x0040
61cdf0e10cSrcweir
62cdf0e10cSrcweir class SvListEntry;
63cdf0e10cSrcweir
64cdf0e10cSrcweir class SvTreeEntryList : public List // SvEntryListStd
65cdf0e10cSrcweir {
66cdf0e10cSrcweir public:
SvTreeEntryList(sal_uInt16 nInitPos=16,sal_uInt16 nResize=16)67cdf0e10cSrcweir SvTreeEntryList(sal_uInt16 nInitPos=16, sal_uInt16 nResize=16 )
68cdf0e10cSrcweir : List( nInitPos, nResize )
69cdf0e10cSrcweir {}
SvTreeEntryList(sal_uInt16 BlockSize,sal_uInt16 InitSize,sal_uInt16 Resize)70cdf0e10cSrcweir SvTreeEntryList(sal_uInt16 BlockSize, sal_uInt16 InitSize, sal_uInt16 Resize )
71cdf0e10cSrcweir : List(BlockSize, InitSize, Resize )
72cdf0e10cSrcweir {}
73cdf0e10cSrcweir
74cdf0e10cSrcweir void DestroyAll();
75cdf0e10cSrcweir };
76cdf0e10cSrcweir
77cdf0e10cSrcweir class SVT_DLLPUBLIC SvListEntry
78cdf0e10cSrcweir {
79cdf0e10cSrcweir friend class SvTreeList;
80cdf0e10cSrcweir friend class SvListView;
81cdf0e10cSrcweir
82cdf0e10cSrcweir private:
83cdf0e10cSrcweir SvListEntry* pParent;
84cdf0e10cSrcweir SvTreeEntryList* pChilds;
85cdf0e10cSrcweir sal_uLong nAbsPos;
86cdf0e10cSrcweir sal_uLong nListPos;
87cdf0e10cSrcweir
88cdf0e10cSrcweir void SetListPositions();
InvalidateChildrensListPositions()89cdf0e10cSrcweir void InvalidateChildrensListPositions()
90cdf0e10cSrcweir {
91cdf0e10cSrcweir nListPos |= 0x80000000;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir public:
94cdf0e10cSrcweir SvListEntry();
95cdf0e10cSrcweir SvListEntry( const SvListEntry& );
96cdf0e10cSrcweir virtual ~SvListEntry();
HasChilds()97cdf0e10cSrcweir sal_Bool HasChilds() { return (sal_Bool)(pChilds!=0); }
HasChildListPos() const98cdf0e10cSrcweir sal_Bool HasChildListPos() const
99cdf0e10cSrcweir {
100cdf0e10cSrcweir if( pParent && !(pParent->nListPos & 0x80000000) )
101cdf0e10cSrcweir return sal_True;
102cdf0e10cSrcweir else return sal_False;
103cdf0e10cSrcweir }
GetChildListPos() const104cdf0e10cSrcweir sal_uLong GetChildListPos() const
105cdf0e10cSrcweir {
106cdf0e10cSrcweir if( pParent && (pParent->nListPos & 0x80000000) )
107cdf0e10cSrcweir pParent->SetListPositions();
108cdf0e10cSrcweir return ( nListPos & 0x7fffffff );
109cdf0e10cSrcweir }
110cdf0e10cSrcweir virtual void Clone( SvListEntry* pSource );
111cdf0e10cSrcweir };
112cdf0e10cSrcweir
113cdf0e10cSrcweir class SvListView;
114cdf0e10cSrcweir
115cdf0e10cSrcweir class SvViewData
116cdf0e10cSrcweir {
117cdf0e10cSrcweir friend class SvTreeList;
118cdf0e10cSrcweir friend class SvListView;
119cdf0e10cSrcweir
120cdf0e10cSrcweir sal_uLong nVisPos;
121cdf0e10cSrcweir protected:
122cdf0e10cSrcweir sal_uInt16 nFlags;
123cdf0e10cSrcweir public:
124cdf0e10cSrcweir SvViewData();
125cdf0e10cSrcweir SvViewData( const SvViewData& );
126cdf0e10cSrcweir virtual ~SvViewData();
127cdf0e10cSrcweir
IsSelected() const128cdf0e10cSrcweir sal_Bool IsSelected() const { return (sal_Bool)(nFlags&SVLISTENTRYFLAG_SELECTED)!=0; }
IsExpanded() const129cdf0e10cSrcweir sal_Bool IsExpanded() const { return (sal_Bool)(nFlags&SVLISTENTRYFLAG_EXPANDED)!=0; }
HasFocus() const130cdf0e10cSrcweir sal_Bool HasFocus() const { return (sal_Bool)(nFlags&SVLISTENTRYFLAG_FOCUSED)!=0; }
SetFocus(sal_Bool bFocus)131cdf0e10cSrcweir void SetFocus( sal_Bool bFocus)
132cdf0e10cSrcweir {
133cdf0e10cSrcweir if ( !bFocus )
134cdf0e10cSrcweir nFlags &= (~SVLISTENTRYFLAG_FOCUSED);
135cdf0e10cSrcweir else
136cdf0e10cSrcweir nFlags |= SVLISTENTRYFLAG_FOCUSED;
137cdf0e10cSrcweir }
IsCursored() const138cdf0e10cSrcweir sal_Bool IsCursored() const { return (sal_Bool)(nFlags&SVLISTENTRYFLAG_CURSORED)!=0; }
SetCursored(sal_Bool bCursored)139cdf0e10cSrcweir void SetCursored( sal_Bool bCursored )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir if ( !bCursored )
142cdf0e10cSrcweir nFlags &= (~SVLISTENTRYFLAG_CURSORED);
143cdf0e10cSrcweir else
144cdf0e10cSrcweir nFlags |= SVLISTENTRYFLAG_CURSORED;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir
GetFlags() const147cdf0e10cSrcweir sal_uInt16 GetFlags() const { return nFlags; }
148cdf0e10cSrcweir
SetSelectable(bool bSelectable)149cdf0e10cSrcweir void SetSelectable( bool bSelectable )
150cdf0e10cSrcweir {
151cdf0e10cSrcweir if( bSelectable )
152cdf0e10cSrcweir nFlags &= (~SVLISTENTRYFLAG_NOT_SELECTABLE);
153cdf0e10cSrcweir else
154cdf0e10cSrcweir nFlags |= SVLISTENTRYFLAG_NOT_SELECTABLE;
155cdf0e10cSrcweir }
IsSelectable() const156cdf0e10cSrcweir bool IsSelectable() const { return (bool)(nFlags&SVLISTENTRYFLAG_NOT_SELECTABLE)==0; }
1572bfcd321SSteve Yin // IAccessible2 implementation
SetObjectSelected(sal_Bool bSelected)1582bfcd321SSteve Yin void SetObjectSelected(sal_Bool bSelected)
1592bfcd321SSteve Yin {
1602bfcd321SSteve Yin if ( !bSelected )
1612bfcd321SSteve Yin nFlags &= (~SVLISTENTRYFLAG_OBJSELECTED);
1622bfcd321SSteve Yin else
1632bfcd321SSteve Yin nFlags |= SVLISTENTRYFLAG_OBJSELECTED;
1642bfcd321SSteve Yin }
165cdf0e10cSrcweir };
166cdf0e10cSrcweir
167cdf0e10cSrcweir enum SvSortMode { SortAscending, SortDescending, SortNone };
168cdf0e10cSrcweir
169cdf0e10cSrcweir // Rueckgabewerte Sortlink:
170cdf0e10cSrcweir // siehe International::Compare( pLeft, pRight )
171cdf0e10cSrcweir // ( Compare(a,b) ==> b.Compare(a) ==> strcmp(a,b) )
172cdf0e10cSrcweir struct SvSortData
173cdf0e10cSrcweir {
174cdf0e10cSrcweir SvListEntry* pLeft;
175cdf0e10cSrcweir SvListEntry* pRight;
176cdf0e10cSrcweir };
177cdf0e10cSrcweir
178cdf0e10cSrcweir class SVT_DLLPUBLIC SvTreeList
179cdf0e10cSrcweir {
180cdf0e10cSrcweir friend class SvListView;
181cdf0e10cSrcweir
182cdf0e10cSrcweir List aViewList;
183cdf0e10cSrcweir sal_uLong nEntryCount;
184cdf0e10cSrcweir
185cdf0e10cSrcweir Link aCloneLink;
186cdf0e10cSrcweir Link aCompareLink;
187cdf0e10cSrcweir SvSortMode eSortMode;
188cdf0e10cSrcweir
189cdf0e10cSrcweir sal_uInt16 nRefCount;
190cdf0e10cSrcweir
191cdf0e10cSrcweir sal_Bool bAbsPositionsValid;
192cdf0e10cSrcweir
FirstVisible() const193cdf0e10cSrcweir SvListEntry* FirstVisible() const { return First(); }
194cdf0e10cSrcweir SvListEntry* NextVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
195cdf0e10cSrcweir SvListEntry* PrevVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
196cdf0e10cSrcweir SvListEntry* LastVisible( const SvListView*,sal_uInt16* pDepth=0 ) const;
197cdf0e10cSrcweir SvListEntry* NextVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16& rDelta ) const;
198cdf0e10cSrcweir SvListEntry* PrevVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16& rDelta ) const;
199cdf0e10cSrcweir
200cdf0e10cSrcweir sal_Bool IsEntryVisible( const SvListView*,SvListEntry* pEntry ) const;
201cdf0e10cSrcweir SvListEntry* GetEntryAtVisPos( const SvListView*,sal_uLong nVisPos ) const;
202cdf0e10cSrcweir sal_uLong GetVisiblePos( const SvListView*,SvListEntry* pEntry ) const;
203cdf0e10cSrcweir sal_uLong GetVisibleCount( const SvListView* ) const;
204cdf0e10cSrcweir sal_uLong GetVisibleChildCount( const SvListView*,SvListEntry* pParent ) const;
205cdf0e10cSrcweir
206cdf0e10cSrcweir SvListEntry* FirstSelected( const SvListView*) const;
207cdf0e10cSrcweir SvListEntry* NextSelected( const SvListView*,SvListEntry* pEntry ) const;
208cdf0e10cSrcweir SvListEntry* PrevSelected( const SvListView*,SvListEntry* pEntry ) const;
209cdf0e10cSrcweir SvListEntry* LastSelected( const SvListView*) const;
210cdf0e10cSrcweir
211cdf0e10cSrcweir sal_Bool Select( SvListView*,SvListEntry* pEntry, sal_Bool bSelect=sal_True );
212cdf0e10cSrcweir sal_uLong SelectChilds( SvListView*,SvListEntry* pParent, sal_Bool bSelect );
213cdf0e10cSrcweir void SelectAll( SvListView*,sal_Bool bSelect ); // ruft nicht Select-Hdl
214cdf0e10cSrcweir sal_uLong GetChildSelectionCount( const SvListView*,SvListEntry* pParent ) const;
215cdf0e10cSrcweir
216cdf0e10cSrcweir void Expand( SvListView*,SvListEntry* pParent );
217cdf0e10cSrcweir void Collapse( SvListView*,SvListEntry* pParent );
218cdf0e10cSrcweir
219cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE
220cdf0e10cSrcweir SVT_DLLPRIVATE void SetAbsolutePositions();
221cdf0e10cSrcweir SVT_DLLPRIVATE SvTreeEntryList*CloneChilds( SvTreeEntryList* pChilds,
222cdf0e10cSrcweir SvListEntry* pNewParent,
223cdf0e10cSrcweir sal_uLong& nCloneCount ) const;
224cdf0e10cSrcweir SVT_DLLPRIVATE void SetListPositions( SvTreeEntryList* );
225cdf0e10cSrcweir
226cdf0e10cSrcweir // rPos wird bei SortModeNone nicht geaendert
227cdf0e10cSrcweir SVT_DLLPRIVATE void GetInsertionPos( SvListEntry* pEntry, SvListEntry* pParent,
228cdf0e10cSrcweir sal_uLong& rPos );
229cdf0e10cSrcweir SVT_DLLPRIVATE void ResortChilds( SvListEntry* pParent );
230cdf0e10cSrcweir //#endif /* _SOLAR__PRIVATE */
231cdf0e10cSrcweir
232cdf0e10cSrcweir protected:
233cdf0e10cSrcweir
234cdf0e10cSrcweir SvListEntry* pRootItem;
235cdf0e10cSrcweir
236cdf0e10cSrcweir public:
237cdf0e10cSrcweir
238cdf0e10cSrcweir SvTreeList();
239cdf0e10cSrcweir virtual ~SvTreeList();
240cdf0e10cSrcweir
241cdf0e10cSrcweir void InsertView( SvListView* );
242cdf0e10cSrcweir void RemoveView( SvListView* );
GetViewCount() const243cdf0e10cSrcweir sal_uLong GetViewCount() const { return aViewList.Count(); }
GetView(sal_uLong nPos) const244cdf0e10cSrcweir SvListView* GetView(sal_uLong nPos) const {return (SvListView*)aViewList.GetObject(nPos);}
245cdf0e10cSrcweir void Broadcast( sal_uInt16 nActionId, SvListEntry* pEntry1=0,
246cdf0e10cSrcweir SvListEntry* pEntry2=0, sal_uLong nPos=0 );
247cdf0e10cSrcweir // informiert alle Listener
248cdf0e10cSrcweir void InvalidateEntry( SvListEntry* );
249cdf0e10cSrcweir
GetEntryCount() const250cdf0e10cSrcweir sal_uLong GetEntryCount() const { return nEntryCount; }
251cdf0e10cSrcweir SvListEntry* First() const;
252cdf0e10cSrcweir SvListEntry* Next( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
253cdf0e10cSrcweir SvListEntry* Prev( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
254cdf0e10cSrcweir SvListEntry* Last( sal_uInt16* pDepth=0 ) const;
255cdf0e10cSrcweir
256cdf0e10cSrcweir SvListEntry* FirstChild( SvListEntry* pParent ) const;
257cdf0e10cSrcweir SvListEntry* NextSibling( SvListEntry* pEntry ) const;
258cdf0e10cSrcweir SvListEntry* PrevSibling( SvListEntry* pEntry ) const;
259cdf0e10cSrcweir SvListEntry* LastSibling( SvListEntry* pEntry ) const;
260cdf0e10cSrcweir
261cdf0e10cSrcweir sal_uLong Insert( SvListEntry* pEntry,SvListEntry* pPar,sal_uLong nPos=LIST_APPEND);
Insert(SvListEntry * pEntry,sal_uLong nRootPos=LIST_APPEND)262cdf0e10cSrcweir sal_uLong Insert( SvListEntry* pEntry,sal_uLong nRootPos = LIST_APPEND ) { return Insert(pEntry, pRootItem, nRootPos ); }
263cdf0e10cSrcweir void InsertTree( SvListEntry* pTree, SvListEntry* pTarget );
264cdf0e10cSrcweir void InsertTree( SvListEntry* pTree, SvListEntry* pTargetParent,
265cdf0e10cSrcweir sal_uLong nListPos );
266cdf0e10cSrcweir // Entries muessen im gleichen Model stehen!
267cdf0e10cSrcweir void Move( SvListEntry* pSource, SvListEntry* pTarget );
268cdf0e10cSrcweir // erzeugt ggf. Child-List
269cdf0e10cSrcweir sal_uLong Move( SvListEntry* pSource, SvListEntry* pTargetParent,
270cdf0e10cSrcweir sal_uLong nListPos);
271cdf0e10cSrcweir void Copy( SvListEntry* pSource, SvListEntry* pTarget );
272cdf0e10cSrcweir sal_uLong Copy( SvListEntry* pSource, SvListEntry* pTargetParent,
273cdf0e10cSrcweir sal_uLong nListPos);
274cdf0e10cSrcweir
275cdf0e10cSrcweir sal_Bool Remove( SvListEntry* pEntry );
276cdf0e10cSrcweir void Clear();
277cdf0e10cSrcweir
278cdf0e10cSrcweir sal_Bool HasChilds( SvListEntry* pEntry ) const;
HasParent(SvListEntry * pEntry) const279cdf0e10cSrcweir sal_Bool HasParent( SvListEntry* pEntry ) const { return (sal_Bool)(pEntry->pParent!=pRootItem); }
280cdf0e10cSrcweir sal_Bool IsChild( SvListEntry* pParent, SvListEntry* pChild ) const;
281cdf0e10cSrcweir sal_Bool IsInChildList( SvListEntry* pParent, SvListEntry* pChild) const;
282cdf0e10cSrcweir SvListEntry* GetEntry( SvListEntry* pParent, sal_uLong nPos ) const;
283cdf0e10cSrcweir SvListEntry* GetEntry( sal_uLong nRootPos ) const;
284cdf0e10cSrcweir SvListEntry* GetEntryAtAbsPos( sal_uLong nAbsPos ) const;
285cdf0e10cSrcweir SvListEntry* GetParent( SvListEntry* pEntry ) const;
286cdf0e10cSrcweir SvListEntry* GetRootLevelParent( SvListEntry* pEntry ) const;
287cdf0e10cSrcweir SvTreeEntryList* GetChildList( SvListEntry* pParent ) const;
288cdf0e10cSrcweir
289cdf0e10cSrcweir sal_uLong GetAbsPos( SvListEntry* pEntry ) const;
GetRelPos(SvListEntry * pChild) const290cdf0e10cSrcweir sal_uLong GetRelPos( SvListEntry* pChild ) const { return pChild->GetChildListPos(); }
291cdf0e10cSrcweir sal_uLong GetChildCount( SvListEntry* pParent ) const;
292cdf0e10cSrcweir sal_uInt16 GetDepth( SvListEntry* pEntry ) const;
IsAtRootDepth(SvListEntry * pEntry) const293cdf0e10cSrcweir sal_Bool IsAtRootDepth( SvListEntry* pEntry ) const { return (sal_Bool)(pEntry->pParent==pRootItem); }
294cdf0e10cSrcweir
295cdf0e10cSrcweir // das Model ruft zum Clonen von Entries den Clone-Link auf,
296cdf0e10cSrcweir // damit man sich nicht vom Model ableiten muss, wenn man
297cdf0e10cSrcweir // sich von SvListEntry ableitet.
298cdf0e10cSrcweir // Deklaration des Clone-Handlers:
299cdf0e10cSrcweir // DECL_LINK(CloneHdl,SvListEntry*);
300cdf0e10cSrcweir // der Handler muss einen SvListEntry* zurueckgeben
301cdf0e10cSrcweir SvListEntry* Clone( SvListEntry* pEntry, sal_uLong& nCloneCount ) const;
SetCloneLink(const Link & rLink)302cdf0e10cSrcweir void SetCloneLink( const Link& rLink ) { aCloneLink=rLink; }
GetCloneLink() const303cdf0e10cSrcweir const Link& GetCloneLink() const { return aCloneLink; }
304cdf0e10cSrcweir virtual SvListEntry* CloneEntry( SvListEntry* ) const; // ruft den Clone-Link
305cdf0e10cSrcweir virtual SvListEntry* CreateEntry() const; // zum 'new'en von Entries
306cdf0e10cSrcweir
GetRefCount() const307cdf0e10cSrcweir sal_uInt16 GetRefCount() const { return nRefCount; }
SetRefCount(sal_uInt16 nRef)308cdf0e10cSrcweir void SetRefCount( sal_uInt16 nRef ) { nRefCount = nRef; }
309cdf0e10cSrcweir
SetSortMode(SvSortMode eMode)310cdf0e10cSrcweir void SetSortMode( SvSortMode eMode ) { eSortMode = eMode; }
GetSortMode() const311cdf0e10cSrcweir SvSortMode GetSortMode() const { return eSortMode; }
312cdf0e10cSrcweir virtual StringCompare Compare( SvListEntry*, SvListEntry* ) const;
SetCompareHdl(const Link & rLink)313cdf0e10cSrcweir void SetCompareHdl( const Link& rLink ) { aCompareLink = rLink; }
GetCompareHdl() const314cdf0e10cSrcweir const Link& GetCompareHdl() const { return aCompareLink; }
315cdf0e10cSrcweir void Resort();
316cdf0e10cSrcweir
317cdf0e10cSrcweir void CheckIntegrity() const;
318cdf0e10cSrcweir };
319cdf0e10cSrcweir
320cdf0e10cSrcweir class SVT_DLLPUBLIC SvListView
321cdf0e10cSrcweir {
322cdf0e10cSrcweir friend class SvTreeList;
323cdf0e10cSrcweir
324cdf0e10cSrcweir sal_uLong nVisibleCount;
325cdf0e10cSrcweir sal_uLong nSelectionCount;
326cdf0e10cSrcweir sal_Bool bVisPositionsValid;
327cdf0e10cSrcweir
328cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE
329cdf0e10cSrcweir SVT_DLLPRIVATE void InitTable();
330cdf0e10cSrcweir SVT_DLLPRIVATE void ClearTable();
331cdf0e10cSrcweir SVT_DLLPRIVATE void RemoveViewData( SvListEntry* pParent );
332cdf0e10cSrcweir //#endif
333cdf0e10cSrcweir
334cdf0e10cSrcweir protected:
335cdf0e10cSrcweir Table aDataTable; // Mapping SvListEntry -> ViewData
336cdf0e10cSrcweir SvTreeList* pModel;
337cdf0e10cSrcweir
338cdf0e10cSrcweir void ActionMoving( SvListEntry* pEntry,SvListEntry* pTargetPrnt,sal_uLong nChildPos);
339cdf0e10cSrcweir void ActionMoved( SvListEntry* pEntry,SvListEntry* pTargetPrnt,sal_uLong nChildPos);
340cdf0e10cSrcweir void ActionInserted( SvListEntry* pEntry );
341cdf0e10cSrcweir void ActionInsertedTree( SvListEntry* pEntry );
342cdf0e10cSrcweir void ActionRemoving( SvListEntry* pEntry );
343cdf0e10cSrcweir void ActionRemoved( SvListEntry* pEntry );
344cdf0e10cSrcweir void ActionClear();
345cdf0e10cSrcweir
346cdf0e10cSrcweir public:
347cdf0e10cSrcweir
348cdf0e10cSrcweir SvListView(); // !!! setzt das Model auf 0
349cdf0e10cSrcweir SvListView( SvTreeList* pModel );
350cdf0e10cSrcweir virtual ~SvListView();
351cdf0e10cSrcweir void Clear();
GetModel() const352cdf0e10cSrcweir SvTreeList* GetModel() const { return pModel; }
353cdf0e10cSrcweir virtual void SetModel( SvTreeList* );
354cdf0e10cSrcweir virtual void ModelNotification( sal_uInt16 nActionId, SvListEntry* pEntry1,
355cdf0e10cSrcweir SvListEntry* pEntry2, sal_uLong nPos );
356cdf0e10cSrcweir
GetVisibleCount() const357cdf0e10cSrcweir sal_uLong GetVisibleCount() const { return pModel->GetVisibleCount( (SvListView*)this );}
FirstVisible() const358cdf0e10cSrcweir SvListEntry* FirstVisible() const { return pModel->FirstVisible(); }
NextVisible(SvListEntry * pEntry,sal_uInt16 * pDepth=0) const359cdf0e10cSrcweir SvListEntry* NextVisible( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const {return pModel->NextVisible(this,pEntry,pDepth); }
PrevVisible(SvListEntry * pEntry,sal_uInt16 * pDepth=0) const360cdf0e10cSrcweir SvListEntry* PrevVisible( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const {return pModel->PrevVisible(this,pEntry,pDepth); }
LastVisible(sal_uInt16 * pDepth=0) const361cdf0e10cSrcweir SvListEntry* LastVisible( sal_uInt16* pDepth=0 ) const { return pModel->LastVisible(this,pDepth);}
NextVisible(SvListEntry * pEntry,sal_uInt16 & rDelta) const362cdf0e10cSrcweir SvListEntry* NextVisible( SvListEntry* pEntry, sal_uInt16& rDelta ) const { return pModel->NextVisible(this,pEntry,rDelta); }
PrevVisible(SvListEntry * pEntry,sal_uInt16 & rDelta) const363cdf0e10cSrcweir SvListEntry* PrevVisible( SvListEntry* pEntry, sal_uInt16& rDelta ) const { return pModel->PrevVisible(this,pEntry,rDelta); }
364cdf0e10cSrcweir
GetSelectionCount() const365cdf0e10cSrcweir sal_uLong GetSelectionCount() const { return nSelectionCount; }
FirstSelected() const366cdf0e10cSrcweir SvListEntry* FirstSelected() const { return pModel->FirstSelected(this);}
NextSelected(SvListEntry * pEntry) const367cdf0e10cSrcweir SvListEntry* NextSelected( SvListEntry* pEntry ) const { return pModel->NextSelected(this,pEntry); }
PrevSelected(SvListEntry * pEntry) const368cdf0e10cSrcweir SvListEntry* PrevSelected( SvListEntry* pEntry ) const { return pModel->PrevSelected(this,pEntry); }
LastSelected() const369cdf0e10cSrcweir SvListEntry* LastSelected() const { return pModel->LastSelected(this); }
GetEntryAtVisPos(sal_uLong nVisPos) const370cdf0e10cSrcweir SvListEntry* GetEntryAtVisPos( sal_uLong nVisPos ) const { return pModel->GetEntryAtVisPos((SvListView*)this,nVisPos); }
GetVisiblePos(SvListEntry * pEntry) const371cdf0e10cSrcweir sal_uLong GetVisiblePos( SvListEntry* pEntry ) const { return pModel->GetVisiblePos((SvListView*)this,pEntry); }
372cdf0e10cSrcweir
GetVisibleChildCount(SvListEntry * pParent) const373cdf0e10cSrcweir sal_uLong GetVisibleChildCount(SvListEntry* pParent ) const { return pModel->GetVisibleChildCount((SvListView*)this,pParent); }
GetChildSelectionCount(SvListEntry * pParent) const374cdf0e10cSrcweir sal_uLong GetChildSelectionCount( SvListEntry* pParent ) const { return pModel->GetChildSelectionCount((SvListView*)this,pParent); }
Expand(SvListEntry * pParent)375cdf0e10cSrcweir void Expand( SvListEntry* pParent ) { pModel->Expand((SvListView*)this,pParent); }
Collapse(SvListEntry * pParent)376cdf0e10cSrcweir void Collapse( SvListEntry* pParent ) { pModel->Collapse((SvListView*)this,pParent); }
Select(SvListEntry * pEntry,sal_Bool bSelect=sal_True)377cdf0e10cSrcweir sal_Bool Select( SvListEntry* pEntry, sal_Bool bSelect=sal_True ) { return pModel->Select((SvListView*)this,pEntry,bSelect); }
SelectChilds(SvListEntry * pParent,sal_Bool bSelect)378cdf0e10cSrcweir sal_uLong SelectChilds( SvListEntry* pParent, sal_Bool bSelect ) { return pModel->SelectChilds((SvListView*)this,pParent, bSelect); }
379cdf0e10cSrcweir // ruft nicht Select-Hdl
SelectAll(sal_Bool bSelect,sal_Bool)380cdf0e10cSrcweir virtual void SelectAll( sal_Bool bSelect, sal_Bool ) { pModel->SelectAll((SvListView*)this, bSelect); }
IsEntryVisible(SvListEntry * pEntry) const381cdf0e10cSrcweir sal_Bool IsEntryVisible( SvListEntry* pEntry ) const { return pModel->IsEntryVisible((SvListView*)this,pEntry); }
382cdf0e10cSrcweir sal_Bool IsExpanded( SvListEntry* pEntry ) const;
383cdf0e10cSrcweir sal_Bool IsSelected( SvListEntry* pEntry ) const;
384cdf0e10cSrcweir sal_Bool HasEntryFocus( SvListEntry* pEntry ) const;
385cdf0e10cSrcweir void SetEntryFocus( SvListEntry* pEntry, sal_Bool bFocus ) const;
386cdf0e10cSrcweir SvViewData* GetViewData( SvListEntry* pEntry ) const;
HasViewData() const387cdf0e10cSrcweir sal_Bool HasViewData() const { return aDataTable.Count() > 1;} // eine ROOT gibts immer
388cdf0e10cSrcweir virtual SvViewData* CreateViewData( SvListEntry* pEntry );
389cdf0e10cSrcweir virtual void InitViewData( SvViewData*, SvListEntry* pEntry );
390cdf0e10cSrcweir
391cdf0e10cSrcweir virtual void ModelHasCleared();
392cdf0e10cSrcweir virtual void ModelHasInserted( SvListEntry* pEntry );
393cdf0e10cSrcweir virtual void ModelHasInsertedTree( SvListEntry* pEntry );
394cdf0e10cSrcweir virtual void ModelIsMoving( SvListEntry* pSource, SvListEntry* pTargetParent,
395cdf0e10cSrcweir sal_uLong nPos );
396cdf0e10cSrcweir virtual void ModelHasMoved( SvListEntry* pSource );
397cdf0e10cSrcweir virtual void ModelIsRemoving( SvListEntry* pEntry );
398cdf0e10cSrcweir virtual void ModelHasRemoved( SvListEntry* pEntry );
399cdf0e10cSrcweir virtual void ModelHasEntryInvalidated( SvListEntry* pEntry );
400cdf0e10cSrcweir };
401cdf0e10cSrcweir
IsExpanded(SvListEntry * pEntry) const402cdf0e10cSrcweir inline sal_Bool SvListView::IsExpanded( SvListEntry* pEntry ) const
403cdf0e10cSrcweir {
404cdf0e10cSrcweir DBG_ASSERT(pEntry,"IsExpanded:No Entry");
405cdf0e10cSrcweir SvViewData* pData = (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
406cdf0e10cSrcweir DBG_ASSERT(pData,"Entry not in Table");
407*cf948285Shanya return pData && pData->IsExpanded();
408cdf0e10cSrcweir }
IsSelected(SvListEntry * pEntry) const409cdf0e10cSrcweir inline sal_Bool SvListView::IsSelected( SvListEntry* pEntry ) const
410cdf0e10cSrcweir {
411cdf0e10cSrcweir DBG_ASSERT(pEntry,"IsExpanded:No Entry");
412cdf0e10cSrcweir SvViewData* pData = (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
413cdf0e10cSrcweir DBG_ASSERT(pData,"Entry not in Table");
414d84f099fSTsutomu Uchino return pData && pData->IsSelected();
415cdf0e10cSrcweir }
HasEntryFocus(SvListEntry * pEntry) const416cdf0e10cSrcweir inline sal_Bool SvListView::HasEntryFocus( SvListEntry* pEntry ) const
417cdf0e10cSrcweir {
418cdf0e10cSrcweir DBG_ASSERT(pEntry,"IsExpanded:No Entry");
419cdf0e10cSrcweir SvViewData* pData = (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
420cdf0e10cSrcweir DBG_ASSERT(pData,"Entry not in Table");
421d84f099fSTsutomu Uchino return pData && pData->HasFocus();
422cdf0e10cSrcweir }
SetEntryFocus(SvListEntry * pEntry,sal_Bool bFocus) const423cdf0e10cSrcweir inline void SvListView::SetEntryFocus( SvListEntry* pEntry, sal_Bool bFocus ) const
424cdf0e10cSrcweir {
425cdf0e10cSrcweir DBG_ASSERT(pEntry,"SetEntryFocus:No Entry");
426cdf0e10cSrcweir SvViewData* pData = (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
427cdf0e10cSrcweir DBG_ASSERT(pData,"Entry not in Table");
428cdf0e10cSrcweir pData->SetFocus(bFocus);
429cdf0e10cSrcweir }
430cdf0e10cSrcweir
GetViewData(SvListEntry * pEntry) const431cdf0e10cSrcweir inline SvViewData* SvListView::GetViewData( SvListEntry* pEntry ) const
432cdf0e10cSrcweir {
433cdf0e10cSrcweir #ifndef DBG_UTIL
434cdf0e10cSrcweir return (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
435cdf0e10cSrcweir #else
436cdf0e10cSrcweir SvViewData* pResult = (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
437cdf0e10cSrcweir DBG_ASSERT(pResult,"Entry not in model or wrong view");
438cdf0e10cSrcweir return pResult;
439cdf0e10cSrcweir #endif
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
HasChilds(SvListEntry * pEntry) const442cdf0e10cSrcweir inline sal_Bool SvTreeList::HasChilds( SvListEntry* pEntry ) const
443cdf0e10cSrcweir {
444cdf0e10cSrcweir if ( !pEntry )
445cdf0e10cSrcweir pEntry = pRootItem;
446cdf0e10cSrcweir return (sal_Bool)(pEntry->pChilds != 0);
447cdf0e10cSrcweir }
448cdf0e10cSrcweir
GetEntry(SvListEntry * pParent,sal_uLong nPos) const449cdf0e10cSrcweir inline SvListEntry* SvTreeList::GetEntry( SvListEntry* pParent, sal_uLong nPos ) const
450cdf0e10cSrcweir { if ( !pParent )
451cdf0e10cSrcweir pParent = pRootItem;
452cdf0e10cSrcweir SvListEntry* pRet = 0;
453cdf0e10cSrcweir if ( pParent->pChilds )
454cdf0e10cSrcweir pRet = (SvListEntry*)(pParent->pChilds->GetObject(nPos));
455cdf0e10cSrcweir return pRet;
456cdf0e10cSrcweir }
457cdf0e10cSrcweir
GetEntry(sal_uLong nRootPos) const458cdf0e10cSrcweir inline SvListEntry* SvTreeList::GetEntry( sal_uLong nRootPos ) const
459cdf0e10cSrcweir {
460cdf0e10cSrcweir SvListEntry* pRet;
461cdf0e10cSrcweir if ( nEntryCount )
462cdf0e10cSrcweir pRet = (SvListEntry*)(pRootItem->pChilds->GetObject(nRootPos));
463cdf0e10cSrcweir else
464cdf0e10cSrcweir pRet = 0;
465cdf0e10cSrcweir return pRet;
466cdf0e10cSrcweir }
467cdf0e10cSrcweir
GetChildList(SvListEntry * pParent) const468cdf0e10cSrcweir inline SvTreeEntryList* SvTreeList::GetChildList( SvListEntry* pParent ) const
469cdf0e10cSrcweir {
470cdf0e10cSrcweir if ( !pParent )
471cdf0e10cSrcweir pParent = pRootItem;
472cdf0e10cSrcweir return pParent->pChilds;
473cdf0e10cSrcweir }
474cdf0e10cSrcweir
GetParent(SvListEntry * pEntry) const475cdf0e10cSrcweir inline SvListEntry* SvTreeList::GetParent( SvListEntry* pEntry ) const
476cdf0e10cSrcweir {
477cdf0e10cSrcweir SvListEntry* pParent = pEntry->pParent;
478cdf0e10cSrcweir if ( pParent==pRootItem )
479cdf0e10cSrcweir pParent = 0;
480cdf0e10cSrcweir return pParent;
481cdf0e10cSrcweir }
482cdf0e10cSrcweir
483cdf0e10cSrcweir #define DECLARE_SVTREELIST( ClassName, Type ) \
484cdf0e10cSrcweir class ClassName : public SvTreeList \
485cdf0e10cSrcweir { \
486cdf0e10cSrcweir public: \
487cdf0e10cSrcweir Type First() const \
488cdf0e10cSrcweir { return (Type)SvTreeList::First(); } \
489cdf0e10cSrcweir Type Next( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const \
490cdf0e10cSrcweir { return (Type)SvTreeList::Next(pEntry,pDepth); } \
491cdf0e10cSrcweir Type Prev( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const \
492cdf0e10cSrcweir { return (Type)SvTreeList::Prev(pEntry,pDepth); } \
493cdf0e10cSrcweir Type Last( sal_uInt16* pDepth=0 ) const \
494cdf0e10cSrcweir { return (Type)SvTreeList::Last(pDepth); } \
495cdf0e10cSrcweir \
496cdf0e10cSrcweir Type Clone( SvListEntry* pEntry, sal_uLong& nCloneCount ) const \
497cdf0e10cSrcweir { return (Type)SvTreeList::Clone(pEntry,nCloneCount); } \
498cdf0e10cSrcweir Type GetEntry( SvListEntry* pParent, sal_uLong nPos ) const \
499cdf0e10cSrcweir { return (Type)SvTreeList::GetEntry(pParent,nPos); } \
500cdf0e10cSrcweir Type GetEntry( sal_uLong nRootPos ) const \
501cdf0e10cSrcweir { return (Type)SvTreeList::GetEntry(nRootPos); } \
502cdf0e10cSrcweir Type GetParent( SvListEntry* pEntry ) const \
503cdf0e10cSrcweir { return (Type)SvTreeList::GetParent(pEntry); } \
504cdf0e10cSrcweir using SvTreeList::FirstChild; \
505cdf0e10cSrcweir Type FirstChild( Type pParent ) const \
506cdf0e10cSrcweir { return (Type)SvTreeList::FirstChild(pParent); } \
507cdf0e10cSrcweir using SvTreeList::NextSibling; \
508cdf0e10cSrcweir Type NextSibling( Type pEntry ) const \
509cdf0e10cSrcweir { return (Type)SvTreeList::NextSibling(pEntry); } \
510cdf0e10cSrcweir using SvTreeList::PrevSibling; \
511cdf0e10cSrcweir Type PrevSibling( Type pEntry ) const \
512cdf0e10cSrcweir { return (Type)SvTreeList::PrevSibling(pEntry); } \
513cdf0e10cSrcweir using SvTreeList::LastSibling; \
514cdf0e10cSrcweir Type LastSibling( Type pEntry ) const \
515cdf0e10cSrcweir { return (Type)SvTreeList::LastSibling(pEntry); } \
516cdf0e10cSrcweir Type GetEntryAtAbsPos( sal_uLong nAbsPos ) const \
517cdf0e10cSrcweir { return (Type)SvTreeList::GetEntryAtAbsPos( nAbsPos); } \
518cdf0e10cSrcweir };
519cdf0e10cSrcweir
520cdf0e10cSrcweir #endif
521