xref: /AOO41X/main/linguistic/source/hyphdsp.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _LINGUISTIC_HYPHDSP_HXX_
29*cdf0e10cSrcweir #define _LINGUISTIC_HYPHDSP_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceDisplayName.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XHyphenator.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XPossibleHyphens.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <uno/lbnames.h>			// CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
42*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>	// helper for implementations
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
45*cdf0e10cSrcweir #include <map>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include "lngopt.hxx"
48*cdf0e10cSrcweir #include "linguistic/misc.hxx"
49*cdf0e10cSrcweir #include "defs.hxx"
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir class LngSvcMgr;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir class HyphenatorDispatcher :
56*cdf0e10cSrcweir 	public cppu::WeakImplHelper1
57*cdf0e10cSrcweir 	<
58*cdf0e10cSrcweir 		::com::sun::star::linguistic2::XHyphenator
59*cdf0e10cSrcweir 	>,
60*cdf0e10cSrcweir 	public LinguDispatcher
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir     typedef boost::shared_ptr< LangSvcEntries_Hyph >                LangSvcEntries_Hyph_Ptr_t;
63*cdf0e10cSrcweir     typedef std::map< LanguageType, LangSvcEntries_Hyph_Ptr_t >     HyphSvcByLangMap_t;
64*cdf0e10cSrcweir     HyphSvcByLangMap_t      aSvcMap;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
67*cdf0e10cSrcweir 		::com::sun::star::beans::XPropertySet >						xPropSet;
68*cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
69*cdf0e10cSrcweir 		::com::sun::star::linguistic2::XSearchableDictionaryList >	xDicList;
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	LngSvcMgr	   &rMgr;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 	// disallow copy-constructor and assignment-operator for now
74*cdf0e10cSrcweir 	HyphenatorDispatcher(const HyphenatorDispatcher &);
75*cdf0e10cSrcweir 	HyphenatorDispatcher & operator = (const HyphenatorDispatcher &);
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	inline ::com::sun::star::uno::Reference<
78*cdf0e10cSrcweir 		::com::sun::star::beans::XPropertySet >
79*cdf0e10cSrcweir 			GetPropSet();
80*cdf0e10cSrcweir 	inline ::com::sun::star::uno::Reference<
81*cdf0e10cSrcweir 		::com::sun::star::linguistic2::XSearchableDictionaryList >
82*cdf0e10cSrcweir 			GetDicList();
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 	void	ClearSvcList();
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	com::sun::star::uno::Reference<
87*cdf0e10cSrcweir 		::com::sun::star::linguistic2::XHyphenatedWord>
88*cdf0e10cSrcweir             buildHyphWord( const rtl::OUString rOrigWord,
89*cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference<
90*cdf0e10cSrcweir 					::com::sun::star::linguistic2::XDictionaryEntry> &xEntry,
91*cdf0e10cSrcweir 				sal_Int16 nLang, sal_Int16 nMaxLeading );
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 	com::sun::star::uno::Reference<
94*cdf0e10cSrcweir 		::com::sun::star::linguistic2::XPossibleHyphens >
95*cdf0e10cSrcweir 			buildPossHyphens( const ::com::sun::star::uno::Reference<
96*cdf0e10cSrcweir 					::com::sun::star::linguistic2::XDictionaryEntry > &xEntry,
97*cdf0e10cSrcweir 					sal_Int16 nLanguage );
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir public:
100*cdf0e10cSrcweir 	HyphenatorDispatcher( LngSvcMgr &rLngSvcMgr );
101*cdf0e10cSrcweir 	virtual ~HyphenatorDispatcher();
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 	// XSupportedLocales
104*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence<
105*cdf0e10cSrcweir 			::com::sun::star::lang::Locale > SAL_CALL
106*cdf0e10cSrcweir 		getLocales()
107*cdf0e10cSrcweir 			throw(::com::sun::star::uno::RuntimeException);
108*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
109*cdf0e10cSrcweir 		hasLocale( const ::com::sun::star::lang::Locale& aLocale )
110*cdf0e10cSrcweir 			throw(::com::sun::star::uno::RuntimeException);
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 	// XHyphenator
113*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
114*cdf0e10cSrcweir 			::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL
115*cdf0e10cSrcweir 		hyphenate( const ::rtl::OUString& aWord,
116*cdf0e10cSrcweir 				const ::com::sun::star::lang::Locale& aLocale,
117*cdf0e10cSrcweir 				sal_Int16 nMaxLeading,
118*cdf0e10cSrcweir 				const ::com::sun::star::beans::PropertyValues& aProperties )
119*cdf0e10cSrcweir 			throw(::com::sun::star::lang::IllegalArgumentException,
120*cdf0e10cSrcweir 				  ::com::sun::star::uno::RuntimeException);
121*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
122*cdf0e10cSrcweir 			::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL
123*cdf0e10cSrcweir 		queryAlternativeSpelling( const ::rtl::OUString& aWord,
124*cdf0e10cSrcweir 				const ::com::sun::star::lang::Locale& aLocale,
125*cdf0e10cSrcweir 				sal_Int16 nIndex,
126*cdf0e10cSrcweir 				const ::com::sun::star::beans::PropertyValues& aProperties )
127*cdf0e10cSrcweir 			throw(::com::sun::star::lang::IllegalArgumentException,
128*cdf0e10cSrcweir 				  ::com::sun::star::uno::RuntimeException);
129*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
130*cdf0e10cSrcweir 			::com::sun::star::linguistic2::XPossibleHyphens > SAL_CALL
131*cdf0e10cSrcweir 		createPossibleHyphens(
132*cdf0e10cSrcweir 				const ::rtl::OUString& aWord,
133*cdf0e10cSrcweir 				const ::com::sun::star::lang::Locale& aLocale,
134*cdf0e10cSrcweir 				const ::com::sun::star::beans::PropertyValues& aProperties )
135*cdf0e10cSrcweir 			throw(::com::sun::star::lang::IllegalArgumentException,
136*cdf0e10cSrcweir 				  ::com::sun::star::uno::RuntimeException);
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 	// LinguDispatcher
139*cdf0e10cSrcweir 	virtual void
140*cdf0e10cSrcweir 		SetServiceList( const ::com::sun::star::lang::Locale &rLocale,
141*cdf0e10cSrcweir 				const ::com::sun::star::uno::Sequence<
142*cdf0e10cSrcweir 					rtl::OUString > &rSvcImplNames );
143*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< rtl::OUString >
144*cdf0e10cSrcweir 		GetServiceList( const ::com::sun::star::lang::Locale &rLocale ) const;
145*cdf0e10cSrcweir 	virtual DspType
146*cdf0e10cSrcweir 		GetDspType() const;
147*cdf0e10cSrcweir };
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir inline ::com::sun::star::uno::Reference<
151*cdf0e10cSrcweir 	::com::sun::star::beans::XPropertySet >
152*cdf0e10cSrcweir 		HyphenatorDispatcher::GetPropSet()
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir 	return xPropSet.is() ?
155*cdf0e10cSrcweir 				xPropSet : xPropSet = ::linguistic::GetLinguProperties();
156*cdf0e10cSrcweir }
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir inline ::com::sun::star::uno::Reference<
160*cdf0e10cSrcweir 	::com::sun::star::linguistic2::XSearchableDictionaryList >
161*cdf0e10cSrcweir 		HyphenatorDispatcher::GetDicList()
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir 	return xDicList.is() ?
164*cdf0e10cSrcweir 				xDicList : xDicList = ::linguistic::GetSearchableDictionaryList();
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir #endif
172*cdf0e10cSrcweir 
173