xref: /trunk/main/linguistic/workben/sspellimp.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*63ce064aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*63ce064aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*63ce064aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*63ce064aSAndrew Rist  * distributed with this work for additional information
6*63ce064aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*63ce064aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*63ce064aSAndrew Rist  * "License"); you may not use this file except in compliance
9*63ce064aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*63ce064aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*63ce064aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*63ce064aSAndrew Rist  * software distributed under the License is distributed on an
15*63ce064aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63ce064aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*63ce064aSAndrew Rist  * specific language governing permissions and limitations
18*63ce064aSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*63ce064aSAndrew Rist  *************************************************************/
21*63ce064aSAndrew Rist 
22*63ce064aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _LINGU2_SPELLIMP_HXX_
25cdf0e10cSrcweir #define _LINGU2_SPELLIMP_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <uno/lbnames.h>            // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
28cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> // helper for implementations
29cdf0e10cSrcweir #include <cppuhelper/implbase6.hxx> // helper for implementations
30cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
31cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XServiceDisplayName.hpp>
33cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
34cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValues.hpp>
35cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
36cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellChecker.hpp>
37cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
38cdf0e10cSrcweir #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
39cdf0e10cSrcweir #include <tools/table.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "linguistic/misc.hxx"
42cdf0e10cSrcweir #include "sprophelp.hxx"
43cdf0e10cSrcweir 
44cdf0e10cSrcweir using namespace ::rtl;
45cdf0e10cSrcweir using namespace ::com::sun::star::uno;
46cdf0e10cSrcweir using namespace ::com::sun::star::beans;
47cdf0e10cSrcweir using namespace ::com::sun::star::lang;
48cdf0e10cSrcweir using namespace ::com::sun::star::linguistic2;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #define A2OU(x) ::rtl::OUString::createFromAscii( x )
52cdf0e10cSrcweir 
53cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir class SpellChecker :
57cdf0e10cSrcweir     public cppu::WeakImplHelper6
58cdf0e10cSrcweir     <
59cdf0e10cSrcweir         XSpellChecker,
60cdf0e10cSrcweir         XLinguServiceEventBroadcaster,
61cdf0e10cSrcweir         XInitialization,
62cdf0e10cSrcweir         XComponent,
63cdf0e10cSrcweir         XServiceInfo,
64cdf0e10cSrcweir         XServiceDisplayName
65cdf0e10cSrcweir     >
66cdf0e10cSrcweir {
67cdf0e10cSrcweir     Sequence< Locale >                      aSuppLocales;
68cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper       aEvtListeners;
69cdf0e10cSrcweir     Reference< XPropertyChangeListener >    xPropHelper;
70cdf0e10cSrcweir     PropertyHelper_Spell *                  pPropHelper;
71cdf0e10cSrcweir     BOOL                                    bDisposing;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     // disallow copy-constructor and assignment-operator for now
74cdf0e10cSrcweir     SpellChecker(const SpellChecker &);
75cdf0e10cSrcweir     SpellChecker & operator = (const SpellChecker &);
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     PropertyHelper_Spell &  GetPropHelper_Impl();
GetPropHelper()78cdf0e10cSrcweir     PropertyHelper_Spell &  GetPropHelper()
79cdf0e10cSrcweir     {
80cdf0e10cSrcweir         return pPropHelper ? *pPropHelper : GetPropHelper_Impl();
81cdf0e10cSrcweir     }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     INT16   GetSpellFailure( const OUString &rWord, const Locale &rLocale );
84cdf0e10cSrcweir     Reference< XSpellAlternatives >
85cdf0e10cSrcweir             GetProposals( const OUString &rWord, const Locale &rLocale );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir public:
88cdf0e10cSrcweir     SpellChecker();
89cdf0e10cSrcweir     virtual ~SpellChecker();
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     // XSupportedLocales (for XSpellChecker)
92cdf0e10cSrcweir     virtual Sequence< Locale > SAL_CALL
93cdf0e10cSrcweir         getLocales()
94cdf0e10cSrcweir             throw(RuntimeException);
95cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
96cdf0e10cSrcweir         hasLocale( const Locale& rLocale )
97cdf0e10cSrcweir             throw(RuntimeException);
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     // XSpellChecker
100cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
101cdf0e10cSrcweir         isValid( const OUString& rWord, const Locale& rLocale,
102cdf0e10cSrcweir                 const PropertyValues& rProperties )
103cdf0e10cSrcweir             throw(IllegalArgumentException,
104cdf0e10cSrcweir                   RuntimeException);
105cdf0e10cSrcweir     virtual Reference< XSpellAlternatives > SAL_CALL
106cdf0e10cSrcweir         spell( const OUString& rWord, const Locale& rLocale,
107cdf0e10cSrcweir                 const PropertyValues& rProperties )
108cdf0e10cSrcweir             throw(IllegalArgumentException,
109cdf0e10cSrcweir                   RuntimeException);
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     // XLinguServiceEventBroadcaster
112cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
113cdf0e10cSrcweir         addLinguServiceEventListener(
114cdf0e10cSrcweir             const Reference< XLinguServiceEventListener >& rxLstnr )
115cdf0e10cSrcweir             throw(RuntimeException);
116cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
117cdf0e10cSrcweir         removeLinguServiceEventListener(
118cdf0e10cSrcweir             const Reference< XLinguServiceEventListener >& rxLstnr )
119cdf0e10cSrcweir             throw(RuntimeException);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     // XServiceDisplayName
122cdf0e10cSrcweir     virtual OUString SAL_CALL
123cdf0e10cSrcweir         getServiceDisplayName( const Locale& rLocale )
124cdf0e10cSrcweir             throw(RuntimeException);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     // XInitialization
127cdf0e10cSrcweir     virtual void SAL_CALL
128cdf0e10cSrcweir         initialize( const Sequence< Any >& rArguments )
129cdf0e10cSrcweir             throw(Exception, RuntimeException);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     // XComponent
132cdf0e10cSrcweir     virtual void SAL_CALL
133cdf0e10cSrcweir         dispose()
134cdf0e10cSrcweir             throw(RuntimeException);
135cdf0e10cSrcweir     virtual void SAL_CALL
136cdf0e10cSrcweir         addEventListener( const Reference< XEventListener >& rxListener )
137cdf0e10cSrcweir             throw(RuntimeException);
138cdf0e10cSrcweir     virtual void SAL_CALL
139cdf0e10cSrcweir         removeEventListener( const Reference< XEventListener >& rxListener )
140cdf0e10cSrcweir             throw(RuntimeException);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     ////////////////////////////////////////////////////////////
143cdf0e10cSrcweir     // Service specific part
144cdf0e10cSrcweir     //
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     // XServiceInfo
147cdf0e10cSrcweir     virtual OUString SAL_CALL
148cdf0e10cSrcweir         getImplementationName()
149cdf0e10cSrcweir             throw(RuntimeException);
150cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
151cdf0e10cSrcweir         supportsService( const OUString& rServiceName )
152cdf0e10cSrcweir             throw(RuntimeException);
153cdf0e10cSrcweir     virtual Sequence< OUString > SAL_CALL
154cdf0e10cSrcweir         getSupportedServiceNames()
155cdf0e10cSrcweir             throw(RuntimeException);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     static inline OUString
159cdf0e10cSrcweir         getImplementationName_Static() throw();
160cdf0e10cSrcweir     static Sequence< OUString >
161cdf0e10cSrcweir         getSupportedServiceNames_Static() throw();
162cdf0e10cSrcweir };
163cdf0e10cSrcweir 
getImplementationName_Static()164cdf0e10cSrcweir inline OUString SpellChecker::getImplementationName_Static() throw()
165cdf0e10cSrcweir {
166cdf0e10cSrcweir     return A2OU( "com.sun.star.lingu.examples.SpellChecker" );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 
170cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
171cdf0e10cSrcweir 
172cdf0e10cSrcweir #endif
173