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 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_framework.hxx"
30 #include <uielement/newmenucontroller.hxx>
31 
32 //_________________________________________________________________________________________________________________
33 //	my own includes
34 //_________________________________________________________________________________________________________________
35 #include <threadhelp/resetableguard.hxx>
36 #include "services.h"
37 #ifndef __FRAMEWORK_CLASSES_RESOURCE_HRC_
38 #include <classes/resource.hrc>
39 #endif
40 #include <classes/fwkresid.hxx>
41 #include <framework/bmkmenu.hxx>
42 #include <framework/imageproducer.hxx>
43 #include <framework/menuconfiguration.hxx>
44 
45 //_________________________________________________________________________________________________________________
46 //	interface includes
47 //_________________________________________________________________________________________________________________
48 #include <com/sun/star/awt/XDevice.hpp>
49 #include <com/sun/star/beans/PropertyValue.hpp>
50 #include <com/sun/star/awt/MenuItemStyle.hpp>
51 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
52 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
53 #include <com/sun/star/frame/XModuleManager.hpp>
54 #include <com/sun/star/container/XNameAccess.hpp>
55 #include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
56 
57 //_________________________________________________________________________________________________________________
58 //	includes of other projects
59 //_________________________________________________________________________________________________________________
60 #include <vcl/svapp.hxx>
61 #include <vcl/i18nhelp.hxx>
62 #include <tools/urlobj.hxx>
63 #include <rtl/ustrbuf.hxx>
64 #include <cppuhelper/implbase1.hxx>
65 #include <osl/file.hxx>
66 #include <svtools/menuoptions.hxx>
67 #include <svtools/acceleratorexecute.hxx>
68 #include <unotools/moduleoptions.hxx>
69 #include <dispatch/uieventloghelper.hxx>
70 #include <vos/mutex.hxx>
71 
72 //_________________________________________________________________________________________________________________
73 //	Defines
74 //_________________________________________________________________________________________________________________
75 //
76 
77 using namespace com::sun::star::uno;
78 using namespace com::sun::star::lang;
79 using namespace com::sun::star::frame;
80 using namespace com::sun::star::beans;
81 using namespace com::sun::star::util;
82 using namespace com::sun::star::container;
83 using namespace com::sun::star::ui;
84 
85 static const char SFX_REFERER_USER[] = "private:user";
86 
87 namespace framework
88 {
89 
90 DEFINE_XSERVICEINFO_MULTISERVICE        (   NewMenuController                           ,
91                                             OWeakObject                                 ,
92                                             SERVICENAME_POPUPMENUCONTROLLER		        ,
93 											IMPLEMENTATIONNAME_NEWMENUCONTROLLER
94 										)
95 
96 DEFINE_INIT_SERVICE                     (   NewMenuController, {} )
97 
98 void NewMenuController::setMenuImages( PopupMenu* pPopupMenu, sal_Bool bSetImages, sal_Bool bHiContrast )
99 {
100 	sal_uInt16 nItemCount = pPopupMenu->GetItemCount();
101     Image               aImage;
102     Reference< XFrame > xFrame( m_xFrame );
103 
104     for ( sal_uInt16 i = 0; i < nItemCount; i++ )
105     {
106         sal_uInt16 nItemId = pPopupMenu->GetItemId( sal::static_int_cast<sal_uInt16>( i ));
107         if ( nItemId != 0 )
108         {
109             if ( bSetImages )
110             {
111                 sal_Bool        bImageSet( sal_False );
112 		        ::rtl::OUString aImageId;
113 
114                 AddInfoForId::const_iterator pInfo = m_aAddInfoForItem.find( nItemId );
115                 if ( pInfo != m_aAddInfoForItem.end() )
116 				    aImageId = pInfo->second.aImageId; // Retrieve image id for menu item
117 
118 			    if ( aImageId.getLength() > 0 )
119 			    {
120                     aImage = GetImageFromURL( xFrame, aImageId, sal_False, bHiContrast );
121 				    if ( !!aImage )
122 				    {
123 					    bImageSet = sal_True;
124 					    pPopupMenu->SetItemImage( nItemId, aImage );
125 				    }
126 			    }
127 
128 			    if ( !bImageSet )
129                 {
130                     String aCmd( pPopupMenu->GetItemCommand( nItemId ) );
131                     if ( aCmd.Len() )
132                         aImage = GetImageFromURL( xFrame, aCmd, sal_False, bHiContrast );
133 
134                     if ( !!aImage )
135                         pPopupMenu->SetItemImage( nItemId, aImage );
136                 }
137             }
138             else
139                 pPopupMenu->SetItemImage( nItemId, aImage );
140         }
141     }
142 }
143 
144 void NewMenuController::determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const KeyCode& rKeyCode )
145 {
146     sal_uInt16        nCount( pPopupMenu->GetItemCount() );
147     sal_uInt16        nId( 0 );
148     sal_Bool      bFound( sal_False );
149     rtl::OUString aCommand;
150 
151     if ( m_aEmptyDocURL.getLength() > 0 )
152     {
153         // Search for the empty document URL
154 
155         for ( sal_uInt32 i = 0; i < sal_uInt32( nCount ); i++ )
156         {
157             nId = pPopupMenu->GetItemId( sal_uInt16( i ));
158             if ( nId != 0 && pPopupMenu->GetItemType( nId ) != MENUITEM_SEPARATOR )
159             {
160                 aCommand = pPopupMenu->GetItemCommand( nId );
161                 if ( aCommand.indexOf( m_aEmptyDocURL ) == 0 )
162                 {
163                     pPopupMenu->SetAccelKey( nId, rKeyCode );
164                     bFound = sal_True;
165                     break;
166                 }
167             }
168         }
169     }
170 
171     if ( !bFound )
172     {
173         // Search for the default module name
174         rtl::OUString aDefaultModuleName( SvtModuleOptions().GetDefaultModuleName() );
175         if ( aDefaultModuleName.getLength() > 0 )
176         {
177             for ( sal_uInt32 i = 0; i < sal_uInt32( nCount ); i++ )
178             {
179                 nId = pPopupMenu->GetItemId( sal_uInt16( i ));
180                 if ( nId != 0 && pPopupMenu->GetItemType( nId ) != MENUITEM_SEPARATOR )
181                 {
182                     aCommand = pPopupMenu->GetItemCommand( nId );
183                     if ( aCommand.indexOf( aDefaultModuleName ) >= 0 )
184                     {
185                         pPopupMenu->SetAccelKey( nId, rKeyCode );
186                         break;
187                     }
188                 }
189             }
190         }
191     }
192 }
193 
194 void NewMenuController::setAccelerators( PopupMenu* pPopupMenu )
195 {
196     if ( m_bModuleIdentified )
197     {
198         Reference< XAcceleratorConfiguration > xDocAccelCfg( m_xDocAcceleratorManager );
199         Reference< XAcceleratorConfiguration > xModuleAccelCfg( m_xModuleAcceleratorManager );
200         Reference< XAcceleratorConfiguration > xGlobalAccelCfg( m_xGlobalAcceleratorManager );
201 
202         if ( !m_bAcceleratorCfg )
203         {
204             // Retrieve references on demand
205             m_bAcceleratorCfg = sal_True;
206             if ( !xDocAccelCfg.is() )
207             {
208                 Reference< XController > xController = m_xFrame->getController();
209                 Reference< XModel > xModel;
210                 if ( xController.is() )
211                 {
212                     xModel = xController->getModel();
213                     if ( xModel.is() )
214                     {
215                         Reference< XUIConfigurationManagerSupplier > xSupplier( xModel, UNO_QUERY );
216                         if ( xSupplier.is() )
217                         {
218                             Reference< XUIConfigurationManager > xDocUICfgMgr( xSupplier->getUIConfigurationManager(), UNO_QUERY );
219                             if ( xDocUICfgMgr.is() )
220                             {
221                                 xDocAccelCfg = Reference< XAcceleratorConfiguration >( xDocUICfgMgr->getShortCutManager(), UNO_QUERY );
222                                 m_xDocAcceleratorManager = xDocAccelCfg;
223                             }
224                         }
225                     }
226                 }
227             }
228 
229             if ( !xModuleAccelCfg.is() )
230             {
231                 Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier( m_xServiceManager->createInstance(
232                                                                                             SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER ),
233                                                                                         UNO_QUERY );
234                 Reference< XUIConfigurationManager > xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier );
235                 if ( xUICfgMgr.is() )
236                 {
237                     xModuleAccelCfg = Reference< XAcceleratorConfiguration >( xUICfgMgr->getShortCutManager(), UNO_QUERY );
238                     m_xModuleAcceleratorManager = xModuleAccelCfg;
239                 }
240             }
241 
242             if ( !xGlobalAccelCfg.is() )
243             {
244                 xGlobalAccelCfg = Reference< XAcceleratorConfiguration >( m_xServiceManager->createInstance(
245                                                                             SERVICENAME_GLOBALACCELERATORCONFIGURATION ),
246                                                                           UNO_QUERY );
247                 m_xGlobalAcceleratorManager = xGlobalAccelCfg;
248             }
249         }
250 
251         KeyCode                         aEmptyKeyCode;
252         sal_uInt32                      nItemCount( pPopupMenu->GetItemCount() );
253         std::vector< KeyCode >          aMenuShortCuts;
254         std::vector< rtl::OUString >    aCmds;
255         std::vector< sal_uInt32 >       aIds;
256         for ( sal_uInt32 i = 0; i < nItemCount; i++ )
257         {
258             sal_uInt16 nId( pPopupMenu->GetItemId( sal_uInt16( i )));
259             if ( nId & ( pPopupMenu->GetItemType( nId ) != MENUITEM_SEPARATOR ))
260             {
261                 aIds.push_back( nId );
262                 aMenuShortCuts.push_back( aEmptyKeyCode );
263                 aCmds.push_back( pPopupMenu->GetItemCommand( nId ));
264             }
265         }
266 
267         sal_uInt32 nSeqCount( aIds.size() );
268 
269         if ( m_bNewMenu )
270             nSeqCount+=1;
271 
272         Sequence< rtl::OUString > aSeq( nSeqCount );
273 
274         // Add a special command for our "New" menu.
275         if ( m_bNewMenu )
276         {
277             aSeq[nSeqCount-1] = m_aCommandURL;
278             aMenuShortCuts.push_back( aEmptyKeyCode );
279         }
280 
281         const sal_uInt32 nCount = aCmds.size();
282         for ( sal_uInt32 i = 0; i < nCount; i++ )
283             aSeq[i] = aCmds[i];
284 
285         if ( m_xGlobalAcceleratorManager.is() )
286             retrieveShortcutsFromConfiguration( xGlobalAccelCfg, aSeq, aMenuShortCuts );
287         if ( m_xModuleAcceleratorManager.is() )
288             retrieveShortcutsFromConfiguration( xModuleAccelCfg, aSeq, aMenuShortCuts );
289         if ( m_xDocAcceleratorManager.is() )
290             retrieveShortcutsFromConfiguration( xGlobalAccelCfg, aSeq, aMenuShortCuts );
291 
292         const sal_uInt32 nCount2 = aIds.size();
293         for ( sal_uInt32 i = 0; i < nCount2; i++ )
294             pPopupMenu->SetAccelKey( sal_uInt16( aIds[i] ), aMenuShortCuts[i] );
295 
296         // Special handling for "New" menu short-cut should be set at the
297         // document which will be opened using it.
298         if ( m_bNewMenu )
299         {
300             if ( aMenuShortCuts[nSeqCount-1] != aEmptyKeyCode )
301                 determineAndSetNewDocAccel( pPopupMenu, aMenuShortCuts[nSeqCount-1] );
302         }
303     }
304 }
305 
306 void NewMenuController::retrieveShortcutsFromConfiguration(
307     const Reference< XAcceleratorConfiguration >& rAccelCfg,
308     const Sequence< rtl::OUString >& rCommands,
309     std::vector< KeyCode >& aMenuShortCuts )
310 {
311     if ( rAccelCfg.is() )
312     {
313         try
314         {
315             com::sun::star::awt::KeyEvent aKeyEvent;
316             Sequence< Any > aSeqKeyCode = rAccelCfg->getPreferredKeyEventsForCommandList( rCommands );
317             for ( sal_Int32 i = 0; i < aSeqKeyCode.getLength(); i++ )
318             {
319                 if ( aSeqKeyCode[i] >>= aKeyEvent )
320                     aMenuShortCuts[i] = svt::AcceleratorExecute::st_AWTKey2VCLKey( aKeyEvent );
321             }
322         }
323         catch ( IllegalArgumentException& )
324         {
325         }
326     }
327 }
328 
329 NewMenuController::NewMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) :
330 	svt::PopupMenuControllerBase( xServiceManager ),
331     m_bShowImages( sal_True ),
332     m_bHiContrast( sal_False ),
333     m_bNewMenu( sal_False ),
334     m_bModuleIdentified( sal_False ),
335     m_bAcceleratorCfg( sal_False ),
336     m_aTargetFrame( RTL_CONSTASCII_USTRINGPARAM( "_default" ))
337 {
338 }
339 
340 NewMenuController::~NewMenuController()
341 {
342 }
343 
344 // private function
345 void NewMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu )
346 {
347     VCLXPopupMenu* pPopupMenu    = (VCLXPopupMenu *)VCLXMenu::GetImplementation( rPopupMenu );
348     PopupMenu*     pVCLPopupMenu = 0;
349 
350     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
351 
352     resetPopupMenu( rPopupMenu );
353     if ( pPopupMenu )
354         pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu();
355 
356     if ( pVCLPopupMenu )
357     {
358         MenuConfiguration aMenuCfg( m_xServiceManager );
359         BmkMenu* pSubMenu( 0 );
360 
361         if ( m_bNewMenu )
362             pSubMenu = (BmkMenu*)aMenuCfg.CreateBookmarkMenu( m_xFrame, BOOKMARK_NEWMENU );
363         else
364             pSubMenu = (BmkMenu*)aMenuCfg.CreateBookmarkMenu( m_xFrame, BOOKMARK_WIZARDMENU );
365 
366         // copy entries as we have to use the provided popup menu
367         *pVCLPopupMenu = *pSubMenu;
368 
369         Image           aImage;
370         AddInfo         aAddInfo;
371 
372         // retrieve additional parameters from bookmark menu and
373         // store it in a hash_map.
374         for ( sal_uInt16 i = 0; i < pSubMenu->GetItemCount(); i++ )
375         {
376 		    sal_uInt16 nItemId = pSubMenu->GetItemId( sal::static_int_cast<sal_uInt16>( i ) );
377             if (( nItemId != 0 ) &&
378                 ( pSubMenu->GetItemType( nItemId ) != MENUITEM_SEPARATOR ))
379             {
380 				MenuConfiguration::Attributes* pBmkAttributes = (MenuConfiguration::Attributes *)(pSubMenu->GetUserValue( nItemId ));
381                 if ( pBmkAttributes != 0 )
382                 {
383                     aAddInfo.aTargetFrame = pBmkAttributes->aTargetFrame;
384                     aAddInfo.aImageId     = pBmkAttributes->aImageId;
385 
386                     m_aAddInfoForItem.insert( AddInfoForId::value_type( nItemId, aAddInfo ));
387                 }
388             }
389         }
390 
391         if ( m_bShowImages )
392             setMenuImages( pVCLPopupMenu, m_bShowImages, m_bHiContrast );
393 
394         delete pSubMenu;
395     }
396 }
397 
398 // XEventListener
399 void SAL_CALL NewMenuController::disposing( const EventObject& ) throw ( RuntimeException )
400 {
401     Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY );
402 
403     osl::MutexGuard aLock( m_aMutex );
404     m_xFrame.clear();
405     m_xDispatch.clear();
406     m_xServiceManager.clear();
407 
408     if ( m_xPopupMenu.is() )
409         m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(( OWeakObject *)this, UNO_QUERY ));
410     m_xPopupMenu.clear();
411 }
412 
413 // XStatusListener
414 void SAL_CALL NewMenuController::statusChanged( const FeatureStateEvent& ) throw ( RuntimeException )
415 {
416 }
417 
418 // XMenuListener
419 void SAL_CALL NewMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException)
420 {
421     Reference< css::awt::XPopupMenu > xPopupMenu;
422     Reference< XDispatch >            xDispatch;
423     Reference< XDispatchProvider >    xDispatchProvider;
424     Reference< XMultiServiceFactory > xServiceManager;
425     Reference< XURLTransformer >      xURLTransformer;
426 
427     osl::ClearableMutexGuard aLock( m_aMutex );
428     xPopupMenu          = m_xPopupMenu;
429     xDispatchProvider   = Reference< XDispatchProvider >( m_xFrame, UNO_QUERY );
430     xServiceManager     = m_xServiceManager;
431     xURLTransformer     = m_xURLTransformer;
432     aLock.clear();
433 
434     css::util::URL aTargetURL;
435     Sequence< PropertyValue > aArgsList( 1 );
436 
437     if ( xPopupMenu.is() && xDispatchProvider.is() )
438     {
439         VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu );
440         if ( pPopupMenu )
441         {
442             {
443                 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
444                 PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu();
445                 aTargetURL.Complete = pVCLPopupMenu->GetItemCommand( rEvent.MenuId );
446             }
447 
448             xURLTransformer->parseStrict( aTargetURL );
449 
450             aArgsList[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Referer" ));
451 	        aArgsList[0].Value = makeAny( ::rtl::OUString::createFromAscii( SFX_REFERER_USER ));
452 
453             rtl::OUString aTargetFrame( m_aTargetFrame );
454             AddInfoForId::const_iterator pItem = m_aAddInfoForItem.find( rEvent.MenuId );
455             if ( pItem != m_aAddInfoForItem.end() )
456                 aTargetFrame = pItem->second.aTargetFrame;
457 
458             xDispatch = xDispatchProvider->queryDispatch( aTargetURL, aTargetFrame, 0 );
459         }
460     }
461 
462     if ( xDispatch.is() )
463     {
464         // Call dispatch asychronously as we can be destroyed while dispatch is
465         // executed. VCL is not able to survive this as it wants to call listeners
466         // after select!!!
467         NewDocument* pNewDocument = new NewDocument;
468         pNewDocument->xDispatch  = xDispatch;
469         pNewDocument->aTargetURL = aTargetURL;
470         pNewDocument->aArgSeq    = aArgsList;
471         if(::comphelper::UiEventsLogger::isEnabled()) //#i88653#
472             UiEventLogHelper(::rtl::OUString::createFromAscii("NewMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgsList);
473         Application::PostUserEvent( STATIC_LINK(0, NewMenuController, ExecuteHdl_Impl), pNewDocument );
474     }
475 }
476 
477 void SAL_CALL NewMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException)
478 {
479     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
480     if ( m_xFrame.is() && m_xPopupMenu.is() )
481     {
482         VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( m_xPopupMenu );
483         if ( pPopupMenu )
484         {
485             const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
486             sal_Bool bShowImages( rSettings.GetUseImagesInMenus() );
487             sal_Bool bHiContrast( rSettings.GetHighContrastMode() );
488 
489             PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu();
490 
491             if (( m_bShowImages != bShowImages ) ||
492                 ( m_bHiContrast != bHiContrast ))
493             {
494                 m_bShowImages = bShowImages;
495                 m_bHiContrast = bHiContrast;
496 
497                 setMenuImages( pVCLPopupMenu, m_bShowImages, m_bHiContrast );
498             }
499 
500             setAccelerators( pVCLPopupMenu );
501         }
502     }
503 }
504 
505 // XPopupMenuController
506 void NewMenuController::impl_setPopupMenu()
507 {
508 
509     if ( m_xPopupMenu.is() )
510         fillPopupMenu( m_xPopupMenu );
511 
512     // Identify module that we are attach to. It's our context that we need to know.
513     Reference< XModuleManager > xModuleManager( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ),UNO_QUERY );
514     if ( xModuleManager.is() )
515     {
516         try
517         {
518             m_aModuleIdentifier = xModuleManager->identify( m_xFrame );
519             m_bModuleIdentified = sal_True;
520 
521             Reference< XNameAccess > xNameAccess( xModuleManager, UNO_QUERY );
522             if (( m_aModuleIdentifier.getLength() > 0 ) && xNameAccess.is() )
523             {
524                 Sequence< PropertyValue > aSeq;
525 
526                 if ( xNameAccess->getByName( m_aModuleIdentifier ) >>= aSeq )
527                 {
528                     for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ )
529                     {
530                         if ( aSeq[y].Name.equalsAscii("ooSetupFactoryEmptyDocumentURL") )
531                         {
532                             aSeq[y].Value >>= m_aEmptyDocURL;
533                             break;
534                         }
535                     }
536                 }
537             }
538         }
539         catch ( RuntimeException& e )
540         {
541             throw e;
542         }
543         catch ( Exception& )
544         {
545         }
546     }
547 }
548 
549 // XInitialization
550 void SAL_CALL NewMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
551 {
552     osl::MutexGuard aLock( m_aMutex );
553 
554     sal_Bool bInitalized( m_bInitialized );
555     if ( !bInitalized )
556     {
557 		svt::PopupMenuControllerBase::initialize( aArguments );
558 
559         if ( m_bInitialized )
560         {
561             const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
562 
563             m_bShowImages   = rSettings.GetUseImagesInMenus();
564             m_bHiContrast   = rSettings.GetHighContrastMode();
565 
566             m_bNewMenu      = m_aCommandURL.equalsAscii( ".uno:AddDirect" );
567         }
568     }
569 }
570 
571 IMPL_STATIC_LINK_NOINSTANCE( NewMenuController, ExecuteHdl_Impl, NewDocument*, pNewDocument )
572 {
573 /*  i62706: Don't catch all exceptions. We hide all problems here and are not able
574             to handle them on higher levels.
575     try
576     {
577 */
578         // Asynchronous execution as this can lead to our own destruction!
579         // Framework can recycle our current frame and the layout manager disposes all user interface
580         // elements if a component gets detached from its frame!
581         pNewDocument->xDispatch->dispatch( pNewDocument->aTargetURL, pNewDocument->aArgSeq );
582 /*
583     }
584     catch (const ::com::sun::star::document::CorruptedFilterConfigurationException& exFilters)
585     {
586         throw exFilters;
587     }
588     catch (const Exception& )
589     {
590     }
591 */
592     delete pNewDocument;
593     return 0;
594 }
595 
596 }
597