xref: /AOO41X/main/svtools/source/uno/treecontrolpeer.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svtools.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #define _SVTREEBX_CXX
32*cdf0e10cSrcweir #include <tools/debug.hxx>
33*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/view/SelectionType.hpp>
36*cdf0e10cSrcweir #include <toolkit/helper/property.hxx>
37*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <com/sun/star/awt/tree/XMutableTreeNode.hpp>
40*cdf0e10cSrcweir #include <treecontrolpeer.hxx>
41*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <rtl/ref.hxx>
44*cdf0e10cSrcweir #include <vcl/graph.hxx>
45*cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include <map>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir using ::rtl::OUString;
50*cdf0e10cSrcweir using namespace ::com::sun::star;
51*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
52*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
53*cdf0e10cSrcweir using namespace ::com::sun::star::awt::tree;
54*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
55*cdf0e10cSrcweir using namespace ::com::sun::star::view;
56*cdf0e10cSrcweir using namespace ::com::sun::star::container;
57*cdf0e10cSrcweir using namespace ::com::sun::star::util;
58*cdf0e10cSrcweir using namespace ::com::sun::star::graphic;
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir #define O(x) OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir struct LockGuard
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir public:
65*cdf0e10cSrcweir 	LockGuard( sal_Int32& rLock )
66*cdf0e10cSrcweir 	: mrLock( rLock )
67*cdf0e10cSrcweir 	{
68*cdf0e10cSrcweir 		rLock++;
69*cdf0e10cSrcweir 	}
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	~LockGuard()
72*cdf0e10cSrcweir 	{
73*cdf0e10cSrcweir 		mrLock--;
74*cdf0e10cSrcweir 	}
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	sal_Int32& mrLock;
77*cdf0e10cSrcweir };
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir // --------------------------------------------------------------------
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir class ImplGraphicItem : public SvLBoxBmp
82*cdf0e10cSrcweir {
83*cdf0e10cSrcweir public:
84*cdf0e10cSrcweir 	ImplGraphicItem( SvLBoxEntry* pEntry, sal_uInt16 nFlags, Image& aImage ) : SvLBoxBmp( pEntry, nFlags, aImage ) {}
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	OUString msGraphicURL;
87*cdf0e10cSrcweir };
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir // --------------------------------------------------------------------
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir class ImplContextGraphicItem : public SvLBoxContextBmp
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir public:
94*cdf0e10cSrcweir 	ImplContextGraphicItem( SvLBoxEntry* pEntry,sal_uInt16 nFlags,Image& rI1,Image& rI2, sal_uInt16 nEntryFlagsBmp1)
95*cdf0e10cSrcweir 		: SvLBoxContextBmp( pEntry, nFlags, rI1, rI2, nEntryFlagsBmp1 ) {}
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 	OUString msExpandedGraphicURL;
98*cdf0e10cSrcweir 	OUString msCollapsedGraphicURL;
99*cdf0e10cSrcweir };
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir // --------------------------------------------------------------------
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir class UnoTreeListBoxImpl : public SvTreeListBox
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir public:
106*cdf0e10cSrcweir 	UnoTreeListBoxImpl( TreeControlPeer* pPeer, Window* pParent, WinBits nWinStyle );
107*cdf0e10cSrcweir 	~UnoTreeListBoxImpl();
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	sal_uInt32 insert( SvLBoxEntry* pEntry,SvLBoxEntry* pParent,sal_uLong nPos=LIST_APPEND );
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	virtual void	RequestingChilds( SvLBoxEntry* pParent );
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	virtual sal_Bool	EditingEntry( SvLBoxEntry* pEntry, Selection& );
114*cdf0e10cSrcweir 	virtual sal_Bool	EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 	DECL_LINK( OnSelectionChangeHdl, UnoTreeListBoxImpl* );
117*cdf0e10cSrcweir 	DECL_LINK( OnExpandingHdl, UnoTreeListBoxImpl* );
118*cdf0e10cSrcweir 	DECL_LINK( OnExpandedHdl, UnoTreeListBoxImpl* );
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir private:
121*cdf0e10cSrcweir 	rtl::Reference< TreeControlPeer > mxPeer;
122*cdf0e10cSrcweir };
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir // --------------------------------------------------------------------
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir class SVT_DLLPUBLIC UnoTreeListItem : public SvLBoxItem
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir public:
129*cdf0e10cSrcweir 					UnoTreeListItem( SvLBoxEntry* );
130*cdf0e10cSrcweir 					UnoTreeListItem();
131*cdf0e10cSrcweir 	virtual			~UnoTreeListItem();
132*cdf0e10cSrcweir 	virtual sal_uInt16	IsA();
133*cdf0e10cSrcweir 	void			InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* );
134*cdf0e10cSrcweir 	OUString		GetText() const;
135*cdf0e10cSrcweir 	void 			SetText( const OUString& rText );
136*cdf0e10cSrcweir 	Image			GetImage() const;
137*cdf0e10cSrcweir 	void			SetImage( const Image& rImage );
138*cdf0e10cSrcweir 	OUString		GetGraphicURL() const;
139*cdf0e10cSrcweir 	void			SetGraphicURL( const OUString& rGraphicURL );
140*cdf0e10cSrcweir 	void			Paint( const Point&, SvLBox& rDev, sal_uInt16 nFlags,SvLBoxEntry* );
141*cdf0e10cSrcweir 	SvLBoxItem* 	Create() const;
142*cdf0e10cSrcweir 	void 			Clone( SvLBoxItem* pSource );
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir private:
145*cdf0e10cSrcweir 	OUString		maText;
146*cdf0e10cSrcweir 	OUString		maGraphicURL;
147*cdf0e10cSrcweir 	Image			maImage;
148*cdf0e10cSrcweir };
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir // --------------------------------------------------------------------
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir class UnoTreeListEntry : public SvLBoxEntry
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir public:
155*cdf0e10cSrcweir 	UnoTreeListEntry( const Reference< XTreeNode >& xNode, TreeControlPeer* pPeer );
156*cdf0e10cSrcweir 	virtual ~UnoTreeListEntry();
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 	Reference< XTreeNode > mxNode;
159*cdf0e10cSrcweir 	TreeControlPeer* mpPeer;
160*cdf0e10cSrcweir };
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir // --------------------------------------------------------------------
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir class TreeNodeMap : public std::map< Reference< XTreeNode >, UnoTreeListEntry* >
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir };
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir // --------------------------------------------------------------------
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir TreeControlPeer::TreeControlPeer()
171*cdf0e10cSrcweir : maSelectionListeners( *this )
172*cdf0e10cSrcweir , maTreeExpansionListeners( *this )
173*cdf0e10cSrcweir , maTreeEditListeners( *this )
174*cdf0e10cSrcweir , mpTreeImpl( 0 )
175*cdf0e10cSrcweir , mnEditLock( 0 )
176*cdf0e10cSrcweir , mpTreeNodeMap( 0 )
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir // --------------------------------------------------------------------
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir TreeControlPeer::~TreeControlPeer()
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir 	if( mpTreeImpl )
185*cdf0e10cSrcweir 		mpTreeImpl->Clear();
186*cdf0e10cSrcweir 	delete mpTreeNodeMap;
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir // --------------------------------------------------------------------
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir void TreeControlPeer::addEntry( UnoTreeListEntry* pEntry )
192*cdf0e10cSrcweir {
193*cdf0e10cSrcweir 	if( pEntry && pEntry->mxNode.is() )
194*cdf0e10cSrcweir 	{
195*cdf0e10cSrcweir 		if( !mpTreeNodeMap )
196*cdf0e10cSrcweir 		{
197*cdf0e10cSrcweir 			mpTreeNodeMap = new TreeNodeMap();
198*cdf0e10cSrcweir 		}
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 		(*mpTreeNodeMap)[ pEntry->mxNode ] = pEntry;
201*cdf0e10cSrcweir 	}
202*cdf0e10cSrcweir }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir // --------------------------------------------------------------------
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir void TreeControlPeer::removeEntry( UnoTreeListEntry* pEntry )
207*cdf0e10cSrcweir {
208*cdf0e10cSrcweir 	if( mpTreeNodeMap && pEntry && pEntry->mxNode.is() )
209*cdf0e10cSrcweir 	{
210*cdf0e10cSrcweir 		TreeNodeMap::iterator aIter( mpTreeNodeMap->find( pEntry->mxNode ) );
211*cdf0e10cSrcweir 		if( aIter != mpTreeNodeMap->end() )
212*cdf0e10cSrcweir         {
213*cdf0e10cSrcweir 			mpTreeNodeMap->erase( aIter );
214*cdf0e10cSrcweir         }
215*cdf0e10cSrcweir 	}
216*cdf0e10cSrcweir }
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir // --------------------------------------------------------------------
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir UnoTreeListEntry* TreeControlPeer::getEntry( const Reference< XTreeNode >& xNode, bool bThrow /* = true */ ) throw( IllegalArgumentException )
221*cdf0e10cSrcweir {
222*cdf0e10cSrcweir 	if( mpTreeNodeMap )
223*cdf0e10cSrcweir 	{
224*cdf0e10cSrcweir 		TreeNodeMap::iterator aIter( mpTreeNodeMap->find( xNode ) );
225*cdf0e10cSrcweir 		if( aIter != mpTreeNodeMap->end() )
226*cdf0e10cSrcweir 			return (*aIter).second;
227*cdf0e10cSrcweir 	}
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 	if( bThrow )
230*cdf0e10cSrcweir 		throw IllegalArgumentException();
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 	return 0;
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir // --------------------------------------------------------------------
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir Window* TreeControlPeer::createVclControl( Window* pParent, sal_Int64 nWinStyle )
238*cdf0e10cSrcweir {
239*cdf0e10cSrcweir 	mpTreeImpl = new UnoTreeListBoxImpl( this, pParent, nWinStyle );
240*cdf0e10cSrcweir 	return mpTreeImpl;
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir // --------------------------------------------------------------------
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir /** called from the UnoTreeListBoxImpl when it gets deleted */
246*cdf0e10cSrcweir void TreeControlPeer::disposeControl()
247*cdf0e10cSrcweir {
248*cdf0e10cSrcweir 	delete mpTreeNodeMap;
249*cdf0e10cSrcweir 	mpTreeNodeMap = 0;
250*cdf0e10cSrcweir 	mpTreeImpl = 0;
251*cdf0e10cSrcweir }
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir // --------------------------------------------------------------------
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir void TreeControlPeer::SetWindow( Window* pWindow )
256*cdf0e10cSrcweir {
257*cdf0e10cSrcweir 	VCLXWindow::SetWindow( pWindow );
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir // --------------------------------------------------------------------
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir UnoTreeListEntry* TreeControlPeer::createEntry( const Reference< XTreeNode >& xNode, UnoTreeListEntry* pParent, sal_uLong nPos /* = LIST_APPEND */ )
263*cdf0e10cSrcweir {
264*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = 0;
265*cdf0e10cSrcweir 	if( mpTreeImpl )
266*cdf0e10cSrcweir 	{
267*cdf0e10cSrcweir 		Image aImage;
268*cdf0e10cSrcweir 		pEntry = new UnoTreeListEntry( xNode, this );
269*cdf0e10cSrcweir 		ImplContextGraphicItem* pContextBmp= new ImplContextGraphicItem( pEntry,0, aImage, aImage, SVLISTENTRYFLAG_EXPANDED );
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 		pEntry->AddItem( pContextBmp );
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir 		UnoTreeListItem * pUnoItem = new UnoTreeListItem( pEntry );
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir 		if( xNode->getNodeGraphicURL().getLength() )
276*cdf0e10cSrcweir 		{
277*cdf0e10cSrcweir 			pUnoItem->SetGraphicURL( xNode->getNodeGraphicURL() );
278*cdf0e10cSrcweir 			Image aNodeImage;
279*cdf0e10cSrcweir 			loadImage( xNode->getNodeGraphicURL(), aNodeImage );
280*cdf0e10cSrcweir 			pUnoItem->SetImage( aNodeImage );
281*cdf0e10cSrcweir 			mpTreeImpl->AdjustEntryHeight( aNodeImage );
282*cdf0e10cSrcweir 		}
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 		pEntry->AddItem( pUnoItem );
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 		mpTreeImpl->insert( pEntry, pParent, nPos );
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir         if( msDefaultExpandedGraphicURL.getLength() )
289*cdf0e10cSrcweir 			mpTreeImpl->SetExpandedEntryBmp( pEntry, maDefaultExpandedImage );
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 		if( msDefaultCollapsedGraphicURL.getLength() )
292*cdf0e10cSrcweir 			mpTreeImpl->SetCollapsedEntryBmp( pEntry, maDefaultCollapsedImage );
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 		updateEntry( pEntry );
295*cdf0e10cSrcweir 	}
296*cdf0e10cSrcweir 	return pEntry;
297*cdf0e10cSrcweir }
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir // --------------------------------------------------------------------
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir bool TreeControlPeer::updateEntry( UnoTreeListEntry* pEntry )
302*cdf0e10cSrcweir {
303*cdf0e10cSrcweir 	bool bChanged = false;
304*cdf0e10cSrcweir 	if( pEntry && pEntry->mxNode.is() && mpTreeImpl )
305*cdf0e10cSrcweir 	{
306*cdf0e10cSrcweir 		const OUString aValue( getEntryString( pEntry->mxNode->getDisplayValue() ) );
307*cdf0e10cSrcweir 		UnoTreeListItem* pUnoItem = dynamic_cast< UnoTreeListItem* >( pEntry->GetItem( 1 ) );
308*cdf0e10cSrcweir 		if( pUnoItem )
309*cdf0e10cSrcweir 		{
310*cdf0e10cSrcweir 			if( aValue != pUnoItem->GetText() )
311*cdf0e10cSrcweir 			{
312*cdf0e10cSrcweir 				pUnoItem->SetText( aValue );
313*cdf0e10cSrcweir 				bChanged = true;
314*cdf0e10cSrcweir 			}
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 			if( pUnoItem->GetGraphicURL() != pEntry->mxNode->getNodeGraphicURL() )
317*cdf0e10cSrcweir 			{
318*cdf0e10cSrcweir 				Image aImage;
319*cdf0e10cSrcweir 				if( loadImage( pEntry->mxNode->getNodeGraphicURL(), aImage ) )
320*cdf0e10cSrcweir 				{
321*cdf0e10cSrcweir 					pUnoItem->SetGraphicURL( pEntry->mxNode->getNodeGraphicURL() );
322*cdf0e10cSrcweir 					pUnoItem->SetImage( aImage );
323*cdf0e10cSrcweir 					mpTreeImpl->AdjustEntryHeight( aImage );
324*cdf0e10cSrcweir 					bChanged = true;
325*cdf0e10cSrcweir 				}
326*cdf0e10cSrcweir 			}
327*cdf0e10cSrcweir 		}
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 		if( (pEntry->mxNode->hasChildrenOnDemand() == sal_True) != (pEntry->HasChildsOnDemand() == sal_True) )
330*cdf0e10cSrcweir 		{
331*cdf0e10cSrcweir 			pEntry->EnableChildsOnDemand( pEntry->mxNode->hasChildrenOnDemand() ? sal_True : sal_False );
332*cdf0e10cSrcweir 			bChanged = true;
333*cdf0e10cSrcweir 		}
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 		ImplContextGraphicItem* pContextGraphicItem = dynamic_cast< ImplContextGraphicItem* >( pEntry->GetItem( 0 ) );
336*cdf0e10cSrcweir 		if( pContextGraphicItem )
337*cdf0e10cSrcweir 		{
338*cdf0e10cSrcweir 			if( pContextGraphicItem->msExpandedGraphicURL != pEntry->mxNode->getExpandedGraphicURL() )
339*cdf0e10cSrcweir 			{
340*cdf0e10cSrcweir 				Image aImage;
341*cdf0e10cSrcweir 				if(	loadImage( pEntry->mxNode->getExpandedGraphicURL(), aImage ) )
342*cdf0e10cSrcweir 				{
343*cdf0e10cSrcweir 					pContextGraphicItem->msExpandedGraphicURL = pEntry->mxNode->getExpandedGraphicURL();
344*cdf0e10cSrcweir 					mpTreeImpl->SetExpandedEntryBmp( pEntry, aImage );
345*cdf0e10cSrcweir 					bChanged = true;
346*cdf0e10cSrcweir 				}
347*cdf0e10cSrcweir 			}
348*cdf0e10cSrcweir 			if( pContextGraphicItem->msCollapsedGraphicURL != pEntry->mxNode->getCollapsedGraphicURL() )
349*cdf0e10cSrcweir 			{
350*cdf0e10cSrcweir 				Image aImage;
351*cdf0e10cSrcweir 				if(	loadImage( pEntry->mxNode->getCollapsedGraphicURL(), aImage ) )
352*cdf0e10cSrcweir 				{
353*cdf0e10cSrcweir 					pContextGraphicItem->msCollapsedGraphicURL = pEntry->mxNode->getCollapsedGraphicURL();
354*cdf0e10cSrcweir 					mpTreeImpl->SetCollapsedEntryBmp( pEntry, aImage );
355*cdf0e10cSrcweir 					bChanged = true;
356*cdf0e10cSrcweir 				}
357*cdf0e10cSrcweir 			}
358*cdf0e10cSrcweir 		}
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 		if( bChanged )
361*cdf0e10cSrcweir 			mpTreeImpl->GetModel()->InvalidateEntry( pEntry );
362*cdf0e10cSrcweir 	}
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 	return bChanged;
365*cdf0e10cSrcweir }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir // --------------------------------------------------------------------
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir void TreeControlPeer::onSelectionChanged()
370*cdf0e10cSrcweir {
371*cdf0e10cSrcweir 	Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
372*cdf0e10cSrcweir 	EventObject aEvent( xSource );
373*cdf0e10cSrcweir 	maSelectionListeners.selectionChanged( aEvent );
374*cdf0e10cSrcweir }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir // --------------------------------------------------------------------
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir void TreeControlPeer::onRequestChildNodes( const Reference< XTreeNode >& xNode )
379*cdf0e10cSrcweir {
380*cdf0e10cSrcweir 	try
381*cdf0e10cSrcweir 	{
382*cdf0e10cSrcweir 		Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
383*cdf0e10cSrcweir 		TreeExpansionEvent aEvent( xSource, xNode );
384*cdf0e10cSrcweir 		maTreeExpansionListeners.requestChildNodes( aEvent );
385*cdf0e10cSrcweir 	}
386*cdf0e10cSrcweir 	catch( Exception& )
387*cdf0e10cSrcweir 	{
388*cdf0e10cSrcweir 	}
389*cdf0e10cSrcweir }
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir // --------------------------------------------------------------------
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir bool TreeControlPeer::onExpanding( const Reference< XTreeNode >& xNode, bool bExpanding )
394*cdf0e10cSrcweir {
395*cdf0e10cSrcweir 	try
396*cdf0e10cSrcweir 	{
397*cdf0e10cSrcweir 		Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
398*cdf0e10cSrcweir 		TreeExpansionEvent aEvent( xSource, xNode );
399*cdf0e10cSrcweir 		if( bExpanding )
400*cdf0e10cSrcweir 		{
401*cdf0e10cSrcweir 			maTreeExpansionListeners.treeExpanding( aEvent );
402*cdf0e10cSrcweir 		}
403*cdf0e10cSrcweir 		else
404*cdf0e10cSrcweir 		{
405*cdf0e10cSrcweir 			maTreeExpansionListeners.treeCollapsing( aEvent );
406*cdf0e10cSrcweir 		}
407*cdf0e10cSrcweir 	}
408*cdf0e10cSrcweir 	catch( Exception& )
409*cdf0e10cSrcweir 	{
410*cdf0e10cSrcweir 		return false;
411*cdf0e10cSrcweir 	}
412*cdf0e10cSrcweir 	return true;
413*cdf0e10cSrcweir }
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir // --------------------------------------------------------------------
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir void TreeControlPeer::onExpanded( const Reference< XTreeNode >& xNode, bool bExpanding )
418*cdf0e10cSrcweir {
419*cdf0e10cSrcweir 	try
420*cdf0e10cSrcweir 	{
421*cdf0e10cSrcweir 		Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
422*cdf0e10cSrcweir 		TreeExpansionEvent aEvent( xSource, xNode );
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 		if( bExpanding )
425*cdf0e10cSrcweir 		{
426*cdf0e10cSrcweir 			maTreeExpansionListeners.treeExpanded( aEvent );
427*cdf0e10cSrcweir 		}
428*cdf0e10cSrcweir 		else
429*cdf0e10cSrcweir 		{
430*cdf0e10cSrcweir 			maTreeExpansionListeners.treeCollapsed( aEvent );
431*cdf0e10cSrcweir 		}
432*cdf0e10cSrcweir 	}
433*cdf0e10cSrcweir 	catch( Exception& )
434*cdf0e10cSrcweir 	{
435*cdf0e10cSrcweir 	}
436*cdf0e10cSrcweir }
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir // --------------------------------------------------------------------
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir void TreeControlPeer::fillTree( UnoTreeListBoxImpl& rTree, const Reference< XTreeDataModel >& xDataModel )
441*cdf0e10cSrcweir {
442*cdf0e10cSrcweir 	rTree.Clear();
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 	if( xDataModel.is() )
445*cdf0e10cSrcweir 	{
446*cdf0e10cSrcweir 		Reference< XTreeNode > xRootNode( xDataModel->getRoot() );
447*cdf0e10cSrcweir 		if( xRootNode.is() )
448*cdf0e10cSrcweir 		{
449*cdf0e10cSrcweir 			if( mbIsRootDisplayed )
450*cdf0e10cSrcweir 			{
451*cdf0e10cSrcweir 				addNode( rTree, xRootNode, 0 );
452*cdf0e10cSrcweir 			}
453*cdf0e10cSrcweir 			else
454*cdf0e10cSrcweir 			{
455*cdf0e10cSrcweir 				const sal_Int32 nChildCount = xRootNode->getChildCount();
456*cdf0e10cSrcweir 				for( sal_Int32 nChild = 0; nChild < nChildCount; nChild++ )
457*cdf0e10cSrcweir 					addNode( rTree, xRootNode->getChildAt( nChild ), 0 );
458*cdf0e10cSrcweir 			}
459*cdf0e10cSrcweir 		}
460*cdf0e10cSrcweir 	}
461*cdf0e10cSrcweir }
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir // --------------------------------------------------------------------
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir void TreeControlPeer::addNode( UnoTreeListBoxImpl& rTree, const Reference< XTreeNode >& xNode, UnoTreeListEntry* pParentEntry )
466*cdf0e10cSrcweir {
467*cdf0e10cSrcweir 	if( xNode.is() )
468*cdf0e10cSrcweir 	{
469*cdf0e10cSrcweir 		UnoTreeListEntry* pEntry = createEntry( xNode, pParentEntry, LIST_APPEND );
470*cdf0e10cSrcweir 		const sal_Int32 nChildCount = xNode->getChildCount();
471*cdf0e10cSrcweir 		for( sal_Int32 nChild = 0; nChild < nChildCount; nChild++ )
472*cdf0e10cSrcweir 			addNode( rTree, xNode->getChildAt( nChild ), pEntry );
473*cdf0e10cSrcweir 	}
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir // --------------------------------------------------------------------
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir UnoTreeListBoxImpl& TreeControlPeer::getTreeListBoxOrThrow() const throw (RuntimeException )
479*cdf0e10cSrcweir {
480*cdf0e10cSrcweir 	if( !mpTreeImpl )
481*cdf0e10cSrcweir 		throw DisposedException();
482*cdf0e10cSrcweir 	return *mpTreeImpl;
483*cdf0e10cSrcweir }
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir // --------------------------------------------------------------------
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir void TreeControlPeer::ChangeNodesSelection( const Any& rSelection, bool bSelect, bool bSetSelection ) throw( RuntimeException, IllegalArgumentException )
488*cdf0e10cSrcweir {
489*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir 	Reference< XTreeNode > xTempNode;
494*cdf0e10cSrcweir 	Sequence< XTreeNode > aTempSeq;
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir 	const Reference< XTreeNode > *pNodes = 0;
497*cdf0e10cSrcweir 	sal_Int32 nCount = 0;
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir 	if( rSelection.hasValue() )
500*cdf0e10cSrcweir 	{
501*cdf0e10cSrcweir 		switch( rSelection.getValueTypeClass() )
502*cdf0e10cSrcweir 		{
503*cdf0e10cSrcweir 		case TypeClass_INTERFACE:
504*cdf0e10cSrcweir 			{
505*cdf0e10cSrcweir 				rSelection >>= xTempNode;
506*cdf0e10cSrcweir 				if( xTempNode.is() )
507*cdf0e10cSrcweir 				{
508*cdf0e10cSrcweir 					nCount = 1;
509*cdf0e10cSrcweir 					pNodes = &xTempNode;
510*cdf0e10cSrcweir 				}
511*cdf0e10cSrcweir 				break;
512*cdf0e10cSrcweir 			}
513*cdf0e10cSrcweir 		case TypeClass_SEQUENCE:
514*cdf0e10cSrcweir 			{
515*cdf0e10cSrcweir 				if( rSelection.getValueType() == ::getCppuType( (const Sequence< Reference< XTreeNode > > *) 0 ) )
516*cdf0e10cSrcweir 				{
517*cdf0e10cSrcweir 					const Sequence< Reference< XTreeNode > >& rSeq( *(const Sequence< Reference< XTreeNode > > *)rSelection.getValue() );
518*cdf0e10cSrcweir 					nCount = rSeq.getLength();
519*cdf0e10cSrcweir 					if( nCount )
520*cdf0e10cSrcweir 						pNodes = rSeq.getConstArray();
521*cdf0e10cSrcweir 				}
522*cdf0e10cSrcweir 				break;
523*cdf0e10cSrcweir 			}
524*cdf0e10cSrcweir 		default:
525*cdf0e10cSrcweir 			break;
526*cdf0e10cSrcweir 		}
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir 		if( nCount == 0 )
529*cdf0e10cSrcweir 			throw IllegalArgumentException();
530*cdf0e10cSrcweir 	}
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir 	if( bSetSelection )
533*cdf0e10cSrcweir 		rTree.SelectAll( sal_False );
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir 	if( pNodes && nCount )
536*cdf0e10cSrcweir 	{
537*cdf0e10cSrcweir 		while( nCount-- )
538*cdf0e10cSrcweir 		{
539*cdf0e10cSrcweir 			UnoTreeListEntry* pEntry = getEntry( *pNodes++ );
540*cdf0e10cSrcweir 			rTree.Select( pEntry, bSelect ? sal_True : sal_False );
541*cdf0e10cSrcweir 		}
542*cdf0e10cSrcweir 	}
543*cdf0e10cSrcweir }
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir // -------------------------------------------------------------------
546*cdf0e10cSrcweir // ::com::sun::star::view::XSelectionSupplier
547*cdf0e10cSrcweir // -------------------------------------------------------------------
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir sal_Bool SAL_CALL TreeControlPeer::select( const Any& rSelection ) throw (IllegalArgumentException, RuntimeException)
550*cdf0e10cSrcweir {
551*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
552*cdf0e10cSrcweir 	ChangeNodesSelection( rSelection, true, true );
553*cdf0e10cSrcweir 	return sal_True;
554*cdf0e10cSrcweir }
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir // -------------------------------------------------------------------
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir Any SAL_CALL TreeControlPeer::getSelection() throw (RuntimeException)
559*cdf0e10cSrcweir {
560*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir 	Any aRet;
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir 	sal_uLong nSelectionCount = rTree.GetSelectionCount();
567*cdf0e10cSrcweir 	if( nSelectionCount == 1 )
568*cdf0e10cSrcweir 	{
569*cdf0e10cSrcweir 		UnoTreeListEntry* pEntry = dynamic_cast< UnoTreeListEntry* >( rTree.FirstSelected() );
570*cdf0e10cSrcweir 		if( pEntry && pEntry->mxNode.is() )
571*cdf0e10cSrcweir 			aRet <<= pEntry->mxNode;
572*cdf0e10cSrcweir 	}
573*cdf0e10cSrcweir 	else if( nSelectionCount > 1 )
574*cdf0e10cSrcweir 	{
575*cdf0e10cSrcweir 		Sequence< Reference< XTreeNode > > aSelection( nSelectionCount );
576*cdf0e10cSrcweir 		Reference< XTreeNode >* pNodes = aSelection.getArray();
577*cdf0e10cSrcweir 		UnoTreeListEntry* pEntry = dynamic_cast< UnoTreeListEntry* >( rTree.FirstSelected() );
578*cdf0e10cSrcweir 		while( pEntry && nSelectionCount )
579*cdf0e10cSrcweir 		{
580*cdf0e10cSrcweir 			*pNodes++ = pEntry->mxNode;
581*cdf0e10cSrcweir 			pEntry = dynamic_cast< UnoTreeListEntry* >( rTree.NextSelected( pEntry ) );
582*cdf0e10cSrcweir 			--nSelectionCount;
583*cdf0e10cSrcweir 		}
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir 		OSL_ASSERT( (pEntry == 0) && (nSelectionCount == 0) );
586*cdf0e10cSrcweir 		aRet <<= aSelection;
587*cdf0e10cSrcweir 	}
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir 	return aRet;
590*cdf0e10cSrcweir }
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir // -------------------------------------------------------------------
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::addSelectionChangeListener( const Reference< XSelectionChangeListener >& xListener ) throw (RuntimeException)
595*cdf0e10cSrcweir {
596*cdf0e10cSrcweir 	maSelectionListeners.addInterface( xListener );
597*cdf0e10cSrcweir }
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir // -------------------------------------------------------------------
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& xListener ) throw (RuntimeException)
602*cdf0e10cSrcweir {
603*cdf0e10cSrcweir 	maSelectionListeners.addInterface( xListener );
604*cdf0e10cSrcweir }
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir // -------------------------------------------------------------------
607*cdf0e10cSrcweir // ::com::sun::star::view::XMultiSelectionSupplier
608*cdf0e10cSrcweir // -------------------------------------------------------------------
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir sal_Bool SAL_CALL TreeControlPeer::addSelection( const Any& rSelection ) throw (IllegalArgumentException, RuntimeException)
611*cdf0e10cSrcweir {
612*cdf0e10cSrcweir 	ChangeNodesSelection( rSelection, true, false );
613*cdf0e10cSrcweir 	return sal_True;
614*cdf0e10cSrcweir }
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir // -------------------------------------------------------------------
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::removeSelection( const Any& rSelection ) throw (IllegalArgumentException, RuntimeException)
619*cdf0e10cSrcweir {
620*cdf0e10cSrcweir 	ChangeNodesSelection( rSelection, false, false );
621*cdf0e10cSrcweir }
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir // -------------------------------------------------------------------
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::clearSelection() throw (RuntimeException)
626*cdf0e10cSrcweir {
627*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
628*cdf0e10cSrcweir 	getTreeListBoxOrThrow().SelectAll( sal_False );
629*cdf0e10cSrcweir }
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir // -------------------------------------------------------------------
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir sal_Int32 SAL_CALL TreeControlPeer::getSelectionCount() throw (RuntimeException)
634*cdf0e10cSrcweir {
635*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
636*cdf0e10cSrcweir 	return getTreeListBoxOrThrow().GetSelectionCount();
637*cdf0e10cSrcweir }
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir // -------------------------------------------------------------------
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir class TreeSelectionEnumeration : public ::cppu::WeakImplHelper1< XEnumeration >
642*cdf0e10cSrcweir {
643*cdf0e10cSrcweir public:
644*cdf0e10cSrcweir 	TreeSelectionEnumeration( std::list< Any >& rSelection );
645*cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL hasMoreElements() throw (RuntimeException);
646*cdf0e10cSrcweir     virtual Any SAL_CALL nextElement() throw (NoSuchElementException, WrappedTargetException, RuntimeException);
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir 	std::list< Any > maSelection;
649*cdf0e10cSrcweir 	std::list< Any >::iterator maIter;
650*cdf0e10cSrcweir };
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir // -------------------------------------------------------------------
653*cdf0e10cSrcweir 
654*cdf0e10cSrcweir TreeSelectionEnumeration::TreeSelectionEnumeration( std::list< Any >& rSelection )
655*cdf0e10cSrcweir {
656*cdf0e10cSrcweir 	maSelection.swap( rSelection );
657*cdf0e10cSrcweir 	maIter = maSelection.begin();
658*cdf0e10cSrcweir }
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir // -------------------------------------------------------------------
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir ::sal_Bool SAL_CALL TreeSelectionEnumeration::hasMoreElements() throw (RuntimeException)
663*cdf0e10cSrcweir {
664*cdf0e10cSrcweir 	return maIter != maSelection.end();
665*cdf0e10cSrcweir }
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir // -------------------------------------------------------------------
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir Any SAL_CALL TreeSelectionEnumeration::nextElement() throw (NoSuchElementException, WrappedTargetException, RuntimeException)
670*cdf0e10cSrcweir {
671*cdf0e10cSrcweir 	if( maIter == maSelection.end() )
672*cdf0e10cSrcweir 		throw NoSuchElementException();
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir 	return (*maIter++);
675*cdf0e10cSrcweir }
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir // -------------------------------------------------------------------
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir Reference< XEnumeration > SAL_CALL TreeControlPeer::createSelectionEnumeration() throw (RuntimeException)
680*cdf0e10cSrcweir {
681*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir 	sal_uInt32 nSelectionCount = rTree.GetSelectionCount();
686*cdf0e10cSrcweir 	std::list< Any > aSelection( nSelectionCount );
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = dynamic_cast< UnoTreeListEntry* >( rTree.FirstSelected() );
689*cdf0e10cSrcweir 	while( pEntry && nSelectionCount )
690*cdf0e10cSrcweir 	{
691*cdf0e10cSrcweir 		aSelection.push_back( Any( pEntry->mxNode ) );
692*cdf0e10cSrcweir 		pEntry = dynamic_cast< UnoTreeListEntry* >( rTree.NextSelected( pEntry ) );
693*cdf0e10cSrcweir 		--nSelectionCount;
694*cdf0e10cSrcweir 	}
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir 	OSL_ASSERT( (pEntry == 0) && (nSelectionCount == 0) );
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir 	return Reference< XEnumeration >( new TreeSelectionEnumeration( aSelection ) );
699*cdf0e10cSrcweir }
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir // -------------------------------------------------------------------
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir Reference< XEnumeration > SAL_CALL TreeControlPeer::createReverseSelectionEnumeration() throw (RuntimeException)
704*cdf0e10cSrcweir {
705*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir 	sal_uInt32 nSelectionCount = rTree.GetSelectionCount();
710*cdf0e10cSrcweir 	std::list< Any > aSelection;
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = dynamic_cast< UnoTreeListEntry* >( rTree.FirstSelected() );
713*cdf0e10cSrcweir 	while( pEntry && nSelectionCount )
714*cdf0e10cSrcweir 	{
715*cdf0e10cSrcweir 		aSelection.push_front( Any( pEntry->mxNode ) );
716*cdf0e10cSrcweir 		pEntry = dynamic_cast< UnoTreeListEntry* >( rTree.NextSelected( pEntry ) );
717*cdf0e10cSrcweir 		--nSelectionCount;
718*cdf0e10cSrcweir 	}
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir 	OSL_ASSERT( (pEntry == 0) && (nSelectionCount == 0) );
721*cdf0e10cSrcweir 
722*cdf0e10cSrcweir 	return Reference< XEnumeration >( new TreeSelectionEnumeration( aSelection ) );
723*cdf0e10cSrcweir }
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir // --------------------------------------------------------------------
726*cdf0e10cSrcweir // ::com::sun::star::awt::XTreeControl
727*cdf0e10cSrcweir // --------------------------------------------------------------------
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir OUString SAL_CALL TreeControlPeer::getDefaultExpandedGraphicURL() throw (::com::sun::star::uno::RuntimeException)
730*cdf0e10cSrcweir {
731*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
732*cdf0e10cSrcweir 	return msDefaultExpandedGraphicURL;
733*cdf0e10cSrcweir }
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir // --------------------------------------------------------------------
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::setDefaultExpandedGraphicURL( const ::rtl::OUString& sDefaultExpandedGraphicURL ) throw (::com::sun::star::uno::RuntimeException)
738*cdf0e10cSrcweir {
739*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
740*cdf0e10cSrcweir 	if( msDefaultExpandedGraphicURL != sDefaultExpandedGraphicURL )
741*cdf0e10cSrcweir 	{
742*cdf0e10cSrcweir 		if( sDefaultExpandedGraphicURL.getLength() )
743*cdf0e10cSrcweir 			loadImage( sDefaultExpandedGraphicURL, maDefaultExpandedImage );
744*cdf0e10cSrcweir 		else
745*cdf0e10cSrcweir 			maDefaultExpandedImage = Image();
746*cdf0e10cSrcweir 
747*cdf0e10cSrcweir 		UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir 		SvLBoxEntry* pEntry = rTree.First();
750*cdf0e10cSrcweir 		while( pEntry )
751*cdf0e10cSrcweir 		{
752*cdf0e10cSrcweir 			ImplContextGraphicItem* pContextGraphicItem = dynamic_cast< ImplContextGraphicItem* >( pEntry->GetItem( 0 ) );
753*cdf0e10cSrcweir 			if( pContextGraphicItem )
754*cdf0e10cSrcweir 			{
755*cdf0e10cSrcweir 				if( pContextGraphicItem->msExpandedGraphicURL.getLength() == 0 )
756*cdf0e10cSrcweir 					rTree.SetExpandedEntryBmp( pEntry, maDefaultExpandedImage );
757*cdf0e10cSrcweir 			}
758*cdf0e10cSrcweir 			pEntry = rTree.Next( pEntry );
759*cdf0e10cSrcweir 		}
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir 		msDefaultExpandedGraphicURL = sDefaultExpandedGraphicURL;
762*cdf0e10cSrcweir 	}
763*cdf0e10cSrcweir }
764*cdf0e10cSrcweir 
765*cdf0e10cSrcweir // --------------------------------------------------------------------
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir OUString SAL_CALL TreeControlPeer::getDefaultCollapsedGraphicURL() throw (::com::sun::star::uno::RuntimeException)
768*cdf0e10cSrcweir {
769*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
770*cdf0e10cSrcweir 	return msDefaultCollapsedGraphicURL;
771*cdf0e10cSrcweir }
772*cdf0e10cSrcweir 
773*cdf0e10cSrcweir // --------------------------------------------------------------------
774*cdf0e10cSrcweir 
775*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::setDefaultCollapsedGraphicURL( const ::rtl::OUString& sDefaultCollapsedGraphicURL ) throw (::com::sun::star::uno::RuntimeException)
776*cdf0e10cSrcweir {
777*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
778*cdf0e10cSrcweir 	if( msDefaultCollapsedGraphicURL != sDefaultCollapsedGraphicURL )
779*cdf0e10cSrcweir 	{
780*cdf0e10cSrcweir 		if( sDefaultCollapsedGraphicURL.getLength() )
781*cdf0e10cSrcweir 			loadImage( sDefaultCollapsedGraphicURL, maDefaultCollapsedImage );
782*cdf0e10cSrcweir 		else
783*cdf0e10cSrcweir 			maDefaultCollapsedImage = Image();
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir 		UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir 		SvLBoxEntry* pEntry = rTree.First();
788*cdf0e10cSrcweir 		while( pEntry )
789*cdf0e10cSrcweir 		{
790*cdf0e10cSrcweir 			ImplContextGraphicItem* pContextGraphicItem = dynamic_cast< ImplContextGraphicItem* >( pEntry->GetItem( 0 ) );
791*cdf0e10cSrcweir 			if( pContextGraphicItem )
792*cdf0e10cSrcweir 			{
793*cdf0e10cSrcweir 				if( pContextGraphicItem->msCollapsedGraphicURL.getLength() == 0 )
794*cdf0e10cSrcweir 					rTree.SetCollapsedEntryBmp( pEntry, maDefaultCollapsedImage );
795*cdf0e10cSrcweir 			}
796*cdf0e10cSrcweir 			pEntry = rTree.Next( pEntry );
797*cdf0e10cSrcweir 		}
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir 		msDefaultCollapsedGraphicURL = sDefaultCollapsedGraphicURL;
800*cdf0e10cSrcweir 	}
801*cdf0e10cSrcweir }
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir // --------------------------------------------------------------------
804*cdf0e10cSrcweir 
805*cdf0e10cSrcweir sal_Bool SAL_CALL TreeControlPeer::isNodeExpanded( const Reference< XTreeNode >& xNode ) throw (RuntimeException, IllegalArgumentException)
806*cdf0e10cSrcweir {
807*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
808*cdf0e10cSrcweir 
809*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
810*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = getEntry( xNode );
811*cdf0e10cSrcweir 	return ( pEntry && rTree.IsExpanded( pEntry ) ) ? sal_True : sal_False;
812*cdf0e10cSrcweir }
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir // -------------------------------------------------------------------
815*cdf0e10cSrcweir 
816*cdf0e10cSrcweir sal_Bool SAL_CALL TreeControlPeer::isNodeCollapsed( const Reference< XTreeNode >& xNode ) throw (RuntimeException, IllegalArgumentException)
817*cdf0e10cSrcweir {
818*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
819*cdf0e10cSrcweir 	return !isNodeExpanded( xNode );
820*cdf0e10cSrcweir }
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir // -------------------------------------------------------------------
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::makeNodeVisible( const Reference< XTreeNode >& xNode ) throw (RuntimeException, ExpandVetoException, IllegalArgumentException)
825*cdf0e10cSrcweir {
826*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
829*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = getEntry( xNode );
830*cdf0e10cSrcweir 	if( pEntry )
831*cdf0e10cSrcweir 		rTree.MakeVisible( pEntry );
832*cdf0e10cSrcweir }
833*cdf0e10cSrcweir 
834*cdf0e10cSrcweir // -------------------------------------------------------------------
835*cdf0e10cSrcweir 
836*cdf0e10cSrcweir sal_Bool SAL_CALL TreeControlPeer::isNodeVisible( const Reference< XTreeNode >& xNode ) throw (RuntimeException, IllegalArgumentException)
837*cdf0e10cSrcweir {
838*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
839*cdf0e10cSrcweir 
840*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
841*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = getEntry( xNode );
842*cdf0e10cSrcweir 	return ( pEntry && rTree.IsEntryVisible( pEntry ) ) ? sal_True : sal_False;
843*cdf0e10cSrcweir }
844*cdf0e10cSrcweir 
845*cdf0e10cSrcweir // -------------------------------------------------------------------
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::expandNode( const Reference< XTreeNode >& xNode ) throw (RuntimeException, ExpandVetoException, IllegalArgumentException)
848*cdf0e10cSrcweir {
849*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
852*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = getEntry( xNode );
853*cdf0e10cSrcweir 	if( pEntry )
854*cdf0e10cSrcweir 		rTree.Expand( pEntry );
855*cdf0e10cSrcweir }
856*cdf0e10cSrcweir 
857*cdf0e10cSrcweir // -------------------------------------------------------------------
858*cdf0e10cSrcweir 
859*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::collapseNode( const Reference< XTreeNode >& xNode ) throw (RuntimeException, ExpandVetoException, IllegalArgumentException)
860*cdf0e10cSrcweir {
861*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
862*cdf0e10cSrcweir 
863*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
864*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = getEntry( xNode );
865*cdf0e10cSrcweir 	if( pEntry )
866*cdf0e10cSrcweir 		rTree.Collapse( pEntry );
867*cdf0e10cSrcweir }
868*cdf0e10cSrcweir 
869*cdf0e10cSrcweir // -------------------------------------------------------------------
870*cdf0e10cSrcweir 
871*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::addTreeExpansionListener( const Reference< XTreeExpansionListener >& xListener ) throw (RuntimeException)
872*cdf0e10cSrcweir {
873*cdf0e10cSrcweir 	maTreeExpansionListeners.addInterface( xListener );
874*cdf0e10cSrcweir }
875*cdf0e10cSrcweir 
876*cdf0e10cSrcweir // -------------------------------------------------------------------
877*cdf0e10cSrcweir 
878*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::removeTreeExpansionListener( const Reference< XTreeExpansionListener >& xListener ) throw (RuntimeException)
879*cdf0e10cSrcweir {
880*cdf0e10cSrcweir 	maTreeExpansionListeners.removeInterface( xListener );
881*cdf0e10cSrcweir }
882*cdf0e10cSrcweir 
883*cdf0e10cSrcweir // -------------------------------------------------------------------
884*cdf0e10cSrcweir 
885*cdf0e10cSrcweir Reference< XTreeNode > SAL_CALL TreeControlPeer::getNodeForLocation( sal_Int32 x, sal_Int32 y ) throw (RuntimeException)
886*cdf0e10cSrcweir {
887*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
888*cdf0e10cSrcweir 
889*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
890*cdf0e10cSrcweir 
891*cdf0e10cSrcweir 	Reference< XTreeNode > xNode;
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir 	const Point aPos( x, y );
894*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = dynamic_cast< UnoTreeListEntry* >( rTree.GetEntry( aPos, sal_True ) );
895*cdf0e10cSrcweir 	if( pEntry )
896*cdf0e10cSrcweir 		xNode = pEntry->mxNode;
897*cdf0e10cSrcweir 
898*cdf0e10cSrcweir 	return xNode;
899*cdf0e10cSrcweir }
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir // -------------------------------------------------------------------
902*cdf0e10cSrcweir 
903*cdf0e10cSrcweir Reference< XTreeNode > SAL_CALL TreeControlPeer::getClosestNodeForLocation( sal_Int32 x, sal_Int32 y ) throw (RuntimeException)
904*cdf0e10cSrcweir {
905*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
906*cdf0e10cSrcweir 
907*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
908*cdf0e10cSrcweir 
909*cdf0e10cSrcweir 	Reference< XTreeNode > xNode;
910*cdf0e10cSrcweir 
911*cdf0e10cSrcweir 	const Point aPos( x, y );
912*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = dynamic_cast< UnoTreeListEntry* >( rTree.GetEntry( aPos, sal_True ) );
913*cdf0e10cSrcweir 	if( pEntry )
914*cdf0e10cSrcweir 		xNode = pEntry->mxNode;
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir 	return xNode;
917*cdf0e10cSrcweir }
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir // -------------------------------------------------------------------
920*cdf0e10cSrcweir 
921*cdf0e10cSrcweir awt::Rectangle SAL_CALL TreeControlPeer::getNodeRect( const Reference< XTreeNode >& i_Node ) throw (IllegalArgumentException, RuntimeException)
922*cdf0e10cSrcweir {
923*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
926*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = getEntry( i_Node, true );
927*cdf0e10cSrcweir 
928*cdf0e10cSrcweir     ::Rectangle aEntryRect( rTree.GetFocusRect( pEntry, rTree.GetEntryPosition( pEntry ).Y() ) );
929*cdf0e10cSrcweir     return VCLUnoHelper::ConvertToAWTRect( aEntryRect );
930*cdf0e10cSrcweir }
931*cdf0e10cSrcweir 
932*cdf0e10cSrcweir // -------------------------------------------------------------------
933*cdf0e10cSrcweir 
934*cdf0e10cSrcweir sal_Bool SAL_CALL TreeControlPeer::isEditing(  ) throw (RuntimeException)
935*cdf0e10cSrcweir {
936*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
939*cdf0e10cSrcweir 	return rTree.IsEditingActive() ? sal_True : sal_False;
940*cdf0e10cSrcweir }
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir // -------------------------------------------------------------------
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir sal_Bool SAL_CALL TreeControlPeer::stopEditing() throw (RuntimeException)
945*cdf0e10cSrcweir {
946*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
947*cdf0e10cSrcweir 
948*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
949*cdf0e10cSrcweir 	if( rTree.IsEditingActive() )
950*cdf0e10cSrcweir 	{
951*cdf0e10cSrcweir 		rTree.EndEditing(sal_False);
952*cdf0e10cSrcweir 		return sal_True;
953*cdf0e10cSrcweir 	}
954*cdf0e10cSrcweir 	else
955*cdf0e10cSrcweir 	{
956*cdf0e10cSrcweir 		return sal_False;
957*cdf0e10cSrcweir 	}
958*cdf0e10cSrcweir }
959*cdf0e10cSrcweir 
960*cdf0e10cSrcweir // -------------------------------------------------------------------
961*cdf0e10cSrcweir 
962*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::cancelEditing(  ) throw (RuntimeException)
963*cdf0e10cSrcweir {
964*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
967*cdf0e10cSrcweir 	rTree.EndEditing(sal_False);
968*cdf0e10cSrcweir }
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir // -------------------------------------------------------------------
971*cdf0e10cSrcweir 
972*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::startEditingAtNode( const Reference< XTreeNode >& xNode ) throw (IllegalArgumentException, RuntimeException)
973*cdf0e10cSrcweir {
974*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
975*cdf0e10cSrcweir 
976*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
977*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = getEntry( xNode );
978*cdf0e10cSrcweir 	rTree.EditEntry( pEntry );
979*cdf0e10cSrcweir }
980*cdf0e10cSrcweir 
981*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::addTreeEditListener( const Reference< XTreeEditListener >& xListener ) throw (RuntimeException)
982*cdf0e10cSrcweir {
983*cdf0e10cSrcweir 	maTreeEditListeners.addInterface( xListener );
984*cdf0e10cSrcweir }
985*cdf0e10cSrcweir 
986*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::removeTreeEditListener( const Reference< XTreeEditListener >& xListener ) throw (RuntimeException)
987*cdf0e10cSrcweir {
988*cdf0e10cSrcweir 	maTreeEditListeners.removeInterface( xListener );
989*cdf0e10cSrcweir }
990*cdf0e10cSrcweir 
991*cdf0e10cSrcweir bool TreeControlPeer::onEditingEntry( UnoTreeListEntry* pEntry )
992*cdf0e10cSrcweir {
993*cdf0e10cSrcweir 	if( mpTreeImpl && pEntry && pEntry->mxNode.is() && (maTreeEditListeners.getLength() > 0)  )
994*cdf0e10cSrcweir 	{
995*cdf0e10cSrcweir 		try
996*cdf0e10cSrcweir 		{
997*cdf0e10cSrcweir 			maTreeEditListeners.nodeEditing( pEntry->mxNode );
998*cdf0e10cSrcweir 		}
999*cdf0e10cSrcweir 		catch( VetoException& )
1000*cdf0e10cSrcweir 		{
1001*cdf0e10cSrcweir 			return false;
1002*cdf0e10cSrcweir 		}
1003*cdf0e10cSrcweir 		catch( Exception& )
1004*cdf0e10cSrcweir 		{
1005*cdf0e10cSrcweir 		}
1006*cdf0e10cSrcweir 	}
1007*cdf0e10cSrcweir 	return true;
1008*cdf0e10cSrcweir }
1009*cdf0e10cSrcweir 
1010*cdf0e10cSrcweir bool TreeControlPeer::onEditedEntry( UnoTreeListEntry* pEntry, const XubString& rNewText )
1011*cdf0e10cSrcweir {
1012*cdf0e10cSrcweir 	if( mpTreeImpl && pEntry && pEntry->mxNode.is() ) try
1013*cdf0e10cSrcweir 	{
1014*cdf0e10cSrcweir 		LockGuard aLockGuard( mnEditLock );
1015*cdf0e10cSrcweir 		const OUString aNewText( rNewText );
1016*cdf0e10cSrcweir 		if( maTreeEditListeners.getLength() > 0 )
1017*cdf0e10cSrcweir 		{
1018*cdf0e10cSrcweir 			maTreeEditListeners.nodeEdited( pEntry->mxNode, aNewText );
1019*cdf0e10cSrcweir 			return false;
1020*cdf0e10cSrcweir 		}
1021*cdf0e10cSrcweir 		else
1022*cdf0e10cSrcweir 		{
1023*cdf0e10cSrcweir 			Reference< XMutableTreeNode > xMutableNode( pEntry->mxNode, UNO_QUERY );
1024*cdf0e10cSrcweir 			if( xMutableNode.is() )
1025*cdf0e10cSrcweir 				xMutableNode->setDisplayValue( Any( aNewText ) );
1026*cdf0e10cSrcweir 			else
1027*cdf0e10cSrcweir 				return false;
1028*cdf0e10cSrcweir 		}
1029*cdf0e10cSrcweir 
1030*cdf0e10cSrcweir 	}
1031*cdf0e10cSrcweir 	catch( Exception& )
1032*cdf0e10cSrcweir 	{
1033*cdf0e10cSrcweir 	}
1034*cdf0e10cSrcweir 
1035*cdf0e10cSrcweir 	return true;
1036*cdf0e10cSrcweir }
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir // --------------------------------------------------------------------
1039*cdf0e10cSrcweir // ::com::sun::star::awt::tree::TreeDataModelListener
1040*cdf0e10cSrcweir // --------------------------------------------------------------------
1041*cdf0e10cSrcweir 
1042*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::treeNodesChanged( const ::com::sun::star::awt::tree::TreeDataModelEvent& rEvent ) throw (RuntimeException)
1043*cdf0e10cSrcweir {
1044*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1045*cdf0e10cSrcweir 
1046*cdf0e10cSrcweir 	if( mnEditLock != 0 )
1047*cdf0e10cSrcweir 		return;
1048*cdf0e10cSrcweir 
1049*cdf0e10cSrcweir 	updateTree( rEvent, true );
1050*cdf0e10cSrcweir }
1051*cdf0e10cSrcweir 
1052*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::treeNodesInserted( const ::com::sun::star::awt::tree::TreeDataModelEvent& rEvent ) throw (RuntimeException)
1053*cdf0e10cSrcweir {
1054*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1055*cdf0e10cSrcweir 
1056*cdf0e10cSrcweir 	if( mnEditLock != 0 )
1057*cdf0e10cSrcweir 		return;
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir 	updateTree( rEvent, true );
1060*cdf0e10cSrcweir }
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::treeNodesRemoved( const ::com::sun::star::awt::tree::TreeDataModelEvent& rEvent ) throw (RuntimeException)
1063*cdf0e10cSrcweir {
1064*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1065*cdf0e10cSrcweir 
1066*cdf0e10cSrcweir 	if( mnEditLock != 0 )
1067*cdf0e10cSrcweir 		return;
1068*cdf0e10cSrcweir 
1069*cdf0e10cSrcweir 	updateTree( rEvent, true );
1070*cdf0e10cSrcweir }
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::treeStructureChanged( const ::com::sun::star::awt::tree::TreeDataModelEvent& rEvent ) throw (RuntimeException)
1073*cdf0e10cSrcweir {
1074*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1075*cdf0e10cSrcweir 
1076*cdf0e10cSrcweir 	if( mnEditLock != 0 )
1077*cdf0e10cSrcweir 		return;
1078*cdf0e10cSrcweir 
1079*cdf0e10cSrcweir 	updateTree( rEvent, true );
1080*cdf0e10cSrcweir }
1081*cdf0e10cSrcweir 
1082*cdf0e10cSrcweir void TreeControlPeer::updateTree( const ::com::sun::star::awt::tree::TreeDataModelEvent& rEvent, bool bRecursive )
1083*cdf0e10cSrcweir {
1084*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
1085*cdf0e10cSrcweir 
1086*cdf0e10cSrcweir 	Sequence< Reference< XTreeNode > > Nodes;
1087*cdf0e10cSrcweir 	Reference< XTreeNode > xNode( rEvent.ParentNode );
1088*cdf0e10cSrcweir 	if( !xNode.is() && Nodes.getLength() )
1089*cdf0e10cSrcweir 	{
1090*cdf0e10cSrcweir 		xNode = Nodes[0];
1091*cdf0e10cSrcweir 	}
1092*cdf0e10cSrcweir 
1093*cdf0e10cSrcweir 	if( xNode.is() )
1094*cdf0e10cSrcweir 		updateNode( rTree, xNode, bRecursive );
1095*cdf0e10cSrcweir }
1096*cdf0e10cSrcweir 
1097*cdf0e10cSrcweir void TreeControlPeer::updateNode( UnoTreeListBoxImpl& rTree, const Reference< XTreeNode >& xNode, bool bRecursive )
1098*cdf0e10cSrcweir {
1099*cdf0e10cSrcweir 	if( xNode.is() )
1100*cdf0e10cSrcweir 	{
1101*cdf0e10cSrcweir 		UnoTreeListEntry* pNodeEntry = getEntry( xNode, false );
1102*cdf0e10cSrcweir 
1103*cdf0e10cSrcweir 		if( !pNodeEntry )
1104*cdf0e10cSrcweir 		{
1105*cdf0e10cSrcweir 			Reference< XTreeNode > xParentNode( xNode->getParent() );
1106*cdf0e10cSrcweir 			UnoTreeListEntry* pParentEntry = 0;
1107*cdf0e10cSrcweir 			sal_uLong nChild = LIST_APPEND;
1108*cdf0e10cSrcweir 
1109*cdf0e10cSrcweir 			if( xParentNode.is() )
1110*cdf0e10cSrcweir 			{
1111*cdf0e10cSrcweir 				pParentEntry = getEntry( xParentNode  );
1112*cdf0e10cSrcweir 				nChild = xParentNode->getIndex( xNode );
1113*cdf0e10cSrcweir 			}
1114*cdf0e10cSrcweir 
1115*cdf0e10cSrcweir 			pNodeEntry = createEntry( xNode, pParentEntry, nChild );
1116*cdf0e10cSrcweir 		}
1117*cdf0e10cSrcweir 
1118*cdf0e10cSrcweir 		if( bRecursive )
1119*cdf0e10cSrcweir 			updateChildNodes( rTree, xNode, pNodeEntry );
1120*cdf0e10cSrcweir 	}
1121*cdf0e10cSrcweir }
1122*cdf0e10cSrcweir 
1123*cdf0e10cSrcweir void TreeControlPeer::updateChildNodes( UnoTreeListBoxImpl& rTree, const Reference< XTreeNode >& xParentNode, UnoTreeListEntry* pParentEntry )
1124*cdf0e10cSrcweir {
1125*cdf0e10cSrcweir 	if( xParentNode.is() && pParentEntry )
1126*cdf0e10cSrcweir 	{
1127*cdf0e10cSrcweir 		UnoTreeListEntry* pCurrentChild = dynamic_cast< UnoTreeListEntry* >( rTree.FirstChild( pParentEntry ) );
1128*cdf0e10cSrcweir 
1129*cdf0e10cSrcweir 		const sal_Int32 nChildCount = xParentNode->getChildCount();
1130*cdf0e10cSrcweir 		for( sal_Int32 nChild = 0; nChild < nChildCount; nChild++ )
1131*cdf0e10cSrcweir 		{
1132*cdf0e10cSrcweir 			Reference< XTreeNode > xNode( xParentNode->getChildAt( nChild ) );
1133*cdf0e10cSrcweir 			if( !pCurrentChild || ( pCurrentChild->mxNode != xNode ) )
1134*cdf0e10cSrcweir 			{
1135*cdf0e10cSrcweir 				UnoTreeListEntry* pNodeEntry = getEntry( xNode, false );
1136*cdf0e10cSrcweir 				if( pNodeEntry == 0 )
1137*cdf0e10cSrcweir 				{
1138*cdf0e10cSrcweir 					// child node is not yet part of the tree, add it
1139*cdf0e10cSrcweir 					pCurrentChild = createEntry( xNode, pParentEntry, nChild );
1140*cdf0e10cSrcweir 				}
1141*cdf0e10cSrcweir 				else if( pNodeEntry != pCurrentChild )
1142*cdf0e10cSrcweir 				{
1143*cdf0e10cSrcweir 					// node is already part of the tree, but not on the correct position
1144*cdf0e10cSrcweir 					rTree.GetModel()->Move( pNodeEntry, pParentEntry, nChild );
1145*cdf0e10cSrcweir 					pCurrentChild = pNodeEntry;
1146*cdf0e10cSrcweir 					updateEntry( pCurrentChild );
1147*cdf0e10cSrcweir 				}
1148*cdf0e10cSrcweir 			}
1149*cdf0e10cSrcweir 			else
1150*cdf0e10cSrcweir 			{
1151*cdf0e10cSrcweir 				// child node has entry and entry is equal to current entry,
1152*cdf0e10cSrcweir 				// so no structural changes happened
1153*cdf0e10cSrcweir 				updateEntry( pCurrentChild );
1154*cdf0e10cSrcweir 			}
1155*cdf0e10cSrcweir 
1156*cdf0e10cSrcweir 			pCurrentChild = dynamic_cast< UnoTreeListEntry* >( rTree.NextSibling( pCurrentChild ) );
1157*cdf0e10cSrcweir 		}
1158*cdf0e10cSrcweir 
1159*cdf0e10cSrcweir 		// check if we have entries without nodes left, we need to remove them
1160*cdf0e10cSrcweir 		while( pCurrentChild )
1161*cdf0e10cSrcweir 		{
1162*cdf0e10cSrcweir 			UnoTreeListEntry* pNextChild = dynamic_cast< UnoTreeListEntry* >( rTree.NextSibling( pCurrentChild ) );
1163*cdf0e10cSrcweir 			rTree.GetModel()->Remove( pCurrentChild );
1164*cdf0e10cSrcweir 			pCurrentChild = pNextChild;
1165*cdf0e10cSrcweir 		}
1166*cdf0e10cSrcweir 	}
1167*cdf0e10cSrcweir }
1168*cdf0e10cSrcweir 
1169*cdf0e10cSrcweir OUString TreeControlPeer::getEntryString( const Any& rValue )
1170*cdf0e10cSrcweir {
1171*cdf0e10cSrcweir 	OUString sValue;
1172*cdf0e10cSrcweir 	if( rValue.hasValue() )
1173*cdf0e10cSrcweir 	{
1174*cdf0e10cSrcweir 		switch( rValue.getValueTypeClass() )
1175*cdf0e10cSrcweir 		{
1176*cdf0e10cSrcweir 		case TypeClass_SHORT:
1177*cdf0e10cSrcweir 		case TypeClass_LONG:
1178*cdf0e10cSrcweir 			{
1179*cdf0e10cSrcweir 				sal_Int32 nValue = 0;
1180*cdf0e10cSrcweir 				if( rValue >>= nValue )
1181*cdf0e10cSrcweir 					sValue = OUString::valueOf( nValue );
1182*cdf0e10cSrcweir 				break;
1183*cdf0e10cSrcweir 			}
1184*cdf0e10cSrcweir 		case TypeClass_BYTE:
1185*cdf0e10cSrcweir 		case TypeClass_UNSIGNED_SHORT:
1186*cdf0e10cSrcweir 		case TypeClass_UNSIGNED_LONG:
1187*cdf0e10cSrcweir 			{
1188*cdf0e10cSrcweir 				sal_uInt32 nValue = 0;
1189*cdf0e10cSrcweir 				if( rValue >>= nValue )
1190*cdf0e10cSrcweir 					sValue = OUString::valueOf( (sal_Int64)nValue );
1191*cdf0e10cSrcweir 				break;
1192*cdf0e10cSrcweir 			}
1193*cdf0e10cSrcweir 		case TypeClass_HYPER:
1194*cdf0e10cSrcweir 			{
1195*cdf0e10cSrcweir 				sal_Int64 nValue = 0;
1196*cdf0e10cSrcweir 				if( rValue >>= nValue )
1197*cdf0e10cSrcweir 					sValue = OUString::valueOf( nValue );
1198*cdf0e10cSrcweir 				break;
1199*cdf0e10cSrcweir 			}
1200*cdf0e10cSrcweir 		case TypeClass_UNSIGNED_HYPER:
1201*cdf0e10cSrcweir 			{
1202*cdf0e10cSrcweir 				sal_uInt64 nValue = 0;
1203*cdf0e10cSrcweir 				if( rValue >>= nValue )
1204*cdf0e10cSrcweir 					sValue = OUString::valueOf( (sal_Int64)nValue );
1205*cdf0e10cSrcweir 				break;
1206*cdf0e10cSrcweir 			}
1207*cdf0e10cSrcweir 		case TypeClass_FLOAT:
1208*cdf0e10cSrcweir 		case TypeClass_DOUBLE:
1209*cdf0e10cSrcweir 			{
1210*cdf0e10cSrcweir 				double fValue = 0.0;
1211*cdf0e10cSrcweir 				if( rValue >>= fValue )
1212*cdf0e10cSrcweir 					sValue = OUString::valueOf( fValue );
1213*cdf0e10cSrcweir 				break;
1214*cdf0e10cSrcweir 			}
1215*cdf0e10cSrcweir 		case TypeClass_STRING:
1216*cdf0e10cSrcweir 			rValue >>= sValue;
1217*cdf0e10cSrcweir 			break;
1218*cdf0e10cSrcweir 	/*
1219*cdf0e10cSrcweir 		case TypeClass_INTERFACE:
1220*cdf0e10cSrcweir 			// @todo
1221*cdf0e10cSrcweir 			break;
1222*cdf0e10cSrcweir 		case TypeClass_SEQUENCE:
1223*cdf0e10cSrcweir 			{
1224*cdf0e10cSrcweir 				Sequence< Any > aValues;
1225*cdf0e10cSrcweir 				if( aValue >>= aValues )
1226*cdf0e10cSrcweir 				{
1227*cdf0e10cSrcweir 					updateEntry( SvLBoxEntry& rEntry, aValues );
1228*cdf0e10cSrcweir 					return;
1229*cdf0e10cSrcweir 				}
1230*cdf0e10cSrcweir 			}
1231*cdf0e10cSrcweir 			break;
1232*cdf0e10cSrcweir 	*/
1233*cdf0e10cSrcweir 		default:
1234*cdf0e10cSrcweir 			break;
1235*cdf0e10cSrcweir 		}
1236*cdf0e10cSrcweir 	}
1237*cdf0e10cSrcweir 	return sValue;
1238*cdf0e10cSrcweir }
1239*cdf0e10cSrcweir 
1240*cdf0e10cSrcweir // XEventListener
1241*cdf0e10cSrcweir void SAL_CALL TreeControlPeer::disposing( const ::com::sun::star::lang::EventObject& ) throw(::com::sun::star::uno::RuntimeException)
1242*cdf0e10cSrcweir {
1243*cdf0e10cSrcweir 	// model is disposed, so we clear our tree
1244*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1245*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
1246*cdf0e10cSrcweir 	rTree.Clear();
1247*cdf0e10cSrcweir 	mxDataModel.clear();
1248*cdf0e10cSrcweir }
1249*cdf0e10cSrcweir 
1250*cdf0e10cSrcweir void TreeControlPeer::onChangeDataModel( UnoTreeListBoxImpl& rTree, const Reference< XTreeDataModel >& xDataModel )
1251*cdf0e10cSrcweir {
1252*cdf0e10cSrcweir 	if( xDataModel.is() && (mxDataModel == xDataModel) )
1253*cdf0e10cSrcweir 		return; // do nothing
1254*cdf0e10cSrcweir 
1255*cdf0e10cSrcweir 	Reference< XTreeDataModelListener > xListener( this );
1256*cdf0e10cSrcweir 
1257*cdf0e10cSrcweir 	if( mxDataModel.is() )
1258*cdf0e10cSrcweir 		mxDataModel->removeTreeDataModelListener( xListener );
1259*cdf0e10cSrcweir 
1260*cdf0e10cSrcweir 	if( !xDataModel.is() )
1261*cdf0e10cSrcweir 	{
1262*cdf0e10cSrcweir 		static const OUString aSN( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.tree.DefaultTreeDataModel" ) );
1263*cdf0e10cSrcweir 		Reference< XMultiServiceFactory > xORB( ::comphelper::getProcessServiceFactory() );
1264*cdf0e10cSrcweir 		if( xORB.is() )
1265*cdf0e10cSrcweir 		{
1266*cdf0e10cSrcweir 			mxDataModel.query( xORB->createInstance( aSN ) );
1267*cdf0e10cSrcweir 		}
1268*cdf0e10cSrcweir 	}
1269*cdf0e10cSrcweir 
1270*cdf0e10cSrcweir 	mxDataModel = xDataModel;
1271*cdf0e10cSrcweir 
1272*cdf0e10cSrcweir 	fillTree( rTree, mxDataModel );
1273*cdf0e10cSrcweir 
1274*cdf0e10cSrcweir 	if( mxDataModel.is() )
1275*cdf0e10cSrcweir 		mxDataModel->addTreeDataModelListener( xListener );
1276*cdf0e10cSrcweir }
1277*cdf0e10cSrcweir 
1278*cdf0e10cSrcweir // --------------------------------------------------------------------
1279*cdf0e10cSrcweir // ::com::sun::star::awt::XLayoutConstrains
1280*cdf0e10cSrcweir // --------------------------------------------------------------------
1281*cdf0e10cSrcweir 
1282*cdf0e10cSrcweir ::com::sun::star::awt::Size TreeControlPeer::getMinimumSize() throw(RuntimeException)
1283*cdf0e10cSrcweir {
1284*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1285*cdf0e10cSrcweir 
1286*cdf0e10cSrcweir 	::com::sun::star::awt::Size aSz;
1287*cdf0e10cSrcweir /* todo
1288*cdf0e10cSrcweir 	MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow();
1289*cdf0e10cSrcweir 	if ( pEdit )
1290*cdf0e10cSrcweir 		aSz = AWTSize(pEdit->CalcMinimumSize());
1291*cdf0e10cSrcweir */
1292*cdf0e10cSrcweir 	return aSz;
1293*cdf0e10cSrcweir }
1294*cdf0e10cSrcweir 
1295*cdf0e10cSrcweir ::com::sun::star::awt::Size TreeControlPeer::getPreferredSize() throw(RuntimeException)
1296*cdf0e10cSrcweir {
1297*cdf0e10cSrcweir 	return getMinimumSize();
1298*cdf0e10cSrcweir }
1299*cdf0e10cSrcweir 
1300*cdf0e10cSrcweir ::com::sun::star::awt::Size TreeControlPeer::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(RuntimeException)
1301*cdf0e10cSrcweir {
1302*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1303*cdf0e10cSrcweir 
1304*cdf0e10cSrcweir 	::com::sun::star::awt::Size aSz = rNewSize;
1305*cdf0e10cSrcweir /* todo
1306*cdf0e10cSrcweir 	MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow();
1307*cdf0e10cSrcweir 	if ( pEdit )
1308*cdf0e10cSrcweir 		aSz = AWTSize(pEdit->CalcAdjustedSize( VCLSize(rNewSize )));
1309*cdf0e10cSrcweir */
1310*cdf0e10cSrcweir 	return aSz;
1311*cdf0e10cSrcweir }
1312*cdf0e10cSrcweir 
1313*cdf0e10cSrcweir // --------------------------------------------------------------------
1314*cdf0e10cSrcweir // ::com::sun::star::awt::XVclWindowPeer
1315*cdf0e10cSrcweir // --------------------------------------------------------------------
1316*cdf0e10cSrcweir 
1317*cdf0e10cSrcweir void TreeControlPeer::setProperty( const ::rtl::OUString& PropertyName, const Any& aValue) throw(RuntimeException)
1318*cdf0e10cSrcweir {
1319*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1320*cdf0e10cSrcweir 
1321*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
1322*cdf0e10cSrcweir 
1323*cdf0e10cSrcweir 	switch( GetPropertyId( PropertyName ) )
1324*cdf0e10cSrcweir 	{
1325*cdf0e10cSrcweir         case BASEPROPERTY_HIDEINACTIVESELECTION:
1326*cdf0e10cSrcweir         {
1327*cdf0e10cSrcweir             sal_Bool bEnabled = sal_False;
1328*cdf0e10cSrcweir             if ( aValue >>= bEnabled )
1329*cdf0e10cSrcweir             {
1330*cdf0e10cSrcweir                 WinBits nStyle = rTree.GetStyle();
1331*cdf0e10cSrcweir                 if ( bEnabled )
1332*cdf0e10cSrcweir                     nStyle |= WB_HIDESELECTION;
1333*cdf0e10cSrcweir                 else
1334*cdf0e10cSrcweir                     nStyle &= ~WB_HIDESELECTION;
1335*cdf0e10cSrcweir                 rTree.SetStyle( nStyle );
1336*cdf0e10cSrcweir             }
1337*cdf0e10cSrcweir         }
1338*cdf0e10cSrcweir         break;
1339*cdf0e10cSrcweir 
1340*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_SELECTIONTYPE:
1341*cdf0e10cSrcweir 		{
1342*cdf0e10cSrcweir 			SelectionType eSelectionType;
1343*cdf0e10cSrcweir 			if( aValue >>= eSelectionType )
1344*cdf0e10cSrcweir 			{
1345*cdf0e10cSrcweir 				SelectionMode eSelMode;
1346*cdf0e10cSrcweir 				switch( eSelectionType )
1347*cdf0e10cSrcweir 				{
1348*cdf0e10cSrcweir 				case SelectionType_SINGLE:	eSelMode = SINGLE_SELECTION; break;
1349*cdf0e10cSrcweir 				case SelectionType_RANGE:	eSelMode = RANGE_SELECTION; break;
1350*cdf0e10cSrcweir 				case SelectionType_MULTI:	eSelMode = MULTIPLE_SELECTION; break;
1351*cdf0e10cSrcweir 	//			case SelectionType_NONE:
1352*cdf0e10cSrcweir 				default:					eSelMode = NO_SELECTION; break;
1353*cdf0e10cSrcweir 				}
1354*cdf0e10cSrcweir 				if( rTree.GetSelectionMode() != eSelMode )
1355*cdf0e10cSrcweir 					rTree.SetSelectionMode( eSelMode );
1356*cdf0e10cSrcweir 			}
1357*cdf0e10cSrcweir 			break;
1358*cdf0e10cSrcweir 		}
1359*cdf0e10cSrcweir 
1360*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_DATAMODEL:
1361*cdf0e10cSrcweir 			onChangeDataModel( rTree, Reference< XTreeDataModel >( aValue, UNO_QUERY ) );
1362*cdf0e10cSrcweir 			break;
1363*cdf0e10cSrcweir 		case BASEPROPERTY_ROW_HEIGHT:
1364*cdf0e10cSrcweir 		{
1365*cdf0e10cSrcweir 			sal_Int32 nHeight = 0;
1366*cdf0e10cSrcweir 			if( aValue >>= nHeight )
1367*cdf0e10cSrcweir 				rTree.SetEntryHeight( (short)nHeight );
1368*cdf0e10cSrcweir 			break;
1369*cdf0e10cSrcweir 		}
1370*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_EDITABLE:
1371*cdf0e10cSrcweir 		{
1372*cdf0e10cSrcweir 			sal_Bool bEnabled = false;
1373*cdf0e10cSrcweir 			if( aValue >>= bEnabled )
1374*cdf0e10cSrcweir 				rTree.EnableInplaceEditing( bEnabled ? sal_True : sal_False );
1375*cdf0e10cSrcweir 			break;
1376*cdf0e10cSrcweir 		}
1377*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_INVOKESSTOPNODEEDITING:
1378*cdf0e10cSrcweir 			break; // @todo
1379*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_ROOTDISPLAYED:
1380*cdf0e10cSrcweir         {
1381*cdf0e10cSrcweir 			sal_Bool bDisplayed = false;
1382*cdf0e10cSrcweir 			if( (aValue >>= bDisplayed) && ( bDisplayed != mbIsRootDisplayed) )
1383*cdf0e10cSrcweir 			{
1384*cdf0e10cSrcweir 				onChangeRootDisplayed(bDisplayed);
1385*cdf0e10cSrcweir 			}
1386*cdf0e10cSrcweir 			break;
1387*cdf0e10cSrcweir         }
1388*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_SHOWSHANDLES:
1389*cdf0e10cSrcweir 		{
1390*cdf0e10cSrcweir 			sal_Bool bEnabled = false;
1391*cdf0e10cSrcweir 			if( aValue >>= bEnabled )
1392*cdf0e10cSrcweir 			{
1393*cdf0e10cSrcweir 				WinBits nBits = rTree.GetStyle() & (~WB_HASLINES);
1394*cdf0e10cSrcweir 				if( bEnabled )
1395*cdf0e10cSrcweir 					nBits |= WB_HASLINES;
1396*cdf0e10cSrcweir 				if( nBits != rTree.GetStyle() )
1397*cdf0e10cSrcweir 					rTree.SetStyle( nBits );
1398*cdf0e10cSrcweir 			}
1399*cdf0e10cSrcweir 			break;
1400*cdf0e10cSrcweir 		}
1401*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_SHOWSROOTHANDLES:
1402*cdf0e10cSrcweir 		{
1403*cdf0e10cSrcweir 			sal_Bool bEnabled = false;
1404*cdf0e10cSrcweir 			if( aValue >>= bEnabled )
1405*cdf0e10cSrcweir 			{
1406*cdf0e10cSrcweir 				WinBits nBits = rTree.GetStyle() & (~WB_HASLINESATROOT);
1407*cdf0e10cSrcweir 				if( bEnabled )
1408*cdf0e10cSrcweir 					nBits |= WB_HASLINESATROOT;
1409*cdf0e10cSrcweir 				if( nBits != rTree.GetStyle() )
1410*cdf0e10cSrcweir 					rTree.SetStyle( nBits );
1411*cdf0e10cSrcweir 			}
1412*cdf0e10cSrcweir 			break;
1413*cdf0e10cSrcweir 		}
1414*cdf0e10cSrcweir 		default:
1415*cdf0e10cSrcweir 		VCLXWindow::setProperty( PropertyName, aValue );
1416*cdf0e10cSrcweir 		break;
1417*cdf0e10cSrcweir 	}
1418*cdf0e10cSrcweir }
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir Any TreeControlPeer::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException)
1421*cdf0e10cSrcweir {
1422*cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1423*cdf0e10cSrcweir 
1424*cdf0e10cSrcweir 	const sal_uInt16 nPropId = GetPropertyId( PropertyName );
1425*cdf0e10cSrcweir 	if( (nPropId >= BASEPROPERTY_TREE_START) && (nPropId <= BASEPROPERTY_TREE_END) )
1426*cdf0e10cSrcweir 	{
1427*cdf0e10cSrcweir 		UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
1428*cdf0e10cSrcweir 		switch(nPropId)
1429*cdf0e10cSrcweir 		{
1430*cdf0e10cSrcweir         case BASEPROPERTY_HIDEINACTIVESELECTION:
1431*cdf0e10cSrcweir 			return Any( ( rTree.GetStyle() & WB_HIDESELECTION ) != 0 ? sal_True : sal_False );
1432*cdf0e10cSrcweir 
1433*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_SELECTIONTYPE:
1434*cdf0e10cSrcweir 		{
1435*cdf0e10cSrcweir 			SelectionType eSelectionType;
1436*cdf0e10cSrcweir 
1437*cdf0e10cSrcweir 			SelectionMode eSelMode = rTree.GetSelectionMode();
1438*cdf0e10cSrcweir 			switch( eSelMode )
1439*cdf0e10cSrcweir 			{
1440*cdf0e10cSrcweir 			case SINGLE_SELECTION:	eSelectionType = SelectionType_SINGLE; break;
1441*cdf0e10cSrcweir 			case RANGE_SELECTION:	eSelectionType = SelectionType_RANGE; break;
1442*cdf0e10cSrcweir 			case MULTIPLE_SELECTION:eSelectionType = SelectionType_MULTI; break;
1443*cdf0e10cSrcweir //			case NO_SELECTION:
1444*cdf0e10cSrcweir 			default:				eSelectionType = SelectionType_NONE; break;
1445*cdf0e10cSrcweir 			}
1446*cdf0e10cSrcweir 			return Any( eSelectionType );
1447*cdf0e10cSrcweir 		}
1448*cdf0e10cSrcweir 		case BASEPROPERTY_ROW_HEIGHT:
1449*cdf0e10cSrcweir 			return Any( (sal_Int32)rTree.GetEntryHeight() );
1450*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_DATAMODEL:
1451*cdf0e10cSrcweir 			return Any( mxDataModel );
1452*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_EDITABLE:
1453*cdf0e10cSrcweir 			return Any( rTree.IsInplaceEditingEnabled() ? sal_True : sal_False );
1454*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_INVOKESSTOPNODEEDITING:
1455*cdf0e10cSrcweir 			return Any( sal_True ); // @todo
1456*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_ROOTDISPLAYED:
1457*cdf0e10cSrcweir 			return Any( mbIsRootDisplayed );
1458*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_SHOWSHANDLES:
1459*cdf0e10cSrcweir 			return Any( (rTree.GetStyle() & WB_HASLINES) != 0 ? sal_True : sal_False );
1460*cdf0e10cSrcweir 		case BASEPROPERTY_TREE_SHOWSROOTHANDLES:
1461*cdf0e10cSrcweir 			return Any( (rTree.GetStyle() & WB_HASLINESATROOT) != 0 ? sal_True : sal_False );
1462*cdf0e10cSrcweir 		}
1463*cdf0e10cSrcweir 	}
1464*cdf0e10cSrcweir 	return VCLXWindow::getProperty( PropertyName );
1465*cdf0e10cSrcweir }
1466*cdf0e10cSrcweir 
1467*cdf0e10cSrcweir void TreeControlPeer::onChangeRootDisplayed( sal_Bool bIsRootDisplayed )
1468*cdf0e10cSrcweir {
1469*cdf0e10cSrcweir 	if( mbIsRootDisplayed == bIsRootDisplayed )
1470*cdf0e10cSrcweir 		return;
1471*cdf0e10cSrcweir 
1472*cdf0e10cSrcweir 	mbIsRootDisplayed = bIsRootDisplayed;
1473*cdf0e10cSrcweir 
1474*cdf0e10cSrcweir 	UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow();
1475*cdf0e10cSrcweir 
1476*cdf0e10cSrcweir 	if( rTree.GetEntryCount() == 0 )
1477*cdf0e10cSrcweir 		return;
1478*cdf0e10cSrcweir 
1479*cdf0e10cSrcweir 	// todo
1480*cdf0e10cSrcweir 	fillTree( rTree, mxDataModel );
1481*cdf0e10cSrcweir 	if( mbIsRootDisplayed )
1482*cdf0e10cSrcweir 	{
1483*cdf0e10cSrcweir 	}
1484*cdf0e10cSrcweir 	else
1485*cdf0e10cSrcweir 	{
1486*cdf0e10cSrcweir 	}
1487*cdf0e10cSrcweir }
1488*cdf0e10cSrcweir 
1489*cdf0e10cSrcweir bool TreeControlPeer::loadImage( const ::rtl::OUString& rURL, Image& rImage )
1490*cdf0e10cSrcweir {
1491*cdf0e10cSrcweir 	if( !mxGraphicProvider.is() )
1492*cdf0e10cSrcweir 	{
1493*cdf0e10cSrcweir 		static const OUString aSN( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) );
1494*cdf0e10cSrcweir 		Reference< XMultiServiceFactory > xORB( ::comphelper::getProcessServiceFactory() );
1495*cdf0e10cSrcweir 		if( xORB.is() )
1496*cdf0e10cSrcweir 		{
1497*cdf0e10cSrcweir 			Reference< XInterface > x( xORB->createInstance( aSN ) );
1498*cdf0e10cSrcweir 			mxGraphicProvider.query( x );
1499*cdf0e10cSrcweir 			mxGraphicProvider = Reference< XGraphicProvider >( x, UNO_QUERY );
1500*cdf0e10cSrcweir 		}
1501*cdf0e10cSrcweir 	}
1502*cdf0e10cSrcweir 
1503*cdf0e10cSrcweir 	if( mxGraphicProvider.is() ) try
1504*cdf0e10cSrcweir 	{
1505*cdf0e10cSrcweir 		::com::sun::star::beans::PropertyValues aProps( 1 );
1506*cdf0e10cSrcweir 		aProps[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
1507*cdf0e10cSrcweir 		aProps[0].Value <<= rURL;
1508*cdf0e10cSrcweir 
1509*cdf0e10cSrcweir 		Reference< XGraphic > xGraphic( mxGraphicProvider->queryGraphic( aProps ) );
1510*cdf0e10cSrcweir 
1511*cdf0e10cSrcweir 		Graphic aGraphic( xGraphic );
1512*cdf0e10cSrcweir 		rImage = aGraphic.GetBitmapEx();
1513*cdf0e10cSrcweir 		return true;
1514*cdf0e10cSrcweir 	}
1515*cdf0e10cSrcweir 	catch( Exception& )
1516*cdf0e10cSrcweir 	{
1517*cdf0e10cSrcweir 	}
1518*cdf0e10cSrcweir 
1519*cdf0e10cSrcweir 	return false;
1520*cdf0e10cSrcweir }
1521*cdf0e10cSrcweir 
1522*cdf0e10cSrcweir // ====================================================================
1523*cdf0e10cSrcweir // class UnoTreeListBoxImpl
1524*cdf0e10cSrcweir // ====================================================================
1525*cdf0e10cSrcweir 
1526*cdf0e10cSrcweir UnoTreeListBoxImpl::UnoTreeListBoxImpl( TreeControlPeer* pPeer, Window* pParent, WinBits nWinStyle )
1527*cdf0e10cSrcweir : SvTreeListBox( pParent, nWinStyle )
1528*cdf0e10cSrcweir , mxPeer( pPeer )
1529*cdf0e10cSrcweir {
1530*cdf0e10cSrcweir 	SetStyle( WB_BORDER | WB_HASLINES |WB_HASBUTTONS | WB_HASLINESATROOT | WB_HASBUTTONSATROOT | WB_HSCROLL );
1531*cdf0e10cSrcweir 	SetNodeDefaultImages();
1532*cdf0e10cSrcweir 	SetSelectHdl( LINK(this, UnoTreeListBoxImpl, OnSelectionChangeHdl) );
1533*cdf0e10cSrcweir 	SetDeselectHdl( LINK(this, UnoTreeListBoxImpl, OnSelectionChangeHdl) );
1534*cdf0e10cSrcweir 
1535*cdf0e10cSrcweir 	SetExpandingHdl( LINK(this, UnoTreeListBoxImpl, OnExpandingHdl) );
1536*cdf0e10cSrcweir 	SetExpandedHdl( LINK(this, UnoTreeListBoxImpl, OnExpandedHdl) );
1537*cdf0e10cSrcweir 
1538*cdf0e10cSrcweir }
1539*cdf0e10cSrcweir 
1540*cdf0e10cSrcweir // --------------------------------------------------------------------
1541*cdf0e10cSrcweir 
1542*cdf0e10cSrcweir UnoTreeListBoxImpl::~UnoTreeListBoxImpl()
1543*cdf0e10cSrcweir {
1544*cdf0e10cSrcweir 	if( mxPeer.is() )
1545*cdf0e10cSrcweir 		mxPeer->disposeControl();
1546*cdf0e10cSrcweir }
1547*cdf0e10cSrcweir 
1548*cdf0e10cSrcweir // --------------------------------------------------------------------
1549*cdf0e10cSrcweir 
1550*cdf0e10cSrcweir IMPL_LINK( UnoTreeListBoxImpl, OnSelectionChangeHdl, UnoTreeListBoxImpl*, EMPTYARG )
1551*cdf0e10cSrcweir {
1552*cdf0e10cSrcweir 	if( mxPeer.is() )
1553*cdf0e10cSrcweir 		mxPeer->onSelectionChanged();
1554*cdf0e10cSrcweir 	return 0;
1555*cdf0e10cSrcweir }
1556*cdf0e10cSrcweir 
1557*cdf0e10cSrcweir // --------------------------------------------------------------------
1558*cdf0e10cSrcweir 
1559*cdf0e10cSrcweir IMPL_LINK(UnoTreeListBoxImpl, OnExpandingHdl, UnoTreeListBoxImpl*, EMPTYARG )
1560*cdf0e10cSrcweir {
1561*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = dynamic_cast< UnoTreeListEntry* >( GetHdlEntry() );
1562*cdf0e10cSrcweir 
1563*cdf0e10cSrcweir 	if( pEntry && mxPeer.is() )
1564*cdf0e10cSrcweir 	{
1565*cdf0e10cSrcweir 		return mxPeer->onExpanding( pEntry->mxNode, !IsExpanded( pEntry ) ) ? 1 : 0;
1566*cdf0e10cSrcweir 	}
1567*cdf0e10cSrcweir 	return 0;
1568*cdf0e10cSrcweir }
1569*cdf0e10cSrcweir 
1570*cdf0e10cSrcweir // --------------------------------------------------------------------
1571*cdf0e10cSrcweir 
1572*cdf0e10cSrcweir IMPL_LINK(UnoTreeListBoxImpl, OnExpandedHdl, UnoTreeListBoxImpl*, EMPTYARG )
1573*cdf0e10cSrcweir {
1574*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = dynamic_cast< UnoTreeListEntry* >( GetHdlEntry() );
1575*cdf0e10cSrcweir 	if( pEntry && mxPeer.is() )
1576*cdf0e10cSrcweir 	{
1577*cdf0e10cSrcweir 		mxPeer->onExpanded( pEntry->mxNode, IsExpanded( pEntry ) );
1578*cdf0e10cSrcweir 	}
1579*cdf0e10cSrcweir 	return 0;
1580*cdf0e10cSrcweir }
1581*cdf0e10cSrcweir 
1582*cdf0e10cSrcweir // --------------------------------------------------------------------
1583*cdf0e10cSrcweir 
1584*cdf0e10cSrcweir sal_uInt32 UnoTreeListBoxImpl::insert( SvLBoxEntry* pEntry,SvLBoxEntry* pParent,sal_uLong nPos )
1585*cdf0e10cSrcweir {
1586*cdf0e10cSrcweir 	if( pParent )
1587*cdf0e10cSrcweir 		return SvTreeListBox::Insert( pEntry, pParent, nPos );
1588*cdf0e10cSrcweir 	else
1589*cdf0e10cSrcweir 		return SvTreeListBox::Insert( pEntry, nPos );
1590*cdf0e10cSrcweir }
1591*cdf0e10cSrcweir 
1592*cdf0e10cSrcweir // --------------------------------------------------------------------
1593*cdf0e10cSrcweir 
1594*cdf0e10cSrcweir void UnoTreeListBoxImpl::RequestingChilds( SvLBoxEntry* pParent )
1595*cdf0e10cSrcweir {
1596*cdf0e10cSrcweir 	UnoTreeListEntry* pEntry = dynamic_cast< UnoTreeListEntry* >( pParent );
1597*cdf0e10cSrcweir 	if( pEntry && pEntry->mxNode.is() && mxPeer.is() )
1598*cdf0e10cSrcweir 		mxPeer->onRequestChildNodes( pEntry->mxNode );
1599*cdf0e10cSrcweir }
1600*cdf0e10cSrcweir 
1601*cdf0e10cSrcweir // --------------------------------------------------------------------
1602*cdf0e10cSrcweir 
1603*cdf0e10cSrcweir sal_Bool UnoTreeListBoxImpl::EditingEntry( SvLBoxEntry* pEntry, Selection& )
1604*cdf0e10cSrcweir {
1605*cdf0e10cSrcweir 	return mxPeer.is() ? mxPeer->onEditingEntry( dynamic_cast< UnoTreeListEntry* >( pEntry ) ) : false;
1606*cdf0e10cSrcweir }
1607*cdf0e10cSrcweir 
1608*cdf0e10cSrcweir // --------------------------------------------------------------------
1609*cdf0e10cSrcweir 
1610*cdf0e10cSrcweir sal_Bool UnoTreeListBoxImpl::EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText )
1611*cdf0e10cSrcweir {
1612*cdf0e10cSrcweir 	return mxPeer.is() ? mxPeer->onEditedEntry( dynamic_cast< UnoTreeListEntry* >( pEntry ), rNewText ) : false;
1613*cdf0e10cSrcweir }
1614*cdf0e10cSrcweir 
1615*cdf0e10cSrcweir // ====================================================================
1616*cdf0e10cSrcweir // class UnoTreeListItem
1617*cdf0e10cSrcweir // ====================================================================
1618*cdf0e10cSrcweir 
1619*cdf0e10cSrcweir UnoTreeListItem::UnoTreeListItem( SvLBoxEntry* pEntry )
1620*cdf0e10cSrcweir : SvLBoxItem( pEntry, 0 )
1621*cdf0e10cSrcweir {
1622*cdf0e10cSrcweir }
1623*cdf0e10cSrcweir 
1624*cdf0e10cSrcweir // --------------------------------------------------------------------
1625*cdf0e10cSrcweir 
1626*cdf0e10cSrcweir UnoTreeListItem::UnoTreeListItem()
1627*cdf0e10cSrcweir : SvLBoxItem()
1628*cdf0e10cSrcweir {
1629*cdf0e10cSrcweir }
1630*cdf0e10cSrcweir 
1631*cdf0e10cSrcweir // --------------------------------------------------------------------
1632*cdf0e10cSrcweir 
1633*cdf0e10cSrcweir UnoTreeListItem::~UnoTreeListItem()
1634*cdf0e10cSrcweir {
1635*cdf0e10cSrcweir }
1636*cdf0e10cSrcweir 
1637*cdf0e10cSrcweir // --------------------------------------------------------------------
1638*cdf0e10cSrcweir 
1639*cdf0e10cSrcweir sal_uInt16 UnoTreeListItem::IsA()
1640*cdf0e10cSrcweir {
1641*cdf0e10cSrcweir 	return 0;
1642*cdf0e10cSrcweir }
1643*cdf0e10cSrcweir 
1644*cdf0e10cSrcweir // --------------------------------------------------------------------
1645*cdf0e10cSrcweir 
1646*cdf0e10cSrcweir void UnoTreeListItem::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /* nFlags */, SvLBoxEntry* _pEntry)
1647*cdf0e10cSrcweir {
1648*cdf0e10cSrcweir 	Point aPos( rPos );
1649*cdf0e10cSrcweir 	if( _pEntry )
1650*cdf0e10cSrcweir 	{
1651*cdf0e10cSrcweir 		Size aSize( GetSize(&rDev,_pEntry) );
1652*cdf0e10cSrcweir 		if( !!maImage )
1653*cdf0e10cSrcweir 		{
1654*cdf0e10cSrcweir 			rDev.DrawImage( aPos, maImage, rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE );
1655*cdf0e10cSrcweir 			int nWidth = maImage.GetSizePixel().Width() + 6;
1656*cdf0e10cSrcweir 			aPos.X() += nWidth;
1657*cdf0e10cSrcweir 			aSize.Width() -= nWidth;
1658*cdf0e10cSrcweir 		}
1659*cdf0e10cSrcweir 		rDev.DrawText( Rectangle(aPos,aSize),maText, rDev.IsEnabled() ? 0 : TEXT_DRAW_DISABLE );
1660*cdf0e10cSrcweir 	}
1661*cdf0e10cSrcweir 	else
1662*cdf0e10cSrcweir 	{
1663*cdf0e10cSrcweir 		if( !!maImage )
1664*cdf0e10cSrcweir 		{
1665*cdf0e10cSrcweir 			rDev.DrawImage( aPos, maImage, rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE);
1666*cdf0e10cSrcweir 			aPos.X() += maImage.GetSizePixel().Width() + 6;
1667*cdf0e10cSrcweir 		}
1668*cdf0e10cSrcweir 		rDev.DrawText( aPos, maText);
1669*cdf0e10cSrcweir 	}
1670*cdf0e10cSrcweir }
1671*cdf0e10cSrcweir 
1672*cdf0e10cSrcweir // --------------------------------------------------------------------
1673*cdf0e10cSrcweir 
1674*cdf0e10cSrcweir SvLBoxItem* UnoTreeListItem::Create() const
1675*cdf0e10cSrcweir {
1676*cdf0e10cSrcweir 	return new UnoTreeListItem;
1677*cdf0e10cSrcweir }
1678*cdf0e10cSrcweir 
1679*cdf0e10cSrcweir // --------------------------------------------------------------------
1680*cdf0e10cSrcweir 
1681*cdf0e10cSrcweir void UnoTreeListItem::Clone( SvLBoxItem* pSource )
1682*cdf0e10cSrcweir {
1683*cdf0e10cSrcweir 	UnoTreeListItem* pSourceItem = dynamic_cast< UnoTreeListItem* >( pSource );
1684*cdf0e10cSrcweir 	if( pSourceItem )
1685*cdf0e10cSrcweir 	{
1686*cdf0e10cSrcweir 		maText = pSourceItem->maText;
1687*cdf0e10cSrcweir 		maImage = pSourceItem->maImage;
1688*cdf0e10cSrcweir 	}
1689*cdf0e10cSrcweir }
1690*cdf0e10cSrcweir 
1691*cdf0e10cSrcweir // --------------------------------------------------------------------
1692*cdf0e10cSrcweir 
1693*cdf0e10cSrcweir OUString UnoTreeListItem::GetText() const
1694*cdf0e10cSrcweir {
1695*cdf0e10cSrcweir 	return maText;
1696*cdf0e10cSrcweir }
1697*cdf0e10cSrcweir 
1698*cdf0e10cSrcweir // --------------------------------------------------------------------
1699*cdf0e10cSrcweir 
1700*cdf0e10cSrcweir void UnoTreeListItem::SetText( const OUString& rText )
1701*cdf0e10cSrcweir {
1702*cdf0e10cSrcweir 	maText = rText;
1703*cdf0e10cSrcweir }
1704*cdf0e10cSrcweir 
1705*cdf0e10cSrcweir // --------------------------------------------------------------------
1706*cdf0e10cSrcweir 
1707*cdf0e10cSrcweir void UnoTreeListItem::SetImage( const Image& rImage )
1708*cdf0e10cSrcweir {
1709*cdf0e10cSrcweir 	maImage = rImage;
1710*cdf0e10cSrcweir }
1711*cdf0e10cSrcweir 
1712*cdf0e10cSrcweir // --------------------------------------------------------------------
1713*cdf0e10cSrcweir 
1714*cdf0e10cSrcweir OUString UnoTreeListItem::GetGraphicURL() const
1715*cdf0e10cSrcweir {
1716*cdf0e10cSrcweir 	return maGraphicURL;
1717*cdf0e10cSrcweir }
1718*cdf0e10cSrcweir 
1719*cdf0e10cSrcweir // --------------------------------------------------------------------
1720*cdf0e10cSrcweir 
1721*cdf0e10cSrcweir void UnoTreeListItem::SetGraphicURL( const OUString& rGraphicURL )
1722*cdf0e10cSrcweir {
1723*cdf0e10cSrcweir 	maGraphicURL = rGraphicURL;
1724*cdf0e10cSrcweir }
1725*cdf0e10cSrcweir 
1726*cdf0e10cSrcweir // --------------------------------------------------------------------
1727*cdf0e10cSrcweir 
1728*cdf0e10cSrcweir void UnoTreeListItem::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData)
1729*cdf0e10cSrcweir {
1730*cdf0e10cSrcweir 	if( !pViewData )
1731*cdf0e10cSrcweir 		pViewData = pView->GetViewDataItem( pEntry, this );
1732*cdf0e10cSrcweir 
1733*cdf0e10cSrcweir 	pViewData->aSize = maImage.GetSizePixel();
1734*cdf0e10cSrcweir 
1735*cdf0e10cSrcweir 	const Size aTextSize(pView->GetTextWidth( maText ), pView->GetTextHeight());
1736*cdf0e10cSrcweir 	if( pViewData->aSize.Width() )
1737*cdf0e10cSrcweir 	{
1738*cdf0e10cSrcweir 		pViewData->aSize.Width() += 6 + aTextSize.Width();
1739*cdf0e10cSrcweir 		if( pViewData->aSize.Height() < aTextSize.Height() )
1740*cdf0e10cSrcweir 			pViewData->aSize.Height() = aTextSize.Height();
1741*cdf0e10cSrcweir 	}
1742*cdf0e10cSrcweir 	else
1743*cdf0e10cSrcweir 	{
1744*cdf0e10cSrcweir 		pViewData->aSize = aTextSize;
1745*cdf0e10cSrcweir 	}
1746*cdf0e10cSrcweir }
1747*cdf0e10cSrcweir 
1748*cdf0e10cSrcweir // --------------------------------------------------------------------
1749*cdf0e10cSrcweir 
1750*cdf0e10cSrcweir UnoTreeListEntry::UnoTreeListEntry( const Reference< XTreeNode >& xNode, TreeControlPeer* pPeer )
1751*cdf0e10cSrcweir : SvLBoxEntry()
1752*cdf0e10cSrcweir , mxNode( xNode )
1753*cdf0e10cSrcweir , mpPeer( pPeer )
1754*cdf0e10cSrcweir {
1755*cdf0e10cSrcweir 	if( mpPeer )
1756*cdf0e10cSrcweir 		mpPeer->addEntry( this );
1757*cdf0e10cSrcweir }
1758*cdf0e10cSrcweir 
1759*cdf0e10cSrcweir // --------------------------------------------------------------------
1760*cdf0e10cSrcweir 
1761*cdf0e10cSrcweir UnoTreeListEntry::~UnoTreeListEntry()
1762*cdf0e10cSrcweir {
1763*cdf0e10cSrcweir 	if( mpPeer )
1764*cdf0e10cSrcweir 		mpPeer->removeEntry( this );
1765*cdf0e10cSrcweir }
1766