xref: /aoo42x/main/linguistic/source/hyphdsp.hxx (revision 63ce064a)
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
10*63ce064aSAndrew Rist  *
11*63ce064aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*63ce064aSAndrew Rist  *
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.
19*63ce064aSAndrew Rist  *
20*63ce064aSAndrew Rist  *************************************************************/
21*63ce064aSAndrew Rist 
22*63ce064aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _LINGUISTIC_HYPHDSP_HXX_
25cdf0e10cSrcweir #define _LINGUISTIC_HYPHDSP_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
29cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
30cdf0e10cSrcweir #include <com/sun/star/lang/XServiceDisplayName.hpp>
31cdf0e10cSrcweir #include <com/sun/star/linguistic2/XHyphenator.hpp>
32cdf0e10cSrcweir #include <com/sun/star/linguistic2/XPossibleHyphens.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
34cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
35cdf0e10cSrcweir #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <uno/lbnames.h>			// CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
38cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>	// helper for implementations
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
41cdf0e10cSrcweir #include <map>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "lngopt.hxx"
44cdf0e10cSrcweir #include "linguistic/misc.hxx"
45cdf0e10cSrcweir #include "defs.hxx"
46cdf0e10cSrcweir 
47cdf0e10cSrcweir class LngSvcMgr;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
50cdf0e10cSrcweir 
51cdf0e10cSrcweir class HyphenatorDispatcher :
52cdf0e10cSrcweir 	public cppu::WeakImplHelper1
53cdf0e10cSrcweir 	<
54cdf0e10cSrcweir 		::com::sun::star::linguistic2::XHyphenator
55cdf0e10cSrcweir 	>,
56cdf0e10cSrcweir 	public LinguDispatcher
57cdf0e10cSrcweir {
58cdf0e10cSrcweir     typedef boost::shared_ptr< LangSvcEntries_Hyph >                LangSvcEntries_Hyph_Ptr_t;
59cdf0e10cSrcweir     typedef std::map< LanguageType, LangSvcEntries_Hyph_Ptr_t >     HyphSvcByLangMap_t;
60cdf0e10cSrcweir     HyphSvcByLangMap_t      aSvcMap;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
63cdf0e10cSrcweir 		::com::sun::star::beans::XPropertySet >						xPropSet;
64cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
65cdf0e10cSrcweir 		::com::sun::star::linguistic2::XSearchableDictionaryList >	xDicList;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	LngSvcMgr	   &rMgr;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	// disallow copy-constructor and assignment-operator for now
70cdf0e10cSrcweir 	HyphenatorDispatcher(const HyphenatorDispatcher &);
71cdf0e10cSrcweir 	HyphenatorDispatcher & operator = (const HyphenatorDispatcher &);
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	inline ::com::sun::star::uno::Reference<
74cdf0e10cSrcweir 		::com::sun::star::beans::XPropertySet >
75cdf0e10cSrcweir 			GetPropSet();
76cdf0e10cSrcweir 	inline ::com::sun::star::uno::Reference<
77cdf0e10cSrcweir 		::com::sun::star::linguistic2::XSearchableDictionaryList >
78cdf0e10cSrcweir 			GetDicList();
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 	void	ClearSvcList();
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	com::sun::star::uno::Reference<
83cdf0e10cSrcweir 		::com::sun::star::linguistic2::XHyphenatedWord>
84cdf0e10cSrcweir             buildHyphWord( const rtl::OUString rOrigWord,
85cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference<
86cdf0e10cSrcweir 					::com::sun::star::linguistic2::XDictionaryEntry> &xEntry,
87cdf0e10cSrcweir 				sal_Int16 nLang, sal_Int16 nMaxLeading );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	com::sun::star::uno::Reference<
90cdf0e10cSrcweir 		::com::sun::star::linguistic2::XPossibleHyphens >
91cdf0e10cSrcweir 			buildPossHyphens( const ::com::sun::star::uno::Reference<
92cdf0e10cSrcweir 					::com::sun::star::linguistic2::XDictionaryEntry > &xEntry,
93cdf0e10cSrcweir 					sal_Int16 nLanguage );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir public:
96cdf0e10cSrcweir 	HyphenatorDispatcher( LngSvcMgr &rLngSvcMgr );
97cdf0e10cSrcweir 	virtual ~HyphenatorDispatcher();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	// XSupportedLocales
100cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence<
101cdf0e10cSrcweir 			::com::sun::star::lang::Locale > SAL_CALL
102cdf0e10cSrcweir 		getLocales()
103cdf0e10cSrcweir 			throw(::com::sun::star::uno::RuntimeException);
104cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
105cdf0e10cSrcweir 		hasLocale( const ::com::sun::star::lang::Locale& aLocale )
106cdf0e10cSrcweir 			throw(::com::sun::star::uno::RuntimeException);
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	// XHyphenator
109cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
110cdf0e10cSrcweir 			::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL
111cdf0e10cSrcweir 		hyphenate( const ::rtl::OUString& aWord,
112cdf0e10cSrcweir 				const ::com::sun::star::lang::Locale& aLocale,
113cdf0e10cSrcweir 				sal_Int16 nMaxLeading,
114cdf0e10cSrcweir 				const ::com::sun::star::beans::PropertyValues& aProperties )
115cdf0e10cSrcweir 			throw(::com::sun::star::lang::IllegalArgumentException,
116cdf0e10cSrcweir 				  ::com::sun::star::uno::RuntimeException);
117cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
118cdf0e10cSrcweir 			::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL
119cdf0e10cSrcweir 		queryAlternativeSpelling( const ::rtl::OUString& aWord,
120cdf0e10cSrcweir 				const ::com::sun::star::lang::Locale& aLocale,
121cdf0e10cSrcweir 				sal_Int16 nIndex,
122cdf0e10cSrcweir 				const ::com::sun::star::beans::PropertyValues& aProperties )
123cdf0e10cSrcweir 			throw(::com::sun::star::lang::IllegalArgumentException,
124cdf0e10cSrcweir 				  ::com::sun::star::uno::RuntimeException);
125cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
126cdf0e10cSrcweir 			::com::sun::star::linguistic2::XPossibleHyphens > SAL_CALL
127cdf0e10cSrcweir 		createPossibleHyphens(
128cdf0e10cSrcweir 				const ::rtl::OUString& aWord,
129cdf0e10cSrcweir 				const ::com::sun::star::lang::Locale& aLocale,
130cdf0e10cSrcweir 				const ::com::sun::star::beans::PropertyValues& aProperties )
131cdf0e10cSrcweir 			throw(::com::sun::star::lang::IllegalArgumentException,
132cdf0e10cSrcweir 				  ::com::sun::star::uno::RuntimeException);
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	// LinguDispatcher
135cdf0e10cSrcweir 	virtual void
136cdf0e10cSrcweir 		SetServiceList( const ::com::sun::star::lang::Locale &rLocale,
137cdf0e10cSrcweir 				const ::com::sun::star::uno::Sequence<
138cdf0e10cSrcweir 					rtl::OUString > &rSvcImplNames );
139cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< rtl::OUString >
140cdf0e10cSrcweir 		GetServiceList( const ::com::sun::star::lang::Locale &rLocale ) const;
141cdf0e10cSrcweir 	virtual DspType
142cdf0e10cSrcweir 		GetDspType() const;
143cdf0e10cSrcweir };
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
146cdf0e10cSrcweir inline ::com::sun::star::uno::Reference<
147cdf0e10cSrcweir 	::com::sun::star::beans::XPropertySet >
GetPropSet()148cdf0e10cSrcweir 		HyphenatorDispatcher::GetPropSet()
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	return xPropSet.is() ?
151cdf0e10cSrcweir 				xPropSet : xPropSet = ::linguistic::GetLinguProperties();
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 
155cdf0e10cSrcweir inline ::com::sun::star::uno::Reference<
156cdf0e10cSrcweir 	::com::sun::star::linguistic2::XSearchableDictionaryList >
GetDicList()157cdf0e10cSrcweir 		HyphenatorDispatcher::GetDicList()
158cdf0e10cSrcweir {
159cdf0e10cSrcweir 	return xDicList.is() ?
160cdf0e10cSrcweir 				xDicList : xDicList = ::linguistic::GetSearchableDictionaryList();
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 
164cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 
167cdf0e10cSrcweir #endif
168cdf0e10cSrcweir 
169