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