LibreOffice Module lingucomponent (master)  1
nthesimp.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_THESAURUS_LIBNTH_NTHESIMP_HXX
21 #define INCLUDED_LINGUCOMPONENT_SOURCE_THESAURUS_LIBNTH_NTHESIMP_HXX
22 
23 #include <cppuhelper/implbase.hxx>
24 #include <com/sun/star/uno/Reference.h>
25 #include <com/sun/star/uno/Sequence.h>
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 
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/linguistic2/XMeaning.hpp>
34 #include <com/sun/star/linguistic2/XThesaurus.hpp>
35 
36 #include <unotools/charclass.hxx>
37 
38 #include <lingutil.hxx>
39 #include <linguistic/misc.hxx>
41 
42 #include <osl/file.hxx>
43 #include <mythes.hxx>
44 #include <memory>
45 #include <vector>
46 
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::beans;
49 using namespace ::com::sun::star::lang;
50 using namespace ::com::sun::star::linguistic2;
51 
52 namespace com { namespace sun { namespace star { namespace beans {
53  class XPropertySet;
54 }}}}
55 
56 class Thesaurus :
57  public cppu::WeakImplHelper
58  <
59  XThesaurus,
60  XInitialization,
61  XComponent,
62  XServiceInfo,
63  XServiceDisplayName
64  >
65 {
66  Sequence< Locale > aSuppLocales;
67 
70  bool bDisposing;
71  struct ThesInfo
72  {
73  std::unique_ptr<CharClass> aCharSetInfo;
74  std::unique_ptr<MyThes> aThes;
75  rtl_TextEncoding aEncoding;
77  OUString aName;
78  };
79  std::vector<ThesInfo> mvThesInfo;
80 
81  // cache for the Thesaurus dialog
82  Sequence < Reference < css::linguistic2::XMeaning > > prevMeanings;
83  OUString prevTerm;
85 
86  Thesaurus(const Thesaurus &) = delete;
87  Thesaurus & operator = (const Thesaurus &) = delete;
88 
91  {
92  return pPropHelper ? *pPropHelper : GetPropHelper_Impl();
93  }
94 
95 public:
96  Thesaurus();
97  virtual ~Thesaurus() override;
98 
99  // XSupportedLocales (for XThesaurus)
100  virtual Sequence< Locale > SAL_CALL getLocales() override;
101  virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) override;
102 
103  // XThesaurus
104  virtual Sequence< Reference < css::linguistic2::XMeaning > > SAL_CALL queryMeanings( const OUString& rTerm, const Locale& rLocale, const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override;
105 
106  // XServiceDisplayName
107  virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) override;
108 
109  // XInitialization
110  virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) override;
111 
112  // XComponent
113  virtual void SAL_CALL dispose() override;
114  virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) override;
115  virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) override;
116 
117  // XServiceInfo
118  virtual OUString SAL_CALL getImplementationName() override;
119  virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override;
120  virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
121 
122  static inline OUString
124  static Sequence< OUString >
126 
127 private:
128  static OUString makeLowerCase(const OUString&, CharClass const *);
129  static OUString makeUpperCase(const OUString&, CharClass const *);
130  static OUString makeInitCap(const OUString&, CharClass const *);
131 };
132 
133 inline OUString Thesaurus::getImplementationName_Static() throw()
134 {
135  return "org.openoffice.lingu.new.Thesaurus";
136 }
137 
138 #endif
139 
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Thesaurus & operator=(const Thesaurus &)=delete
virtual Sequence< Locale > SAL_CALL getLocales() override
Definition: nthesimp.cxx:103
static OUString makeUpperCase(const OUString &, CharClass const *)
Definition: nthesimp.cxx:502
virtual void SAL_CALL dispose() override
Definition: nthesimp.cxx:526
linguistic::PropertyHelper_Thesaurus & GetPropHelper_Impl()
Definition: nthesimp.cxx:91
rtl_TextEncoding aEncoding
Definition: nthesimp.hxx:75
static OUString makeLowerCase(const OUString &, CharClass const *)
Definition: nthesimp.cxx:495
LanguageType prevLocale
Definition: nthesimp.hxx:84
static OUString getImplementationName_Static()
Definition: nthesimp.hxx:133
bool bDisposing
Definition: nthesimp.hxx:70
std::vector< ThesInfo > mvThesInfo
Definition: nthesimp.hxx:79
virtual void SAL_CALL removeEventListener(const Reference< XEventListener > &rxListener) override
Definition: nthesimp.cxx:552
virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: nthesimp.cxx:571
std::unique_ptr< CharClass > aCharSetInfo
Definition: nthesimp.hxx:73
Sequence< Locale > aSuppLocales
Definition: nthesimp.hxx:66
linguistic::PropertyHelper_Thesaurus & GetPropHelper()
Definition: nthesimp.hxx:90
OUString prevTerm
Definition: nthesimp.hxx:83
virtual Sequence< Reference< css::linguistic2::XMeaning > > SAL_CALL queryMeanings(const OUString &rTerm, const Locale &rLocale, const css::uno::Sequence< css::beans::PropertyValue > &rProperties) override
Definition: nthesimp.cxx:221
class SAL_NO_VTABLE XPropertySet
virtual void SAL_CALL initialize(const Sequence< Any > &rArguments) override
Definition: nthesimp.cxx:471
unsigned char sal_Bool
static OUString makeInitCap(const OUString &, CharClass const *)
Definition: nthesimp.cxx:509
virtual ~Thesaurus() override
Definition: nthesimp.cxx:82
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: nthesimp.cxx:566
virtual void SAL_CALL addEventListener(const Reference< XEventListener > &rxListener) override
Definition: nthesimp.cxx:544
virtual OUString SAL_CALL getServiceDisplayName(const Locale &rLocale) override
Definition: nthesimp.cxx:465
virtual sal_Bool SAL_CALL hasLocale(const Locale &rLocale) override
Definition: nthesimp.cxx:211
linguistic::PropertyHelper_Thesaurus * pPropHelper
Definition: nthesimp.hxx:69
Sequence< Reference< css::linguistic2::XMeaning > > prevMeanings
Definition: nthesimp.hxx:82
std::unique_ptr< MyThes > aThes
Definition: nthesimp.hxx:74
virtual OUString SAL_CALL getImplementationName() override
Definition: nthesimp.cxx:561
static Sequence< OUString > getSupportedServiceNames_Static()
Definition: nthesimp.cxx:576
::comphelper::OInterfaceContainerHelper2 aEvtListeners
Definition: nthesimp.hxx:68