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 125 static Window* GetTopMostParentSystemWindow( Window* pWindow ) 126 { 127 OSL_ASSERT( pWindow ); 128 if ( pWindow ) 129 { 130 // ->manually search topmost system window 131 // required because their might be another system window between this and the top window 132 pWindow = pWindow->GetParent(); 133 SystemWindow* pTopMostSysWin = NULL; 134 while ( pWindow ) 135 { 136 if ( pWindow->IsSystemWindow() ) 137 pTopMostSysWin = (SystemWindow*)pWindow; 138 pWindow = pWindow->GetParent(); 139 } 140 pWindow = pTopMostSysWin; 141 OSL_ASSERT( pWindow ); 142 return pWindow; 143 } 144 145 return NULL; 146 } 147 148 svt::ToolboxController* SAL_CALL SfxToolBoxControllerFactory( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const ::rtl::OUString& aCommandURL ) 149 { 150 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 151 152 URL aTargetURL; 153 aTargetURL.Complete = aCommandURL; 154 Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY ); 155 xTrans->parseStrict( aTargetURL ); 156 if ( aTargetURL.Arguments.getLength() ) 157 return NULL; 158 159 SfxObjectShell* pObjShell = NULL; 160 Reference < XController > xController; 161 Reference < XModel > xModel; 162 if ( rFrame.is() ) 163 { 164 xController = rFrame->getController(); 165 if ( xController.is() ) 166 xModel = xController->getModel(); 167 } 168 169 if ( xModel.is() ) 170 { 171 // Get tunnel from model to retrieve the SfxObjectShell pointer from it 172 ::com::sun::star::uno::Reference < ::com::sun::star::lang::XUnoTunnel > xObj( xModel, UNO_QUERY ); 173 if ( xObj.is() ) 174 { 175 ::com::sun::star::uno::Sequence < sal_Int8 > aSeq = SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence(); 176 sal_Int64 nHandle = xObj->getSomething( aSeq ); 177 if ( nHandle ) 178 pObjShell = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle )); 179 } 180 } 181 182 SfxModule* pModule = pObjShell ? pObjShell->GetModule() : NULL; 183 SfxSlotPool* pSlotPool = 0; 184 185 if ( pModule ) 186 pSlotPool = pModule->GetSlotPool(); 187 else 188 pSlotPool = &(SfxSlotPool::GetSlotPool( NULL )); 189 190 const SfxSlot* pSlot = pSlotPool->GetUnoSlot( aTargetURL.Path ); 191 if ( pSlot ) 192 { 193 sal_uInt16 nSlotId = pSlot->GetSlotId(); 194 if ( nSlotId > 0 ) 195 return SfxToolBoxControl::CreateControl( nSlotId, nID, pToolbox, pModule ); 196 } 197 198 return NULL; 199 } 200 201 struct SfxToolBoxControl_Impl 202 { 203 ToolBox* pBox; 204 sal_Bool bShowString; 205 sal_uInt16 nSelectModifier; 206 SfxTbxCtrlFactory* pFact; 207 sal_uInt16 nTbxId; 208 sal_uInt16 nSlotId; 209 SfxPopupWindow* mpFloatingWindow; 210 SfxPopupWindow* mpPopupWindow; 211 Reference< XUIElement > mxUIElement; 212 213 DECL_LINK( WindowEventListener, VclSimpleEvent* ); 214 }; 215 216 IMPL_LINK( SfxToolBoxControl_Impl, WindowEventListener, VclSimpleEvent*, pEvent ) 217 { 218 if ( pEvent && 219 pEvent->ISA( VclWindowEvent ) && 220 (( pEvent->GetId() == VCLEVENT_WINDOW_MOVE ) || 221 ( pEvent->GetId() == VCLEVENT_WINDOW_ACTIVATE ))) 222 { 223 Window* pWindow( ((VclWindowEvent*)pEvent)->GetWindow() ); 224 if (( pWindow == mpFloatingWindow ) && 225 ( mpPopupWindow != 0 )) 226 { 227 delete mpPopupWindow; 228 mpPopupWindow = 0; 229 } 230 } 231 232 return 1; 233 } 234 235 //-------------------------------------------------------------------- 236 237 SfxToolBoxControl::SfxToolBoxControl( 238 sal_uInt16 nSlotID, 239 sal_uInt16 nID, 240 ToolBox& rBox, 241 sal_Bool bShowStringItems ) 242 : svt::ToolboxController() 243 { 244 pImpl = new SfxToolBoxControl_Impl; 245 246 pImpl->pBox = &rBox; 247 pImpl->bShowString = bShowStringItems; 248 pImpl->nSelectModifier = 0; 249 pImpl->pFact = 0; 250 pImpl->nTbxId = nID; 251 pImpl->nSlotId = nSlotID; 252 pImpl->mpFloatingWindow = 0; 253 pImpl->mpPopupWindow = 0; 254 } 255 256 //-------------------------------------------------------------------- 257 258 SfxToolBoxControl::~SfxToolBoxControl() 259 { 260 if ( pImpl->mxUIElement.is() ) 261 { 262 Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY ); 263 xComponent->dispose(); 264 } 265 pImpl->mxUIElement = 0; 266 delete pImpl; 267 } 268 269 //-------------------------------------------------------------------- 270 271 ToolBox& SfxToolBoxControl::GetToolBox() const 272 { 273 return *pImpl->pBox; 274 } 275 unsigned short SfxToolBoxControl::GetId() const 276 { 277 return pImpl->nTbxId; 278 } 279 unsigned short SfxToolBoxControl::GetSlotId() const 280 { 281 return pImpl->nSlotId; 282 } 283 284 //-------------------------------------------------------------------- 285 286 void SAL_CALL SfxToolBoxControl::dispose() throw (::com::sun::star::uno::RuntimeException) 287 { 288 if ( m_bDisposed ) 289 return; 290 291 svt::ToolboxController::dispose(); 292 293 // Remove and destroy our item window at our toolbox 294 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 295 Window* pWindow = pImpl->pBox->GetItemWindow( pImpl->nTbxId ); 296 pImpl->pBox->SetItemWindow( pImpl->nTbxId, 0 ); 297 delete pWindow; 298 299 // Dispose an open sub toolbar. It's possible that we have an open 300 // sub toolbar while we get disposed. Therefore we have to dispose 301 // it now! Not doing so would result in a crash. The sub toolbar 302 // gets destroyed asynchronously and would access a non-existing 303 // parent toolbar! See #126569# 304 if ( pImpl->mxUIElement.is() ) 305 { 306 Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY ); 307 xComponent->dispose(); 308 } 309 pImpl->mxUIElement = 0; 310 311 // Delete my popup windows 312 delete pImpl->mpFloatingWindow; 313 delete pImpl->mpPopupWindow; 314 315 pImpl->mpFloatingWindow = 0; 316 pImpl->mpPopupWindow = 0; 317 } 318 319 //-------------------------------------------------------------------- 320 void SfxToolBoxControl::RegisterToolBoxControl( SfxModule* pMod, SfxTbxCtrlFactory* pFact) 321 { 322 SFX_APP()->RegisterToolBoxControl_Impl( pMod, pFact ); 323 } 324 325 SfxToolBoxControl* SfxToolBoxControl::CreateControl( sal_uInt16 nSlotId, sal_uInt16 nTbxId, ToolBox *pBox, SfxModule* pMod ) 326 { 327 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 328 329 SfxToolBoxControl *pCtrl; 330 SfxApplication *pApp = SFX_APP(); 331 332 SfxSlotPool *pSlotPool; 333 if ( pMod ) 334 pSlotPool = pMod->GetSlotPool(); 335 else 336 pSlotPool = &SfxSlotPool::GetSlotPool(); 337 TypeId aSlotType = pSlotPool->GetSlotType( nSlotId ); 338 if ( aSlotType ) 339 { 340 if ( pMod ) 341 { 342 SfxTbxCtrlFactArr_Impl *pFactories = pMod->GetTbxCtrlFactories_Impl(); 343 if ( pFactories ) 344 { 345 SfxTbxCtrlFactArr_Impl &rFactories = *pFactories; 346 sal_uInt16 nFactory; 347 const sal_uInt16 nCount = rFactories.Count(); 348 349 // search for a factory with the given slot id 350 for( nFactory = 0; nFactory < nCount; ++nFactory ) 351 if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == nSlotId) ) 352 break; 353 354 if( nFactory == nCount ) 355 { 356 // if no factory exists for the given slot id, see if we 357 // have a generic factory with the correct slot type and slot id == 0 358 for ( nFactory = 0; nFactory < nCount; ++nFactory ) 359 if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == 0) ) 360 break; 361 } 362 363 if( nFactory < nCount ) 364 { 365 pCtrl = rFactories[nFactory]->pCtor( nSlotId, nTbxId, *pBox ); 366 pCtrl->pImpl->pFact = rFactories[nFactory]; 367 return pCtrl; 368 } 369 } 370 } 371 372 SfxTbxCtrlFactArr_Impl &rFactories = pApp->GetTbxCtrlFactories_Impl(); 373 sal_uInt16 nFactory; 374 const sal_uInt16 nCount = rFactories.Count(); 375 376 for( nFactory = 0; nFactory < nCount; ++nFactory ) 377 if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == nSlotId) ) 378 break; 379 380 if( nFactory == nCount ) 381 { 382 // if no factory exists for the given slot id, see if we 383 // have a generic factory with the correct slot type and slot id == 0 384 for( nFactory = 0; nFactory < nCount; ++nFactory ) 385 if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == 0) ) 386 break; 387 } 388 389 if( nFactory < nCount ) 390 { 391 pCtrl = rFactories[nFactory]->pCtor( nSlotId, nTbxId, *pBox ); 392 pCtrl->pImpl->pFact = rFactories[nFactory]; 393 return pCtrl; 394 } 395 } 396 397 return NULL; 398 } 399 400 SfxItemState SfxToolBoxControl::GetItemState( 401 const SfxPoolItem* pState ) 402 /* [Beschreibung] 403 404 Statische Methode zum Ermitteln des Status des SfxPoolItem-Pointers, 405 in der Methode <SfxControllerItem::StateChanged(const SfxPoolItem*)> 406 zu verwenden. 407 408 [R"uckgabewert] 409 410 SfxItemState SFX_ITEM_UNKNOWN 411 Enabled, aber keine weitere Statusinformation 412 verf"ugbar. Typisch f"ur <Slot>s, die allenfalls 413 zeitweise disabled sind, aber ihre Darstellung sonst 414 nicht "andern. 415 416 SFX_ITEM_DISABLED 417 Disabled und keine weiter Statusinformation 418 verf"ugbar. Alle anderen ggf. angezeigten Werte sollten 419 auf den Default zur"uckgesetzt werden. 420 421 SFX_ITEM_DONTCARE 422 Enabled aber es waren nur uneindeutige Werte 423 verf"ugbar (also keine, die abgefragt werden k"onnen). 424 425 SFX_ITEM_AVAILABLE 426 Enabled und mit verf"ugbarem Wert, der von 'pState' 427 erfragbar ist. Der Typ ist dabei im gesamten 428 Programm eindeutig und durch den Slot festgelegt. 429 */ 430 431 { 432 return !pState 433 ? SFX_ITEM_DISABLED 434 : IsInvalidItem(pState) 435 ? SFX_ITEM_DONTCARE 436 : pState->ISA(SfxVoidItem) && !pState->Which() 437 ? SFX_ITEM_UNKNOWN 438 : SFX_ITEM_AVAILABLE; 439 } 440 441 void SfxToolBoxControl::Dispatch( 442 const Reference< XDispatchProvider >& rProvider, 443 const rtl::OUString& rCommand, 444 Sequence< ::PropertyValue >& aArgs ) 445 { 446 if ( rProvider.is() ) 447 { 448 ::com::sun::star::util::URL aTargetURL; 449 aTargetURL.Complete = rCommand; 450 Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( 451 rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), 452 UNO_QUERY ); 453 xTrans->parseStrict( aTargetURL ); 454 455 Reference < XDispatch > xDispatch = rProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); 456 if ( xDispatch.is() ) 457 xDispatch->dispatch( aTargetURL, aArgs ); 458 } 459 } 460 461 void SfxToolBoxControl::Dispatch( const ::rtl::OUString& aCommand, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs ) 462 { 463 Reference < XController > xController; 464 465 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 466 if ( getFrameInterface().is() ) 467 xController = getFrameInterface()->getController(); 468 469 Reference < XDispatchProvider > xProvider( xController, UNO_QUERY ); 470 if ( xProvider.is() ) 471 { 472 ::com::sun::star::util::URL aTargetURL; 473 aTargetURL.Complete = aCommand; 474 getURLTransformer()->parseStrict( aTargetURL ); 475 476 Reference < XDispatch > xDispatch = xProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); 477 if ( xDispatch.is() ) 478 { 479 if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# 480 { 481 ::rtl::OUString sAppName; 482 try 483 { 484 static ::rtl::OUString our_aModuleManagerName = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager"); 485 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager = 486 ::comphelper::getProcessServiceFactory(); 487 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleManager( 488 xServiceManager->createInstance(our_aModuleManagerName) 489 , ::com::sun::star::uno::UNO_QUERY_THROW); 490 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame( 491 getFrameInterface(), UNO_QUERY_THROW); 492 sAppName = xModuleManager->identify(xFrame); 493 } catch(::com::sun::star::uno::Exception&) {} 494 Sequence<PropertyValue> source; 495 ::comphelper::UiEventsLogger::appendDispatchOrigin(source, sAppName, ::rtl::OUString::createFromAscii("SfxToolBoxControl")); 496 ::comphelper::UiEventsLogger::logDispatch(aTargetURL, source); 497 } 498 xDispatch->dispatch( aTargetURL, aArgs ); 499 } 500 } 501 } 502 503 // XInterface 504 Any SAL_CALL SfxToolBoxControl::queryInterface( const Type & rType ) 505 throw(::com::sun::star::uno::RuntimeException) 506 { 507 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 508 SAL_STATIC_CAST( ::com::sun::star::awt::XDockableWindowListener*, this ), 509 SAL_STATIC_CAST( ::com::sun::star::frame::XSubToolbarController*, this )); 510 return (aRet.hasValue() ? aRet : svt::ToolboxController::queryInterface( rType )); 511 } 512 513 void SAL_CALL SfxToolBoxControl::acquire() throw() 514 { 515 OWeakObject::acquire(); 516 } 517 518 void SAL_CALL SfxToolBoxControl::release() throw() 519 { 520 OWeakObject::release(); 521 } 522 523 void SAL_CALL SfxToolBoxControl::disposing( const ::com::sun::star::lang::EventObject& aEvent ) 524 throw( ::com::sun::star::uno::RuntimeException ) 525 { 526 svt::ToolboxController::disposing( aEvent ); 527 } 528 529 // XStatusListener 530 void SAL_CALL SfxToolBoxControl::statusChanged( const FeatureStateEvent& rEvent ) 531 throw ( ::com::sun::star::uno::RuntimeException ) 532 { 533 SfxViewFrame* pViewFrame = NULL; 534 Reference < XController > xController; 535 536 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 537 if ( getFrameInterface().is() ) 538 xController = getFrameInterface()->getController(); 539 540 Reference < XDispatchProvider > xProvider( xController, UNO_QUERY ); 541 if ( xProvider.is() ) 542 { 543 Reference < XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, ::rtl::OUString(), 0 ); 544 if ( xDisp.is() ) 545 { 546 Reference< XUnoTunnel > xTunnel( xDisp, UNO_QUERY ); 547 SfxOfficeDispatch* pDisp = NULL; 548 if ( xTunnel.is() ) 549 { 550 sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier()); 551 pDisp = reinterpret_cast< SfxOfficeDispatch* >( sal::static_int_cast< sal_IntPtr >( nImplementation )); 552 } 553 554 if ( pDisp ) 555 pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame(); 556 } 557 } 558 559 sal_uInt16 nSlotId = 0; 560 SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( pViewFrame ); 561 const SfxSlot* pSlot = rPool.GetUnoSlot( rEvent.FeatureURL.Path ); 562 if ( pSlot ) 563 nSlotId = pSlot->GetSlotId(); 564 else if ( m_aCommandURL == rEvent.FeatureURL.Path ) 565 nSlotId = GetSlotId(); 566 567 if ( nSlotId > 0 ) 568 { 569 if ( rEvent.Requery ) 570 svt::ToolboxController::statusChanged( rEvent ); 571 else 572 { 573 SfxItemState eState = SFX_ITEM_DISABLED; 574 SfxPoolItem* pItem = NULL; 575 if ( rEvent.IsEnabled ) 576 { 577 eState = SFX_ITEM_AVAILABLE; 578 ::com::sun::star::uno::Type pType = rEvent.State.getValueType(); 579 580 if ( pType == ::getVoidCppuType() ) 581 { 582 pItem = new SfxVoidItem( nSlotId ); 583 eState = SFX_ITEM_UNKNOWN; 584 } 585 else if ( pType == ::getBooleanCppuType() ) 586 { 587 sal_Bool bTemp = false; 588 rEvent.State >>= bTemp ; 589 pItem = new SfxBoolItem( nSlotId, bTemp ); 590 } 591 else if ( pType == ::getCppuType((const sal_uInt16*)0) ) 592 { 593 sal_uInt16 nTemp = 0; 594 rEvent.State >>= nTemp ; 595 pItem = new SfxUInt16Item( nSlotId, nTemp ); 596 } 597 else if ( pType == ::getCppuType((const sal_uInt32*)0) ) 598 { 599 sal_uInt32 nTemp = 0; 600 rEvent.State >>= nTemp ; 601 pItem = new SfxUInt32Item( nSlotId, nTemp ); 602 } 603 else if ( pType == ::getCppuType((const ::rtl::OUString*)0) ) 604 { 605 ::rtl::OUString sTemp ; 606 rEvent.State >>= sTemp ; 607 pItem = new SfxStringItem( nSlotId, sTemp ); 608 } 609 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::ItemStatus*)0) ) 610 { 611 ItemStatus aItemStatus; 612 rEvent.State >>= aItemStatus; 613 eState = aItemStatus.State; 614 pItem = new SfxVoidItem( nSlotId ); 615 } 616 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::Visibility*)0) ) 617 { 618 Visibility aVisibilityStatus; 619 rEvent.State >>= aVisibilityStatus; 620 pItem = new SfxVisibilityItem( nSlotId, aVisibilityStatus.bVisible ); 621 } 622 else 623 { 624 if ( pSlot ) 625 pItem = pSlot->GetType()->CreateItem(); 626 if ( pItem ) 627 { 628 pItem->SetWhich( nSlotId ); 629 pItem->PutValue( rEvent.State ); 630 } 631 else 632 pItem = new SfxVoidItem( nSlotId ); 633 } 634 } 635 636 StateChanged( nSlotId, eState, pItem ); 637 delete pItem; 638 } 639 } 640 } 641 642 // XSubToolbarController 643 ::sal_Bool SAL_CALL SfxToolBoxControl::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException) 644 { 645 return sal_False; 646 } 647 648 ::rtl::OUString SAL_CALL SfxToolBoxControl::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException) 649 { 650 return rtl::OUString(); 651 } 652 653 void SAL_CALL SfxToolBoxControl::functionSelected( const ::rtl::OUString& /*aCommand*/ ) throw (::com::sun::star::uno::RuntimeException) 654 { 655 // must be implemented by sub-class 656 } 657 658 void SAL_CALL SfxToolBoxControl::updateImage() throw (::com::sun::star::uno::RuntimeException) 659 { 660 // must be implemented by sub-class 661 } 662 663 // XToolbarController 664 void SAL_CALL SfxToolBoxControl::execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException) 665 { 666 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 667 Select( (sal_uInt16)KeyModifier ); 668 } 669 void SAL_CALL SfxToolBoxControl::click() throw (::com::sun::star::uno::RuntimeException) 670 { 671 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 672 Click(); 673 } 674 675 void SAL_CALL SfxToolBoxControl::doubleClick() throw (::com::sun::star::uno::RuntimeException) 676 { 677 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 678 DoubleClick(); 679 } 680 681 Reference< ::com::sun::star::awt::XWindow > SAL_CALL SfxToolBoxControl::createPopupWindow() throw (::com::sun::star::uno::RuntimeException) 682 { 683 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 684 Window* pWindow = CreatePopupWindow(); 685 if ( pWindow ) 686 return VCLUnoHelper::GetInterface( pWindow ); 687 else 688 return Reference< ::com::sun::star::awt::XWindow >(); 689 } 690 691 Reference< ::com::sun::star::awt::XWindow > SAL_CALL SfxToolBoxControl::createItemWindow( const Reference< ::com::sun::star::awt::XWindow >& rParent ) throw (::com::sun::star::uno::RuntimeException) 692 { 693 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 694 return VCLUnoHelper::GetInterface( CreateItemWindow( VCLUnoHelper::GetWindow( rParent ))); 695 } 696 697 // XDockableWindowListener 698 void SAL_CALL SfxToolBoxControl::startDocking( const ::com::sun::star::awt::DockingEvent& ) 699 throw (::com::sun::star::uno::RuntimeException) 700 { 701 } 702 ::com::sun::star::awt::DockingData SAL_CALL SfxToolBoxControl::docking( const ::com::sun::star::awt::DockingEvent& ) 703 throw (::com::sun::star::uno::RuntimeException) 704 { 705 return ::com::sun::star::awt::DockingData(); 706 } 707 708 void SAL_CALL SfxToolBoxControl::endDocking( const ::com::sun::star::awt::EndDockingEvent& ) 709 throw (::com::sun::star::uno::RuntimeException) 710 { 711 } 712 713 sal_Bool SAL_CALL SfxToolBoxControl::prepareToggleFloatingMode( const ::com::sun::star::lang::EventObject& ) 714 throw (::com::sun::star::uno::RuntimeException) 715 { 716 return sal_False; 717 } 718 719 void SAL_CALL SfxToolBoxControl::toggleFloatingMode( const ::com::sun::star::lang::EventObject& ) 720 throw (::com::sun::star::uno::RuntimeException) 721 { 722 } 723 724 void SAL_CALL SfxToolBoxControl::closed( const ::com::sun::star::lang::EventObject& ) 725 throw (::com::sun::star::uno::RuntimeException) 726 { 727 } 728 729 void SAL_CALL SfxToolBoxControl::endPopupMode( const ::com::sun::star::awt::EndPopupModeEvent& aEvent ) 730 throw (::com::sun::star::uno::RuntimeException) 731 { 732 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 733 734 ::rtl::OUString aSubToolBarResName; 735 if ( pImpl->mxUIElement.is() ) 736 { 737 Reference< XPropertySet > xPropSet( pImpl->mxUIElement, UNO_QUERY ); 738 if ( xPropSet.is() ) 739 { 740 try 741 { 742 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" ))) >>= aSubToolBarResName; 743 } 744 catch ( com::sun::star::beans::UnknownPropertyException& ) 745 { 746 } 747 catch ( com::sun::star::lang::WrappedTargetException& ) 748 { 749 } 750 } 751 752 Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY ); 753 xComponent->dispose(); 754 } 755 pImpl->mxUIElement = 0; 756 757 // if the toolbar was teared-off recreate it and place it at the given position 758 if( aEvent.bTearoff ) 759 { 760 Reference< XUIElement > xUIElement; 761 Reference< XLayoutManager > xLayoutManager = getLayoutManager(); 762 763 if ( !xLayoutManager.is() ) 764 return; 765 766 xLayoutManager->createElement( aSubToolBarResName ); 767 xUIElement = xLayoutManager->getElement( aSubToolBarResName ); 768 if ( xUIElement.is() ) 769 { 770 Reference< ::com::sun::star::awt::XWindow > xParent = getFrameInterface()->getContainerWindow(); 771 772 Reference< ::com::sun::star::awt::XWindow > xSubToolBar( xUIElement->getRealInterface(), UNO_QUERY ); 773 Reference< ::com::sun::star::beans::XPropertySet > xProp( xUIElement, UNO_QUERY ); 774 if ( xSubToolBar.is() && xProp.is() ) 775 { 776 rtl::OUString aPersistentString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" )); 777 try 778 { 779 Window* pTbxWindow = VCLUnoHelper::GetWindow( xSubToolBar ); 780 ToolBox* pToolBar( 0 ); 781 if ( pTbxWindow && pTbxWindow->GetType() == WINDOW_TOOLBOX ) 782 { 783 pToolBar = (ToolBox *)pTbxWindow; 784 785 Any a; 786 a = xProp->getPropertyValue( aPersistentString ); 787 xProp->setPropertyValue( aPersistentString, makeAny( sal_False )); 788 789 xLayoutManager->hideElement( aSubToolBarResName ); 790 xLayoutManager->floatWindow( aSubToolBarResName ); 791 792 xLayoutManager->setElementPos( aSubToolBarResName, aEvent.FloatingPosition ); 793 xLayoutManager->showElement( aSubToolBarResName ); 794 795 xProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" )), a ); 796 } 797 } 798 catch ( ::com::sun::star::uno::RuntimeException& ) 799 { 800 throw; 801 } 802 catch ( ::com::sun::star::uno::Exception& ) 803 { 804 } 805 } 806 } 807 } 808 } 809 810 ::Size SfxToolBoxControl::getPersistentFloatingSize( const Reference< XFrame >& /*xFrame*/, const ::rtl::OUString& /*rSubToolBarResName*/ ) 811 { 812 ::Size aToolboxSize; 813 return aToolboxSize; 814 } 815 816 void SfxToolBoxControl::createAndPositionSubToolBar( const ::rtl::OUString& rSubToolBarResName ) 817 { 818 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 819 820 if ( pImpl->pBox ) 821 { 822 static WeakReference< XUIElementFactory > xWeakUIElementFactory; 823 824 sal_uInt16 nItemId = pImpl->pBox->GetDownItemId(); 825 826 if ( !nItemId ) 827 return; 828 829 // create element with factory 830 Reference< XMultiServiceFactory > xServiceManager = getServiceManager(); 831 Reference< XFrame > xFrame = getFrameInterface(); 832 Reference< XUIElement > xUIElement; 833 Reference< XUIElementFactory > xUIEementFactory; 834 835 xUIEementFactory = xWeakUIElementFactory; 836 if ( !xUIEementFactory.is() ) 837 { 838 xUIEementFactory = Reference< XUIElementFactory >( 839 xServiceManager->createInstance( 840 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 841 "com.sun.star.ui.UIElementFactoryManager" ))), 842 UNO_QUERY ); 843 xWeakUIElementFactory = xUIEementFactory; 844 } 845 846 Sequence< PropertyValue > aPropSeq( 3 ); 847 aPropSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); 848 aPropSeq[0].Value <<= xFrame; 849 aPropSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" )); 850 aPropSeq[1].Value <<= sal_False; 851 aPropSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PopupMode" )); 852 aPropSeq[2].Value <<= sal_True; 853 854 try 855 { 856 xUIElement = xUIEementFactory->createUIElement( rSubToolBarResName, aPropSeq ); 857 } 858 catch ( ::com::sun::star::container::NoSuchElementException& ) 859 { 860 } 861 catch ( IllegalArgumentException& ) 862 { 863 } 864 865 if ( xUIElement.is() ) 866 { 867 Reference< ::com::sun::star::awt::XWindow > xParent = getFrameInterface()->getContainerWindow(); 868 869 Reference< ::com::sun::star::awt::XWindow > xSubToolBar( xUIElement->getRealInterface(), UNO_QUERY ); 870 if ( xSubToolBar.is() ) 871 { 872 Reference< ::com::sun::star::awt::XDockableWindow > xDockWindow( xSubToolBar, UNO_QUERY ); 873 xDockWindow->addDockableWindowListener( Reference< ::com::sun::star::awt::XDockableWindowListener >( 874 static_cast< OWeakObject * >( this ), UNO_QUERY )); 875 xDockWindow->enableDocking( sal_True ); 876 877 // keep refererence to UIElement to avoid its destruction 878 if ( pImpl->mxUIElement.is() ) 879 { 880 Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY ); 881 xComponent->dispose(); 882 } 883 pImpl->mxUIElement = xUIElement; 884 885 Window* pParentTbxWindow( pImpl->pBox ); 886 Window* pTbxWindow = VCLUnoHelper::GetWindow( xSubToolBar ); 887 ToolBox* pToolBar( 0 ); 888 if ( pTbxWindow && pTbxWindow->GetType() == WINDOW_TOOLBOX ) 889 pToolBar = (ToolBox *)pTbxWindow; 890 891 if ( pToolBar ) 892 { 893 pToolBar->SetParent( pParentTbxWindow ); 894 ::Size aSize = getPersistentFloatingSize( xFrame, rSubToolBarResName ); 895 if ( aSize.Width() == 0 || aSize.Height() == 0 ) 896 { 897 // calc and set size for popup mode 898 aSize = pToolBar->CalcPopupWindowSizePixel(); 899 } 900 pToolBar->SetSizePixel( aSize ); 901 902 // open subtoolbox in popup mode 903 Window::GetDockingManager()->StartPopupMode( pImpl->pBox, pToolBar ); 904 } 905 } 906 } 907 } 908 } 909 910 //-------------------------------------------------------------------- 911 912 void SfxToolBoxControl::SetPopupWindow( SfxPopupWindow* pWindow ) 913 { 914 pImpl->mpPopupWindow = pWindow; 915 pImpl->mpPopupWindow->SetPopupModeEndHdl( LINK( this, SfxToolBoxControl, PopupModeEndHdl )); 916 pImpl->mpPopupWindow->SetDeleteLink_Impl( LINK( this, SfxToolBoxControl, ClosePopupWindow )); 917 } 918 919 //-------------------------------------------------------------------- 920 921 IMPL_LINK( SfxToolBoxControl, PopupModeEndHdl, void *, EMPTYARG ) 922 { 923 if ( pImpl->mpPopupWindow->IsVisible() ) 924 { 925 // Replace floating window with popup window and destroy 926 // floating window instance. 927 delete pImpl->mpFloatingWindow; 928 pImpl->mpFloatingWindow = pImpl->mpPopupWindow; 929 pImpl->mpPopupWindow = 0; 930 // We also need to know when the user tries to use the 931 // floating window. 932 pImpl->mpFloatingWindow->AddEventListener( LINK( pImpl, SfxToolBoxControl_Impl, WindowEventListener )); 933 } 934 else 935 { 936 // Popup window has been closed by the user. No replacement, instance 937 // will destroy itself. 938 pImpl->mpPopupWindow = 0; 939 } 940 941 return 1; 942 } 943 944 //-------------------------------------------------------------------- 945 IMPL_LINK( SfxToolBoxControl, ClosePopupWindow, SfxPopupWindow *, pWindow ) 946 { 947 if ( pWindow == pImpl->mpFloatingWindow ) 948 pImpl->mpFloatingWindow = 0; 949 else 950 pImpl->mpPopupWindow = 0; 951 952 return 1; 953 } 954 955 //-------------------------------------------------------------------- 956 957 void SfxToolBoxControl::StateChanged 958 ( 959 sal_uInt16 nId, 960 SfxItemState eState, 961 const SfxPoolItem* pState 962 ) 963 { 964 DBG_MEMTEST(); 965 DBG_ASSERT( pImpl->pBox != 0, "setting state to dangling ToolBox" ); 966 967 if ( GetId() >= SID_OBJECTMENU0 && GetId() <= SID_OBJECTMENU_LAST ) 968 return; 969 970 // enabled/disabled-Flag pauschal korrigieren 971 pImpl->pBox->EnableItem( GetId(), eState != SFX_ITEM_DISABLED ); 972 973 sal_uInt16 nItemBits = pImpl->pBox->GetItemBits( GetId() ); 974 nItemBits &= ~TIB_CHECKABLE; 975 TriState eTri = STATE_NOCHECK; 976 switch ( eState ) 977 { 978 case SFX_ITEM_AVAILABLE: 979 { 980 if ( pState->ISA(SfxBoolItem) ) 981 { 982 // BoolItem fuer checken 983 if ( ((const SfxBoolItem*)pState)->GetValue() ) 984 eTri = STATE_CHECK; 985 nItemBits |= TIB_CHECKABLE; 986 } 987 else if ( pState->ISA(SfxEnumItemInterface) && 988 ((SfxEnumItemInterface *)pState)->HasBoolValue()) 989 { 990 // EnumItem wie Bool behandeln 991 if ( ((const SfxEnumItemInterface *)pState)->GetBoolValue() ) 992 eTri = STATE_CHECK; 993 nItemBits |= TIB_CHECKABLE; 994 } 995 else if ( pImpl->bShowString && pState->ISA(SfxStringItem) ) 996 pImpl->pBox->SetItemText(nId, ((const SfxStringItem*)pState)->GetValue() ); 997 break; 998 } 999 1000 case SFX_ITEM_DONTCARE: 1001 { 1002 eTri = STATE_DONTKNOW; 1003 nItemBits |= TIB_CHECKABLE; 1004 } 1005 } 1006 1007 pImpl->pBox->SetItemState( GetId(), eTri ); 1008 pImpl->pBox->SetItemBits( GetId(), nItemBits ); 1009 } 1010 1011 //-------------------------------------------------------------------- 1012 1013 void SfxToolBoxControl::Select( sal_uInt16 nModifier ) 1014 { 1015 pImpl->nSelectModifier = nModifier; 1016 Select( sal_Bool((nModifier & KEY_MOD1)!=0) ); 1017 } 1018 1019 //-------------------------------------------------------------------- 1020 1021 void SfxToolBoxControl::Select( sal_Bool /*bMod1*/ ) 1022 { 1023 if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# #i102805# 1024 { 1025 ::rtl::OUString sAppName; 1026 try 1027 { 1028 static ::rtl::OUString our_aModuleManagerName = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager"); 1029 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager = 1030 ::comphelper::getProcessServiceFactory(); 1031 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleManager( 1032 xServiceManager->createInstance(our_aModuleManagerName) 1033 , ::com::sun::star::uno::UNO_QUERY_THROW); 1034 sAppName = xModuleManager->identify(m_xFrame); 1035 } catch(::com::sun::star::uno::Exception&) {} 1036 Sequence<PropertyValue> vSource; 1037 ::comphelper::UiEventsLogger::appendDispatchOrigin(vSource, sAppName, ::rtl::OUString::createFromAscii("SfxToolBoxControl")); 1038 URL aURL; 1039 aURL.Complete = m_aCommandURL; 1040 ::comphelper::UiEventsLogger::logDispatch(aURL, vSource); 1041 } 1042 svt::ToolboxController::execute( pImpl->nSelectModifier ); 1043 } 1044 1045 //-------------------------------------------------------------------- 1046 1047 void SfxToolBoxControl::DoubleClick() 1048 { 1049 } 1050 1051 //-------------------------------------------------------------------- 1052 1053 void SfxToolBoxControl::Click() 1054 { 1055 } 1056 1057 //-------------------------------------------------------------------- 1058 1059 SfxPopupWindowType SfxToolBoxControl::GetPopupWindowType() const 1060 { 1061 return SFX_POPUPWINDOW_NONE; 1062 } 1063 1064 //-------------------------------------------------------------------- 1065 1066 SfxPopupWindow* SfxToolBoxControl::CreatePopupWindow() 1067 { 1068 return 0; 1069 } 1070 1071 SfxPopupWindow* SfxToolBoxControl::CreatePopupWindowCascading() 1072 { 1073 return 0; 1074 } 1075 1076 //-------------------------------------------------------------------- 1077 1078 Window* SfxToolBoxControl::CreateItemWindow( Window * ) 1079 { 1080 return 0; 1081 } 1082 1083 //-------------------------------------------------------------------- 1084 1085 SfxFrameStatusListener::SfxFrameStatusListener( 1086 const Reference< XMultiServiceFactory >& rServiceManager, 1087 const Reference< XFrame >& xFrame, 1088 SfxStatusListenerInterface* pCallee ) : 1089 svt::FrameStatusListener( rServiceManager, xFrame ), 1090 m_pCallee( pCallee ) 1091 { 1092 } 1093 1094 //-------------------------------------------------------------------- 1095 1096 SfxFrameStatusListener::~SfxFrameStatusListener() 1097 { 1098 } 1099 1100 //-------------------------------------------------------------------- 1101 1102 // XStatusListener 1103 void SAL_CALL SfxFrameStatusListener::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& rEvent ) 1104 throw ( ::com::sun::star::uno::RuntimeException ) 1105 { 1106 SfxViewFrame* pViewFrame = NULL; 1107 Reference < XController > xController; 1108 1109 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1110 if ( m_xFrame.is() ) 1111 xController = m_xFrame->getController(); 1112 1113 Reference < XDispatchProvider > xProvider( xController, UNO_QUERY ); 1114 if ( xProvider.is() ) 1115 { 1116 Reference < XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, ::rtl::OUString(), 0 ); 1117 if ( xDisp.is() ) 1118 { 1119 Reference< XUnoTunnel > xTunnel( xDisp, UNO_QUERY ); 1120 SfxOfficeDispatch* pDisp = NULL; 1121 if ( xTunnel.is() ) 1122 { 1123 sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier()); 1124 pDisp = reinterpret_cast< SfxOfficeDispatch* >( sal::static_int_cast< sal_IntPtr >( nImplementation )); 1125 } 1126 1127 if ( pDisp ) 1128 pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame(); 1129 } 1130 } 1131 1132 sal_uInt16 nSlotId = 0; 1133 SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( pViewFrame ); 1134 const SfxSlot* pSlot = rPool.GetUnoSlot( rEvent.FeatureURL.Path ); 1135 if ( pSlot ) 1136 nSlotId = pSlot->GetSlotId(); 1137 1138 if ( nSlotId > 0 ) 1139 { 1140 if ( rEvent.Requery ) 1141 { 1142 // requery for the notified state 1143 addStatusListener( rEvent.FeatureURL.Complete ); 1144 } 1145 else 1146 { 1147 SfxItemState eState = SFX_ITEM_DISABLED; 1148 SfxPoolItem* pItem = NULL; 1149 if ( rEvent.IsEnabled ) 1150 { 1151 eState = SFX_ITEM_AVAILABLE; 1152 ::com::sun::star::uno::Type pType = rEvent.State.getValueType(); 1153 1154 if ( pType == ::getVoidCppuType() ) 1155 { 1156 pItem = new SfxVoidItem( nSlotId ); 1157 eState = SFX_ITEM_UNKNOWN; 1158 } 1159 else if ( pType == ::getBooleanCppuType() ) 1160 { 1161 sal_Bool bTemp = false; 1162 rEvent.State >>= bTemp ; 1163 pItem = new SfxBoolItem( nSlotId, bTemp ); 1164 } 1165 else if ( pType == ::getCppuType((const sal_uInt16*)0) ) 1166 { 1167 sal_uInt16 nTemp = 0; 1168 rEvent.State >>= nTemp ; 1169 pItem = new SfxUInt16Item( nSlotId, nTemp ); 1170 } 1171 else if ( pType == ::getCppuType((const sal_uInt32*)0) ) 1172 { 1173 sal_uInt32 nTemp = 0; 1174 rEvent.State >>= nTemp ; 1175 pItem = new SfxUInt32Item( nSlotId, nTemp ); 1176 } 1177 else if ( pType == ::getCppuType((const ::rtl::OUString*)0) ) 1178 { 1179 ::rtl::OUString sTemp ; 1180 rEvent.State >>= sTemp ; 1181 pItem = new SfxStringItem( nSlotId, sTemp ); 1182 } 1183 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::ItemStatus*)0) ) 1184 { 1185 ItemStatus aItemStatus; 1186 rEvent.State >>= aItemStatus; 1187 eState = aItemStatus.State; 1188 pItem = new SfxVoidItem( nSlotId ); 1189 } 1190 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::Visibility*)0) ) 1191 { 1192 Visibility aVisibilityStatus; 1193 rEvent.State >>= aVisibilityStatus; 1194 pItem = new SfxVisibilityItem( nSlotId, aVisibilityStatus.bVisible ); 1195 } 1196 else 1197 { 1198 if ( pSlot ) 1199 pItem = pSlot->GetType()->CreateItem(); 1200 if ( pItem ) 1201 { 1202 pItem->SetWhich( nSlotId ); 1203 pItem->PutValue( rEvent.State ); 1204 } 1205 else 1206 pItem = new SfxVoidItem( nSlotId ); 1207 } 1208 } 1209 1210 if ( m_pCallee ) 1211 m_pCallee->StateChanged( nSlotId, eState, pItem ); 1212 delete pItem; 1213 } 1214 } 1215 } 1216 1217 //-------------------------------------------------------------------- 1218 1219 SfxPopupWindow::SfxPopupWindow( 1220 sal_uInt16 nId, 1221 const Reference< XFrame >& rFrame, 1222 WinBits nBits ) : 1223 FloatingWindow( SFX_APP()->GetTopWindow(), nBits ) 1224 , m_bFloating(sal_False) 1225 , m_bCascading( sal_False ) 1226 , m_nId( nId ) 1227 , m_xFrame( rFrame ) 1228 , m_pStatusListener( 0 ) 1229 { 1230 m_xServiceManager = ::comphelper::getProcessServiceFactory(); 1231 1232 Window* pWindow = GetTopMostParentSystemWindow( this ); 1233 if ( pWindow ) 1234 ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this ); 1235 } 1236 1237 //-------------------------------------------------------------------- 1238 1239 SfxPopupWindow::SfxPopupWindow( 1240 sal_uInt16 nId, 1241 const Reference< XFrame >& rFrame, 1242 const ResId &rId ) : 1243 FloatingWindow( SFX_APP()->GetTopWindow(), rId ) 1244 , m_bFloating(sal_False) 1245 , m_bCascading( sal_False ) 1246 , m_nId( nId ) 1247 , m_xFrame( rFrame ) 1248 , m_pStatusListener( 0 ) 1249 { 1250 m_xServiceManager = ::comphelper::getProcessServiceFactory(); 1251 1252 Window* pWindow = GetTopMostParentSystemWindow( this ); 1253 if ( pWindow ) 1254 ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this ); 1255 } 1256 1257 //-------------------------------------------------------------------- 1258 1259 SfxPopupWindow::SfxPopupWindow( 1260 sal_uInt16 nId, 1261 const Reference< XFrame >& rFrame, 1262 Window* pParentWindow, 1263 WinBits nBits ) : 1264 FloatingWindow( pParentWindow, nBits ) 1265 , m_bFloating(sal_False) 1266 , m_bCascading( sal_False ) 1267 , m_nId( nId ) 1268 , m_xFrame( rFrame ) 1269 , m_pStatusListener( 0 ) 1270 { 1271 m_xServiceManager = ::comphelper::getProcessServiceFactory(); 1272 1273 Window* pWindow = GetTopMostParentSystemWindow( this ); 1274 if ( pWindow ) 1275 ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this ); 1276 } 1277 1278 //-------------------------------------------------------------------- 1279 1280 SfxPopupWindow::SfxPopupWindow( 1281 sal_uInt16 nId, 1282 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, 1283 Window* pParentWindow, 1284 const ResId &rId ) : 1285 FloatingWindow( pParentWindow, rId ) 1286 , m_bFloating(sal_False) 1287 , m_bCascading( sal_False ) 1288 , m_nId( nId ) 1289 , m_xFrame( rFrame ) 1290 , m_pStatusListener( 0 ) 1291 { 1292 m_xServiceManager = ::comphelper::getProcessServiceFactory(); 1293 1294 Window* pWindow = GetTopMostParentSystemWindow( this ); 1295 if ( pWindow ) 1296 ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this ); 1297 } 1298 1299 //-------------------------------------------------------------------- 1300 1301 SfxPopupWindow::~SfxPopupWindow() 1302 { 1303 if ( m_xStatusListener.is() ) 1304 { 1305 m_xStatusListener->dispose(); 1306 m_xStatusListener.clear(); 1307 } 1308 1309 Window* pWindow = GetTopMostParentSystemWindow( this ); 1310 if ( pWindow ) 1311 ((SystemWindow *)pWindow)->GetTaskPaneList()->RemoveWindow( this ); 1312 } 1313 1314 //-------------------------------------------------------------------- 1315 1316 SfxFrameStatusListener* SfxPopupWindow::GetOrCreateStatusListener() 1317 { 1318 if ( !m_xStatusListener.is() ) 1319 { 1320 m_pStatusListener = new SfxFrameStatusListener( 1321 m_xServiceManager, 1322 m_xFrame, 1323 this ); 1324 m_xStatusListener = Reference< XComponent >( static_cast< cppu::OWeakObject* >( 1325 m_pStatusListener ), UNO_QUERY ); 1326 } 1327 1328 return m_pStatusListener; 1329 } 1330 1331 //-------------------------------------------------------------------- 1332 1333 void SfxPopupWindow::BindListener() 1334 { 1335 GetOrCreateStatusListener(); 1336 if ( m_xStatusListener.is() ) 1337 m_pStatusListener->bindListener(); 1338 } 1339 1340 //-------------------------------------------------------------------- 1341 1342 void SfxPopupWindow::UnbindListener() 1343 { 1344 GetOrCreateStatusListener(); 1345 if ( m_xStatusListener.is() ) 1346 m_pStatusListener->unbindListener(); 1347 } 1348 1349 //-------------------------------------------------------------------- 1350 1351 void SfxPopupWindow::AddStatusListener( const rtl::OUString& rCommandURL ) 1352 { 1353 GetOrCreateStatusListener(); 1354 if ( m_xStatusListener.is() ) 1355 m_pStatusListener->addStatusListener( rCommandURL ); 1356 } 1357 1358 //-------------------------------------------------------------------- 1359 1360 void SfxPopupWindow::RemoveStatusListener( const rtl::OUString& rCommandURL ) 1361 { 1362 GetOrCreateStatusListener(); 1363 if ( m_xStatusListener.is() ) 1364 m_pStatusListener->removeStatusListener( rCommandURL ); 1365 } 1366 1367 //-------------------------------------------------------------------- 1368 1369 void SfxPopupWindow::UpdateStatus( const rtl::OUString& rCommandURL ) 1370 { 1371 GetOrCreateStatusListener(); 1372 if ( m_xStatusListener.is() ) 1373 m_pStatusListener->updateStatus( rCommandURL ); 1374 } 1375 1376 //-------------------------------------------------------------------- 1377 1378 sal_Bool SfxPopupWindow::Close() 1379 { 1380 m_bFloating = sal_False; 1381 FloatingWindow::Close(); 1382 1383 Delete(0); 1384 return sal_True; 1385 } 1386 1387 //-------------------------------------------------------------------- 1388 1389 void SfxPopupWindow::PopupModeEnd() 1390 { 1391 //! to allow PopupModeEndHdl to be called 1392 FloatingWindow::PopupModeEnd(); 1393 1394 if ( IsVisible() ) 1395 { 1396 // wurde abgerissen 1397 DeleteFloatingWindow(); 1398 m_bFloating = sal_True; 1399 } 1400 else 1401 Close(); 1402 } 1403 1404 //-------------------------------------------------------------------- 1405 1406 void SfxPopupWindow::DeleteFloatingWindow() 1407 { 1408 if ( m_bFloating ) 1409 { 1410 Hide(); 1411 Delete(0); 1412 } 1413 } 1414 1415 //-------------------------------------------------------------------- 1416 1417 void SfxPopupWindow::MouseMove( const ::MouseEvent& rMEvt ) 1418 { 1419 if ( m_bCascading == sal_False ) 1420 FloatingWindow::MouseMove( rMEvt ); 1421 else 1422 { 1423 // MouseMove-Event an die Children forwarden 1424 ::Point aPos = rMEvt.GetPosPixel(); 1425 ::Point aScrPos = OutputToScreenPixel( aPos ); 1426 sal_uInt16 i = 0; 1427 Window* pWindow = GetChild( i ); 1428 while ( pWindow ) 1429 { 1430 ::MouseEvent aMEvt( pWindow->ScreenToOutputPixel( aScrPos ), 1431 rMEvt.GetClicks(), rMEvt.GetMode(), 1432 rMEvt.GetButtons(), rMEvt.GetModifier() ); 1433 pWindow->MouseMove( rMEvt ); 1434 pWindow->Update(); 1435 i++; 1436 pWindow = GetChild( i ); 1437 } 1438 } 1439 } 1440 1441 //-------------------------------------------------------------------- 1442 1443 void SfxPopupWindow::StartCascading() 1444 { 1445 m_bCascading= sal_True; 1446 } 1447 1448 void SfxPopupWindow::EndCascading() 1449 { 1450 m_bCascading = sal_False; 1451 } 1452 1453 //-------------------------------------------------------------------- 1454 1455 SfxPopupWindow* SfxPopupWindow::Clone() const 1456 1457 /* [Beschreibung] 1458 1459 Diese Methode mu\s "uberladen werden, um dieses Popup auch im 1460 Presentations-Modus anzuzeigen. Sie wird gerufen, wenn ein Show() 1461 sinnlos w"are, da der Parent nicht das Presentations-Window ist. 1462 Beim neu erzeugen wird automatisch das neue Top-Window verwendet, so 1463 da\s der Parent das Presentations-Window ist und das neue Popup somit 1464 sichtbar ist. 1465 */ 1466 1467 { 1468 return 0; 1469 } 1470 1471 //-------------------------------------------------------------------- 1472 1473 void SfxPopupWindow::StateChanged( 1474 sal_uInt16 /*nSID*/, 1475 SfxItemState eState, 1476 const SfxPoolItem* /*pState*/ ) 1477 /* [Bescheibung] 1478 1479 Siehe auch <SfxControllerItem::StateChanged()>. Au\serdem wird 1480 bei eState==SFX_ITEM_DISABLED das Popup gehided und in allen anderen 1481 F"allen, falls es floating ist, wieder angezeigt. Daher mu\s die 1482 Basisklasse i.d.R. gerufen werden. 1483 1484 Es findet wegen des Parents eine Sonderbehandlung f"ur den 1485 Presentationsmodus statt. 1486 1487 */ 1488 1489 { 1490 if ( SFX_ITEM_DISABLED == eState ) 1491 { 1492 Hide(); 1493 } 1494 else if ( m_bFloating ) 1495 { 1496 Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE ); 1497 } 1498 } 1499 1500 //-------------------------------------------------------------------- 1501 1502 IMPL_LINK( SfxPopupWindow, Delete, void *, EMPTYARG ) 1503 { 1504 if ( m_aDeleteLink.IsSet() ) 1505 m_aDeleteLink.Call( this ); 1506 delete this; 1507 return 0; 1508 } 1509 1510 //-------------------------------------------------------------------- 1511 1512