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 29 #include <com/sun/star/awt/grid/XGridColumn.hpp> 30 #include <com/sun/star/lang/XEventListener.hpp> 31 #include <com/sun/star/lang/XServiceInfo.hpp> 32 #include <com/sun/star/lang/XUnoTunnel.hpp> 33 #include <com/sun/star/style/HorizontalAlignment.hpp> 34 35 #include <cppuhelper/basemutex.hxx> 36 #include <cppuhelper/compbase3.hxx> 37 #include <comphelper/componentguard.hxx> 38 #include <rtl/ref.hxx> 39 #include <toolkit/helper/mutexandbroadcasthelper.hxx> 40 41 #include <vector> 42 43 namespace toolkit 44 { 45 46 typedef ::cppu::WeakComponentImplHelper3 < ::com::sun::star::awt::grid::XGridColumn 47 , ::com::sun::star::lang::XServiceInfo 48 , ::com::sun::star::lang::XUnoTunnel 49 > GridColumn_Base; 50 class GridColumn :public ::cppu::BaseMutex 51 ,public GridColumn_Base 52 { 53 public: 54 GridColumn(); 55 GridColumn( GridColumn const & i_copySource ); 56 virtual ~GridColumn(); 57 58 // ::com::sun::star::awt::grid::XGridColumn 59 virtual ::com::sun::star::uno::Any SAL_CALL getIdentifier() throw (::com::sun::star::uno::RuntimeException); 60 virtual void SAL_CALL setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException); 61 virtual ::sal_Int32 SAL_CALL getColumnWidth() throw (::com::sun::star::uno::RuntimeException); 62 virtual void SAL_CALL setColumnWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); 63 virtual ::sal_Int32 SAL_CALL getMaxWidth() throw (::com::sun::star::uno::RuntimeException); 64 virtual void SAL_CALL setMaxWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); 65 virtual ::sal_Int32 SAL_CALL getMinWidth() throw (::com::sun::star::uno::RuntimeException); 66 virtual void SAL_CALL setMinWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); 67 virtual ::sal_Bool SAL_CALL getResizeable() throw (::com::sun::star::uno::RuntimeException); 68 virtual void SAL_CALL setResizeable(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); 69 virtual ::sal_Int32 SAL_CALL getFlexibility() throw (::com::sun::star::uno::RuntimeException); 70 virtual void SAL_CALL setFlexibility( ::sal_Int32 _flexibility ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 71 virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); 72 virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); 73 virtual ::rtl::OUString SAL_CALL getHelpText() throw (::com::sun::star::uno::RuntimeException); 74 virtual void SAL_CALL setHelpText(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); 75 virtual ::sal_Int32 SAL_CALL getIndex() throw (::com::sun::star::uno::RuntimeException); 76 virtual ::sal_Int32 SAL_CALL getDataColumnIndex() throw(::com::sun::star::uno::RuntimeException); 77 virtual void SAL_CALL setDataColumnIndex( ::sal_Int32 i_dataColumnIndex ) throw(::com::sun::star::uno::RuntimeException); 78 virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException); 79 virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException); 80 virtual void SAL_CALL addGridColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 81 virtual void SAL_CALL removeGridColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 82 83 // OComponentHelper 84 virtual void SAL_CALL disposing(); 85 86 // XCloneable (base of XGridColumn) 87 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); 88 89 // XServiceInfo 90 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 91 virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 92 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); 93 94 // XUnoTunnel and friends 95 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& i_identifier ) throw(::com::sun::star::uno::RuntimeException); 96 static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelId() throw(); 97 static GridColumn* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_component ); 98 99 // attribute access 100 void setIndex( sal_Int32 const i_index ); 101 102 private: 103 void broadcast_changed( 104 sal_Char const * const i_asciiAttributeName, 105 ::com::sun::star::uno::Any i_oldValue, 106 ::com::sun::star::uno::Any i_newValue, 107 ::comphelper::ComponentGuard& i_Guard 108 ); 109 110 template< class TYPE > 111 void impl_set( TYPE & io_attribute, TYPE const & i_newValue, sal_Char const * i_attributeName ) 112 { 113 ::comphelper::ComponentGuard aGuard( *this, rBHelper ); 114 if ( io_attribute == i_newValue ) 115 return; 116 117 TYPE const aOldValue( io_attribute ); 118 io_attribute = i_newValue; 119 broadcast_changed( i_attributeName, ::com::sun::star::uno::makeAny( aOldValue ), ::com::sun::star::uno::makeAny( io_attribute ), aGuard ); 120 } 121 122 ::com::sun::star::uno::Any m_aIdentifier; 123 sal_Int32 m_nIndex; 124 sal_Int32 m_nDataColumnIndex; 125 sal_Int32 m_nColumnWidth; 126 sal_Int32 m_nMaxWidth; 127 sal_Int32 m_nMinWidth; 128 sal_Int32 m_nFlexibility; 129 sal_Bool m_bResizeable; 130 ::rtl::OUString m_sTitle; 131 ::rtl::OUString m_sHelpText; 132 ::com::sun::star::style::HorizontalAlignment m_eHorizontalAlign; 133 }; 134 135 } 136