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