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