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 : #ifndef INCLUDED_LINGUISTIC_SOURCE_DLISTIMP_HXX
21 : #define INCLUDED_LINGUISTIC_SOURCE_DLISTIMP_HXX
22 :
23 : #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
24 : #include <com/sun/star/lang/XComponent.hpp>
25 : #include <com/sun/star/lang/XServiceInfo.hpp>
26 :
27 : #include <cppuhelper/implbase1.hxx>
28 : #include <cppuhelper/implbase3.hxx>
29 : #include <cppuhelper/interfacecontainer.h>
30 :
31 : #include <vector>
32 :
33 : #include "linguistic/misc.hxx"
34 : #include "lngopt.hxx"
35 :
36 : class DicEvtListenerHelper;
37 :
38 :
39 : class DicList :
40 : public cppu::WeakImplHelper3
41 : <
42 : ::com::sun::star::linguistic2::XSearchableDictionaryList,
43 : ::com::sun::star::lang::XComponent,
44 : ::com::sun::star::lang::XServiceInfo
45 : >
46 : {
47 146 : class MyAppExitListener : public linguistic::AppExitListener
48 : {
49 : DicList & rMyDicList;
50 :
51 : public:
52 76 : MyAppExitListener( DicList &rDicList ) : rMyDicList( rDicList ) {}
53 : virtual void AtExit() SAL_OVERRIDE;
54 : };
55 :
56 : LinguOptions aOpt;
57 :
58 : ::cppu::OInterfaceContainerHelper aEvtListeners;
59 :
60 : typedef std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > > DictionaryVec_t;
61 : DictionaryVec_t aDicList;
62 :
63 : ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::
64 : XDictionaryEventListener > xDicEvtLstnrHelper;
65 : DicEvtListenerHelper *pDicEvtLstnrHelper;
66 :
67 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::
68 : XTerminateListener > xExitListener;
69 : MyAppExitListener *pExitListener;
70 :
71 : bool bDisposing;
72 : bool bInCreation;
73 :
74 : // disallow copy-constructor and assignment-operator for now
75 : DicList( const DicList & );
76 : DicList & operator = (const DicList &);
77 :
78 : void _CreateDicList();
79 126661 : DictionaryVec_t & GetOrCreateDicList()
80 : {
81 126661 : if ( !bInCreation && aDicList.empty() )
82 38 : _CreateDicList();
83 126661 : return aDicList;
84 : }
85 :
86 : void SearchForDictionaries( DictionaryVec_t &rDicList,
87 : const OUString &rDicDir, bool bIsWritePath );
88 : sal_Int32 GetDicPos(const com::sun::star::uno::Reference<
89 : ::com::sun::star::linguistic2::XDictionary > &xDic);
90 :
91 : public:
92 : DicList();
93 : virtual ~DicList();
94 :
95 : // XDictionaryList
96 : virtual ::sal_Int16 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
97 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > > SAL_CALL getDictionaries( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > SAL_CALL getDictionaryByName( const OUString& aDictionaryName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 : virtual sal_Bool SAL_CALL addDictionary( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary >& xDictionary ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 : virtual sal_Bool SAL_CALL removeDictionary( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary >& xDictionary ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 : virtual sal_Bool SAL_CALL addDictionaryListEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryListEventListener >& xListener, sal_Bool bReceiveVerbose ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 : virtual sal_Bool SAL_CALL removeDictionaryListEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryListEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 : virtual ::sal_Int16 SAL_CALL beginCollectEvents( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 : virtual ::sal_Int16 SAL_CALL endCollectEvents( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
105 : virtual ::sal_Int16 SAL_CALL flushEvents( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > SAL_CALL createDictionary( const OUString& aName, const ::com::sun::star::lang::Locale& aLocale, ::com::sun::star::linguistic2::DictionaryType eDicType, const OUString& aURL ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 :
108 : // XSearchableDictionaryList
109 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryEntry > SAL_CALL queryDictionaryEntry( const OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, sal_Bool bSearchPosDics, sal_Bool bSpellEntry ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 :
111 : // XComponent
112 : virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 :
116 : // XServiceInfo
117 : virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
120 :
121 :
122 : static inline OUString getImplementationName_Static() throw();
123 : static com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static() throw();
124 :
125 : // non UNO-specific
126 : void SaveDics();
127 : };
128 :
129 162 : inline OUString DicList::getImplementationName_Static() throw()
130 : {
131 162 : return OUString( "com.sun.star.lingu2.DicList" );
132 : }
133 :
134 :
135 : #endif
136 :
137 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|