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