1*63ce064aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*63ce064aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*63ce064aSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*63ce064aSAndrew Rist * distributed with this work for additional information
6*63ce064aSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*63ce064aSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*63ce064aSAndrew Rist * "License"); you may not use this file except in compliance
9*63ce064aSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*63ce064aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*63ce064aSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*63ce064aSAndrew Rist * software distributed under the License is distributed on an
15*63ce064aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63ce064aSAndrew Rist * KIND, either express or implied. See the License for the
17*63ce064aSAndrew Rist * specific language governing permissions and limitations
18*63ce064aSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*63ce064aSAndrew Rist *************************************************************/
21*63ce064aSAndrew Rist
22*63ce064aSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _LINGUISTIC_DLISTIMP_HXX_
25cdf0e10cSrcweir #define _LINGUISTIC_DLISTIMP_HXX_
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
28cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
29cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
32cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> // helper for implementations
33cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> // helper for implementations
34cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
35cdf0e10cSrcweir #include <tools/debug.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include <vector>
38cdf0e10cSrcweir #include <memory>
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include "linguistic/misc.hxx"
41cdf0e10cSrcweir #include "lngopt.hxx"
42cdf0e10cSrcweir
43cdf0e10cSrcweir class DicEvtListenerHelper;
44cdf0e10cSrcweir
45cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
46cdf0e10cSrcweir
47cdf0e10cSrcweir class DicList :
48cdf0e10cSrcweir public cppu::WeakImplHelper3
49cdf0e10cSrcweir <
50cdf0e10cSrcweir ::com::sun::star::linguistic2::XSearchableDictionaryList,
51cdf0e10cSrcweir ::com::sun::star::lang::XComponent,
52cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo
53cdf0e10cSrcweir >
54cdf0e10cSrcweir {
55cdf0e10cSrcweir class MyAppExitListener : public linguistic::AppExitListener
56cdf0e10cSrcweir {
57cdf0e10cSrcweir DicList & rMyDicList;
58cdf0e10cSrcweir
59cdf0e10cSrcweir public:
MyAppExitListener(DicList & rDicList)60cdf0e10cSrcweir MyAppExitListener( DicList &rDicList ) : rMyDicList( rDicList ) {}
61cdf0e10cSrcweir virtual void AtExit();
62cdf0e10cSrcweir };
63cdf0e10cSrcweir
64cdf0e10cSrcweir LinguOptions aOpt;
65cdf0e10cSrcweir
66cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper aEvtListeners;
67cdf0e10cSrcweir
68cdf0e10cSrcweir typedef std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > > DictionaryVec_t;
69cdf0e10cSrcweir DictionaryVec_t aDicList;
70cdf0e10cSrcweir
71cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::
72cdf0e10cSrcweir XDictionaryEventListener > xDicEvtLstnrHelper;
73cdf0e10cSrcweir DicEvtListenerHelper *pDicEvtLstnrHelper;
74cdf0e10cSrcweir
75cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::
76cdf0e10cSrcweir XTerminateListener > xExitListener;
77cdf0e10cSrcweir MyAppExitListener *pExitListener;
78cdf0e10cSrcweir
79cdf0e10cSrcweir sal_Bool bDisposing;
80cdf0e10cSrcweir sal_Bool bInCreation;
81cdf0e10cSrcweir
82cdf0e10cSrcweir // disallow copy-constructor and assignment-operator for now
83cdf0e10cSrcweir DicList( const DicList & );
84cdf0e10cSrcweir DicList & operator = (const DicList &);
85cdf0e10cSrcweir
86cdf0e10cSrcweir void _CreateDicList();
GetOrCreateDicList()87cdf0e10cSrcweir DictionaryVec_t & GetOrCreateDicList()
88cdf0e10cSrcweir {
89cdf0e10cSrcweir if (!bInCreation && aDicList.size() == 0)
90cdf0e10cSrcweir _CreateDicList();
91cdf0e10cSrcweir return aDicList;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
94cdf0e10cSrcweir void LaunchEvent(sal_Int16 nEvent, com::sun::star::uno::Sequence<
95cdf0e10cSrcweir ::com::sun::star::linguistic2::XDictionary > xDic);
96cdf0e10cSrcweir void SearchForDictionaries( DictionaryVec_t &rDicList,
97cdf0e10cSrcweir const String &rDicDir, sal_Bool bIsWritePath );
98cdf0e10cSrcweir sal_Int32 GetDicPos(const com::sun::star::uno::Reference<
99cdf0e10cSrcweir ::com::sun::star::linguistic2::XDictionary > &xDic);
100cdf0e10cSrcweir
101cdf0e10cSrcweir public:
102cdf0e10cSrcweir DicList();
103cdf0e10cSrcweir virtual ~DicList();
104cdf0e10cSrcweir
105cdf0e10cSrcweir // XDictionaryList
106cdf0e10cSrcweir virtual ::sal_Int16 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException);
107cdf0e10cSrcweir 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);
108cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > SAL_CALL getDictionaryByName( const ::rtl::OUString& aDictionaryName ) throw (::com::sun::star::uno::RuntimeException);
109cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL addDictionary( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary >& xDictionary ) throw (::com::sun::star::uno::RuntimeException);
110cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL removeDictionary( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary >& xDictionary ) throw (::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir 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);
112cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL removeDictionaryListEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryListEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
113cdf0e10cSrcweir virtual ::sal_Int16 SAL_CALL beginCollectEvents( ) throw (::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir virtual ::sal_Int16 SAL_CALL endCollectEvents( ) throw (::com::sun::star::uno::RuntimeException);
115cdf0e10cSrcweir virtual ::sal_Int16 SAL_CALL flushEvents( ) throw (::com::sun::star::uno::RuntimeException);
116cdf0e10cSrcweir 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);
117cdf0e10cSrcweir
118cdf0e10cSrcweir // XSearchableDictionaryList
119cdf0e10cSrcweir 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);
120cdf0e10cSrcweir
121cdf0e10cSrcweir // XComponent
122cdf0e10cSrcweir virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
123cdf0e10cSrcweir virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
124cdf0e10cSrcweir virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
125cdf0e10cSrcweir
126cdf0e10cSrcweir // XServiceInfo
127cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
128cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
129cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
130cdf0e10cSrcweir
131cdf0e10cSrcweir
132cdf0e10cSrcweir static inline ::rtl::OUString getImplementationName_Static() throw();
133cdf0e10cSrcweir static com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
134cdf0e10cSrcweir
135cdf0e10cSrcweir // non UNO-specific
136cdf0e10cSrcweir void SaveDics();
137cdf0e10cSrcweir };
138cdf0e10cSrcweir
getImplementationName_Static()139cdf0e10cSrcweir inline ::rtl::OUString DicList::getImplementationName_Static() throw()
140cdf0e10cSrcweir {
141cdf0e10cSrcweir return A2OU( "com.sun.star.lingu2.DicList" );
142cdf0e10cSrcweir }
143cdf0e10cSrcweir
144cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
145cdf0e10cSrcweir
146cdf0e10cSrcweir #endif
147cdf0e10cSrcweir
148