/src/libreoffice/lingucomponent/source/spellcheck/spell/sspellimp.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 | | #ifndef INCLUDED_LINGUCOMPONENT_SOURCE_SPELLCHECK_SPELL_SSPELLIMP_HXX |
21 | | #define INCLUDED_LINGUCOMPONENT_SOURCE_SPELLCHECK_SPELL_SSPELLIMP_HXX |
22 | | |
23 | | #include <comphelper/interfacecontainer3.hxx> |
24 | | #include <cppuhelper/implbase.hxx> |
25 | | #include <com/sun/star/lang/XComponent.hpp> |
26 | | #include <com/sun/star/lang/XInitialization.hpp> |
27 | | #include <com/sun/star/lang/XServiceDisplayName.hpp> |
28 | | #include <com/sun/star/beans/PropertyValue.hpp> |
29 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
30 | | #include <com/sun/star/linguistic2/XSpellChecker.hpp> |
31 | | #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> |
32 | | |
33 | | #include <linguistic/lngprophelp.hxx> |
34 | | |
35 | | #include <memory> |
36 | | |
37 | | #include <hunspell.hxx> |
38 | | |
39 | | using namespace ::com::sun::star::uno; |
40 | | using namespace ::com::sun::star::beans; |
41 | | using namespace ::com::sun::star::lang; |
42 | | using namespace ::com::sun::star::linguistic2; |
43 | | |
44 | | class SpellChecker : |
45 | | public cppu::WeakImplHelper |
46 | | < |
47 | | XSpellChecker, |
48 | | XLinguServiceEventBroadcaster, |
49 | | XInitialization, |
50 | | XComponent, |
51 | | XServiceInfo, |
52 | | XServiceDisplayName |
53 | | > |
54 | | { |
55 | | struct DictItem |
56 | | { |
57 | | OUString m_aDName; |
58 | | Locale m_aDLoc; |
59 | | std::unique_ptr<Hunspell> m_pDict; |
60 | | rtl_TextEncoding m_aDEnc; |
61 | | |
62 | | DictItem(OUString i_DName, Locale i_DLoc, rtl_TextEncoding i_DEnc); |
63 | | }; |
64 | | |
65 | | std::vector<DictItem> m_DictItems; |
66 | | |
67 | | Sequence< Locale > m_aSuppLocales; |
68 | | |
69 | | ::comphelper::OInterfaceContainerHelper3<XEventListener> m_aEvtListeners; |
70 | | std::unique_ptr<linguistic::PropertyHelper_Spelling> m_pPropHelper; |
71 | | bool m_bDisposing; |
72 | | |
73 | | SpellChecker(const SpellChecker &) = delete; |
74 | | SpellChecker & operator = (const SpellChecker &) = delete; |
75 | | |
76 | | linguistic::PropertyHelper_Spelling& GetPropHelper_Impl(); |
77 | | linguistic::PropertyHelper_Spelling& GetPropHelper() |
78 | 0 | { |
79 | 0 | return m_pPropHelper ? *m_pPropHelper : GetPropHelper_Impl(); |
80 | 0 | } |
81 | | |
82 | | sal_Int16 GetSpellFailure( const OUString &rWord, const Locale &rLocale, int& rInfo ); |
83 | | Reference< XSpellAlternatives > GetProposals( const OUString &rWord, const Locale &rLocale ); |
84 | | |
85 | | public: |
86 | | SpellChecker(); |
87 | | virtual ~SpellChecker() override; |
88 | | |
89 | | // XSupportedLocales (for XSpellChecker) |
90 | | virtual Sequence< Locale > SAL_CALL getLocales() override; |
91 | | virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) override; |
92 | | |
93 | | // XSpellChecker |
94 | | virtual sal_Bool SAL_CALL isValid( const OUString& rWord, const Locale& rLocale, const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override; |
95 | | virtual Reference< XSpellAlternatives > SAL_CALL spell( const OUString& rWord, const Locale& rLocale, const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override; |
96 | | |
97 | | // XLinguServiceEventBroadcaster |
98 | | virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) override; |
99 | | virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) override; |
100 | | |
101 | | // XServiceDisplayName |
102 | | virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) override; |
103 | | |
104 | | // XInitialization |
105 | | virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) override; |
106 | | |
107 | | // XComponent |
108 | | virtual void SAL_CALL dispose() override; |
109 | | virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) override; |
110 | | virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) override; |
111 | | |
112 | | // XServiceInfo |
113 | | virtual OUString SAL_CALL getImplementationName() override; |
114 | | virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; |
115 | | virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
116 | | }; |
117 | | |
118 | | #endif |
119 | | |
120 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |