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