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