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 
29 #include "ListenerHelper.h"
30 #include "MyProtocolHandler.h"
31 #include <com/sun/star/beans/PropertyValue.hpp>
32 #include <com/sun/star/frame/XFrame.hpp>
33 #include <com/sun/star/frame/XController.hpp>
34 #include <com/sun/star/frame/DispatchDescriptor.hpp>
35 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
36 #include <com/sun/star/text/XTextViewCursor.hpp>
37 #include <com/sun/star/text/XTextCursor.hpp>
38 #include <com/sun/star/text/XTextDocument.hpp>
39 #include <com/sun/star/sheet/XSpreadsheetView.hpp>
40 #include <com/sun/star/frame/ControlCommand.hpp>
41 #include <com/sun/star/frame/ControlEvent.hpp>
42 #include <com/sun/star/frame/XModel.hpp>
43 #include <com/sun/star/frame/XControlNotificationListener.hpp>
44 #include <com/sun/star/beans/PropertyValue.hpp>
45 #include <com/sun/star/awt/XWindowPeer.hpp>
46 #include <com/sun/star/awt/WindowAttribute.hpp>
47 #include <com/sun/star/awt/XMessageBox.hpp>
48 #include <com/sun/star/frame/XComponentLoader.hpp>
49 #include <com/sun/star/view/XSelectionSupplier.hpp>
50 #include <com/sun/star/system/XSystemShellExecute.hpp>
51 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
52 #include <com/sun/star/frame/XStorable.hpp>
53 #include <com/sun/star/container/XContainerQuery.hpp>
54 
55 #include <osl/file.hxx>
56 
57 using namespace com::sun::star::uno;
58 using namespace com::sun::star::frame;
59 using com::sun::star::lang::XMultiServiceFactory;
60 using com::sun::star::beans::PropertyValue;
61 using com::sun::star::util::URL;
62 using com::sun::star::text::XTextViewCursorSupplier;
63 using com::sun::star::text::XTextViewCursor;
64 using com::sun::star::text::XTextCursor;
65 using com::sun::star::sheet::XSpreadsheetView;
66 using com::sun::star::frame::XModel;
67 using com::sun::star::text::XTextRange;
68 using com::sun::star::text::XTextDocument;
69 using com::sun::star::beans::NamedValue;
70 using namespace com::sun::star::awt;
71 using com::sun::star::view::XSelectionSupplier;
72 using namespace com::sun::star::system;
73 
74 ListenerHelper aListenerHelper;
75 
76 void BaseDispatch::ShowMessageBox( const Reference< XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText )
77 {
78 	if ( !mxToolkit.is() )
79 		mxToolkit = Reference< XToolkit > ( mxMSF->createInstance(
80 			::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
81                                             "com.sun.star.awt.Toolkit" ))), UNO_QUERY );
82     if ( rFrame.is() && mxToolkit.is() )
83     {
84         // describe window properties.
85         WindowDescriptor                aDescriptor;
86         aDescriptor.Type              = WindowClass_MODALTOP;
87         aDescriptor.WindowServiceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "infobox" ));
88         aDescriptor.ParentIndex       = -1;
89         aDescriptor.Parent            = Reference< XWindowPeer >( rFrame->getContainerWindow(), UNO_QUERY );
90         aDescriptor.Bounds            = Rectangle(0,0,300,200);
91         aDescriptor.WindowAttributes  = WindowAttribute::BORDER | WindowAttribute::MOVEABLE | WindowAttribute::CLOSEABLE;
92 
93         Reference< XWindowPeer > xPeer = mxToolkit->createWindow( aDescriptor );
94         if ( xPeer.is() )
95         {
96             Reference< XMessageBox > xMsgBox( xPeer, UNO_QUERY );
97             if ( xMsgBox.is() )
98             {
99                 xMsgBox->setCaptionText( aTitle );
100                 xMsgBox->setMessageText( aMsgText );
101                 xMsgBox->execute();
102             }
103         }
104     }
105 }
106 
107 void BaseDispatch::SendCommand( const com::sun::star::util::URL& aURL, const ::rtl::OUString& rCommand, const Sequence< NamedValue >& rArgs, sal_Bool bEnabled )
108 {
109     Reference < XDispatch > xDispatch =
110             aListenerHelper.GetDispatch( mxFrame, aURL.Path );
111 
112     FeatureStateEvent aEvent;
113 
114     aEvent.FeatureURL = aURL;
115     aEvent.Source     = xDispatch;
116     aEvent.IsEnabled  = bEnabled;
117     aEvent.Requery    = sal_False;
118 
119     ControlCommand aCtrlCmd;
120     aCtrlCmd.Command   = rCommand;
121     aCtrlCmd.Arguments = rArgs;
122 
123     aEvent.State <<= aCtrlCmd;
124     aListenerHelper.Notify( mxFrame, aEvent.FeatureURL.Path, aEvent );
125 }
126 
127 void BaseDispatch::SendCommandTo( const Reference< XStatusListener >& xControl, const URL& aURL, const ::rtl::OUString& rCommand, const Sequence< NamedValue >& rArgs, sal_Bool bEnabled )
128 {
129     FeatureStateEvent aEvent;
130 
131     aEvent.FeatureURL = aURL;
132     aEvent.Source     = (::com::sun::star::frame::XDispatch*) this;
133     aEvent.IsEnabled  = bEnabled;
134     aEvent.Requery    = sal_False;
135 
136     ControlCommand aCtrlCmd;
137     aCtrlCmd.Command   = rCommand;
138     aCtrlCmd.Arguments = rArgs;
139 
140     aEvent.State <<= aCtrlCmd;
141     xControl->statusChanged( aEvent );
142 }
143 
144 void SAL_CALL MyProtocolHandler::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException)
145 {
146 	Reference < XFrame > xFrame;
147 	if ( aArguments.getLength() )
148 	{
149 		// das erste Argument ist immer der Frame, da ein ProtocolHandler den braucht um Zugriff
150 		// auf den Context zu haben, in dem er aufgerufen wird
151 		aArguments[0] >>= xFrame;
152 		mxFrame = xFrame;
153 	}
154 }
155 
156 Reference< XDispatch > SAL_CALL MyProtocolHandler::queryDispatch(	const URL& aURL, const ::rtl::OUString& sTargetFrameName, sal_Int32 nSearchFlags )
157 				throw( RuntimeException )
158 {
159 	Reference < XDispatch > xRet;
160 	if ( !mxFrame.is() )
161 		return 0;
162 
163 	Reference < XController > xCtrl = mxFrame->getController();
164 	if ( xCtrl.is() && !aURL.Protocol.compareToAscii("vnd.demo.complextoolbarcontrols.demoaddon:") )
165 	{
166 		Reference < XTextViewCursorSupplier > xCursor( xCtrl, UNO_QUERY );
167 		Reference < XSpreadsheetView > xView( xCtrl, UNO_QUERY );
168 		if ( !xCursor.is() && !xView.is() )
169 			// ohne ein entsprechendes Dokument funktioniert der Handler nicht
170 			return xRet;
171 
172 		if ( aURL.Path.equalsAscii("Command1" ) ||
173 			 aURL.Path.equalsAscii("Command2" ) ||
174 			 aURL.Path.equalsAscii("Command3" ) ||
175 			 aURL.Path.equalsAscii("Command4" ) ||
176 			 aURL.Path.equalsAscii("Command5" ) ||
177 			 aURL.Path.equalsAscii("Command6" ) ||
178              aURL.Path.equalsAscii("Command7" ) )
179 		{
180 			xRet = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
181 			if ( !xRet.is() )
182 			{
183 				xRet = xCursor.is() ? (BaseDispatch*) new WriterDispatch( mxMSF, mxFrame ) :
184 					(BaseDispatch*) new CalcDispatch( mxMSF, mxFrame );
185 				aListenerHelper.AddDispatch( xRet, mxFrame, aURL.Path );
186 			}
187 		}
188 	}
189 
190 	return xRet;
191 }
192 
193 Sequence < Reference< XDispatch > > SAL_CALL MyProtocolHandler::queryDispatches( const Sequence < DispatchDescriptor >& seqDescripts )
194 			throw( RuntimeException )
195 {
196     sal_Int32 nCount = seqDescripts.getLength();
197     Sequence < Reference < XDispatch > > lDispatcher( nCount );
198 
199     for( sal_Int32 i=0; i<nCount; ++i )
200         lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL, seqDescripts[i].FrameName, seqDescripts[i].SearchFlags );
201 
202     return lDispatcher;
203 }
204 
205 ::rtl::OUString MyProtocolHandler_getImplementationName ()
206 	throw (RuntimeException)
207 {
208     return ::rtl::OUString::createFromAscii(MYPROTOCOLHANDLER_IMPLEMENTATIONNAME);
209 }
210 
211 sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& ServiceName )
212 	throw (RuntimeException)
213 {
214     return (
215             ServiceName.equalsAscii(MYPROTOCOLHANDLER_SERVICENAME  ) ||
216             ServiceName.equalsAscii("com.sun.star.frame.ProtocolHandler")
217            );
218 }
219 
220 Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler_getSupportedServiceNames(  )
221 	throw (RuntimeException)
222 {
223 	Sequence < ::rtl::OUString > aRet(1);
224     aRet[0] = ::rtl::OUString::createFromAscii(MYPROTOCOLHANDLER_SERVICENAME);
225     return aRet;
226 }
227 
228 #undef SERVICE_NAME
229 
230 Reference< XInterface > SAL_CALL MyProtocolHandler_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
231 	throw( Exception )
232 {
233 	return (cppu::OWeakObject*) new MyProtocolHandler( rSMgr );
234 }
235 
236 // XServiceInfo
237 ::rtl::OUString SAL_CALL MyProtocolHandler::getImplementationName(  )
238 	throw (RuntimeException)
239 {
240 	return MyProtocolHandler_getImplementationName();
241 }
242 
243 sal_Bool SAL_CALL MyProtocolHandler::supportsService( const ::rtl::OUString& rServiceName )
244 	throw (RuntimeException)
245 {
246     return MyProtocolHandler_supportsService( rServiceName );
247 }
248 
249 Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler::getSupportedServiceNames(  )
250 	throw (RuntimeException)
251 {
252     return MyProtocolHandler_getSupportedServiceNames();
253 }
254 
255 void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < PropertyValue >& lArgs ) throw (RuntimeException)
256 {
257 	/* Its neccessary to hold this object alive, till this method finish.
258 	   May the outside dispatch cache (implemented by the menu/toolbar!)
259 	   forget this instance during de-/activation of frames (focus!).
260 
261 		E.g. An open db beamer in combination with the My-Dialog
262 		can force such strange situation :-(
263 	 */
264 	Reference< XInterface > xSelfHold(static_cast< XDispatch* >(this), UNO_QUERY);
265 
266 	if ( !aURL.Protocol.compareToAscii("vnd.demo.complextoolbarcontrols.demoaddon:") )
267 	{
268 		if ( !aURL.Path.compareToAscii("Command1" ) )
269 		{
270             // open the OpenOffice.org web page
271             ::rtl::OUString sURL(::rtl::OUString::createFromAscii("http://www.openoffice.org"));
272             Reference< XSystemShellExecute > xSystemShellExecute( mxMSF->createInstance(
273                 ::rtl::OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" )), UNO_QUERY );
274             if ( xSystemShellExecute.is() )
275             {
276                 try
277 
278                 {
279                     xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
280                 }
281                 catch( Exception& rEx )
282                 {
283                     (void)rEx;
284                 }
285             }
286         }
287 		else if ( !aURL.Path.compareToAscii("Command2" ) )
288 		{
289             // remove the text if it's in our list
290             Sequence< NamedValue > aRemoveArgs( 1 );
291             aRemoveArgs[0].Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ));
292             aRemoveArgs[0].Value <<= maComboBoxText;
293             SendCommand( aURL, ::rtl::OUString::createFromAscii( "RemoveEntryText" ), aRemoveArgs, sal_True );
294 
295             // add the new text to the start of the list
296             Sequence< NamedValue > aInsertArgs( 2 );
297             aInsertArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" ));
298             aInsertArgs[0].Value <<= sal_Int32( 0 );
299             aInsertArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ));
300             aInsertArgs[1].Value <<= maComboBoxText;
301             SendCommand( aURL, ::rtl::OUString::createFromAscii( "InsertEntry" ), aInsertArgs, sal_True );
302         }
303 		else if ( !aURL.Path.compareToAscii("Command3" ) )
304 		{
305             // Retrieve the text argument from the sequence property value
306             rtl::OUString aText;
307             for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
308             {
309                 if ( lArgs[i].Name.equalsAsciiL( "Text", 4 ))
310                 {
311                     lArgs[i].Value >>= aText;
312                     break;
313                 }
314             }
315 
316             // create new URL to address the combox box
317             URL aCmdURL;
318             aCmdURL.Path = rtl::OUString::createFromAscii( "Command2" );
319             aCmdURL.Protocol = rtl::OUString::createFromAscii( "vnd.demo.complextoolbarcontrols.demoaddon:" );
320             aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol;
321 
322             // set the selected item as text into the combobox
323             Sequence< NamedValue > aArgs( 1 );
324             aArgs[0].Name = rtl::OUString::createFromAscii( "Text" );
325             aArgs[0].Value <<= aText;
326             SendCommand( aCmdURL, ::rtl::OUString::createFromAscii( "SetText" ), aArgs, sal_True );
327 		}
328 		else if ( !aURL.Path.compareToAscii("Command4" ) )
329 		{
330             // Retrieve the text argument from the sequence property value
331             rtl::OUString aText;
332             for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
333             {
334                 if ( lArgs[i].Name.equalsAsciiL( "Text", 4 ))
335                 {
336                     lArgs[i].Value >>= aText;
337                     break;
338                 }
339             }
340 
341             // just enable this command
342 
343             // set enable flag according to selection
344             if ( aText.equalsAscii( "Button Disabled" ))
345                 mbButtonEnabled = sal_False;
346             else
347                 mbButtonEnabled = sal_True;
348 
349             // create new URL to address the image button
350             URL aCmdURL;
351             aCmdURL.Path = rtl::OUString::createFromAscii( "Command1" );
352             aCmdURL.Protocol = rtl::OUString::createFromAscii( "vnd.demo.complextoolbarcontrols.demoaddon:" );
353             aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol;
354 
355             // create and initialize FeatureStateEvent with IsEnabled
356             ::com::sun::star::frame::FeatureStateEvent aEvent;
357 			aEvent.FeatureURL = aCmdURL;
358 		    aEvent.Source = (::com::sun::star::frame::XDispatch*) this;
359 			aEvent.IsEnabled = mbButtonEnabled;
360 			aEvent.Requery = sal_False;
361 			aEvent.State <<= Any();
362 
363             // Notify listener about new state
364             Reference < XDispatch > xDispatch = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
365             aListenerHelper.Notify( mxFrame, aEvent.FeatureURL.Path, aEvent );
366         }
367         else if ( !aURL.Path.compareToAscii("Command5" ) )
368         {
369         }
370 	}
371 }
372 
373 void SAL_CALL BaseDispatch::addStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw (RuntimeException)
374 {
375 	if ( aURL.Protocol.equalsAscii("vnd.demo.complextoolbarcontrols.demoaddon:") )
376 	{
377 		if ( aURL.Path.equalsAscii("Command1" ) )
378         {
379 			// just enable this command
380 		    ::com::sun::star::frame::FeatureStateEvent aEvent;
381 			aEvent.FeatureURL = aURL;
382 		    aEvent.Source = (::com::sun::star::frame::XDispatch*) this;
383 			aEvent.IsEnabled = mbButtonEnabled;
384 			aEvent.Requery = sal_False;
385 			aEvent.State <<= Any();
386 			xControl->statusChanged( aEvent );
387         }
388         else if ( aURL.Path.equalsAscii("Command2" ) )
389 		{
390 			// just enable this command
391 		    ::com::sun::star::frame::FeatureStateEvent aEvent;
392 			aEvent.FeatureURL = aURL;
393 		    aEvent.Source = (::com::sun::star::frame::XDispatch*) this;
394 			aEvent.IsEnabled = sal_True;
395 			aEvent.Requery = sal_False;
396 			aEvent.State <<= Any();
397 			xControl->statusChanged( aEvent );
398 		}
399 		else if ( aURL.Path.equalsAscii("Command3" ) )
400 		{
401             // A toggle dropdown box is normally used for a group of commands
402             // where the user can select the last issued command easily.
403             // E.g. a typical command group would be "Insert shape"
404             Sequence< NamedValue > aArgs( 1 );
405 
406             // send command to set context menu content
407             Sequence< rtl::OUString > aContextMenu( 3 );
408             aContextMenu[0] = rtl::OUString::createFromAscii( "Command 1" );
409             aContextMenu[1] = rtl::OUString::createFromAscii( "Command 2" );
410             aContextMenu[2] = rtl::OUString::createFromAscii( "Command 3" );
411 
412             aArgs[0].Name = rtl::OUString::createFromAscii( "List" );
413             aArgs[0].Value <<= aContextMenu;
414             SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True );
415 
416             // send command to check item on pos=0
417             aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" ));
418             aArgs[0].Value <<= sal_Int32( 0 );
419             SendCommandTo( xControl, aURL, ::rtl::OUString::createFromAscii( "CheckItemPos" ), aArgs, sal_True );
420         }
421         else if ( aURL.Path.equalsAscii("Command4" ) )
422         {
423             // A dropdown box is normally used for a group of dependent modes, where
424             // the user can only select one. The modes cannot be combined.
425             // E.g. a typical group would be left,right,center,block.
426             Sequence< NamedValue > aArgs( 1 );
427 
428             // send command to set context menu content
429             Sequence< rtl::OUString > aContextMenu( 2 );
430             aContextMenu[0] = rtl::OUString::createFromAscii( "Button Enabled" );
431             aContextMenu[1] = rtl::OUString::createFromAscii( "Button Disabled" );
432 
433             aArgs[0].Name = rtl::OUString::createFromAscii( "List" );
434             aArgs[0].Value <<= aContextMenu;
435             SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True );
436 
437             // set position according to enable/disable state of button
438             sal_Int32 nPos( mbButtonEnabled ? 0 : 1 );
439 
440             // send command to check item on pos=0
441             aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" ));
442             aArgs[0].Value <<= nPos;
443             SendCommandTo( xControl, aURL, ::rtl::OUString::createFromAscii( "CheckItemPos" ), aArgs, sal_True );
444         }
445         else if ( aURL.Path.equalsAscii("Command5" ) )
446         {
447             // A spin button
448             Sequence< NamedValue > aArgs( 5 );
449 
450             // send command to initialize spin button
451             aArgs[0].Name = rtl::OUString::createFromAscii( "Value" );
452             aArgs[0].Value <<= double( 0.0 );
453             aArgs[1].Name = rtl::OUString::createFromAscii( "UpperLimit" );
454             aArgs[1].Value <<= double( 10.0 );
455             aArgs[2].Name = rtl::OUString::createFromAscii( "LowerLimit" );
456             aArgs[2].Value <<= double( 0.0 );
457             aArgs[3].Name = rtl::OUString::createFromAscii( "Step" );
458             aArgs[3].Value <<= double( 0.1 );
459             aArgs[4].Name = rtl::OUString::createFromAscii( "OutputFormat" );
460             aArgs[4].Value <<= rtl::OUString::createFromAscii( "%.2f cm" );
461 
462             SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetValues" ), aArgs, sal_True );
463         }
464         else if ( aURL.Path.equalsAscii("Command7" ) )
465         {
466             // A dropdown box is normally used for a group of commands
467             // where the user can select one of a defined set.
468             Sequence< NamedValue > aArgs( 1 );
469 
470             // send command to set context menu content
471             Sequence< rtl::OUString > aList( 10 );
472             aList[0] = rtl::OUString::createFromAscii( "White" );
473             aList[1] = rtl::OUString::createFromAscii( "Black" );
474             aList[2] = rtl::OUString::createFromAscii( "Red" );
475             aList[3] = rtl::OUString::createFromAscii( "Blue" );
476             aList[4] = rtl::OUString::createFromAscii( "Green" );
477             aList[5] = rtl::OUString::createFromAscii( "Grey" );
478             aList[6] = rtl::OUString::createFromAscii( "Yellow" );
479             aList[7] = rtl::OUString::createFromAscii( "Orange" );
480             aList[8] = rtl::OUString::createFromAscii( "Brown" );
481             aList[9] = rtl::OUString::createFromAscii( "Pink" );
482 
483             aArgs[0].Name = rtl::OUString::createFromAscii( "List" );
484             aArgs[0].Value <<= aList;
485             SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True );
486         }
487 
488 		aListenerHelper.AddListener( mxFrame, xControl, aURL.Path );
489 	}
490 }
491 
492 void SAL_CALL BaseDispatch::removeStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw (RuntimeException)
493 {
494 	aListenerHelper.RemoveListener( mxFrame, xControl, aURL.Path );
495 }
496 
497 void SAL_CALL BaseDispatch::controlEvent( const ControlEvent& Event ) throw (RuntimeException)
498 {
499     if ( Event.aURL.Protocol.equalsAscii("vnd.demo.complextoolbarcontrols.demoaddon:" ))
500 	{
501         if ( Event.aURL.Path.equalsAscii( "Command2" ))
502         {
503             // We get notifications whenever the text inside the combobox has been changed.
504             // We store the new text into a member.
505             if ( Event.Event.equalsAscii( "TextChanged" ))
506             {
507                 rtl::OUString aNewText;
508                 sal_Bool      bHasText( sal_False );
509                 for ( sal_Int32 i = 0; i < Event.aInformation.getLength(); i++ )
510                 {
511                     if ( Event.aInformation[i].Name.equalsAsciiL( "Text", 4 ))
512                     {
513                         bHasText = Event.aInformation[i].Value >>= aNewText;
514                         break;
515                     }
516                 }
517 
518                 if ( bHasText )
519                     maComboBoxText = aNewText;
520             }
521         }
522     }
523 }
524 
525 BaseDispatch::BaseDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
526         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const ::rtl::OUString& rServiceName )
527         : mxMSF( rxMSF )
528 		, mxFrame( xFrame )
529         , msDocService( rServiceName )
530         , mbButtonEnabled( sal_True )
531 {
532 }
533 
534 
535 BaseDispatch::~BaseDispatch()
536 {
537 	mxFrame.clear();
538 	mxMSF.clear();
539 }
540