xref: /trunk/main/toolkit/source/controls/tree/treecontrol.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef TOOLKIT_TREE_CONTROL_HXX
25 #define TOOLKIT_TREE_CONTROL_HXX
26 
27 #include <com/sun/star/awt/tree/XTreeControl.hpp>
28 #include <toolkit/controls/unocontrols.hxx>
29 #include <toolkit/controls/unocontrolmodel.hxx>
30 #include <toolkit/helper/servicenames.hxx>
31 #include <cppuhelper/implbase1.hxx>
32 
33 #include <toolkit/helper/listenermultiplexer.hxx>
34 
35 namespace toolkit {
36 
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::awt;
39 using namespace ::com::sun::star::lang;
40 using namespace ::com::sun::star::beans;
41 using namespace ::com::sun::star::container;
42 
43 // ===================================================================
44 // = UnoTreeModel
45 // ===================================================================
46 class UnoTreeModel : public UnoControlModel
47 {
48 protected:
49     Any     ImplGetDefaultValue( sal_uInt16 nPropId ) const;
50     ::cppu::IPropertyArrayHelper&   SAL_CALL getInfoHelper();
51 
52 public:
53     UnoTreeModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
54     UnoTreeModel( const UnoTreeModel& rModel );
55 
56     UnoControlModel* Clone() const;
57 
58     // ::com::sun::star::beans::XMultiPropertySet
59     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  );
60 
61     // ::com::sun::star::io::XPersistObject
62     ::rtl::OUString SAL_CALL getServiceName();
63 
64     // XServiceInfo
65     DECLIMPL_SERVICEINFO_DERIVED( UnoTreeModel, UnoControlModel, szServiceName_TreeControlModel )
66 };
67 
68 
69 // ===================================================================
70 // = UnoTreeControl
71 // ===================================================================
72 typedef ::cppu::ImplInheritanceHelper1< UnoControlBase, ::com::sun::star::awt::tree::XTreeControl > UnoTreeControl_Base;
73 class UnoTreeControl : public UnoTreeControl_Base
74 {
75 public:
76     UnoTreeControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
77     ::rtl::OUString             GetComponentServiceName();
78 
79     // ::com::sun::star::lang::XComponent
80     void SAL_CALL dispose(  );
81 
82     // ::com::sun::star::awt::XControl
83     void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent );
84 
85     // ::com::sun::star::view::XSelectionSupplier
86     virtual ::sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& xSelection );
87     virtual ::com::sun::star::uno::Any SAL_CALL getSelection(  );
88     virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener );
89     virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener );
90 
91     // ::com::sun::star::view::XMultiSelectionSupplier
92     virtual ::sal_Bool SAL_CALL addSelection( const ::com::sun::star::uno::Any& Selection );
93     virtual void SAL_CALL removeSelection( const ::com::sun::star::uno::Any& Selection );
94     virtual void SAL_CALL clearSelection(  );
95     virtual ::sal_Int32 SAL_CALL getSelectionCount(  );
96     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createSelectionEnumeration(  );
97     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createReverseSelectionEnumeration(  );
98 
99     // ::com::sun::star::awt::XTreeControl
100     virtual ::rtl::OUString SAL_CALL getDefaultExpandedGraphicURL();
101     virtual void SAL_CALL setDefaultExpandedGraphicURL( const ::rtl::OUString& _defaultexpandedgraphicurl );
102     virtual ::rtl::OUString SAL_CALL getDefaultCollapsedGraphicURL();
103     virtual void SAL_CALL setDefaultCollapsedGraphicURL( const ::rtl::OUString& _defaultcollapsedgraphicurl );
104     virtual ::sal_Bool SAL_CALL isNodeExpanded( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node );
105     virtual ::sal_Bool SAL_CALL isNodeCollapsed( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node );
106     virtual void SAL_CALL makeNodeVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node );
107     virtual ::sal_Bool SAL_CALL isNodeVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node );
108     virtual void SAL_CALL expandNode( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node );
109     virtual void SAL_CALL collapseNode( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node );
110     virtual void SAL_CALL addTreeExpansionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeExpansionListener >& Listener );
111     virtual void SAL_CALL removeTreeExpansionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeExpansionListener >& Listener );
112     virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode > SAL_CALL getNodeForLocation( ::sal_Int32 x, ::sal_Int32 y );
113     virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode > SAL_CALL getClosestNodeForLocation( ::sal_Int32 x, ::sal_Int32 y );
114     virtual ::com::sun::star::awt::Rectangle SAL_CALL getNodeRect( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node );
115     virtual ::sal_Bool SAL_CALL isEditing(  );
116     virtual ::sal_Bool SAL_CALL stopEditing(  );
117     virtual void SAL_CALL cancelEditing(  );
118     virtual void SAL_CALL startEditingAtNode( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node );
119     virtual void SAL_CALL addTreeEditListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeEditListener >& Listener );
120     virtual void SAL_CALL removeTreeEditListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeEditListener >& Listener );
121 
122     // ::com::sun::star::lang::XServiceInfo
123     DECLIMPL_SERVICEINFO_DERIVED( UnoTreeControl, UnoControlBase, szServiceName_TreeControl )
124 
125     using UnoControl::getPeer;
126 private:
127     TreeSelectionListenerMultiplexer maSelectionListeners;
128     TreeExpansionListenerMultiplexer maTreeExpansionListeners;
129     TreeEditListenerMultiplexer maTreeEditListeners;
130 };
131 
132 } // toolkit
133 
134 #endif // _TOOLKIT_TREE_CONTROL_HXX
135