1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_LINGUISTIC_SOURCE_HYPHDSP_HXX 21 #define INCLUDED_LINGUISTIC_SOURCE_HYPHDSP_HXX 22 23 24 #include <com/sun/star/linguistic2/XHyphenator.hpp> 25 #include <com/sun/star/linguistic2/XPossibleHyphens.hpp> 26 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> 27 28 #include <cppuhelper/implbase.hxx> 29 30 #include <map> 31 #include <memory> 32 33 #include <linguistic/misc.hxx> 34 #include "defs.hxx" 35 36 class LngSvcMgr; 37 38 39 class HyphenatorDispatcher : 40 public cppu::WeakImplHelper 41 < 42 css::linguistic2::XHyphenator 43 >, 44 public LinguDispatcher 45 { 46 typedef std::shared_ptr< LangSvcEntries_Hyph > LangSvcEntries_Hyph_Ptr_t; 47 typedef std::map< LanguageType, LangSvcEntries_Hyph_Ptr_t > HyphSvcByLangMap_t; 48 HyphSvcByLangMap_t aSvcMap; 49 50 css::uno::Reference< css::linguistic2::XLinguProperties > xPropSet; 51 css::uno::Reference< css::linguistic2::XSearchableDictionaryList > xDicList; 52 53 LngSvcMgr &rMgr; 54 55 HyphenatorDispatcher(const HyphenatorDispatcher &) = delete; 56 HyphenatorDispatcher & operator = (const HyphenatorDispatcher &) = delete; 57 58 inline const css::uno::Reference< css::linguistic2::XLinguProperties > & 59 GetPropSet(); 60 inline const css::uno::Reference< css::linguistic2::XSearchableDictionaryList > & 61 GetDicList(); 62 63 void ClearSvcList(); 64 65 static css::uno::Reference< css::linguistic2::XHyphenatedWord> 66 buildHyphWord( const OUString& rOrigWord, 67 const css::uno::Reference< css::linguistic2::XDictionaryEntry> &xEntry, 68 LanguageType nLang, sal_Int16 nMaxLeading ); 69 70 static css::uno::Reference< css::linguistic2::XPossibleHyphens > 71 buildPossHyphens( const css::uno::Reference< css::linguistic2::XDictionaryEntry > &xEntry, 72 LanguageType nLanguage ); 73 74 public: 75 explicit HyphenatorDispatcher( LngSvcMgr &rLngSvcMgr ); 76 virtual ~HyphenatorDispatcher() override; 77 78 // XSupportedLocales 79 virtual css::uno::Sequence< css::lang::Locale > SAL_CALL 80 getLocales() override; 81 virtual sal_Bool SAL_CALL 82 hasLocale( const css::lang::Locale& aLocale ) override; 83 84 // XHyphenator 85 virtual css::uno::Reference< css::linguistic2::XHyphenatedWord > SAL_CALL 86 hyphenate( const OUString& aWord, 87 const css::lang::Locale& aLocale, 88 sal_Int16 nMaxLeading, 89 const css::uno::Sequence< ::css::beans::PropertyValue >& aProperties ) override; 90 virtual css::uno::Reference< css::linguistic2::XHyphenatedWord > SAL_CALL 91 queryAlternativeSpelling( const OUString& aWord, 92 const css::lang::Locale& aLocale, 93 sal_Int16 nIndex, 94 const css::uno::Sequence< ::css::beans::PropertyValue >& aProperties ) override; 95 virtual css::uno::Reference< 96 css::linguistic2::XPossibleHyphens > SAL_CALL 97 createPossibleHyphens( 98 const OUString& aWord, 99 const css::lang::Locale& aLocale, 100 const css::uno::Sequence< ::css::beans::PropertyValue >& aProperties ) override; 101 102 // LinguDispatcher 103 virtual void 104 SetServiceList( const css::lang::Locale &rLocale, 105 const css::uno::Sequence< OUString > &rSvcImplNames ) override; 106 virtual css::uno::Sequence< OUString > 107 GetServiceList( const css::lang::Locale &rLocale ) const override; 108 }; 109 110 111 inline const css::uno::Reference< css::linguistic2::XLinguProperties > & GetPropSet()112 HyphenatorDispatcher::GetPropSet() 113 { 114 if (!xPropSet.is()) 115 xPropSet = ::linguistic::GetLinguProperties(); 116 return xPropSet; 117 } 118 119 120 inline const css::uno::Reference< css::linguistic2::XSearchableDictionaryList > & GetDicList()121 HyphenatorDispatcher::GetDicList() 122 { 123 if (!xDicList.is()) 124 xDicList = ::linguistic::GetDictionaryList(); 125 return xDicList; 126 } 127 128 129 #endif 130 131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 132