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