1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SVT_GRIDCONTROL_HXX_ 29 #define _SVT_GRIDCONTROL_HXX_ 30 31 #include <unocontroltablemodel.hxx> 32 #include <svtools/table/tablecontrol.hxx> 33 #include <com/sun/star/awt/grid/XGridControl.hpp> 34 #include <com/sun/star/awt/grid/XGridRowSelection.hpp> 35 #include <com/sun/star/awt/grid/XGridDataListener.hpp> 36 #include <com/sun/star/awt/grid/GridDataEvent.hpp> 37 #include <com/sun/star/awt/grid/GridColumnEvent.hpp> 38 #include <com/sun/star/awt/grid/XGridColumnModel.hpp> 39 #include <com/sun/star/awt/grid/XGridDataModel.hpp> 40 #include <com/sun/star/awt/grid/XGridSelectionListener.hpp> 41 #include <com/sun/star/container/XContainerListener.hpp> 42 #include <toolkit/awt/vclxwindow.hxx> 43 #include <toolkit/awt/vclxwindows.hxx> 44 #include <cppuhelper/typeprovider.hxx> 45 #include <cppuhelper/implbase4.hxx> 46 #include <toolkit/helper/listenermultiplexer.hxx> 47 48 49 namespace svt { namespace table { 50 class TableControl; 51 } } 52 53 typedef ::cppu::ImplInheritanceHelper4 < VCLXWindow 54 , ::com::sun::star::awt::grid::XGridControl 55 , ::com::sun::star::awt::grid::XGridRowSelection 56 , ::com::sun::star::awt::grid::XGridDataListener 57 , ::com::sun::star::container::XContainerListener 58 > SVTXGridControl_Base; 59 class SVTXGridControl : public SVTXGridControl_Base 60 { 61 private: 62 ::boost::shared_ptr< ::svt::table::UnoControlTableModel > m_pTableModel; 63 bool m_bTableModelInitCompleted; 64 SelectionListenerMultiplexer m_aSelectionListeners; 65 66 protected: 67 virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); 68 void ImplCallItemListeners(); 69 70 public: 71 SVTXGridControl(); 72 ~SVTXGridControl(); 73 74 // XGridDataListener 75 virtual void SAL_CALL rowsInserted( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 76 virtual void SAL_CALL rowsRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 77 virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 78 virtual void SAL_CALL rowHeadingChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 79 80 // XContainerListener 81 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 82 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 83 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 84 85 // XEventListener 86 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); 87 88 // XGridControl 89 virtual ::sal_Int32 SAL_CALL getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); 90 virtual ::sal_Int32 SAL_CALL getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); 91 virtual ::sal_Int32 SAL_CALL getCurrentColumn( ) throw (::com::sun::star::uno::RuntimeException); 92 virtual ::sal_Int32 SAL_CALL getCurrentRow( ) throw (::com::sun::star::uno::RuntimeException); 93 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); 94 95 // XGridRowSelection 96 virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException ); 97 virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException); 98 virtual void SAL_CALL deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException ); 99 virtual void SAL_CALL deselectAllRows() throw (::com::sun::star::uno::RuntimeException); 100 virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelectedRows() throw (::com::sun::star::uno::RuntimeException); 101 virtual ::sal_Bool SAL_CALL hasSelectedRows() throw (::com::sun::star::uno::RuntimeException); 102 virtual ::sal_Bool SAL_CALL isRowSelected(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); 103 virtual void SAL_CALL addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); 104 virtual void SAL_CALL removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); 105 106 void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); 107 ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); 108 static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds ); 109 110 // ::com::sun::star::lang::XComponent 111 void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); 112 113 protected: 114 // VCLXWindow 115 virtual void SetWindow( Window* pWindow ); 116 117 private: 118 void impl_updateColumnsFromModel_nothrow(); 119 void impl_checkTableModelInit(); 120 121 void impl_checkColumnIndex_throw( ::svt::table::TableControl const & i_table, sal_Int32 const i_columnIndex ) const; 122 void impl_checkRowIndex_throw( ::svt::table::TableControl const & i_table, sal_Int32 const i_rowIndex ) const; 123 }; 124 #endif // _SVT_GRIDCONTROL_HXX_ 125