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_GRID_CONTROL_HXX
25 #define TOOLKIT_GRID_CONTROL_HXX
26 
27 #include <com/sun/star/awt/grid/XGridControl.hpp>
28 #include <com/sun/star/awt/grid/XGridRowSelection.hpp>
29 #include <com/sun/star/view/SelectionType.hpp>
30 
31 #include <toolkit/controls/unocontrolbase.hxx>
32 #include <toolkit/controls/unocontrolmodel.hxx>
33 #include <toolkit/helper/servicenames.hxx>
34 #include <cppuhelper/implbase2.hxx>
35 #include <comphelper/sequence.hxx>
36 #include <toolkit/helper/listenermultiplexer.hxx>
37 
38 #include <boost/scoped_ptr.hpp>
39 
40 namespace toolkit
41 {
42 
43 class GridEventForwarder;
44 
45 // ===================================================================
46 // = UnoGridModel
47 // ===================================================================
48 class UnoGridModel : public UnoControlModel
49 {
50 protected:
51     ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const;
52 	::cppu::IPropertyArrayHelper&	SAL_CALL getInfoHelper();
53 
54 public:
55 	UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
56 	UnoGridModel( const UnoGridModel& rModel );
57 
58 	UnoControlModel* Clone() const;
59 
60 	// ::com::sun::star::lang::XComponent
61     void SAL_CALL dispose(  ) throw(::com::sun::star::uno::RuntimeException);
62 
63 	// ::com::sun::star::beans::XMultiPropertySet
64     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
65 
66 	// ::com::sun::star::io::XPersistObject
67     ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException);
68 
69     // OPropertySetHelper
70 	void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception);
71 
72 	// XServiceInfo
73 	DECLIMPL_SERVICEINFO_DERIVED( UnoGridModel, UnoControlModel, szServiceName_GridControlModel )
74 };
75 
76 
77 // ===================================================================
78 // = UnoGridControl
79 // ===================================================================
80 typedef ::cppu::ImplInheritanceHelper2  <   UnoControlBase
81                                         ,   ::com::sun::star::awt::grid::XGridControl
82                                         ,   ::com::sun::star::awt::grid::XGridRowSelection
83                                         >   UnoGridControl_Base;
84 class UnoGridControl : public UnoGridControl_Base
85 {
86 public:
87 	UnoGridControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
88 	::rtl::OUString				GetComponentServiceName();
89 
90 	// ::com::sun::star::lang::XComponent
91     void SAL_CALL dispose(  ) throw(::com::sun::star::uno::RuntimeException);
92 
93 	// ::com::sun::star::awt::XControl
94     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 ) throw(::com::sun::star::uno::RuntimeException);
95     sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel ) throw(::com::sun::star::uno::RuntimeException);
96 
97 	// ::com::sun::star::awt::grid::XGridControl
98 	virtual ::sal_Int32 SAL_CALL getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException);
99 	virtual ::sal_Int32 SAL_CALL getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException);
100     virtual ::sal_Int32 SAL_CALL getCurrentColumn(  ) throw (::com::sun::star::uno::RuntimeException);
101     virtual ::sal_Int32 SAL_CALL getCurrentRow(  ) throw (::com::sun::star::uno::RuntimeException);
102     virtual void SAL_CALL goToCell( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::util::VetoException);
103 
104 	// ::com::sun::star::awt::grid::XGridRowSelection
105 	virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException );
106 	virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException);
107 	virtual void SAL_CALL deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException );
108 	virtual void SAL_CALL deselectAllRows() throw (::com::sun::star::uno::RuntimeException);
109 	virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelectedRows() throw (::com::sun::star::uno::RuntimeException);
110 	virtual ::sal_Bool SAL_CALL hasSelectedRows() throw (::com::sun::star::uno::RuntimeException);
111 	virtual ::sal_Bool SAL_CALL isRowSelected(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException);
112 	virtual void SAL_CALL addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException);
113 	virtual void SAL_CALL removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException);
114 
115 	// ::com::sun::star::lang::XServiceInfo
116 	DECLIMPL_SERVICEINFO_DERIVED( UnoGridControl, UnoControlBase, szServiceName_GridControl )
117 
118 	using UnoControl::getPeer;
119 
120 protected:
121     ~UnoGridControl();
122 
123 private:
124 	::com::sun::star::view::SelectionType       mSelectionMode;
125 	SelectionListenerMultiplexer 	            m_aSelectionListeners;
126     ::boost::scoped_ptr< GridEventForwarder >   m_pEventForwarder;
127 };
128 
129 } // toolkit
130 
131 #endif // _TOOLKIT_TREE_CONTROL_HXX
132