1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_CELLVALUEBINDING_HXX
25cdf0e10cSrcweir #define SC_CELLVALUEBINDING_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/form/binding/XValueBinding.hpp>
28cdf0e10cSrcweir #include <com/sun/star/util/XModifyBroadcaster.hpp>
29cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx>
30cdf0e10cSrcweir #include <comphelper/propertycontainer.hxx>
31cdf0e10cSrcweir #include <comphelper/uno3.hxx>
32cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
33cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx>
34cdf0e10cSrcweir #include <com/sun/star/table/XCell.hpp>
35cdf0e10cSrcweir #include <com/sun/star/table/CellAddress.hpp>
36cdf0e10cSrcweir #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
37cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp>
38cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
39cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
40cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 
43cdf0e10cSrcweir //.........................................................................
44cdf0e10cSrcweir namespace calc
45cdf0e10cSrcweir {
46cdf0e10cSrcweir //.........................................................................
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     //=====================================================================
49cdf0e10cSrcweir     //= OCellValueBinding
50cdf0e10cSrcweir     //=====================================================================
51cdf0e10cSrcweir     class OCellValueBinding;
52cdf0e10cSrcweir     // the base for our interfaces
53cdf0e10cSrcweir     typedef ::cppu::WeakAggComponentImplHelper5 <   ::com::sun::star::form::binding::XValueBinding
54cdf0e10cSrcweir                                                 ,   ::com::sun::star::lang::XServiceInfo
55cdf0e10cSrcweir                                                 ,   ::com::sun::star::util::XModifyBroadcaster
56cdf0e10cSrcweir                                                 ,   ::com::sun::star::util::XModifyListener
57cdf0e10cSrcweir                                                 ,   ::com::sun::star::lang::XInitialization
58cdf0e10cSrcweir                                                 >   OCellValueBinding_Base;
59cdf0e10cSrcweir     // the base for the property handling
60cdf0e10cSrcweir     typedef ::comphelper::OPropertyContainer        OCellValueBinding_PBase;
61cdf0e10cSrcweir     // the second base for property handling
62cdf0e10cSrcweir     typedef ::comphelper::OPropertyArrayUsageHelper< OCellValueBinding >
63cdf0e10cSrcweir                                                     OCellValueBinding_PABase;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     class OCellValueBinding :public ::comphelper::OBaseMutex
66cdf0e10cSrcweir                             ,public OCellValueBinding_Base      // order matters! before OCellValueBinding_PBase, so rBHelper gets initialized
67cdf0e10cSrcweir                             ,public OCellValueBinding_PBase
68cdf0e10cSrcweir 					        ,public OCellValueBinding_PABase
69cdf0e10cSrcweir     {
70cdf0e10cSrcweir     private:
71cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
72cdf0e10cSrcweir                     m_xDocument;            /// the document where our cell lives
73cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell >
74cdf0e10cSrcweir                     m_xCell;                /// the cell we're bound to, for double value access
75cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >
76cdf0e10cSrcweir                     m_xCellText;            /// the cell we're bound to, for text access
77cdf0e10cSrcweir     	::cppu::OInterfaceContainerHelper
78cdf0e10cSrcweir                     m_aModifyListeners;     /// our modify listeners
79cdf0e10cSrcweir         sal_Bool    m_bInitialized;         /// has XInitialization::initialize been called?
80cdf0e10cSrcweir         sal_Bool    m_bListPos;             /// constructed as ListPositionCellBinding?
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     public:
83cdf0e10cSrcweir         OCellValueBinding(
84cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& _rxDocument,
85cdf0e10cSrcweir             sal_Bool _bListPos
86cdf0e10cSrcweir         );
87cdf0e10cSrcweir 
88cdf0e10cSrcweir         using OCellValueBinding_PBase::getFastPropertyValue;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     protected:
91cdf0e10cSrcweir         ~OCellValueBinding( );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     protected:
94cdf0e10cSrcweir         // XInterface
95cdf0e10cSrcweir         DECLARE_XINTERFACE()
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         // XTypeProvider
98cdf0e10cSrcweir         DECLARE_XTYPEPROVIDER()
99cdf0e10cSrcweir 
100cdf0e10cSrcweir         // XValueBinding
101cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getSupportedValueTypes(  ) throw (::com::sun::star::uno::RuntimeException);
102cdf0e10cSrcweir         virtual sal_Bool SAL_CALL supportsType( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
103cdf0e10cSrcweir         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);
104cdf0e10cSrcweir         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);
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         // OComponentHelper/XComponent
107cdf0e10cSrcweir         virtual void SAL_CALL disposing();
108cdf0e10cSrcweir 
109cdf0e10cSrcweir         // XServiceInfo
110cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
112cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir         // XPropertySet
115cdf0e10cSrcweir         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
116cdf0e10cSrcweir 
117cdf0e10cSrcweir         // OPropertySetHelper
118cdf0e10cSrcweir         virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
119cdf0e10cSrcweir 	    virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& _rValue, sal_Int32 _nHandle ) const;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir         // ::comphelper::OPropertyArrayUsageHelper
122cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir         // XModifyBroadcaster
125cdf0e10cSrcweir         virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
126cdf0e10cSrcweir         virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
127cdf0e10cSrcweir 
128cdf0e10cSrcweir         // XModifyListener
129cdf0e10cSrcweir         virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
130cdf0e10cSrcweir         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         // XInitialization
133cdf0e10cSrcweir         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);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     private:
136cdf0e10cSrcweir         void    checkDisposed( ) const
137cdf0e10cSrcweir                     SAL_THROW( ( ::com::sun::star::lang::DisposedException ) );
138cdf0e10cSrcweir         void    checkValueType( const ::com::sun::star::uno::Type& _rType ) const
139cdf0e10cSrcweir                     SAL_THROW( ( ::com::sun::star::form::binding::IncompatibleTypesException ) );
140cdf0e10cSrcweir         void    checkInitialized()
141cdf0e10cSrcweir                     SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir         /** notifies our modify listeners
144cdf0e10cSrcweir             @precond
145cdf0e10cSrcweir                 our mutex is <em>not</em> locked
146cdf0e10cSrcweir         */
147cdf0e10cSrcweir         void    notifyModified();
148cdf0e10cSrcweir 
149cdf0e10cSrcweir         void    setBooleanFormat();
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     private:
152cdf0e10cSrcweir         OCellValueBinding();                                        // never implemented
153cdf0e10cSrcweir         OCellValueBinding( const OCellValueBinding& );              // never implemented
154cdf0e10cSrcweir         OCellValueBinding& operator=( const OCellValueBinding& );   // never implemented
155cdf0e10cSrcweir 
156cdf0e10cSrcweir #ifdef DBG_UTIL
157cdf0e10cSrcweir     private:
158cdf0e10cSrcweir         static  const char* checkConsistency_static( const void* _pThis );
159cdf0e10cSrcweir                 const char* checkConsistency( ) const;
160cdf0e10cSrcweir #endif
161cdf0e10cSrcweir     };
162cdf0e10cSrcweir 
163cdf0e10cSrcweir //.........................................................................
164cdf0e10cSrcweir }   // namespace calc
165cdf0e10cSrcweir //.........................................................................
166cdf0e10cSrcweir 
167cdf0e10cSrcweir #endif // SC_CELLVALUEBINDING_HXX
168