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