LibreOffice Module lingucomponent (master)  1
hyphenimp.hxx
Go to the documentation of this file.
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/implbase.hxx>
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/beans/XPropertySet.hpp>
28 #include <com/sun/star/beans/PropertyValues.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/linguistic2/XHyphenator.hpp>
31 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
32 
33 #include <unotools/charclass.hxx>
34 
35 #include <linguistic/misc.hxx>
37 
38 #include <lingutil.hxx>
39 #include <stdio.h>
40 
41 #include <hyphen.h>
42 
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::beans;
45 using namespace ::com::sun::star::lang;
46 using namespace ::com::sun::star::linguistic2;
47 
48 struct HDInfo {
49  HyphenDict * aPtr;
50  OUString aName;
52  rtl_TextEncoding eEnc;
53  std::unique_ptr<CharClass> apCC;
54 };
55 
56 class Hyphenator :
57  public cppu::WeakImplHelper
58  <
59  XHyphenator,
60  XLinguServiceEventBroadcaster,
61  XInitialization,
62  XComponent,
63  XServiceInfo,
64  XServiceDisplayName
65  >
66 {
67  Sequence< Locale > aSuppLocales;
68  std::vector< HDInfo > mvDicts;
69 
71  std::unique_ptr<linguistic::PropertyHelper_Hyphenation> pPropHelper;
72  bool bDisposing;
73 
74  Hyphenator(const Hyphenator &) = delete;
75  Hyphenator & operator = (const Hyphenator &) = delete;
76 
79  {
80  return pPropHelper ? *pPropHelper : GetPropHelper_Impl();
81  }
82 
83 public:
84  Hyphenator();
85 
86  virtual ~Hyphenator() override;
87 
88  // XSupportedLocales (for XHyphenator)
89  virtual Sequence< Locale > SAL_CALL getLocales() override;
90  virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) override;
91 
92  // XHyphenator
93  virtual css::uno::Reference< css::linguistic2::XHyphenatedWord > SAL_CALL hyphenate( const OUString& aWord, const css::lang::Locale& aLocale, sal_Int16 nMaxLeading, const css::uno::Sequence< css::beans::PropertyValue >& aProperties ) override;
94  virtual css::uno::Reference< css::linguistic2::XHyphenatedWord > SAL_CALL queryAlternativeSpelling( const OUString& aWord, const css::lang::Locale& aLocale, sal_Int16 nIndex, const css::uno::Sequence< css::beans::PropertyValue >& aProperties ) override;
95  virtual css::uno::Reference< css::linguistic2::XPossibleHyphens > SAL_CALL createPossibleHyphens( const OUString& aWord, const css::lang::Locale& aLocale, const css::uno::Sequence< css::beans::PropertyValue >& aProperties ) override;
96 
97  // XLinguServiceEventBroadcaster
98  virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) override;
99  virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) override;
100 
101  // XServiceDisplayName
102  virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) override;
103 
104  // XInitialization
105  virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) override;
106 
107  // XComponent
108  virtual void SAL_CALL dispose() override;
109  virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) override;
110  virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) override;
111 
112  // XServiceInfo
113  virtual OUString SAL_CALL getImplementationName() override;
114  virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override;
115  virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
116 
117  static inline OUString getImplementationName_Static() throw();
118  static Sequence< OUString > getSupportedServiceNames_Static() throw();
119 
120 private:
121  static OUString makeLowerCase(const OUString&, CharClass const *);
122  static OUString makeUpperCase(const OUString&, CharClass const *);
123  static OUString makeInitCap(const OUString&, CharClass const *);
124 };
125 
126 inline OUString Hyphenator::getImplementationName_Static() throw()
127 {
128  return "org.openoffice.lingu.LibHnjHyphenator";
129 }
130 
131 #endif
132 
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static OUString makeUpperCase(const OUString &, CharClass const *)
Definition: hyphenimp.cxx:666
linguistic::PropertyHelper_Hyphenation & GetPropHelper_Impl()
Definition: hyphenimp.cxx:89
virtual ~Hyphenator() override
Definition: hyphenimp.cxx:75
virtual css::uno::Reference< css::linguistic2::XHyphenatedWord > SAL_CALL hyphenate(const OUString &aWord, const css::lang::Locale &aLocale, sal_Int16 nMaxLeading, const css::uno::Sequence< css::beans::PropertyValue > &aProperties) override
Definition: hyphenimp.cxx:247
::comphelper::OInterfaceContainerHelper2 aEvtListeners
Definition: hyphenimp.hxx:70
OUString aName
Definition: hyphenimp.hxx:50
static Sequence< OUString > getSupportedServiceNames_Static()
Definition: hyphenimp.cxx:802
HyphenDict * aPtr
Definition: hyphenimp.hxx:49
virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: hyphenimp.cxx:797
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: hyphenimp.cxx:792
Sequence< Locale > aSuppLocales
Definition: hyphenimp.hxx:67
static OUString getImplementationName_Static()
Definition: hyphenimp.hxx:126
virtual Sequence< Locale > SAL_CALL getLocales() override
Definition: hyphenimp.cxx:101
virtual sal_Bool SAL_CALL hasLocale(const Locale &rLocale) override
Definition: hyphenimp.cxx:209
virtual void SAL_CALL addEventListener(const Reference< XEventListener > &rxListener) override
Definition: hyphenimp.cxx:770
bool bDisposing
Definition: hyphenimp.hxx:72
rtl_TextEncoding eEnc
Definition: hyphenimp.hxx:52
virtual void SAL_CALL dispose() override
Definition: hyphenimp.cxx:753
virtual sal_Bool SAL_CALL addLinguServiceEventListener(const Reference< XLinguServiceEventListener > &rxLstnr) override
Definition: hyphenimp.cxx:695
virtual css::uno::Reference< css::linguistic2::XPossibleHyphens > SAL_CALL createPossibleHyphens(const OUString &aWord, const css::lang::Locale &aLocale, const css::uno::Sequence< css::beans::PropertyValue > &aProperties) override
Definition: hyphenimp.cxx:488
static OUString makeInitCap(const OUString &, CharClass const *)
Definition: hyphenimp.cxx:673
unsigned char sal_Bool
static OUString makeLowerCase(const OUString &, CharClass const *)
Definition: hyphenimp.cxx:659
std::vector< HDInfo > mvDicts
Definition: hyphenimp.hxx:68
virtual css::uno::Reference< css::linguistic2::XHyphenatedWord > SAL_CALL queryAlternativeSpelling(const OUString &aWord, const css::lang::Locale &aLocale, sal_Int16 nIndex, const css::uno::Sequence< css::beans::PropertyValue > &aProperties) override
Definition: hyphenimp.cxx:472
linguistic::PropertyHelper_Hyphenation & GetPropHelper()
Definition: hyphenimp.hxx:78
virtual OUString SAL_CALL getImplementationName() override
Definition: hyphenimp.cxx:787
virtual void SAL_CALL initialize(const Sequence< Any > &rArguments) override
Definition: hyphenimp.cxx:727
virtual OUString SAL_CALL getServiceDisplayName(const Locale &rLocale) override
Definition: hyphenimp.cxx:721
std::unique_ptr< linguistic::PropertyHelper_Hyphenation > pPropHelper
Definition: hyphenimp.hxx:71
std::unique_ptr< CharClass > apCC
Definition: hyphenimp.hxx:53
Hyphenator & operator=(const Hyphenator &)=delete
Locale aLoc
Definition: hyphenimp.hxx:51
virtual void SAL_CALL removeEventListener(const Reference< XEventListener > &rxListener) override
Definition: hyphenimp.cxx:778
virtual sal_Bool SAL_CALL removeLinguServiceEventListener(const Reference< XLinguServiceEventListener > &rxLstnr) override
Definition: hyphenimp.cxx:708