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 virtual sal_Bool SAL_CALL 104 hasLocale( const ::com::sun::star::lang::Locale& aLocale ); 105 106 // XHyphenator 107 virtual ::com::sun::star::uno::Reference< 108 ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL 109 hyphenate( const ::rtl::OUString& aWord, 110 const ::com::sun::star::lang::Locale& aLocale, 111 sal_Int16 nMaxLeading, 112 const ::com::sun::star::beans::PropertyValues& aProperties ); 113 virtual ::com::sun::star::uno::Reference< 114 ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL 115 queryAlternativeSpelling( const ::rtl::OUString& aWord, 116 const ::com::sun::star::lang::Locale& aLocale, 117 sal_Int16 nIndex, 118 const ::com::sun::star::beans::PropertyValues& aProperties ); 119 virtual ::com::sun::star::uno::Reference< 120 ::com::sun::star::linguistic2::XPossibleHyphens > SAL_CALL 121 createPossibleHyphens( 122 const ::rtl::OUString& aWord, 123 const ::com::sun::star::lang::Locale& aLocale, 124 const ::com::sun::star::beans::PropertyValues& aProperties ); 125 126 // LinguDispatcher 127 virtual void 128 SetServiceList( const ::com::sun::star::lang::Locale &rLocale, 129 const ::com::sun::star::uno::Sequence< 130 rtl::OUString > &rSvcImplNames ); 131 virtual ::com::sun::star::uno::Sequence< rtl::OUString > 132 GetServiceList( const ::com::sun::star::lang::Locale &rLocale ) const; 133 virtual DspType 134 GetDspType() const; 135 }; 136 137 138 inline ::com::sun::star::uno::Reference< 139 ::com::sun::star::beans::XPropertySet > GetPropSet()140 HyphenatorDispatcher::GetPropSet() 141 { 142 return xPropSet.is() ? 143 xPropSet : xPropSet = ::linguistic::GetLinguProperties(); 144 } 145 146 147 inline ::com::sun::star::uno::Reference< 148 ::com::sun::star::linguistic2::XSearchableDictionaryList > GetDicList()149 HyphenatorDispatcher::GetDicList() 150 { 151 return xDicList.is() ? 152 xDicList : xDicList = ::linguistic::GetSearchableDictionaryList(); 153 } 154 155 156 /////////////////////////////////////////////////////////////////////////// 157 158 159 #endif 160