Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/toolkit/inc/controls/formattedcontrol.hxx
Line
Count
Source (jump to first uncovered line)
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/controls/unocontrols.hxx>
23
#include <toolkit/controls/unocontrolmodel.hxx>
24
25
namespace com::sun::star::util { class XNumberFormatter; }
26
27
28
namespace toolkit
29
{
30
31
32
    // = UnoControlFormattedFieldModel
33
34
    class UnoControlFormattedFieldModel final : public UnoControlModel
35
    {
36
    public:
37
        UnoControlFormattedFieldModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
38
        UnoControlFormattedFieldModel( const UnoControlFormattedFieldModel& rModel )
39
0
            : UnoControlModel(rModel)
40
0
            , m_bRevokedAsClient(false)
41
0
            , m_bSettingValueAndText(false)
42
0
        {
43
0
        }
44
45
0
        rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlFormattedFieldModel( *this ); }
46
47
        // css::io::XPersistObject
48
        OUString SAL_CALL getServiceName() override;
49
50
        // css::beans::XMultiPropertySet
51
        css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) override;
52
53
54
        // css::lang::XServiceInfo
55
        OUString SAL_CALL getImplementationName() override;
56
57
        css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
58
59
    private:
60
        virtual ~UnoControlFormattedFieldModel() override;
61
62
        // XComponent
63
        void SAL_CALL dispose() override;
64
65
        // XPropertySet
66
        void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Sequence< css::uno::Any >& Values ) override;
67
68
        // UnoControlModel
69
        virtual void ImplNormalizePropertySequence(
70
                        const sal_Int32                 _nCount,        /// the number of entries in the arrays
71
                        sal_Int32*                      _pHandles,      /// the handles of the properties to set
72
                        css::uno::Any*     _pValues,       /// the values of the properties to set
73
                        sal_Int32*                      _pValidHandles  /// pointer to the valid handles, allowed to be adjusted
74
                    )   const override;
75
        void    impl_updateTextFromValue_nothrow(std::unique_lock<std::mutex>& rGuard);
76
        void    impl_updateCachedFormatter_nothrow(std::unique_lock<std::mutex>& rGuard);
77
        void    impl_updateCachedFormatKey_nothrow(std::unique_lock<std::mutex>& rGuard);
78
79
        css::uno::Any      ImplGetDefaultValue( sal_uInt16 nPropId ) const override;
80
        ::cppu::IPropertyArrayHelper& getInfoHelper() override;
81
        bool convertFastPropertyValue(
82
                    std::unique_lock<std::mutex>& rGuard,
83
                    css::uno::Any& rConvertedValue,
84
                    css::uno::Any& rOldValue,
85
                    sal_Int32 nPropId,
86
                    const css::uno::Any& rValue
87
                ) override;
88
89
        void setFastPropertyValue_NoBroadcast(
90
                    std::unique_lock<std::mutex>& rGuard,
91
                    sal_Int32 nHandle,
92
                    const css::uno::Any& rValue
93
                ) override;
94
95
        css::uno::Any      m_aCachedFormat;
96
        bool               m_bRevokedAsClient;
97
        bool               m_bSettingValueAndText;
98
        css::uno::Reference< css::util::XNumberFormatter >
99
                           m_xCachedFormatter;
100
    };
101
102
103
    // = UnoFormattedFieldControl
104
105
    class UnoFormattedFieldControl final : public UnoSpinFieldControl
106
    {
107
    public:
108
                            UnoFormattedFieldControl();
109
        OUString     GetComponentServiceName() const override;
110
111
        // css::awt::XTextListener
112
        void SAL_CALL textChanged( const css::awt::TextEvent& rEvent ) override;
113
114
        // css::lang::XServiceInfo
115
        OUString SAL_CALL getImplementationName() override;
116
117
        css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
118
    };
119
120
121
}   // namespace toolkit
122
123
124
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */