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
25 #ifndef _LINGU2_HYPHENIMP_HXX_
26 #define _LINGU2_HYPHENIMP_HXX_
27
28 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
29 #include <cppuhelper/implbase1.hxx> // helper for implementations
30 #include <cppuhelper/implbase6.hxx> // helper for implementations
31 #include <com/sun/star/lang/XComponent.hpp>
32 #include <com/sun/star/lang/XInitialization.hpp>
33 #include <com/sun/star/lang/XServiceDisplayName.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/beans/PropertyValues.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/linguistic2/XHyphenator.hpp>
38 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
39 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
40 #include <tools/table.hxx>
41
42 #include <unotools/charclass.hxx>
43
44 #include <linguistic/misc.hxx>
45 #include <linguistic/lngprophelp.hxx>
46
47 #include <lingutil.hxx>
48 #include <stdio.h>
49
50 using namespace ::rtl;
51 using namespace ::com::sun::star::uno;
52 using namespace ::com::sun::star::beans;
53 using namespace ::com::sun::star::lang;
54 using namespace ::com::sun::star::linguistic2;
55
56
57 ///////////////////////////////////////////////////////////////////////////
58
59
60 struct HDInfo {
61 HyphenDict * aPtr;
62 OUString aName;
63 Locale aLoc;
64 rtl_TextEncoding eEnc;
65 CharClass * apCC;
66 };
67
68
69
70 class Hyphenator :
71 public cppu::WeakImplHelper6
72 <
73 XHyphenator,
74 XLinguServiceEventBroadcaster,
75 XInitialization,
76 XComponent,
77 XServiceInfo,
78 XServiceDisplayName
79 >
80 {
81 Sequence< Locale > aSuppLocales;
82 HDInfo * aDicts;
83 sal_Int32 numdict;
84
85 ::cppu::OInterfaceContainerHelper aEvtListeners;
86 Reference< XMultiServiceFactory > rSMgr;
87 linguistic::PropertyHelper_Hyphenation* pPropHelper;
88 sal_Bool bDisposing;
89
90 // disallow copy-constructor and assignment-operator for now
91 Hyphenator(const Hyphenator &);
92 Hyphenator & operator = (const Hyphenator &);
93
94 linguistic::PropertyHelper_Hyphenation& GetPropHelper_Impl();
GetPropHelper()95 linguistic::PropertyHelper_Hyphenation& GetPropHelper()
96 {
97 return pPropHelper ? *pPropHelper : GetPropHelper_Impl();
98 }
99
100 public:
101 Hyphenator();
102
103 virtual ~Hyphenator();
104
105 // XSupportedLocales (for XHyphenator)
106 virtual Sequence< Locale > SAL_CALL getLocales();
107 virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale );
108
109 // XHyphenator
110 virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL hyphenate( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nMaxLeading, const ::com::sun::star::beans::PropertyValues& aProperties );
111 virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL queryAlternativeSpelling( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nIndex, const ::com::sun::star::beans::PropertyValues& aProperties );
112 virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XPossibleHyphens > SAL_CALL createPossibleHyphens( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, const ::com::sun::star::beans::PropertyValues& aProperties );
113
114 // XLinguServiceEventBroadcaster
115 virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr );
116 virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr );
117
118 // XServiceDisplayName
119 virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale );
120
121 // XInitialization
122 virtual void SAL_CALL initialize( const Sequence< Any >& rArguments );
123
124 // XComponent
125 virtual void SAL_CALL dispose();
126 virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener );
127 virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener );
128
129 // XServiceInfo
130 virtual OUString SAL_CALL getImplementationName();
131 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName );
132 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames();
133
134
135 static inline OUString getImplementationName_Static() throw();
136 static Sequence< OUString > getSupportedServiceNames_Static() throw();
137
138
139 private:
140 sal_uInt16 SAL_CALL capitalType(const OUString&, CharClass *);
141 OUString SAL_CALL makeLowerCase(const OUString&, CharClass *);
142 OUString SAL_CALL makeUpperCase(const OUString&, CharClass *);
143 OUString SAL_CALL makeInitCap(const OUString&, CharClass *);
144 };
145
getImplementationName_Static()146 inline OUString Hyphenator::getImplementationName_Static() throw()
147 {
148 return A2OU( "org.openoffice.lingu.LibHnjHyphenator" );
149 }
150
151
152 ///////////////////////////////////////////////////////////////////////////
153
154 #endif
155