Line data Source code
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 <cppuhelper/implbase1.hxx>
24 : #include <cppuhelper/implbase6.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/XPropertySet.hpp>
29 : #include <com/sun/star/beans/PropertyValues.hpp>
30 : #include <com/sun/star/lang/XServiceInfo.hpp>
31 : #include <com/sun/star/linguistic2/XSpellChecker.hpp>
32 : #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
33 : #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
34 :
35 : #include <linguistic/misc.hxx>
36 : #include <linguistic/lngprophelp.hxx>
37 :
38 : #include <lingutil.hxx>
39 :
40 : using namespace ::com::sun::star::uno;
41 : using namespace ::com::sun::star::beans;
42 : using namespace ::com::sun::star::lang;
43 : using namespace ::com::sun::star::linguistic2;
44 :
45 : class Hunspell;
46 :
47 : class SpellChecker :
48 : public cppu::WeakImplHelper6
49 : <
50 : XSpellChecker,
51 : XLinguServiceEventBroadcaster,
52 : XInitialization,
53 : XComponent,
54 : XServiceInfo,
55 : XServiceDisplayName
56 : >
57 : {
58 : Sequence< Locale > aSuppLocales;
59 : Hunspell ** aDicts;
60 : rtl_TextEncoding * aDEncs;
61 : Locale * aDLocs;
62 : OUString * aDNames;
63 : sal_Int32 numdict;
64 :
65 : ::cppu::OInterfaceContainerHelper aEvtListeners;
66 : linguistic::PropertyHelper_Spelling* pPropHelper;
67 : bool bDisposing;
68 :
69 : SpellChecker(const SpellChecker &) SAL_DELETED_FUNCTION;
70 : SpellChecker & operator = (const SpellChecker &) SAL_DELETED_FUNCTION;
71 :
72 : linguistic::PropertyHelper_Spelling& GetPropHelper_Impl();
73 71072155 : linguistic::PropertyHelper_Spelling& GetPropHelper()
74 : {
75 71072155 : return pPropHelper ? *pPropHelper : GetPropHelper_Impl();
76 : }
77 :
78 : sal_Int16 GetSpellFailure( const OUString &rWord, const Locale &rLocale );
79 : Reference< XSpellAlternatives > GetProposals( const OUString &rWord, const Locale &rLocale );
80 :
81 : public:
82 : SpellChecker();
83 : virtual ~SpellChecker();
84 :
85 : // XSupportedLocales (for XSpellChecker)
86 : virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException, std::exception) SAL_OVERRIDE;
87 : virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
88 :
89 : // XSpellChecker
90 : virtual sal_Bool SAL_CALL isValid( const OUString& rWord, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException, std::exception) SAL_OVERRIDE;
91 : virtual Reference< XSpellAlternatives > SAL_CALL spell( const OUString& rWord, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException, std::exception) SAL_OVERRIDE;
92 :
93 : // XLinguServiceEventBroadcaster
94 : virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
95 : virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
96 :
97 : // XServiceDisplayName
98 : virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
99 :
100 : // XInitialization
101 : virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException, std::exception) SAL_OVERRIDE;
102 :
103 : // XComponent
104 : virtual void SAL_CALL dispose() throw(RuntimeException, std::exception) SAL_OVERRIDE;
105 : virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
106 : virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
107 :
108 : // XServiceInfo
109 : virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) SAL_OVERRIDE;
110 : virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
111 : virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
112 :
113 : static inline OUString getImplementationName_Static() throw();
114 : static Sequence< OUString > getSupportedServiceNames_Static() throw();
115 : };
116 :
117 130 : inline OUString SpellChecker::getImplementationName_Static() throw()
118 : {
119 130 : return OUString( "org.openoffice.lingu.MySpellSpellChecker" );
120 : }
121 :
122 : void * SAL_CALL SpellChecker_getFactory(
123 : char const * pImplName, css::lang::XMultiServiceFactory * pServiceManager,
124 : void *);
125 :
126 : #endif
127 :
128 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|