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 SC_CELLVALUEBINDING_HXX 25 #define SC_CELLVALUEBINDING_HXX 26 27 #include <com/sun/star/form/binding/XValueBinding.hpp> 28 #include <com/sun/star/util/XModifyBroadcaster.hpp> 29 #include <cppuhelper/compbase5.hxx> 30 #include <comphelper/propertycontainer.hxx> 31 #include <comphelper/uno3.hxx> 32 #include <comphelper/broadcasthelper.hxx> 33 #include <comphelper/proparrhlp.hxx> 34 #include <com/sun/star/table/XCell.hpp> 35 #include <com/sun/star/table/CellAddress.hpp> 36 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> 37 #include <com/sun/star/text/XTextRange.hpp> 38 #include <com/sun/star/lang/DisposedException.hpp> 39 #include <com/sun/star/lang/XServiceInfo.hpp> 40 #include <com/sun/star/lang/XInitialization.hpp> 41 42 43 //......................................................................... 44 namespace calc 45 { 46 //......................................................................... 47 48 //===================================================================== 49 //= OCellValueBinding 50 //===================================================================== 51 class OCellValueBinding; 52 // the base for our interfaces 53 typedef ::cppu::WeakAggComponentImplHelper5 < ::com::sun::star::form::binding::XValueBinding 54 , ::com::sun::star::lang::XServiceInfo 55 , ::com::sun::star::util::XModifyBroadcaster 56 , ::com::sun::star::util::XModifyListener 57 , ::com::sun::star::lang::XInitialization 58 > OCellValueBinding_Base; 59 // the base for the property handling 60 typedef ::comphelper::OPropertyContainer OCellValueBinding_PBase; 61 // the second base for property handling 62 typedef ::comphelper::OPropertyArrayUsageHelper< OCellValueBinding > 63 OCellValueBinding_PABase; 64 65 class OCellValueBinding :public ::comphelper::OBaseMutex 66 ,public OCellValueBinding_Base // order matters! before OCellValueBinding_PBase, so rBHelper gets initialized 67 ,public OCellValueBinding_PBase 68 ,public OCellValueBinding_PABase 69 { 70 private: 71 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > 72 m_xDocument; /// the document where our cell lives 73 ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > 74 m_xCell; /// the cell we're bound to, for double value access 75 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > 76 m_xCellText; /// the cell we're bound to, for text access 77 ::cppu::OInterfaceContainerHelper 78 m_aModifyListeners; /// our modify listeners 79 sal_Bool m_bInitialized; /// has XInitialization::initialize been called? 80 sal_Bool m_bListPos; /// constructed as ListPositionCellBinding? 81 82 public: 83 OCellValueBinding( 84 const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& _rxDocument, 85 sal_Bool _bListPos 86 ); 87 88 using OCellValueBinding_PBase::getFastPropertyValue; 89 90 protected: 91 ~OCellValueBinding( ); 92 93 protected: 94 // XInterface 95 DECLARE_XINTERFACE() 96 97 // XTypeProvider 98 DECLARE_XTYPEPROVIDER() 99 100 // XValueBinding 101 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getSupportedValueTypes( ) throw (::com::sun::star::uno::RuntimeException); 102 virtual sal_Bool SAL_CALL supportsType( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); 103 virtual ::com::sun::star::uno::Any SAL_CALL getValue( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::form::binding::IncompatibleTypesException, ::com::sun::star::uno::RuntimeException); 104 virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::form::binding::IncompatibleTypesException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); 105 106 // OComponentHelper/XComponent 107 virtual void SAL_CALL disposing(); 108 109 // XServiceInfo 110 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 111 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 112 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); 113 114 // XPropertySet 115 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 116 117 // OPropertySetHelper 118 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 119 virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& _rValue, sal_Int32 _nHandle ) const; 120 121 // ::comphelper::OPropertyArrayUsageHelper 122 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 123 124 // XModifyBroadcaster 125 virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 126 virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 127 128 // XModifyListener 129 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); 130 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 131 132 // XInitialization 133 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 134 135 private: 136 void checkDisposed( ) const 137 SAL_THROW( ( ::com::sun::star::lang::DisposedException ) ); 138 void checkValueType( const ::com::sun::star::uno::Type& _rType ) const 139 SAL_THROW( ( ::com::sun::star::form::binding::IncompatibleTypesException ) ); 140 void checkInitialized() 141 SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) ); 142 143 /** notifies our modify listeners 144 @precond 145 our mutex is <em>not</em> locked 146 */ 147 void notifyModified(); 148 149 void setBooleanFormat(); 150 151 private: 152 OCellValueBinding(); // never implemented 153 OCellValueBinding( const OCellValueBinding& ); // never implemented 154 OCellValueBinding& operator=( const OCellValueBinding& ); // never implemented 155 156 #ifdef DBG_UTIL 157 private: 158 static const char* checkConsistency_static( const void* _pThis ); 159 const char* checkConsistency( ) const; 160 #endif 161 }; 162 163 //......................................................................... 164 } // namespace calc 165 //......................................................................... 166 167 #endif // SC_CELLVALUEBINDING_HXX 168