Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #ifndef _LINGU2_HYPHENIMP_HXX_
31 : : #define _LINGU2_HYPHENIMP_HXX_
32 : :
33 : : #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
34 : : #include <cppuhelper/implbase1.hxx> // helper for implementations
35 : : #include <cppuhelper/implbase6.hxx> // helper for implementations
36 : : #include <com/sun/star/lang/XComponent.hpp>
37 : : #include <com/sun/star/lang/XInitialization.hpp>
38 : : #include <com/sun/star/lang/XServiceDisplayName.hpp>
39 : : #include <com/sun/star/beans/XPropertySet.hpp>
40 : : #include <com/sun/star/beans/PropertyValues.hpp>
41 : : #include <com/sun/star/lang/XServiceInfo.hpp>
42 : : #include <com/sun/star/linguistic2/XHyphenator.hpp>
43 : : #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
44 : : #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
45 : :
46 : : #include <unotools/charclass.hxx>
47 : :
48 : : #include <linguistic/misc.hxx>
49 : : #include <linguistic/lngprophelp.hxx>
50 : :
51 : : #include <lingutil.hxx>
52 : : #include <stdio.h>
53 : :
54 : : using namespace ::rtl;
55 : : using namespace ::com::sun::star::uno;
56 : : using namespace ::com::sun::star::beans;
57 : : using namespace ::com::sun::star::lang;
58 : : using namespace ::com::sun::star::linguistic2;
59 : :
60 : :
61 : : ///////////////////////////////////////////////////////////////////////////
62 : :
63 : :
64 : 4232 : struct HDInfo {
65 : : HyphenDict * aPtr;
66 : : OUString aName;
67 : : Locale aLoc;
68 : : rtl_TextEncoding eEnc;
69 : : CharClass * apCC;
70 : : };
71 : :
72 : :
73 : :
74 : : class Hyphenator :
75 : : public cppu::WeakImplHelper6
76 : : <
77 : : XHyphenator,
78 : : XLinguServiceEventBroadcaster,
79 : : XInitialization,
80 : : XComponent,
81 : : XServiceInfo,
82 : : XServiceDisplayName
83 : : >
84 : : {
85 : : Sequence< Locale > aSuppLocales;
86 : : HDInfo * aDicts;
87 : : sal_Int32 numdict;
88 : :
89 : : ::cppu::OInterfaceContainerHelper aEvtListeners;
90 : : Reference< XMultiServiceFactory > rSMgr;
91 : : linguistic::PropertyHelper_Hyphenation* pPropHelper;
92 : : sal_Bool bDisposing;
93 : :
94 : : // disallow copy-constructor and assignment-operator for now
95 : : Hyphenator(const Hyphenator &);
96 : : Hyphenator & operator = (const Hyphenator &);
97 : :
98 : : linguistic::PropertyHelper_Hyphenation& GetPropHelper_Impl();
99 : 33612 : linguistic::PropertyHelper_Hyphenation& GetPropHelper()
100 : : {
101 [ + + ]: 33612 : return pPropHelper ? *pPropHelper : GetPropHelper_Impl();
102 : : }
103 : :
104 : : public:
105 : : Hyphenator();
106 : :
107 : : virtual ~Hyphenator();
108 : :
109 : : // XSupportedLocales (for XHyphenator)
110 : : virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException);
111 : : virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException);
112 : :
113 : : // XHyphenator
114 : : 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);
115 : : 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);
116 : : 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);
117 : :
118 : : // XLinguServiceEventBroadcaster
119 : : virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException);
120 : : virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException);
121 : :
122 : : // XServiceDisplayName
123 : : virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException);
124 : :
125 : : // XInitialization
126 : : virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException);
127 : :
128 : : // XComponent
129 : : virtual void SAL_CALL dispose() throw(RuntimeException);
130 : : virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException);
131 : : virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException);
132 : :
133 : : // XServiceInfo
134 : : virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
135 : : virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException);
136 : : virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
137 : :
138 : :
139 : : static inline OUString getImplementationName_Static() throw();
140 : : static Sequence< OUString > getSupportedServiceNames_Static() throw();
141 : :
142 : :
143 : : private:
144 : : sal_uInt16 SAL_CALL capitalType(const OUString&, CharClass *);
145 : : OUString SAL_CALL makeLowerCase(const OUString&, CharClass *);
146 : : OUString SAL_CALL makeUpperCase(const OUString&, CharClass *);
147 : : OUString SAL_CALL makeInitCap(const OUString&, CharClass *);
148 : : };
149 : :
150 : 140 : inline OUString Hyphenator::getImplementationName_Static() throw()
151 : : {
152 : 140 : return A2OU( "org.openoffice.lingu.LibHnjHyphenator" );
153 : : }
154 : :
155 : :
156 : : ///////////////////////////////////////////////////////////////////////////
157 : :
158 : : #endif
159 : :
160 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|