1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 #include <hintids.hxx> 32 #include <tools/urlobj.hxx> 33 34 #include <tools/debug.hxx> 35 #include <tools/link.hxx> 36 37 #define _SVSTDARR_STRINGSDTOR 38 #include <svl/svstdarr.hxx> 39 #include <svl/urihelper.hxx> 40 #include <unotools/undoopt.hxx> 41 #include <unotools/pathoptions.hxx> 42 #include <svtools/accessibilityoptions.hxx> 43 #include <sfx2/dispatch.hxx> 44 #include <sfx2/event.hxx> 45 #include <sfx2/objitem.hxx> 46 #include <svx/dataaccessdescriptor.hxx> 47 #include <svl/srchitem.hxx> 48 #include <svtools/colorcfg.hxx> 49 #include <svl/eitem.hxx> 50 #include <svl/whiter.hxx> 51 #include <svl/isethint.hxx> 52 #include <svx/hyprlink.hxx> 53 #include <sfx2/request.hxx> 54 #include <sfx2/fcontnr.hxx> 55 #include <svl/stritem.hxx> 56 #include <svl/ctloptions.hxx> 57 #include <unotools/useroptions.hxx> 58 #include <vcl/msgbox.hxx> 59 #include <vcl/wrkwin.hxx> 60 #include <svx/insctrl.hxx> 61 #include <svx/selctrl.hxx> 62 #include <com/sun/star/document/UpdateDocMode.hpp> 63 #include <sfx2/docfile.hxx> 64 #include <svx/xmlsecctrl.hxx> 65 #include <navicfg.hxx> 66 67 #include <sfx2/objface.hxx> 68 #include <sfx2/app.hxx> 69 70 #include <view.hxx> 71 #include <pview.hxx> 72 #include <srcview.hxx> 73 #include <wrtsh.hxx> 74 #include <docsh.hxx> 75 #include <cmdid.h> // Funktion-Ids 76 #include <initui.hxx> 77 #include <uitool.hxx> 78 #include <swmodule.hxx> 79 #include <wdocsh.hxx> 80 #include <wview.hxx> 81 #include <usrpref.hxx> 82 #include <gloslst.hxx> // SwGlossaryList 83 #include <glosdoc.hxx> // SwGlossaryList 84 #include <doc.hxx> 85 #include <IDocumentUndoRedo.hxx> 86 #include <cfgitems.hxx> 87 #include <prtopt.hxx> 88 #include <modcfg.hxx> 89 #include <globals.h> // globale Konstanten z.B. 90 #include <app.hrc> 91 #include <fontcfg.hxx> 92 #include <barcfg.hxx> 93 #include <uinums.hxx> 94 #include <dbconfig.hxx> 95 #include <mmconfigitem.hxx> 96 #include <mailmergechildwindow.hxx> 97 #include <linguistic/lngprops.hxx> 98 #include <editeng/unolingu.hxx> 99 #include <com/sun/star/beans/XMultiPropertySet.hpp> 100 #include <com/sun/star/beans/XFastPropertySet.hpp> 101 #include <com/sun/star/beans/XPropertyState.hpp> 102 #include <com/sun/star/beans/XPropertyStateChangeListener.hpp> 103 #include <com/sun/star/beans/PropertyAttribute.hpp> 104 #include <com/sun/star/beans/XPropertyAccess.hpp> 105 #include <com/sun/star/beans/XPropertyContainer.hpp> 106 #include <com/sun/star/container/XChild.hpp> 107 #include <com/sun/star/sdbc/XConnection.hpp> 108 #include <com/sun/star/sdbc/XDataSource.hpp> 109 #include <swabstdlg.hxx> 110 111 112 #include <vcl/status.hxx> 113 114 #include "salhelper/simplereferenceobject.hxx" 115 #include "rtl/ref.hxx" 116 117 #include <unomid.h> 118 119 using namespace ::com::sun::star; 120 121 /*-------------------------------------------------------------------- 122 Beschreibung: Slotmaps fuer Methoden der Applikation 123 --------------------------------------------------------------------*/ 124 125 126 // hier werden die SlotID's included 127 // siehe Idl-File 128 // 129 #define SwModule 130 #define ViewSettings 131 #define WebViewSettings 132 #define PrintSettings 133 #define _ExecAddress ExecOther 134 #define _StateAddress StateOther 135 #include <sfx2/msg.hxx> 136 #include "swslots.hxx" 137 #include <cfgid.h> 138 139 #include <shells.hrc> 140 141 SFX_IMPL_INTERFACE( SwModule, SfxModule, SW_RES(RID_SW_NAME) ) 142 { 143 SFX_CHILDWINDOW_REGISTRATION(SvxHyperlinkDlgWrapper::GetChildWindowId()); 144 SFX_STATUSBAR_REGISTRATION(SW_RES(CFG_STATUSBAR)); 145 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION | 146 SFX_VISIBILITY_DESKTOP | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_CLIENT | SFX_VISIBILITY_VIEWER, 147 SW_RES(RID_MODULE_TOOLBOX) ); 148 } 149 150 151 /*-------------------------------------------------------------------- 152 Beschreibung: Andere States 153 --------------------------------------------------------------------*/ 154 155 156 void SwModule::StateOther(SfxItemSet &rSet) 157 { 158 SfxWhichIter aIter(rSet); 159 sal_uInt16 nWhich = aIter.FirstWhich(); 160 161 SwView* pActView = ::GetActiveView(); 162 sal_Bool bWebView = 0 != PTR_CAST(SwWebView, pActView); 163 164 while(nWhich) 165 { 166 switch(nWhich) 167 { 168 case FN_BUSINESS_CARD: 169 case FN_LABEL: 170 case FN_ENVELOP: 171 { 172 sal_Bool bDisable = sal_False; 173 SfxViewShell* pCurrView = SfxViewShell::Current(); 174 if( !pCurrView || (pCurrView && !pCurrView->ISA(SwView)) ) 175 bDisable = sal_True; 176 SwDocShell *pDocSh = (SwDocShell*) SfxObjectShell::Current(); 177 if ( bDisable || 178 (pDocSh && (pDocSh->IsReadOnly() || 179 pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)) ) 180 rSet.DisableItem( nWhich ); 181 182 } 183 break; 184 case FN_XFORMS_INIT: 185 // slot is always active! 186 break; 187 case FN_EDIT_FORMULA: 188 { 189 SwWrtShell* pSh = 0; 190 int nSelection = 0; 191 if( pActView ) 192 pSh = &pActView->GetWrtShell(); 193 if( pSh ) 194 nSelection = pSh->GetSelectionType(); 195 196 if( (pSh && pSh->HasSelection()) || 197 !(nSelection & (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL))) 198 rSet.DisableItem(nWhich); 199 } 200 break; 201 case SID_ATTR_METRIC: 202 rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, static_cast< sal_uInt16 >(::GetDfltMetric(bWebView)))); 203 break; 204 case FN_SET_MODOPT_TBLNUMFMT: 205 rSet.Put( SfxBoolItem( nWhich, pModuleConfig-> 206 IsInsTblFormatNum( bWebView ))); 207 break; 208 default: 209 DBG_ERROR("::StateOther: default"); 210 } 211 nWhich = aIter.NextWhich(); 212 } 213 } 214 215 /*-- 06.04.2004 15:21:43--------------------------------------------------- 216 217 -----------------------------------------------------------------------*/ 218 SwView* lcl_LoadDoc(SwView* pView, const String& rURL) 219 { 220 SwView* pNewView = 0; 221 if(rURL.Len()) 222 { 223 SfxStringItem aURL(SID_FILE_NAME, rURL); 224 SfxStringItem aTargetFrameName( SID_TARGETNAME, String::CreateFromAscii("_blank") ); 225 SfxBoolItem aHidden( SID_HIDDEN, sal_True ); 226 SfxStringItem aReferer(SID_REFERER, pView->GetDocShell()->GetTitle()); 227 SfxObjectItem* pItem = (SfxObjectItem*)pView->GetViewFrame()->GetDispatcher()-> 228 Execute(SID_OPENDOC, SFX_CALLMODE_SYNCHRON, 229 &aURL, &aHidden, &aReferer, &aTargetFrameName, 0L); 230 SfxShell* pShell = pItem ? pItem->GetShell() : 0; 231 232 if(pShell) 233 { 234 SfxViewShell* pViewShell = pShell->GetViewShell(); 235 if(pViewShell) 236 { 237 if( pViewShell->ISA(SwView) ) 238 { 239 pNewView = PTR_CAST(SwView,pViewShell); 240 pNewView->GetViewFrame()->GetFrame().Appear(); 241 } 242 else 243 { 244 pViewShell->GetViewFrame()->DoClose(); 245 } 246 } 247 } 248 } 249 else 250 { 251 SfxStringItem aFactory(SID_NEWDOCDIRECT, SwDocShell::Factory().GetFilterContainer()->GetName()); 252 const SfxFrameItem* pItem = (SfxFrameItem*) 253 pView->GetViewFrame()->GetDispatcher()->Execute(SID_NEWDOCDIRECT, 254 SFX_CALLMODE_SYNCHRON, &aFactory, 0L); 255 SfxFrame* pFrm = pItem ? pItem->GetFrame() : 0; 256 SfxViewFrame* pFrame = pFrm ? pFrm->GetCurrentViewFrame() : 0; 257 pNewView = pFrame ? PTR_CAST(SwView, pFrame->GetViewShell()) : 0; 258 } 259 260 return pNewView; 261 } 262 /*-------------------------------------------------------------------- 263 Beschreibung: Felddialog starten 264 --------------------------------------------------------------------*/ 265 266 void NewXForms( SfxRequest& rReq ); // implementation: below 267 268 namespace 269 { 270 271 class SwMailMergeWizardExecutor : public salhelper::SimpleReferenceObject 272 { 273 SwView* m_pView; // never owner 274 SwView* m_pView2Close; // never owner 275 SwMailMergeConfigItem* m_pMMConfig; // sometimes owner 276 AbstractMailMergeWizard* m_pWizard; // always owner 277 278 DECL_LINK( EndDialogHdl, AbstractMailMergeWizard* ); 279 DECL_LINK( DestroyDialogHdl, AbstractMailMergeWizard* ); 280 DECL_LINK( DestroyWizardHdl, AbstractMailMergeWizard* ); 281 DECL_LINK( CancelHdl, AbstractMailMergeWizard* ); 282 DECL_LINK( CloseFrameHdl, AbstractMailMergeWizard* ); 283 284 void ExecutionFinished( bool bDeleteConfigItem ); 285 void ExecuteWizard(); 286 287 public: 288 SwMailMergeWizardExecutor(); 289 ~SwMailMergeWizardExecutor(); 290 291 void ExecuteMailMergeWizard( const SfxItemSet * pArgs ); 292 }; 293 294 SwMailMergeWizardExecutor::SwMailMergeWizardExecutor() 295 : m_pView( 0 ), 296 m_pView2Close( NULL ), 297 m_pMMConfig( 0 ), 298 m_pWizard( 0 ) 299 { 300 } 301 302 SwMailMergeWizardExecutor::~SwMailMergeWizardExecutor() 303 { 304 DBG_ASSERT( m_pWizard == 0, "SwMailMergeWizardExecutor: m_pWizard must be Null!" ); 305 DBG_ASSERT( m_pMMConfig == 0, "SwMailMergeWizardExecutor: m_pMMConfig must be Null!" ); 306 } 307 308 void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs ) 309 { 310 if ( m_pView ) 311 { 312 DBG_ERROR( "SwMailMergeWizardExecutor::ExecuteMailMergeWizard: Already executing the wizard!" ); 313 return; 314 } 315 316 m_pView = ::GetActiveView(); // not owner! 317 DBG_ASSERT(m_pView, "no current view?"); 318 if(m_pView) 319 { 320 // keep self alive until done. 321 acquire(); 322 323 // if called from the child window - get the config item and close the ChildWindow, then restore 324 // the wizard 325 SwMailMergeChildWindow* pChildWin = 326 static_cast<SwMailMergeChildWindow*>(m_pView->GetViewFrame()->GetChildWindow(FN_MAILMERGE_CHILDWINDOW)); 327 bool bRestoreWizard = false; 328 sal_uInt16 nRestartPage = 0; 329 if(pChildWin && pChildWin->IsVisible()) 330 { 331 m_pMMConfig = m_pView->GetMailMergeConfigItem(); 332 nRestartPage = m_pView->GetMailMergeRestartPage(); 333 if(m_pView->IsMailMergeSourceView()) 334 m_pMMConfig->SetSourceView( m_pView ); 335 m_pView->SetMailMergeConfigItem(0, 0, sal_True); 336 SfxViewFrame* pViewFrame = m_pView->GetViewFrame(); 337 pViewFrame->ShowChildWindow(FN_MAILMERGE_CHILDWINDOW, sal_False); 338 DBG_ASSERT(m_pMMConfig, "no MailMergeConfigItem available"); 339 bRestoreWizard = true; 340 } 341 // to make it bullet proof ;-) 342 if(!m_pMMConfig) 343 { 344 m_pMMConfig = new SwMailMergeConfigItem; 345 m_pMMConfig->SetSourceView(m_pView); 346 347 //set the first used database as default source on the config item 348 const SfxPoolItem* pItem = 0; 349 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( 350 FN_PARAM_DATABASE_PROPERTIES, sal_False, &pItem)) 351 { 352 //mailmerge has been called from the database beamer 353 uno::Sequence< beans::PropertyValue> aDBValues; 354 if(static_cast<const SfxUsrAnyItem*>(pItem)->GetValue() >>= aDBValues) 355 { 356 SwDBData aDBData; 357 svx::ODataAccessDescriptor aDescriptor(aDBValues); 358 aDescriptor[svx::daDataSource] >>= aDBData.sDataSource; 359 aDescriptor[svx::daCommand] >>= aDBData.sCommand; 360 aDescriptor[svx::daCommandType] >>= aDBData.nCommandType; 361 362 uno::Sequence< uno::Any > aSelection; 363 uno::Reference< sdbc::XConnection> xConnection; 364 uno::Reference< sdbc::XDataSource> xSource; 365 uno::Reference< sdbcx::XColumnsSupplier> xColumnsSupplier; 366 if ( aDescriptor.has(svx::daSelection) ) 367 aDescriptor[svx::daSelection] >>= aSelection; 368 if ( aDescriptor.has(svx::daConnection) ) 369 aDescriptor[svx::daConnection] >>= xConnection; 370 uno::Reference<container::XChild> xChild(xConnection, uno::UNO_QUERY); 371 if(xChild.is()) 372 xSource = uno::Reference<sdbc::XDataSource>( 373 xChild->getParent(), uno::UNO_QUERY); 374 m_pMMConfig->SetCurrentConnection( 375 xSource, SharedConnection( xConnection, SharedConnection::NoTakeOwnership ), 376 xColumnsSupplier, aDBData); 377 } 378 } 379 else 380 { 381 SvStringsDtor aDBNameList(5, 1); 382 SvStringsDtor aAllDBNames(5, 5); 383 m_pView->GetWrtShell().GetAllUsedDB( aDBNameList, &aAllDBNames ); 384 if(aDBNameList.Count()) 385 { 386 String sDBName = *aDBNameList[0]; 387 SwDBData aDBData; 388 aDBData.sDataSource = sDBName.GetToken(0, DB_DELIM); 389 aDBData.sCommand = sDBName.GetToken(1, DB_DELIM); 390 aDBData.nCommandType = sDBName.GetToken(2, DB_DELIM ).ToInt32(); 391 //set the currently used database for the wizard 392 m_pMMConfig->SetCurrentDBData( aDBData ); 393 } 394 } 395 } 396 397 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 398 m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *m_pMMConfig); 399 400 if(bRestoreWizard) 401 { 402 m_pWizard->ShowPage( nRestartPage ); 403 } 404 405 ExecuteWizard(); 406 } 407 } 408 409 void SwMailMergeWizardExecutor::ExecutionFinished( bool bDeleteConfigItem ) 410 { 411 m_pMMConfig->Commit(); 412 if ( bDeleteConfigItem ) // owner? 413 delete m_pMMConfig; 414 415 m_pMMConfig = 0; 416 417 // release/destroy asynchronously 418 Application::PostUserEvent( LINK( this, SwMailMergeWizardExecutor, DestroyDialogHdl ) ); 419 } 420 421 void SwMailMergeWizardExecutor::ExecuteWizard() 422 { 423 m_pWizard->StartExecuteModal( 424 LINK( this, SwMailMergeWizardExecutor, EndDialogHdl ) ); 425 } 426 427 #if OSL_DEBUG_LEVEL > 1 428 IMPL_LINK( SwMailMergeWizardExecutor, EndDialogHdl, AbstractMailMergeWizard*, pDialog ) 429 #else 430 IMPL_LINK( SwMailMergeWizardExecutor, EndDialogHdl, AbstractMailMergeWizard*, EMPTYARG ) 431 #endif 432 { 433 #if OSL_DEBUG_LEVEL > 1 434 DBG_ASSERT( pDialog == m_pWizard, "wrong dialog passed to EndDialogHdl!" ); 435 (void) pDialog; 436 #endif 437 438 long nRet = m_pWizard->GetResult(); 439 sal_uInt16 nRestartPage = m_pWizard->GetRestartPage(); 440 441 switch ( nRet ) 442 { 443 case RET_LOAD_DOC: 444 { 445 SwView* pNewView = lcl_LoadDoc(m_pView, m_pWizard->GetReloadDocument()); 446 447 // destroy wizard asynchronously 448 Application::PostUserEvent( 449 LINK( this, SwMailMergeWizardExecutor, DestroyWizardHdl ), m_pWizard ); 450 451 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 452 if(pNewView) 453 { 454 m_pView = pNewView; 455 m_pMMConfig->DocumentReloaded(); 456 //new source view! 457 m_pMMConfig->SetSourceView( m_pView ); 458 m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *m_pMMConfig); 459 m_pWizard->ShowPage( nRestartPage ); 460 } 461 else 462 { 463 m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *m_pMMConfig); 464 } 465 466 // execute the wizard again 467 ExecuteWizard(); 468 break; 469 } 470 case RET_TARGET_CREATED: 471 { 472 SwView* pTargetView = m_pMMConfig->GetTargetView(); 473 uno::Reference< frame::XFrame > xFrame = 474 m_pView->GetViewFrame()->GetFrame().GetFrameInterface(); 475 xFrame->getContainerWindow()->setVisible(sal_False); 476 DBG_ASSERT(pTargetView, "No target view has been created"); 477 if(pTargetView) 478 { 479 // destroy wizard asynchronously 480 Application::PostUserEvent( 481 LINK( this, SwMailMergeWizardExecutor, DestroyWizardHdl ), m_pWizard ); 482 483 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 484 m_pWizard = pFact->CreateMailMergeWizard(*pTargetView, *m_pMMConfig); 485 m_pWizard->ShowPage( nRestartPage ); 486 487 // execute the wizard again 488 ExecuteWizard(); 489 } 490 else 491 { 492 //should not happen - just in case no target view has been created 493 ExecutionFinished( true ); 494 } 495 break; 496 } 497 case RET_EDIT_DOC: 498 case RET_EDIT_RESULT_DOC: 499 { 500 //create a non-modal dialog that allows to return to the wizard 501 //the ConfigItem ownership moves to this dialog 502 bool bResult = nRet == RET_EDIT_RESULT_DOC && m_pMMConfig->GetTargetView(); 503 SwView* pTempView = bResult ? m_pMMConfig->GetTargetView() : m_pMMConfig->GetSourceView(); 504 pTempView->SetMailMergeConfigItem(m_pMMConfig, m_pWizard->GetRestartPage(), !bResult); 505 SfxViewFrame* pViewFrame = pTempView->GetViewFrame(); 506 pViewFrame->GetDispatcher()->Execute( 507 FN_MAILMERGE_CHILDWINDOW, SFX_CALLMODE_SYNCHRON); 508 ExecutionFinished( false ); 509 break; 510 } 511 case RET_REMOVE_TARGET: 512 { 513 SwView* pTargetView = m_pMMConfig->GetTargetView(); 514 SwView* pSourceView = m_pMMConfig->GetSourceView(); 515 DBG_ASSERT(pTargetView && pSourceView, "source or target view not available" ); 516 if(pTargetView && pSourceView) 517 { 518 m_pView2Close = pTargetView; 519 pTargetView->GetViewFrame()->GetTopViewFrame()->GetWindow().Hide(); 520 pSourceView->GetViewFrame()->GetFrame().AppearWithUpdate(); 521 // the current view has be be set when the target is destroyed 522 m_pView = pSourceView; 523 m_pMMConfig->SetTargetView(0); 524 525 // destroy wizard asynchronously 526 Application::PostUserEvent( 527 LINK( this, SwMailMergeWizardExecutor, CloseFrameHdl ), m_pWizard ); 528 529 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 530 m_pWizard = pFact->CreateMailMergeWizard(*pSourceView, *m_pMMConfig); 531 m_pWizard->ShowPage( nRestartPage ); 532 533 // execute the wizard again 534 ExecuteWizard(); 535 } 536 else 537 { 538 //should not happen - just in case no target view has been created 539 ExecutionFinished( true ); 540 } 541 break; 542 } 543 case RET_CANCEL: 544 { 545 // close frame and destroy wizard asynchronously 546 Application::PostUserEvent( 547 LINK( this, SwMailMergeWizardExecutor, CancelHdl ), m_pWizard ); 548 break; 549 } 550 default: //finish 551 { 552 SwView* pSourceView = m_pMMConfig->GetSourceView(); 553 if(pSourceView) 554 { 555 SwDocShell* pDocShell = pSourceView->GetDocShell(); 556 if(pDocShell->HasName() && !pDocShell->IsModified()) 557 m_pMMConfig->GetSourceView()->GetViewFrame()->DoClose(); 558 else 559 m_pMMConfig->GetSourceView()->GetViewFrame()->GetFrame().Appear(); 560 } 561 ExecutionFinished( true ); 562 break; 563 } 564 565 } // switch 566 567 return 0L; 568 } 569 570 IMPL_LINK( SwMailMergeWizardExecutor, DestroyDialogHdl, AbstractMailMergeWizard*, EMPTYARG ) 571 { 572 delete m_pWizard; 573 m_pWizard = 0; 574 575 release(); 576 return 0L; 577 } 578 579 IMPL_LINK( SwMailMergeWizardExecutor, DestroyWizardHdl, AbstractMailMergeWizard*, pDialog ) 580 { 581 delete pDialog; 582 return 0L; 583 } 584 585 IMPL_LINK( SwMailMergeWizardExecutor, CancelHdl, AbstractMailMergeWizard*, EMPTYARG ) 586 { 587 if(m_pMMConfig->GetTargetView()) 588 { 589 m_pMMConfig->GetTargetView()->GetViewFrame()->DoClose(); 590 m_pMMConfig->SetTargetView(0); 591 } 592 if(m_pMMConfig->GetSourceView()) 593 m_pMMConfig->GetSourceView()->GetViewFrame()->GetFrame().AppearWithUpdate(); 594 595 m_pMMConfig->Commit(); 596 delete m_pMMConfig; 597 m_pMMConfig = 0; 598 // m_pWizard already deleted by closing the target view 599 m_pWizard = 0; 600 release(); 601 602 return 0L; 603 } 604 605 IMPL_LINK( SwMailMergeWizardExecutor, CloseFrameHdl, AbstractMailMergeWizard*, EMPTYARG ) 606 { 607 if ( m_pView2Close ) 608 { 609 m_pView2Close->GetViewFrame()->DoClose(); 610 m_pView2Close = NULL; 611 } 612 613 return 0L; 614 } 615 616 } // namespace 617 618 void SwModule::ExecOther(SfxRequest& rReq) 619 { 620 const SfxItemSet *pArgs = rReq.GetArgs(); 621 const SfxPoolItem* pItem = 0; 622 623 sal_uInt16 nWhich = rReq.GetSlot(); 624 switch (nWhich) 625 { 626 case FN_ENVELOP: 627 InsertEnv( rReq ); 628 break; 629 630 case FN_BUSINESS_CARD: 631 case FN_LABEL: 632 InsertLab(rReq, nWhich == FN_LABEL); 633 break; 634 635 case FN_XFORMS_INIT: 636 NewXForms( rReq ); 637 break; 638 639 case SID_ATTR_METRIC: 640 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(nWhich, sal_False, &pItem)) 641 { 642 FieldUnit eUnit = (FieldUnit)((const SfxUInt16Item*)pItem)->GetValue(); 643 switch( eUnit ) 644 { 645 case FUNIT_MM: 646 case FUNIT_CM: 647 case FUNIT_INCH: 648 case FUNIT_PICA: 649 case FUNIT_POINT: 650 { 651 SwView* pActView = ::GetActiveView(); 652 sal_Bool bWebView = 0 != PTR_CAST(SwWebView, pActView); 653 ::SetDfltMetric(eUnit, bWebView); 654 } 655 break; 656 default:;//prevent warning 657 } 658 } 659 break; 660 661 case FN_SET_MODOPT_TBLNUMFMT: 662 { 663 sal_Bool bWebView = 0 != PTR_CAST(SwWebView, ::GetActiveView() ), 664 bSet; 665 666 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( 667 nWhich, sal_False, &pItem )) 668 bSet = ((SfxBoolItem*)pItem)->GetValue(); 669 else 670 bSet = !pModuleConfig->IsInsTblFormatNum( bWebView ); 671 672 pModuleConfig->SetInsTblFormatNum( bWebView, bSet ); 673 } 674 break; 675 case FN_MAILMERGE_WIZARD: 676 { 677 rtl::Reference< SwMailMergeWizardExecutor > xEx( new SwMailMergeWizardExecutor ); 678 xEx->ExecuteMailMergeWizard( pArgs ); 679 } 680 break; 681 } 682 } 683 684 /*-------------------------------------------------------------------- 685 Beschreibung: Notifies abfangen 686 --------------------------------------------------------------------*/ 687 688 689 // Hint abfangen fuer DocInfo 690 void SwModule::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) 691 { 692 if( rHint.ISA( SfxEventHint ) ) 693 { 694 SfxEventHint& rEvHint = (SfxEventHint&) rHint; 695 SwDocShell* pDocSh = PTR_CAST( SwDocShell, rEvHint.GetObjShell() ); 696 if( pDocSh ) 697 { 698 SwWrtShell* pWrtSh = pDocSh ? pDocSh->GetWrtShell() : 0; 699 switch( rEvHint.GetEventId() ) 700 { 701 case SFX_EVENT_LOADFINISHED: 702 OSL_ASSERT(!pWrtSh); 703 // if it is a new document created from a template, 704 // update fixed fields 705 if (pDocSh->GetMedium()) 706 { 707 SFX_ITEMSET_ARG( pDocSh->GetMedium()->GetItemSet(), 708 pTemplateItem, SfxBoolItem, 709 SID_TEMPLATE, sal_False); 710 if (pTemplateItem && pTemplateItem->GetValue()) 711 { 712 pDocSh->GetDoc()->SetFixFields(false, 0); 713 } 714 } 715 break; 716 case SFX_EVENT_CREATEDOC: 717 if( pWrtSh ) 718 { 719 SFX_ITEMSET_ARG( pDocSh->GetMedium()->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False); 720 sal_Bool bUpdateFields = sal_True; 721 if( pUpdateDocItem && pUpdateDocItem->GetValue() == document::UpdateDocMode::NO_UPDATE) 722 bUpdateFields = sal_False; 723 if(bUpdateFields) 724 { 725 pWrtSh->UpdateInputFlds(); 726 727 // Sind Datenbankfelder enthalten? 728 // Erstmal alle verwendeten Datenbanken holen 729 SwDoc *pDoc = pDocSh->GetDoc(); 730 SvStringsDtor aDBNameList; 731 pDoc->GetAllUsedDB( aDBNameList ); 732 sal_uInt16 nCount = aDBNameList.Count(); 733 if (nCount) 734 { // Datenbankbeamer oeffnen 735 ShowDBObj(pWrtSh->GetView(), pDoc->GetDBData()); 736 } 737 } 738 } 739 break; 740 } 741 } 742 } 743 else if(rHint.ISA(SfxItemSetHint)) 744 { 745 if( SFX_ITEM_SET == ((SfxItemSetHint&)rHint).GetItemSet().GetItemState(SID_ATTR_PATHNAME)) 746 { 747 ::GetGlossaries()->UpdateGlosPath( sal_False ); 748 SwGlossaryList* pList = ::GetGlossaryList(); 749 if(pList->IsActive()) 750 pList->Update(); 751 } 752 } 753 else if(rHint.ISA(SfxSimpleHint)) 754 { 755 sal_uInt16 nHintId = ((SfxSimpleHint&)rHint).GetId(); 756 if(SFX_HINT_DEINITIALIZING == nHintId) 757 { 758 DELETEZ(pWebUsrPref); 759 DELETEZ(pUsrPref) ; 760 DELETEZ(pModuleConfig); 761 DELETEZ(pPrtOpt) ; 762 DELETEZ(pWebPrtOpt) ; 763 DELETEZ(pChapterNumRules); 764 DELETEZ(pStdFontConfig) ; 765 DELETEZ(pNavigationConfig) ; 766 DELETEZ(pToolbarConfig) ; 767 DELETEZ(pWebToolbarConfig) ; 768 DELETEZ(pAuthorNames) ; 769 DELETEZ(pDBConfig); 770 if( pColorConfig ) 771 { 772 pColorConfig->RemoveListener(this); 773 DELETEZ(pColorConfig); 774 } 775 if( pAccessibilityOptions ) 776 { 777 pAccessibilityOptions->RemoveListener(this); 778 DELETEZ(pAccessibilityOptions); 779 } 780 if( pCTLOptions ) 781 { 782 pCTLOptions->RemoveListener(this); 783 DELETEZ(pCTLOptions); 784 } 785 if( pUserOptions ) 786 { 787 pUserOptions->RemoveListener(this); 788 DELETEZ(pUserOptions); 789 } 790 if( pUndoOptions ) 791 { 792 pUndoOptions->RemoveListener(this); 793 DELETEZ(pUndoOptions); 794 } 795 } 796 } 797 } 798 799 void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, sal_uInt32 ) 800 { 801 if( pBrdCst == pUserOptions ) 802 { 803 bAuthorInitialised = sal_False; 804 } 805 else if( pBrdCst == pUndoOptions ) 806 { 807 sal_Int32 const nNew = GetUndoOptions().GetUndoCount(); 808 bool const bUndo = (nNew != 0); 809 // switch Undo for all DocShells 810 TypeId aType(TYPE(SwDocShell)); 811 SwDocShell * pDocShell = 812 static_cast<SwDocShell *>(SfxObjectShell::GetFirst(&aType)); 813 while (pDocShell) 814 { 815 pDocShell->GetDoc()->GetIDocumentUndoRedo().DoUndo(bUndo); 816 pDocShell = static_cast<SwDocShell *>( 817 SfxObjectShell::GetNext(*pDocShell, &aType)); 818 } 819 } 820 else if ( pBrdCst == pColorConfig || pBrdCst == pAccessibilityOptions ) 821 { 822 sal_Bool bAccessibility = sal_False; 823 if( pBrdCst == pColorConfig ) 824 SwViewOption::ApplyColorConfigValues(*pColorConfig); 825 else 826 bAccessibility = sal_True; 827 828 //invalidate all edit windows 829 const TypeId aSwViewTypeId = TYPE(SwView); 830 const TypeId aSwPreViewTypeId = TYPE(SwPagePreView); 831 const TypeId aSwSrcViewTypeId = TYPE(SwSrcView); 832 SfxViewShell* pViewShell = SfxViewShell::GetFirst(); 833 while(pViewShell) 834 { 835 if(pViewShell->GetWindow()) 836 { 837 if((pViewShell->IsA(aSwViewTypeId) || 838 pViewShell->IsA(aSwPreViewTypeId) || 839 pViewShell->IsA(aSwSrcViewTypeId))) 840 { 841 if(bAccessibility) 842 { 843 if(pViewShell->IsA(aSwViewTypeId)) 844 ((SwView*)pViewShell)->ApplyAccessiblityOptions(*pAccessibilityOptions); 845 else if(pViewShell->IsA(aSwPreViewTypeId)) 846 ((SwPagePreView*)pViewShell)->ApplyAccessiblityOptions(*pAccessibilityOptions); 847 } 848 pViewShell->GetWindow()->Invalidate(); 849 } 850 } 851 pViewShell = SfxViewShell::GetNext( *pViewShell ); 852 } 853 } 854 else if( pBrdCst == pCTLOptions ) 855 { 856 const SfxObjectShell* pObjSh = SfxObjectShell::GetFirst(); 857 while( pObjSh ) 858 { 859 if( pObjSh->IsA(TYPE(SwDocShell)) ) 860 { 861 const SwDoc* pDoc = ((SwDocShell*)pObjSh)->GetDoc(); 862 ViewShell* pVSh = 0; 863 pDoc->GetEditShell( &pVSh ); 864 if ( pVSh ) 865 pVSh->ChgNumberDigits(); 866 } 867 pObjSh = SfxObjectShell::GetNext(*pObjSh); 868 } 869 } 870 871 } 872 873 /* -----------------------------20.02.01 12:43-------------------------------- 874 875 ---------------------------------------------------------------------------*/ 876 SwDBConfig* SwModule::GetDBConfig() 877 { 878 if(!pDBConfig) 879 pDBConfig = new SwDBConfig; 880 return pDBConfig; 881 } 882 /* -----------------------------11.04.2002 15:27------------------------------ 883 884 ---------------------------------------------------------------------------*/ 885 svtools::ColorConfig& SwModule::GetColorConfig() 886 { 887 if(!pColorConfig) 888 { 889 pColorConfig = new svtools::ColorConfig; 890 SwViewOption::ApplyColorConfigValues(*pColorConfig); 891 pColorConfig->AddListener(this); 892 } 893 return *pColorConfig; 894 } 895 /* -----------------------------06.05.2002 09:42------------------------------ 896 897 ---------------------------------------------------------------------------*/ 898 SvtAccessibilityOptions& SwModule::GetAccessibilityOptions() 899 { 900 if(!pAccessibilityOptions) 901 { 902 pAccessibilityOptions = new SvtAccessibilityOptions; 903 pAccessibilityOptions->AddListener(this); 904 } 905 return *pAccessibilityOptions; 906 } 907 /* -----------------06.05.2003 14:52----------------- 908 909 --------------------------------------------------*/ 910 SvtCTLOptions& SwModule::GetCTLOptions() 911 { 912 if(!pCTLOptions) 913 { 914 pCTLOptions = new SvtCTLOptions; 915 pCTLOptions->AddListener(this); 916 } 917 return *pCTLOptions; 918 } 919 /* -----------------07.07.2003 09:31----------------- 920 921 --------------------------------------------------*/ 922 SvtUserOptions& SwModule::GetUserOptions() 923 { 924 if(!pUserOptions) 925 { 926 pUserOptions = new SvtUserOptions; 927 pUserOptions->AddListener(this); 928 } 929 return *pUserOptions; 930 } 931 /* -----------------18.07.2003 13:31----------------- 932 933 --------------------------------------------------*/ 934 SvtUndoOptions& SwModule::GetUndoOptions() 935 { 936 if(!pUndoOptions) 937 { 938 pUndoOptions = new SvtUndoOptions; 939 pUndoOptions->AddListener(this); 940 } 941 return *pUndoOptions; 942 } 943 /*-----------------30.01.97 08.30------------------- 944 945 --------------------------------------------------*/ 946 const SwMasterUsrPref *SwModule::GetUsrPref(sal_Bool bWeb) const 947 { 948 SwModule* pNonConstModule = (SwModule*)this; 949 if(bWeb && !pWebUsrPref) 950 { 951 // im Load der SwMasterUsrPref wird der SpellChecker gebraucht, dort darf 952 // er aber nicht angelegt werden #58256# 953 pNonConstModule->pWebUsrPref = new SwMasterUsrPref(sal_True); 954 } 955 else if(!bWeb && !pUsrPref) 956 { 957 pNonConstModule->pUsrPref = new SwMasterUsrPref(sal_False); 958 } 959 return bWeb ? pWebUsrPref : pUsrPref; 960 } 961 962 963 964 void NewXForms( SfxRequest& rReq ) 965 { 966 // copied & excerpted from SwModule::InsertLab(..) 967 968 // create new document 969 SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD) ); 970 xDocSh->DoInitNew( 0 ); 971 972 // initialize XForms 973 static_cast<SwDocShell*>( &xDocSh )->GetDoc()->initXForms( true ); 974 975 // load document into frame 976 SfxViewFrame::DisplayNewDocument( *xDocSh, rReq ); 977 978 // set return value 979 rReq.SetReturnValue( SfxVoidItem( rReq.GetSlot() ) ); 980 } 981