LibreOffice Module toolkit (master) 1
unocontrolmodel.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLMODEL_HXX
21#define INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLMODEL_HXX
22
23#include <com/sun/star/awt/XControlModel.hpp>
24#include <com/sun/star/lang/XComponent.hpp>
25#include <com/sun/star/lang/XServiceInfo.hpp>
26#include <com/sun/star/beans/XPropertyState.hpp>
27#include <com/sun/star/io/XPersistObject.hpp>
28#include <com/sun/star/util/XCloneable.hpp>
30
33
36#include <comphelper/uno3.hxx>
37#include <rtl/ref.hxx>
38
39#include <vector>
40#include <map>
41
42namespace com::sun::star::uno { class XComponentContext; }
43
44typedef std::map<sal_uInt16, css::uno::Any> ImplPropertyTable;
45
46typedef ::cppu::WeakAggImplHelper6 < css::awt::XControlModel
47 , css::beans::XPropertyState
48 , css::io::XPersistObject
49 , css::lang::XComponent
50 , css::lang::XServiceInfo
51 , css::util::XCloneable
53
56{
57private:
59 EventListenerMultiplexer maDisposeListeners;
60
61protected:
62 css::uno::Reference< css::uno::XComponentContext > m_xContext;
63
64protected:
65 void ImplRegisterProperty( sal_uInt16 nPropType );
66 void ImplRegisterProperties( const std::vector< sal_uInt16 > &rIds );
67 void ImplRegisterProperty( sal_uInt16 nPropId, const css::uno::Any& rDefault );
68 css::uno::Sequence<sal_Int32> ImplGetPropertyIds() const;
69 virtual css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const;
70 bool ImplHasProperty( sal_uInt16 nPropId ) const;
71
79 const sal_Int32 _nCount,
80 sal_Int32* _pHandles,
81 css::uno::Any* _pValues,
82 sal_Int32* _pValidHandles
83 ) const;
84
86 static void ImplEnsureHandleOrder(
87 const sal_Int32 _nCount,
88 sal_Int32* _pHandles,
89 css::uno::Any* _pValues,
90 sal_Int32 _nFirstHandle,
91 sal_Int32 _nSecondHandle
92 );
93
94 template<typename T> void UNO_CONTROL_MODEL_REGISTER_PROPERTIES() {
95 std::vector< sal_uInt16 > aIds;
96 T::ImplGetPropertyIds( aIds );
98 }
99
100protected:
101#ifdef _MSC_VER
102 UnoControlModel() //do not use! needed by MSVC at compile time to satisfy WeakAggImplHelper7
105 , maDisposeListeners( *this )
106 , m_xContext( css::uno::Reference< css::uno::XComponentContext >() )
107 {
108 assert(false);
109 }
110#endif
111
112public:
113 UnoControlModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
114 UnoControlModel( const UnoControlModel& rModel );
115
117
118 // css::uno::XInterface
119 css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return OWeakAggObject::queryInterface(rType); }
120 void SAL_CALL acquire() noexcept override;
121 void SAL_CALL release() noexcept override;
122
123 // css::uno::XAggregation
124 css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override;
125
126 // css::util::XCloneable
127 css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
128
129 // css::lang::XTypeProvider
130 DECLARE_XTYPEPROVIDER()
131
132 // css::lang::XComponent
133 void SAL_CALL dispose( ) override;
134 void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
135 void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
136
137 // css::beans::XPropertyState
138 css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
139 css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
140 void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
141 css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
142
143 // css::io::XPersistObject
144 OUString SAL_CALL getServiceName() override;
145 void SAL_CALL write( const css::uno::Reference< css::io::XObjectOutputStream >& OutStream ) override;
146 void SAL_CALL read( const css::uno::Reference< css::io::XObjectInputStream >& InStream ) override;
147
148 // css::lang::XServiceInfo
149 OUString SAL_CALL getImplementationName( ) override;
150 sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
151 css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
152
153 // ::cppu::OPropertySetHelper
154 ::cppu::IPropertyArrayHelper& getInfoHelper() override = 0;
155 bool convertFastPropertyValue( std::unique_lock<std::mutex>& rGuard, css::uno::Any & rConvertedValue, css::uno::Any & rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue ) override;
157 std::unique_lock<std::mutex>& rGuard,
158 sal_Int32 nHandle, const css::uno::Any& rValue ) override;
160 void getFastPropertyValue( std::unique_lock<std::mutex>& rGuard, css::uno::Any& rValue, sal_Int32 nHandle ) const override;
161
162 // css::beans::XMultiPropertySet
163 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
164 void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Sequence< css::uno::Any >& Values ) override;
165protected:
166 // override setValue methods to handle properties of FontDescriptor
167 // css::beans::XFastPropertySet
168 void setFastPropertyValueImpl( std::unique_lock<std::mutex>& rGuard, sal_Int32 nHandle, const css::uno::Any& aValue ) override;
169 css::beans::PropertyState getPropertyStateImpl( std::unique_lock<std::mutex>& rGuard, const OUString& PropertyName );
170 void setPropertyValuesImpl( std::unique_lock<std::mutex>& rGuard, const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Sequence< css::uno::Any >& Values );
171};
172
173#endif // INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLMODEL_HXX
174
175/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setPropertyValuesImpl(std::unique_lock< std::mutex > &rGuard, const css::uno::Sequence< OUString > &PropertyNames, const css::uno::Sequence< css::uno::Any > &Values)
css::uno::Sequence< sal_Int32 > ImplGetPropertyIds() const
sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
void ImplRegisterProperty(sal_uInt16 nPropType)
void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
void SAL_CALL dispose() override
css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
void setFastPropertyValue_NoBroadcast(std::unique_lock< std::mutex > &rGuard, sal_Int32 nHandle, const css::uno::Any &rValue) override
css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
OUString SAL_CALL getServiceName() override
void UNO_CONTROL_MODEL_REGISTER_PROPERTIES()
void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream > &InStream) override
void setFastPropertyValueImpl(std::unique_lock< std::mutex > &rGuard, sal_Int32 nHandle, const css::uno::Any &aValue) override
UnoControlModel(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
ImplPropertyTable maData
virtual rtl::Reference< UnoControlModel > Clone() const =0
virtual css::uno::Any ImplGetDefaultValue(sal_uInt16 nPropId) const
::cppu::IPropertyArrayHelper & getInfoHelper() override=0
void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &PropertyNames, const css::uno::Sequence< css::uno::Any > &Values) override
void SAL_CALL acquire() noexcept override
void getFastPropertyValue(std::unique_lock< std::mutex > &rGuard, css::uno::Any &rValue, sal_Int32 nHandle) const override
void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
virtual void ImplNormalizePropertySequence(const sal_Int32 _nCount, sal_Int32 *_pHandles, css::uno::Any *_pValues, sal_Int32 *_pValidHandles) const
called before setting multiple properties, allows to care for property dependencies
css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &rType) override
static void ImplEnsureHandleOrder(const sal_Int32 _nCount, sal_Int32 *_pHandles, css::uno::Any *_pValues, sal_Int32 _nFirstHandle, sal_Int32 _nSecondHandle)
ensures that two property values in a sequence have a certain order
bool ImplHasProperty(sal_uInt16 nPropId) const
void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream > &OutStream) override
EventListenerMultiplexer maDisposeListeners
bool convertFastPropertyValue(std::unique_lock< std::mutex > &rGuard, css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
css::beans::PropertyState getPropertyStateImpl(std::unique_lock< std::mutex > &rGuard, const OUString &PropertyName)
void SAL_CALL release() noexcept override
OUString SAL_CALL getImplementationName() override
void ImplRegisterProperties(const std::vector< sal_uInt16 > &rIds)
Type
Reference
unsigned char sal_Bool
std::map< sal_uInt16, css::uno::Any > ImplPropertyTable
::cppu::WeakAggImplHelper6< css::awt::XControlModel, css::beans::XPropertyState, css::io::XPersistObject, css::lang::XComponent, css::lang::XServiceInfo, css::util::XCloneable > UnoControlModel_Base