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