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