tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / unoobj / cellvaluebinding.hxx
blob8c77523f4ab04589e347bf2337ecbe8ef1c3037f
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/XValueBinding.hpp>
23 #include <com/sun/star/util/XModifyBroadcaster.hpp>
24 #include <comphelper/compbase.hxx>
25 #include <comphelper/interfacecontainer4.hxx>
26 #include <comphelper/propertycontainer2.hxx>
27 #include <comphelper/uno3.hxx>
28 #include <comphelper/proparrhlp.hxx>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/lang/XInitialization.hpp>
32 namespace com::sun::star::table { class XCell; }
33 namespace com::sun::star::sheet { class XSpreadsheetDocument; }
34 namespace com::sun::star::text { class XTextRange; }
36 namespace calc
39 //= OCellValueBinding
41 class OCellValueBinding;
42 // the base for our interfaces
43 typedef ::comphelper::WeakComponentImplHelper < css::form::binding::XValueBinding
44 , css::lang::XServiceInfo
45 , css::util::XModifyBroadcaster
46 , css::util::XModifyListener
47 , css::lang::XInitialization
48 > OCellValueBinding_Base;
49 // the base for the property handling
50 typedef ::comphelper::OPropertyContainer2 OCellValueBinding_PBase;
51 // the second base for property handling
52 typedef ::comphelper::OPropertyArrayUsageHelper< OCellValueBinding >
53 OCellValueBinding_PABase;
55 class OCellValueBinding :
56 public OCellValueBinding_Base // order matters! before OCellValueBinding_PBase, so rBHelper gets initialized
57 ,public OCellValueBinding_PBase
58 ,public OCellValueBinding_PABase
60 private:
61 css::uno::Reference< css::sheet::XSpreadsheetDocument >
62 m_xDocument; /// the document where our cell lives
63 css::uno::Reference< css::table::XCell >
64 m_xCell; /// the cell we're bound to, for double value access
65 css::uno::Reference< css::text::XTextRange >
66 m_xCellText; /// the cell we're bound to, for text access
67 ::comphelper::OInterfaceContainerHelper4<css::util::XModifyListener>
68 m_aModifyListeners; /// our modify listeners
69 bool m_bInitialized; /// has XInitialization::initialize been called?
70 bool m_bListPos; /// constructed as ListPositionCellBinding?
72 public:
73 OCellValueBinding(
74 const css::uno::Reference< css::sheet::XSpreadsheetDocument >& _rxDocument,
75 bool _bListPos
78 using OCellValueBinding_PBase::getFastPropertyValue;
80 protected:
81 virtual ~OCellValueBinding( ) override;
83 protected:
84 // XInterface
85 DECLARE_XINTERFACE()
87 // XTypeProvider
88 DECLARE_XTYPEPROVIDER()
90 // XValueBinding
91 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getSupportedValueTypes( ) override;
92 virtual sal_Bool SAL_CALL supportsType( const css::uno::Type& aType ) override;
93 virtual css::uno::Any SAL_CALL getValue( const css::uno::Type& aType ) override;
94 virtual void SAL_CALL setValue( const css::uno::Any& aValue ) override;
96 // OComponentHelper/XComponent
97 virtual void disposing(std::unique_lock<std::mutex>& rGuard) override;
99 // XServiceInfo
100 virtual OUString SAL_CALL getImplementationName( ) override;
101 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
102 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
104 // XPropertySet
105 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
107 // OPropertySetHelper
108 virtual ::cppu::IPropertyArrayHelper& getInfoHelper() override;
109 virtual void getFastPropertyValue( std::unique_lock<std::mutex>& rGuard, css::uno::Any& _rValue, sal_Int32 _nHandle ) const override;
111 // ::comphelper::OPropertyArrayUsageHelper
112 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
114 // XModifyBroadcaster
115 virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
116 virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
118 // XModifyListener
119 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
120 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
122 // XInitialization
123 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
125 private:
126 void checkValueType( std::unique_lock<std::mutex>& rGuard, const css::uno::Type& _rType ) const;
127 void checkInitialized();
128 css::uno::Sequence< css::uno::Type > getSupportedValueTypes(std::unique_lock<std::mutex>& rGuard) const;
129 bool supportsType( std::unique_lock<std::mutex>& rGuard, const css::uno::Type& aType ) const;
131 /** notifies our modify listeners
132 @precond
133 our mutex is <em>not</em> locked
135 void notifyModified();
137 void setBooleanFormat();
139 private:
140 OCellValueBinding( const OCellValueBinding& ) = delete;
141 OCellValueBinding& operator=( const OCellValueBinding& ) = delete;
144 } // namespace calc
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */