Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/linguistic/source/lngopt.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 <cppuhelper/implbase.hxx>
23
#include <comphelper/interfacecontainer3.hxx>
24
#include <comphelper/multiinterfacecontainer3.hxx>
25
#include <com/sun/star/beans/XFastPropertySet.hpp>
26
#include <com/sun/star/beans/XPropertyAccess.hpp>
27
#include <com/sun/star/lang/XServiceInfo.hpp>
28
#include <com/sun/star/lang/XComponent.hpp>
29
#include <com/sun/star/linguistic2/XLinguProperties.hpp>
30
#include <unotools/lingucfg.hxx>
31
#include <svl/itemprop.hxx>
32
#include <unotools/linguprops.hxx>
33
#include <com/sun/star/uno/Any.h>
34
35
namespace com::sun::star {
36
    namespace beans {
37
        struct PropertyChangeEvent;
38
    }
39
}
40
41
42
// LinguOptions
43
// This class represents all Linguistik relevant options.
44
45
class LinguOptions
46
{
47
    static SvtLinguOptions     *pData;
48
    static oslInterlockedCount  nRefCount;  // number of objects of this class
49
50
public:
51
    LinguOptions();
52
    LinguOptions(const LinguOptions &rOpt);
53
    ~LinguOptions();
54
55
    static OUString    GetName( sal_Int32 nWID );
56
57
    const css::uno::Sequence< OUString >&
58
0
            GetActiveDics() const   { return pData->aActiveDics; }
59
};
60
61
typedef comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XPropertyChangeListener, sal_Int32>
62
    OPropertyListenerContainerHelper;
63
64
class LinguProps :
65
    public cppu::WeakImplHelper
66
    <
67
        css::linguistic2::XLinguProperties,
68
        css::beans::XFastPropertySet,
69
        css::beans::XPropertyAccess,
70
        css::lang::XComponent,
71
        css::lang::XServiceInfo
72
    >
