1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_SOURCE_UI_UNOOBJ_CELLLISTSOURCE_HXX
21 #define INCLUDED_SC_SOURCE_UI_UNOOBJ_CELLLISTSOURCE_HXX
23 #include <com/sun/star/form/binding/XListEntrySource.hpp>
24 #include <cppuhelper/compbase4.hxx>
25 #include <comphelper/propertycontainer.hxx>
26 #include <comphelper/uno3.hxx>
27 #include <comphelper/broadcasthelper.hxx>
28 #include <comphelper/proparrhlp.hxx>
29 #include <com/sun/star/table/XCellRange.hpp>
30 #include <com/sun/star/table/CellRangeAddress.hpp>
31 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
32 #include <com/sun/star/lang/DisposedException.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/lang/XInitialization.hpp>
35 #include <com/sun/star/util/XModifyListener.hpp>
42 class OCellListSource
;
43 // the base for our interfaces
44 typedef ::cppu::WeakAggComponentImplHelper4
< ::com::sun::star::form::binding::XListEntrySource
45 , ::com::sun::star::util::XModifyListener
46 , ::com::sun::star::lang::XServiceInfo
47 , ::com::sun::star::lang::XInitialization
48 > OCellListSource_Base
;
49 // the base for the property handling
50 typedef ::comphelper::OPropertyContainer OCellListSource_PBase
;
51 // the second base for property handling
52 typedef ::comphelper::OPropertyArrayUsageHelper
< OCellListSource
>
53 OCellListSource_PABase
;
55 class OCellListSource
:public ::comphelper::OBaseMutex
56 ,public OCellListSource_Base
// order matters! before OCellListSource_PBase, so rBHelper gets initialized
57 ,public OCellListSource_PBase
58 ,public OCellListSource_PABase
61 ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XSpreadsheetDocument
>
62 m_xDocument
; /// the document where our cell lives
63 ::com::sun::star::uno::Reference
< ::com::sun::star::table::XCellRange
>
64 m_xRange
; /// the range of cells we're bound to
65 ::cppu::OInterfaceContainerHelper
66 m_aListEntryListeners
; /// our listeners
67 bool m_bInitialized
; /// has XInitialization::initialize been called?
71 const ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XSpreadsheetDocument
>& _rxDocument
74 using OCellListSource_PBase::getFastPropertyValue
;
77 virtual ~OCellListSource( );
84 DECLARE_XTYPEPROVIDER()
87 virtual sal_Int32 SAL_CALL
getListEntryCount( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
88 virtual OUString SAL_CALL
getListEntry( sal_Int32 Position
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
89 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getAllListEntries( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
90 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
, std::exception
) SAL_OVERRIDE
;
91 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
, std::exception
) SAL_OVERRIDE
;
93 // OComponentHelper/XComponent
94 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
97 virtual OUString SAL_CALL
getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
98 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
99 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
102 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
104 // OPropertySetHelper
105 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
106 virtual void SAL_CALL
getFastPropertyValue( ::com::sun::star::uno::Any
& _rValue
, sal_Int32 _nHandle
) const SAL_OVERRIDE
;
108 // ::comphelper::OPropertyArrayUsageHelper
109 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const SAL_OVERRIDE
;
112 virtual void SAL_CALL
modified( const ::com::sun::star::lang::EventObject
& aEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
113 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
116 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
, std::exception
) SAL_OVERRIDE
;
119 void checkDisposed( ) const;
120 void checkInitialized();
122 /** retrieves the actual address of our cell range
124 our m_xRange is not <NULL/>
126 ::com::sun::star::table::CellRangeAddress
127 getRangeAddress( ) const;
129 /** retrievs the text of a cell within our range
130 @param _nRangeRelativeColumn
131 the relative column index of the cell within our range
132 @param _nRangeRelativeRow
133 the relative row index of the cell within our range
135 our m_xRange is not <NULL/>
138 getCellTextContent_noCheck(
139 sal_Int32 _nRangeRelativeColumn
,
140 sal_Int32 _nRangeRelativeRow
143 void notifyModified();
146 OCellListSource( const OCellListSource
& ) SAL_DELETED_FUNCTION
;
147 OCellListSource
& operator=( const OCellListSource
& ) SAL_DELETED_FUNCTION
;
152 #endif // INCLUDED_SC_SOURCE_UI_UNOOBJ_CELLLISTSOURCE_HXX
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */