update dev300-m58
[ooovba.git] / sc / source / ui / unoobj / cellvaluebinding.hxx
blobb383c89e8d24940652bb20707bbdaf10a1da2416
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cellvaluebinding.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_CELLVALUEBINDING_HXX
32 #define SC_CELLVALUEBINDING_HXX
34 #include <com/sun/star/form/binding/XValueBinding.hpp>
35 #include <com/sun/star/util/XModifyBroadcaster.hpp>
36 #include <cppuhelper/compbase5.hxx>
37 #include <comphelper/propertycontainer.hxx>
38 #include <comphelper/uno3.hxx>
39 #include <comphelper/broadcasthelper.hxx>
40 #include <comphelper/proparrhlp.hxx>
41 #include <com/sun/star/table/XCell.hpp>
42 #include <com/sun/star/table/CellAddress.hpp>
43 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
44 #include <com/sun/star/text/XTextRange.hpp>
45 #include <com/sun/star/lang/DisposedException.hpp>
46 #include <com/sun/star/lang/XServiceInfo.hpp>
47 #include <com/sun/star/lang/XInitialization.hpp>
50 //.........................................................................
51 namespace calc
53 //.........................................................................
55 //=====================================================================
56 //= OCellValueBinding
57 //=====================================================================
58 class OCellValueBinding;
59 // the base for our interfaces
60 typedef ::cppu::WeakAggComponentImplHelper5 < ::com::sun::star::form::binding::XValueBinding
61 , ::com::sun::star::lang::XServiceInfo
62 , ::com::sun::star::util::XModifyBroadcaster
63 , ::com::sun::star::util::XModifyListener
64 , ::com::sun::star::lang::XInitialization
65 > OCellValueBinding_Base;
66 // the base for the property handling
67 typedef ::comphelper::OPropertyContainer OCellValueBinding_PBase;
68 // the second base for property handling
69 typedef ::comphelper::OPropertyArrayUsageHelper< OCellValueBinding >
70 OCellValueBinding_PABase;
72 class OCellValueBinding :public ::comphelper::OBaseMutex
73 ,public OCellValueBinding_Base // order matters! before OCellValueBinding_PBase, so rBHelper gets initialized
74 ,public OCellValueBinding_PBase
75 ,public OCellValueBinding_PABase
77 private:
78 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
79 m_xDocument; /// the document where our cell lives
80 ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell >
81 m_xCell; /// the cell we're bound to, for double value access
82 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >
83 m_xCellText; /// the cell we're bound to, for text access
84 ::cppu::OInterfaceContainerHelper
85 m_aModifyListeners; /// our modify listeners
86 sal_Bool m_bInitialized; /// has XInitialization::initialize been called?
87 sal_Bool m_bListPos; /// constructed as ListPositionCellBinding?
89 public:
90 OCellValueBinding(
91 const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& _rxDocument,
92 sal_Bool _bListPos
95 using OCellValueBinding_PBase::getFastPropertyValue;
97 protected:
98 ~OCellValueBinding( );
100 protected:
101 // XInterface
102 DECLARE_XINTERFACE()
104 // XTypeProvider
105 DECLARE_XTYPEPROVIDER()
107 // XValueBinding
108 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getSupportedValueTypes( ) throw (::com::sun::star::uno::RuntimeException);
109 virtual sal_Bool SAL_CALL supportsType( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
110 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);
111 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);
113 // OComponentHelper/XComponent
114 virtual void SAL_CALL disposing();
116 // XServiceInfo
117 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
118 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
119 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
121 // XPropertySet
122 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
124 // OPropertySetHelper
125 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
126 virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& _rValue, sal_Int32 _nHandle ) const;
128 // ::comphelper::OPropertyArrayUsageHelper
129 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
131 // XModifyBroadcaster
132 virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
133 virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
135 // XModifyListener
136 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
137 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
139 // XInitialization
140 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);
142 private:
143 void checkDisposed( ) const
144 SAL_THROW( ( ::com::sun::star::lang::DisposedException ) );
145 void checkValueType( const ::com::sun::star::uno::Type& _rType ) const
146 SAL_THROW( ( ::com::sun::star::form::binding::IncompatibleTypesException ) );
147 void checkInitialized()
148 SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) );
150 /** notifies our modify listeners
151 @precond
152 our mutex is <em>not</em> locked
154 void notifyModified();
156 void setBooleanFormat();
158 private:
159 OCellValueBinding(); // never implemented
160 OCellValueBinding( const OCellValueBinding& ); // never implemented
161 OCellValueBinding& operator=( const OCellValueBinding& ); // never implemented
163 #ifdef DBG_UTIL
164 private:
165 static const char* checkConsistency_static( const void* _pThis );
166 const char* checkConsistency( ) const;
167 #endif
170 //.........................................................................
171 } // namespace calc
172 //.........................................................................
174 #endif // SC_CELLVALUEBINDING_HXX