Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / linguistic / source / hyphdsp.hxx
blob938ab2758597dac0c7fc172f2cb660f8f59b0b27
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_LINGUISTIC_SOURCE_HYPHDSP_HXX
21 #define INCLUDED_LINGUISTIC_SOURCE_HYPHDSP_HXX
24 #include <com/sun/star/linguistic2/XHyphenator.hpp>
25 #include <com/sun/star/linguistic2/XPossibleHyphens.hpp>
26 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
28 #include <cppuhelper/implbase.hxx>
30 #include <map>
31 #include <memory>
33 #include <linguistic/misc.hxx>
34 #include "defs.hxx"
36 class LngSvcMgr;
39 class HyphenatorDispatcher :
40 public cppu::WeakImplHelper
42 css::linguistic2::XHyphenator
44 public LinguDispatcher
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;
50 css::uno::Reference< css::linguistic2::XLinguProperties > xPropSet;
51 css::uno::Reference< css::linguistic2::XSearchableDictionaryList > xDicList;
53 LngSvcMgr &rMgr;
55 HyphenatorDispatcher(const HyphenatorDispatcher &) = delete;
56 HyphenatorDispatcher & operator = (const HyphenatorDispatcher &) = delete;
58 inline css::uno::Reference< css::linguistic2::XLinguProperties >
59 GetPropSet();
60 inline css::uno::Reference< css::linguistic2::XSearchableDictionaryList >
61 GetDicList();
63 void ClearSvcList();
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 );
70 static css::uno::Reference< css::linguistic2::XPossibleHyphens >
71 buildPossHyphens( const css::uno::Reference< css::linguistic2::XDictionaryEntry > &xEntry,
72 LanguageType nLanguage );
74 public:
75 explicit HyphenatorDispatcher( LngSvcMgr &rLngSvcMgr );
76 virtual ~HyphenatorDispatcher() override;
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;
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;
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;
111 inline css::uno::Reference< css::linguistic2::XLinguProperties >
112 HyphenatorDispatcher::GetPropSet()
114 return xPropSet.is() ?
115 xPropSet : xPropSet = ::linguistic::GetLinguProperties();
119 inline css::uno::Reference< css::linguistic2::XSearchableDictionaryList >
120 HyphenatorDispatcher::GetDicList()
122 return xDicList.is() ?
123 xDicList : xDicList = ::linguistic::GetDictionaryList();
127 #endif
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */