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