Better, Faster, Freer

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: i386 ]
Version: HEAD ]

001 /*************************************************************************
002  *
003  *  OpenOffice.org - a multi-platform office productivity suite
004  *
005  *  $RCSfile: dlelstnr.cxx,v $
006  *
007  *  $Revision: 1.11 $
008  *
009  *  last change: $Author: hr $ $Date: 2007/09/27 12:41:14 $
010  *
011  *  The Contents of this file are made available subject to
012  *  the terms of GNU Lesser General Public License Version 2.1.
013  *
014  *
015  *    GNU Lesser General Public License Version 2.1
016  *    =============================================
017  *    Copyright 2005 by Sun Microsystems, Inc.
018  *    901 San Antonio Road, Palo Alto, CA 94303, USA
019  *
020  *    This library is free software; you can redistribute it and/or
021  *    modify it under the terms of the GNU Lesser General Public
022  *    License version 2.1, as published by the Free Software Foundation.
023  *
024  *    This library is distributed in the hope that it will be useful,
025  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
026  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
027  *    Lesser General Public License for more details.
028  *
029  *    You should have received a copy of the GNU Lesser General Public
030  *    License along with this library; if not, write to the Free Software
031  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
032  *    MA  02111-1307  USA
033  *
034  ************************************************************************/
035 
036 // MARKER(update_precomp.py): autogen include statement, do not remove
037 #include "precompiled_sw.hxx"
038 
039 
040 
041 
042 #ifndef _COM_SUN_STAR_LINGUISTIC2_DICTIONARYLISTEVENTFLAGS_HPP_
043 #include <com/sun/star/linguistic2/DictionaryListEventFlags.hpp>
044 #endif
045 #ifndef _COM_SUN_STAR_LINGUISTIC_XDICTIONARYLIST_HPP_
046 #include <com/sun/star/linguistic2/XDictionaryList.hpp>
047 #endif
048 #ifndef _COM_SUN_STAR_LINGUISTIC2_XLINGUSERVICEMANAGER_HPP_
049 #include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
050 #endif
051 #ifndef _COM_SUN_STAR_LINGUISTIC2_LINGUSERVICEEVENTFLAGS_HPP_
052 #include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp>
053 #endif
054 
055 #include <com/sun/star/uno/Reference.h>
056 
057 #ifndef _COMPHELPER_PROCESSFACTORY_HXX_
058 #include <comphelper/processfactory.hxx>
059 #endif
060 
061 #ifndef _VOS_MUTEX_HXX_
062 #include <vos/mutex.hxx>
063 #endif
064 #ifndef _SV_SVAPP_HXX
065 #include <vcl/svapp.hxx>
066 #endif
067 #ifndef _SHL_HXX
068 #include <tools/shl.hxx>
069 #endif
070 
071 #ifndef _DLELSTNR_HXX_
072 #include "dlelstnr.hxx"
073 #endif
074 #ifndef _SWMODULE_HXX
075 #include <swmodule.hxx>
076 #endif
077 #ifndef _WRTSH_HXX
078 #include <wrtsh.hxx>
079 #endif
080 #ifndef _SWVIEW_HXX
081 #include <view.hxx>
082 #endif
083 
084 
085 using namespace ::rtl;
086 using namespace ::com::sun::star;
087 using namespace ::com::sun::star::lang;
088 using namespace ::com::sun::star::frame;
089 using namespace ::com::sun::star::uno;
090 using namespace ::com::sun::star::linguistic2;
091 using namespace ::com::sun::star::linguistic2::LinguServiceEventFlags;
092 
093 #define A2OU(x) OUString::createFromAscii(x)
094 
095 /* -----------------------------17.03.00 09:07--------------------------------
096 
097  ---------------------------------------------------------------------------*/
098 SwLinguServiceEventListener::SwLinguServiceEventListener()
099 {
100         Reference< XMultiServiceFactory > xMgr( comphelper::getProcessServiceFactory() );
101         if (xMgr.is())
102         {
103                 OUString aSvcName( A2OU( "com.sun.star.frame.Desktop" ) );
104                 xDesktop = Reference< frame::XDesktop >(
105                                 xMgr->createInstance( aSvcName ), UNO_QUERY );
106                 if (xDesktop.is())
107                         xDesktop->addTerminateListener( this );
108 
109                 aSvcName = A2OU( "com.sun.star.linguistic2.LinguServiceManager" );
110                 xLngSvcMgr = Reference< XLinguServiceManager >(
111                                 xMgr->createInstance( aSvcName ), UNO_QUERY );
112                 if (xLngSvcMgr.is())
113                         xLngSvcMgr->addLinguServiceManagerListener(
114                                 (XLinguServiceEventListener *) this );
115         }
116 }
117 /* -----------------------------17.03.00 09:07--------------------------------
118 
119  ---------------------------------------------------------------------------*/
120 SwLinguServiceEventListener::~SwLinguServiceEventListener()
121 {
122 }
123 
124 /* -----------------------------17.03.00 09:06--------------------------------
125 
126  ---------------------------------------------------------------------------*/
127 
128 void SwLinguServiceEventListener::processDictionaryListEvent(
129                         const DictionaryListEvent& rDicListEvent)
130                 throw( RuntimeException )
131 {
132         vos::OGuard aGuard(Application::GetSolarMutex());
133 
134         sal_Int16 nEvt = rDicListEvent.nCondensedEvent;
135 
136         sal_Int16 nSpellWrongFlags =
137                         DictionaryListEventFlags::ADD_POS_ENTRY         |
138                         DictionaryListEventFlags::DEL_NEG_ENTRY         |
139                         DictionaryListEventFlags::ACTIVATE_POS_DIC      |
140                         DictionaryListEventFlags::DEACTIVATE_NEG_DIC;
141         sal_Bool bIsSpellWrong  =  0 != (nEvt & nSpellWrongFlags);
142         sal_Int16 nSpellAllFlags =
143                         DictionaryListEventFlags::ADD_NEG_ENTRY         |
144                         DictionaryListEventFlags::DEL_POS_ENTRY         |
145                         DictionaryListEventFlags::ACTIVATE_NEG_DIC      |
146                         DictionaryListEventFlags::DEACTIVATE_POS_DIC;
147         sal_Bool bIsSpellAll    =  0 != (nEvt & nSpellAllFlags);
148 
149         if (bIsSpellWrong || bIsSpellAll)
150                 SW_MOD()->CheckSpellChanges( sal_False, bIsSpellWrong, bIsSpellAll, sal_False );
151 }
152 
153 
154 void SAL_CALL SwLinguServiceEventListener::processLinguServiceEvent(
155                         const LinguServiceEvent& rLngSvcEvent )
156                 throw(RuntimeException)
157 {
158         vos::OGuard aGuard(Application::GetSolarMutex());
159 
160         if (rLngSvcEvent.Source == xLngSvcMgr)
161         {
162                 sal_Bool bIsSpellWrong =
163                                 0 != (rLngSvcEvent.nEvent & SPELL_WRONG_WORDS_AGAIN);
164                 sal_Bool bIsSpellAll   =
165                                 0 != (rLngSvcEvent.nEvent & SPELL_CORRECT_WORDS_AGAIN);
166                 if (bIsSpellWrong || bIsSpellAll)
167                 {
168                         SW_MOD()->CheckSpellChanges( sal_False, bIsSpellWrong, bIsSpellAll, sal_False );
169                 }
170                 if (rLngSvcEvent.nEvent & HYPHENATE_AGAIN)
171                 {
172                         SwView *pSwView = SW_MOD()->GetFirstView();
173 
174             //!! since this function may be called within the ctor of
175             //!! SwView (during formatting) where the WrtShell is not yet
176             //!! created, we have to check for the WrtShellPtr to see
177             //!! if it is already availbale
178             while (pSwView && pSwView->GetWrtShellPtr())
179                         {
180                                 pSwView->GetWrtShell().ChgHyphenation();
181                                 pSwView = SW_MOD()->GetNextView( pSwView );
182                         }
183                 }
184         }
185 }
186 
187 
188 void SAL_CALL SwLinguServiceEventListener::disposing(
189                         const EventObject& rEventObj )
190                 throw(RuntimeException)
191 {
192         vos::OGuard aGuard(Application::GetSolarMutex());
193 
194         if (xLngSvcMgr.is()  &&  rEventObj.Source == xLngSvcMgr)
195         {
196                 xLngSvcMgr = 0;
197         }
198 }
199 
200 
201 void SAL_CALL SwLinguServiceEventListener::queryTermination(
202                         const EventObject& /*rEventObj*/ )
203                 throw(TerminationVetoException, RuntimeException)
204 {
205         //vos::OGuard aGuard(Application::GetSolarMutex());
206 }
207 
208 
209 void SAL_CALL SwLinguServiceEventListener::notifyTermination(
210                         const EventObject& rEventObj )
211                 throw(RuntimeException)
212 {
213         vos::OGuard aGuard(Application::GetSolarMutex());
214 
215         if (xDesktop.is()  &&  rEventObj.Source == xDesktop)
216         {
217                 if (xLngSvcMgr.is())
218                 {
219                         xLngSvcMgr->removeLinguServiceManagerListener(
220                                         (XLinguServiceEventListener *) this );
221                         xLngSvcMgr = 0;
222                 }
223                 xDesktop = NULL;
224         }
225 }
226 

source navigation ] diff markup ] identifier search ] general search ]

This page was automatically generated by the LXR engine.
The LXR team
Valid HTML 4.01!