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 #include <com/sun/star/uno/Reference.hxx> 27 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 28 #include <com/sun/star/lang/IllegalArgumentException.hpp> 29 #include <com/sun/star/frame/DispatchResultEvent.hpp> 30 #include <com/sun/star/frame/DispatchResultState.hpp> 31 #include <com/sun/star/task/XJobExecutor.hpp> 32 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 33 #include <com/sun/star/frame/XDesktop.hpp> 34 #include <com/sun/star/frame/XDispatchHelper.hpp> 35 #include <com/sun/star/frame/XFramesSupplier.hpp> 36 #include <com/sun/star/util/XCloseable.hpp> 37 #include <com/sun/star/util/CloseVetoException.hpp> 38 #include <com/sun/star/frame/XLayoutManager.hpp> 39 #include <com/sun/star/document/XEmbeddedScripts.hpp> 40 #include <com/sun/star/embed/XStorage.hpp> 41 #include <com/sun/star/embed/ElementModes.hpp> 42 #include <com/sun/star/system/XSystemShellExecute.hpp> 43 #include <com/sun/star/system/SystemShellExecuteFlags.hpp> 44 #include <com/sun/star/system/SystemShellExecuteException.hpp> 45 46 #include <comphelper/processfactory.hxx> 47 #include <comphelper/storagehelper.hxx> 48 #include "comphelper/configurationhelper.hxx" 49 50 #include <svtools/addresstemplate.hxx> 51 #include <svl/visitem.hxx> 52 #include <unotools/intlwrapper.hxx> 53 54 #include <unotools/configmgr.hxx> 55 #include <tools/config.hxx> 56 #include <tools/diagnose_ex.h> 57 #include <vcl/msgbox.hxx> 58 #include <svl/intitem.hxx> 59 #include <svl/eitem.hxx> 60 #include <svl/stritem.hxx> 61 #include <basic/sbstar.hxx> 62 #include <basic/basmgr.hxx> 63 #include <basic/basrdll.hxx> 64 #include <svtools/sfxecode.hxx> 65 #include <svtools/ehdl.hxx> 66 #include <vcl/help.hxx> 67 #include <vcl/stdtext.hxx> 68 #include <rtl/ustrbuf.hxx> 69 70 #include <unotools/pathoptions.hxx> 71 #include <unotools/moduleoptions.hxx> 72 #include <svtools/helpopt.hxx> 73 #include <toolkit/helper/vclunohelper.hxx> 74 #include <tools/shl.hxx> 75 #include <unotools/bootstrap.hxx> 76 #include <vos/process.hxx> 77 #include <rtl/bootstrap.hxx> 78 #include <cppuhelper/exc_hlp.hxx> 79 #include <rtl/ustrbuf.hxx> 80 81 #include <com/sun/star/script/provider/XScriptProviderFactory.hpp> 82 #include <com/sun/star/frame/XModuleManager.hpp> 83 #include <com/sun/star/beans/XPropertySet.hpp> 84 85 #include "frmload.hxx" 86 #include "referers.hxx" 87 #include <sfx2/app.hxx> 88 #include <sfx2/request.hxx> 89 #include <sfx2/dispatch.hxx> 90 #include <sfx2/bindings.hxx> 91 #include <sfx2/msg.hxx> 92 #include <sfx2/objface.hxx> 93 #include <sfx2/objitem.hxx> 94 #include <sfx2/objsh.hxx> 95 #include <sfx2/hintpost.hxx> 96 #include <sfx2/viewsh.hxx> 97 #include <sfx2/docfac.hxx> 98 #include <sfx2/docfile.hxx> 99 #include <sfx2/docfilt.hxx> 100 #include "docvor.hxx" 101 #include <sfx2/new.hxx> 102 #include <sfx2/templdlg.hxx> 103 #include "sfxtypes.hxx" 104 #include <sfx2/tabdlg.hxx> 105 #include "arrdecl.hxx" 106 #include "fltfnc.hxx" 107 #include <sfx2/sfx.hrc> 108 #include "app.hrc" 109 #include <sfx2/passwd.hxx> 110 #include "sfx2/sfxresid.hxx" 111 #include "arrdecl.hxx" 112 #include <sfx2/childwin.hxx> 113 #include "appdata.hxx" 114 #include "sfx2/minfitem.hxx" 115 #include <sfx2/event.hxx> 116 #include <sfx2/module.hxx> 117 #include <sfx2/viewfrm.hxx> 118 #include "sfxpicklist.hxx" 119 #include "imestatuswindow.hxx" 120 #include <sfx2/sfxdlg.hxx> 121 #include <sfx2/dialogs.hrc> 122 #include "sorgitm.hxx" 123 #include "sfx2/sfxhelp.hxx" 124 #include <tools/svlibrary.hxx> 125 126 using namespace ::com::sun::star; 127 using namespace ::com::sun::star::beans; 128 using namespace ::com::sun::star::uno; 129 using namespace ::com::sun::star::frame; 130 using namespace ::com::sun::star::container; 131 using namespace ::com::sun::star::util; 132 using namespace ::com::sun::star::script; 133 using namespace ::com::sun::star::system; 134 using namespace ::com::sun::star::lang; 135 using namespace ::com::sun::star::document; 136 137 namespace css = com::sun::star; 138 139 //------------------------------------------------------------------------- 140 long QuitAgain_Impl( void* pObj, void* pArg ) 141 { 142 SfxApplication* pApp = (SfxApplication*)pObj; 143 Timer* pTimer = (Timer*)pArg; 144 delete pTimer; 145 pApp->GetDispatcher_Impl()->Execute( SID_QUITAPP, SFX_CALLMODE_ASYNCHRON ); 146 return 0; 147 } 148 149 void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) 150 { 151 DBG_MEMTEST(); 152 bool bDone = sal_False; 153 switch ( rReq.GetSlot() ) 154 { 155 case SID_SETOPTIONS: 156 { 157 if( rReq.GetArgs() ) 158 SetOptions_Impl( *rReq.GetArgs() ); 159 break; 160 } 161 162 case SID_QUITAPP: 163 case SID_EXITANDRETURN: 164 case SID_LOGOUT: 165 { 166 // protect against reentrant calls 167 if ( pAppData_Impl->bInQuit ) 168 return; 169 170 if ( rReq.GetSlot() == SID_LOGOUT ) 171 { 172 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst(); 173 pObjSh; pObjSh = SfxObjectShell::GetNext( *pObjSh ) ) 174 { 175 if ( !pObjSh->IsModified() ) 176 continue; 177 178 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pObjSh ); 179 if ( !pFrame || !pFrame->GetWindow().IsReallyVisible() ) 180 continue; 181 182 if ( pObjSh->PrepareClose(2) ) 183 pObjSh->SetModified( sal_False ); 184 else 185 return; 186 } 187 188 String aName = String::CreateFromAscii("vnd.sun.star.cmd:logout"); 189 SfxStringItem aNameItem( SID_FILE_NAME, aName ); 190 SfxStringItem aReferer( SID_REFERER, DEFINE_CONST_UNICODE( "private/user" ) ); 191 pAppData_Impl->pAppDispat->Execute( SID_OPENDOC, SFX_CALLMODE_SLOT, &aNameItem, &aReferer, 0L ); 192 return; 193 } 194 195 // aus verschachtelten Requests nach 100ms nochmal probieren 196 if( Application::GetDispatchLevel() > 1 ) 197 { 198 /* Dont save the request for closing the application and try it later 199 again. This is an UI bound functionality ... and the user will try it again 200 if the dialog is closed. But we shouldnt close the application automaticly 201 if this dialog is closed by the user ... 202 So we ignore this request now and wait for a new user decision. 203 */ 204 DBG_TRACE1( "QueryExit => FALSE (DispatchLevel == %u)", Application::GetDispatchLevel() ); 205 return; 206 } 207 208 // block reentrant calls 209 pAppData_Impl->bInQuit = sal_True; 210 Reference < XDesktop > xDesktop ( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY ); 211 212 rReq.ForgetAllArgs(); 213 214 // if terminate() failed, pAppData_Impl->bInQuit will now be sal_False, allowing further calls of SID_QUITAPP 215 sal_Bool bTerminated = xDesktop->terminate(); 216 if (!bTerminated) 217 // if terminate() was successful, SfxApplication is now dead! 218 pAppData_Impl->bInQuit = sal_False; 219 220 // Returnwert setzten, ggf. terminieren 221 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bTerminated ) ); 222 return; 223 } 224 225 case SID_CONFIG: 226 case SID_TOOLBOXOPTIONS: 227 case SID_CONFIGSTATUSBAR: 228 case SID_CONFIGMENU: 229 case SID_CONFIGACCEL: 230 case SID_CONFIGEVENT: 231 { 232 SfxAbstractDialogFactory* pFact = 233 SfxAbstractDialogFactory::Create(); 234 235 if ( pFact ) 236 { 237 SFX_REQUEST_ARG(rReq, pStringItem, 238 SfxStringItem, SID_CONFIG, sal_False); 239 240 SfxItemSet aSet( 241 GetPool(), SID_CONFIG, SID_CONFIG ); 242 243 if ( pStringItem ) 244 { 245 aSet.Put( SfxStringItem( 246 SID_CONFIG, pStringItem->GetValue() ) ); 247 } 248 249 Reference< XFrame > xFrame; 250 const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl(); 251 SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False ); 252 if ( pFrameItem ) 253 xFrame = pFrameItem->GetFrame(); 254 255 SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( 256 RID_SVXDLG_CUSTOMIZE, 257 NULL, &aSet, xFrame ); 258 259 if ( pDlg ) 260 { 261 const short nRet = pDlg->Execute(); 262 263 if ( nRet ) 264 bDone = sal_True; 265 266 delete pDlg; 267 } 268 } 269 break; 270 } 271 272 case SID_CLOSEDOCS: 273 case SID_CLOSEWINS: 274 { 275 276 Reference < XFramesSupplier > xDesktop ( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY ); 277 Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY ); 278 if ( !xTasks.is() ) 279 break; 280 281 sal_Int32 n=0; 282 do 283 { 284 if ( xTasks->getCount() <= n ) 285 break; 286 287 Any aAny = xTasks->getByIndex(n); 288 Reference < XCloseable > xTask; 289 aAny >>= xTask; 290 try 291 { 292 xTask->close(sal_True); 293 n++; 294 } 295 catch( CloseVetoException& ) 296 { 297 } 298 } 299 while( sal_True ); 300 301 sal_Bool bOk = ( n == 0); 302 rReq.SetReturnValue( SfxBoolItem( 0, bOk ) ); 303 bDone = sal_True; 304 break; 305 } 306 307 case SID_SAVEDOCS: 308 { 309 sal_Bool bOK = sal_True; 310 sal_Bool bTmpDone = sal_True; 311 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst(); 312 pObjSh; 313 pObjSh = SfxObjectShell::GetNext( *pObjSh ) ) 314 { 315 SfxRequest aReq( SID_SAVEDOC, 0, pObjSh->GetPool() ); 316 if ( pObjSh->IsModified() ) 317 { 318 pObjSh->ExecuteSlot( aReq ); 319 SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, aReq.GetReturnValue() ); 320 bTmpDone = aReq.IsDone(); 321 if ( !pItem || !pItem->GetValue() ) 322 bOK = sal_False; 323 } 324 } 325 326 rReq.SetReturnValue( SfxBoolItem( 0, bOK ) ); 327 rReq.Done(); 328 break; 329 } 330 331 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332 case SID_HELPINDEX: 333 case SID_HELP_SUPPORTPAGE: 334 { 335 Help* pHelp = Application::GetHelp(); 336 if ( pHelp ) 337 { 338 if ( rReq.GetSlot() == SID_HELP_SUPPORTPAGE ) 339 { 340 // show Support page with new URL 341 String sHelpURL = SfxHelp::CreateHelpURL( String::CreateFromAscii(".uno:HelpSupport"), String() ); 342 String sParams = sHelpURL.Copy( sHelpURL.Search( '?' ) ); 343 sHelpURL = String::CreateFromAscii("vnd.sun.star.help://shared/text/shared/05/00000001.xhp"); 344 sHelpURL += sParams; 345 sHelpURL += String::CreateFromAscii("&UseDB=no"); 346 pHelp->Start( sHelpURL, NULL ); 347 } 348 else 349 pHelp->Start( String::CreateFromAscii(".uno:HelpIndex"), NULL ); // show start page 350 bDone = sal_True; 351 } 352 break; 353 } 354 355 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356 case SID_HELPTIPS: 357 { 358 // Parameter aus werten 359 SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPTIPS, sal_False); 360 bool bOn = pOnItem 361 ? ((SfxBoolItem*)pOnItem)->GetValue() 362 : !Help::IsQuickHelpEnabled(); 363 364 // ausf"uhren 365 if ( bOn ) 366 Help::EnableQuickHelp(); 367 else 368 Help::DisableQuickHelp(); 369 SvtHelpOptions().SetHelpTips( bOn ); 370 Invalidate(SID_HELPTIPS); 371 bDone = sal_True; 372 373 // ggf. recorden 374 if ( !rReq.IsAPI() ) 375 rReq.AppendItem( SfxBoolItem( SID_HELPTIPS, bOn) ); 376 break; 377 } 378 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 379 case SID_EXTENDEDHELP: 380 { 381 Help::StartExtHelp(); 382 break; 383 } 384 case SID_HELPBALLOONS: 385 { 386 // Parameter auswerten 387 SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPBALLOONS, sal_False); 388 bool bOn = pOnItem 389 ? ((SfxBoolItem*)pOnItem)->GetValue() 390 : !Help::IsBalloonHelpEnabled(); 391 392 // ausf"uhren 393 if ( bOn ) 394 Help::EnableBalloonHelp(); 395 else 396 Help::DisableBalloonHelp(); 397 SvtHelpOptions().SetExtendedHelp( bOn ); 398 Invalidate(SID_HELPBALLOONS); 399 bDone = sal_True; 400 401 // ggf. recorden 402 if ( !rReq.IsAPI() ) 403 rReq.AppendItem( SfxBoolItem( SID_HELPBALLOONS, bOn) ); 404 break; 405 } 406 407 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 408 case SID_HELP_PI: 409 { 410 SvtHelpOptions aHelpOpt; 411 SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELP_PI, sal_False); 412 sal_Bool bOn = pOnItem 413 ? ((SfxBoolItem*)pOnItem)->GetValue() 414 : !aHelpOpt.IsHelpAgentAutoStartMode(); 415 aHelpOpt.SetHelpAgentAutoStartMode( bOn ); 416 Invalidate(SID_HELP_PI); 417 bDone = sal_True; 418 break; 419 } 420 421 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 422 case SID_ABOUT: 423 { 424 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 425 if ( pFact ) 426 { 427 VclAbstractDialog* pDlg = pFact->CreateVclDialog( 0, RID_DEFAULTABOUT ); 428 pDlg->Execute(); 429 delete pDlg; 430 bDone = sal_True; 431 } 432 break; 433 } 434 435 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 436 case SID_ORGANIZER: 437 { 438 SfxTemplateOrganizeDlg *pDlg = 439 new SfxTemplateOrganizeDlg(NULL); 440 pDlg->Execute(); 441 delete pDlg; 442 bDone = sal_True; 443 break; 444 } 445 446 case SID_TEMPLATE_ADDRESSBOKSOURCE: 447 { 448 svt::AddressBookSourceDialog aDialog(GetTopWindow(), ::comphelper::getProcessServiceFactory()); 449 aDialog.Execute(); 450 bDone = sal_True; 451 break; 452 } 453 454 case SID_BASICSTOP: 455 StarBASIC::Stop(); 456 break; 457 458 case SID_BASICBREAK : 459 BASIC_DLL()->BasicBreak(); 460 break; 461 462 case SID_CRASH : 463 { 464 // Provoke a crash: 465 char * crash = 0; 466 *crash = 0; 467 break; 468 } 469 470 case SID_SHOW_IME_STATUS_WINDOW: 471 if (pAppData_Impl->m_xImeStatusWindow->canToggle()) 472 { 473 SfxBoolItem const * pItem = static_cast< SfxBoolItem const * >( 474 rReq.GetArg(SID_SHOW_IME_STATUS_WINDOW, false, 475 TYPE(SfxBoolItem))); 476 bool bShow = pItem == 0 477 ? !pAppData_Impl->m_xImeStatusWindow->isShowing() 478 : ( pItem->GetValue() == sal_True ); 479 pAppData_Impl->m_xImeStatusWindow->show(bShow); 480 if (pItem == 0) 481 rReq.AppendItem(SfxBoolItem(SID_SHOW_IME_STATUS_WINDOW, 482 bShow)); 483 } 484 bDone = true; 485 break; 486 487 case SID_AVAILABLE_TOOLBARS: 488 { 489 SfxStringItem const * pToolbarName = static_cast< SfxStringItem const *>( 490 rReq.GetArg(SID_AVAILABLE_TOOLBARS, false, TYPE(SfxStringItem))); 491 492 if ( pToolbarName ) 493 { 494 com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame; 495 Reference < XFramesSupplier > xDesktop ( ::comphelper::getProcessServiceFactory()->createInstance( 496 DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY ); 497 xFrame = xDesktop->getActiveFrame(); 498 499 Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY ); 500 Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; 501 if ( xPropSet.is() ) 502 { 503 try 504 { 505 Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))); 506 aValue >>= xLayoutManager; 507 } 508 catch ( ::com::sun::star::uno::RuntimeException& e ) 509 { 510 throw e; 511 } 512 catch ( ::com::sun::star::uno::Exception& ) 513 { 514 } 515 } 516 517 if ( xLayoutManager.is() ) 518 { 519 rtl::OUString aToolbarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/" )); 520 rtl::OUStringBuffer aBuf( aToolbarResName ); 521 aBuf.append( pToolbarName->GetValue() ); 522 523 // Parameter auswerten 524 rtl::OUString aToolbarName( aBuf.makeStringAndClear() ); 525 sal_Bool bShow( !xLayoutManager->isElementVisible( aToolbarName )); 526 527 if ( bShow ) 528 { 529 xLayoutManager->createElement( aToolbarName ); 530 xLayoutManager->showElement( aToolbarName ); 531 } 532 else 533 xLayoutManager->hideElement( aToolbarName ); 534 } 535 } 536 537 bDone = true; 538 break; 539 } 540 541 default: 542 break; 543 } 544 545 if ( bDone ) 546 rReq.Done(); 547 } 548 549 //-------------------------------------------------------------------- 550 551 void SfxApplication::MiscState_Impl(SfxItemSet &rSet) 552 { 553 DBG_MEMTEST(); 554 555 LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() ); 556 const sal_uInt16 *pRanges = rSet.GetRanges(); 557 DBG_ASSERT(pRanges && *pRanges, "Set ohne Bereich"); 558 while ( *pRanges ) 559 { 560 for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich) 561 { 562 switch(nWhich) 563 { 564 case SID_TEMPLATE_ADDRESSBOKSOURCE: 565 if ( !SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE) ) 566 rSet.Put(SfxVisibilityItem(nWhich, sal_False)); 567 break; 568 case SID_EXITANDRETURN: 569 case SID_QUITAPP: 570 { 571 if ( pAppData_Impl->nDocModalMode ) 572 rSet.DisableItem(nWhich); 573 else 574 rSet.Put(SfxStringItem(nWhich, String(SfxResId(STR_QUITAPP)))); 575 break; 576 } 577 578 case SID_BASICSTOP: 579 if ( !StarBASIC::IsRunning() ) 580 rSet.DisableItem(nWhich); 581 break; 582 583 case SID_HELPTIPS: 584 { 585 rSet.Put( SfxBoolItem( SID_HELPTIPS, Help::IsQuickHelpEnabled() ) ); 586 } 587 break; 588 case SID_HELPBALLOONS: 589 { 590 rSet.Put( SfxBoolItem( SID_HELPBALLOONS, Help::IsBalloonHelpEnabled() ) ); 591 } 592 break; 593 case SID_HELP_PI: 594 { 595 rSet.Put( SfxBoolItem( SID_HELP_PI, SvtHelpOptions().IsHelpAgentAutoStartMode() ) ); 596 } 597 break; 598 599 case SID_EXTENDEDHELP: 600 { 601 } 602 break; 603 604 case SID_CLOSEDOCS: 605 case SID_CLOSEWINS: 606 { 607 Reference < XFramesSupplier > xDesktop ( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY ); 608 Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY ); 609 if ( !xTasks.is() || !xTasks->getCount() ) 610 rSet.DisableItem(nWhich); 611 break; 612 } 613 614 case SID_SAVEDOCS: 615 { 616 sal_Bool bModified = sal_False; 617 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst(); 618 pObjSh; 619 pObjSh = SfxObjectShell::GetNext( *pObjSh ) ) 620 { 621 if ( pObjSh->IsModified() ) 622 { 623 bModified = sal_True; 624 break; 625 } 626 } 627 628 if ( !bModified ) 629 rSet.DisableItem( nWhich ); 630 break; 631 } 632 633 case SID_SHOW_IME_STATUS_WINDOW: 634 if (pAppData_Impl->m_xImeStatusWindow->canToggle()) 635 rSet.Put(SfxBoolItem( 636 SID_SHOW_IME_STATUS_WINDOW, 637 pAppData_Impl->m_xImeStatusWindow-> 638 isShowing())); 639 else 640 rSet.DisableItem(SID_SHOW_IME_STATUS_WINDOW); 641 break; 642 643 default: 644 break; 645 } 646 } 647 648 ++pRanges; 649 } 650 } 651 652 typedef rtl_uString* (SAL_CALL *basicide_choose_macro)(XModel*, sal_Bool, rtl_uString*); 653 typedef void (SAL_CALL *basicide_macro_organizer)( sal_Int16 ); 654 655 #define DOSTRING( x ) #x 656 #define STRING( x ) DOSTRING( x ) 657 658 extern "C" { static void SAL_CALL thisModule() {} } 659 660 ::rtl::OUString ChooseMacro( const Reference< XModel >& rxLimitToDocument, sal_Bool bChooseOnly, const ::rtl::OUString& rMacroDesc = ::rtl::OUString() ) 661 { 662 // get basctl dllname 663 static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) ); 664 665 // load module 666 oslModule handleMod = osl_loadModuleRelative( 667 &thisModule, aLibName.pData, 0 ); 668 669 // get symbol 670 ::rtl::OUString aSymbol( RTL_CONSTASCII_USTRINGPARAM( "basicide_choose_macro" ) ); 671 basicide_choose_macro pSymbol = (basicide_choose_macro) osl_getFunctionSymbol( handleMod, aSymbol.pData ); 672 673 // call basicide_choose_macro in basctl 674 rtl_uString* pScriptURL = pSymbol( rxLimitToDocument.get(), bChooseOnly, rMacroDesc.pData ); 675 ::rtl::OUString aScriptURL( pScriptURL ); 676 rtl_uString_release( pScriptURL ); 677 return aScriptURL; 678 } 679 680 void MacroOrganizer( sal_Int16 nTabId ) 681 { 682 // get basctl dllname 683 static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) ); 684 685 // load module 686 oslModule handleMod = osl_loadModuleRelative( 687 &thisModule, aLibName.pData, 0 ); 688 689 // get symbol 690 ::rtl::OUString aSymbol( RTL_CONSTASCII_USTRINGPARAM( "basicide_macro_organizer" ) ); 691 basicide_macro_organizer pSymbol = (basicide_macro_organizer) osl_getFunctionSymbol( handleMod, aSymbol.pData ); 692 693 // call basicide_macro_organizer in basctl 694 pSymbol( nTabId ); 695 } 696 697 #define RID_ERRBOX_MODULENOTINSTALLED (RID_OFA_START + 72) 698 699 ResMgr* SfxApplication::GetOffResManager_Impl() 700 { 701 if ( !pAppData_Impl->pOfaResMgr ) 702 pAppData_Impl->pOfaResMgr = CreateResManager( "ofa"); 703 return pAppData_Impl->pOfaResMgr; 704 } 705 706 namespace 707 { 708 Window* lcl_getDialogParent( const Reference< XFrame >& _rxFrame, Window* _pFallback ) 709 { 710 if ( !_rxFrame.is() ) 711 return _pFallback; 712 713 try 714 { 715 Reference< awt::XWindow > xContainerWindow( _rxFrame->getContainerWindow(), UNO_SET_THROW ); 716 Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow ); 717 OSL_ENSURE( pWindow, "lcl_getDialogParent: cool, somebody implemented a VCL-less toolkit!" ); 718 719 if ( pWindow ) 720 return pWindow->GetSystemWindow(); 721 } 722 catch( const Exception& ) 723 { 724 DBG_UNHANDLED_EXCEPTION(); 725 } 726 return _pFallback; 727 } 728 729 const ::rtl::OUString& lcl_getBasicIDEServiceName() 730 { 731 static const ::rtl::OUString s_sBasicName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.BasicIDE" ) ); 732 return s_sBasicName; 733 } 734 735 SfxViewFrame* lcl_getBasicIDEViewFrame( SfxObjectShell* i_pBasicIDE ) 736 { 737 SfxViewFrame* pView = SfxViewFrame::GetFirst( i_pBasicIDE ); 738 while ( pView ) 739 { 740 if ( pView->GetObjectShell()->GetFactory().GetDocumentServiceName() == lcl_getBasicIDEServiceName() ) 741 break; 742 pView = SfxViewFrame::GetNext( *pView, i_pBasicIDE ); 743 } 744 return pView; 745 } 746 Reference< XFrame > lcl_findStartModuleFrame( const ::comphelper::ComponentContext& i_rContext ) 747 { 748 try 749 { 750 Reference < XFramesSupplier > xSupplier( i_rContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW ); 751 Reference < XIndexAccess > xContainer( xSupplier->getFrames(), UNO_QUERY_THROW ); 752 753 Reference< XModuleManager > xCheck( i_rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW ); 754 755 sal_Int32 nCount = xContainer->getCount(); 756 for ( sal_Int32 i=0; i<nCount; ++i ) 757 { 758 try 759 { 760 Reference < XFrame > xFrame( xContainer->getByIndex(i), UNO_QUERY_THROW ); 761 ::rtl::OUString sModule = xCheck->identify( xFrame ); 762 if ( sModule.equalsAscii( "com.sun.star.frame.StartModule" ) ) 763 return xFrame; 764 } 765 catch( const UnknownModuleException& ) 766 { 767 // silence 768 } 769 catch(const Exception&) 770 { 771 // re-throw, caught below 772 throw; 773 } 774 } 775 } 776 catch( const Exception& ) 777 { 778 DBG_UNHANDLED_EXCEPTION(); 779 } 780 return NULL; 781 } 782 } 783 784 static ::rtl::OUString getConfigurationStringValue( 785 const ::rtl::OUString& rPackage, 786 const ::rtl::OUString& rRelPath, 787 const ::rtl::OUString& rKey, 788 const ::rtl::OUString& rDefaultValue ) 789 { 790 ::rtl::OUString aDefVal( rDefaultValue ); 791 792 try 793 { 794 ::comphelper::ConfigurationHelper::readDirectKey( 795 comphelper::getProcessServiceFactory(), 796 rPackage, 797 rRelPath, 798 rKey, 799 ::comphelper::ConfigurationHelper::E_READONLY) >>= aDefVal; 800 } 801 catch(const com::sun::star::uno::RuntimeException& exRun) 802 { throw exRun; } 803 catch(const com::sun::star::uno::Exception&) 804 {} 805 806 return aDefVal; 807 } 808 809 void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) 810 { 811 DBG_MEMTEST(); 812 switch ( rReq.GetSlot() ) 813 { 814 case SID_OPTIONS_TREEDIALOG: 815 { 816 String sPageURL; 817 SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, SID_OPTIONS_PAGEURL, sal_False ); 818 if ( pURLItem ) 819 sPageURL = pURLItem->GetValue(); 820 const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl(); 821 const SfxPoolItem* pItem = NULL; 822 Reference < XFrame > xFrame; 823 if ( pArgs && pArgs->GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET ) 824 { 825 OSL_ENSURE( pItem->ISA( SfxUnoFrameItem ), "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" ); 826 xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame(); 827 } 828 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 829 if ( pFact ) 830 { 831 VclAbstractDialog* pDlg = 832 pFact->CreateFrameDialog( NULL, xFrame, rReq.GetSlot(), sPageURL ); 833 pDlg->Execute(); 834 delete pDlg; 835 SfxViewFrame* pView = SfxViewFrame::GetFirst(); 836 while ( pView ) 837 { 838 pView->GetBindings().InvalidateAll(sal_False); 839 pView = SfxViewFrame::GetNext( *pView ); 840 } 841 } 842 break; 843 } 844 845 case SID_MORE_DICTIONARIES: 846 { 847 try 848 { 849 uno::Reference< lang::XMultiServiceFactory > xSMGR = 850 ::comphelper::getProcessServiceFactory(); 851 uno::Reference< css::system::XSystemShellExecute > xSystemShell( 852 xSMGR->createInstance( DEFINE_CONST_UNICODE("com.sun.star.system.SystemShellExecute" ) ), 853 uno::UNO_QUERY_THROW ); 854 855 // read repository URL from configuration 856 ::rtl::OUString sTemplRepoURL = 857 getConfigurationStringValue( 858 ::rtl::OUString::createFromAscii("org.openoffice.Office.Common"), 859 ::rtl::OUString::createFromAscii("Dictionaries"), 860 ::rtl::OUString::createFromAscii("RepositoryURL"), 861 ::rtl::OUString()); 862 863 if ( xSystemShell.is() && sTemplRepoURL.getLength() > 0 ) 864 { 865 ::rtl::OUStringBuffer aURLBuf( sTemplRepoURL ); 866 aURLBuf.appendAscii( "?" ); 867 aURLBuf.appendAscii( "lang=" ); 868 869 // read locale from configuration 870 ::rtl::OUString sLocale = getConfigurationStringValue( 871 ::rtl::OUString::createFromAscii("org.openoffice.Setup"), 872 ::rtl::OUString::createFromAscii("L10N"), 873 ::rtl::OUString::createFromAscii("ooLocale"), 874 ::rtl::OUString::createFromAscii("en-US")); 875 876 aURLBuf.append( sLocale ); 877 xSystemShell->execute( 878 aURLBuf.makeStringAndClear(), 879 ::rtl::OUString(), 880 css::system::SystemShellExecuteFlags::DEFAULTS ); 881 } 882 } 883 catch( const ::com::sun::star::uno::Exception& ) 884 { 885 DBG_ERRORFILE( "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES): caught an exception!" ); 886 } 887 break; 888 } 889 890 case SID_BASICIDE_APPEAR: 891 { 892 SfxViewFrame* pView = lcl_getBasicIDEViewFrame( NULL ); 893 if ( !pView ) 894 { 895 SfxObjectShell* pBasicIDE = SfxObjectShell::CreateObject( lcl_getBasicIDEServiceName() ); 896 pBasicIDE->DoInitNew( 0 ); 897 pBasicIDE->SetModified( sal_False ); 898 try 899 { 900 // load the Basic IDE via direct access to the SFX frame loader. A generic loadComponentFromURL 901 // (which could be done via SfxViewFrame::LoadDocumentIntoFrame) is not feasible here, since the Basic IDE 902 // does not really play nice with the framework's concept. For instance, it is a "singleton document", 903 // which conflicts, at the latest, with the framework's concept of loading into _blank frames. 904 // So, since we know that our frame loader can handle it, we skip the generic framework loader 905 // mechanism, and the type detection (which doesn't know about the Basic IDE). 906 ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); 907 Reference< XSynchronousFrameLoader > xLoader( aContext.createComponent( 908 SfxFrameLoader_Impl::impl_getStaticImplementationName() ), UNO_QUERY_THROW ); 909 ::comphelper::NamedValueCollection aLoadArgs; 910 aLoadArgs.put( "Model", pBasicIDE->GetModel() ); 911 aLoadArgs.put( "URL", ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:factory/sbasic" ) ) ); 912 913 Reference< XFrame > xTargetFrame( lcl_findStartModuleFrame( aContext ) ); 914 if ( !xTargetFrame.is() ) 915 xTargetFrame = SfxFrame::CreateBlankFrame(); 916 ENSURE_OR_THROW( xTargetFrame.is(), "could not obtain a frameto load the Basic IDE into!" ); 917 918 xLoader->load( aLoadArgs.getPropertyValues(), xTargetFrame ); 919 } 920 catch( const Exception& ) 921 { 922 DBG_UNHANDLED_EXCEPTION(); 923 } 924 925 pView = lcl_getBasicIDEViewFrame( pBasicIDE ); 926 if ( pView ) 927 pView->SetName( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC:1" ) ) ); 928 } 929 930 if ( pView ) 931 pView->GetFrame().Appear(); 932 933 const SfxItemSet* pArgs = rReq.GetArgs(); 934 if ( pArgs && pView ) 935 { 936 SfxViewShell* pViewShell = pView->GetViewShell(); 937 SfxObjectShell* pObjShell = pView->GetObjectShell(); 938 if ( pViewShell && pObjShell ) 939 { 940 SfxRequest aReq( SID_BASICIDE_SHOWWINDOW, SFX_CALLMODE_SYNCHRON, pObjShell->GetPool() ); 941 aReq.SetArgs( *pArgs ); 942 pViewShell->ExecuteSlot( aReq ); 943 } 944 } 945 946 rReq.Done(); 947 } 948 break; 949 950 case SID_BASICCHOOSER: 951 { 952 const SfxItemSet* pArgs = rReq.GetArgs(); 953 const SfxPoolItem* pItem; 954 sal_Bool bChooseOnly = sal_False; 955 Reference< XModel > xLimitToModel; 956 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_RECORDMACRO, sal_False, &pItem) ) 957 { 958 sal_Bool bRecord = ((SfxBoolItem*)pItem)->GetValue(); 959 if ( bRecord ) 960 { 961 // !Hack 962 bChooseOnly = sal_False; 963 SfxObjectShell* pCurrentShell = SfxObjectShell::Current(); 964 OSL_ENSURE( pCurrentShell, "macro recording outside an SFX document?" ); 965 if ( pCurrentShell ) 966 xLimitToModel = pCurrentShell->GetModel(); 967 } 968 } 969 970 rReq.SetReturnValue( SfxStringItem( rReq.GetSlot(), ChooseMacro( xLimitToModel, bChooseOnly ) ) ); 971 rReq.Done(); 972 } 973 break; 974 975 case SID_MACROORGANIZER: 976 { 977 OSL_TRACE("handling SID_MACROORGANIZER"); 978 const SfxItemSet* pArgs = rReq.GetArgs(); 979 const SfxPoolItem* pItem; 980 sal_Int16 nTabId = 0; 981 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_MACROORGANIZER, sal_False, &pItem) ) 982 { 983 nTabId = ((SfxUInt16Item*)pItem)->GetValue(); 984 } 985 986 SfxApplication::MacroOrganizer( nTabId ); 987 rReq.Done(); 988 } 989 break; 990 991 case SID_RUNMACRO: 992 { 993 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 994 OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg"); 995 996 Reference< XFrame > xFrame; 997 const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl(); 998 SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False ); 999 if ( pFrameItem ) 1000 xFrame = pFrameItem->GetFrame(); 1001 1002 if ( !xFrame.is() ) 1003 { 1004 const SfxViewFrame* pViewFrame = SfxViewFrame::Current(); 1005 if ( pViewFrame ) 1006 xFrame = pViewFrame->GetFrame().GetFrameInterface(); 1007 } 1008 1009 do // artificial loop for flow control 1010 { 1011 AbstractScriptSelectorDialog* pDlg = pFact->CreateScriptSelectorDialog( 1012 lcl_getDialogParent( xFrame, GetTopWindow() ), sal_False, xFrame ); 1013 OSL_ENSURE( pDlg, "SfxApplication::OfaExec_Impl( SID_RUNMACRO ): no dialog!" ); 1014 if ( !pDlg ) 1015 break; 1016 pDlg->SetRunLabel(); 1017 1018 short nDialogResult = pDlg->Execute(); 1019 if ( !nDialogResult ) 1020 break; 1021 1022 Sequence< Any > args; 1023 Sequence< sal_Int16 > outIndex; 1024 Sequence< Any > outArgs; 1025 Any ret; 1026 1027 Reference< XInterface > xScriptContext; 1028 1029 Reference< XController > xController; 1030 if ( xFrame.is() ) 1031 xController = xFrame->getController(); 1032 if ( xController.is() ) 1033 xScriptContext = xController->getModel(); 1034 if ( !xScriptContext.is() ) 1035 xScriptContext = xController; 1036 1037 SfxObjectShell::CallXScript( xScriptContext, pDlg->GetScriptURL(), args, ret, outIndex, outArgs ); 1038 } 1039 while ( false ); 1040 rReq.Done(); 1041 } 1042 break; 1043 1044 case SID_SCRIPTORGANIZER: 1045 { 1046 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 1047 OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg"); 1048 const SfxItemSet* pArgs = rReq.GetArgs(); 1049 const SfxPoolItem* pItem; 1050 String aLanguage; 1051 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_SCRIPTORGANIZER, sal_False, &pItem) ) 1052 { 1053 aLanguage = ((SfxScriptOrganizerItem*)pItem)->getLanguage(); 1054 } 1055 1056 ::rtl::OUString aLang( aLanguage ); 1057 OSL_TRACE("SfxApplication::OfaExec_Impl: about to create dialog for: %s", ::rtl::OUStringToOString( aLang , RTL_TEXTENCODING_ASCII_US ).pData->buffer); 1058 // not sure about the Window* 1059 VclAbstractDialog* pDlg = pFact->CreateSvxScriptOrgDialog( GetTopWindow(), aLanguage ); 1060 if( pDlg ) 1061 { 1062 pDlg->Execute(); 1063 } 1064 else 1065 { 1066 OSL_TRACE("no dialog!!!"); 1067 } 1068 rReq.Done(); 1069 } 1070 break; 1071 1072 case SID_OFFICE_CHECK_PLZ: 1073 { 1074 sal_Bool bRet = sal_False; 1075 SFX_REQUEST_ARG(rReq, pStringItem, SfxStringItem, rReq.GetSlot(), sal_False); 1076 1077 if ( pStringItem ) 1078 { 1079 String aPLZ = pStringItem->GetValue(); 1080 bRet = sal_True /*!!!SfxIniManager::CheckPLZ( aPLZ )*/; 1081 } 1082 else 1083 SbxBase::SetError( SbxERR_WRONG_ARGS ); 1084 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bRet ) ); 1085 } 1086 break; 1087 1088 case SID_AUTO_CORRECT_DLG: 1089 { 1090 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 1091 if ( pFact ) 1092 { 1093 SfxItemSet aSet(GetPool(), SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG); 1094 const SfxPoolItem* pItem=NULL; 1095 const SfxItemSet* pSet = rReq.GetArgs(); 1096 SfxItemPool* pSetPool = pSet ? pSet->GetPool() : NULL; 1097 if ( pSet && pSet->GetItemState( pSetPool->GetWhich( SID_AUTO_CORRECT_DLG ), sal_False, &pItem ) == SFX_ITEM_SET ) 1098 aSet.Put( *pItem ); 1099 1100 SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( RID_OFA_AUTOCORR_DLG, NULL, &aSet, NULL ); 1101 pDlg->Execute(); 1102 delete pDlg; 1103 } 1104 1105 break; 1106 } 1107 1108 case SID_SD_AUTOPILOT : 1109 case SID_NEWSD : 1110 { 1111 SvtModuleOptions aModuleOpt; 1112 if ( !aModuleOpt.IsImpress() ) 1113 { 1114 ErrorBox( 0, ResId( RID_ERRBOX_MODULENOTINSTALLED, *GetOffResManager_Impl() )).Execute(); 1115 return; 1116 } 1117 1118 Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); 1119 Reference< com::sun::star::frame::XDispatchProvider > xProv( 1120 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY ); 1121 1122 if ( xProv.is() ) 1123 { 1124 ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() ); 1125 Reference< com::sun::star::frame::XDispatchHelper > xHelper( 1126 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY ); 1127 if ( xHelper.is() ) 1128 { 1129 Sequence < com::sun::star::beans::PropertyValue > aSeq; 1130 if ( rReq.GetArgs() ) 1131 TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq ); 1132 Any aResult = xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aSeq ); 1133 ::com::sun::star::frame::DispatchResultEvent aEvent; 1134 sal_Bool bSuccess = ( 1135 (aResult >>= aEvent) && 1136 (aEvent.State == ::com::sun::star::frame::DispatchResultState::SUCCESS) 1137 ); 1138 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) ); 1139 } 1140 } 1141 } 1142 break; 1143 1144 case FN_LABEL : 1145 case FN_BUSINESS_CARD : 1146 case FN_XFORMS_INIT : 1147 { 1148 Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); 1149 Reference< com::sun::star::frame::XDispatchProvider > xProv( 1150 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.text.ModuleDispatcher")), UNO_QUERY ); 1151 1152 if ( xProv.is() ) 1153 { 1154 ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() ); 1155 Reference< com::sun::star::frame::XDispatchHelper > xHelper( 1156 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY ); 1157 if ( xHelper.is() ) 1158 { 1159 Sequence < com::sun::star::beans::PropertyValue > aSeq; 1160 if ( rReq.GetArgs() ) 1161 TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq ); 1162 Any aResult = xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aSeq ); 1163 ::com::sun::star::frame::DispatchResultEvent aEvent; 1164 sal_Bool bSuccess = ( 1165 (aResult >>= aEvent) && 1166 (aEvent.State == ::com::sun::star::frame::DispatchResultState::SUCCESS) 1167 ); 1168 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) ); 1169 } 1170 } 1171 } 1172 break; 1173 1174 case SID_ADDRESS_DATA_SOURCE: 1175 { 1176 ::rtl::OUString sDialogServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.AddressBookSourcePilot" ) ); 1177 try 1178 { 1179 Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); 1180 Reference< com::sun::star::ui::dialogs::XExecutableDialog > xDialog; 1181 if (xORB.is()) 1182 xDialog = Reference< com::sun::star::ui::dialogs::XExecutableDialog >(xORB->createInstance(sDialogServiceName), UNO_QUERY); 1183 if (xDialog.is()) 1184 xDialog->execute(); 1185 else 1186 ShowServiceNotAvailableError(NULL, sDialogServiceName, sal_True); 1187 } 1188 catch(::com::sun::star::uno::Exception&) 1189 { 1190 } 1191 } 1192 break; 1193 1194 case SID_COMP_BIBLIOGRAPHY: 1195 { 1196 SfxStringItem aURL(SID_FILE_NAME, String::CreateFromAscii(".component:Bibliography/View1")); 1197 SfxStringItem aRef(SID_REFERER, String::CreateFromAscii("private:user")); 1198 SfxStringItem aTarget(SID_TARGETNAME, String::CreateFromAscii("_blank")); 1199 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aURL, &aRef, &aTarget, 0L); 1200 } 1201 break; 1202 } 1203 } 1204 1205 void SfxApplication::OfaState_Impl(SfxItemSet &rSet) 1206 { 1207 SvtModuleOptions aModuleOpt; 1208 1209 if( !aModuleOpt.IsWriter()) 1210 { 1211 rSet.DisableItem( FN_LABEL ); 1212 rSet.DisableItem( FN_BUSINESS_CARD ); 1213 rSet.DisableItem( FN_XFORMS_INIT ); 1214 } 1215 1216 if ( !aModuleOpt.IsImpress() ) 1217 rSet.DisableItem( SID_SD_AUTOPILOT ); 1218 } 1219