73
{
74
    ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> aEvtListeners;
75
    OPropertyListenerContainerHelper            aPropListeners;
76
77
    SfxItemPropertyMap                          aPropertyMap;
78
    SvtLinguConfig                              aConfig;
79
80
    bool                                        bDisposing;
81
82
    LinguProps(const LinguProps &) = delete;
83
    LinguProps & operator = (const LinguProps &) = delete;
84
85
    void    launchEvent( const css::beans::PropertyChangeEvent &rEvt ) const;
86
87
    /// @throws css::uno::RuntimeException
88
    bool getPropertyBool(const OUString& aPropertyName);
89
    /// @throws css::uno::RuntimeException
90
    sal_Int16 getPropertyInt16(const OUString& aPropertyName);
91
    /// @throws css::uno::RuntimeException
92
    css::lang::Locale getPropertyLocale(const OUString& aPropertyName);
93
    /// @throws css::uno::RuntimeException
94
    void setProperty(const OUString& aPropertyName, bool p1)
95
0
        { setPropertyValue( aPropertyName, css::uno::Any(p1) ); }
96
    /// @throws css::uno::RuntimeException
97
    void setProperty(const OUString& aPropertyName, sal_Int16 p1)
98
0
        { setPropertyValue( aPropertyName, css::uno::Any(p1) ); }
99
    /// @throws css::uno::RuntimeException
100
    void setProperty(const OUString& aPropertyName, css::lang::Locale p1)
101
0
        { setPropertyValue( aPropertyName, css::uno::Any(p1) ); }
102
103
public:
104
    LinguProps();
105
106
    virtual sal_Bool SAL_CALL getIsUseDictionaryList() override
107
0
        { return getPropertyBool(UPN_IS_USE_DICTIONARY_LIST); }
108
    virtual void SAL_CALL setIsUseDictionaryList(sal_Bool p1) override
109
0
        { setProperty(UPN_IS_USE_DICTIONARY_LIST, static_cast<bool>(p1)); }
110
    virtual sal_Bool SAL_CALL getIsIgnoreControlCharacters() override
111
0
        { return getPropertyBool(UPN_IS_IGNORE_CONTROL_CHARACTERS); }
112
    virtual void SAL_CALL setIsIgnoreControlCharacters(sal_Bool p1) override
113
0
        { setProperty(UPN_IS_IGNORE_CONTROL_CHARACTERS, static_cast<bool>(p1)); }
114
    virtual sal_Bool SAL_CALL getIsSpellUpperCase() override
115
0
        { return getPropertyBool(UPN_IS_SPELL_UPPER_CASE); }
116
    virtual void SAL_CALL setIsSpellUpperCase(sal_Bool p1) override
117
0
        { setProperty(UPN_IS_SPELL_UPPER_CASE, static_cast<bool>(p1)); }
118
    virtual sal_Bool SAL_CALL getIsSpellWithDigits() override
119
0
        { return getPropertyBool(UPN_IS_SPELL_WITH_DIGITS); }
120
    virtual void SAL_CALL setIsSpellWithDigits(sal_Bool p1) override
121
0
        { setProperty(UPN_IS_SPELL_WITH_DIGITS, static_cast<bool>(p1)); }
122
    virtual sal_Bool SAL_CALL getIsSpellCapitalization() override
123
0
        { return false; }
124
    virtual void SAL_CALL setIsSpellCapitalization(sal_Bool /*p1*/) override
125
0
        { throw new css::beans::UnknownPropertyException( u"this deprecated property has been removed"_ustr); }
126
    virtual sal_Int16 SAL_CALL getHyphMinLeading() override
127
0
        { return getPropertyInt16(UPN_HYPH_MIN_LEADING); }
128
    virtual void SAL_CALL setHyphMinLeading(sal_Int16 p1) override
129
0
        { setProperty(UPN_HYPH_MIN_LEADING, p1); }
130
    virtual sal_Int16 SAL_CALL getHyphMinTrailing() override
131
0
        { return getPropertyInt16(UPN_HYPH_MIN_TRAILING); }
132
    virtual void SAL_CALL setHyphMinTrailing(sal_Int16 p1) override
133
0
        { setProperty(UPN_HYPH_MIN_TRAILING, p1); }
134
    virtual sal_Int16 SAL_CALL getHyphMinWordLength() override
135
0
        { return getPropertyInt16(UPN_HYPH_MIN_WORD_LENGTH); }
136
    virtual void SAL_CALL setHyphMinWordLength(sal_Int16 p1) override
137
0
        { setProperty(UPN_HYPH_MIN_WORD_LENGTH, p1); }
138
    virtual css::lang::Locale SAL_CALL getDefaultLocale() override
139
0
        { return getPropertyLocale(UPN_DEFAULT_LOCALE); }
140
    virtual void SAL_CALL setDefaultLocale(const css::lang::Locale& p1) override
141
0
        { setProperty(UPN_DEFAULT_LOCALE, p1); }
142
    virtual sal_Bool SAL_CALL getIsHyphAuto() override
143
0
        { return getPropertyBool(UPN_IS_HYPH_AUTO); }
144
    virtual void SAL_CALL setIsHyphAuto(sal_Bool p1) override
145
0
        { setProperty(UPN_IS_HYPH_AUTO, static_cast<bool>(p1)); }
146
    virtual sal_Bool SAL_CALL getIsHyphSpecial() override
147
0
        { return getPropertyBool(UPN_IS_HYPH_SPECIAL); }
148
    virtual void SAL_CALL setIsHyphSpecial(sal_Bool p1) override
149
0
        { setProperty(UPN_IS_HYPH_SPECIAL, static_cast<bool>(p1)); }
150
    virtual sal_Bool SAL_CALL getIsSpellAuto() override
151
0
        { return getPropertyBool(UPN_IS_SPELL_AUTO); }
152
    virtual void SAL_CALL setIsSpellAuto(sal_Bool p1) override
153
0
        { setProperty(UPN_IS_SPELL_AUTO, static_cast<bool>(p1)); }
154
    virtual sal_Bool SAL_CALL getIsSpellSpecial() override
155
0
        { return getPropertyBool(UPN_IS_SPELL_SPECIAL); }
156
    virtual void SAL_CALL setIsSpellSpecial(sal_Bool p1) override
157
0
        { setProperty(UPN_IS_SPELL_SPECIAL, static_cast<bool>(p1)); }
158
    virtual sal_Bool SAL_CALL getIsWrapReverse() override
159
0
        { return getPropertyBool(UPN_IS_WRAP_REVERSE); }
160
    virtual void SAL_CALL setIsWrapReverse(sal_Bool p1) override
161
0
        { setProperty(UPN_IS_WRAP_REVERSE, static_cast<bool>(p1)); }
162
    virtual css::lang::Locale SAL_CALL getDefaultLocale_CJK() override
163
0
        { return getPropertyLocale(UPN_DEFAULT_LOCALE_CJK); }
164
    virtual void SAL_CALL setDefaultLocale_CJK(const css::lang::Locale& p1) override
165
0
        { setProperty(UPN_DEFAULT_LOCALE_CJK, p1); }
166
    virtual css::lang::Locale SAL_CALL getDefaultLocale_CTL() override
167
0
        { return getPropertyLocale(UPN_DEFAULT_LOCALE_CTL); }
168
    virtual void SAL_CALL setDefaultLocale_CTL(const css::lang::Locale& p1) override
169
0
        { setProperty(UPN_DEFAULT_LOCALE_CTL, p1); }
170
171
    // XPropertySet
172
    virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
173
    virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
174
    virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
175
    virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override;
176
    virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override;
177
    virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override;
178
    virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override;
179
180
    // XFastPropertySet
181
    virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& aValue ) override;
182
    virtual css::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) override;
183
184
    // XPropertyAccess
185
    virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override;
186
    virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& aProps ) override;
187
188
    // XComponent
189
    virtual void SAL_CALL dispose() override;
190
    virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) override;
191
    virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) override;
192
193
    // XServiceInfo
194
    virtual OUString SAL_CALL getImplementationName() override;
195
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
196
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
197
};
198
199
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */