LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/app - apphdl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 84 387 21.7 %
Date: 2012-12-17 Functions: 13 34 38.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10