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_sfx2.hxx" 30 31 #ifdef SOLARIS 32 // HACK: prevent conflict between STLPORT and Workshop headers on Solaris 8 33 #include <ctime> 34 #endif 35 36 #include <string> // prevent conflict with STL includes 37 #include <com/sun/star/uno/Reference.h> 38 #include <com/sun/star/frame/XFrame.hpp> 39 #include <com/sun/star/awt/XWindow.hpp> 40 #include <com/sun/star/util/URL.hpp> 41 #include <com/sun/star/util/XURLTransformer.hpp> 42 #include <com/sun/star/frame/XController.hpp> 43 #include <com/sun/star/lang/XUnoTunnel.hpp> 44 #include <com/sun/star/document/MacroExecMode.hpp> 45 #include <com/sun/star/document/UpdateDocMode.hpp> 46 #include <com/sun/star/frame/XComponentLoader.hpp> 47 #include <com/sun/star/beans/PropertyValue.hpp> 48 #include <com/sun/star/beans/XPropertySet.hpp> 49 #include <com/sun/star/frame/XLayoutManager.hpp> 50 #include <com/sun/star/frame/status/ItemStatus.hpp> 51 #include <com/sun/star/frame/status/ItemState.hpp> 52 #include <com/sun/star/ui/XUIElementFactory.hpp> 53 #include <com/sun/star/frame/XModuleManager.hpp> 54 #include <com/sun/star/container/XNameAccess.hpp> 55 #include <com/sun/star/ui/XUIFunctionListener.hpp> 56 #include <com/sun/star/frame/status/Visibility.hpp> 57 #include <com/sun/star/document/CorruptedFilterConfigurationException.hpp> 58 #include <svl/eitem.hxx> 59 #include <svl/stritem.hxx> 60 #include <svl/intitem.hxx> 61 #include <svl/imageitm.hxx> 62 #include <svl/visitem.hxx> 63 #include <svl/urlbmk.hxx> 64 #include <vcl/toolbox.hxx> 65 #include <unotools/moduleoptions.hxx> 66 67 #include <svtools/imagemgr.hxx> 68 #include <comphelper/processfactory.hxx> 69 #include <framework/addonmenu.hxx> 70 #include <framework/addonsoptions.hxx> 71 #include <framework/menuconfiguration.hxx> 72 #include <framework/sfxhelperfunctions.hxx> 73 #include <vcl/taskpanelist.hxx> 74 #ifndef _TOOLKIT_UNOHLP_HXX 75 #include <toolkit/helper/vclunohelper.hxx> 76 #endif 77 #include <svtools/menuoptions.hxx> 78 #include <svtools/miscopt.hxx> 79 80 #ifndef GCC 81 #endif 82 83 #include <sfx2/tbxctrl.hxx> 84 #include <sfx2/mnumgr.hxx> 85 #include <sfx2/dispatch.hxx> 86 #include "fltfnc.hxx" 87 #include <sfx2/msg.hxx> 88 #include <sfx2/msgpool.hxx> 89 #include "statcach.hxx" 90 #include <sfx2/viewfrm.hxx> 91 #include "arrdecl.hxx" 92 #include "sfxtypes.hxx" 93 #include <sfx2/genlink.hxx> 94 #include "sfx2/sfxresid.hxx" 95 #include <sfx2/sfx.hrc> 96 #include <sfx2/module.hxx> 97 #include <sfx2/docfile.hxx> 98 #include <sfx2/docfac.hxx> 99 #include "referers.hxx" 100 #include <sfx2/frmhtmlw.hxx> 101 #include <sfx2/app.hxx> 102 #include <sfx2/unoctitm.hxx> 103 #include "helpid.hrc" 104 #include "workwin.hxx" 105 #include "sfx2/imgmgr.hxx" 106 #include "virtmenu.hxx" 107 #include <sfx2/viewfrm.hxx> 108 #include <sfx2/module.hxx> 109 #include "sfx2/imagemgr.hxx" 110 111 #include <comphelper/uieventslogger.hxx> 112 #include <com/sun/star/frame/XModuleManager.hpp> 113 114 //using namespace ::com::sun::star::awt; 115 using namespace ::com::sun::star::beans; 116 using namespace ::com::sun::star::frame; 117 using namespace ::com::sun::star::frame::status; 118 using namespace ::com::sun::star::lang; 119 using namespace ::com::sun::star::uno; 120 using namespace ::com::sun::star::util; 121 using namespace ::com::sun::star::container; 122 using namespace ::com::sun::star::frame; 123 using namespace ::com::sun::star::ui; 124 125 //==================================================================== 126 127 SFX_IMPL_TOOLBOX_CONTROL_ARG(SfxToolBoxControl, SfxStringItem, sal_True); 128 SFX_IMPL_TOOLBOX_CONTROL(SfxAppToolBoxControl_Impl, SfxStringItem); 129 130 static Window* GetTopMostParentSystemWindow( Window* pWindow ) 131 { 132 OSL_ASSERT( pWindow ); 133 if ( pWindow ) 134 { 135 // ->manually search topmost system window 136 // required because their might be another system window between this and the top window 137 pWindow = pWindow->GetParent(); 138 SystemWindow* pTopMostSysWin = NULL; 139 while ( pWindow ) 140 { 141 if ( pWindow->IsSystemWindow() ) 142 pTopMostSysWin = (SystemWindow*)pWindow; 143 pWindow = pWindow->GetParent(); 144 } 145 pWindow = pTopMostSysWin; 146 OSL_ASSERT( pWindow ); 147 return pWindow; 148 } 149 150 return NULL; 151 } 152 153 svt::ToolboxController* SAL_CALL SfxToolBoxControllerFactory( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const ::rtl::OUString& aCommandURL ) 154 { 155 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 156 157 URL aTargetURL; 158 aTargetURL.Complete = aCommandURL; 159 Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY ); 160 xTrans->parseStrict( aTargetURL ); 161 if ( aTargetURL.Arguments.getLength() ) 162 return NULL; 163 164 SfxObjectShell* pObjShell = NULL; 165 Reference < XController > xController; 166 Reference < XModel > xModel; 167 if ( rFrame.is() ) 168 { 169 xController = rFrame->getController(); 170 if ( xController.is() ) 171 xModel = xController->getModel(); 172 } 173 174 if ( xModel.is() ) 175 { 176 // Get tunnel from model to retrieve the SfxObjectShell pointer from it 177 ::com::sun::star::uno::Reference < ::com::sun::star::lang::XUnoTunnel > xObj( xModel, UNO_QUERY ); 178 if ( xObj.is() ) 179 { 180 ::com::sun::star::uno::Sequence < sal_Int8 > aSeq = SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence(); 181 sal_Int64 nHandle = xObj->getSomething( aSeq ); 182 if ( nHandle ) 183 pObjShell = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle )); 184 } 185 } 186 187 SfxModule* pModule = pObjShell ? pObjShell->GetModule() : NULL; 188 SfxSlotPool* pSlotPool = 0; 189 190 if ( pModule ) 191 pSlotPool = pModule->GetSlotPool(); 192 else 193 pSlotPool = &(SfxSlotPool::GetSlotPool( NULL )); 194 195 const SfxSlot* pSlot = pSlotPool->GetUnoSlot( aTargetURL.Path ); 196 if ( pSlot ) 197 { 198 sal_uInt16 nSlotId = pSlot->GetSlotId(); 199 if ( nSlotId > 0 ) 200 return SfxToolBoxControl::CreateControl( nSlotId, nID, pToolbox, pModule ); 201 } 202 203 return NULL; 204 } 205 206 struct SfxToolBoxControl_Impl 207 { 208 ToolBox* pBox; 209 sal_Bool bShowString; 210 sal_uInt16 nSelectModifier; 211 SfxTbxCtrlFactory* pFact; 212 sal_uInt16 nTbxId; 213 sal_uInt16 nSlotId; 214 SfxPopupWindow* mpFloatingWindow; 215 SfxPopupWindow* mpPopupWindow; 216 Reference< XUIElement > mxUIElement; 217 218 DECL_LINK( WindowEventListener, VclSimpleEvent* ); 219 }; 220 221 IMPL_LINK( SfxToolBoxControl_Impl, WindowEventListener, VclSimpleEvent*, pEvent ) 222 { 223 if ( pEvent && 224 pEvent->ISA( VclWindowEvent ) && 225 (( pEvent->GetId() == VCLEVENT_WINDOW_MOVE ) || 226 ( pEvent->GetId() == VCLEVENT_WINDOW_ACTIVATE ))) 227 { 228 Window* pWindow( ((VclWindowEvent*)pEvent)->GetWindow() ); 229 if (( pWindow == mpFloatingWindow ) && 230 ( mpPopupWindow != 0 )) 231 { 232 delete mpPopupWindow; 233 mpPopupWindow = 0; 234 } 235 } 236 237 return 1; 238 } 239 240 //-------------------------------------------------------------------- 241 242 SfxToolBoxControl::SfxToolBoxControl( 243 sal_uInt16 nSlotID, 244 sal_uInt16 nID, 245 ToolBox& rBox, 246 sal_Bool bShowStringItems ) 247 : svt::ToolboxController() 248 { 249 pImpl = new SfxToolBoxControl_Impl; 250 251 pImpl->pBox = &rBox; 252 pImpl->bShowString = bShowStringItems; 253 pImpl->nSelectModifier = 0; 254 pImpl->pFact = 0; 255 pImpl->nTbxId = nID; 256 pImpl->nSlotId = nSlotID; 257 pImpl->mpFloatingWindow = 0; 258 pImpl->mpPopupWindow = 0; 259 } 260 261 //-------------------------------------------------------------------- 262 263 SfxToolBoxControl::~SfxToolBoxControl() 264 { 265 if ( pImpl->mxUIElement.is() ) 266 { 267 Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY ); 268 xComponent->dispose(); 269 } 270 pImpl->mxUIElement = 0; 271 delete pImpl; 272 } 273 274 //-------------------------------------------------------------------- 275 276 ToolBox& SfxToolBoxControl::GetToolBox() const 277 { 278 return *pImpl->pBox; 279 } 280 unsigned short SfxToolBoxControl::GetId() const 281 { 282 return pImpl->nTbxId; 283 } 284 unsigned short SfxToolBoxControl::GetSlotId() const 285 { 286 return pImpl->nSlotId; 287 } 288 289 //-------------------------------------------------------------------- 290 291 void SAL_CALL SfxToolBoxControl::dispose() throw (::com::sun::star::uno::RuntimeException) 292 { 293 if ( m_bDisposed ) 294 return; 295 296 svt::ToolboxController::dispose(); 297 298 // Remove and destroy our item window at our toolbox 299 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 300 Window* pWindow = pImpl->pBox->GetItemWindow( pImpl->nTbxId ); 301 pImpl->pBox->SetItemWindow( pImpl->nTbxId, 0 ); 302 delete pWindow; 303 304 // Dispose an open sub toolbar. It's possible that we have an open 305 // sub toolbar while we get disposed. Therefore we have to dispose 306 // it now! Not doing so would result in a crash. The sub toolbar 307 // gets destroyed asynchronously and would access a non-existing 308 // parent toolbar! See #126569# 309 if ( pImpl->mxUIElement.is() ) 310 { 311 Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY ); 312 xComponent->dispose(); 313 } 314 pImpl->mxUIElement = 0; 315 316 // Delete my popup windows 317 delete pImpl->mpFloatingWindow; 318 delete pImpl->mpPopupWindow; 319 320 pImpl->mpFloatingWindow = 0; 321 pImpl->mpPopupWindow = 0; 322 } 323 324 //-------------------------------------------------------------------- 325 void SfxToolBoxControl::RegisterToolBoxControl( SfxModule* pMod, SfxTbxCtrlFactory* pFact) 326 { 327 SFX_APP()->RegisterToolBoxControl_Impl( pMod, pFact ); 328 } 329 330 SfxToolBoxControl* SfxToolBoxControl::CreateControl( sal_uInt16 nSlotId, sal_uInt16 nTbxId, ToolBox *pBox, SfxModule* pMod ) 331 { 332 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 333 334 SfxToolBoxControl *pCtrl; 335 SfxApplication *pApp = SFX_APP(); 336 337 SfxSlotPool *pSlotPool; 338 if ( pMod ) 339 pSlotPool = pMod->GetSlotPool(); 340 else 341 pSlotPool = &SfxSlotPool::GetSlotPool(); 342 TypeId aSlotType = pSlotPool->GetSlotType( nSlotId ); 343 if ( aSlotType ) 344 { 345 if ( pMod ) 346 { 347 SfxTbxCtrlFactArr_Impl *pFactories = pMod->GetTbxCtrlFactories_Impl(); 348 if ( pFactories ) 349 { 350 SfxTbxCtrlFactArr_Impl &rFactories = *pFactories; 351 sal_uInt16 nFactory; 352 const sal_uInt16 nCount = rFactories.Count(); 353 354 // search for a factory with the given slot id 355 for( nFactory = 0; nFactory < nCount; ++nFactory ) 356 if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == nSlotId) ) 357 break; 358 359 if( nFactory == nCount ) 360 { 361 // if no factory exists for the given slot id, see if we 362 // have a generic factory with the correct slot type and slot id == 0 363 for ( nFactory = 0; nFactory < nCount; ++nFactory ) 364 if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == 0) ) 365 break; 366 } 367 368 if( nFactory < nCount ) 369 { 370 pCtrl = rFactories[nFactory]->pCtor( nSlotId, nTbxId, *pBox ); 371 pCtrl->pImpl->pFact = rFactories[nFactory]; 372 return pCtrl; 373 } 374 } 375 } 376 377 SfxTbxCtrlFactArr_Impl &rFactories = pApp->GetTbxCtrlFactories_Impl(); 378 sal_uInt16 nFactory; 379 const sal_uInt16 nCount = rFactories.Count(); 380 381 for( nFactory = 0; nFactory < nCount; ++nFactory ) 382 if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == nSlotId) ) 383 break; 384 385 if( nFactory == nCount ) 386 { 387 // if no factory exists for the given slot id, see if we 388 // have a generic factory with the correct slot type and slot id == 0 389 for( nFactory = 0; nFactory < nCount; ++nFactory ) 390 if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == 0) ) 391 break; 392 } 393 394 if( nFactory < nCount ) 395 { 396 pCtrl = rFactories[nFactory]->pCtor( nSlotId, nTbxId, *pBox ); 397 pCtrl->pImpl->pFact = rFactories[nFactory]; 398 return pCtrl; 399 } 400 } 401 402 return NULL; 403 } 404 405 SfxItemState SfxToolBoxControl::GetItemState( 406 const SfxPoolItem* pState ) 407 /* [Beschreibung] 408 409 Statische Methode zum Ermitteln des Status des SfxPoolItem-Pointers, 410 in der Methode <SfxControllerItem::StateChanged(const SfxPoolItem*)> 411 zu verwenden. 412 413 [R"uckgabewert] 414 415 SfxItemState SFX_ITEM_UNKNOWN 416 Enabled, aber keine weitere Statusinformation 417 verf"ugbar. Typisch f"ur <Slot>s, die allenfalls 418 zeitweise disabled sind, aber ihre Darstellung sonst 419 nicht "andern. 420 421 SFX_ITEM_DISABLED 422 Disabled und keine weiter Statusinformation 423 verf"ugbar. Alle anderen ggf. angezeigten Werte sollten 424 auf den Default zur"uckgesetzt werden. 425 426 SFX_ITEM_DONTCARE 427 Enabled aber es waren nur uneindeutige Werte 428 verf"ugbar (also keine, die abgefragt werden k"onnen). 429 430 SFX_ITEM_AVAILABLE 431 Enabled und mit verf"ugbarem Wert, der von 'pState' 432 erfragbar ist. Der Typ ist dabei im gesamten 433 Programm eindeutig und durch den Slot festgelegt. 434 */ 435 436 { 437 return !pState 438 ? SFX_ITEM_DISABLED 439 : IsInvalidItem(pState) 440 ? SFX_ITEM_DONTCARE 441 : pState->ISA(SfxVoidItem) && !pState->Which() 442 ? SFX_ITEM_UNKNOWN 443 : SFX_ITEM_AVAILABLE; 444 } 445 446 void SfxToolBoxControl::Dispatch( 447 const Reference< XDispatchProvider >& rProvider, 448 const rtl::OUString& rCommand, 449 Sequence< ::PropertyValue >& aArgs ) 450 { 451 if ( rProvider.is() ) 452 { 453 ::com::sun::star::util::URL aTargetURL; 454 aTargetURL.Complete = rCommand; 455 Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( 456 rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), 457 UNO_QUERY ); 458 xTrans->parseStrict( aTargetURL ); 459 460 Reference < XDispatch > xDispatch = rProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); 461 if ( xDispatch.is() ) 462 xDispatch->dispatch( aTargetURL, aArgs ); 463 } 464 } 465 466 void SfxToolBoxControl::Dispatch( const ::rtl::OUString& aCommand, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs ) 467 { 468 Reference < XController > xController; 469 470 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 471 if ( getFrameInterface().is() ) 472 xController = getFrameInterface()->getController(); 473 474 Reference < XDispatchProvider > xProvider( xController, UNO_QUERY ); 475 if ( xProvider.is() ) 476 { 477 ::com::sun::star::util::URL aTargetURL; 478 aTargetURL.Complete = aCommand; 479 getURLTransformer()->parseStrict( aTargetURL ); 480 481 Reference < XDispatch > xDispatch = xProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); 482 if ( xDispatch.is() ) 483 { 484 if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# 485 { 486 ::rtl::OUString sAppName; 487 try 488 { 489 static ::rtl::OUString our_aModuleManagerName = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager"); 490 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager = 491 ::comphelper::getProcessServiceFactory(); 492 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleManager( 493 xServiceManager->createInstance(our_aModuleManagerName) 494 , ::com::sun::star::uno::UNO_QUERY_THROW); 495 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame( 496 getFrameInterface(), UNO_QUERY_THROW); 497 sAppName = xModuleManager->identify(xFrame); 498 } catch(::com::sun::star::uno::Exception&) {} 499 Sequence<PropertyValue> source; 500 ::comphelper::UiEventsLogger::appendDispatchOrigin(source, sAppName, ::rtl::OUString::createFromAscii("SfxToolBoxControl")); 501 ::comphelper::UiEventsLogger::logDispatch(aTargetURL, source); 502 } 503 xDispatch->dispatch( aTargetURL, aArgs ); 504 } 505 } 506 } 507 508 // XInterface 509 Any SAL_CALL SfxToolBoxControl::queryInterface( const Type & rType ) 510 throw(::com::sun::star::uno::RuntimeException) 511 { 512 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 513 SAL_STATIC_CAST( ::com::sun::star::awt::XDockableWindowListener*, this ), 514 SAL_STATIC_CAST( ::com::sun::star::frame::XSubToolbarController*, this )); 515 return (aRet.hasValue() ? aRet : svt::ToolboxController::queryInterface( rType )); 516 } 517 518 void SAL_CALL SfxToolBoxControl::acquire() throw() 519 { 520 OWeakObject::acquire(); 521 } 522 523 void SAL_CALL SfxToolBoxControl::release() throw() 524 { 525 OWeakObject::release(); 526 } 527 528 void SAL_CALL SfxToolBoxControl::disposing( const ::com::sun::star::lang::EventObject& aEvent ) 529 throw( ::com::sun::star::uno::RuntimeException ) 530 { 531 svt::ToolboxController::disposing( aEvent ); 532 } 533 534 // XStatusListener 535 void SAL_CALL SfxToolBoxControl::statusChanged( const FeatureStateEvent& rEvent ) 536 throw ( ::com::sun::star::uno::RuntimeException ) 537 { 538 SfxViewFrame* pViewFrame = NULL; 539 Reference < XController > xController; 540 541 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 542 if ( getFrameInterface().is() ) 543 xController = getFrameInterface()->getController(); 544 545 Reference < XDispatchProvider > xProvider( xController, UNO_QUERY ); 546 if ( xProvider.is() ) 547 { 548 Reference < XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, ::rtl::OUString(), 0 ); 549 if ( xDisp.is() ) 550 { 551 Reference< XUnoTunnel > xTunnel( xDisp, UNO_QUERY ); 552 SfxOfficeDispatch* pDisp = NULL; 553 if ( xTunnel.is() ) 554 { 555 sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier()); 556 pDisp = reinterpret_cast< SfxOfficeDispatch* >( sal::static_int_cast< sal_IntPtr >( nImplementation )); 557 } 558 559 if ( pDisp ) 560 pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame(); 561 } 562 } 563 564 sal_uInt16 nSlotId = 0; 565 SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( pViewFrame ); 566 const SfxSlot* pSlot = rPool.GetUnoSlot( rEvent.FeatureURL.Path ); 567 if ( pSlot ) 568 nSlotId = pSlot->GetSlotId(); 569 else if ( m_aCommandURL == rEvent.FeatureURL.Path ) 570 nSlotId = GetSlotId(); 571 572 if ( nSlotId > 0 ) 573 { 574 if ( rEvent.Requery ) 575 svt::ToolboxController::statusChanged( rEvent ); 576 else 577 { 578 SfxItemState eState = SFX_ITEM_DISABLED; 579 SfxPoolItem* pItem = NULL; 580 if ( rEvent.IsEnabled ) 581 { 582 eState = SFX_ITEM_AVAILABLE; 583 ::com::sun::star::uno::Type pType = rEvent.State.getValueType(); 584 585 if ( pType == ::getVoidCppuType() ) 586 { 587 pItem = new SfxVoidItem( nSlotId ); 588 eState = SFX_ITEM_UNKNOWN; 589 } 590 else if ( pType == ::getBooleanCppuType() ) 591 { 592 sal_Bool bTemp = false; 593 rEvent.State >>= bTemp ; 594 pItem = new SfxBoolItem( nSlotId, bTemp ); 595 } 596 else if ( pType == ::getCppuType((const sal_uInt16*)0) ) 597 { 598 sal_uInt16 nTemp = 0; 599 rEvent.State >>= nTemp ; 600 pItem = new SfxUInt16Item( nSlotId, nTemp ); 601 } 602 else if ( pType == ::getCppuType((const sal_uInt32*)0) ) 603 { 604 sal_uInt32 nTemp = 0; 605 rEvent.State >>= nTemp ; 606 pItem = new SfxUInt32Item( nSlotId, nTemp ); 607 } 608 else if ( pType == ::getCppuType((const ::rtl::OUString*)0) ) 609 { 610 ::rtl::OUString sTemp ; 611 rEvent.State >>= sTemp ; 612 pItem = new SfxStringItem( nSlotId, sTemp ); 613 } 614 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::ItemStatus*)0) ) 615 { 616 ItemStatus aItemStatus; 617 rEvent.State >>= aItemStatus; 618 eState = aItemStatus.State; 619 pItem = new SfxVoidItem( nSlotId ); 620 } 621 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::Visibility*)0) ) 622 { 623 Visibility aVisibilityStatus; 624 rEvent.State >>= aVisibilityStatus; 625 pItem = new SfxVisibilityItem( nSlotId, aVisibilityStatus.bVisible ); 626 } 627 else 628 { 629 if ( pSlot ) 630 pItem = pSlot->GetType()->CreateItem(); 631 if ( pItem ) 632 { 633 pItem->SetWhich( nSlotId ); 634 pItem->PutValue( rEvent.State ); 635 } 636 else 637 pItem = new SfxVoidItem( nSlotId ); 638 } 639 } 640 641 StateChanged( nSlotId, eState, pItem ); 642 delete pItem; 643 } 644 } 645 } 646 647 // XSubToolbarController 648 ::sal_Bool SAL_CALL SfxToolBoxControl::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException) 649 { 650 return sal_False; 651 } 652 653 ::rtl::OUString SAL_CALL SfxToolBoxControl::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException) 654 { 655 return rtl::OUString(); 656 } 657 658 void SAL_CALL SfxToolBoxControl::functionSelected( const ::rtl::OUString& /*aCommand*/ ) throw (::com::sun::star::uno::RuntimeException) 659 { 660 // must be implemented by sub-class 661 } 662 663 void SAL_CALL SfxToolBoxControl::updateImage() throw (::com::sun::star::uno::RuntimeException) 664 { 665 // must be implemented by sub-class 666 } 667 668 // XToolbarController 669 void SAL_CALL SfxToolBoxControl::execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException) 670 { 671 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 672 Select( (sal_uInt16)KeyModifier ); 673 } 674 void SAL_CALL SfxToolBoxControl::click() throw (::com::sun::star::uno::RuntimeException) 675 { 676 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 677 Click(); 678 } 679 680 void SAL_CALL SfxToolBoxControl::doubleClick() throw (::com::sun::star::uno::RuntimeException) 681 { 682 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 683 DoubleClick(); 684 } 685 686 Reference< ::com::sun::star::awt::XWindow > SAL_CALL SfxToolBoxControl::createPopupWindow() throw (::com::sun::star::uno::RuntimeException) 687 { 688 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 689 Window* pWindow = CreatePopupWindow(); 690 if ( pWindow ) 691 return VCLUnoHelper::GetInterface( pWindow ); 692 else 693 return Reference< ::com::sun::star::awt::XWindow >(); 694 } 695 696 Reference< ::com::sun::star::awt::XWindow > SAL_CALL SfxToolBoxControl::createItemWindow( const Reference< ::com::sun::star::awt::XWindow >& rParent ) throw (::com::sun::star::uno::RuntimeException) 697 { 698 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 699 return VCLUnoHelper::GetInterface( CreateItemWindow( VCLUnoHelper::GetWindow( rParent ))); 700 } 701 702 // XDockableWindowListener 703 void SAL_CALL SfxToolBoxControl::startDocking( const ::com::sun::star::awt::DockingEvent& ) 704 throw (::com::sun::star::uno::RuntimeException) 705 { 706 } 707 ::com::sun::star::awt::DockingData SAL_CALL SfxToolBoxControl::docking( const ::com::sun::star::awt::DockingEvent& ) 708 throw (::com::sun::star::uno::RuntimeException) 709 { 710 return ::com::sun::star::awt::DockingData(); 711 } 712 713 void SAL_CALL SfxToolBoxControl::endDocking( const ::com::sun::star::awt::EndDockingEvent& ) 714 throw (::com::sun::star::uno::RuntimeException) 715 { 716 } 717 718 sal_Bool SAL_CALL SfxToolBoxControl::prepareToggleFloatingMode( const ::com::sun::star::lang::EventObject& ) 719 throw (::com::sun::star::uno::RuntimeException) 720 { 721 return sal_False; 722 } 723 724 void SAL_CALL SfxToolBoxControl::toggleFloatingMode( const ::com::sun::star::lang::EventObject& ) 725 throw (::com::sun::star::uno::RuntimeException) 726 { 727 } 728 729 void SAL_CALL SfxToolBoxControl::closed( const ::com::sun::star::lang::EventObject& ) 730 throw (::com::sun::star::uno::RuntimeException) 731 { 732 } 733 734 void SAL_CALL SfxToolBoxControl::endPopupMode( const ::com::sun::star::awt::EndPopupModeEvent& aEvent ) 735 throw (::com::sun::star::uno::RuntimeException) 736 { 737 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 738 739 ::rtl::OUString aSubToolBarResName; 740 if ( pImpl->mxUIElement.is() ) 741 { 742 Reference< XPropertySet > xPropSet( pImpl->mxUIElement, UNO_QUERY ); 743 if ( xPropSet.is() ) 744 { 745 try 746 { 747 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" ))) >>= aSubToolBarResName; 748 } 749 catch ( com::sun::star::beans::UnknownPropertyException& ) 750 { 751 } 752 catch ( com::sun::star::lang::WrappedTargetException& ) 753 { 754 } 755 } 756 757 Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY ); 758 xComponent->dispose(); 759 } 760 pImpl->mxUIElement = 0; 761 762 // if the toolbar was teared-off recreate it and place it at the given position 763 if( aEvent.bTearoff ) 764 { 765 Reference< XUIElement > xUIElement; 766 Reference< XLayoutManager > xLayoutManager = getLayoutManager(); 767 768 if ( !xLayoutManager.is() ) 769 return; 770 771 xLayoutManager->createElement( aSubToolBarResName ); 772 xUIElement = xLayoutManager->getElement( aSubToolBarResName ); 773 if ( xUIElement.is() ) 774 { 775 Reference< ::com::sun::star::awt::XWindow > xParent = getFrameInterface()->getContainerWindow(); 776 777 Reference< ::com::sun::star::awt::XWindow > xSubToolBar( xUIElement->getRealInterface(), UNO_QUERY ); 778 Reference< ::com::sun::star::beans::XPropertySet > xProp( xUIElement, UNO_QUERY ); 779 if ( xSubToolBar.is() && xProp.is() ) 780 { 781 rtl::OUString aPersistentString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" )); 782 try 783 { 784 Window* pTbxWindow = VCLUnoHelper::GetWindow( xSubToolBar ); 785 ToolBox* pToolBar( 0 ); 786 if ( pTbxWindow && pTbxWindow->GetType() == WINDOW_TOOLBOX ) 787 { 788 pToolBar = (ToolBox *)pTbxWindow; 789 790 Any a; 791 a = xProp->getPropertyValue( aPersistentString ); 792 xProp->setPropertyValue( aPersistentString, makeAny( sal_False )); 793 794 xLayoutManager->hideElement( aSubToolBarResName ); 795 xLayoutManager->floatWindow( aSubToolBarResName ); 796 797 xLayoutManager->setElementPos( aSubToolBarResName, aEvent.FloatingPosition ); 798 xLayoutManager->showElement( aSubToolBarResName ); 799 800 xProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" )), a ); 801 } 802 } 803 catch ( ::com::sun::star::uno::RuntimeException& ) 804 { 805 throw; 806 } 807 catch ( ::com::sun::star::uno::Exception& ) 808 { 809 } 810 } 811 } 812 } 813 } 814 815 ::Size SfxToolBoxControl::getPersistentFloatingSize( const Reference< XFrame >& /*xFrame*/, const ::rtl::OUString& /*rSubToolBarResName*/ ) 816 { 817 ::Size aToolboxSize; 818 return aToolboxSize; 819 } 820 821 void SfxToolBoxControl::createAndPositionSubToolBar( const ::rtl::OUString& rSubToolBarResName ) 822 { 823 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 824 825 if ( pImpl->pBox ) 826 { 827 static WeakReference< XUIElementFactory > xWeakUIElementFactory; 828 829 sal_uInt16 nItemId = pImpl->pBox->GetDownItemId(); 830 831 if ( !nItemId ) 832 return; 833 834 // create element with factory 835 Reference< XMultiServiceFactory > xServiceManager = getServiceManager(); 836 Reference< XFrame > xFrame = getFrameInterface(); 837 Reference< XUIElement > xUIElement; 838 Reference< XUIElementFactory > xUIEementFactory; 839 840 xUIEementFactory = xWeakUIElementFactory; 841 if ( !xUIEementFactory.is() ) 842 { 843 xUIEementFactory = Reference< XUIElementFactory >( 844 xServiceManager->createInstance( 845 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 846 "com.sun.star.ui.UIElementFactoryManager" ))), 847 UNO_QUERY ); 848 xWeakUIElementFactory = xUIEementFactory; 849 } 850 851 Sequence< PropertyValue > aPropSeq( 3 ); 852 aPropSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); 853 aPropSeq[0].Value <<= xFrame; 854 aPropSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" )); 855 aPropSeq[1].Value <<= sal_False; 856 aPropSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PopupMode" )); 857 aPropSeq[2].Value <<= sal_True; 858 859 try 860 { 861 xUIElement = xUIEementFactory->createUIElement( rSubToolBarResName, aPropSeq ); 862 } 863 catch ( ::com::sun::star::container::NoSuchElementException& ) 864 { 865 } 866 catch ( IllegalArgumentException& ) 867 { 868 } 869 870 if ( xUIElement.is() ) 871 { 872 Reference< ::com::sun::star::awt::XWindow > xParent = getFrameInterface()->getContainerWindow(); 873 874 Reference< ::com::sun::star::awt::XWindow > xSubToolBar( xUIElement->getRealInterface(), UNO_QUERY ); 875 if ( xSubToolBar.is() ) 876 { 877 Reference< ::com::sun::star::awt::XDockableWindow > xDockWindow( xSubToolBar, UNO_QUERY ); 878 xDockWindow->addDockableWindowListener( Reference< ::com::sun::star::awt::XDockableWindowListener >( 879 static_cast< OWeakObject * >( this ), UNO_QUERY )); 880 xDockWindow->enableDocking( sal_True ); 881 882 // keep refererence to UIElement to avoid its destruction 883 if ( pImpl->mxUIElement.is() ) 884 { 885 Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY ); 886 xComponent->dispose(); 887 } 888 pImpl->mxUIElement = xUIElement; 889 890 Window* pParentTbxWindow( pImpl->pBox ); 891 Window* pTbxWindow = VCLUnoHelper::GetWindow( xSubToolBar ); 892 ToolBox* pToolBar( 0 ); 893 if ( pTbxWindow && pTbxWindow->GetType() == WINDOW_TOOLBOX ) 894 pToolBar = (ToolBox *)pTbxWindow; 895 896 if ( pToolBar ) 897 { 898 pToolBar->SetParent( pParentTbxWindow ); 899 ::Size aSize = getPersistentFloatingSize( xFrame, rSubToolBarResName ); 900 if ( aSize.Width() == 0 || aSize.Height() == 0 ) 901 { 902 // calc and set size for popup mode 903 aSize = pToolBar->CalcPopupWindowSizePixel(); 904 } 905 pToolBar->SetSizePixel( aSize ); 906 907 // open subtoolbox in popup mode 908 Window::GetDockingManager()->StartPopupMode( pImpl->pBox, pToolBar ); 909 } 910 } 911 } 912 } 913 } 914 915 //-------------------------------------------------------------------- 916 917 void SfxToolBoxControl::SetPopupWindow( SfxPopupWindow* pWindow ) 918 { 919 pImpl->mpPopupWindow = pWindow; 920 pImpl->mpPopupWindow->SetPopupModeEndHdl( LINK( this, SfxToolBoxControl, PopupModeEndHdl )); 921 pImpl->mpPopupWindow->SetDeleteLink_Impl( LINK( this, SfxToolBoxControl, ClosePopupWindow )); 922 } 923 924 //-------------------------------------------------------------------- 925 926 IMPL_LINK( SfxToolBoxControl, PopupModeEndHdl, void *, EMPTYARG ) 927 { 928 if ( pImpl->mpPopupWindow->IsVisible() ) 929 { 930 // Replace floating window with popup window and destroy 931 // floating window instance. 932 delete pImpl->mpFloatingWindow; 933 pImpl->mpFloatingWindow = pImpl->mpPopupWindow; 934 pImpl->mpPopupWindow = 0; 935 // We also need to know when the user tries to use the 936 // floating window. 937 pImpl->mpFloatingWindow->AddEventListener( LINK( pImpl, SfxToolBoxControl_Impl, WindowEventListener )); 938 } 939 else 940 { 941 // Popup window has been closed by the user. No replacement, instance 942 // will destroy itself. 943 pImpl->mpPopupWindow = 0; 944 } 945 946 return 1; 947 } 948 949 //-------------------------------------------------------------------- 950 IMPL_LINK( SfxToolBoxControl, ClosePopupWindow, SfxPopupWindow *, pWindow ) 951 { 952 if ( pWindow == pImpl->mpFloatingWindow ) 953 pImpl->mpFloatingWindow = 0; 954 else 955 pImpl->mpPopupWindow = 0; 956 957 return 1; 958 } 959 960 //-------------------------------------------------------------------- 961 962 void SfxToolBoxControl::StateChanged 963 ( 964 sal_uInt16 nId, 965 SfxItemState eState, 966 const SfxPoolItem* pState 967 ) 968 { 969 DBG_MEMTEST(); 970 DBG_ASSERT( pImpl->pBox != 0, "setting state to dangling ToolBox" ); 971 972 if ( GetId() >= SID_OBJECTMENU0 && GetId() <= SID_OBJECTMENU_LAST ) 973 return; 974 975 // enabled/disabled-Flag pauschal korrigieren 976 pImpl->pBox->EnableItem( GetId(), eState != SFX_ITEM_DISABLED ); 977 978 sal_uInt16 nItemBits = pImpl->pBox->GetItemBits( GetId() ); 979 nItemBits &= ~TIB_CHECKABLE; 980 TriState eTri = STATE_NOCHECK; 981 switch ( eState ) 982 { 983 case SFX_ITEM_AVAILABLE: 984 { 985 if ( pState->ISA(SfxBoolItem) ) 986 { 987 // BoolItem fuer checken 988 if ( ((const SfxBoolItem*)pState)->GetValue() ) 989 eTri = STATE_CHECK; 990 nItemBits |= TIB_CHECKABLE; 991 } 992 else if ( pState->ISA(SfxEnumItemInterface) && 993 ((SfxEnumItemInterface *)pState)->HasBoolValue()) 994 { 995 // EnumItem wie Bool behandeln 996 if ( ((const SfxEnumItemInterface *)pState)->GetBoolValue() ) 997 eTri = STATE_CHECK; 998 nItemBits |= TIB_CHECKABLE; 999 } 1000 else if ( pImpl->bShowString && pState->ISA(SfxStringItem) ) 1001 pImpl->pBox->SetItemText(nId, ((const SfxStringItem*)pState)->GetValue() ); 1002 break; 1003 } 1004 1005 case SFX_ITEM_DONTCARE: 1006 { 1007 eTri = STATE_DONTKNOW; 1008 nItemBits |= TIB_CHECKABLE; 1009 } 1010 } 1011 1012 pImpl->pBox->SetItemState( GetId(), eTri ); 1013 pImpl->pBox->SetItemBits( GetId(), nItemBits ); 1014 } 1015 1016 //-------------------------------------------------------------------- 1017 1018 void SfxToolBoxControl::Select( sal_uInt16 nModifier ) 1019 { 1020 pImpl->nSelectModifier = nModifier; 1021 Select( sal_Bool((nModifier & KEY_MOD1)!=0) ); 1022 } 1023 1024 //-------------------------------------------------------------------- 1025 1026 void SfxToolBoxControl::Select( sal_Bool /*bMod1*/ ) 1027 { 1028 if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# #i102805# 1029 { 1030 ::rtl::OUString sAppName; 1031 try 1032 { 1033 static ::rtl::OUString our_aModuleManagerName = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager"); 1034 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager = 1035 ::comphelper::getProcessServiceFactory(); 1036 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleManager( 1037 xServiceManager->createInstance(our_aModuleManagerName) 1038 , ::com::sun::star::uno::UNO_QUERY_THROW); 1039 sAppName = xModuleManager->identify(m_xFrame); 1040 } catch(::com::sun::star::uno::Exception&) {} 1041 Sequence<PropertyValue> vSource; 1042 ::comphelper::UiEventsLogger::appendDispatchOrigin(vSource, sAppName, ::rtl::OUString::createFromAscii("SfxToolBoxControl")); 1043 URL aURL; 1044 aURL.Complete = m_aCommandURL; 1045 ::comphelper::UiEventsLogger::logDispatch(aURL, vSource); 1046 } 1047 svt::ToolboxController::execute( pImpl->nSelectModifier ); 1048 } 1049 1050 //-------------------------------------------------------------------- 1051 1052 void SfxToolBoxControl::DoubleClick() 1053 { 1054 } 1055 1056 //-------------------------------------------------------------------- 1057 1058 void SfxToolBoxControl::Click() 1059 { 1060 } 1061 1062 //-------------------------------------------------------------------- 1063 1064 SfxPopupWindowType SfxToolBoxControl::GetPopupWindowType() const 1065 { 1066 return SFX_POPUPWINDOW_NONE; 1067 } 1068 1069 //-------------------------------------------------------------------- 1070 1071 SfxPopupWindow* SfxToolBoxControl::CreatePopupWindow() 1072 { 1073 return 0; 1074 } 1075 1076 SfxPopupWindow* SfxToolBoxControl::CreatePopupWindowCascading() 1077 { 1078 return 0; 1079 } 1080 1081 //-------------------------------------------------------------------- 1082 1083 Window* SfxToolBoxControl::CreateItemWindow( Window * ) 1084 { 1085 return 0; 1086 } 1087 1088 //-------------------------------------------------------------------- 1089 1090 SfxFrameStatusListener::SfxFrameStatusListener( 1091 const Reference< XMultiServiceFactory >& rServiceManager, 1092 const Reference< XFrame >& xFrame, 1093 SfxStatusListenerInterface* pCallee ) : 1094 svt::FrameStatusListener( rServiceManager, xFrame ), 1095 m_pCallee( pCallee ) 1096 { 1097 } 1098 1099 //-------------------------------------------------------------------- 1100 1101 SfxFrameStatusListener::~SfxFrameStatusListener() 1102 { 1103 } 1104 1105 //-------------------------------------------------------------------- 1106 1107 // XStatusListener 1108 void SAL_CALL SfxFrameStatusListener::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& rEvent ) 1109 throw ( ::com::sun::star::uno::RuntimeException ) 1110 { 1111 SfxViewFrame* pViewFrame = NULL; 1112 Reference < XController > xController; 1113 1114 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1115 if ( m_xFrame.is() ) 1116 xController = m_xFrame->getController(); 1117 1118 Reference < XDispatchProvider > xProvider( xController, UNO_QUERY ); 1119 if ( xProvider.is() ) 1120 { 1121 Reference < XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, ::rtl::OUString(), 0 ); 1122 if ( xDisp.is() ) 1123 { 1124 Reference< XUnoTunnel > xTunnel( xDisp, UNO_QUERY ); 1125 SfxOfficeDispatch* pDisp = NULL; 1126 if ( xTunnel.is() ) 1127 { 1128 sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier()); 1129 pDisp = reinterpret_cast< SfxOfficeDispatch* >( sal::static_int_cast< sal_IntPtr >( nImplementation )); 1130 } 1131 1132 if ( pDisp ) 1133 pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame(); 1134 } 1135 } 1136 1137 sal_uInt16 nSlotId = 0; 1138 SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( pViewFrame ); 1139 const SfxSlot* pSlot = rPool.GetUnoSlot( rEvent.FeatureURL.Path ); 1140 if ( pSlot ) 1141 nSlotId = pSlot->GetSlotId(); 1142 1143 if ( nSlotId > 0 ) 1144 { 1145 if ( rEvent.Requery ) 1146 { 1147 // requery for the notified state 1148 addStatusListener( rEvent.FeatureURL.Complete ); 1149 } 1150 else 1151 { 1152 SfxItemState eState = SFX_ITEM_DISABLED; 1153 SfxPoolItem* pItem = NULL; 1154 if ( rEvent.IsEnabled ) 1155 { 1156 eState = SFX_ITEM_AVAILABLE; 1157 ::com::sun::star::uno::Type pType = rEvent.State.getValueType(); 1158 1159 if ( pType == ::getVoidCppuType() ) 1160 { 1161 pItem = new SfxVoidItem( nSlotId ); 1162 eState = SFX_ITEM_UNKNOWN; 1163 } 1164 else if ( pType == ::getBooleanCppuType() ) 1165 { 1166 sal_Bool bTemp = false; 1167 rEvent.State >>= bTemp ; 1168 pItem = new SfxBoolItem( nSlotId, bTemp ); 1169 } 1170 else if ( pType == ::getCppuType((const sal_uInt16*)0) ) 1171 { 1172 sal_uInt16 nTemp = 0; 1173 rEvent.State >>= nTemp ; 1174 pItem = new SfxUInt16Item( nSlotId, nTemp ); 1175 } 1176 else if ( pType == ::getCppuType((const sal_uInt32*)0) ) 1177 { 1178 sal_uInt32 nTemp = 0; 1179 rEvent.State >>= nTemp ; 1180 pItem = new SfxUInt32Item( nSlotId, nTemp ); 1181 } 1182 else if ( pType == ::getCppuType((const ::rtl::OUString*)0) ) 1183 { 1184 ::rtl::OUString sTemp ; 1185 rEvent.State >>= sTemp ; 1186 pItem = new SfxStringItem( nSlotId, sTemp ); 1187 } 1188 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::ItemStatus*)0) ) 1189 { 1190 ItemStatus aItemStatus; 1191 rEvent.State >>= aItemStatus; 1192 eState = aItemStatus.State; 1193 pItem = new SfxVoidItem( nSlotId ); 1194 } 1195 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::Visibility*)0) ) 1196 { 1197 Visibility aVisibilityStatus; 1198 rEvent.State >>= aVisibilityStatus; 1199 pItem = new SfxVisibilityItem( nSlotId, aVisibilityStatus.bVisible ); 1200 } 1201 else 1202 { 1203 if ( pSlot ) 1204 pItem = pSlot->GetType()->CreateItem(); 1205 if ( pItem ) 1206 { 1207 pItem->SetWhich( nSlotId ); 1208 pItem->PutValue( rEvent.State ); 1209 } 1210 else 1211 pItem = new SfxVoidItem( nSlotId ); 1212 } 1213 } 1214 1215 if ( m_pCallee ) 1216 m_pCallee->StateChanged( nSlotId, eState, pItem ); 1217 delete pItem; 1218 } 1219 } 1220 } 1221 1222 //-------------------------------------------------------------------- 1223 1224 SfxPopupWindow::SfxPopupWindow( 1225 sal_uInt16 nId, 1226 const Reference< XFrame >& rFrame, 1227 WinBits nBits ) : 1228 FloatingWindow( SFX_APP()->GetTopWindow(), nBits ) 1229 , m_bFloating(sal_False) 1230 , m_bCascading( sal_False ) 1231 , m_nId( nId ) 1232 , m_xFrame( rFrame ) 1233 , m_pStatusListener( 0 ) 1234 { 1235 m_xServiceManager = ::comphelper::getProcessServiceFactory(); 1236 1237 Window* pWindow = GetTopMostParentSystemWindow( this ); 1238 if ( pWindow ) 1239 ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this ); 1240 } 1241 1242 //-------------------------------------------------------------------- 1243 1244 SfxPopupWindow::SfxPopupWindow( 1245 sal_uInt16 nId, 1246 const Reference< XFrame >& rFrame, 1247 const ResId &rId ) : 1248 FloatingWindow( SFX_APP()->GetTopWindow(), rId ) 1249 , m_bFloating(sal_False) 1250 , m_bCascading( sal_False ) 1251 , m_nId( nId ) 1252 , m_xFrame( rFrame ) 1253 , m_pStatusListener( 0 ) 1254 { 1255 m_xServiceManager = ::comphelper::getProcessServiceFactory(); 1256 1257 Window* pWindow = GetTopMostParentSystemWindow( this ); 1258 if ( pWindow ) 1259 ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this ); 1260 } 1261 1262 //-------------------------------------------------------------------- 1263 1264 SfxPopupWindow::SfxPopupWindow( 1265 sal_uInt16 nId, 1266 const Reference< XFrame >& rFrame, 1267 Window* pParentWindow, 1268 WinBits nBits ) : 1269 FloatingWindow( pParentWindow, nBits ) 1270 , m_bFloating(sal_False) 1271 , m_bCascading( sal_False ) 1272 , m_nId( nId ) 1273 , m_xFrame( rFrame ) 1274 , m_pStatusListener( 0 ) 1275 { 1276 m_xServiceManager = ::comphelper::getProcessServiceFactory(); 1277 1278 Window* pWindow = GetTopMostParentSystemWindow( this ); 1279 if ( pWindow ) 1280 ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this ); 1281 } 1282 1283 //-------------------------------------------------------------------- 1284 1285 SfxPopupWindow::SfxPopupWindow( 1286 sal_uInt16 nId, 1287 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, 1288 Window* pParentWindow, 1289 const ResId &rId ) : 1290 FloatingWindow( pParentWindow, rId ) 1291 , m_bFloating(sal_False) 1292 , m_bCascading( sal_False ) 1293 , m_nId( nId ) 1294 , m_xFrame( rFrame ) 1295 , m_pStatusListener( 0 ) 1296 { 1297 m_xServiceManager = ::comphelper::getProcessServiceFactory(); 1298 1299 Window* pWindow = GetTopMostParentSystemWindow( this ); 1300 if ( pWindow ) 1301 ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this ); 1302 } 1303 1304 //-------------------------------------------------------------------- 1305 1306 SfxPopupWindow::~SfxPopupWindow() 1307 { 1308 if ( m_xStatusListener.is() ) 1309 { 1310 m_xStatusListener->dispose(); 1311 m_xStatusListener.clear(); 1312 } 1313 1314 Window* pWindow = GetTopMostParentSystemWindow( this ); 1315 if ( pWindow ) 1316 ((SystemWindow *)pWindow)->GetTaskPaneList()->RemoveWindow( this ); 1317 } 1318 1319 //-------------------------------------------------------------------- 1320 1321 SfxFrameStatusListener* SfxPopupWindow::GetOrCreateStatusListener() 1322 { 1323 if ( !m_xStatusListener.is() ) 1324 { 1325 m_pStatusListener = new SfxFrameStatusListener( 1326 m_xServiceManager, 1327 m_xFrame, 1328 this ); 1329 m_xStatusListener = Reference< XComponent >( static_cast< cppu::OWeakObject* >( 1330 m_pStatusListener ), UNO_QUERY ); 1331 } 1332 1333 return m_pStatusListener; 1334 } 1335 1336 //-------------------------------------------------------------------- 1337 1338 void SfxPopupWindow::BindListener() 1339 { 1340 GetOrCreateStatusListener(); 1341 if ( m_xStatusListener.is() ) 1342 m_pStatusListener->bindListener(); 1343 } 1344 1345 //-------------------------------------------------------------------- 1346 1347 void SfxPopupWindow::UnbindListener() 1348 { 1349 GetOrCreateStatusListener(); 1350 if ( m_xStatusListener.is() ) 1351 m_pStatusListener->unbindListener(); 1352 } 1353 1354 //-------------------------------------------------------------------- 1355 1356 void SfxPopupWindow::AddStatusListener( const rtl::OUString& rCommandURL ) 1357 { 1358 GetOrCreateStatusListener(); 1359 if ( m_xStatusListener.is() ) 1360 m_pStatusListener->addStatusListener( rCommandURL ); 1361 } 1362 1363 //-------------------------------------------------------------------- 1364 1365 void SfxPopupWindow::RemoveStatusListener( const rtl::OUString& rCommandURL ) 1366 { 1367 GetOrCreateStatusListener(); 1368 if ( m_xStatusListener.is() ) 1369 m_pStatusListener->removeStatusListener( rCommandURL ); 1370 } 1371 1372 //-------------------------------------------------------------------- 1373 1374 void SfxPopupWindow::UpdateStatus( const rtl::OUString& rCommandURL ) 1375 { 1376 GetOrCreateStatusListener(); 1377 if ( m_xStatusListener.is() ) 1378 m_pStatusListener->updateStatus( rCommandURL ); 1379 } 1380 1381 //-------------------------------------------------------------------- 1382 1383 sal_Bool SfxPopupWindow::Close() 1384 { 1385 m_bFloating = sal_False; 1386 FloatingWindow::Close(); 1387 1388 Delete(0); 1389 return sal_True; 1390 } 1391 1392 //-------------------------------------------------------------------- 1393 1394 void SfxPopupWindow::PopupModeEnd() 1395 { 1396 //! to allow PopupModeEndHdl to be called 1397 FloatingWindow::PopupModeEnd(); 1398 1399 if ( IsVisible() ) 1400 { 1401 // wurde abgerissen 1402 DeleteFloatingWindow(); 1403 m_bFloating = sal_True; 1404 } 1405 else 1406 Close(); 1407 } 1408 1409 //-------------------------------------------------------------------- 1410 1411 void SfxPopupWindow::DeleteFloatingWindow() 1412 { 1413 if ( m_bFloating ) 1414 { 1415 Hide(); 1416 Delete(0); 1417 } 1418 } 1419 1420 //-------------------------------------------------------------------- 1421 1422 void SfxPopupWindow::MouseMove( const ::MouseEvent& rMEvt ) 1423 { 1424 if ( m_bCascading == sal_False ) 1425 FloatingWindow::MouseMove( rMEvt ); 1426 else 1427 { 1428 // MouseMove-Event an die Children forwarden 1429 ::Point aPos = rMEvt.GetPosPixel(); 1430 ::Point aScrPos = OutputToScreenPixel( aPos ); 1431 sal_uInt16 i = 0; 1432 Window* pWindow = GetChild( i ); 1433 while ( pWindow ) 1434 { 1435 ::MouseEvent aMEvt( pWindow->ScreenToOutputPixel( aScrPos ), 1436 rMEvt.GetClicks(), rMEvt.GetMode(), 1437 rMEvt.GetButtons(), rMEvt.GetModifier() ); 1438 pWindow->MouseMove( rMEvt ); 1439 pWindow->Update(); 1440 i++; 1441 pWindow = GetChild( i ); 1442 } 1443 } 1444 } 1445 1446 //-------------------------------------------------------------------- 1447 1448 void SfxPopupWindow::StartCascading() 1449 { 1450 m_bCascading= sal_True; 1451 } 1452 1453 void SfxPopupWindow::EndCascading() 1454 { 1455 m_bCascading = sal_False; 1456 } 1457 1458 //-------------------------------------------------------------------- 1459 1460 SfxPopupWindow* SfxPopupWindow::Clone() const 1461 1462 /* [Beschreibung] 1463 1464 Diese Methode mu\s "uberladen werden, um dieses Popup auch im 1465 Presentations-Modus anzuzeigen. Sie wird gerufen, wenn ein Show() 1466 sinnlos w"are, da der Parent nicht das Presentations-Window ist. 1467 Beim neu erzeugen wird automatisch das neue Top-Window verwendet, so 1468 da\s der Parent das Presentations-Window ist und das neue Popup somit 1469 sichtbar ist. 1470 */ 1471 1472 { 1473 return 0; 1474 } 1475 1476 //-------------------------------------------------------------------- 1477 1478 void SfxPopupWindow::StateChanged( 1479 sal_uInt16 /*nSID*/, 1480 SfxItemState eState, 1481 const SfxPoolItem* /*pState*/ ) 1482 /* [Bescheibung] 1483 1484 Siehe auch <SfxControllerItem::StateChanged()>. Au\serdem wird 1485 bei eState==SFX_ITEM_DISABLED das Popup gehided und in allen anderen 1486 F"allen, falls es floating ist, wieder angezeigt. Daher mu\s die 1487 Basisklasse i.d.R. gerufen werden. 1488 1489 Es findet wegen des Parents eine Sonderbehandlung f"ur den 1490 Presentationsmodus statt. 1491 1492 */ 1493 1494 { 1495 if ( SFX_ITEM_DISABLED == eState ) 1496 { 1497 Hide(); 1498 } 1499 else if ( m_bFloating ) 1500 { 1501 Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE ); 1502 } 1503 } 1504 1505 //-------------------------------------------------------------------- 1506 1507 IMPL_LINK( SfxPopupWindow, Delete, void *, EMPTYARG ) 1508 { 1509 if ( m_aDeleteLink.IsSet() ) 1510 m_aDeleteLink.Call( this ); 1511 delete this; 1512 return 0; 1513 } 1514 1515 //-------------------------------------------------------------------- 1516 1517 SfxAppToolBoxControl_Impl::SfxAppToolBoxControl_Impl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox ) 1518 : SfxToolBoxControl( nSlotId, nId, rBox ) 1519 , bBigImages( sal_False ) 1520 , pMenu( 0 ) 1521 { 1522 rBox.SetHelpId( nId, HID_TBXCONTROL_FILENEW ); 1523 rBox.SetItemBits( nId, rBox.GetItemBits( nId ) | TIB_DROPDOWN); 1524 1525 // Determine the current background color of the menus 1526 const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); 1527 m_nSymbolsStyle = rSettings.GetSymbolsStyle(); 1528 m_bWasHiContrastMode = rSettings.GetHighContrastMode(); 1529 m_bShowMenuImages = rSettings.GetUseImagesInMenus(); 1530 1531 SetImage( String() ); 1532 } 1533 1534 SfxAppToolBoxControl_Impl::~SfxAppToolBoxControl_Impl() 1535 { 1536 delete pMenu; 1537 } 1538 1539 //_____________________________________________________ 1540 /* 1541 it return the existing state of the given URL in the popupmenu of this toolbox control. 1542 1543 If the given URL can be located as an action command of one menu item of the 1544 popup menu of this control, we return sal_True. Otherwhise we return sal_False. 1545 Further we return a fallback URL, in case we have to return sal_False. Because 1546 the outside code must select a valid item of the popup menu everytime ... 1547 and we define it here. By the way this m ethod was written to handle 1548 error situations gracefully. E.g. it can be called during creation time 1549 but then we have no valid menu. For this case we know another fallback URL. 1550 Then we return the private:factory/ URL of the default factory. 1551 1552 @param *pMenu 1553 pounts to the popup menu, on which item we try to locate the given URL 1554 Can be NULL! Search will be supressed then. 1555 1556 @param sURL 1557 the URL for searching 1558 1559 @param pFallback 1560 contains the fallback URL in case we return FALSE 1561 Must point to valid memory! 1562 1563 @param pImage 1564 contains the image of the menu for the URL. 1565 1566 @return sal_True - if URL could be located as an item of the popup menu. 1567 sal_False - otherwhise. 1568 */ 1569 sal_Bool Impl_ExistURLInMenu( const PopupMenu *pMenu , 1570 String &sURL , 1571 String *pFallback , 1572 Image *pImage ) 1573 { 1574 sal_Bool bValidFallback = sal_False; 1575 if (pMenu && sURL.Len()) 1576 { 1577 sal_uInt16 c = pMenu->GetItemCount(); 1578 for (sal_uInt16 p=0; p<c; ++p) 1579 { 1580 sal_uInt16 nId = pMenu->GetItemId(p); 1581 String aCmd( pMenu->GetItemCommand(nId) ); 1582 1583 if (!bValidFallback && aCmd.Len()) 1584 { 1585 *pFallback = aCmd; 1586 bValidFallback = sal_True; 1587 } 1588 1589 if (aCmd.Search(sURL)==0)//match even if the menu command is more detailed (maybe an additional query) #i28667# 1590 { 1591 sURL = aCmd; 1592 *pImage = pMenu->GetItemImage( nId ); 1593 return sal_True; 1594 } 1595 } 1596 } 1597 1598 if (!bValidFallback) 1599 { 1600 *pFallback = DEFINE_CONST_UNICODE("private:factory/"); 1601 *pFallback += String(SvtModuleOptions().GetDefaultModuleName()); 1602 } 1603 1604 return sal_False; 1605 } 1606 1607 long Select_Impl( void* pHdl, void* pVoid ); 1608 1609 SfxPopupWindow* SfxAppToolBoxControl_Impl::CreatePopupWindow() 1610 { 1611 ToolBox& rBox = GetToolBox(); 1612 ::Rectangle aRect( rBox.GetItemRect( GetId() ) ); 1613 1614 if ( !pMenu ) 1615 { 1616 ::framework::MenuConfiguration aConf( m_xServiceManager ); 1617 if ( m_aCommandURL.equalsAscii( ".uno:AddDirect" )) 1618 pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_NEWMENU ); 1619 else 1620 pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_WIZARDMENU ); 1621 } 1622 1623 if ( pMenu ) 1624 { 1625 pMenu->SetSelectHdl( Link( NULL, Select_Impl ) ); 1626 pMenu->SetActivateHdl( LINK( this, SfxAppToolBoxControl_Impl, Activate )); 1627 rBox.SetItemDown( GetId(), sal_True ); 1628 sal_uInt16 nSelected = pMenu->Execute( &rBox, aRect, POPUPMENU_EXECUTE_DOWN ); 1629 if ( nSelected ) 1630 { 1631 aLastURL = pMenu->GetItemCommand( nSelected ); 1632 SetImage( pMenu->GetItemCommand( nSelected ) ); 1633 } 1634 1635 rBox.SetItemDown( GetId(), sal_False ); 1636 } 1637 1638 return 0; 1639 } 1640 1641 void SfxAppToolBoxControl_Impl::SetImage( const String &rURL ) 1642 { 1643 /* We accept URL's here only, which exist as items of our internal popup menu. 1644 All other ones will be ignored and a fallback is used ... */ 1645 String aURL = rURL; 1646 String sFallback; 1647 Image aMenuImage; 1648 sal_Bool bValid = Impl_ExistURLInMenu(pMenu,aURL,&sFallback,&aMenuImage); 1649 if (!bValid) 1650 aURL = sFallback; 1651 1652 sal_Bool bBig = SvtMiscOptions().AreCurrentSymbolsLarge(); 1653 sal_Bool bHC = GetToolBox().GetSettings().GetStyleSettings().GetHighContrastMode(); 1654 Image aImage = SvFileInformationManager::GetImageNoDefault( INetURLObject( aURL ), bBig, bHC ); 1655 if ( !aImage ) 1656 aImage = !!aMenuImage ? aMenuImage : 1657 SvFileInformationManager::GetImage( INetURLObject( aURL ), bBig, bHC ); 1658 Size aBigSize( GetToolBox().GetDefaultImageSize() ); 1659 if ( bBig && aImage.GetSizePixel() != aBigSize ) 1660 { 1661 BitmapEx aScaleBmpEx( aImage.GetBitmapEx() ); 1662 aScaleBmpEx.Scale( aBigSize, BMP_SCALE_INTERPOLATE ); 1663 GetToolBox().SetItemImage( GetId(), Image( aScaleBmpEx ) ); 1664 } 1665 else 1666 GetToolBox().SetItemImage( GetId(), aImage ); 1667 aLastURL = aURL; 1668 } 1669 1670 void SfxAppToolBoxControl_Impl::StateChanged 1671 ( 1672 sal_uInt16 nSlotId, 1673 SfxItemState eState, 1674 const SfxPoolItem* pState 1675 ) 1676 { 1677 if ( pState && pState->ISA(SfxStringItem) ) 1678 { 1679 // Important step for following SetImage() call! 1680 // It needs the valid pMenu item to fullfill it's specification 1681 // to check for supported URLs ... 1682 if ( !pMenu ) 1683 { 1684 ::framework::MenuConfiguration aConf( m_xServiceManager ); 1685 // This toolbox controller is used for two popup menus (new documents and wizards!). Create the correct 1686 // popup menu according to the slot ID our controller has been initialized with. 1687 if ( nSlotId == SID_NEWDOCDIRECT ) 1688 pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_NEWMENU ); 1689 else 1690 pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_WIZARDMENU ); 1691 } 1692 1693 GetToolBox().EnableItem( GetId(), eState != SFX_ITEM_DISABLED ); 1694 SetImage(((const SfxStringItem*)pState)->GetValue()); 1695 } 1696 else 1697 SfxToolBoxControl::StateChanged( nSlotId, eState, pState ); 1698 } 1699 1700 //-------------------------------------------------------------------- 1701 1702 void SfxAppToolBoxControl_Impl::Select( sal_Bool bMod1 ) 1703 { 1704 if( aLastURL.Len() ) 1705 { 1706 URL aTargetURL; 1707 Reference< XDispatch > xDispatch; 1708 Reference< XDispatchProvider > xDispatchProvider( getFrameInterface(), UNO_QUERY ); 1709 1710 if ( xDispatchProvider.is() ) 1711 { 1712 aTargetURL.Complete = aLastURL; 1713 getURLTransformer()->parseStrict( aTargetURL ); 1714 1715 ::rtl::OUString aTarget( ::rtl::OUString::createFromAscii( "_default" )); 1716 if ( pMenu ) 1717 { 1718 ::framework::MenuConfiguration::Attributes* pMenuAttributes = 1719 (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( pMenu->GetCurItemId() ); 1720 1721 if ( pMenuAttributes ) 1722 aTarget = pMenuAttributes->aTargetFrame; 1723 } 1724 1725 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, aTarget, 0 ); 1726 1727 if ( xDispatch.is() ) 1728 { 1729 Sequence< PropertyValue > aArgs( 1 ); 1730 1731 aArgs[0].Name = ::rtl::OUString::createFromAscii( "Referer" ); 1732 aArgs[0].Value = makeAny( ::rtl::OUString::createFromAscii( SFX_REFERER_USER )); 1733 1734 ExecuteInfo* pExecuteInfo = new ExecuteInfo; 1735 pExecuteInfo->xDispatch = xDispatch; 1736 pExecuteInfo->aTargetURL = aTargetURL; 1737 pExecuteInfo->aArgs = aArgs; 1738 Application::PostUserEvent( STATIC_LINK(0, SfxAppToolBoxControl_Impl, ExecuteHdl_Impl), pExecuteInfo ); 1739 } 1740 } 1741 } 1742 else 1743 SfxToolBoxControl::Select( bMod1 ); 1744 } 1745 1746 //-------------------------------------------------------------------- 1747 long Select_Impl( void* /*pHdl*/, void* pVoid ) 1748 { 1749 Menu* pMenu = (Menu*)pVoid; 1750 String aURL( pMenu->GetItemCommand( pMenu->GetCurItemId() ) ); 1751 1752 if( !aURL.Len() ) 1753 return 0; 1754 1755 Reference < ::com::sun::star::frame::XFramesSupplier > xDesktop = 1756 Reference < ::com::sun::star::frame::XFramesSupplier >( ::comphelper::getProcessServiceFactory()->createInstance( 1757 DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY ); 1758 Reference < ::com::sun::star::frame::XFrame > xFrame( xDesktop, UNO_QUERY ); 1759 1760 URL aTargetURL; 1761 aTargetURL.Complete = aURL; 1762 Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( 1763 rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), 1764 UNO_QUERY ); 1765 xTrans->parseStrict( aTargetURL ); 1766 1767 Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY ); 1768 Reference < XDispatch > xDisp; 1769 if ( xProv.is() ) 1770 { 1771 if ( aTargetURL.Protocol.compareToAscii("slot:") == COMPARE_EQUAL ) 1772 xDisp = xProv->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); 1773 else 1774 { 1775 ::rtl::OUString aTargetFrame( ::rtl::OUString::createFromAscii( "_blank" ) ); 1776 ::framework::MenuConfiguration::Attributes* pMenuAttributes = 1777 (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( pMenu->GetCurItemId() ); 1778 1779 if ( pMenuAttributes ) 1780 aTargetFrame = pMenuAttributes->aTargetFrame; 1781 1782 xDisp = xProv->queryDispatch( aTargetURL, aTargetFrame , 0 ); 1783 } 1784 } 1785 1786 if ( xDisp.is() ) 1787 { 1788 SfxAppToolBoxControl_Impl::ExecuteInfo* pExecuteInfo = new SfxAppToolBoxControl_Impl::ExecuteInfo; 1789 pExecuteInfo->xDispatch = xDisp; 1790 pExecuteInfo->aTargetURL = aTargetURL; 1791 pExecuteInfo->aArgs = Sequence< PropertyValue >(); 1792 Application::PostUserEvent( STATIC_LINK( 0, SfxAppToolBoxControl_Impl, ExecuteHdl_Impl), pExecuteInfo ); 1793 } 1794 1795 return sal_True; 1796 } 1797 1798 IMPL_LINK( SfxAppToolBoxControl_Impl, Activate, Menu *, pActMenu ) 1799 { 1800 if ( pActMenu ) 1801 { 1802 const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); 1803 sal_uIntPtr nSymbolsStyle = rSettings.GetSymbolsStyle(); 1804 sal_Bool bIsHiContrastMode = rSettings.GetHighContrastMode(); 1805 sal_Bool bShowMenuImages = rSettings.GetUseImagesInMenus(); 1806 1807 if (( nSymbolsStyle != m_nSymbolsStyle ) || 1808 ( bIsHiContrastMode != m_bWasHiContrastMode ) || 1809 ( bShowMenuImages != m_bShowMenuImages )) 1810 { 1811 m_nSymbolsStyle = nSymbolsStyle; 1812 m_bWasHiContrastMode = bIsHiContrastMode; 1813 m_bShowMenuImages = bShowMenuImages; 1814 1815 sal_uInt16 nCount = pActMenu->GetItemCount(); 1816 for ( sal_uInt16 nSVPos = 0; nSVPos < nCount; nSVPos++ ) 1817 { 1818 sal_uInt16 nId = pActMenu->GetItemId( nSVPos ); 1819 if ( pActMenu->GetItemType( nSVPos ) != MENUITEM_SEPARATOR ) 1820 { 1821 if ( bShowMenuImages ) 1822 { 1823 sal_Bool bImageSet = sal_False; 1824 ::rtl::OUString aImageId; 1825 ::framework::MenuConfiguration::Attributes* pMenuAttributes = 1826 (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( nId ); 1827 1828 if ( pMenuAttributes ) 1829 aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes 1830 1831 if ( aImageId.getLength() > 0 ) 1832 { 1833 Reference< ::com::sun::star::frame::XFrame > xFrame; 1834 Image aImage = GetImage( xFrame, aImageId, sal_False, bIsHiContrastMode ); 1835 if ( !!aImage ) 1836 { 1837 bImageSet = sal_True; 1838 pActMenu->SetItemImage( nId, aImage ); 1839 } 1840 } 1841 1842 String aCmd( pActMenu->GetItemCommand( nId ) ); 1843 if ( !bImageSet && aCmd.Len() ) 1844 { 1845 Image aImage = SvFileInformationManager::GetImage( 1846 INetURLObject(aCmd), sal_False, bIsHiContrastMode ); 1847 if ( !!aImage ) 1848 pActMenu->SetItemImage( nId, aImage ); 1849 } 1850 } 1851 else 1852 pActMenu->SetItemImage( nId, Image() ); 1853 } 1854 } 1855 } 1856 1857 return sal_True; 1858 } 1859 1860 return sal_False; 1861 } 1862 1863 //-------------------------------------------------------------------- 1864 1865 IMPL_STATIC_LINK_NOINSTANCE( SfxAppToolBoxControl_Impl, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo ) 1866 { 1867 /* i62706: Don't catch all exceptions. We hide all problems here and are not able 1868 to handle them on higher levels. 1869 try 1870 { 1871 */ 1872 // Asynchronous execution as this can lead to our own destruction! 1873 // Framework can recycle our current frame and the layout manager disposes all user interface 1874 // elements if a component gets detached from its frame! 1875 pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs ); 1876 /* 1877 } 1878 catch (const ::com::sun::star::document::CorruptedFilterConfigurationException& exFilters) 1879 { 1880 throw exFilters; 1881 } 1882 catch (const Exception& ) 1883 { 1884 } 1885 */ 1886 delete pExecuteInfo; 1887 return 0; 1888 } 1889 1890 //-------------------------------------------------------------------- 1891 1892 void SfxAppToolBoxControl_Impl::Click( ) 1893 { 1894 } 1895