LCOV - code coverage report
Current view: top level - sw/source/ui/envelp - mailmrge.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 399 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 36 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 <vcl/msgbox.hxx>
      21             : #include <vcl/svapp.hxx>
      22             : #include <vcl/settings.hxx>
      23             : 
      24             : #include <tools/urlobj.hxx>
      25             : #include <svl/urihelper.hxx>
      26             : #include <unotools/pathoptions.hxx>
      27             : #include <svl/mailenum.hxx>
      28             : #include <svx/svxdlg.hxx>
      29             : #include <svx/dialogs.hrc>
      30             : #include <helpid.h>
      31             : #include <view.hxx>
      32             : #include <docsh.hxx>
      33             : #include <IDocumentDeviceAccess.hxx>
      34             : #include <wrtsh.hxx>
      35             : #include <dbmgr.hxx>
      36             : #include <dbui.hxx>
      37             : #include <prtopt.hxx>
      38             : #include <swmodule.hxx>
      39             : #include <modcfg.hxx>
      40             : #include <mailmergehelper.hxx>
      41             : #include <envelp.hrc>
      42             : #include <mailmrge.hxx>
      43             : #include <sfx2/docfile.hxx>
      44             : #include <sfx2/docfilt.hxx>
      45             : #include <comphelper/sequenceashashmap.hxx>
      46             : #include <com/sun/star/frame/XDispatchProvider.hpp>
      47             : #include <com/sun/star/container/XChild.hpp>
      48             : #include <com/sun/star/container/XContainerQuery.hpp>
      49             : #include <com/sun/star/container/XEnumeration.hpp>
      50             : #include <com/sun/star/form/runtime/XFormController.hpp>
      51             : #include <com/sun/star/frame/Frame.hpp>
      52             : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      53             : #include <com/sun/star/sdbcx/XRowLocate.hpp>
      54             : #include <com/sun/star/sdb/XResultSetAccess.hpp>
      55             : #include <com/sun/star/sdbc/XDataSource.hpp>
      56             : #include <com/sun/star/ui/dialogs/FolderPicker.hpp>
      57             : #include <toolkit/helper/vclunohelper.hxx>
      58             : #include <comphelper/processfactory.hxx>
      59             : #include <cppuhelper/implbase.hxx>
      60             : 
      61             : #include <unomid.h>
      62             : 
      63             : #include <algorithm>
      64             : 
      65             : using namespace ::com::sun::star;
      66             : using namespace ::com::sun::star::container;
      67             : using namespace ::com::sun::star::lang;
      68             : using namespace ::com::sun::star::sdb;
      69             : using namespace ::com::sun::star::sdbc;
      70             : using namespace ::com::sun::star::sdbcx;
      71             : using namespace ::com::sun::star::beans;
      72             : using namespace ::com::sun::star::util;
      73             : using namespace ::com::sun::star::uno;
      74             : using namespace ::com::sun::star::frame;
      75             : using namespace ::com::sun::star::form;
      76             : using namespace ::com::sun::star::view;
      77             : using namespace ::com::sun::star::ui::dialogs;
      78             : 
      79           0 : struct SwMailMergeDlg_Impl
      80             : {
      81             :     uno::Reference<runtime::XFormController> xFController;
      82             :     uno::Reference<XSelectionChangeListener> xChgLstnr;
      83             :     uno::Reference<XSelectionSupplier> xSelSupp;
      84             : };
      85             : 
      86             : class SwXSelChgLstnr_Impl : public cppu::WeakImplHelper
      87             : <
      88             :     view::XSelectionChangeListener
      89             : >
      90             : {
      91             :     SwMailMergeDlg& rParent;
      92             : public:
      93             :     explicit SwXSelChgLstnr_Impl(SwMailMergeDlg& rParentDlg);
      94             :     virtual ~SwXSelChgLstnr_Impl();
      95             : 
      96             :     virtual void SAL_CALL selectionChanged( const EventObject& aEvent ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      97             :     virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      98             : };
      99             : 
     100           0 : SwXSelChgLstnr_Impl::SwXSelChgLstnr_Impl(SwMailMergeDlg& rParentDlg) :
     101           0 :     rParent(rParentDlg)
     102           0 : {}
     103             : 
     104           0 : SwXSelChgLstnr_Impl::~SwXSelChgLstnr_Impl()
     105           0 : {}
     106             : 
     107           0 : void SwXSelChgLstnr_Impl::selectionChanged( const EventObject&  ) throw (RuntimeException, std::exception)
     108             : {
     109             :     //call the parent to enable selection mode
     110           0 :     Sequence <Any> aSelection;
     111           0 :     if(rParent.pImpl->xSelSupp.is())
     112           0 :         rParent.pImpl->xSelSupp->getSelection() >>= aSelection;
     113             : 
     114           0 :     bool bEnable = aSelection.getLength() > 0;
     115           0 :     rParent.m_pMarkedRB->Enable(bEnable);
     116           0 :     if(bEnable)
     117           0 :         rParent.m_pMarkedRB->Check();
     118           0 :     else if(rParent.m_pMarkedRB->IsChecked())
     119             :     {
     120           0 :         rParent.m_pAllRB->Check();
     121           0 :         rParent.m_aSelection.realloc(0);
     122           0 :     }
     123           0 : }
     124             : 
     125           0 : void SwXSelChgLstnr_Impl::disposing( const EventObject&  ) throw (RuntimeException, std::exception)
     126             : {
     127             :     OSL_FAIL("disposing");
     128           0 : }
     129             : 
     130           0 : SwMailMergeDlg::SwMailMergeDlg(vcl::Window* pParent, SwWrtShell& rShell,
     131             :         const OUString& rSourceName,
     132             :         const OUString& rTableName,
     133             :         sal_Int32 nCommandType,
     134             :         const uno::Reference< XConnection>& _xConnection,
     135             :         Sequence< Any >* pSelection) :
     136             : 
     137             :     SvxStandardDialog(pParent, "MailmergeDialog", "modules/swriter/ui/mailmerge.ui"),
     138             : 
     139           0 :     pImpl           (new SwMailMergeDlg_Impl),
     140             : 
     141             :     rSh             (rShell),
     142             :     nMergeType      (DBMGR_MERGE_EMAIL),
     143           0 :     m_aDialogSize( GetSizePixel() )
     144             : {
     145           0 :     get(m_pBeamerWin, "beamer");
     146             : 
     147           0 :     get(m_pAllRB, "all");
     148           0 :     get(m_pMarkedRB, "selected");
     149           0 :     get(m_pFromRB, "rbfrom");
     150           0 :     get(m_pFromNF, "from");
     151           0 :     get(m_pToNF, "to");
     152             : 
     153           0 :     get(m_pPrinterRB, "printer");
     154           0 :     get(m_pMailingRB, "electronic");
     155           0 :     get(m_pFileRB, "file");
     156             : 
     157           0 :     get(m_pSingleJobsCB, "singlejobs");
     158             : 
     159           0 :     get(m_pSaveMergedDocumentFT, "savemergeddoclabel");
     160           0 :     get(m_pSaveSingleDocRB, "singledocument");
     161           0 :     get(m_pSaveIndividualRB, "idividualdocuments");
     162           0 :     get(m_pGenerateFromDataBaseCB, "generate");
     163             : 
     164           0 :     get(m_pColumnFT, "fieldlabel");
     165           0 :     get(m_pColumnLB, "field");
     166             : 
     167           0 :     get(m_pPathFT, "pathlabel");
     168           0 :     get(m_pPathED, "path");
     169           0 :     get(m_pPathPB, "pathpb");
     170           0 :     get(m_pFilterFT, "fileformatlabel");
     171           0 :     get(m_pFilterLB, "fileformat");
     172             : 
     173           0 :     get(m_pAddressFieldLB, "address");
     174           0 :     get(m_pSubjectFT, "subjectlabel");
     175           0 :     get(m_pSubjectED, "subject");
     176           0 :     get(m_pFormatFT, "mailformatlabel");
     177           0 :     get(m_pAttachFT, "attachmentslabel");
     178           0 :     get(m_pAttachED, "attachments");
     179           0 :     get(m_pAttachPB, "attach");
     180           0 :     get(m_pFormatHtmlCB, "html");
     181           0 :     get(m_pFormatRtfCB, "rtf");
     182           0 :     get(m_pFormatSwCB, "swriter");
     183             : 
     184           0 :     get(m_pOkBTN, "ok");
     185             : 
     186           0 :     m_pSingleJobsCB->Show(false); // not supported in since cws printerpullpages anymore
     187             :     //task #97066# mailing of form letters is currently not supported
     188           0 :     m_pMailingRB->Show(false);
     189           0 :     m_pSubjectFT->Show(false);
     190           0 :     m_pSubjectED->Show(false);
     191           0 :     m_pFormatFT->Show(false);
     192           0 :     m_pFormatSwCB->Show(false);
     193           0 :     m_pFormatHtmlCB->Show(false);
     194           0 :     m_pFormatRtfCB->Show(false);
     195           0 :     m_pAttachFT->Show(false);
     196           0 :     m_pAttachED->Show(false);
     197           0 :     m_pAttachPB->Show(false);
     198             : 
     199           0 :     Point aMailPos = m_pMailingRB->GetPosPixel();
     200           0 :     Point aFilePos = m_pFileRB->GetPosPixel();
     201           0 :     aFilePos.X() -= (aFilePos.X() - aMailPos.X()) /2;
     202           0 :     m_pFileRB->SetPosPixel(aFilePos);
     203           0 :     uno::Reference< lang::XMultiServiceFactory > xMSF = comphelper::getProcessServiceFactory();
     204           0 :     if(pSelection)
     205             :     {
     206           0 :         m_aSelection = *pSelection;
     207           0 :         m_pBeamerWin->Show(false);
     208             :     }
     209             :     else
     210             :     {
     211             :         try
     212             :         {
     213             :             // create a frame wrapper for myself
     214           0 :             m_xFrame = frame::Frame::create( comphelper::getProcessComponentContext() );
     215           0 :             m_pUIBuilder->drop_ownership(m_pBeamerWin);
     216           0 :             m_xFrame->initialize( VCLUnoHelper::GetInterface ( m_pBeamerWin ) );
     217             :         }
     218           0 :         catch (const Exception&)
     219             :         {
     220           0 :             m_xFrame.clear();
     221             :         }
     222           0 :         if(m_xFrame.is())
     223             :         {
     224           0 :             URL aURL;
     225           0 :             aURL.Complete = ".component:DB/DataSourceBrowser";
     226           0 :             uno::Reference<XDispatch> xD = m_xFrame->queryDispatch(aURL,
     227             :                         "",
     228           0 :                         0x0C);
     229           0 :             if(xD.is())
     230             :             {
     231           0 :                 Sequence<PropertyValue> aProperties(3);
     232           0 :                 PropertyValue* pProperties = aProperties.getArray();
     233           0 :                 pProperties[0].Name = "DataSourceName";
     234           0 :                 pProperties[0].Value <<= rSourceName;
     235           0 :                 pProperties[1].Name = "Command";
     236           0 :                 pProperties[1].Value <<= rTableName;
     237           0 :                 pProperties[2].Name = "CommandType";
     238           0 :                 pProperties[2].Value <<= nCommandType;
     239           0 :                 xD->dispatch(aURL, aProperties);
     240           0 :                 m_pBeamerWin->Show();
     241             :             }
     242           0 :             uno::Reference<XController> xController = m_xFrame->getController();
     243           0 :             pImpl->xFController = uno::Reference<runtime::XFormController>(xController, UNO_QUERY);
     244           0 :             if(pImpl->xFController.is())
     245             :             {
     246           0 :                 uno::Reference< awt::XControl > xCtrl = pImpl->xFController->getCurrentControl(  );
     247           0 :                 pImpl->xSelSupp = uno::Reference<XSelectionSupplier>(xCtrl, UNO_QUERY);
     248           0 :                 if(pImpl->xSelSupp.is())
     249             :                 {
     250           0 :                     pImpl->xChgLstnr = new SwXSelChgLstnr_Impl(*this);
     251           0 :                     pImpl->xSelSupp->addSelectionChangeListener(  pImpl->xChgLstnr );
     252           0 :                 }
     253           0 :             }
     254             :         }
     255             :     }
     256             : 
     257           0 :     pModOpt = SW_MOD()->GetModuleConfig();
     258             : 
     259           0 :     MailTextFormats nMailingMode(pModOpt->GetMailingFormats());
     260           0 :     m_pFormatSwCB->Check(bool(nMailingMode & MailTextFormats::OFFICE));
     261           0 :     m_pFormatHtmlCB->Check(bool(nMailingMode & MailTextFormats::HTML));
     262           0 :     m_pFormatRtfCB->Check(bool(nMailingMode & MailTextFormats::RTF));
     263             : 
     264           0 :     m_pAllRB->Check(true);
     265             : 
     266             :     // Install handlers
     267           0 :     Link<> aLk = LINK(this, SwMailMergeDlg, ButtonHdl);
     268           0 :     m_pOkBTN->SetClickHdl(aLk);
     269             : 
     270           0 :     m_pPathPB->SetClickHdl(LINK(this, SwMailMergeDlg, InsertPathHdl));
     271             : 
     272           0 :     aLk = LINK(this, SwMailMergeDlg, OutputTypeHdl);
     273           0 :     m_pPrinterRB->SetClickHdl(aLk);
     274           0 :     m_pFileRB->SetClickHdl(aLk);
     275             : 
     276             :     //#i63267# printing might be disabled
     277           0 :     bool bIsPrintable = !Application::GetSettings().GetMiscSettings().GetDisablePrinting();
     278           0 :     m_pPrinterRB->Enable(bIsPrintable);
     279           0 :     OutputTypeHdl(bIsPrintable ? m_pPrinterRB : m_pFileRB);
     280             : 
     281           0 :     aLk = LINK(this, SwMailMergeDlg, FilenameHdl);
     282           0 :     m_pGenerateFromDataBaseCB->SetClickHdl( aLk );
     283           0 :     bool bColumn = pModOpt->IsNameFromColumn();
     284           0 :     if(bColumn)
     285           0 :         m_pGenerateFromDataBaseCB->Check();
     286             : 
     287           0 :     FilenameHdl( m_pGenerateFromDataBaseCB );
     288           0 :     aLk = LINK(this, SwMailMergeDlg, SaveTypeHdl);
     289           0 :     m_pSaveSingleDocRB->Check( true );
     290           0 :     m_pSaveSingleDocRB->SetClickHdl( aLk );
     291           0 :     m_pSaveIndividualRB->SetClickHdl( aLk );
     292           0 :     aLk.Call( m_pSaveSingleDocRB );
     293             : 
     294           0 :     aLk = LINK(this, SwMailMergeDlg, ModifyHdl);
     295           0 :     m_pFromNF->SetModifyHdl(aLk);
     296           0 :     m_pToNF->SetModifyHdl(aLk);
     297           0 :     m_pFromNF->SetMax(SAL_MAX_INT32);
     298           0 :     m_pToNF->SetMax(SAL_MAX_INT32);
     299             : 
     300           0 :     SwDBManager* pDBManager = rSh.GetDBManager();
     301           0 :     if(_xConnection.is())
     302           0 :         SwDBManager::GetColumnNames(m_pAddressFieldLB, _xConnection, rTableName);
     303             :     else
     304           0 :         pDBManager->GetColumnNames(m_pAddressFieldLB, rSourceName, rTableName);
     305           0 :     for(sal_Int32 nEntry = 0; nEntry < m_pAddressFieldLB->GetEntryCount(); ++nEntry)
     306           0 :         m_pColumnLB->InsertEntry(m_pAddressFieldLB->GetEntry(nEntry));
     307             : 
     308           0 :     m_pAddressFieldLB->SelectEntry("EMAIL");
     309             : 
     310           0 :     OUString sPath(pModOpt->GetMailingPath());
     311           0 :     if(sPath.isEmpty())
     312             :     {
     313           0 :         SvtPathOptions aPathOpt;
     314           0 :         sPath = aPathOpt.GetWorkPath();
     315             :     }
     316           0 :     INetURLObject aURL(sPath);
     317           0 :     if(aURL.GetProtocol() == INetProtocol::File)
     318           0 :         m_pPathED->SetText(aURL.PathToFileName());
     319             :     else
     320           0 :         m_pPathED->SetText(aURL.GetFull());
     321             : 
     322           0 :     if (!bColumn )
     323             :     {
     324           0 :         m_pColumnLB->SelectEntry("NAME");
     325             :     }
     326             :     else
     327           0 :         m_pColumnLB->SelectEntry(pModOpt->GetNameFromColumn());
     328             : 
     329           0 :     if (m_pAddressFieldLB->GetSelectEntryCount() == 0)
     330           0 :         m_pAddressFieldLB->SelectEntryPos(0);
     331           0 :     if (m_pColumnLB->GetSelectEntryCount() == 0)
     332           0 :         m_pColumnLB->SelectEntryPos(0);
     333             : 
     334           0 :     const bool bEnable = m_aSelection.getLength() != 0;
     335           0 :     m_pMarkedRB->Enable(bEnable);
     336           0 :     if (bEnable)
     337           0 :         m_pMarkedRB->Check();
     338             :     else
     339             :     {
     340           0 :         m_pAllRB->Check();
     341           0 :         m_pMarkedRB->Enable(false);
     342             :     }
     343           0 :     SetMinOutputSizePixel(m_aDialogSize);
     344             :     try
     345             :     {
     346             :         uno::Reference< container::XNameContainer> xFilterFactory(
     347           0 :                 xMSF->createInstance("com.sun.star.document.FilterFactory"), UNO_QUERY_THROW);
     348           0 :         uno::Reference< container::XContainerQuery > xQuery(xFilterFactory, UNO_QUERY_THROW);
     349             :         const OUString sCommand("matchByDocumentService=com.sun.star.text.TextDocument:iflags="
     350           0 :             + OUString::number(static_cast<sal_Int32>(SfxFilterFlags::EXPORT))
     351           0 :             + ":eflags="
     352           0 :             + OUString::number(static_cast<sal_Int32>(SfxFilterFlags::NOTINFILEDLG))
     353           0 :             + ":default_first");
     354           0 :         uno::Reference< container::XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand);
     355           0 :         const OUString sName("Name");
     356           0 :         sal_Int32 nODT = -1;
     357           0 :         while(xList->hasMoreElements())
     358             :         {
     359           0 :             comphelper::SequenceAsHashMap aFilter(xList->nextElement());
     360           0 :             const OUString sFilter = aFilter.getUnpackedValueOrDefault(sName, OUString());
     361             : 
     362           0 :             uno::Any aProps = xFilterFactory->getByName(sFilter);
     363           0 :             uno::Sequence< beans::PropertyValue > aFilterProperties;
     364           0 :             aProps >>= aFilterProperties;
     365           0 :             OUString sUIName2;
     366           0 :             const beans::PropertyValue* pFilterProperties = aFilterProperties.getConstArray();
     367           0 :             for(sal_Int32 nProp = 0; nProp < aFilterProperties.getLength(); ++nProp)
     368             :             {
     369           0 :                 if(pFilterProperties[nProp].Name == "UIName")
     370             :                 {
     371           0 :                     pFilterProperties[nProp].Value >>= sUIName2;
     372           0 :                     break;
     373             :                 }
     374             :             }
     375           0 :             if( !sUIName2.isEmpty() )
     376             :             {
     377           0 :                 const sal_Int32 nFilter = m_pFilterLB->InsertEntry( sUIName2 );
     378           0 :                 if( sFilter == "writer8" )
     379           0 :                     nODT = nFilter;
     380           0 :                 m_pFilterLB->SetEntryData( nFilter, new OUString( sFilter ) );
     381             :             }
     382           0 :         }
     383           0 :         m_pFilterLB->SelectEntryPos( nODT );
     384             :     }
     385           0 :     catch (const uno::Exception&)
     386             :     {
     387           0 :     }
     388           0 : }
     389             : 
     390           0 : SwMailMergeDlg::~SwMailMergeDlg()
     391             : {
     392           0 :     disposeOnce();
     393           0 : }
     394             : 
     395           0 : void SwMailMergeDlg::dispose()
     396             : {
     397           0 :     if(m_xFrame.is())
     398             :     {
     399           0 :         m_xFrame->setComponent(NULL, NULL);
     400           0 :         m_xFrame->dispose();
     401             :     }
     402             : 
     403           0 :     for( sal_Int32 nFilter = 0; nFilter < m_pFilterLB->GetEntryCount(); ++nFilter )
     404             :     {
     405           0 :         OUString* pData = static_cast< OUString* >( m_pFilterLB->GetEntryData(nFilter) );
     406           0 :         delete pData;
     407             :     }
     408           0 :     delete pImpl;
     409           0 :     m_pBeamerWin.clear();
     410           0 :     m_pAllRB.clear();
     411           0 :     m_pMarkedRB.clear();
     412           0 :     m_pFromRB.clear();
     413           0 :     m_pFromNF.clear();
     414           0 :     m_pToNF.clear();
     415           0 :     m_pPrinterRB.clear();
     416           0 :     m_pMailingRB.clear();
     417           0 :     m_pFileRB.clear();
     418           0 :     m_pSingleJobsCB.clear();
     419           0 :     m_pSaveMergedDocumentFT.clear();
     420           0 :     m_pSaveSingleDocRB.clear();
     421           0 :     m_pSaveIndividualRB.clear();
     422           0 :     m_pGenerateFromDataBaseCB.clear();
     423           0 :     m_pColumnFT.clear();
     424           0 :     m_pColumnLB.clear();
     425           0 :     m_pPathFT.clear();
     426           0 :     m_pPathED.clear();
     427           0 :     m_pPathPB.clear();
     428           0 :     m_pFilterFT.clear();
     429           0 :     m_pFilterLB.clear();
     430           0 :     m_pAddressFieldLB.clear();
     431           0 :     m_pSubjectFT.clear();
     432           0 :     m_pSubjectED.clear();
     433           0 :     m_pFormatFT.clear();
     434           0 :     m_pAttachFT.clear();
     435           0 :     m_pAttachED.clear();
     436           0 :     m_pAttachPB.clear();
     437           0 :     m_pFormatHtmlCB.clear();
     438           0 :     m_pFormatRtfCB.clear();
     439           0 :     m_pFormatSwCB.clear();
     440           0 :     m_pOkBTN.clear();
     441           0 :     SvxStandardDialog::dispose();
     442           0 : }
     443             : 
     444           0 : void SwMailMergeDlg::Apply()
     445             : {
     446           0 : }
     447             : 
     448           0 : IMPL_LINK( SwMailMergeDlg, ButtonHdl, Button *, pBtn )
     449             : {
     450           0 :     if (pBtn == m_pOkBTN)
     451             :     {
     452           0 :         if( ExecQryShell() )
     453           0 :             EndDialog(RET_OK);
     454             :     }
     455           0 :     return 0;
     456             : }
     457             : 
     458           0 : IMPL_LINK( SwMailMergeDlg, OutputTypeHdl, RadioButton *, pBtn )
     459             : {
     460           0 :     bool bPrint = pBtn == m_pPrinterRB;
     461           0 :     m_pSingleJobsCB->Enable(bPrint);
     462             : 
     463           0 :     m_pSaveMergedDocumentFT->Enable( !bPrint );
     464           0 :     m_pSaveSingleDocRB->Enable( !bPrint );
     465           0 :     m_pSaveIndividualRB->Enable( !bPrint );
     466             : 
     467           0 :     if( !bPrint )
     468             :     {
     469           0 :         SaveTypeHdl( m_pSaveSingleDocRB->IsChecked() ? m_pSaveSingleDocRB : m_pSaveIndividualRB );
     470             :     }
     471             :     else
     472             :     {
     473           0 :         m_pPathFT->Enable(false);
     474           0 :         m_pPathED->Enable(false);
     475           0 :         m_pPathPB->Enable(false);
     476           0 :         m_pColumnFT->Enable(false);
     477           0 :         m_pColumnLB->Enable(false);
     478           0 :         m_pFilterFT->Enable(false);
     479           0 :         m_pFilterLB->Enable(false);
     480           0 :         m_pGenerateFromDataBaseCB->Enable(false);
     481             :     }
     482             : 
     483           0 :     return 0;
     484             : }
     485             : 
     486           0 : IMPL_LINK( SwMailMergeDlg, SaveTypeHdl, RadioButton*,  pBtn )
     487             : {
     488           0 :     bool bIndividual = pBtn == m_pSaveIndividualRB;
     489             : 
     490           0 :     m_pGenerateFromDataBaseCB->Enable( bIndividual );
     491           0 :     if( bIndividual )
     492             :     {
     493           0 :         FilenameHdl( m_pGenerateFromDataBaseCB );
     494             :     }
     495             :     else
     496             :     {
     497           0 :         m_pColumnFT->Enable(false);
     498           0 :         m_pColumnLB->Enable(false);
     499           0 :         m_pPathFT->Enable( false );
     500           0 :         m_pPathED->Enable( false );
     501           0 :         m_pPathPB->Enable( false );
     502           0 :         m_pFilterFT->Enable( false );
     503           0 :         m_pFilterLB->Enable( false );
     504             :     }
     505           0 :     return 0;
     506             : }
     507             : 
     508           0 : IMPL_LINK( SwMailMergeDlg, FilenameHdl, CheckBox*, pBox )
     509             : {
     510           0 :     bool bEnable = pBox->IsChecked();
     511           0 :     m_pColumnFT->Enable( bEnable );
     512           0 :     m_pColumnLB->Enable(bEnable);
     513           0 :     m_pPathFT->Enable( bEnable );
     514           0 :     m_pPathED->Enable(bEnable);
     515           0 :     m_pPathPB->Enable( bEnable );
     516           0 :     m_pFilterFT->Enable( bEnable );
     517           0 :     m_pFilterLB->Enable( bEnable );
     518           0 :  return 0;
     519             : }
     520             : 
     521           0 : IMPL_LINK_NOARG(SwMailMergeDlg, ModifyHdl)
     522             : {
     523           0 :     m_pFromRB->Check();
     524           0 :     return 0;
     525             : }
     526             : 
     527           0 : bool SwMailMergeDlg::ExecQryShell()
     528             : {
     529           0 :     if(pImpl->xSelSupp.is())
     530             :     {
     531           0 :         pImpl->xSelSupp->removeSelectionChangeListener(  pImpl->xChgLstnr );
     532             :     }
     533           0 :     SwDBManager* pMgr = rSh.GetDBManager();
     534             : 
     535           0 :     if (m_pPrinterRB->IsChecked())
     536           0 :         nMergeType = DBMGR_MERGE_PRINTER;
     537             :     else
     538             :     {
     539           0 :         nMergeType = DBMGR_MERGE_FILE;
     540           0 :         SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
     541           0 :         INetURLObject aAbs;
     542           0 :         if( pMedium )
     543           0 :             aAbs = pMedium->GetURLObject();
     544             :         OUString sPath(
     545             :             URIHelper::SmartRel2Abs(
     546           0 :                 aAbs, m_pPathED->GetText(), URIHelper::GetMaybeFileHdl()));
     547           0 :         pModOpt->SetMailingPath(sPath);
     548             : 
     549           0 :         if (!sPath.endsWith("/"))
     550           0 :             sPath += "/";
     551             : 
     552           0 :         pModOpt->SetIsNameFromColumn(m_pGenerateFromDataBaseCB->IsChecked());
     553             : 
     554           0 :         if (m_pGenerateFromDataBaseCB->IsEnabled() && m_pGenerateFromDataBaseCB->IsChecked())
     555             :         {
     556           0 :             pMgr->SetEMailColumn(m_pColumnLB->GetSelectEntry());
     557           0 :             pModOpt->SetNameFromColumn(m_pColumnLB->GetSelectEntry());
     558           0 :             if( m_pFilterLB->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
     559           0 :                 m_sSaveFilter = *static_cast<const OUString*>(m_pFilterLB->GetSelectEntryData());
     560             :         }
     561             :         else
     562             :         {
     563             :             //#i97667# reset column name - otherwise it's remembered from the last run
     564           0 :             pMgr->SetEMailColumn(OUString());
     565             :             //start save as dialog
     566           0 :             OUString sFilter;
     567           0 :             sPath = SwMailMergeHelper::CallSaveAsDialog(sFilter);
     568           0 :             if (sPath.isEmpty())
     569           0 :                 return false;
     570           0 :             m_sSaveFilter = sFilter;
     571             :         }
     572             : 
     573           0 :         pMgr->SetSubject(sPath);
     574             :     }
     575             : 
     576           0 :     if (m_pFromRB->IsChecked())    // Insert list
     577             :     {
     578             :         // Safe: the maximal value of the fields is limited
     579           0 :         sal_Int32 nStart = sal::static_int_cast<sal_Int32>(m_pFromNF->GetValue());
     580           0 :         sal_Int32 nEnd = sal::static_int_cast<sal_Int32>(m_pToNF->GetValue());
     581             : 
     582           0 :         if (nEnd < nStart)
     583           0 :             std::swap(nEnd, nStart);
     584             : 
     585           0 :         m_aSelection.realloc(nEnd - nStart + 1);
     586           0 :         Any* pSelection = m_aSelection.getArray();
     587           0 :         for (sal_Int32 i = nStart; i <= nEnd; ++i, ++pSelection)
     588           0 :             *pSelection <<= i;
     589             :     }
     590           0 :     else if (m_pAllRB->IsChecked() )
     591           0 :         m_aSelection.realloc(0);    // Empty selection = insert all
     592             :     else
     593             :     {
     594           0 :         if(pImpl->xSelSupp.is())
     595             :         {
     596             :             //update selection
     597           0 :             uno::Reference< XRowLocate > xRowLocate(GetResultSet(),UNO_QUERY);
     598           0 :             uno::Reference< XResultSet > xRes(xRowLocate,UNO_QUERY);
     599           0 :             pImpl->xSelSupp->getSelection() >>= m_aSelection;
     600           0 :             if ( xRowLocate.is() )
     601             :             {
     602           0 :                 Any* pBegin = m_aSelection.getArray();
     603           0 :                 Any* pEnd   = pBegin + m_aSelection.getLength();
     604           0 :                 for (;pBegin != pEnd ; ++pBegin)
     605             :                 {
     606           0 :                     if ( xRowLocate->moveToBookmark(*pBegin) )
     607           0 :                         *pBegin <<= xRes->getRow();
     608             :                 }
     609           0 :             }
     610             :         }
     611             :     }
     612           0 :     IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess();
     613           0 :     SwPrintData aPrtData( pIDDA->getPrintData() );
     614           0 :     aPrtData.SetPrintSingleJobs(m_pSingleJobsCB->IsChecked());
     615           0 :     pIDDA->setPrintData(aPrtData);
     616             : 
     617           0 :     pModOpt->SetSinglePrintJob(m_pSingleJobsCB->IsChecked());
     618             : 
     619           0 :     MailTextFormats nMailingMode = MailTextFormats::NONE;
     620             : 
     621           0 :     if (m_pFormatSwCB->IsChecked())
     622           0 :         nMailingMode |= MailTextFormats::OFFICE;
     623           0 :     if (m_pFormatHtmlCB->IsChecked())
     624           0 :         nMailingMode |= MailTextFormats::HTML;
     625           0 :     if (m_pFormatRtfCB->IsChecked())
     626           0 :         nMailingMode |= MailTextFormats::RTF;
     627           0 :     pModOpt->SetMailingFormats(nMailingMode);
     628           0 :     return true;
     629             : }
     630             : 
     631           0 : IMPL_LINK_NOARG(SwMailMergeDlg, InsertPathHdl)
     632             : {
     633           0 :     OUString sPath( m_pPathED->GetText() );
     634           0 :     if( sPath.isEmpty() )
     635             :     {
     636           0 :         SvtPathOptions aPathOpt;
     637           0 :         sPath = aPathOpt.GetWorkPath();
     638             :     }
     639             : 
     640           0 :     uno::Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     641           0 :     uno::Reference < XFolderPicker2 > xFP = FolderPicker::create(xContext);
     642           0 :     xFP->setDisplayDirectory(sPath);
     643           0 :     if( xFP->execute() == RET_OK )
     644             :     {
     645           0 :         INetURLObject aURL(xFP->getDirectory());
     646           0 :         if(aURL.GetProtocol() == INetProtocol::File)
     647           0 :             m_pPathED->SetText(aURL.PathToFileName());
     648             :         else
     649           0 :             m_pPathED->SetText(aURL.GetFull());
     650             :     }
     651           0 :     return 0;
     652             : }
     653             : 
     654           0 : uno::Reference<XResultSet> SwMailMergeDlg::GetResultSet() const
     655             : {
     656           0 :     uno::Reference< XResultSet >  xResSetClone;
     657           0 :     if ( pImpl->xFController.is() )
     658             :     {
     659             :         // we create a clone to do the task
     660           0 :         uno::Reference< XResultSetAccess > xResultSetAccess( pImpl->xFController->getModel(),UNO_QUERY);
     661           0 :         if ( xResultSetAccess.is() )
     662           0 :             xResSetClone = xResultSetAccess->createResultSet();
     663             :     }
     664           0 :     return xResSetClone;
     665             : }
     666             : 
     667           0 : SwMailMergeCreateFromDlg::SwMailMergeCreateFromDlg(vcl::Window* pParent)
     668             :     : ModalDialog(pParent, "MailMergeDialog",
     669           0 :         "modules/swriter/ui/mailmergedialog.ui")
     670             : {
     671           0 :     get(m_pThisDocRB, "document");
     672           0 : }
     673             : 
     674           0 : SwMailMergeCreateFromDlg::~SwMailMergeCreateFromDlg()
     675             : {
     676           0 :     disposeOnce();
     677           0 : }
     678             : 
     679           0 : void SwMailMergeCreateFromDlg::dispose()
     680             : {
     681           0 :     m_pThisDocRB.clear();
     682           0 :     ModalDialog::dispose();
     683           0 : }
     684             : 
     685           0 : SwMailMergeFieldConnectionsDlg::SwMailMergeFieldConnectionsDlg(vcl::Window* pParent)
     686             :     : ModalDialog(pParent, "MergeConnectDialog",
     687           0 :         "modules/swriter/ui/mergeconnectdialog.ui")
     688             : {
     689           0 :     get(m_pUseExistingRB, "existing");
     690           0 : }
     691             : 
     692           0 : SwMailMergeFieldConnectionsDlg::~SwMailMergeFieldConnectionsDlg()
     693             : {
     694           0 :     disposeOnce();
     695           0 : }
     696             : 
     697           0 : void SwMailMergeFieldConnectionsDlg::dispose()
     698             : {
     699           0 :     m_pUseExistingRB.clear();
     700           0 :     ModalDialog::dispose();
     701           0 : }
     702             : 
     703             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11