Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/toolkit/controls/unocontrolmodel.hxx
Line
Count
Source
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
#pragma once
21
22
#include <toolkit/dllapi.h>
23
24
#include <com/sun/star/awt/XControlModel.hpp>
25
#include <com/sun/star/lang/XComponent.hpp>
26
#include <com/sun/star/lang/XServiceInfo.hpp>
27
#include <com/sun/star/beans/XPropertyState.hpp>
28
#include <com/sun/star/io/XPersistObject.hpp>
29
#include <com/sun/star/util/XCloneable.hpp>
30
#include <cppuhelper/weakagg.hxx>
31
32
#include <toolkit/helper/listenermultiplexer.hxx>
33
34
#include <comphelper/propshlp.hxx>
35
#include <cppuhelper/implbase6.hxx>
36
#include <comphelper/uno3.hxx>
37
38
#include <vector>
39
#include <map>
40
41
namespace rtl { template <class reference_type> class Reference; }
42
namespace com::sun::star::uno { class XComponentContext; }
43
44
typedef std::map<sal_uInt16, css::uno::Any> ImplPropertyTable;
45
46
typedef ::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
52
                                    >   UnoControlModel_Base;
53
54
class TOOLKIT_DLLPUBLIC UnoControlModel : public UnoControlModel_Base
55
                       ,public ::comphelper::OPropertySetHelper
56
{
57
private:
58
    ImplPropertyTable                       maData;
59
    EventListenerMultiplexer                maDisposeListeners;
60
61
protected:
62
    css::uno::Reference< css::uno::XComponentContext > m_xContext;
63
64
protected:
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
72
    /** called before setting multiple properties, allows to care for property dependencies
73
74
        <p>When multiple property values are set (e.g. XPropertySet::setPropertyValues), it may happen that some
75
        of them are dependent. For this, derivees which know such dependencies can affect the order in which
76
        the properties are internally really set.</p>
77
    */
78
    virtual void ImplNormalizePropertySequence(
79
                    const sal_Int32                 _nCount,        /// the number of entries in the arrays
80
                    sal_Int32*                      _pHandles,      /// the handles of the properties to set
81
                    css::uno::Any*     _pValues,       /// the values of the properties to set
82
                    sal_Int32*                      _pValidHandles  /// pointer to the valid handles, allowed to be adjusted
83
                )   const;
84
85
    /// ensures that two property values in a sequence have a certain order
86
    static void ImplEnsureHandleOrder(
87
                const sal_Int32 _nCount,                /// number of entries in the array
88
                sal_Int32* _pHandles,                   /// pointer to the handles
89
                css::uno::Any* _pValues,   /// pointer to the values
90
                sal_Int32 _nFirstHandle,                /// first handle, which should precede _nSecondHandle in the sequence
91
                sal_Int32 _nSecondHandle                /// second handle, which should supersede _nFirstHandle in the sequence
92
            );
93
94
0
    template<typename T> void UNO_CONTROL_MODEL_REGISTER_PROPERTIES() {
95
0
        std::vector< sal_uInt16 > aIds;
96
0
        T::ImplGetPropertyIds( aIds );
97
0
        ImplRegisterProperties( aIds );
98
0
    }
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXScrollBar>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXEdit>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXButton>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXImageControl>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXRadioButton>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXCheckBox>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXFixedHyperlink>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXFixedText>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXListBox>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXComboBox>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXDateField>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXTimeField>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXNumericField>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<SVTXCurrencyField>()
Unexecuted instantiation: void UnoControlModel::UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXPatternField>()
99
100
protected:
101
#ifdef _MSC_VER
102
    UnoControlModel() //do not use! needed by MSVC at compile time to satisfy WeakAggImplHelper7
103
        : UnoControlModel_Base()
104
        , OPropertySetHelper()
105
        , maDisposeListeners( *this )
106
        , m_xContext( css::uno::Reference< css::uno::XComponentContext >() )
107
    {
108
        assert(false);
109
    }
110
#endif
111
112
public:
113
                UnoControlModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
114
                UnoControlModel( const UnoControlModel& rModel );
115
116
    virtual rtl::Reference<UnoControlModel> Clone() const = 0;
117
118
    // css::uno::XInterface
119
124
    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;
156
    void setFastPropertyValue_NoBroadcast(
157
                std::unique_lock<std::mutex>& rGuard,
158
                sal_Int32 nHandle, const css::uno::Any& rValue ) override;
159
    using comphelper::OPropertySetHelper::getFastPropertyValue;
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;
165
protected:
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
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */