Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _LINGUISTIC_DLISTIMP_HXX_
30 : : #define _LINGUISTIC_DLISTIMP_HXX_
31 : :
32 : : #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
33 : : #include <com/sun/star/lang/XComponent.hpp>
34 : : #include <com/sun/star/lang/XServiceInfo.hpp>
35 : :
36 : : #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
37 : : #include <cppuhelper/implbase1.hxx> // helper for implementations
38 : : #include <cppuhelper/implbase3.hxx> // helper for implementations
39 : : #include <cppuhelper/interfacecontainer.h>
40 : :
41 : : #include <vector>
42 : : #include <memory>
43 : :
44 : : #include "linguistic/misc.hxx"
45 : : #include "lngopt.hxx"
46 : :
47 : : class DicEvtListenerHelper;
48 : :
49 : :
50 : : class DicList :
51 : : public cppu::WeakImplHelper3
52 : : <
53 : : ::com::sun::star::linguistic2::XSearchableDictionaryList,
54 : : ::com::sun::star::lang::XComponent,
55 : : ::com::sun::star::lang::XServiceInfo
56 : : >
57 : : {
58 [ - + ]: 84 : class MyAppExitListener : public linguistic::AppExitListener
59 : : {
60 : : DicList & rMyDicList;
61 : :
62 : : public:
63 : 44 : MyAppExitListener( DicList &rDicList ) : rMyDicList( rDicList ) {}
64 : : virtual void AtExit();
65 : : };
66 : :
67 : : LinguOptions aOpt;
68 : :
69 : : ::cppu::OInterfaceContainerHelper aEvtListeners;
70 : :
71 : : typedef std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > > DictionaryVec_t;
72 : : DictionaryVec_t aDicList;
73 : :
74 : : ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::
75 : : XDictionaryEventListener > xDicEvtLstnrHelper;
76 : : DicEvtListenerHelper *pDicEvtLstnrHelper;
77 : :
78 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::
79 : : XTerminateListener > xExitListener;
80 : : MyAppExitListener *pExitListener;
81 : :
82 : : sal_Bool bDisposing;
83 : : sal_Bool bInCreation;
84 : :
85 : : // disallow copy-constructor and assignment-operator for now
86 : : DicList( const DicList & );
87 : : DicList & operator = (const DicList &);
88 : :
89 : : void _CreateDicList();
90 : 228901 : DictionaryVec_t & GetOrCreateDicList()
91 : : {
92 [ + + ][ + + ]: 228901 : if ( !bInCreation && aDicList.empty() )
[ + + ]
93 : 42 : _CreateDicList();
94 : 228901 : return aDicList;
95 : : }
96 : :
97 : : void LaunchEvent(sal_Int16 nEvent, com::sun::star::uno::Sequence<
98 : : ::com::sun::star::linguistic2::XDictionary > xDic);
99 : : void SearchForDictionaries( DictionaryVec_t &rDicList,
100 : : const String &rDicDir, sal_Bool bIsWritePath );
101 : : sal_Int32 GetDicPos(const com::sun::star::uno::Reference<
102 : : ::com::sun::star::linguistic2::XDictionary > &xDic);
103 : :
104 : : public:
105 : : DicList();
106 : : virtual ~DicList();
107 : :
108 : : // XDictionaryList
109 : : virtual ::sal_Int16 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException);
110 : : 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);
111 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > SAL_CALL getDictionaryByName( const ::rtl::OUString& aDictionaryName ) throw (::com::sun::star::uno::RuntimeException);
112 : : virtual ::sal_Bool SAL_CALL addDictionary( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary >& xDictionary ) throw (::com::sun::star::uno::RuntimeException);
113 : : virtual ::sal_Bool SAL_CALL removeDictionary( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary >& xDictionary ) throw (::com::sun::star::uno::RuntimeException);
114 : : 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);
115 : : virtual ::sal_Bool SAL_CALL removeDictionaryListEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryListEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
116 : : virtual ::sal_Int16 SAL_CALL beginCollectEvents( ) throw (::com::sun::star::uno::RuntimeException);
117 : : virtual ::sal_Int16 SAL_CALL endCollectEvents( ) throw (::com::sun::star::uno::RuntimeException);
118 : : virtual ::sal_Int16 SAL_CALL flushEvents( ) throw (::com::sun::star::uno::RuntimeException);
119 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > SAL_CALL createDictionary( const ::rtl::OUString& aName, const ::com::sun::star::lang::Locale& aLocale, ::com::sun::star::linguistic2::DictionaryType eDicType, const ::rtl::OUString& aURL ) throw (::com::sun::star::uno::RuntimeException);
120 : :
121 : : // XSearchableDictionaryList
122 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryEntry > SAL_CALL queryDictionaryEntry( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, sal_Bool bSearchPosDics, sal_Bool bSpellEntry ) throw(::com::sun::star::uno::RuntimeException);
123 : :
124 : : // XComponent
125 : : virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
126 : : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
127 : : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
128 : :
129 : : // XServiceInfo
130 : : virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
131 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
132 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
133 : :
134 : :
135 : : static inline ::rtl::OUString getImplementationName_Static() throw();
136 : : static com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
137 : :
138 : : // non UNO-specific
139 : : void SaveDics();
140 : : };
141 : :
142 : 142 : inline ::rtl::OUString DicList::getImplementationName_Static() throw()
143 : : {
144 : 142 : return A2OU( "com.sun.star.lingu2.DicList" );
145 : : }
146 : :
147 : :
148 : : #endif
149 : :
150 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|