Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/linguistic/source/dlistimp.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 <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
23
#include <com/sun/star/lang/XComponent.hpp>
24
#include <com/sun/star/lang/XServiceInfo.hpp>
25
#include <com/sun/star/lang/XInitialization.hpp>
26
27
#include <comphelper/interfacecontainer3.hxx>
28
#include <cppuhelper/implbase.hxx>
29
#include <rtl/ref.hxx>
30
31
#include <vector>
32
33
#include <linguistic/misc.hxx>
34
#include "lngopt.hxx"
35
36
class DicEvtListenerHelper;
37
38
class DicList : public cppu::WeakImplHelper<css::linguistic2::XSearchableDictionaryList,
39
                                            css::lang::XComponent, css::lang::XServiceInfo,
40
                                            css::lang::XInitialization>
41
{
42
    class MyAppExitListener : public linguistic::AppExitListener
43
    {
44
        DicList & rMyDicList;
45
46
    public:
47
0
        explicit MyAppExitListener( DicList &rDicList ) : rMyDicList( rDicList ) {}
48
        virtual void    AtExit() override;
49
    };
50
51
    LinguOptions    aOpt;
52
53
    ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> aEvtListeners;
54
55
    typedef std::vector< css::uno::Reference< css::linguistic2::XDictionary > >   DictionaryVec_t;
56
    DictionaryVec_t                             aDicList;
57
58
    rtl::Reference<DicEvtListenerHelper>        mxDicEvtLstnrHelper;
59
    rtl::Reference<MyAppExitListener>           mxExitListener;
60
61
    bool    bDisposing;
62
    bool    bInCreation;
63
64
    DicList( const DicList & ) = delete;
65
    DicList & operator = (const DicList &) = delete;
66
67
68
    void                CreateDicList();
69
    DictionaryVec_t &   GetOrCreateDicList()
70
0
                        {
71
0
                            if ( !bInCreation && aDicList.empty() )
72
0
                                CreateDicList();
73
0
                            return aDicList;
74
0
                        }
75
76
    void                SearchForDictionaries( DictionaryVec_t &rDicList,
77
                                            const OUString &rDicDir, bool bIsWritePath );
78
    sal_Int32           GetDicPos(const css::uno::Reference<
79
                            css::linguistic2::XDictionary > &xDic);
80
81
public:
82
    DicList();
83
    virtual ~DicList() override;
84
85
    // XDictionaryList
86
    virtual ::sal_Int16 SAL_CALL getCount(  ) override;
87
    virtual css::uno::Sequence< css::uno::Reference< css::linguistic2::XDictionary > > SAL_CALL getDictionaries(  ) override;
88
    virtual css::uno::Reference< css::linguistic2::XDictionary > SAL_CALL getDictionaryByName( const OUString& aDictionaryName ) override;
89
    virtual sal_Bool SAL_CALL addDictionary( const css::uno::Reference< css::linguistic2::XDictionary >& xDictionary ) override;
90
    virtual sal_Bool SAL_CALL removeDictionary( const css::uno::Reference< css::linguistic2::XDictionary >& xDictionary ) override;
91
    virtual sal_Bool SAL_CALL addDictionaryListEventListener( const css::uno::Reference< css::linguistic2::XDictionaryListEventListener >& xListener, sal_Bool bReceiveVerbose ) override;
92
    virtual sal_Bool SAL_CALL removeDictionaryListEventListener( const css::uno::Reference< css::linguistic2::XDictionaryListEventListener >& xListener ) override;
93
    virtual ::sal_Int16 SAL_CALL beginCollectEvents(  ) override;
94
    virtual ::sal_Int16 SAL_CALL endCollectEvents(  ) override;
95
    virtual ::sal_Int16 SAL_CALL flushEvents(  ) override;
96
    virtual css::uno::Reference< css::linguistic2::XDictionary > SAL_CALL createDictionary( const OUString& aName, const css::lang::Locale& aLocale, css::linguistic2::DictionaryType eDicType, const OUString& aURL ) override;
97
98
    // XSearchableDictionaryList
99
    virtual css::uno::Reference< css::linguistic2::XDictionaryEntry > SAL_CALL queryDictionaryEntry( const OUString& aWord, const css::lang::Locale& aLocale, sal_Bool bSearchPosDics, sal_Bool bSpellEntry ) override;
100
101
    // XComponent
102
    virtual void SAL_CALL dispose() override;
103
    virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
104
    virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
105
106
    // XServiceInfo
107
    virtual OUString SAL_CALL getImplementationName() override;
108
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
109
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
110
111
    // XInitialization
112
    virtual void SAL_CALL
113
    initialize(const css::uno::Sequence<css::uno::Any>& /*rArguments*/) override;
114
115
    // non UNO-specific
116
    void    SaveDics();
117
};
118
119
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */