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