xref: /trunk/main/svtools/source/uno/svtxgridcontrol.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 _SVT_GRIDCONTROL_HXX_
25 #define _SVT_GRIDCONTROL_HXX_
26 
27 #include <unocontroltablemodel.hxx>
28 #include <svtools/table/tablecontrol.hxx>
29 #include <com/sun/star/awt/grid/XGridControl.hpp>
30 #include <com/sun/star/awt/grid/XGridRowSelection.hpp>
31 #include <com/sun/star/awt/grid/XGridDataListener.hpp>
32 #include <com/sun/star/awt/grid/GridDataEvent.hpp>
33 #include <com/sun/star/awt/grid/GridColumnEvent.hpp>
34 #include <com/sun/star/awt/grid/XGridColumnModel.hpp>
35 #include <com/sun/star/awt/grid/XGridDataModel.hpp>
36 #include <com/sun/star/awt/grid/XGridSelectionListener.hpp>
37 #include <com/sun/star/container/XContainerListener.hpp>
38 #include <toolkit/awt/vclxwindow.hxx>
39 #include <toolkit/awt/vclxwindows.hxx>
40 #include <cppuhelper/typeprovider.hxx>
41 #include <cppuhelper/implbase4.hxx>
42 #include <toolkit/helper/listenermultiplexer.hxx>
43 
44 
45 namespace svt { namespace table {
46     class TableControl;
47 } }
48 
49 typedef ::cppu::ImplInheritanceHelper4  <   VCLXWindow
50                                         ,   ::com::sun::star::awt::grid::XGridControl
51                                         ,   ::com::sun::star::awt::grid::XGridRowSelection
52                                         ,   ::com::sun::star::awt::grid::XGridDataListener
53                                         ,   ::com::sun::star::container::XContainerListener
54                                         >   SVTXGridControl_Base;
55 class SVTXGridControl : public SVTXGridControl_Base
56 {
57 private:
58     ::boost::shared_ptr< ::svt::table::UnoControlTableModel >   m_pTableModel;
59     bool                                                        m_bTableModelInitCompleted;
60     SelectionListenerMultiplexer                                m_aSelectionListeners;
61 
62 protected:
63     virtual void    ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
64     void            ImplCallItemListeners();
65 
66 public:
67     SVTXGridControl();
68     ~SVTXGridControl();
69 
70     // XGridDataListener
71     virtual void SAL_CALL rowsInserted( const ::com::sun::star::awt::grid::GridDataEvent& Event );
72     virtual void SAL_CALL rowsRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event );
73     virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event );
74     virtual void SAL_CALL rowHeadingChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event );
75 
76     // XContainerListener
77     virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event );
78     virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event );
79     virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event );
80 
81     // XEventListener
82     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source );
83 
84     // XGridControl
85     virtual ::sal_Int32 SAL_CALL getRowAtPoint(::sal_Int32 x, ::sal_Int32 y);
86     virtual ::sal_Int32 SAL_CALL getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y);
87     virtual ::sal_Int32 SAL_CALL getCurrentColumn(  );
88     virtual ::sal_Int32 SAL_CALL getCurrentRow(  );
89     virtual void SAL_CALL goToCell( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex );
90 
91     // XGridRowSelection
92     virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex );
93     virtual void SAL_CALL selectAllRows();
94     virtual void SAL_CALL deselectRow( ::sal_Int32 i_rowIndex );
95     virtual void SAL_CALL deselectAllRows();
96     virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelectedRows();
97     virtual ::sal_Bool SAL_CALL hasSelectedRows();
98     virtual ::sal_Bool SAL_CALL isRowSelected(::sal_Int32 index);
99     virtual void SAL_CALL addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener);
100     virtual void SAL_CALL removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener);
101 
102     void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value );
103     ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName );
104     static void     ImplGetPropertyIds( std::list< sal_uInt16 > &aIds );
105 
106     // ::com::sun::star::lang::XComponent
107     void SAL_CALL dispose(  );
108 
109     // XWindow
110     void SAL_CALL setEnable( sal_Bool bEnable );
111 
112 protected:
113     // VCLXWindow
114     virtual void    SetWindow( Window* pWindow );
115 
116 private:
117     void    impl_updateColumnsFromModel_nothrow();
118     void    impl_checkTableModelInit();
119 
120     void    impl_checkColumnIndex_throw( ::svt::table::TableControl const & i_table, sal_Int32 const i_columnIndex ) const;
121     void    impl_checkRowIndex_throw( ::svt::table::TableControl const & i_table, sal_Int32 const i_rowIndex ) const;
122 };
123 #endif // _SVT_GRIDCONTROL_HXX_
124