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