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