LCOV - code coverage report
Current view: top level - toolkit/source/controls/tree - treecontrol.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 49 184 26.6 %
Date: 2015-06-13 12:38:46 Functions: 8 50 16.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <treecontrol.hxx>
      22             : 
      23             : #include <com/sun/star/awt/tree/XTreeControl.hpp>
      24             : #include <com/sun/star/awt/tree/XTreeDataModel.hpp>
      25             : #include <com/sun/star/uno/XComponentContext.hpp>
      26             : #include <com/sun/star/view/SelectionType.hpp>
      27             : #include <toolkit/helper/property.hxx>
      28             : #include <osl/diagnose.h>
      29             : 
      30             : #include "helper/unopropertyarrayhelper.hxx"
      31             : 
      32             : using namespace ::com::sun::star;
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::awt;
      35             : using namespace ::com::sun::star::awt::tree;
      36             : using namespace ::com::sun::star::lang;
      37             : using namespace ::com::sun::star::beans;
      38             : using namespace ::com::sun::star::container;
      39             : using namespace ::com::sun::star::view;
      40             : 
      41             : namespace toolkit
      42             : {
      43             : 
      44             : //  class UnoTreeModel
      45             : 
      46           4 : UnoTreeModel::UnoTreeModel( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_factory )
      47           4 :     :UnoControlModel( i_factory )
      48             : {
      49           4 :     ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
      50           4 :     ImplRegisterProperty( BASEPROPERTY_BORDER );
      51           4 :     ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
      52           4 :     ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
      53           4 :     ImplRegisterProperty( BASEPROPERTY_ENABLED );
      54           4 :     ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
      55           4 :     ImplRegisterProperty( BASEPROPERTY_FILLCOLOR );
      56           4 :     ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
      57           4 :     ImplRegisterProperty( BASEPROPERTY_HELPURL );
      58           4 :     ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
      59           4 :     ImplRegisterProperty( BASEPROPERTY_TABSTOP );
      60           4 :     ImplRegisterProperty( BASEPROPERTY_TREE_SELECTIONTYPE );
      61           4 :     ImplRegisterProperty( BASEPROPERTY_TREE_EDITABLE );
      62           4 :     ImplRegisterProperty( BASEPROPERTY_TREE_DATAMODEL );
      63           4 :     ImplRegisterProperty( BASEPROPERTY_TREE_ROOTDISPLAYED );
      64           4 :     ImplRegisterProperty( BASEPROPERTY_TREE_SHOWSHANDLES );
      65           4 :     ImplRegisterProperty( BASEPROPERTY_TREE_SHOWSROOTHANDLES );
      66           4 :     ImplRegisterProperty( BASEPROPERTY_ROW_HEIGHT );
      67           4 :     ImplRegisterProperty( BASEPROPERTY_TREE_INVOKESSTOPNODEEDITING );
      68           4 :     ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION );
      69           4 : }
      70             : 
      71           1 : UnoTreeModel::UnoTreeModel( const UnoTreeModel& rModel )
      72           1 : : UnoControlModel( rModel )
      73             : {
      74           1 : }
      75             : 
      76           1 : UnoControlModel* UnoTreeModel::Clone() const
      77             : {
      78           1 :     return new UnoTreeModel( *this );
      79             : }
      80             : 
      81           1 : OUString UnoTreeModel::getServiceName() throw(RuntimeException, std::exception)
      82             : {
      83           1 :     return OUString( "com.sun.star.awt.tree.TreeControlModel" );
      84             : }
      85             : 
      86         100 : Any UnoTreeModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
      87             : {
      88         100 :     switch( nPropId )
      89             :     {
      90             :     case BASEPROPERTY_TREE_SELECTIONTYPE:
      91           5 :         return Any( SelectionType_NONE );
      92             :     case BASEPROPERTY_ROW_HEIGHT:
      93           5 :         return Any( sal_Int32( 0 ) );
      94             :     case BASEPROPERTY_TREE_DATAMODEL:
      95           5 :         return Any( Reference< XTreeDataModel >( 0 ) );
      96             :     case BASEPROPERTY_TREE_EDITABLE:
      97             :     case BASEPROPERTY_TREE_INVOKESSTOPNODEEDITING:
      98          10 :         return Any( sal_False );
      99             :     case BASEPROPERTY_TREE_ROOTDISPLAYED:
     100             :     case BASEPROPERTY_TREE_SHOWSROOTHANDLES:
     101             :     case BASEPROPERTY_TREE_SHOWSHANDLES:
     102          15 :         return Any( sal_True );
     103             :     case BASEPROPERTY_DEFAULTCONTROL:
     104           5 :         return uno::makeAny( OUString( "com.sun.star.awt.tree.TreeControl" ) );
     105             :     default:
     106          55 :         return UnoControlModel::ImplGetDefaultValue( nPropId );
     107             :     }
     108             : }
     109             : 
     110         482 : ::cppu::IPropertyArrayHelper& UnoTreeModel::getInfoHelper()
     111             : {
     112             :     static UnoPropertyArrayHelper* pHelper = NULL;
     113         482 :     if ( !pHelper )
     114             :     {
     115           1 :         Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
     116           1 :         pHelper = new UnoPropertyArrayHelper( aIDs );
     117             :     }
     118         482 :     return *pHelper;
     119             : }
     120             : 
     121             : // XMultiPropertySet
     122          11 : Reference< XPropertySetInfo > UnoTreeModel::getPropertySetInfo(  ) throw(RuntimeException, std::exception)
     123             : {
     124          11 :     static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
     125          11 :     return xInfo;
     126             : }
     127             : 
     128             : }
     129             : 
     130             : namespace {
     131             : 
     132             : typedef ::cppu::ImplInheritanceHelper1< UnoControlBase, css::awt::tree::XTreeControl > UnoTreeControl_Base;
     133           0 : class UnoTreeControl : public UnoTreeControl_Base
     134             : {
     135             : public:
     136             :     UnoTreeControl();
     137             :     OUString GetComponentServiceName() SAL_OVERRIDE;
     138             : 
     139             :     // css::lang::XComponent
     140             :     void SAL_CALL dispose(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     141             : 
     142             :     // css::awt::XControl
     143             :     void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     144             : 
     145             :     // css::view::XSelectionSupplier
     146             :     virtual sal_Bool SAL_CALL select( const css::uno::Any& xSelection ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     147             :     virtual css::uno::Any SAL_CALL getSelection(  ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     148             :     virtual void SAL_CALL addSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     149             :     virtual void SAL_CALL removeSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     150             : 
     151             :     // css::view::XMultiSelectionSupplier
     152             :     virtual sal_Bool SAL_CALL addSelection( const css::uno::Any& Selection ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     153             :     virtual void SAL_CALL removeSelection( const css::uno::Any& Selection ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     154             :     virtual void SAL_CALL clearSelection(  ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     155             :     virtual ::sal_Int32 SAL_CALL getSelectionCount(  ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     156             :     virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSelectionEnumeration(  ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     157             :     virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createReverseSelectionEnumeration(  ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     158             : 
     159             :     // css::awt::XTreeControl
     160             :     virtual OUString SAL_CALL getDefaultExpandedGraphicURL() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     161             :     virtual void SAL_CALL setDefaultExpandedGraphicURL( const OUString& _defaultexpandedgraphicurl ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     162             :     virtual OUString SAL_CALL getDefaultCollapsedGraphicURL() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     163             :     virtual void SAL_CALL setDefaultCollapsedGraphicURL( const OUString& _defaultcollapsedgraphicurl ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     164             :     virtual sal_Bool SAL_CALL isNodeExpanded( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     165             :     virtual sal_Bool SAL_CALL isNodeCollapsed( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     166             :     virtual void SAL_CALL makeNodeVisible( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) throw (css::lang::IllegalArgumentException, css::awt::tree::ExpandVetoException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     167             :     virtual sal_Bool SAL_CALL isNodeVisible( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     168             :     virtual void SAL_CALL expandNode( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) throw (css::lang::IllegalArgumentException, css::awt::tree::ExpandVetoException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     169             :     virtual void SAL_CALL collapseNode( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) throw (css::lang::IllegalArgumentException, css::awt::tree::ExpandVetoException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     170             :     virtual void SAL_CALL addTreeExpansionListener( const css::uno::Reference< css::awt::tree::XTreeExpansionListener >& Listener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     171             :     virtual void SAL_CALL removeTreeExpansionListener( const css::uno::Reference< css::awt::tree::XTreeExpansionListener >& Listener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     172             :     virtual css::uno::Reference< css::awt::tree::XTreeNode > SAL_CALL getNodeForLocation( ::sal_Int32 x, ::sal_Int32 y ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     173             :     virtual css::uno::Reference< css::awt::tree::XTreeNode > SAL_CALL getClosestNodeForLocation( ::sal_Int32 x, ::sal_Int32 y ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     174             :     virtual css::awt::Rectangle SAL_CALL getNodeRect( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     175             :     virtual sal_Bool SAL_CALL isEditing(  ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     176             :     virtual sal_Bool SAL_CALL stopEditing(  ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     177             :     virtual void SAL_CALL cancelEditing(  ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     178             :     virtual void SAL_CALL startEditingAtNode( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     179             :     virtual void SAL_CALL addTreeEditListener( const css::uno::Reference< css::awt::tree::XTreeEditListener >& Listener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     180             :     virtual void SAL_CALL removeTreeEditListener( const css::uno::Reference< css::awt::tree::XTreeEditListener >& Listener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     181             : 
     182             :     // css::lang::XServiceInfo
     183           0 :     DECLIMPL_SERVICEINFO_DERIVED( UnoTreeControl, UnoControlBase, "com.sun.star.awt.tree.TreeControl" )
     184             : 
     185             :     using UnoControl::getPeer;
     186             : private:
     187             :     TreeSelectionListenerMultiplexer maSelectionListeners;
     188             :     TreeExpansionListenerMultiplexer maTreeExpansionListeners;
     189             :     TreeEditListenerMultiplexer maTreeEditListeners;
     190             : };
     191             : 
     192           0 : UnoTreeControl::UnoTreeControl()
     193             : : UnoTreeControl_Base()
     194             : , maSelectionListeners( *this )
     195             : , maTreeExpansionListeners( *this )
     196           0 : , maTreeEditListeners( *this )
     197             : {
     198           0 : }
     199             : 
     200           0 : OUString UnoTreeControl::GetComponentServiceName()
     201             : {
     202           0 :     return OUString("Tree");
     203             : }
     204             : 
     205             : 
     206             : // ::com::sun::star::view::XSelectionSupplier
     207             : 
     208             : 
     209           0 : sal_Bool SAL_CALL UnoTreeControl::select( const Any& rSelection ) throw (IllegalArgumentException, RuntimeException, std::exception)
     210             : {
     211           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->select( rSelection );
     212             : }
     213             : 
     214             : 
     215             : 
     216           0 : Any SAL_CALL UnoTreeControl::getSelection() throw (RuntimeException, std::exception)
     217             : {
     218           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->getSelection();
     219             : }
     220             : 
     221             : 
     222             : 
     223           0 : void SAL_CALL UnoTreeControl::addSelectionChangeListener( const Reference< XSelectionChangeListener >& xListener ) throw (RuntimeException, std::exception)
     224             : {
     225           0 :     maSelectionListeners.addInterface( xListener );
     226           0 :     if( getPeer().is() && (maSelectionListeners.getLength() == 1) )
     227             :     {
     228             :         // maSelectionListeners acts as a proxy,
     229             :         // add it to the peer if this is the first listener added to that proxy
     230           0 :         Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->addSelectionChangeListener(&maSelectionListeners);
     231             :     }
     232           0 : }
     233             : 
     234             : 
     235             : 
     236           0 : void SAL_CALL UnoTreeControl::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& xListener ) throw (RuntimeException, std::exception)
     237             : {
     238           0 :     if( getPeer().is() && (maSelectionListeners.getLength() == 1) )
     239             :     {
     240             :         // maSelectionListeners acts as a proxy,
     241             :         // remove it from the peer if this is the last listener removed from that proxy
     242           0 :         Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->removeSelectionChangeListener(&maSelectionListeners);
     243             :     }
     244           0 :     maSelectionListeners.removeInterface( xListener );
     245           0 : }
     246             : 
     247             : 
     248             : // ::com::sun::star::view::XMultiSelectionSupplier
     249             : 
     250             : 
     251           0 : sal_Bool SAL_CALL UnoTreeControl::addSelection( const Any& rSelection ) throw (IllegalArgumentException, RuntimeException, std::exception)
     252             : {
     253           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->addSelection(rSelection);
     254             : }
     255             : 
     256             : 
     257             : 
     258           0 : void SAL_CALL UnoTreeControl::removeSelection( const Any& rSelection ) throw (IllegalArgumentException, RuntimeException, std::exception)
     259             : {
     260           0 :     Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->removeSelection(rSelection);
     261           0 : }
     262             : 
     263             : 
     264             : 
     265           0 : void SAL_CALL UnoTreeControl::clearSelection() throw (RuntimeException, std::exception)
     266             : {
     267           0 :     Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->clearSelection();
     268           0 : }
     269             : 
     270             : 
     271             : 
     272           0 : sal_Int32 SAL_CALL UnoTreeControl::getSelectionCount() throw (RuntimeException, std::exception)
     273             : {
     274           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->getSelectionCount();
     275             : }
     276             : 
     277             : 
     278             : 
     279           0 : Reference< XEnumeration > SAL_CALL UnoTreeControl::createSelectionEnumeration() throw (RuntimeException, std::exception)
     280             : {
     281           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->createSelectionEnumeration();
     282             : }
     283             : 
     284             : 
     285             : 
     286           0 : Reference< XEnumeration > SAL_CALL UnoTreeControl::createReverseSelectionEnumeration() throw (RuntimeException, std::exception)
     287             : {
     288           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->createReverseSelectionEnumeration();
     289             : }
     290             : 
     291             : 
     292             : // XTreeControl
     293             : 
     294             : 
     295           0 : OUString SAL_CALL UnoTreeControl::getDefaultExpandedGraphicURL() throw (RuntimeException, std::exception)
     296             : {
     297           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->getDefaultExpandedGraphicURL();
     298             : }
     299             : 
     300             : 
     301             : 
     302           0 : void SAL_CALL UnoTreeControl::setDefaultExpandedGraphicURL( const OUString& _defaultexpansiongraphicurl ) throw (RuntimeException, std::exception)
     303             : {
     304           0 :     Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->setDefaultExpandedGraphicURL(_defaultexpansiongraphicurl);
     305           0 : }
     306             : 
     307             : 
     308             : 
     309           0 : OUString SAL_CALL UnoTreeControl::getDefaultCollapsedGraphicURL() throw (RuntimeException, std::exception)
     310             : {
     311           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->getDefaultCollapsedGraphicURL();
     312             : }
     313             : 
     314             : 
     315             : 
     316           0 : void SAL_CALL UnoTreeControl::setDefaultCollapsedGraphicURL( const OUString& _defaultcollapsedgraphicurl ) throw (RuntimeException, std::exception)
     317             : {
     318           0 :     Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->setDefaultCollapsedGraphicURL(_defaultcollapsedgraphicurl);
     319           0 : }
     320             : 
     321             : 
     322             : 
     323           0 : sal_Bool SAL_CALL UnoTreeControl::isNodeExpanded( const Reference< XTreeNode >& xNode ) throw (RuntimeException, IllegalArgumentException, std::exception)
     324             : {
     325           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->isNodeExpanded(xNode);
     326             : }
     327             : 
     328             : 
     329             : 
     330           0 : sal_Bool SAL_CALL UnoTreeControl::isNodeCollapsed( const Reference< XTreeNode >& xNode ) throw (RuntimeException, IllegalArgumentException, std::exception)
     331             : {
     332           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->isNodeCollapsed(xNode);
     333             : }
     334             : 
     335             : 
     336             : 
     337           0 : void SAL_CALL UnoTreeControl::makeNodeVisible( const Reference< XTreeNode >& xNode ) throw (RuntimeException, ExpandVetoException, IllegalArgumentException, std::exception)
     338             : {
     339           0 :     Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->makeNodeVisible(xNode);
     340           0 : }
     341             : 
     342             : 
     343             : 
     344           0 : sal_Bool SAL_CALL UnoTreeControl::isNodeVisible( const Reference< XTreeNode >& xNode ) throw (RuntimeException, IllegalArgumentException, std::exception)
     345             : {
     346           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->isNodeVisible(xNode);
     347             : }
     348             : 
     349             : 
     350             : 
     351           0 : void SAL_CALL UnoTreeControl::expandNode( const Reference< XTreeNode >& xNode ) throw (RuntimeException, ExpandVetoException, IllegalArgumentException, std::exception)
     352             : {
     353           0 :     Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->expandNode(xNode);
     354           0 : }
     355             : 
     356             : 
     357             : 
     358           0 : void SAL_CALL UnoTreeControl::collapseNode( const Reference< XTreeNode >& xNode ) throw (RuntimeException, ExpandVetoException, IllegalArgumentException, std::exception)
     359             : {
     360           0 :     Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->collapseNode(xNode);
     361           0 : }
     362             : 
     363             : 
     364             : 
     365           0 : void SAL_CALL UnoTreeControl::addTreeExpansionListener( const Reference< XTreeExpansionListener >& xListener ) throw (RuntimeException, std::exception)
     366             : {
     367           0 :     maTreeExpansionListeners.addInterface( xListener );
     368           0 :     if( getPeer().is() && (maTreeExpansionListeners.getLength() == 1) )
     369             :     {
     370             :         // maSelectionListeners acts as a proxy,
     371             :         // add it to the peer if this is the first listener added to that proxy
     372           0 :         Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->addTreeExpansionListener(&maTreeExpansionListeners);
     373             :     }
     374           0 : }
     375             : 
     376             : 
     377             : 
     378           0 : void SAL_CALL UnoTreeControl::removeTreeExpansionListener( const Reference< XTreeExpansionListener >& xListener ) throw (RuntimeException, std::exception)
     379             : {
     380           0 :     if( getPeer().is() && (maTreeExpansionListeners.getLength() == 1) )
     381             :     {
     382             :         // maSelectionListeners acts as a proxy,
     383             :         // remove it from the peer if this is the last listener removed from that proxy
     384           0 :         Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->removeTreeExpansionListener(&maTreeExpansionListeners);
     385             :     }
     386           0 :     maTreeExpansionListeners.removeInterface( xListener );
     387           0 : }
     388             : 
     389             : 
     390             : 
     391           0 : Reference< XTreeNode > SAL_CALL UnoTreeControl::getNodeForLocation( sal_Int32 x, sal_Int32 y ) throw (RuntimeException, std::exception)
     392             : {
     393           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->getNodeForLocation(x,y);
     394             : }
     395             : 
     396             : 
     397             : 
     398           0 : Reference< XTreeNode > SAL_CALL UnoTreeControl::getClosestNodeForLocation( sal_Int32 x, sal_Int32 y ) throw (RuntimeException, std::exception)
     399             : {
     400           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->getClosestNodeForLocation(x,y);
     401             : }
     402             : 
     403             : 
     404             : 
     405           0 : awt::Rectangle SAL_CALL UnoTreeControl::getNodeRect( const Reference< XTreeNode >& Node ) throw (IllegalArgumentException, RuntimeException, std::exception)
     406             : {
     407           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->getNodeRect( Node );
     408             : }
     409             : 
     410             : 
     411             : 
     412           0 : sal_Bool SAL_CALL UnoTreeControl::isEditing(  ) throw (RuntimeException, std::exception)
     413             : {
     414           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->isEditing();
     415             : }
     416             : 
     417             : 
     418             : 
     419           0 : sal_Bool SAL_CALL UnoTreeControl::stopEditing() throw (RuntimeException, std::exception)
     420             : {
     421           0 :     return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->stopEditing();
     422             : }
     423             : 
     424             : 
     425             : 
     426           0 : void SAL_CALL UnoTreeControl::cancelEditing() throw (RuntimeException, std::exception)
     427             : {
     428           0 :     Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->cancelEditing();
     429           0 : }
     430             : 
     431             : 
     432             : 
     433           0 : void SAL_CALL UnoTreeControl::startEditingAtNode( const Reference< XTreeNode >& xNode ) throw (IllegalArgumentException, RuntimeException, std::exception)
     434             : {
     435           0 :     Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->startEditingAtNode(xNode);
     436           0 : }
     437             : 
     438             : 
     439             : 
     440           0 : void SAL_CALL UnoTreeControl::addTreeEditListener( const Reference< XTreeEditListener >& xListener ) throw (RuntimeException, std::exception)
     441             : {
     442           0 :     maTreeEditListeners.addInterface( xListener );
     443           0 :     if( getPeer().is() && (maTreeEditListeners.getLength() == 1) )
     444             :     {
     445             :         // maSelectionListeners acts as a proxy,
     446             :         // add it to the peer if this is the first listener added to that proxy
     447           0 :         Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->addTreeEditListener(&maTreeEditListeners);
     448             :     }
     449           0 : }
     450             : 
     451             : 
     452             : 
     453           0 : void SAL_CALL UnoTreeControl::removeTreeEditListener( const Reference< XTreeEditListener >& xListener ) throw (RuntimeException, std::exception)
     454             : {
     455           0 :     if( getPeer().is() && (maTreeEditListeners.getLength() == 1) )
     456             :     {
     457             :         // maSelectionListeners acts as a proxy,
     458             :         // remove it from the peer if this is the last listener removed from that proxy
     459           0 :         Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->removeTreeEditListener(&maTreeEditListeners);
     460             :     }
     461           0 :     maTreeEditListeners.removeInterface( xListener );
     462           0 : }
     463             : 
     464             : 
     465             : // XComponent
     466             : 
     467             : 
     468           0 : void SAL_CALL UnoTreeControl::dispose(  ) throw(RuntimeException, std::exception)
     469             : {
     470           0 :     lang::EventObject aEvt;
     471           0 :     aEvt.Source = static_cast< ::cppu::OWeakObject* >(this);
     472           0 :     maSelectionListeners.disposeAndClear( aEvt );
     473           0 :     maTreeExpansionListeners.disposeAndClear( aEvt );
     474           0 :     UnoControl::dispose();
     475           0 : }
     476             : 
     477           0 : void UnoTreeControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException, std::exception)
     478             : {
     479           0 :     UnoControlBase::createPeer( rxToolkit, rParentPeer );
     480             : 
     481           0 :     Reference< XTreeControl >  xTree( getPeer(), UNO_QUERY_THROW );
     482           0 :     if( maSelectionListeners.getLength() )
     483           0 :         xTree->addSelectionChangeListener( &maSelectionListeners );
     484           0 :     if( maTreeExpansionListeners.getLength() )
     485           0 :         xTree->addTreeExpansionListener( &maTreeExpansionListeners );
     486           0 : }
     487             : 
     488             : }
     489             : 
     490           0 : void SAL_CALL TreeEditListenerMultiplexer::nodeEditing( const Reference< XTreeNode >& Node ) throw (RuntimeException, ::com::sun::star::util::VetoException, std::exception)
     491             : {
     492           0 :     ::cppu::OInterfaceIteratorHelper aIt( *this );
     493           0 :     while( aIt.hasMoreElements() )
     494             :     {
     495           0 :         Reference< XTreeEditListener > xListener(static_cast< XTreeEditListener* >( aIt.next() ) );
     496             :         try
     497             :         {
     498           0 :             xListener->nodeEditing( Node );
     499             :         }
     500           0 :         catch( const DisposedException& e )
     501             :         {
     502             :             OSL_ENSURE( e.Context.is(), "caught DisposedException with empty Context field" );
     503           0 :             if ( e.Context == xListener || !e.Context.is() )
     504           0 :                 aIt.remove();
     505             :         }
     506           0 :         catch( const RuntimeException& e )
     507             :         {
     508             :             (void)e;
     509             :             DISPLAY_EXCEPTION( TreeEditListenerMultiplexer, nodeEditing, e )
     510             :         }
     511           0 :     }
     512           0 : }
     513             : 
     514           0 : void SAL_CALL TreeEditListenerMultiplexer::nodeEdited( const Reference< XTreeNode >& Node, const OUString& NewText ) throw (RuntimeException, std::exception)
     515             : {
     516           0 :     ::cppu::OInterfaceIteratorHelper aIt( *this );
     517           0 :     while( aIt.hasMoreElements() )
     518             :     {
     519           0 :         Reference< XTreeEditListener > xListener( static_cast< XTreeEditListener* >( aIt.next() ) );
     520             :         try
     521             :         {
     522           0 :             xListener->nodeEdited( Node, NewText );
     523             :         }
     524           0 :         catch( const DisposedException& e )
     525             :         {
     526             :             OSL_ENSURE( e.Context.is(), "caught DisposedException with empty Context field" );
     527           0 :             if ( e.Context == xListener || !e.Context.is() )
     528           0 :                 aIt.remove();
     529             :         }
     530           0 :         catch( const RuntimeException& e )
     531             :         {
     532             :             (void)e;
     533             :             DISPLAY_EXCEPTION( TreeEditListenerMultiplexer, nodeEdited, e )
     534             :         }
     535           0 :     }
     536           0 : }
     537             : 
     538             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     539           3 : stardiv_Toolkit_TreeControlModel_get_implementation(
     540             :     css::uno::XComponentContext *context,
     541             :     css::uno::Sequence<css::uno::Any> const &)
     542             : {
     543           3 :     return cppu::acquire(new toolkit::UnoTreeModel(context));
     544             : }
     545             : 
     546             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     547           0 : stardiv_Toolkit_TreeControl_get_implementation(
     548             :     css::uno::XComponentContext *,
     549             :     css::uno::Sequence<css::uno::Any> const &)
     550             : {
     551           0 :     return cppu::acquire(new UnoTreeControl());
     552             : }
     553             : 
     554             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11