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 .
22 #include <com/sun/star/form/binding/XListEntryTypedSource.hpp>
23 #include <comphelper/compbase.hxx>
24 #include <comphelper/interfacecontainer4.hxx>
25 #include <comphelper/propertycontainer2.hxx>
26 #include <comphelper/uno3.hxx>
27 #include <comphelper/proparrhlp.hxx>
28 #include <com/sun/star/table/CellRangeAddress.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/lang/XInitialization.hpp>
31 #include <com/sun/star/util/XModifyListener.hpp>
33 namespace com::sun::star::sheet
{ class XSpreadsheetDocument
; }
34 namespace com::sun::star::table
{ class XCellRange
; }
41 class OCellListSource
;
42 // the base for our interfaces
43 typedef ::comphelper::WeakComponentImplHelper
< css::form::binding::XListEntryTypedSource
44 , css::util::XModifyListener
45 , css::lang::XServiceInfo
46 , css::lang::XInitialization
47 > OCellListSource_Base
;
48 // the base for the property handling
49 typedef ::comphelper::OPropertyContainer2 OCellListSource_PBase
;
50 // the second base for property handling
51 typedef ::comphelper::OPropertyArrayUsageHelper
< OCellListSource
>
52 OCellListSource_PABase
;
54 class OCellListSource
:public OCellListSource_Base
// order matters! before OCellListSource_PBase, so rBHelper gets initialized
55 ,public OCellListSource_PBase
56 ,public OCellListSource_PABase
59 css::uno::Reference
< css::sheet::XSpreadsheetDocument
>
60 m_xDocument
; /// the document where our cell lives
61 css::uno::Reference
< css::table::XCellRange
>
62 m_xRange
; /// the range of cells we're bound to
63 ::comphelper::OInterfaceContainerHelper4
<css::form::binding::XListEntryListener
>
64 m_aListEntryListeners
; /// our listeners
65 bool m_bInitialized
; /// has XInitialization::initialize been called?
68 explicit OCellListSource(
69 const css::uno::Reference
< css::sheet::XSpreadsheetDocument
>& _rxDocument
72 using OCellListSource_PBase::getFastPropertyValue
;
75 virtual ~OCellListSource( ) override
;
82 DECLARE_XTYPEPROVIDER()
85 virtual sal_Int32 SAL_CALL
getListEntryCount( ) override
;
86 virtual OUString SAL_CALL
getListEntry( sal_Int32 Position
) override
;
87 virtual css::uno::Sequence
< OUString
> SAL_CALL
getAllListEntries( ) override
;
88 virtual void SAL_CALL
addListEntryListener( const css::uno::Reference
< css::form::binding::XListEntryListener
>& Listener
) override
;
89 virtual void SAL_CALL
removeListEntryListener( const css::uno::Reference
< css::form::binding::XListEntryListener
>& Listener
) override
;
91 // XListEntryTypedSource
92 virtual css::uno::Sequence
< OUString
> SAL_CALL
getAllListEntriesTyped( css::uno::Sequence
< css::uno::Any
>& rDataValues
) override
;
94 // OComponentHelper/XComponent
95 virtual void disposing( std::unique_lock
<std::mutex
>& ) override
;
98 virtual OUString SAL_CALL
getImplementationName( ) override
;
99 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
100 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
103 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
105 // OPropertySetHelper
106 virtual ::cppu::IPropertyArrayHelper
& getInfoHelper() override
;
107 virtual void getFastPropertyValue( std::unique_lock
<std::mutex
>& rGuard
, css::uno::Any
& _rValue
, sal_Int32 _nHandle
) const override
;
109 // ::comphelper::OPropertyArrayUsageHelper
110 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const override
;
113 virtual void SAL_CALL
modified( const css::lang::EventObject
& aEvent
) override
;
114 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
117 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
120 void checkInitialized();
122 /** retrieves the actual address of our cell range
124 our m_xRange is not <NULL/>
126 css::table::CellRangeAddress
127 getRangeAddress( ) const;
129 /** retrieves the text of a cell within our range
130 @param _nRangeRelativeRow
131 the relative row index of the cell within our range
133 if not <NULL/> then the underlying data value is returned in the Any
135 our m_xRange is not <NULL/>
138 getCellTextContent_noCheck(
139 std::unique_lock
<std::mutex
>& rGuard
,
140 sal_Int32 _nRangeRelativeRow
,
144 void notifyModified();
146 sal_Int32
getListEntryCount(std::unique_lock
<std::mutex
>& rGuard
);
149 OCellListSource( const OCellListSource
& ) = delete;
150 OCellListSource
& operator=( const OCellListSource
& ) = delete;
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */