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