1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dlistimp.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _LINGUISTIC_DLISTIMP_HXX_
32 #define _LINGUISTIC_DLISTIMP_HXX_
34 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
35 #include <com/sun/star/lang/XComponent.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
39 #include <cppuhelper/implbase1.hxx> // helper for implementations
40 #include <cppuhelper/implbase3.hxx> // helper for implementations
41 #include <cppuhelper/interfacecontainer.h>
42 #include <tools/debug.hxx>
50 class DicEvtListenerHelper
;
52 ///////////////////////////////////////////////////////////////////////////
55 public cppu::WeakImplHelper3
57 ::com::sun::star::linguistic2::XSearchableDictionaryList
,
58 ::com::sun::star::lang::XComponent
,
59 ::com::sun::star::lang::XServiceInfo
62 class MyAppExitListener
: public linguistic::AppExitListener
67 MyAppExitListener( DicList
&rDicList
) : rMyDicList( rDicList
) {}
68 virtual void AtExit();
73 ::cppu::OInterfaceContainerHelper aEvtListeners
;
75 typedef std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XDictionary
> > DictionaryVec_t
;
76 DictionaryVec_t aDicList
;
78 ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::
79 XDictionaryEventListener
> xDicEvtLstnrHelper
;
80 DicEvtListenerHelper
*pDicEvtLstnrHelper
;
82 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::
83 XTerminateListener
> xExitListener
;
84 MyAppExitListener
*pExitListener
;
89 // disallow copy-constructor and assignment-operator for now
90 DicList( const DicList
& );
91 DicList
& operator = (const DicList
&);
93 void _CreateDicList();
94 DictionaryVec_t
& GetOrCreateDicList()
96 if (!bInCreation
&& aDicList
.size() == 0)
101 void LaunchEvent(INT16 nEvent
, com::sun::star::uno::Sequence
<
102 ::com::sun::star::linguistic2::XDictionary
> xDic
);
103 void SearchForDictionaries( DictionaryVec_t
&rDicList
,
104 const String
&rDicDir
, BOOL bIsWritePath
);
105 INT32
GetDicPos(const com::sun::star::uno::Reference
<
106 ::com::sun::star::linguistic2::XDictionary
> &xDic
);
113 virtual ::sal_Int16 SAL_CALL
getCount( ) throw (::com::sun::star::uno::RuntimeException
);
114 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
);
115 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XDictionary
> SAL_CALL
getDictionaryByName( const ::rtl::OUString
& aDictionaryName
) throw (::com::sun::star::uno::RuntimeException
);
116 virtual ::sal_Bool SAL_CALL
addDictionary( const ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XDictionary
>& xDictionary
) throw (::com::sun::star::uno::RuntimeException
);
117 virtual ::sal_Bool SAL_CALL
removeDictionary( const ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XDictionary
>& xDictionary
) throw (::com::sun::star::uno::RuntimeException
);
118 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
);
119 virtual ::sal_Bool SAL_CALL
removeDictionaryListEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XDictionaryListEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
120 virtual ::sal_Int16 SAL_CALL
beginCollectEvents( ) throw (::com::sun::star::uno::RuntimeException
);
121 virtual ::sal_Int16 SAL_CALL
endCollectEvents( ) throw (::com::sun::star::uno::RuntimeException
);
122 virtual ::sal_Int16 SAL_CALL
flushEvents( ) throw (::com::sun::star::uno::RuntimeException
);
123 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
);
125 // XSearchableDictionaryList
126 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
);
129 virtual void SAL_CALL
dispose() throw(::com::sun::star::uno::RuntimeException
);
130 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
131 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
);
134 virtual ::rtl::OUString SAL_CALL
getImplementationName() throw(::com::sun::star::uno::RuntimeException
);
135 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
136 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
);
139 static inline ::rtl::OUString
getImplementationName_Static() throw();
140 static com::sun::star::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames_Static() throw();
146 inline ::rtl::OUString
DicList::getImplementationName_Static() throw()
148 return A2OU( "com.sun.star.lingu2.DicList" );
151 ///////////////////////////////////////////////////////////////////////////