LCOV - code coverage report
Current view: top level - sw/source/ui/envelp - mailmrge.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 349 0.0 %
Date: 2014-11-03 Functions: 0 29 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/implbase1.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::WeakImplHelper1
      87             : <
      88             :     view::XSelectionChangeListener
      89             : >
      90             : {
      91             :     SwMailMergeDlg& rParent;
      92             : public:
      93             :     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& rTblName,
     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_pAddressFldLB, "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 <<= rTblName;
     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 :     sal_Int16 nMailingMode(pModOpt->GetMailingFormats());
     260           0 :     m_pFormatSwCB->Check((nMailingMode & TXTFORMAT_OFFICE) != 0);
     261           0 :     m_pFormatHtmlCB->Check((nMailingMode & TXTFORMAT_HTML) != 0);
     262           0 :     m_pFormatRtfCB->Check((nMailingMode & TXTFORMAT_RTF) != 0);
     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 :         pDBManager->GetColumnNames(m_pAddressFldLB, _xConnection, rTblName);
     303             :     else
     304           0 :         pDBManager->GetColumnNames(m_pAddressFldLB, rSourceName, rTblName);
     305           0 :     for(sal_Int32 nEntry = 0; nEntry < m_pAddressFldLB->GetEntryCount(); ++nEntry)
     306           0 :         m_pColumnLB->InsertEntry(m_pAddressFldLB->GetEntry(nEntry));
     307             : 
     308           0 :     m_pAddressFldLB->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() == INET_PROT_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_pAddressFldLB->GetSelectEntryCount() == 0)
     330           0 :         m_pAddressFldLB->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(SFX_FILTER_EXPORT)
     351           0 :             + ":eflags="
     352           0 :             + OUString::number(SFX_FILTER_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.equalsAscii("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 :     if(m_xFrame.is())
     393             :     {
     394           0 :         m_xFrame->setComponent(NULL, NULL);
     395           0 :         m_xFrame->dispose();
     396             :     }
     397             : 
     398           0 :     for( sal_Int32 nFilter = 0; nFilter < m_pFilterLB->GetEntryCount(); ++nFilter )
     399             :     {
     400           0 :         OUString* pData = reinterpret_cast< OUString* >( m_pFilterLB->GetEntryData(nFilter) );
     401           0 :         delete pData;
     402             :     }
     403           0 :     delete pImpl;
     404           0 : }
     405             : 
     406           0 : void SwMailMergeDlg::Apply()
     407             : {
     408           0 : }
     409             : 
     410           0 : IMPL_LINK( SwMailMergeDlg, ButtonHdl, Button *, pBtn )
     411             : {
     412           0 :     if (pBtn == m_pOkBTN)
     413             :     {
     414           0 :         if( ExecQryShell() )
     415           0 :             EndDialog(RET_OK);
     416             :     }
     417           0 :     return 0;
     418             : }
     419             : 
     420           0 : IMPL_LINK( SwMailMergeDlg, OutputTypeHdl, RadioButton *, pBtn )
     421             : {
     422           0 :     bool bPrint = pBtn == m_pPrinterRB;
     423           0 :     m_pSingleJobsCB->Enable(bPrint);
     424             : 
     425           0 :     m_pSaveMergedDocumentFT->Enable( !bPrint );
     426           0 :     m_pSaveSingleDocRB->Enable( !bPrint );
     427           0 :     m_pSaveIndividualRB->Enable( !bPrint );
     428             : 
     429           0 :     if( !bPrint )
     430             :     {
     431           0 :         SaveTypeHdl( m_pSaveSingleDocRB->IsChecked() ? m_pSaveSingleDocRB : m_pSaveIndividualRB );
     432             :     }
     433             :     else
     434             :     {
     435           0 :         m_pPathFT->Enable(false);
     436           0 :         m_pPathED->Enable(false);
     437           0 :         m_pPathPB->Enable(false);
     438           0 :         m_pColumnFT->Enable(false);
     439           0 :         m_pColumnLB->Enable(false);
     440           0 :         m_pFilterFT->Enable(false);
     441           0 :         m_pFilterLB->Enable(false);
     442           0 :         m_pGenerateFromDataBaseCB->Enable(false);
     443             :     }
     444             : 
     445           0 :     return 0;
     446             : }
     447             : 
     448           0 : IMPL_LINK( SwMailMergeDlg, SaveTypeHdl, RadioButton*,  pBtn )
     449             : {
     450           0 :     bool bIndividual = pBtn == m_pSaveIndividualRB;
     451             : 
     452           0 :     m_pGenerateFromDataBaseCB->Enable( bIndividual );
     453           0 :     if( bIndividual )
     454             :     {
     455           0 :         FilenameHdl( m_pGenerateFromDataBaseCB );
     456             :     }
     457             :     else
     458             :     {
     459           0 :         m_pColumnFT->Enable(false);
     460           0 :         m_pColumnLB->Enable(false);
     461           0 :         m_pPathFT->Enable( false );
     462           0 :         m_pPathED->Enable( false );
     463           0 :         m_pPathPB->Enable( false );
     464           0 :         m_pFilterFT->Enable( false );
     465           0 :         m_pFilterLB->Enable( false );
     466             :     }
     467           0 :     return 0;
     468             : }
     469             : 
     470           0 : IMPL_LINK( SwMailMergeDlg, FilenameHdl, CheckBox*, pBox )
     471             : {
     472           0 :     bool bEnable = pBox->IsChecked();
     473           0 :     m_pColumnFT->Enable( bEnable );
     474           0 :     m_pColumnLB->Enable(bEnable);
     475           0 :     m_pPathFT->Enable( bEnable );
     476           0 :     m_pPathED->Enable(bEnable);
     477           0 :     m_pPathPB->Enable( bEnable );
     478           0 :     m_pFilterFT->Enable( bEnable );
     479           0 :     m_pFilterLB->Enable( bEnable );
     480           0 :  return 0;
     481             : }
     482             : 
     483           0 : IMPL_LINK_NOARG(SwMailMergeDlg, ModifyHdl)
     484             : {
     485           0 :     m_pFromRB->Check();
     486           0 :     return (0);
     487             : }
     488             : 
     489           0 : bool SwMailMergeDlg::ExecQryShell()
     490             : {
     491           0 :     if(pImpl->xSelSupp.is())
     492             :     {
     493           0 :         pImpl->xSelSupp->removeSelectionChangeListener(  pImpl->xChgLstnr );
     494             :     }
     495           0 :     SwDBManager* pMgr = rSh.GetDBManager();
     496             : 
     497           0 :     if (m_pPrinterRB->IsChecked())
     498           0 :         nMergeType = DBMGR_MERGE_PRINTER;
     499             :     else
     500             :     {
     501           0 :         nMergeType = DBMGR_MERGE_FILE;
     502           0 :         SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
     503           0 :         INetURLObject aAbs;
     504           0 :         if( pMedium )
     505           0 :             aAbs = pMedium->GetURLObject();
     506             :         OUString sPath(
     507             :             URIHelper::SmartRel2Abs(
     508           0 :                 aAbs, m_pPathED->GetText(), URIHelper::GetMaybeFileHdl()));
     509           0 :         pModOpt->SetMailingPath(sPath);
     510             : 
     511           0 :         if (!sPath.endsWith("/"))
     512           0 :             sPath += "/";
     513             : 
     514           0 :         pModOpt->SetIsNameFromColumn(m_pGenerateFromDataBaseCB->IsChecked());
     515             : 
     516           0 :         if (m_pGenerateFromDataBaseCB->IsEnabled() && m_pGenerateFromDataBaseCB->IsChecked())
     517             :         {
     518           0 :             pMgr->SetEMailColumn(m_pColumnLB->GetSelectEntry());
     519           0 :             pModOpt->SetNameFromColumn(m_pColumnLB->GetSelectEntry());
     520           0 :             if( m_pFilterLB->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
     521           0 :                 m_sSaveFilter = *static_cast<const OUString*>(m_pFilterLB->GetEntryData( m_pFilterLB->GetSelectEntryPos() ));
     522             :         }
     523             :         else
     524             :         {
     525             :             //#i97667# reset column name - otherwise it's remembered from the last run
     526           0 :             pMgr->SetEMailColumn(OUString());
     527             :             //start save as dialog
     528           0 :             OUString sFilter;
     529           0 :             sPath = SwMailMergeHelper::CallSaveAsDialog(sFilter);
     530           0 :             if (sPath.isEmpty())
     531           0 :                 return false;
     532           0 :             m_sSaveFilter = sFilter;
     533             :         }
     534             : 
     535           0 :         pMgr->SetSubject(sPath);
     536             :     }
     537             : 
     538           0 :     if (m_pFromRB->IsChecked())    // Insert list
     539             :     {
     540             :         // Safe: the maximal value of the fields is limited
     541           0 :         sal_Int32 nStart = sal::static_int_cast<sal_Int32>(m_pFromNF->GetValue());
     542           0 :         sal_Int32 nEnd = sal::static_int_cast<sal_Int32>(m_pToNF->GetValue());
     543             : 
     544           0 :         if (nEnd < nStart)
     545           0 :             std::swap(nEnd, nStart);
     546             : 
     547           0 :         m_aSelection.realloc(nEnd - nStart + 1);
     548           0 :         Any* pSelection = m_aSelection.getArray();
     549           0 :         for (sal_Int32 i = nStart; i <= nEnd; ++i, ++pSelection)
     550           0 :             *pSelection <<= i;
     551             :     }
     552           0 :     else if (m_pAllRB->IsChecked() )
     553           0 :         m_aSelection.realloc(0);    // Empty selection = insert all
     554             :     else
     555             :     {
     556           0 :         if(pImpl->xSelSupp.is())
     557             :         {
     558             :             //update selection
     559           0 :             uno::Reference< XRowLocate > xRowLocate(GetResultSet(),UNO_QUERY);
     560           0 :             uno::Reference< XResultSet > xRes(xRowLocate,UNO_QUERY);
     561           0 :             pImpl->xSelSupp->getSelection() >>= m_aSelection;
     562           0 :             if ( xRowLocate.is() )
     563             :             {
     564           0 :                 Any* pBegin = m_aSelection.getArray();
     565           0 :                 Any* pEnd   = pBegin + m_aSelection.getLength();
     566           0 :                 for (;pBegin != pEnd ; ++pBegin)
     567             :                 {
     568           0 :                     if ( xRowLocate->moveToBookmark(*pBegin) )
     569           0 :                         *pBegin <<= xRes->getRow();
     570             :                 }
     571           0 :             }
     572             :         }
     573             :     }
     574           0 :     IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess();
     575           0 :     SwPrintData aPrtData( pIDDA->getPrintData() );
     576           0 :     aPrtData.SetPrintSingleJobs(m_pSingleJobsCB->IsChecked());
     577           0 :     pIDDA->setPrintData(aPrtData);
     578             : 
     579           0 :     pModOpt->SetSinglePrintJob(m_pSingleJobsCB->IsChecked());
     580             : 
     581           0 :     sal_uInt8 nMailingMode = 0;
     582             : 
     583           0 :     if (m_pFormatSwCB->IsChecked())
     584           0 :         nMailingMode |= TXTFORMAT_OFFICE;
     585           0 :     if (m_pFormatHtmlCB->IsChecked())
     586           0 :         nMailingMode |= TXTFORMAT_HTML;
     587           0 :     if (m_pFormatRtfCB->IsChecked())
     588           0 :         nMailingMode |= TXTFORMAT_RTF;
     589           0 :     pModOpt->SetMailingFormats(nMailingMode);
     590           0 :     return true;
     591             : }
     592             : 
     593           0 : IMPL_LINK_NOARG(SwMailMergeDlg, InsertPathHdl)
     594             : {
     595           0 :     OUString sPath( m_pPathED->GetText() );
     596           0 :     if( sPath.isEmpty() )
     597             :     {
     598           0 :         SvtPathOptions aPathOpt;
     599           0 :         sPath = aPathOpt.GetWorkPath();
     600             :     }
     601             : 
     602           0 :     uno::Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     603           0 :     uno::Reference < XFolderPicker2 > xFP = FolderPicker::create(xContext);
     604           0 :     xFP->setDisplayDirectory(sPath);
     605           0 :     if( xFP->execute() == RET_OK )
     606             :     {
     607           0 :         INetURLObject aURL(xFP->getDirectory());
     608           0 :         if(aURL.GetProtocol() == INET_PROT_FILE)
     609           0 :             m_pPathED->SetText(aURL.PathToFileName());
     610             :         else
     611           0 :             m_pPathED->SetText(aURL.GetFull());
     612             :     }
     613           0 :     return 0;
     614             : }
     615             : 
     616           0 : uno::Reference<XResultSet> SwMailMergeDlg::GetResultSet() const
     617             : {
     618           0 :     uno::Reference< XResultSet >  xResSetClone;
     619           0 :     if ( pImpl->xFController.is() )
     620             :     {
     621             :         // we create a clone to do the task
     622           0 :         uno::Reference< XResultSetAccess > xResultSetAccess( pImpl->xFController->getModel(),UNO_QUERY);
     623           0 :         if ( xResultSetAccess.is() )
     624           0 :             xResSetClone = xResultSetAccess->createResultSet();
     625             :     }
     626           0 :     return xResSetClone;
     627             : }
     628             : 
     629           0 : SwMailMergeCreateFromDlg::SwMailMergeCreateFromDlg(vcl::Window* pParent)
     630             :     : ModalDialog(pParent, "MailMergeDialog",
     631           0 :         "modules/swriter/ui/mailmergedialog.ui")
     632             : {
     633           0 :     get(m_pThisDocRB, "document");
     634           0 : }
     635             : 
     636           0 : SwMailMergeFieldConnectionsDlg::SwMailMergeFieldConnectionsDlg(vcl::Window* pParent)
     637             :     : ModalDialog(pParent, "MergeConnectDialog",
     638           0 :         "modules/swriter/ui/mergeconnectdialog.ui")
     639             : {
     640           0 :     get(m_pUseExistingRB, "existing");
     641           0 : }
     642             : 
     643             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10