LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svtools/source/uno - treecontrolpeer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 746 0.1 %
Date: 2013-07-09 Functions: 2 108 1.9 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10