1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _TREE_CONTROL_PEER_HXX_ 29*cdf0e10cSrcweir #define _TREE_CONTROL_PEER_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/awt/tree/XTreeControl.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/awt/tree/XTreeDataModel.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicProvider.hpp> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx> 36*cdf0e10cSrcweir #include <toolkit/awt/vclxwindows.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <vcl/image.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir //#include <comphelper/uno3.hxx> 41*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir class UnoTreeListEntry; 45*cdf0e10cSrcweir class TreeControlPeer; 46*cdf0e10cSrcweir class UnoTreeListBoxImpl; 47*cdf0e10cSrcweir class TreeNodeMap; 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir // ---------------------------------------------------- 50*cdf0e10cSrcweir // class TreeControlPeer 51*cdf0e10cSrcweir // ---------------------------------------------------- 52*cdf0e10cSrcweir class TreeControlPeer : public ::cppu::ImplInheritanceHelper2< VCLXWindow, ::com::sun::star::awt::tree::XTreeControl, ::com::sun::star::awt::tree::XTreeDataModelListener > 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir friend class UnoTreeListBoxImpl; 55*cdf0e10cSrcweir friend class UnoTreeListEntry; 56*cdf0e10cSrcweir public: 57*cdf0e10cSrcweir TreeControlPeer(); 58*cdf0e10cSrcweir virtual ~TreeControlPeer(); 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir Window* createVclControl( Window* pParent, sal_Int64 nWinStyle ); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir // VCLXWindow 63*cdf0e10cSrcweir virtual void SetWindow( Window* pWindow ); 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir // ::com::sun::star::view::XSelectionSupplier 66*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& xSelection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 67*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getSelection( ) throw (::com::sun::star::uno::RuntimeException); 68*cdf0e10cSrcweir virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 69*cdf0e10cSrcweir virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir // ::com::sun::star::view::XMultiSelectionSupplier 72*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL addSelection( const ::com::sun::star::uno::Any& Selection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 73*cdf0e10cSrcweir virtual void SAL_CALL removeSelection( const ::com::sun::star::uno::Any& Selection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 74*cdf0e10cSrcweir virtual void SAL_CALL clearSelection( ) throw (::com::sun::star::uno::RuntimeException); 75*cdf0e10cSrcweir virtual ::sal_Int32 SAL_CALL getSelectionCount( ) throw (::com::sun::star::uno::RuntimeException); 76*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createSelectionEnumeration( ) throw (::com::sun::star::uno::RuntimeException); 77*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createReverseSelectionEnumeration( ) throw (::com::sun::star::uno::RuntimeException); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir // ::com::sun::star::awt::XTreeControl 80*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getDefaultExpandedGraphicURL() throw (::com::sun::star::uno::RuntimeException); 81*cdf0e10cSrcweir virtual void SAL_CALL setDefaultExpandedGraphicURL( const ::rtl::OUString& _defaultexpandedgraphicurl ) throw (::com::sun::star::uno::RuntimeException); 82*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getDefaultCollapsedGraphicURL() throw (::com::sun::star::uno::RuntimeException); 83*cdf0e10cSrcweir virtual void SAL_CALL setDefaultCollapsedGraphicURL( const ::rtl::OUString& _defaultcollapsedgraphicurl ) throw (::com::sun::star::uno::RuntimeException); 84*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL isNodeExpanded( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 85*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL isNodeCollapsed( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 86*cdf0e10cSrcweir virtual void SAL_CALL makeNodeVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::awt::tree::ExpandVetoException, ::com::sun::star::uno::RuntimeException); 87*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL isNodeVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 88*cdf0e10cSrcweir virtual void SAL_CALL expandNode( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::awt::tree::ExpandVetoException, ::com::sun::star::uno::RuntimeException); 89*cdf0e10cSrcweir virtual void SAL_CALL collapseNode( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::awt::tree::ExpandVetoException, ::com::sun::star::uno::RuntimeException); 90*cdf0e10cSrcweir virtual void SAL_CALL addTreeExpansionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeExpansionListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); 91*cdf0e10cSrcweir virtual void SAL_CALL removeTreeExpansionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeExpansionListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); 92*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode > SAL_CALL getNodeForLocation( ::sal_Int32 x, ::sal_Int32 y ) throw (::com::sun::star::uno::RuntimeException); 93*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode > SAL_CALL getClosestNodeForLocation( ::sal_Int32 x, ::sal_Int32 y ) throw (::com::sun::star::uno::RuntimeException); 94*cdf0e10cSrcweir virtual ::com::sun::star::awt::Rectangle SAL_CALL getNodeRect( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 95*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL isEditing( ) throw (::com::sun::star::uno::RuntimeException); 96*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL stopEditing( ) throw (::com::sun::star::uno::RuntimeException); 97*cdf0e10cSrcweir virtual void SAL_CALL cancelEditing( ) throw (::com::sun::star::uno::RuntimeException); 98*cdf0e10cSrcweir virtual void SAL_CALL startEditingAtNode( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 99*cdf0e10cSrcweir virtual void SAL_CALL addTreeEditListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeEditListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); 100*cdf0e10cSrcweir virtual void SAL_CALL removeTreeEditListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeEditListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir // ::com::sun::star::awt::tree::TreeDataModelListener 103*cdf0e10cSrcweir virtual void SAL_CALL treeNodesChanged( const ::com::sun::star::awt::tree::TreeDataModelEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); 104*cdf0e10cSrcweir virtual void SAL_CALL treeNodesInserted( const ::com::sun::star::awt::tree::TreeDataModelEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); 105*cdf0e10cSrcweir virtual void SAL_CALL treeNodesRemoved( const ::com::sun::star::awt::tree::TreeDataModelEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); 106*cdf0e10cSrcweir virtual void SAL_CALL treeStructureChanged( const ::com::sun::star::awt::tree::TreeDataModelEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir // XEventListener 109*cdf0e10cSrcweir void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir // ::com::sun::star::awt::XLayoutConstrains 112*cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL getMinimumSize() throw(::com::sun::star::uno::RuntimeException); 113*cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL getPreferredSize() throw(::com::sun::star::uno::RuntimeException); 114*cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw(::com::sun::star::uno::RuntimeException); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir // ::com::sun::star::awt::XVclWindowPeer 117*cdf0e10cSrcweir void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); 118*cdf0e10cSrcweir ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir private: 121*cdf0e10cSrcweir UnoTreeListEntry* getEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& xNode, bool bThrow = true ) throw (::com::sun::star::lang::IllegalArgumentException ); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir void disposeControl(); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir bool onEditingEntry( UnoTreeListEntry* pEntry ); 126*cdf0e10cSrcweir bool onEditedEntry( UnoTreeListEntry* pEntry, const XubString& rNewText ); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir void eraseTree( UnoTreeListBoxImpl& rTree ); 129*cdf0e10cSrcweir void fillTree( UnoTreeListBoxImpl& rTree, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeDataModel >& xDataModel ); 130*cdf0e10cSrcweir void addNode( UnoTreeListBoxImpl& rTree, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& xNode, UnoTreeListEntry* pParentEntry ); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir UnoTreeListEntry* createEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& xNode, UnoTreeListEntry* pParent, sal_uLong nPos = LIST_APPEND ); 133*cdf0e10cSrcweir bool updateEntry( UnoTreeListEntry* pEntry ); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir void updateTree( const ::com::sun::star::awt::tree::TreeDataModelEvent& rEvent, bool bRecursive ); 136*cdf0e10cSrcweir void updateNode( UnoTreeListBoxImpl& rTree, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& xNode, bool bRecursive ); 137*cdf0e10cSrcweir void updateChildNodes( UnoTreeListBoxImpl& rTree, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& xParentNode, UnoTreeListEntry* pParentEntry ); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir ::rtl::OUString getEntryString( const ::com::sun::star::uno::Any& rValue ); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir UnoTreeListBoxImpl& getTreeListBoxOrThrow() const throw (::com::sun::star::uno::RuntimeException ); 142*cdf0e10cSrcweir void ChangeNodesSelection( const ::com::sun::star::uno::Any& rSelection, bool bSelect, bool bSetSelection ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException ); 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir void onChangeDataModel( UnoTreeListBoxImpl& rTree, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeDataModel >& xDataModel ); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir void onSelectionChanged(); 147*cdf0e10cSrcweir void onRequestChildNodes( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& xNode ); 148*cdf0e10cSrcweir bool onExpanding( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& xNode, bool bExpanding ); 149*cdf0e10cSrcweir void onExpanded( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& xNode, bool bExpanding ); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir void onChangeRootDisplayed( sal_Bool bIsRootDisplayed ); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir void addEntry( UnoTreeListEntry* pEntry ); 154*cdf0e10cSrcweir void removeEntry( UnoTreeListEntry* pEntry ); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir bool loadImage( const ::rtl::OUString& rURL, Image& rImage ); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir private: 159*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeDataModel >mxDataModel; 160*cdf0e10cSrcweir TreeSelectionListenerMultiplexer maSelectionListeners; 161*cdf0e10cSrcweir TreeExpansionListenerMultiplexer maTreeExpansionListeners; 162*cdf0e10cSrcweir TreeEditListenerMultiplexer maTreeEditListeners; 163*cdf0e10cSrcweir sal_Bool mbIsRootDisplayed; 164*cdf0e10cSrcweir UnoTreeListBoxImpl* mpTreeImpl; 165*cdf0e10cSrcweir sal_Int32 mnEditLock; 166*cdf0e10cSrcweir ::rtl::OUString msDefaultCollapsedGraphicURL; 167*cdf0e10cSrcweir ::rtl::OUString msDefaultExpandedGraphicURL; 168*cdf0e10cSrcweir Image maDefaultExpandedImage; 169*cdf0e10cSrcweir Image maDefaultCollapsedImage; 170*cdf0e10cSrcweir TreeNodeMap* mpTreeNodeMap; 171*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicProvider > mxGraphicProvider; 172*cdf0e10cSrcweir }; 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir #endif // _TREE_CONTROL_PEER_HXX_ 175