tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / unoobj / celllistsource.hxx
blob96eb5caa500a25220600808412c56f82bc852764
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
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; }
36 namespace calc
39 //= OCellListSource
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
58 private:
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?
67 public:
68 explicit OCellListSource(
69 const css::uno::Reference< css::sheet::XSpreadsheetDocument >& _rxDocument
72 using OCellListSource_PBase::getFastPropertyValue;
74 protected:
75 virtual ~OCellListSource( ) override;
77 protected:
78 // XInterface
79 DECLARE_XINTERFACE()
81 // XTypeProvider
82 DECLARE_XTYPEPROVIDER()
84 // XListEntrySource
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;
97 // XServiceInfo
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;
102 // XPropertySet
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;
112 // XModifyListener
113 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
114 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
116 // XInitialization
117 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
119 private:
120 void checkInitialized();
122 /** retrieves the actual address of our cell range
123 @precond
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
132 @param pAny
133 if not <NULL/> then the underlying data value is returned in the Any
134 @precond
135 our m_xRange is not <NULL/>
137 OUString
138 getCellTextContent_noCheck(
139 std::unique_lock<std::mutex>& rGuard,
140 sal_Int32 _nRangeRelativeRow,
141 css::uno::Any* pAny
144 void notifyModified();
146 sal_Int32 getListEntryCount(std::unique_lock<std::mutex>& rGuard);
148 private:
149 OCellListSource( const OCellListSource& ) = delete;
150 OCellListSource& operator=( const OCellListSource& ) = delete;
153 } // namespace calc
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */