Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/linguistic/source/hyphdsp.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 <com/sun/star/linguistic2/XHyphenator.hpp>
23
#include <com/sun/star/linguistic2/XPossibleHyphens.hpp>
24
#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
25
26
#include <cppuhelper/implbase.hxx>
27
28
#include <map>
29
#include <memory>
30
31
#include <linguistic/misc.hxx>
32
#include "defs.hxx"
33
34
class LngSvcMgr;
35
namespace linguistic { class HyphenatedWord; class PossibleHyphens; }
36
37
class HyphenatorDispatcher :
38
    public cppu::WeakImplHelper
39
    <
40
        css::linguistic2::XHyphenator
41
    >,
42
    public LinguDispatcher
43
{
44
    typedef std::shared_ptr< LangSvcEntries_Hyph >                LangSvcEntries_Hyph_Ptr_t;
45
    typedef std::map< LanguageType, LangSvcEntries_Hyph_Ptr_t >     HyphSvcByLangMap_t;
46
    HyphSvcByLangMap_t      aSvcMap;
47
48
    css::uno::Reference< css::linguistic2::XLinguProperties >          xPropSet;
49
    css::uno::Reference< css::linguistic2::XSearchableDictionaryList > xDicList;
50
51
    LngSvcMgr      &rMgr;
52
53
    HyphenatorDispatcher(const HyphenatorDispatcher &) = delete;
54
    HyphenatorDispatcher & operator = (const HyphenatorDispatcher &) = delete;
55
56
    inline const css::uno::Reference< css::linguistic2::XLinguProperties > &
57
            GetPropSet();
58
    inline const css::uno::Reference< css::linguistic2::XSearchableDictionaryList > &
59
            GetDicList();
60
61
    void    ClearSvcList();
62
63
    static rtl::Reference< linguistic::HyphenatedWord >
64
            buildHyphWord( const OUString& rOrigWord,
65
                const css::uno::Reference< css::linguistic2::XDictionaryEntry> &xEntry,
66
                LanguageType nLang, sal_Int16 nMaxLeading );
67
68
    static rtl::Reference< linguistic::PossibleHyphens >
69
            buildPossHyphens( const css::uno::Reference< css::linguistic2::XDictionaryEntry > &xEntry,
70
                    LanguageType nLanguage );
71
72
public:
73
    explicit HyphenatorDispatcher( LngSvcMgr &rLngSvcMgr );
74
    virtual ~HyphenatorDispatcher() override;
75
76
    // XSupportedLocales
77
    virtual css::uno::Sequence< css::lang::Locale > SAL_CALL
78
        getLocales() override;
79
    virtual sal_Bool SAL_CALL
80
        hasLocale( const css::lang::Locale& aLocale ) override;
81
82
    // XHyphenator
83
    virtual css::uno::Reference< css::linguistic2::XHyphenatedWord > SAL_CALL
84
        hyphenate( const OUString& aWord,
85
                const css::lang::Locale& aLocale,
86
                sal_Int16 nMaxLeading,
87
                const css::uno::Sequence< ::css::beans::PropertyValue >& aProperties ) override;
88
    virtual css::uno::Reference< css::linguistic2::XHyphenatedWord > SAL_CALL
89
        queryAlternativeSpelling( const OUString& aWord,
90
                const css::lang::Locale& aLocale,
91
                sal_Int16 nIndex,
92
                const css::uno::Sequence< ::css::beans::PropertyValue >& aProperties ) override;
93
    virtual css::uno::Reference<
94
            css::linguistic2::XPossibleHyphens > SAL_CALL
95
        createPossibleHyphens(
96
                const OUString& aWord,
97
                const css::lang::Locale& aLocale,
98
                const css::uno::Sequence< ::css::beans::PropertyValue >& aProperties ) override;
99
100
    // LinguDispatcher
101
    virtual void
102
        SetServiceList( const css::lang::Locale &rLocale,
103
                const css::uno::Sequence< OUString > &rSvcImplNames ) override;
104
    virtual css::uno::Sequence< OUString >
105
        GetServiceList( const css::lang::Locale &rLocale ) const override;
106
};
107
108
109
inline const css::uno::Reference< css::linguistic2::XLinguProperties > &
110
        HyphenatorDispatcher::GetPropSet()
111
0
{
112
0
    if (!xPropSet.is())
113
0
        xPropSet = ::linguistic::GetLinguProperties();
114
0
    return xPropSet;
115
0
}
116
117
118
inline const css::uno::Reference< css::linguistic2::XSearchableDictionaryList > &
119
        HyphenatorDispatcher::GetDicList()
120
0
{
121
0
    if (!xDicList.is())
122
0
        xDicList = ::linguistic::GetDictionaryList();
123
0
    return xDicList;
124
0
}
125
126
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */