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