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_LINGUCOMPONENT_SOURCE_HYPHENATOR_HYPHEN_HYPHENIMP_HXX
21 : #define INCLUDED_LINGUCOMPONENT_SOURCE_HYPHENATOR_HYPHEN_HYPHENIMP_HXX
22 :
23 : #include <cppuhelper/implbase1.hxx>
24 : #include <cppuhelper/implbase6.hxx>
25 : #include <com/sun/star/lang/XComponent.hpp>
26 : #include <com/sun/star/lang/XInitialization.hpp>
27 : #include <com/sun/star/lang/XServiceDisplayName.hpp>
28 : #include <com/sun/star/beans/XPropertySet.hpp>
29 : #include <com/sun/star/beans/PropertyValues.hpp>
30 : #include <com/sun/star/lang/XServiceInfo.hpp>
31 : #include <com/sun/star/linguistic2/XHyphenator.hpp>
32 : #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
33 : #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
34 :
35 : #include <unotools/charclass.hxx>
36 :
37 : #include <linguistic/misc.hxx>
38 : #include <linguistic/lngprophelp.hxx>
39 :
40 : #include <lingutil.hxx>
41 : #include <stdio.h>
42 :
43 : #include <hyphen.h>
44 :
45 : using namespace ::com::sun::star::uno;
46 : using namespace ::com::sun::star::beans;
47 : using namespace ::com::sun::star::lang;
48 : using namespace ::com::sun::star::linguistic2;
49 :
50 85 : struct HDInfo {
51 : HyphenDict * aPtr;
52 : OUString aName;
53 : Locale aLoc;
54 : rtl_TextEncoding eEnc;
55 : CharClass * apCC;
56 : };
57 :
58 : class Hyphenator :
59 : public cppu::WeakImplHelper6
60 : <
61 : XHyphenator,
62 : XLinguServiceEventBroadcaster,
63 : XInitialization,
64 : XComponent,
65 : XServiceInfo,
66 : XServiceDisplayName
67 : >
68 : {
69 : Sequence< Locale > aSuppLocales;
70 : HDInfo * aDicts;
71 : sal_Int32 numdict;
72 :
73 : ::cppu::OInterfaceContainerHelper aEvtListeners;
74 : Reference< XMultiServiceFactory > rSMgr;
75 : linguistic::PropertyHelper_Hyphenation* pPropHelper;
76 : bool bDisposing;
77 :
78 : Hyphenator(const Hyphenator &) SAL_DELETED_FUNCTION;
79 : Hyphenator & operator = (const Hyphenator &) SAL_DELETED_FUNCTION;
80 :
81 : linguistic::PropertyHelper_Hyphenation& GetPropHelper_Impl();
82 5240 : linguistic::PropertyHelper_Hyphenation& GetPropHelper()
83 : {
84 5240 : return pPropHelper ? *pPropHelper : GetPropHelper_Impl();
85 : }
86 :
87 : public:
88 : Hyphenator();
89 :
90 : virtual ~Hyphenator();
91 :
92 : // XSupportedLocales (for XHyphenator)
93 : virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException, std::exception) SAL_OVERRIDE;
94 : virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
95 :
96 : // XHyphenator
97 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL hyphenate( const OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nMaxLeading, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL queryAlternativeSpelling( const OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nIndex, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XPossibleHyphens > SAL_CALL createPossibleHyphens( const OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 :
101 : // XLinguServiceEventBroadcaster
102 : virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
103 : virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
104 :
105 : // XServiceDisplayName
106 : virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
107 :
108 : // XInitialization
109 : virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException, std::exception) SAL_OVERRIDE;
110 :
111 : // XComponent
112 : virtual void SAL_CALL dispose() throw(RuntimeException, std::exception) SAL_OVERRIDE;
113 : virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
114 : virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
115 :
116 : // XServiceInfo
117 : virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) SAL_OVERRIDE;
118 : virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
119 : virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
120 :
121 : static inline OUString getImplementationName_Static() throw();
122 : static Sequence< OUString > getSupportedServiceNames_Static() throw();
123 :
124 : private:
125 : static OUString SAL_CALL makeLowerCase(const OUString&, CharClass *);
126 : static OUString SAL_CALL makeUpperCase(const OUString&, CharClass *);
127 : static OUString SAL_CALL makeInitCap(const OUString&, CharClass *);
128 : };
129 :
130 130 : inline OUString Hyphenator::getImplementationName_Static() throw()
131 : {
132 130 : return OUString( "org.openoffice.lingu.LibHnjHyphenator" );
133 : }
134 :
135 : void * SAL_CALL Hyphenator_getFactory(
136 : char const * pImplName, css::lang::XMultiServiceFactory * pServiceManager,
137 : void *);
138 :
139 : #endif
140 :
141 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|