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_CELLLISTSOURCE_HXX
25cdf0e10cSrcweir #define SC_CELLLISTSOURCE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/form/binding/XListEntrySource.hpp>
28cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
29cdf0e10cSrcweir #include <comphelper/propertycontainer.hxx>
30cdf0e10cSrcweir #include <comphelper/uno3.hxx>
31cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
32cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx>
33cdf0e10cSrcweir #include <com/sun/star/table/XCellRange.hpp>
34cdf0e10cSrcweir #include <com/sun/star/table/CellRangeAddress.hpp>
35cdf0e10cSrcweir #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
36cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
37cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
38cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
39cdf0e10cSrcweir #include <com/sun/star/util/XModifyListener.hpp>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //.........................................................................
43cdf0e10cSrcweir namespace calc
44cdf0e10cSrcweir {
45cdf0e10cSrcweir //.........................................................................
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     //=====================================================================
48cdf0e10cSrcweir     //= OCellListSource
49cdf0e10cSrcweir     //=====================================================================
50cdf0e10cSrcweir     class OCellListSource;
51cdf0e10cSrcweir     // the base for our interfaces
52cdf0e10cSrcweir     typedef ::cppu::WeakAggComponentImplHelper4 <   ::com::sun::star::form::binding::XListEntrySource
53cdf0e10cSrcweir                                                 ,   ::com::sun::star::util::XModifyListener
54cdf0e10cSrcweir                                                 ,   ::com::sun::star::lang::XServiceInfo
55cdf0e10cSrcweir                                                 ,   ::com::sun::star::lang::XInitialization
56cdf0e10cSrcweir                                                 >   OCellListSource_Base;
57cdf0e10cSrcweir     // the base for the property handling
58cdf0e10cSrcweir     typedef ::comphelper::OPropertyContainer        OCellListSource_PBase;
59cdf0e10cSrcweir     // the second base for property handling
60cdf0e10cSrcweir     typedef ::comphelper::OPropertyArrayUsageHelper< OCellListSource >
61cdf0e10cSrcweir                                                     OCellListSource_PABase;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     class OCellListSource :public ::comphelper::OBaseMutex
64cdf0e10cSrcweir                             ,public OCellListSource_Base      // order matters! before OCellListSource_PBase, so rBHelper gets initialized
65cdf0e10cSrcweir                             ,public OCellListSource_PBase
66cdf0e10cSrcweir 					        ,public OCellListSource_PABase
67cdf0e10cSrcweir     {
68cdf0e10cSrcweir     private:
69cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
70cdf0e10cSrcweir                     m_xDocument;            /// the document where our cell lives
71cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >
72cdf0e10cSrcweir                     m_xRange;               /// the range of cells we're bound to
73cdf0e10cSrcweir     	::cppu::OInterfaceContainerHelper
74cdf0e10cSrcweir                     m_aListEntryListeners;  /// our listeners
75cdf0e10cSrcweir         sal_Bool    m_bInitialized;         /// has XInitialization::initialize been called?
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     public:
78cdf0e10cSrcweir         OCellListSource(
79cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& _rxDocument
80cdf0e10cSrcweir         );
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         using OCellListSource_PBase::getFastPropertyValue;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     protected:
85cdf0e10cSrcweir         ~OCellListSource( );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     protected:
88cdf0e10cSrcweir         // XInterface
89cdf0e10cSrcweir         DECLARE_XINTERFACE()
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         // XTypeProvider
92cdf0e10cSrcweir         DECLARE_XTYPEPROVIDER()
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         // XListEntrySource
95cdf0e10cSrcweir         virtual sal_Int32 SAL_CALL getListEntryCount(  ) throw (::com::sun::star::uno::RuntimeException);
96cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getListEntry( sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
97cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllListEntries(  ) throw (::com::sun::star::uno::RuntimeException);
98cdf0e10cSrcweir         virtual void SAL_CALL addListEntryListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntryListener >& Listener ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir         virtual void SAL_CALL removeListEntryListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntryListener >& Listener ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
100cdf0e10cSrcweir 
101cdf0e10cSrcweir         // OComponentHelper/XComponent
102cdf0e10cSrcweir         virtual void SAL_CALL disposing();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         // XServiceInfo
105cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
106cdf0e10cSrcweir         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
107cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir         // XPropertySet
110cdf0e10cSrcweir         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir         // OPropertySetHelper
113cdf0e10cSrcweir         virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
114cdf0e10cSrcweir 	    virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& _rValue, sal_Int32 _nHandle ) const;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir         // ::comphelper::OPropertyArrayUsageHelper
117cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         // XModifyListener
120cdf0e10cSrcweir         virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
121cdf0e10cSrcweir         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
122cdf0e10cSrcweir 
123cdf0e10cSrcweir         // XInitialization
124cdf0e10cSrcweir         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);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     private:
127cdf0e10cSrcweir         void    checkDisposed( ) const
128cdf0e10cSrcweir                     SAL_THROW( ( ::com::sun::star::lang::DisposedException ) );
129cdf0e10cSrcweir         void    checkInitialized()
130cdf0e10cSrcweir                     SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         /** retrieves the actual address of our cell range
133cdf0e10cSrcweir             @precond
134cdf0e10cSrcweir                 our m_xRange is not <NULL/>
135cdf0e10cSrcweir         */
136cdf0e10cSrcweir         ::com::sun::star::table::CellRangeAddress
137cdf0e10cSrcweir                 getRangeAddress( ) const;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         /** retrievs the text of a cell within our range
140cdf0e10cSrcweir             @param _nRangeRelativeColumn
141cdf0e10cSrcweir                 the relative column index of the cell within our range
142cdf0e10cSrcweir             @param _nRangeRelativeRow
143cdf0e10cSrcweir                 the relative row index of the cell within our range
144cdf0e10cSrcweir             @precond
145cdf0e10cSrcweir                 our m_xRange is not <NULL/>
146cdf0e10cSrcweir         */
147cdf0e10cSrcweir         ::rtl::OUString
148cdf0e10cSrcweir                 getCellTextContent_noCheck(
149cdf0e10cSrcweir                     sal_Int32 _nRangeRelativeColumn,
150cdf0e10cSrcweir                     sal_Int32 _nRangeRelativeRow
151cdf0e10cSrcweir                 );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir         void    notifyModified();
154cdf0e10cSrcweir 
155cdf0e10cSrcweir     private:
156cdf0e10cSrcweir         OCellListSource();                                      // never implemented
157cdf0e10cSrcweir         OCellListSource( const OCellListSource& );              // never implemented
158cdf0e10cSrcweir         OCellListSource& operator=( const OCellListSource& );   // never implemented
159cdf0e10cSrcweir 
160cdf0e10cSrcweir #ifdef DBG_UTIL
161cdf0e10cSrcweir     private:
162cdf0e10cSrcweir         static  const char* checkConsistency_static( const void* _pThis );
163cdf0e10cSrcweir                 const char* checkConsistency( ) const;
164cdf0e10cSrcweir #endif
165cdf0e10cSrcweir     };
166cdf0e10cSrcweir 
167cdf0e10cSrcweir //.........................................................................
168cdf0e10cSrcweir }   // namespace calc
169cdf0e10cSrcweir //.........................................................................
170cdf0e10cSrcweir 
171cdf0e10cSrcweir #endif // SC_CELLLISTSOURCE_HXX
172