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

Generated by: LCOV version 1.10