LCOV - code coverage report
Current view: top level - svtools/source/uno - treecontrolpeer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 739 0.0 %
Date: 2012-08-25 Functions: 0 108 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1321 0.0 %

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

Generated by: LCOV version 1.10