1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION 31*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 36*cdf0e10cSrcweir #include <vcl/svapp.hxx> 37*cdf0e10cSrcweir #include <tools/urlobj.hxx> 38*cdf0e10cSrcweir #include <svl/urihelper.hxx> 39*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 40*cdf0e10cSrcweir #include <svl/mailenum.hxx> 41*cdf0e10cSrcweir #include <svx/svxdlg.hxx> 42*cdf0e10cSrcweir #include <svx/dialogs.hrc> 43*cdf0e10cSrcweir #include <helpid.h> 44*cdf0e10cSrcweir #include <view.hxx> 45*cdf0e10cSrcweir #include <docsh.hxx> 46*cdf0e10cSrcweir #include <IDocumentDeviceAccess.hxx> 47*cdf0e10cSrcweir #include <wrtsh.hxx> 48*cdf0e10cSrcweir #include <dbmgr.hxx> 49*cdf0e10cSrcweir #include <dbui.hxx> 50*cdf0e10cSrcweir #include <prtopt.hxx> 51*cdf0e10cSrcweir #include <swmodule.hxx> 52*cdf0e10cSrcweir #include <modcfg.hxx> 53*cdf0e10cSrcweir #include <mailmergehelper.hxx> 54*cdf0e10cSrcweir #include <envelp.hrc> 55*cdf0e10cSrcweir #include <mailmrge.hrc> 56*cdf0e10cSrcweir #include <mailmrge.hxx> 57*cdf0e10cSrcweir #include <sfx2/docfile.hxx> 58*cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 59*cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx> 60*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFolderPicker.hpp> 61*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp> 62*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 63*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XRowLocate.hpp> 64*cdf0e10cSrcweir #include <com/sun/star/sdb/XResultSetAccess.hpp> 65*cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp> 66*cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 67*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 68*cdf0e10cSrcweir #include <com/sun/star/form/runtime/XFormController.hpp> 69*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 70*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 71*cdf0e10cSrcweir #include <com/sun/star/container/XContainerQuery.hpp> 72*cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp> 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir #include <unomid.h> 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir #include <algorithm> 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir using namespace rtl; 79*cdf0e10cSrcweir using namespace ::com::sun::star; 80*cdf0e10cSrcweir using namespace ::com::sun::star::container; 81*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 82*cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 83*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 84*cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 85*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 86*cdf0e10cSrcweir using namespace ::com::sun::star::util; 87*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 88*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 89*cdf0e10cSrcweir using namespace ::com::sun::star::form; 90*cdf0e10cSrcweir using namespace ::com::sun::star::view; 91*cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir /* -----------------------------05.06.01 13:54-------------------------------- 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 97*cdf0e10cSrcweir struct SwMailMergeDlg_Impl 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir uno::Reference<runtime::XFormController> xFController; 100*cdf0e10cSrcweir uno::Reference<XSelectionChangeListener> xChgLstnr; 101*cdf0e10cSrcweir uno::Reference<XSelectionSupplier> xSelSupp; 102*cdf0e10cSrcweir }; 103*cdf0e10cSrcweir /* -----------------------------05.06.01 13:47-------------------------------- 104*cdf0e10cSrcweir helper classes 105*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 106*cdf0e10cSrcweir class SwXSelChgLstnr_Impl : public cppu::WeakImplHelper1 107*cdf0e10cSrcweir < 108*cdf0e10cSrcweir view::XSelectionChangeListener 109*cdf0e10cSrcweir > 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir SwMailMergeDlg& rParent; 112*cdf0e10cSrcweir public: 113*cdf0e10cSrcweir SwXSelChgLstnr_Impl(SwMailMergeDlg& rParentDlg); 114*cdf0e10cSrcweir ~SwXSelChgLstnr_Impl(); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir virtual void SAL_CALL selectionChanged( const EventObject& aEvent ) throw (RuntimeException); 117*cdf0e10cSrcweir virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException); 118*cdf0e10cSrcweir }; 119*cdf0e10cSrcweir /* -----------------------------05.06.01 13:51-------------------------------- 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 122*cdf0e10cSrcweir SwXSelChgLstnr_Impl::SwXSelChgLstnr_Impl(SwMailMergeDlg& rParentDlg) : 123*cdf0e10cSrcweir rParent(rParentDlg) 124*cdf0e10cSrcweir {} 125*cdf0e10cSrcweir /* -----------------------------05.06.01 14:06-------------------------------- 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 128*cdf0e10cSrcweir SwXSelChgLstnr_Impl::~SwXSelChgLstnr_Impl() 129*cdf0e10cSrcweir {} 130*cdf0e10cSrcweir /* -----------------------------05.06.01 14:06-------------------------------- 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 133*cdf0e10cSrcweir void SwXSelChgLstnr_Impl::selectionChanged( const EventObject& ) throw (RuntimeException) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir //call the parent to enable selection mode 136*cdf0e10cSrcweir Sequence <Any> aSelection; 137*cdf0e10cSrcweir if(rParent.pImpl->xSelSupp.is()) 138*cdf0e10cSrcweir rParent.pImpl->xSelSupp->getSelection() >>= aSelection; 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir sal_Bool bEnable = aSelection.getLength() > 0; 141*cdf0e10cSrcweir rParent.aMarkedRB.Enable(bEnable); 142*cdf0e10cSrcweir if(bEnable) 143*cdf0e10cSrcweir rParent.aMarkedRB.Check(); 144*cdf0e10cSrcweir else if(rParent.aMarkedRB.IsChecked()) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir rParent.aAllRB.Check(); 147*cdf0e10cSrcweir rParent.m_aSelection.realloc(0); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir /* -----------------------------05.06.01 14:06-------------------------------- 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 153*cdf0e10cSrcweir void SwXSelChgLstnr_Impl::disposing( const EventObject& ) throw (RuntimeException) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir DBG_ERROR("disposing"); 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir /*------------------------------------------------------------------------ 158*cdf0e10cSrcweir Beschreibung: 159*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 160*cdf0e10cSrcweir SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell, 161*cdf0e10cSrcweir const String& rSourceName, 162*cdf0e10cSrcweir const String& rTblName, 163*cdf0e10cSrcweir sal_Int32 nCommandType, 164*cdf0e10cSrcweir const uno::Reference< XConnection>& _xConnection, 165*cdf0e10cSrcweir Sequence< Any >* pSelection) : 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir SvxStandardDialog(pParent, SW_RES(DLG_MAILMERGE)), 168*cdf0e10cSrcweir pBeamerWin (new Window(this, SW_RES(WIN_BEAMER))), 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir aAllRB (this, SW_RES(RB_ALL)), 171*cdf0e10cSrcweir aMarkedRB (this, SW_RES(RB_MARKED)), 172*cdf0e10cSrcweir aFromRB (this, SW_RES(RB_FROM)), 173*cdf0e10cSrcweir aFromNF (this, SW_RES(NF_FROM)), 174*cdf0e10cSrcweir aBisFT (this, SW_RES(FT_BIS)), 175*cdf0e10cSrcweir aToNF (this, SW_RES(NF_TO)), 176*cdf0e10cSrcweir aRecordFL (this, SW_RES(FL_RECORD)), 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir aSeparatorFL (this, SW_RES(FL_SEPARATOR)), 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir aPrinterRB (this, SW_RES(RB_PRINTER)), 181*cdf0e10cSrcweir aMailingRB (this, SW_RES(RB_MAILING)), 182*cdf0e10cSrcweir aFileRB (this, SW_RES(RB_FILE)), 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir aSingleJobsCB (this, SW_RES(CB_SINGLE_JOBS)), 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir aSaveMergedDocumentFL(this, SW_RES( FL_SAVE_MERGED_DOCUMENT)), 187*cdf0e10cSrcweir aSaveSingleDocRB(this, SW_RES( RB_SAVE_SINGLE_DOC )), 188*cdf0e10cSrcweir aSaveIndividualRB(this, SW_RES( RB_SAVE_INDIVIDUAL )), 189*cdf0e10cSrcweir aGenerateFromDataBaseCB(this, SW_RES( RB_GENERATE_FROM_DATABASE )), 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir aColumnFT (this, SW_RES(FT_COLUMN)), 192*cdf0e10cSrcweir aColumnLB (this, SW_RES(LB_COLUMN)), 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir aPathFT (this, SW_RES(FT_PATH)), 195*cdf0e10cSrcweir aPathED (this, SW_RES(ED_PATH)), 196*cdf0e10cSrcweir aPathPB (this, SW_RES(PB_PATH)), 197*cdf0e10cSrcweir aFilterFT (this, SW_RES(FT_FILTER)), 198*cdf0e10cSrcweir aFilterLB (this, SW_RES(LB_FILTER)), 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir aAddressFldLB (this, SW_RES(LB_ADDRESSFLD)), 201*cdf0e10cSrcweir aSubjectFT (this, SW_RES(FT_SUBJECT)), 202*cdf0e10cSrcweir aSubjectED (this, SW_RES(ED_SUBJECT)), 203*cdf0e10cSrcweir aFormatFT (this, SW_RES(FT_FORMAT)), 204*cdf0e10cSrcweir aAttachFT (this, SW_RES(FT_ATTACH)), 205*cdf0e10cSrcweir aAttachED (this, SW_RES(ED_ATTACH)), 206*cdf0e10cSrcweir aAttachPB (this, SW_RES(PB_ATTACH)), 207*cdf0e10cSrcweir aFormatHtmlCB (this, SW_RES(CB_FORMAT_HTML)), 208*cdf0e10cSrcweir aFormatRtfCB (this, SW_RES(CB_FORMAT_RTF)), 209*cdf0e10cSrcweir aFormatSwCB (this, SW_RES(CB_FORMAT_SW)), 210*cdf0e10cSrcweir aDestFL (this, SW_RES(FL_DEST)), 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir aBottomSeparatorFL(this, SW_RES(FL_BOTTOM_SEPARATOR)), 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir aOkBTN (this, SW_RES(BTN_OK)), 215*cdf0e10cSrcweir aCancelBTN (this, SW_RES(BTN_CANCEL)), 216*cdf0e10cSrcweir aHelpBTN (this, SW_RES(BTN_HELP)), 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir pImpl (new SwMailMergeDlg_Impl), 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir rSh (rShell), 221*cdf0e10cSrcweir rDBName (rSourceName), 222*cdf0e10cSrcweir rTableName (rTblName), 223*cdf0e10cSrcweir nMergeType (DBMGR_MERGE_MAILING), 224*cdf0e10cSrcweir m_aDialogSize( GetSizePixel() ) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir FreeResource(); 227*cdf0e10cSrcweir aSingleJobsCB.Show(sal_False); // not supported in since cws printerpullpages anymore 228*cdf0e10cSrcweir //task #97066# mailing of form letters is currently not supported 229*cdf0e10cSrcweir aMailingRB.Show(sal_False); 230*cdf0e10cSrcweir aSubjectFT.Show(sal_False); 231*cdf0e10cSrcweir aSubjectED.Show(sal_False); 232*cdf0e10cSrcweir aFormatFT.Show(sal_False); 233*cdf0e10cSrcweir aFormatSwCB.Show(sal_False); 234*cdf0e10cSrcweir aFormatHtmlCB.Show(sal_False); 235*cdf0e10cSrcweir aFormatRtfCB.Show(sal_False); 236*cdf0e10cSrcweir aAttachFT.Show(sal_False); 237*cdf0e10cSrcweir aAttachED.Show(sal_False); 238*cdf0e10cSrcweir aAttachPB.Show(sal_False); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir Point aMailPos = aMailingRB.GetPosPixel(); 241*cdf0e10cSrcweir Point aFilePos = aFileRB.GetPosPixel(); 242*cdf0e10cSrcweir aFilePos.X() -= (aFilePos.X() - aMailPos.X()) /2; 243*cdf0e10cSrcweir aFileRB.SetPosPixel(aFilePos); 244*cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xMSF = comphelper::getProcessServiceFactory(); 245*cdf0e10cSrcweir if(pSelection) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir m_aSelection = *pSelection; 248*cdf0e10cSrcweir //move all controls 249*cdf0e10cSrcweir long nDiff = aRecordFL.GetPosPixel().Y() - pBeamerWin->GetPosPixel().Y(); 250*cdf0e10cSrcweir pBeamerWin->Show(sal_False); 251*cdf0e10cSrcweir ::Size aSize = GetSizePixel(); 252*cdf0e10cSrcweir aSize.Height() -= nDiff; 253*cdf0e10cSrcweir SetSizePixel(aSize); 254*cdf0e10cSrcweir Window* aCntrlArr[] = { 255*cdf0e10cSrcweir &aAllRB , 256*cdf0e10cSrcweir &aMarkedRB , 257*cdf0e10cSrcweir &aFromRB , 258*cdf0e10cSrcweir &aFromNF , 259*cdf0e10cSrcweir &aBisFT , 260*cdf0e10cSrcweir &aToNF , 261*cdf0e10cSrcweir &aRecordFL , 262*cdf0e10cSrcweir &aPrinterRB , 263*cdf0e10cSrcweir &aMailingRB , 264*cdf0e10cSrcweir &aFileRB , 265*cdf0e10cSrcweir &aSingleJobsCB, 266*cdf0e10cSrcweir &aPathFT , 267*cdf0e10cSrcweir &aPathED , 268*cdf0e10cSrcweir &aPathPB , 269*cdf0e10cSrcweir &aFilterFT , 270*cdf0e10cSrcweir &aFilterLB , 271*cdf0e10cSrcweir &aColumnLB , 272*cdf0e10cSrcweir &aAddressFldLB, 273*cdf0e10cSrcweir &aSubjectFT , 274*cdf0e10cSrcweir &aSubjectED , 275*cdf0e10cSrcweir &aFormatFT , 276*cdf0e10cSrcweir &aAttachFT , 277*cdf0e10cSrcweir &aAttachED , 278*cdf0e10cSrcweir &aAttachPB , 279*cdf0e10cSrcweir &aFormatHtmlCB, 280*cdf0e10cSrcweir &aFormatRtfCB , 281*cdf0e10cSrcweir &aFormatSwCB , 282*cdf0e10cSrcweir &aDestFL , 283*cdf0e10cSrcweir &aSeparatorFL , 284*cdf0e10cSrcweir 0}; 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir for( Window** ppW = aCntrlArr; *ppW; ++ppW ) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir ::Point aPnt( (*ppW)->GetPosPixel() ); 289*cdf0e10cSrcweir aPnt.Y() -= nDiff; 290*cdf0e10cSrcweir (*ppW)->SetPosPixel( aPnt ); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir else 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir try 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir // create a frame wrapper for myself 298*cdf0e10cSrcweir uno::Reference< XMultiServiceFactory > 299*cdf0e10cSrcweir xMgr = comphelper::getProcessServiceFactory(); 300*cdf0e10cSrcweir xFrame = uno::Reference< XFrame >(xMgr->createInstance(C2U("com.sun.star.frame.Frame")), UNO_QUERY); 301*cdf0e10cSrcweir if(xFrame.is()) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir xFrame->initialize( VCLUnoHelper::GetInterface ( pBeamerWin ) ); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir catch (Exception&) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir xFrame.clear(); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir if(xFrame.is()) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir uno::Reference<XDispatchProvider> xDP(xFrame, UNO_QUERY); 313*cdf0e10cSrcweir URL aURL; 314*cdf0e10cSrcweir aURL.Complete = C2U(".component:DB/DataSourceBrowser"); 315*cdf0e10cSrcweir uno::Reference<XDispatch> xD = xDP->queryDispatch(aURL, 316*cdf0e10cSrcweir C2U(""), 317*cdf0e10cSrcweir 0x0C); 318*cdf0e10cSrcweir if(xD.is()) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir Sequence<PropertyValue> aProperties(3); 321*cdf0e10cSrcweir PropertyValue* pProperties = aProperties.getArray(); 322*cdf0e10cSrcweir pProperties[0].Name = C2U("DataSourceName"); 323*cdf0e10cSrcweir pProperties[0].Value <<= OUString(rSourceName); 324*cdf0e10cSrcweir pProperties[1].Name = C2U("Command"); 325*cdf0e10cSrcweir pProperties[1].Value <<= OUString(rTableName); 326*cdf0e10cSrcweir pProperties[2].Name = C2U("CommandType"); 327*cdf0e10cSrcweir pProperties[2].Value <<= nCommandType; 328*cdf0e10cSrcweir xD->dispatch(aURL, aProperties); 329*cdf0e10cSrcweir pBeamerWin->Show(); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir uno::Reference<XController> xController = xFrame->getController(); 332*cdf0e10cSrcweir pImpl->xFController = uno::Reference<runtime::XFormController>(xController, UNO_QUERY); 333*cdf0e10cSrcweir if(pImpl->xFController.is()) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir uno::Reference< awt::XControl > xCtrl = pImpl->xFController->getCurrentControl( ); 336*cdf0e10cSrcweir pImpl->xSelSupp = uno::Reference<XSelectionSupplier>(xCtrl, UNO_QUERY); 337*cdf0e10cSrcweir if(pImpl->xSelSupp.is()) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir pImpl->xChgLstnr = new SwXSelChgLstnr_Impl(*this); 340*cdf0e10cSrcweir pImpl->xSelSupp->addSelectionChangeListener( pImpl->xChgLstnr ); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir pModOpt = SW_MOD()->GetModuleConfig(); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir //aSingleJobsCB.Check(pModOpt->IsSinglePrintJob());// not supported in since cws printerpullpages anymore 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir sal_Int16 nMailingMode(pModOpt->GetMailingFormats()); 351*cdf0e10cSrcweir aFormatSwCB.Check((nMailingMode & TXTFORMAT_OFFICE) != 0); 352*cdf0e10cSrcweir aFormatHtmlCB.Check((nMailingMode & TXTFORMAT_HTML) != 0); 353*cdf0e10cSrcweir aFormatRtfCB.Check((nMailingMode & TXTFORMAT_RTF) != 0); 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir aAllRB.Check(sal_True); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir // Handler installieren 358*cdf0e10cSrcweir Link aLk = LINK(this, SwMailMergeDlg, ButtonHdl); 359*cdf0e10cSrcweir aOkBTN.SetClickHdl(aLk); 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir aPathPB.SetClickHdl(LINK(this, SwMailMergeDlg, InsertPathHdl)); 362*cdf0e10cSrcweir aAttachPB.SetClickHdl(LINK(this, SwMailMergeDlg, AttachFileHdl)); 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir aLk = LINK(this, SwMailMergeDlg, OutputTypeHdl); 365*cdf0e10cSrcweir aPrinterRB.SetClickHdl(aLk); 366*cdf0e10cSrcweir aMailingRB.SetClickHdl(aLk); 367*cdf0e10cSrcweir aFileRB.SetClickHdl(aLk); 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir //#i63267# printing might be disabled 370*cdf0e10cSrcweir bool bIsPrintable = !Application::GetSettings().GetMiscSettings().GetDisablePrinting(); 371*cdf0e10cSrcweir aPrinterRB.Enable(bIsPrintable); 372*cdf0e10cSrcweir OutputTypeHdl(bIsPrintable ? &aPrinterRB : &aFileRB); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir aLk = LINK(this, SwMailMergeDlg, FilenameHdl); 375*cdf0e10cSrcweir aGenerateFromDataBaseCB.SetClickHdl( aLk ); 376*cdf0e10cSrcweir sal_Bool bColumn = pModOpt->IsNameFromColumn(); 377*cdf0e10cSrcweir if(bColumn) 378*cdf0e10cSrcweir aGenerateFromDataBaseCB.Check(); 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir FilenameHdl( &aGenerateFromDataBaseCB ); 381*cdf0e10cSrcweir aLk = LINK(this, SwMailMergeDlg, SaveTypeHdl); 382*cdf0e10cSrcweir aSaveSingleDocRB.Check( true ); 383*cdf0e10cSrcweir aSaveSingleDocRB.SetClickHdl( aLk ); 384*cdf0e10cSrcweir aSaveIndividualRB.SetClickHdl( aLk ); 385*cdf0e10cSrcweir aLk.Call( &aSaveSingleDocRB ); 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir aLk = LINK(this, SwMailMergeDlg, ModifyHdl); 388*cdf0e10cSrcweir aFromNF.SetModifyHdl(aLk); 389*cdf0e10cSrcweir aToNF.SetModifyHdl(aLk); 390*cdf0e10cSrcweir aFromNF.SetMax(SAL_MAX_INT32); 391*cdf0e10cSrcweir aToNF.SetMax(SAL_MAX_INT32); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr(); 394*cdf0e10cSrcweir if(_xConnection.is()) 395*cdf0e10cSrcweir pNewDBMgr->GetColumnNames(&aAddressFldLB, _xConnection, rTableName); 396*cdf0e10cSrcweir else 397*cdf0e10cSrcweir pNewDBMgr->GetColumnNames(&aAddressFldLB, rDBName, rTableName); 398*cdf0e10cSrcweir for(sal_uInt16 nEntry = 0; nEntry < aAddressFldLB.GetEntryCount(); nEntry++) 399*cdf0e10cSrcweir aColumnLB.InsertEntry(aAddressFldLB.GetEntry(nEntry)); 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir aAddressFldLB.SelectEntry(C2S("EMAIL")); 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir String sPath(pModOpt->GetMailingPath()); 404*cdf0e10cSrcweir if(!sPath.Len()) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir SvtPathOptions aPathOpt; 407*cdf0e10cSrcweir sPath = aPathOpt.GetWorkPath(); 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir INetURLObject aURL(sPath); 410*cdf0e10cSrcweir if(aURL.GetProtocol() == INET_PROT_FILE) 411*cdf0e10cSrcweir aPathED.SetText(aURL.PathToFileName()); 412*cdf0e10cSrcweir else 413*cdf0e10cSrcweir aPathED.SetText(aURL.GetFull()); 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir if (!bColumn ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir aColumnLB.SelectEntry(C2S("NAME")); 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir else 420*cdf0e10cSrcweir aColumnLB.SelectEntry(pModOpt->GetNameFromColumn()); 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir if (aAddressFldLB.GetSelectEntryCount() == 0) 423*cdf0e10cSrcweir aAddressFldLB.SelectEntryPos(0); 424*cdf0e10cSrcweir if (aColumnLB.GetSelectEntryCount() == 0) 425*cdf0e10cSrcweir aColumnLB.SelectEntryPos(0); 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir const sal_Bool bEnable = m_aSelection.getLength() != 0; 428*cdf0e10cSrcweir aMarkedRB.Enable(bEnable); 429*cdf0e10cSrcweir if (bEnable) 430*cdf0e10cSrcweir aMarkedRB.Check(); 431*cdf0e10cSrcweir else 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir aAllRB.Check(); 434*cdf0e10cSrcweir aMarkedRB.Enable(sal_False); 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir SetMinOutputSizePixel(m_aDialogSize); 437*cdf0e10cSrcweir try 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir uno::Reference< container::XNameContainer> xFilterFactory( 440*cdf0e10cSrcweir xMSF->createInstance(C2U("com.sun.star.document.FilterFactory")), UNO_QUERY_THROW); 441*cdf0e10cSrcweir uno::Reference< container::XContainerQuery > xQuery(xFilterFactory, UNO_QUERY_THROW); 442*cdf0e10cSrcweir OUString sCommand(C2U("matchByDocumentService=com.sun.star.text.TextDocument:iflags=")); 443*cdf0e10cSrcweir sCommand += String::CreateFromInt32(SFX_FILTER_EXPORT); 444*cdf0e10cSrcweir sCommand += C2U(":eflags="); 445*cdf0e10cSrcweir sCommand += String::CreateFromInt32(SFX_FILTER_NOTINFILEDLG); 446*cdf0e10cSrcweir sCommand += C2U(":default_first"); 447*cdf0e10cSrcweir uno::Reference< container::XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand); 448*cdf0e10cSrcweir const ::rtl::OUString sName = OUString::createFromAscii("Name"); 449*cdf0e10cSrcweir const ::rtl::OUString sFlags = OUString::createFromAscii("Flags"); 450*cdf0e10cSrcweir const ::rtl::OUString sUIName = OUString::createFromAscii("UIName"); 451*cdf0e10cSrcweir sal_uInt16 nODT = USHRT_MAX; 452*cdf0e10cSrcweir while(xList->hasMoreElements()) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir comphelper::SequenceAsHashMap aFilter(xList->nextElement()); 455*cdf0e10cSrcweir OUString sFilter = aFilter.getUnpackedValueOrDefault(sName, OUString()); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir uno::Any aProps = xFilterFactory->getByName(sFilter); 458*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aFilterProperties; 459*cdf0e10cSrcweir aProps >>= aFilterProperties; 460*cdf0e10cSrcweir ::rtl::OUString sUIName2; 461*cdf0e10cSrcweir const beans::PropertyValue* pFilterProperties = aFilterProperties.getConstArray(); 462*cdf0e10cSrcweir for(int nProp = 0; nProp < aFilterProperties.getLength(); nProp++) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir if(!pFilterProperties[nProp].Name.compareToAscii("UIName")) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir pFilterProperties[nProp].Value >>= sUIName2; 467*cdf0e10cSrcweir break; 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir if( sUIName2.getLength() ) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir sal_uInt16 nFilter = aFilterLB.InsertEntry( sUIName2 ); 473*cdf0e10cSrcweir if( 0 == sFilter.compareToAscii("writer8") ) 474*cdf0e10cSrcweir nODT = nFilter; 475*cdf0e10cSrcweir aFilterLB.SetEntryData( nFilter, new ::rtl::OUString( sFilter ) ); 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir aFilterLB.SelectEntryPos( nODT ); 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir catch( const uno::Exception& ) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir /*------------------------------------------------------------------------ 486*cdf0e10cSrcweir Beschreibung: 487*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir SwMailMergeDlg::~SwMailMergeDlg() 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir if(xFrame.is()) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir xFrame->setComponent(NULL, NULL); 494*cdf0e10cSrcweir xFrame->dispose(); 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir else 497*cdf0e10cSrcweir delete pBeamerWin; 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir for( sal_uInt16 nFilter = 0; nFilter < aFilterLB.GetEntryCount(); ++nFilter ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir ::rtl::OUString* pData = reinterpret_cast< ::rtl::OUString* >( aFilterLB.GetEntryData(nFilter) ); 502*cdf0e10cSrcweir delete pData; 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir delete pImpl; 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir /*------------------------------------------------------------------------ 508*cdf0e10cSrcweir Beschreibung: 509*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir void SwMailMergeDlg::Apply() 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir /*-- 01.06.2007 13:06:50--------------------------------------------------- 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 517*cdf0e10cSrcweir void lcl_MoveControlY( Window* ppW, long nDiffSize ) 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir Point aPos( ppW->GetPosPixel()); 520*cdf0e10cSrcweir aPos.Y() += nDiffSize; 521*cdf0e10cSrcweir ppW->SetPosPixel( aPos ); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir void lcl_MoveControlX( Window* ppW, long nDiffSize ) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir Point aPos( ppW->GetPosPixel()); 526*cdf0e10cSrcweir aPos.X() += nDiffSize; 527*cdf0e10cSrcweir ppW->SetPosPixel( aPos ); 528*cdf0e10cSrcweir } 529*cdf0e10cSrcweir void lcl_ChangeWidth( Window* ppW, long nDiffSize ) 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir Size aSize( ppW->GetSizePixel()); 532*cdf0e10cSrcweir aSize.Width() += nDiffSize; 533*cdf0e10cSrcweir ppW->SetSizePixel( aSize ); 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir void SwMailMergeDlg::Resize() 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir //the only controls that profit from the resize is pBeamerWin 538*cdf0e10cSrcweir // and aPathED, aFilenameED and aColumnLB 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir Size aCurSize( GetSizePixel() ); 541*cdf0e10cSrcweir //find the difference 542*cdf0e10cSrcweir Size aDiffSize( aCurSize.Width() - m_aDialogSize.Width(), 543*cdf0e10cSrcweir aCurSize.Height() - m_aDialogSize.Height() ); 544*cdf0e10cSrcweir m_aDialogSize = aCurSize; 545*cdf0e10cSrcweir if( pBeamerWin->IsVisible() ) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir Window* aCntrlArr[] = { 548*cdf0e10cSrcweir &aAllRB , 549*cdf0e10cSrcweir &aMarkedRB , 550*cdf0e10cSrcweir &aFromRB , 551*cdf0e10cSrcweir &aFromNF , 552*cdf0e10cSrcweir &aBisFT , 553*cdf0e10cSrcweir &aToNF , 554*cdf0e10cSrcweir &aRecordFL , 555*cdf0e10cSrcweir &aPrinterRB , 556*cdf0e10cSrcweir &aMailingRB , 557*cdf0e10cSrcweir &aFileRB , 558*cdf0e10cSrcweir &aSingleJobsCB, 559*cdf0e10cSrcweir &aSaveMergedDocumentFL, 560*cdf0e10cSrcweir &aSaveSingleDocRB, 561*cdf0e10cSrcweir &aSaveIndividualRB, 562*cdf0e10cSrcweir &aGenerateFromDataBaseCB, 563*cdf0e10cSrcweir &aPathFT , 564*cdf0e10cSrcweir &aPathED , 565*cdf0e10cSrcweir &aPathPB , 566*cdf0e10cSrcweir &aColumnFT, 567*cdf0e10cSrcweir &aColumnLB , 568*cdf0e10cSrcweir &aFilterFT , 569*cdf0e10cSrcweir &aFilterLB , 570*cdf0e10cSrcweir &aAddressFldLB, 571*cdf0e10cSrcweir &aSubjectFT , 572*cdf0e10cSrcweir &aSubjectED , 573*cdf0e10cSrcweir &aFormatFT , 574*cdf0e10cSrcweir &aAttachFT , 575*cdf0e10cSrcweir &aAttachED , 576*cdf0e10cSrcweir &aAttachPB , 577*cdf0e10cSrcweir &aFormatHtmlCB, 578*cdf0e10cSrcweir &aFormatRtfCB , 579*cdf0e10cSrcweir &aFormatSwCB , 580*cdf0e10cSrcweir &aDestFL , 581*cdf0e10cSrcweir &aSeparatorFL , 582*cdf0e10cSrcweir &aBottomSeparatorFL, 583*cdf0e10cSrcweir &aOkBTN, 584*cdf0e10cSrcweir &aCancelBTN, 585*cdf0e10cSrcweir &aHelpBTN, 586*cdf0e10cSrcweir 0}; 587*cdf0e10cSrcweir for( Window** ppW = aCntrlArr; *ppW; ++ppW ) 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir lcl_MoveControlY( *ppW, aDiffSize.Height() ); 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir //some controls have to be extended horizontally 592*cdf0e10cSrcweir lcl_MoveControlX( &aOkBTN, aDiffSize.Width() ); 593*cdf0e10cSrcweir lcl_MoveControlX( &aCancelBTN, aDiffSize.Width() ); 594*cdf0e10cSrcweir lcl_MoveControlX( &aHelpBTN, aDiffSize.Width() ); 595*cdf0e10cSrcweir lcl_MoveControlX( &aPathPB, aDiffSize.Width() ); 596*cdf0e10cSrcweir lcl_MoveControlX( &aFileRB, aDiffSize.Width()/2 ); 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir lcl_ChangeWidth( &aBottomSeparatorFL, aDiffSize.Width() ); 599*cdf0e10cSrcweir lcl_ChangeWidth( &aSaveMergedDocumentFL, aDiffSize.Width() ); 600*cdf0e10cSrcweir lcl_ChangeWidth( &aColumnLB, aDiffSize.Width() ); 601*cdf0e10cSrcweir lcl_ChangeWidth( &aPathED, aDiffSize.Width() ); 602*cdf0e10cSrcweir lcl_ChangeWidth( &aFilterLB, aDiffSize.Width() ); 603*cdf0e10cSrcweir lcl_ChangeWidth( &aDestFL, aDiffSize.Width() ); 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir Size aBeamerSize( pBeamerWin->GetSizePixel() ) ; 606*cdf0e10cSrcweir aBeamerSize.Width() += aDiffSize.Width(); 607*cdf0e10cSrcweir aBeamerSize.Height() += aDiffSize.Height(); 608*cdf0e10cSrcweir pBeamerWin->SetSizePixel(aBeamerSize); 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir /*------------------------------------------------------------------------ 613*cdf0e10cSrcweir Beschreibung: 614*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir IMPL_LINK( SwMailMergeDlg, ButtonHdl, Button *, pBtn ) 617*cdf0e10cSrcweir { 618*cdf0e10cSrcweir if (pBtn == &aOkBTN) 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir if( ExecQryShell() ) 621*cdf0e10cSrcweir EndDialog(RET_OK); 622*cdf0e10cSrcweir } 623*cdf0e10cSrcweir return 0; 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir /*------------------------------------------------------------------------ 627*cdf0e10cSrcweir Beschreibung: 628*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir IMPL_LINK( SwMailMergeDlg, OutputTypeHdl, RadioButton *, pBtn ) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir sal_Bool bPrint = pBtn == &aPrinterRB; 633*cdf0e10cSrcweir aSingleJobsCB.Enable(bPrint); 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir aSaveMergedDocumentFL.Enable( !bPrint ); 636*cdf0e10cSrcweir aSaveSingleDocRB.Enable( !bPrint ); 637*cdf0e10cSrcweir aSaveIndividualRB.Enable( !bPrint ); 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir if( !bPrint ) 640*cdf0e10cSrcweir { 641*cdf0e10cSrcweir SaveTypeHdl( aSaveSingleDocRB.IsChecked() ? &aSaveSingleDocRB : &aSaveIndividualRB ); 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir else 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir aPathFT.Enable(false); 646*cdf0e10cSrcweir aPathED.Enable(false); 647*cdf0e10cSrcweir aPathPB.Enable(false); 648*cdf0e10cSrcweir aColumnFT.Enable(false); 649*cdf0e10cSrcweir aColumnLB.Enable(false); 650*cdf0e10cSrcweir aFilterFT.Enable(false); 651*cdf0e10cSrcweir aFilterLB.Enable(false); 652*cdf0e10cSrcweir aGenerateFromDataBaseCB.Enable(false); 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir return 0; 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir /*-- 01.06.2007 12:36:43--------------------------------------------------- 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 660*cdf0e10cSrcweir IMPL_LINK( SwMailMergeDlg, SaveTypeHdl, RadioButton*, pBtn ) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir bool bIndividual = pBtn == &aSaveIndividualRB; 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir aGenerateFromDataBaseCB.Enable( bIndividual ); 665*cdf0e10cSrcweir if( bIndividual ) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir FilenameHdl( &aGenerateFromDataBaseCB ); 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir else 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir aColumnFT.Enable(false); 672*cdf0e10cSrcweir aColumnLB.Enable(false); 673*cdf0e10cSrcweir aPathFT.Enable( false ); 674*cdf0e10cSrcweir aPathED.Enable( false ); 675*cdf0e10cSrcweir aPathPB.Enable( false ); 676*cdf0e10cSrcweir aFilterFT.Enable( false ); 677*cdf0e10cSrcweir aFilterLB.Enable( false ); 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir return 0; 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir /*------------------------------------------------------------------------ 682*cdf0e10cSrcweir Beschreibung: 683*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir IMPL_LINK( SwMailMergeDlg, FilenameHdl, CheckBox*, pBox ) 686*cdf0e10cSrcweir { 687*cdf0e10cSrcweir sal_Bool bEnable = pBox->IsChecked(); 688*cdf0e10cSrcweir aColumnFT.Enable( bEnable ); 689*cdf0e10cSrcweir aColumnLB.Enable(bEnable); 690*cdf0e10cSrcweir aPathFT.Enable( bEnable ); 691*cdf0e10cSrcweir aPathED.Enable(bEnable); 692*cdf0e10cSrcweir aPathPB.Enable( bEnable ); 693*cdf0e10cSrcweir aFilterFT.Enable( bEnable ); 694*cdf0e10cSrcweir aFilterLB.Enable( bEnable ); 695*cdf0e10cSrcweir return 0; 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir /*------------------------------------------------------------------------ 699*cdf0e10cSrcweir Beschreibung: 700*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir IMPL_LINK( SwMailMergeDlg, ModifyHdl, NumericField *, EMPTYARG ) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir aFromRB.Check(); 705*cdf0e10cSrcweir return (0); 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir /*------------------------------------------------------------------------ 709*cdf0e10cSrcweir Beschreibung: 710*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir bool SwMailMergeDlg::ExecQryShell() 713*cdf0e10cSrcweir { 714*cdf0e10cSrcweir if(pImpl->xSelSupp.is()) 715*cdf0e10cSrcweir { 716*cdf0e10cSrcweir pImpl->xSelSupp->removeSelectionChangeListener( pImpl->xChgLstnr ); 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir SwNewDBMgr* pMgr = rSh.GetNewDBMgr(); 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir if (aPrinterRB.IsChecked()) 721*cdf0e10cSrcweir nMergeType = DBMGR_MERGE_MAILMERGE; 722*cdf0e10cSrcweir else if (aMailingRB.IsChecked()) 723*cdf0e10cSrcweir { 724*cdf0e10cSrcweir nMergeType = DBMGR_MERGE_MAILING; 725*cdf0e10cSrcweir pMgr->SetEMailColumn(aAddressFldLB.GetSelectEntry()); 726*cdf0e10cSrcweir pMgr->SetSubject(aSubjectED.GetText()); 727*cdf0e10cSrcweir pMgr->SetAttachment(aAttachED.GetText()); 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir else 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir nMergeType = static_cast< sal_uInt16 >( aSaveSingleDocRB.IsChecked() ? 732*cdf0e10cSrcweir DBMGR_MERGE_SINGLE_FILE : DBMGR_MERGE_MAILFILES ); 733*cdf0e10cSrcweir SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium(); 734*cdf0e10cSrcweir INetURLObject aAbs; 735*cdf0e10cSrcweir if( pMedium ) 736*cdf0e10cSrcweir aAbs = pMedium->GetURLObject(); 737*cdf0e10cSrcweir String sPath( 738*cdf0e10cSrcweir URIHelper::SmartRel2Abs( 739*cdf0e10cSrcweir aAbs, aPathED.GetText(), URIHelper::GetMaybeFileHdl())); 740*cdf0e10cSrcweir pModOpt->SetMailingPath(sPath); 741*cdf0e10cSrcweir String sDelim(INET_PATH_TOKEN); 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir if (sPath.Len() >= sDelim.Len() && 744*cdf0e10cSrcweir sPath.Copy(sPath.Len()-sDelim.Len()).CompareTo(sDelim) != COMPARE_EQUAL) 745*cdf0e10cSrcweir sPath += sDelim; 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir pModOpt->SetIsNameFromColumn(aGenerateFromDataBaseCB.IsChecked()); 748*cdf0e10cSrcweir 749*cdf0e10cSrcweir if (aGenerateFromDataBaseCB.IsEnabled() && aGenerateFromDataBaseCB.IsChecked()) 750*cdf0e10cSrcweir { 751*cdf0e10cSrcweir pMgr->SetEMailColumn(aColumnLB.GetSelectEntry()); 752*cdf0e10cSrcweir pModOpt->SetNameFromColumn(aColumnLB.GetSelectEntry()); 753*cdf0e10cSrcweir if( aFilterLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND) 754*cdf0e10cSrcweir m_sSaveFilter = *static_cast<const ::rtl::OUString*>(aFilterLB.GetEntryData( aFilterLB.GetSelectEntryPos() )); 755*cdf0e10cSrcweir } 756*cdf0e10cSrcweir else 757*cdf0e10cSrcweir { 758*cdf0e10cSrcweir //#i97667# reset column name - otherwise it's remembered from the last run 759*cdf0e10cSrcweir pMgr->SetEMailColumn(::rtl::OUString()); 760*cdf0e10cSrcweir //start save as dialog 761*cdf0e10cSrcweir String sFilter; 762*cdf0e10cSrcweir sPath = SwMailMergeHelper::CallSaveAsDialog(sFilter); 763*cdf0e10cSrcweir if(!sPath.Len()) 764*cdf0e10cSrcweir return false; 765*cdf0e10cSrcweir m_sSaveFilter = sFilter; 766*cdf0e10cSrcweir } 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir pMgr->SetSubject(sPath); 769*cdf0e10cSrcweir } 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir if (aFromRB.IsChecked()) // Liste Einfuegen 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir // Safe: the maximal value of the fields is limited 774*cdf0e10cSrcweir sal_Int32 nStart = sal::static_int_cast<sal_Int32>(aFromNF.GetValue()); 775*cdf0e10cSrcweir sal_Int32 nEnd = sal::static_int_cast<sal_Int32>(aToNF.GetValue()); 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir if (nEnd < nStart) 778*cdf0e10cSrcweir std::swap(nEnd, nStart); 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir m_aSelection.realloc(nEnd - nStart + 1); 781*cdf0e10cSrcweir Any* pSelection = m_aSelection.getArray(); 782*cdf0e10cSrcweir for (sal_Int32 i = nStart; i <= nEnd; ++i, ++pSelection) 783*cdf0e10cSrcweir *pSelection <<= i; 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir else if (aAllRB.IsChecked() ) 786*cdf0e10cSrcweir m_aSelection.realloc(0); // Leere Selektion = Alles einfuegen 787*cdf0e10cSrcweir else 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir if(pImpl->xSelSupp.is()) 790*cdf0e10cSrcweir { 791*cdf0e10cSrcweir //update selection 792*cdf0e10cSrcweir uno::Reference< XRowLocate > xRowLocate(GetResultSet(),UNO_QUERY); 793*cdf0e10cSrcweir uno::Reference< XResultSet > xRes(xRowLocate,UNO_QUERY); 794*cdf0e10cSrcweir pImpl->xSelSupp->getSelection() >>= m_aSelection; 795*cdf0e10cSrcweir if ( xRowLocate.is() ) 796*cdf0e10cSrcweir { 797*cdf0e10cSrcweir Any* pBegin = m_aSelection.getArray(); 798*cdf0e10cSrcweir Any* pEnd = pBegin + m_aSelection.getLength(); 799*cdf0e10cSrcweir for (;pBegin != pEnd ; ++pBegin) 800*cdf0e10cSrcweir { 801*cdf0e10cSrcweir if ( xRowLocate->moveToBookmark(*pBegin) ) 802*cdf0e10cSrcweir *pBegin <<= xRes->getRow(); 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir } 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess(); 808*cdf0e10cSrcweir SwPrintData aPrtData( pIDDA->getPrintData() ); 809*cdf0e10cSrcweir aPrtData.SetPrintSingleJobs(aSingleJobsCB.IsChecked()); 810*cdf0e10cSrcweir pIDDA->setPrintData(aPrtData); 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir pModOpt->SetSinglePrintJob(aSingleJobsCB.IsChecked()); 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir sal_uInt8 nMailingMode = 0; 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir if (aFormatSwCB.IsChecked()) 817*cdf0e10cSrcweir nMailingMode |= TXTFORMAT_OFFICE; 818*cdf0e10cSrcweir if (aFormatHtmlCB.IsChecked()) 819*cdf0e10cSrcweir nMailingMode |= TXTFORMAT_HTML; 820*cdf0e10cSrcweir if (aFormatRtfCB.IsChecked()) 821*cdf0e10cSrcweir nMailingMode |= TXTFORMAT_RTF; 822*cdf0e10cSrcweir pModOpt->SetMailingFormats(nMailingMode); 823*cdf0e10cSrcweir return true; 824*cdf0e10cSrcweir } 825*cdf0e10cSrcweir 826*cdf0e10cSrcweir /*------------------------------------------------------------------------ 827*cdf0e10cSrcweir Beschreibung: 828*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir IMPL_LINK( SwMailMergeDlg, InsertPathHdl, PushButton *, EMPTYARG ) 831*cdf0e10cSrcweir { 832*cdf0e10cSrcweir String sPath( aPathED.GetText() ); 833*cdf0e10cSrcweir if( !sPath.Len() ) 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir SvtPathOptions aPathOpt; 836*cdf0e10cSrcweir sPath = aPathOpt.GetWorkPath(); 837*cdf0e10cSrcweir } 838*cdf0e10cSrcweir 839*cdf0e10cSrcweir uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); 840*cdf0e10cSrcweir uno::Reference < XFolderPicker > xFP; 841*cdf0e10cSrcweir if( xMgr.is() ) 842*cdf0e10cSrcweir { 843*cdf0e10cSrcweir xFP = uno::Reference< XFolderPicker >( 844*cdf0e10cSrcweir xMgr->createInstance( 845*cdf0e10cSrcweir C2U( "com.sun.star.ui.dialogs.FolderPicker" ) ), 846*cdf0e10cSrcweir UNO_QUERY ); 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir // pFileDlg->SetHelpId(HID_FILEDLG_MAILMRGE1); 849*cdf0e10cSrcweir xFP->setDisplayDirectory(sPath); 850*cdf0e10cSrcweir if( xFP->execute() == RET_OK ) 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir INetURLObject aURL(xFP->getDirectory()); 853*cdf0e10cSrcweir if(aURL.GetProtocol() == INET_PROT_FILE) 854*cdf0e10cSrcweir aPathED.SetText(aURL.PathToFileName()); 855*cdf0e10cSrcweir else 856*cdf0e10cSrcweir aPathED.SetText(aURL.GetFull()); 857*cdf0e10cSrcweir } 858*cdf0e10cSrcweir return 0; 859*cdf0e10cSrcweir } 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir /*------------------------------------------------------------------------ 862*cdf0e10cSrcweir Beschreibung: 863*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 864*cdf0e10cSrcweir 865*cdf0e10cSrcweir IMPL_LINK( SwMailMergeDlg, AttachFileHdl, PushButton *, EMPTYARG ) 866*cdf0e10cSrcweir { 867*cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 868*cdf0e10cSrcweir if(pFact) 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir AbstractSvxMultiFileDialog* pFileDlg = pFact->CreateSvxMultiFileDialog( this ); 871*cdf0e10cSrcweir DBG_ASSERT(pFileDlg, "Dialogdiet fail!"); 872*cdf0e10cSrcweir pFileDlg->SetFiles(aAttachED.GetText()); 873*cdf0e10cSrcweir pFileDlg->SetHelpId(HID_FILEDLG_MAILMRGE2); 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir if (pFileDlg->Execute()) 876*cdf0e10cSrcweir aAttachED.SetText(pFileDlg->GetFiles()); 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir delete pFileDlg; 879*cdf0e10cSrcweir } 880*cdf0e10cSrcweir return 0; 881*cdf0e10cSrcweir } 882*cdf0e10cSrcweir /* -----------------------------05.06.01 14:56-------------------------------- 883*cdf0e10cSrcweir 884*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 885*cdf0e10cSrcweir uno::Reference<XResultSet> SwMailMergeDlg::GetResultSet() const 886*cdf0e10cSrcweir { 887*cdf0e10cSrcweir uno::Reference< XResultSet > xResSetClone; 888*cdf0e10cSrcweir if ( pImpl->xFController.is() ) 889*cdf0e10cSrcweir { 890*cdf0e10cSrcweir // we create a clone to do the task 891*cdf0e10cSrcweir uno::Reference< XResultSetAccess > xResultSetAccess( pImpl->xFController->getModel(),UNO_QUERY); 892*cdf0e10cSrcweir if ( xResultSetAccess.is() ) 893*cdf0e10cSrcweir xResSetClone = xResultSetAccess->createResultSet(); 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir return xResSetClone; 896*cdf0e10cSrcweir } 897*cdf0e10cSrcweir /*-- 27.11.2002 12:27:33--------------------------------------------------- 898*cdf0e10cSrcweir 899*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 900*cdf0e10cSrcweir SwMailMergeCreateFromDlg::SwMailMergeCreateFromDlg(Window* pParent) : 901*cdf0e10cSrcweir ModalDialog(pParent, SW_RES(DLG_MERGE_CREATE)), 902*cdf0e10cSrcweir aCreateFromFL( this, SW_RES( FL_CREATEFROM )), 903*cdf0e10cSrcweir aThisDocRB( this, SW_RES( RB_THISDOC )), 904*cdf0e10cSrcweir aUseTemplateRB( this, SW_RES( RB_TEMPLATE )), 905*cdf0e10cSrcweir aOK( this, SW_RES( BT_OK )), 906*cdf0e10cSrcweir aCancel( this, SW_RES( BT_CANCEL )), 907*cdf0e10cSrcweir aHelp( this, SW_RES( BT_HELP )) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir FreeResource(); 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir /*-- 27.11.2002 12:27:33--------------------------------------------------- 912*cdf0e10cSrcweir 913*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 914*cdf0e10cSrcweir SwMailMergeCreateFromDlg::~SwMailMergeCreateFromDlg() 915*cdf0e10cSrcweir { 916*cdf0e10cSrcweir } 917*cdf0e10cSrcweir /* -----------------04.02.2003 13:45----------------- 918*cdf0e10cSrcweir * 919*cdf0e10cSrcweir * --------------------------------------------------*/ 920*cdf0e10cSrcweir SwMailMergeFieldConnectionsDlg::SwMailMergeFieldConnectionsDlg(Window* pParent) : 921*cdf0e10cSrcweir ModalDialog(pParent, SW_RES(DLG_MERGE_FIELD_CONNECTIONS)), 922*cdf0e10cSrcweir aConnectionsFL( this, SW_RES( FL_CONNECTIONS )), 923*cdf0e10cSrcweir aUseExistingRB( this, SW_RES( RB_USEEXISTING )), 924*cdf0e10cSrcweir aCreateNewRB( this, SW_RES( RB_CREATENEW )), 925*cdf0e10cSrcweir aInfoFI( this, SW_RES( FT_INFO )), 926*cdf0e10cSrcweir aOK( this, SW_RES( BT_OK )), 927*cdf0e10cSrcweir aCancel( this, SW_RES( BT_CANCEL )), 928*cdf0e10cSrcweir aHelp( this, SW_RES( BT_HELP )) 929*cdf0e10cSrcweir { 930*cdf0e10cSrcweir FreeResource(); 931*cdf0e10cSrcweir } 932*cdf0e10cSrcweir /* -----------------04.02.2003 13:45----------------- 933*cdf0e10cSrcweir * 934*cdf0e10cSrcweir * --------------------------------------------------*/ 935*cdf0e10cSrcweir SwMailMergeFieldConnectionsDlg::~SwMailMergeFieldConnectionsDlg() 936*cdf0e10cSrcweir { 937*cdf0e10cSrcweir } 938*cdf0e10cSrcweir 939