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

Generated by: LCOV version 1.10