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 0 : class MyAppExitListener : public linguistic::AppExitListener
48 : {
49 : DicList & rMyDicList;
50 :
51 : public:
52 0 : 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 : sal_Bool bDisposing;
72 : sal_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 0 : DictionaryVec_t & GetOrCreateDicList()
80 : {
81 0 : if ( !bInCreation && aDicList.empty() )
82 0 : _CreateDicList();
83 0 : return aDicList;
84 : }
85 :
86 : void LaunchEvent(sal_Int16 nEvent, com::sun::star::uno::Sequence<
87 : ::com::sun::star::linguistic2::XDictionary > xDic);
88 : void SearchForDictionaries( DictionaryVec_t &rDicList,
89 : const OUString &rDicDir, sal_Bool bIsWritePath );
90 : sal_Int32 GetDicPos(const com::sun::star::uno::Reference<
91 : ::com::sun::star::linguistic2::XDictionary > &xDic);
92 :
93 : public:
94 : DicList();
95 : virtual ~DicList();
96 :
97 : // XDictionaryList
98 : virtual ::sal_Int16 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 : 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;
100 : 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;
101 : 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;
102 : 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;
103 : 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;
104 : 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;
105 : virtual ::sal_Int16 SAL_CALL beginCollectEvents( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 : virtual ::sal_Int16 SAL_CALL endCollectEvents( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 : virtual ::sal_Int16 SAL_CALL flushEvents( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 : 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;
109 :
110 : // XSearchableDictionaryList
111 : 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;
112 :
113 : // XComponent
114 : virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 : 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;
116 : 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;
117 :
118 : // XServiceInfo
119 : virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
120 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
121 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 :
123 :
124 : static inline OUString getImplementationName_Static() throw();
125 : static com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static() throw();
126 :
127 : // non UNO-specific
128 : void SaveDics();
129 : };
130 :
131 0 : inline OUString DicList::getImplementationName_Static() throw()
132 : {
133 0 : return OUString( "com.sun.star.lingu2.DicList" );
134 : }
135 :
136 :
137 : #endif
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|