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