xref: /AOO41X/main/sw/source/ui/dbui/mmoutputpage.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 #include <mmoutputpage.hxx>
34*cdf0e10cSrcweir #include <mailmergewizard.hxx>
35*cdf0e10cSrcweir #include <mmconfigitem.hxx>
36*cdf0e10cSrcweir #include <mailmergechildwindow.hxx>
37*cdf0e10cSrcweir #include <mailconfigpage.hxx>
38*cdf0e10cSrcweir #include <cmdid.h>
39*cdf0e10cSrcweir #include <swtypes.hxx>
40*cdf0e10cSrcweir #ifndef _VIEW_HXX
41*cdf0e10cSrcweir #include <view.hxx>
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir #include <wrtsh.hxx>
44*cdf0e10cSrcweir #ifndef _DOCSH_HXX
45*cdf0e10cSrcweir #include <docsh.hxx>
46*cdf0e10cSrcweir #endif
47*cdf0e10cSrcweir #ifndef IDOCUMENTDEVICEACCESS_HXX_INCLUDED
48*cdf0e10cSrcweir #include <IDocumentDeviceAccess.hxx>
49*cdf0e10cSrcweir #endif
50*cdf0e10cSrcweir #include <hintids.hxx>
51*cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx>
52*cdf0e10cSrcweir #include <editeng/langitem.hxx>
53*cdf0e10cSrcweir #include <svl/itemset.hxx>
54*cdf0e10cSrcweir #include <svl/stritem.hxx>
55*cdf0e10cSrcweir #include <svtools/ehdl.hxx>
56*cdf0e10cSrcweir #include <svtools/sfxecode.hxx>
57*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
58*cdf0e10cSrcweir #include <sfx2/dinfdlg.hxx>
59*cdf0e10cSrcweir #include <sfx2/printer.hxx>
60*cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
61*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
62*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
63*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
64*cdf0e10cSrcweir //#ifndef _SFX_DOCFILT_HACK_HXX
65*cdf0e10cSrcweir //#include <sfx2/docfilt.hxx>
66*cdf0e10cSrcweir //#endif
67*cdf0e10cSrcweir #include <tools/urlobj.hxx>
68*cdf0e10cSrcweir #include <svl/urihelper.hxx>
69*cdf0e10cSrcweir #ifndef _VCL_PRINT_HXX
70*cdf0e10cSrcweir #include <vcl/print.hxx>
71*cdf0e10cSrcweir #endif
72*cdf0e10cSrcweir #include <unotools/tempfile.hxx>
73*cdf0e10cSrcweir #include <osl/file.hxx>
74*cdf0e10cSrcweir #include <mmgreetingspage.hxx>
75*cdf0e10cSrcweir #include <com/sun/star/frame/XStorable.hpp>
76*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
77*cdf0e10cSrcweir #include <com/sun/star/sdb/XColumn.hpp>
78*cdf0e10cSrcweir //#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
79*cdf0e10cSrcweir //#include <com/sun/star/beans/PropertyValue.hpp>
80*cdf0e10cSrcweir //#endif
81*cdf0e10cSrcweir //#ifndef _BASEDLGS_HXX
82*cdf0e10cSrcweir //#include <sfx2/basedlgs.hxx>
83*cdf0e10cSrcweir //#endif
84*cdf0e10cSrcweir #ifndef _DBMGR_HXX
85*cdf0e10cSrcweir #include <dbmgr.hxx>
86*cdf0e10cSrcweir #endif
87*cdf0e10cSrcweir #include <swunohelper.hxx>
88*cdf0e10cSrcweir #include <vos/mutex.hxx>
89*cdf0e10cSrcweir #include <shellio.hxx>
90*cdf0e10cSrcweir #include <svtools/htmlcfg.hxx>
91*cdf0e10cSrcweir #include <sfx2/event.hxx>
92*cdf0e10cSrcweir #include <swevent.hxx>
93*cdf0e10cSrcweir #include <mmoutputpage.hrc>
94*cdf0e10cSrcweir #include <dbui.hxx>
95*cdf0e10cSrcweir #include <dbui.hrc>
96*cdf0e10cSrcweir #include <helpid.h>
97*cdf0e10cSrcweir #include <sfx2/app.hxx>
98*cdf0e10cSrcweir #include <statstr.hrc>
99*cdf0e10cSrcweir #include <unomid.h>
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir using namespace svt;
102*cdf0e10cSrcweir using namespace ::com::sun::star;
103*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir /*-- 01.07.2004 16:47:49---------------------------------------------------
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
108*cdf0e10cSrcweir String lcl_GetExtensionForDocType(sal_uLong nDocType)
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir     String sExtension;
111*cdf0e10cSrcweir     switch( nDocType )
112*cdf0e10cSrcweir     {
113*cdf0e10cSrcweir         case MM_DOCTYPE_OOO : sExtension = String::CreateFromAscii( "odt" ); break;
114*cdf0e10cSrcweir         case MM_DOCTYPE_PDF : sExtension = String::CreateFromAscii( "pdf" ); break;
115*cdf0e10cSrcweir         case MM_DOCTYPE_WORD: sExtension = String::CreateFromAscii( "doc" ); break;
116*cdf0e10cSrcweir         case MM_DOCTYPE_HTML: sExtension = String::CreateFromAscii( "html" ); break;
117*cdf0e10cSrcweir         case MM_DOCTYPE_TEXT: sExtension = String::CreateFromAscii( "txt" ); break;
118*cdf0e10cSrcweir     }
119*cdf0e10cSrcweir     return sExtension;
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir /*-- 28.06.2004 11:49:21---------------------------------------------------
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
124*cdf0e10cSrcweir ::rtl::OUString lcl_GetColumnValueOf(const ::rtl::OUString& rColumn, Reference < container::XNameAccess>& rxColAccess )
125*cdf0e10cSrcweir {
126*cdf0e10cSrcweir     ::rtl::OUString sRet;
127*cdf0e10cSrcweir     if(rxColAccess->hasByName(rColumn))
128*cdf0e10cSrcweir     {
129*cdf0e10cSrcweir         Any aCol = rxColAccess->getByName(rColumn);
130*cdf0e10cSrcweir         Reference< sdb::XColumn > xColumn;
131*cdf0e10cSrcweir         aCol >>= xColumn;
132*cdf0e10cSrcweir         if(xColumn.is())
133*cdf0e10cSrcweir             sRet = xColumn->getString();
134*cdf0e10cSrcweir     }
135*cdf0e10cSrcweir     return sRet;
136*cdf0e10cSrcweir }
137*cdf0e10cSrcweir /*-- 21.06.2004 14:01:13---------------------------------------------------
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
140*cdf0e10cSrcweir class SwSaveWarningBox_Impl : public ModalDialog
141*cdf0e10cSrcweir {
142*cdf0e10cSrcweir     FixedImage      aWarningImageIM;
143*cdf0e10cSrcweir     FixedInfo       aWarningFI;
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     FixedText       aFileNameFT;
146*cdf0e10cSrcweir     Edit            aFileNameED;
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     FixedLine       aSeparatorFL;
149*cdf0e10cSrcweir     OKButton        aOKPB;
150*cdf0e10cSrcweir     CancelButton    aCancelPB;
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     DECL_LINK( ModifyHdl, Edit*);
153*cdf0e10cSrcweir public:
154*cdf0e10cSrcweir     SwSaveWarningBox_Impl(Window* pParent, const String& rFileName);
155*cdf0e10cSrcweir     ~SwSaveWarningBox_Impl();
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     String          GetFileName() const {return aFileNameED.GetText();}
158*cdf0e10cSrcweir };
159*cdf0e10cSrcweir /*-- 02.07.2004 08:54:42---------------------------------------------------
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
162*cdf0e10cSrcweir class SwSendQueryBox_Impl : public ModalDialog
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir     FixedImage      aQueryImageIM;
165*cdf0e10cSrcweir     FixedInfo       aQueryFI;
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir     Edit            aTextED;
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     FixedLine       aSeparatorFL;
170*cdf0e10cSrcweir     OKButton        aOKPB;
171*cdf0e10cSrcweir     CancelButton    aCancelPB;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     bool            bIsEmptyAllowed;
174*cdf0e10cSrcweir     DECL_LINK( ModifyHdl, Edit*);
175*cdf0e10cSrcweir public:
176*cdf0e10cSrcweir     SwSendQueryBox_Impl(Window* pParent, const String& rQueryText);
177*cdf0e10cSrcweir     ~SwSendQueryBox_Impl();
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     void            SetValue(const String& rSet)
180*cdf0e10cSrcweir                         {
181*cdf0e10cSrcweir                             aTextED.SetText(rSet);
182*cdf0e10cSrcweir                             ModifyHdl( &aTextED );
183*cdf0e10cSrcweir                         }
184*cdf0e10cSrcweir     String          GetValue() const {return aTextED.GetText();}
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     void            SetIsEmptyTextAllowed(bool bSet)
187*cdf0e10cSrcweir                         {
188*cdf0e10cSrcweir                             bIsEmptyAllowed = bSet;
189*cdf0e10cSrcweir                             ModifyHdl( &aTextED );
190*cdf0e10cSrcweir                         }
191*cdf0e10cSrcweir };
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir /*-- 21.06.2004 14:11:58---------------------------------------------------
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
196*cdf0e10cSrcweir SwSaveWarningBox_Impl::SwSaveWarningBox_Impl(Window* pParent, const String& rFileName) :
197*cdf0e10cSrcweir     ModalDialog(pParent, SW_RES(   DLG_MM_SAVEWARNING )),
198*cdf0e10cSrcweir     aWarningImageIM(this,   SW_RES( IM_WARNING   )),
199*cdf0e10cSrcweir     aWarningFI(this,        SW_RES( FI_WARNING   )),
200*cdf0e10cSrcweir     aFileNameFT(this,       SW_RES( FT_FILENAME  )),
201*cdf0e10cSrcweir     aFileNameED(this,       SW_RES( ED_FILENAME  )),
202*cdf0e10cSrcweir     aSeparatorFL(this,      SW_RES( FL_SEPARATOR )),
203*cdf0e10cSrcweir     aOKPB(this,             SW_RES( PB_OK        )),
204*cdf0e10cSrcweir     aCancelPB(this,         SW_RES( PB_CANCEL    ))
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir     FreeResource();
207*cdf0e10cSrcweir     aWarningImageIM.SetImage(WarningBox::GetStandardImage());
208*cdf0e10cSrcweir     aFileNameED.SetText(rFileName);
209*cdf0e10cSrcweir     aFileNameED.SetModifyHdl(LINK(this, SwSaveWarningBox_Impl, ModifyHdl));
210*cdf0e10cSrcweir     ModifyHdl( &aFileNameED );
211*cdf0e10cSrcweir }
212*cdf0e10cSrcweir /*-- 21.06.2004 14:11:58---------------------------------------------------
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
215*cdf0e10cSrcweir SwSaveWarningBox_Impl::~SwSaveWarningBox_Impl()
216*cdf0e10cSrcweir {
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir /*-- 21.06.2004 14:11:58---------------------------------------------------
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
221*cdf0e10cSrcweir IMPL_LINK( SwSaveWarningBox_Impl, ModifyHdl, Edit*, pEdit)
222*cdf0e10cSrcweir {
223*cdf0e10cSrcweir     aOKPB.Enable(pEdit->GetText().Len() > 0);
224*cdf0e10cSrcweir     return 0;
225*cdf0e10cSrcweir }
226*cdf0e10cSrcweir /*-- 02.07.2004 09:02:53---------------------------------------------------
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
229*cdf0e10cSrcweir SwSendQueryBox_Impl::SwSendQueryBox_Impl(Window* pParent, const String& rText) :
230*cdf0e10cSrcweir     ModalDialog(pParent, SW_RES(   DLG_MM_QUERY )),
231*cdf0e10cSrcweir     aQueryImageIM( this,    SW_RES( IM_QUERY     )),
232*cdf0e10cSrcweir     aQueryFI( this,         SW_RES( FI_QUERY     )),
233*cdf0e10cSrcweir     aTextED( this,          SW_RES( ED_TEXT      )),
234*cdf0e10cSrcweir     aSeparatorFL(this,      SW_RES( FL_SEPARATOR )),
235*cdf0e10cSrcweir     aOKPB(this,             SW_RES( PB_OK        )),
236*cdf0e10cSrcweir     aCancelPB(this,         SW_RES( PB_CANCEL    )),
237*cdf0e10cSrcweir     bIsEmptyAllowed(true)
238*cdf0e10cSrcweir {
239*cdf0e10cSrcweir     FreeResource();
240*cdf0e10cSrcweir     aQueryFI.SetText(rText);
241*cdf0e10cSrcweir     aQueryImageIM.SetImage(QueryBox::GetStandardImage());
242*cdf0e10cSrcweir     aTextED.SetModifyHdl(LINK(this, SwSendQueryBox_Impl, ModifyHdl));
243*cdf0e10cSrcweir     ModifyHdl( &aTextED );
244*cdf0e10cSrcweir }
245*cdf0e10cSrcweir /*-- 02.07.2004 08:58:45---------------------------------------------------
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
248*cdf0e10cSrcweir SwSendQueryBox_Impl::~SwSendQueryBox_Impl()
249*cdf0e10cSrcweir {
250*cdf0e10cSrcweir }
251*cdf0e10cSrcweir /*-- 02.07.2004 08:58:25---------------------------------------------------
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
254*cdf0e10cSrcweir IMPL_LINK( SwSendQueryBox_Impl, ModifyHdl, Edit*, pEdit)
255*cdf0e10cSrcweir {
256*cdf0e10cSrcweir     aOKPB.Enable(bIsEmptyAllowed  || (pEdit->GetText().Len() > 0));
257*cdf0e10cSrcweir     return 0;
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir /*-- 16.04.2004 16:34:48---------------------------------------------------
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
263*cdf0e10cSrcweir class SwCopyToDialog : public SfxModalDialog
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir     FixedInfo       m_aDescriptionFI;
266*cdf0e10cSrcweir     FixedText       m_aCCFT;
267*cdf0e10cSrcweir     Edit            m_aCCED;
268*cdf0e10cSrcweir     FixedText       m_aBCCFT;
269*cdf0e10cSrcweir     Edit            m_aBCCED;
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir     FixedInfo       m_aNoteFI;
272*cdf0e10cSrcweir     FixedLine       m_aSeparatorFL;
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir     OKButton        m_aOK;
275*cdf0e10cSrcweir     CancelButton    m_aCancel;
276*cdf0e10cSrcweir     HelpButton      m_aHelp;
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir public:
279*cdf0e10cSrcweir     SwCopyToDialog(Window* pParent);
280*cdf0e10cSrcweir     ~SwCopyToDialog();
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir     String          GetCC() {return m_aCCED.GetText();}
283*cdf0e10cSrcweir     void            SetCC(const String& rSet) {m_aCCED.SetText(rSet);}
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir     String          GetBCC() {return m_aBCCED.GetText();}
286*cdf0e10cSrcweir     void            SetBCC(const String& rSet) {m_aBCCED.SetText(rSet);}
287*cdf0e10cSrcweir };
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir /*-- 16.04.2004 16:43:18---------------------------------------------------
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
292*cdf0e10cSrcweir SwCopyToDialog::SwCopyToDialog(Window* pParent) :
293*cdf0e10cSrcweir     SfxModalDialog(pParent, SW_RES(DLG_MM_COPYTO)),
294*cdf0e10cSrcweir #ifdef MSC
295*cdf0e10cSrcweir #pragma warning (disable : 4355)
296*cdf0e10cSrcweir #endif
297*cdf0e10cSrcweir     m_aDescriptionFI( this, SW_RES(       FI_DESCRIPTION )),
298*cdf0e10cSrcweir     m_aCCFT( this, SW_RES(                FT_CC          )),
299*cdf0e10cSrcweir     m_aCCED( this, SW_RES(                ED_CC          )),
300*cdf0e10cSrcweir     m_aBCCFT( this, SW_RES(               FT_BCC         )),
301*cdf0e10cSrcweir     m_aBCCED( this, SW_RES(               ED_BCC         )),
302*cdf0e10cSrcweir     m_aNoteFI( this, SW_RES(              FI_NOTE        )),
303*cdf0e10cSrcweir     m_aSeparatorFL( this, SW_RES(         FL_SEPARATOR   )),
304*cdf0e10cSrcweir     m_aOK( this, SW_RES(                  PB_OK          )),
305*cdf0e10cSrcweir     m_aCancel( this, SW_RES(              PB_CANCEL      )),
306*cdf0e10cSrcweir     m_aHelp( this, SW_RES(                PB_HELP        ))
307*cdf0e10cSrcweir #ifdef MSC
308*cdf0e10cSrcweir #pragma warning (default : 4355)
309*cdf0e10cSrcweir #endif
310*cdf0e10cSrcweir {
311*cdf0e10cSrcweir     FreeResource();
312*cdf0e10cSrcweir }
313*cdf0e10cSrcweir /*-- 16.04.2004 16:43:10---------------------------------------------------
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
316*cdf0e10cSrcweir SwCopyToDialog::~SwCopyToDialog()
317*cdf0e10cSrcweir {
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir /*-- 02.04.2004 13:15:54---------------------------------------------------
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
323*cdf0e10cSrcweir SwMailMergeOutputPage::SwMailMergeOutputPage( SwMailMergeWizard* _pParent) :
324*cdf0e10cSrcweir     svt::OWizardPage( _pParent, SW_RES(DLG_MM_OUTPUT_PAGE)),
325*cdf0e10cSrcweir #ifdef MSC
326*cdf0e10cSrcweir #pragma warning (disable : 4355)
327*cdf0e10cSrcweir #endif
328*cdf0e10cSrcweir     m_aHeaderFI(this,           SW_RES(  FI_HEADER           ) ),
329*cdf0e10cSrcweir     m_aOptionsFI(this,          SW_RES(  FI_OPTIONS          ) ),
330*cdf0e10cSrcweir     m_aSaveStartDocRB(this,     SW_RES(  RB_SAVESTARTDOC     ) ),
331*cdf0e10cSrcweir     m_aSaveMergedDocRB(this,    SW_RES(  RB_SAVEMERGEDDOC    ) ),
332*cdf0e10cSrcweir     m_aPrintRB(this,            SW_RES(  RB_PRINT            ) ),
333*cdf0e10cSrcweir     m_aSendMailRB(this,         SW_RES(  RB_SENDMAIL         ) ),
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir     m_aSeparatorFL(this,        SW_RES(  FL_SEPARATOR        ) ),
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir     m_aSaveStartDocPB(this,     SW_RES(  PB_SAVESTARTDOC     ) ),
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir     m_aSaveAsOneRB(this,        SW_RES(  RB_SAVEASONE        ) ),
340*cdf0e10cSrcweir     m_aSaveIndividualRB(this,   SW_RES(  RB_SAVEINDIVIDUAL   ) ),
341*cdf0e10cSrcweir     m_aPrintAllRB(this,         SW_RES(  RB_PRINTALL         ) ),
342*cdf0e10cSrcweir     m_aSendAllRB( this, SW_RES(       RB_SENDALL             ) ),
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir     m_aFromRB(this,             SW_RES(  RB_FROM             ) ),
345*cdf0e10cSrcweir     m_aFromNF(this,             SW_RES(  NF_FROM             ) ),
346*cdf0e10cSrcweir     m_aToFT(this,               SW_RES(  FT_TO               ) ),
347*cdf0e10cSrcweir     m_aToNF(this,               SW_RES(  NF_TO               ) ),
348*cdf0e10cSrcweir     m_aSaveNowPB(this,          SW_RES(  PB_SAVENOW          ) ),
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir     m_aPrinterFT(this,          SW_RES(  FT_PRINT            ) ),
351*cdf0e10cSrcweir     m_aPrinterLB(this,          SW_RES(  LB_PRINT            ) ),
352*cdf0e10cSrcweir     m_aPrinterSettingsPB(this,  SW_RES(  PB_PRINTERSETTINGS  ) ),
353*cdf0e10cSrcweir     m_aPrintNowPB(this,         SW_RES(  PB_PRINTNOW         ) ),
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir     m_aMailToFT( this, SW_RES(        FT_MAILTO              ) ),
356*cdf0e10cSrcweir     m_aMailToLB( this, SW_RES(        LB_MAILTO              ) ),
357*cdf0e10cSrcweir     m_aCopyToPB( this, SW_RES(        PB_COPYTO              ) ),
358*cdf0e10cSrcweir     m_aSubjectFT( this, SW_RES(       FT_SUBJECT             ) ),
359*cdf0e10cSrcweir     m_aSubjectED( this, SW_RES(       ED_SUBJECT             ) ),
360*cdf0e10cSrcweir     m_aSendAsFT( this, SW_RES(        FT_SENDAS              ) ),
361*cdf0e10cSrcweir     m_aSendAsLB( this, SW_RES(        LB_SENDAS              ) ),
362*cdf0e10cSrcweir     m_aAttachmentFT( this, SW_RES(    FT_ATTACHMENT              ) ),
363*cdf0e10cSrcweir     m_aAttachmentED( this, SW_RES(    ED_ATTACHMENT              ) ),
364*cdf0e10cSrcweir     m_aSendAsPB( this, SW_RES(        PB_SENDAS              ) ),
365*cdf0e10cSrcweir     m_aSendDocumentsPB( this, SW_RES( PB_SENDDOCUMENTS       ) ),
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir     m_sSaveStartST(SW_RES(           ST_SAVESTART  ) ),
368*cdf0e10cSrcweir     m_sSaveMergedST(SW_RES(          ST_SAVEMERGED ) ),
369*cdf0e10cSrcweir     m_sPrintST(SW_RES(               ST_PRINT      ) ),
370*cdf0e10cSrcweir     m_sSendMailST(SW_RES(            ST_SENDMAIL   ) ),
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir     m_sDefaultAttachmentST(SW_RES(   ST_DEFAULTATTACHMENT )),
373*cdf0e10cSrcweir     m_sNoSubjectQueryST(SW_RES(      ST_SUBJECTQUERY      )),
374*cdf0e10cSrcweir     m_sNoSubjectST(SW_RES(           ST_NOSUBJECT )),
375*cdf0e10cSrcweir     m_sNoAttachmentNameST(SW_RES(    ST_NOATTACHMENTNAME )),
376*cdf0e10cSrcweir     m_sConfigureMail(SW_RES(         ST_CONFIGUREMAIL)),
377*cdf0e10cSrcweir #ifdef MSC
378*cdf0e10cSrcweir #pragma warning (default : 4355)
379*cdf0e10cSrcweir #endif
380*cdf0e10cSrcweir     m_bCancelSaving( false ),
381*cdf0e10cSrcweir     m_pWizard(_pParent),
382*cdf0e10cSrcweir     m_pTempPrinter( 0 ),
383*cdf0e10cSrcweir     m_pDocumentPrinterCopy(0)
384*cdf0e10cSrcweir {
385*cdf0e10cSrcweir     FreeResource();
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
388*cdf0e10cSrcweir     // #i51949# hide e-Mail option if e-Mail is not supported
389*cdf0e10cSrcweir     if(!rConfigItem.IsMailAvailable())
390*cdf0e10cSrcweir         m_aSendMailRB.Hide();
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir     Link aLink = LINK(this, SwMailMergeOutputPage, OutputTypeHdl_Impl);
393*cdf0e10cSrcweir     m_aSaveStartDocRB.SetClickHdl(aLink);
394*cdf0e10cSrcweir     m_aSaveMergedDocRB.SetClickHdl(aLink);
395*cdf0e10cSrcweir     m_aPrintRB.SetClickHdl(aLink);
396*cdf0e10cSrcweir     m_aSendMailRB.SetClickHdl(aLink);
397*cdf0e10cSrcweir     m_aSaveStartDocRB.Check();
398*cdf0e10cSrcweir     m_aPrintAllRB.Check();
399*cdf0e10cSrcweir     m_aSaveAsOneRB.Check();
400*cdf0e10cSrcweir     m_aSendAllRB.Check();
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir     m_aSaveStartDocPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, SaveStartHdl_Impl));
403*cdf0e10cSrcweir     m_aSaveNowPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, SaveOutputHdl_Impl));
404*cdf0e10cSrcweir     m_aPrinterLB.SetSelectHdl(LINK(this, SwMailMergeOutputPage, PrinterChangeHdl_Impl));
405*cdf0e10cSrcweir     m_aPrintNowPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, PrintHdl_Impl));
406*cdf0e10cSrcweir     m_aPrinterSettingsPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, PrinterSetupHdl_Impl));
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir     m_aSendAsPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, SendAsHdl_Impl)),
409*cdf0e10cSrcweir     m_aSendDocumentsPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, SendDocumentsHdl_Impl)),
410*cdf0e10cSrcweir     m_aSendAsLB.SetSelectHdl(LINK(this, SwMailMergeOutputPage, SendTypeHdl_Impl));
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir     m_nFromToRBPos = m_aFromRB.GetPosPixel().Y();
413*cdf0e10cSrcweir     m_nFromToFTPos = m_aToFT.GetPosPixel().Y();
414*cdf0e10cSrcweir     m_nFromToNFPos = m_aFromNF.GetPosPixel().Y();
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir     m_nRBOffset = m_nFromToRBPos - m_aSaveIndividualRB.GetPosPixel().Y();
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir     OutputTypeHdl_Impl(&m_aSaveStartDocRB);
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir     m_aCopyToPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, CopyToHdl_Impl));
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir     m_aSaveAsOneRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl));
423*cdf0e10cSrcweir     m_aSaveIndividualRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl));
424*cdf0e10cSrcweir     m_aPrintAllRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl));
425*cdf0e10cSrcweir     m_aSendAllRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl));
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir     m_aFromRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl));
428*cdf0e10cSrcweir     //#i63267# printing might be disabled
429*cdf0e10cSrcweir     m_aPrintRB.Enable(!Application::GetSettings().GetMiscSettings().GetDisablePrinting());
430*cdf0e10cSrcweir }
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir /*-- 02.04.2004 13:15:44---------------------------------------------------
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
435*cdf0e10cSrcweir SwMailMergeOutputPage::~SwMailMergeOutputPage()
436*cdf0e10cSrcweir {
437*cdf0e10cSrcweir     delete m_pTempPrinter;
438*cdf0e10cSrcweir     delete m_pDocumentPrinterCopy;
439*cdf0e10cSrcweir }
440*cdf0e10cSrcweir /*-- 31.01.2005 08:38:14---------------------------------------------------
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
443*cdf0e10cSrcweir void SwMailMergeOutputPage::ActivatePage()
444*cdf0e10cSrcweir {
445*cdf0e10cSrcweir     //fill printer ListBox
446*cdf0e10cSrcweir     const std::vector<rtl::OUString>& rPrinters = Printer::GetPrinterQueues();
447*cdf0e10cSrcweir     unsigned int nCount = rPrinters.size();
448*cdf0e10cSrcweir     if ( nCount )
449*cdf0e10cSrcweir     {
450*cdf0e10cSrcweir         for( unsigned int i = 0; i < nCount; i++ )
451*cdf0e10cSrcweir         {
452*cdf0e10cSrcweir             m_aPrinterLB.InsertEntry( rPrinters[i] );
453*cdf0e10cSrcweir         }
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir     }
456*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir     SwView* pTargetView = rConfigItem.GetTargetView();
459*cdf0e10cSrcweir     DBG_ASSERT(pTargetView, "no target view exists");
460*cdf0e10cSrcweir     if(pTargetView)
461*cdf0e10cSrcweir     {
462*cdf0e10cSrcweir         SfxPrinter* pPrinter = pTargetView->GetWrtShell().getIDocumentDeviceAccess()->getPrinter( true );
463*cdf0e10cSrcweir         m_aPrinterLB.SelectEntry( pPrinter->GetName() );
464*cdf0e10cSrcweir         m_aToNF.SetValue( rConfigItem.GetMergedDocumentCount() );
465*cdf0e10cSrcweir         m_aToNF.SetMax( rConfigItem.GetMergedDocumentCount() );
466*cdf0e10cSrcweir         m_pDocumentPrinterCopy = pTargetView->GetWrtShell().getIDocumentDeviceAccess()->getPrinter( true )->Clone();
467*cdf0e10cSrcweir     }
468*cdf0e10cSrcweir     m_aPrinterLB.SelectEntry( rConfigItem.GetSelectedPrinter() );
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir     SwView* pSourceView = rConfigItem.GetSourceView();
471*cdf0e10cSrcweir     DBG_ASSERT(pSourceView, "no source view exists");
472*cdf0e10cSrcweir     if(pSourceView)
473*cdf0e10cSrcweir     {
474*cdf0e10cSrcweir         SwDocShell* pDocShell = pSourceView->GetDocShell();
475*cdf0e10cSrcweir         if ( pDocShell->HasName() )
476*cdf0e10cSrcweir         {
477*cdf0e10cSrcweir             INetURLObject aTmp( pDocShell->GetMedium()->GetName() );
478*cdf0e10cSrcweir             m_aAttachmentED.SetText(aTmp.getName(
479*cdf0e10cSrcweir                     INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ));
480*cdf0e10cSrcweir         }
481*cdf0e10cSrcweir     }
482*cdf0e10cSrcweir }
483*cdf0e10cSrcweir /*-- 05.07.2004 13:54:11---------------------------------------------------
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
486*cdf0e10cSrcweir bool SwMailMergeOutputPage::canAdvance() const
487*cdf0e10cSrcweir {
488*cdf0e10cSrcweir     return false;
489*cdf0e10cSrcweir }
490*cdf0e10cSrcweir /*-- 02.04.2004 13:15:44---------------------------------------------------
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
493*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, OutputTypeHdl_Impl, RadioButton*, pButton)
494*cdf0e10cSrcweir {
495*cdf0e10cSrcweir     Control* aControls[] =
496*cdf0e10cSrcweir     {
497*cdf0e10cSrcweir         &m_aSaveStartDocPB,
498*cdf0e10cSrcweir         &m_aSaveAsOneRB, &m_aSaveIndividualRB,
499*cdf0e10cSrcweir         &m_aFromRB, &m_aFromNF, &m_aToFT, &m_aToNF,
500*cdf0e10cSrcweir         &m_aSaveNowPB,
501*cdf0e10cSrcweir         &m_aPrinterFT, &m_aPrinterLB, &m_aPrinterSettingsPB, &m_aPrintAllRB,
502*cdf0e10cSrcweir         &m_aPrintNowPB,
503*cdf0e10cSrcweir         &m_aMailToFT, &m_aMailToLB, &m_aCopyToPB,
504*cdf0e10cSrcweir         &m_aSubjectFT, &m_aSubjectED,
505*cdf0e10cSrcweir         &m_aSendAsFT, &m_aSendAsLB, &m_aSendAsPB,
506*cdf0e10cSrcweir         &m_aAttachmentFT, &m_aAttachmentED,
507*cdf0e10cSrcweir         &m_aSendAllRB, &m_aSendDocumentsPB,
508*cdf0e10cSrcweir         0
509*cdf0e10cSrcweir     };
510*cdf0e10cSrcweir     SetUpdateMode(sal_True);
511*cdf0e10cSrcweir     Control** pControl = aControls;
512*cdf0e10cSrcweir     do
513*cdf0e10cSrcweir     {
514*cdf0e10cSrcweir         (*pControl)->Show(sal_False);
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir     } while(*(++pControl));
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir     if(&m_aSaveStartDocRB == pButton)
519*cdf0e10cSrcweir     {
520*cdf0e10cSrcweir         m_aSaveStartDocPB.Show();
521*cdf0e10cSrcweir         m_aSeparatorFL.SetText(m_sSaveStartST);
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir     }
524*cdf0e10cSrcweir     else if(&m_aSaveMergedDocRB == pButton)
525*cdf0e10cSrcweir     {
526*cdf0e10cSrcweir         Control* aSaveMergedControls[] =
527*cdf0e10cSrcweir         {
528*cdf0e10cSrcweir             &m_aSaveAsOneRB, &m_aSaveIndividualRB,
529*cdf0e10cSrcweir             &m_aFromRB, &m_aFromNF, &m_aToFT, &m_aToNF,
530*cdf0e10cSrcweir             &m_aSaveNowPB,
531*cdf0e10cSrcweir             0
532*cdf0e10cSrcweir         };
533*cdf0e10cSrcweir         Control** pSaveMergeControl = aSaveMergedControls;
534*cdf0e10cSrcweir         do
535*cdf0e10cSrcweir         {
536*cdf0e10cSrcweir             (*pSaveMergeControl)->Show(sal_True);
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir         } while(*(++pSaveMergeControl));
539*cdf0e10cSrcweir         if(!m_aFromRB.IsChecked() && !m_aSaveAsOneRB.IsChecked())
540*cdf0e10cSrcweir         {
541*cdf0e10cSrcweir             m_aSaveIndividualRB.Check();
542*cdf0e10cSrcweir         }
543*cdf0e10cSrcweir         m_aSeparatorFL.SetText(m_sSaveMergedST);
544*cdf0e10cSrcweir         //reposition the from/to line
545*cdf0e10cSrcweir         if(m_aFromRB.GetPosPixel().Y() != m_nFromToRBPos)
546*cdf0e10cSrcweir         {
547*cdf0e10cSrcweir             Point aPos(m_aFromRB.GetPosPixel()); aPos.Y() = m_nFromToRBPos; m_aFromRB.SetPosPixel(aPos);
548*cdf0e10cSrcweir             aPos =   m_aToFT.GetPosPixel();      aPos.Y() = m_nFromToFTPos; m_aToFT.SetPosPixel(aPos);
549*cdf0e10cSrcweir             aPos =   m_aFromNF.GetPosPixel();    aPos.Y() = m_nFromToNFPos; m_aFromNF.SetPosPixel(aPos);
550*cdf0e10cSrcweir             aPos =   m_aToNF.GetPosPixel();      aPos.Y() = m_nFromToNFPos; m_aToNF.SetPosPixel(aPos);
551*cdf0e10cSrcweir         }
552*cdf0e10cSrcweir     }
553*cdf0e10cSrcweir     else if(&m_aPrintRB == pButton)
554*cdf0e10cSrcweir     {
555*cdf0e10cSrcweir         Control* aPrintControls[] =
556*cdf0e10cSrcweir         {
557*cdf0e10cSrcweir             &m_aFromRB, &m_aFromNF, &m_aToFT, &m_aToNF,
558*cdf0e10cSrcweir             &m_aPrinterFT, &m_aPrinterLB, &m_aPrinterSettingsPB, &m_aPrintAllRB,
559*cdf0e10cSrcweir             &m_aPrintNowPB,
560*cdf0e10cSrcweir             0
561*cdf0e10cSrcweir         };
562*cdf0e10cSrcweir         Control** pPrinterControl = aPrintControls;
563*cdf0e10cSrcweir         do
564*cdf0e10cSrcweir         {
565*cdf0e10cSrcweir             (*pPrinterControl)->Show(sal_True);
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir         } while(*(++pPrinterControl));
568*cdf0e10cSrcweir         if(!m_aFromRB.IsChecked())
569*cdf0e10cSrcweir             m_aPrintAllRB.Check();
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir         m_aSeparatorFL.SetText(m_sPrintST);
572*cdf0e10cSrcweir         //reposition the from/to line
573*cdf0e10cSrcweir         long nRB_FT_Offset = m_nFromToRBPos - m_nFromToFTPos;
574*cdf0e10cSrcweir         long nNewRBXPos = m_aPrintAllRB.GetPosPixel().Y() + m_nRBOffset;
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir         Point aPos(m_aFromRB.GetPosPixel());aPos.Y() = nNewRBXPos;                 m_aFromRB.SetPosPixel(aPos);
577*cdf0e10cSrcweir         aPos = m_aToFT.GetPosPixel();       aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aToFT.SetPosPixel(aPos);
578*cdf0e10cSrcweir         aPos = m_aFromNF.GetPosPixel();     aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aFromNF.SetPosPixel(aPos);
579*cdf0e10cSrcweir         aPos = m_aToNF.GetPosPixel();       aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aToNF.SetPosPixel(aPos);
580*cdf0e10cSrcweir     }
581*cdf0e10cSrcweir     else /*if(&m_aSendMailRB == pButton)*/
582*cdf0e10cSrcweir     {
583*cdf0e10cSrcweir         Control* aMailControls[] =
584*cdf0e10cSrcweir         {
585*cdf0e10cSrcweir             &m_aFromRB, &m_aFromNF, &m_aToFT, &m_aToNF,
586*cdf0e10cSrcweir             &m_aMailToFT, &m_aMailToLB, &m_aCopyToPB,
587*cdf0e10cSrcweir             &m_aSubjectFT, &m_aSubjectED,
588*cdf0e10cSrcweir             &m_aSendAsFT, &m_aSendAsLB, &m_aSendAsPB,
589*cdf0e10cSrcweir             &m_aAttachmentFT, &m_aAttachmentED,
590*cdf0e10cSrcweir             &m_aSendAllRB, &m_aSendDocumentsPB, 0
591*cdf0e10cSrcweir         };
592*cdf0e10cSrcweir         Control** pMailControl = aMailControls;
593*cdf0e10cSrcweir         do
594*cdf0e10cSrcweir         {
595*cdf0e10cSrcweir             (*pMailControl)->Show(sal_True);
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir         } while(*(++pMailControl));
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir         if(!m_aFromRB.IsChecked())
600*cdf0e10cSrcweir             m_aSendAllRB.Check();
601*cdf0e10cSrcweir         if(!m_aAttachmentED.GetText().Len())
602*cdf0e10cSrcweir         {
603*cdf0e10cSrcweir             String sAttach( m_sDefaultAttachmentST );
604*cdf0e10cSrcweir             sAttach += '.';
605*cdf0e10cSrcweir             sAttach += lcl_GetExtensionForDocType(
606*cdf0e10cSrcweir                         (sal_uLong)m_aSendAsLB.GetEntryData(m_aSendAsLB.GetSelectEntryPos()));
607*cdf0e10cSrcweir             m_aAttachmentED.SetText( sAttach );
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir         }
610*cdf0e10cSrcweir         m_aSeparatorFL.SetText(m_sSendMailST);
611*cdf0e10cSrcweir         //fill mail address ListBox
612*cdf0e10cSrcweir         if(!m_aMailToLB.GetEntryCount())
613*cdf0e10cSrcweir         {
614*cdf0e10cSrcweir             SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
615*cdf0e10cSrcweir             //select first column
616*cdf0e10cSrcweir             uno::Reference< sdbcx::XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), uno::UNO_QUERY);
617*cdf0e10cSrcweir             //get the name of the actual columns
618*cdf0e10cSrcweir             uno::Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
619*cdf0e10cSrcweir             uno::Sequence< ::rtl::OUString > aFields;
620*cdf0e10cSrcweir             if(xColAccess.is())
621*cdf0e10cSrcweir                 aFields = xColAccess->getElementNames();
622*cdf0e10cSrcweir             const ::rtl::OUString* pFields = aFields.getConstArray();
623*cdf0e10cSrcweir             for(sal_Int32 nField = 0; nField < aFields.getLength(); ++nField)
624*cdf0e10cSrcweir                 m_aMailToLB.InsertEntry(pFields[nField]);
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir             m_aMailToLB.SelectEntryPos(0);
627*cdf0e10cSrcweir             // then select the right one - may not be available
628*cdf0e10cSrcweir             const ResStringArray& rHeaders = rConfigItem.GetDefaultAddressHeaders();
629*cdf0e10cSrcweir             String sEMailColumn = rHeaders.GetString( MM_PART_E_MAIL );
630*cdf0e10cSrcweir             Sequence< ::rtl::OUString> aAssignment =
631*cdf0e10cSrcweir                             rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
632*cdf0e10cSrcweir             if(aAssignment.getLength() > MM_PART_E_MAIL && aAssignment[MM_PART_E_MAIL].getLength())
633*cdf0e10cSrcweir                 sEMailColumn = aAssignment[MM_PART_E_MAIL];
634*cdf0e10cSrcweir             m_aMailToLB.SelectEntry(sEMailColumn);
635*cdf0e10cSrcweir             // HTML format pre-selected
636*cdf0e10cSrcweir             m_aSendAsLB.SelectEntryPos(3);
637*cdf0e10cSrcweir             SendTypeHdl_Impl(&m_aSendAsLB);
638*cdf0e10cSrcweir         }
639*cdf0e10cSrcweir         if(m_aSendAllRB.GetPosPixel().Y() + m_nRBOffset != m_aFromRB.GetPosPixel().Y())
640*cdf0e10cSrcweir         {
641*cdf0e10cSrcweir             long nRB_FT_Offset = m_nFromToRBPos - m_nFromToFTPos;
642*cdf0e10cSrcweir             long nNewRBXPos = m_aSendAllRB.GetPosPixel().Y() + m_nRBOffset;
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir             Point aPos(m_aFromRB.GetPosPixel());aPos.Y() = nNewRBXPos;                 m_aFromRB.SetPosPixel(aPos);
645*cdf0e10cSrcweir             aPos = m_aToFT.GetPosPixel();       aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aToFT.SetPosPixel(aPos);
646*cdf0e10cSrcweir             aPos = m_aFromNF.GetPosPixel();     aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aFromNF.SetPosPixel(aPos);
647*cdf0e10cSrcweir             aPos = m_aToNF.GetPosPixel();       aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aToNF.SetPosPixel(aPos);
648*cdf0e10cSrcweir         }
649*cdf0e10cSrcweir     }
650*cdf0e10cSrcweir     m_aFromRB.GetClickHdl().Call(m_aFromRB.IsChecked() ? &m_aFromRB : 0);
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir     SetUpdateMode(sal_False);
653*cdf0e10cSrcweir     return 0;
654*cdf0e10cSrcweir }
655*cdf0e10cSrcweir /*-- 22.08.2005 12:15:10---------------------------------------------------
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
658*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, DocumentSelectionHdl_Impl, RadioButton*, pButton)
659*cdf0e10cSrcweir {
660*cdf0e10cSrcweir     sal_Bool bEnableFromTo = pButton == &m_aFromRB;
661*cdf0e10cSrcweir     m_aFromNF.Enable(bEnableFromTo);
662*cdf0e10cSrcweir     m_aToFT.Enable(bEnableFromTo);
663*cdf0e10cSrcweir     m_aToNF.Enable(bEnableFromTo);
664*cdf0e10cSrcweir     return 0;
665*cdf0e10cSrcweir }
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir /*-- 16.04.2004 16:45:10---------------------------------------------------
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
670*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, CopyToHdl_Impl, PushButton*, pButton)
671*cdf0e10cSrcweir {
672*cdf0e10cSrcweir     SwCopyToDialog* pDlg = new SwCopyToDialog(pButton);
673*cdf0e10cSrcweir     pDlg->SetCC(m_sCC );
674*cdf0e10cSrcweir     pDlg->SetBCC(m_sBCC);
675*cdf0e10cSrcweir     if(RET_OK == pDlg->Execute())
676*cdf0e10cSrcweir     {
677*cdf0e10cSrcweir         m_sCC =     pDlg->GetCC() ;
678*cdf0e10cSrcweir         m_sBCC =    pDlg->GetBCC();
679*cdf0e10cSrcweir     }
680*cdf0e10cSrcweir     delete pDlg;
681*cdf0e10cSrcweir     return 0;
682*cdf0e10cSrcweir }
683*cdf0e10cSrcweir /*-- 17.05.2004 13:51:02---------------------------------------------------
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
686*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, SaveStartHdl_Impl, PushButton*, pButton)
687*cdf0e10cSrcweir {
688*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
689*cdf0e10cSrcweir     SwView* pSourceView = rConfigItem.GetSourceView();
690*cdf0e10cSrcweir     DBG_ASSERT( pSourceView, "source view missing");
691*cdf0e10cSrcweir     if(pSourceView)
692*cdf0e10cSrcweir     {
693*cdf0e10cSrcweir         SfxViewFrame* pSourceViewFrm = pSourceView->GetViewFrame();
694*cdf0e10cSrcweir         uno::Reference< frame::XFrame > xFrame =
695*cdf0e10cSrcweir                 pSourceViewFrm->GetFrame().GetFrameInterface();
696*cdf0e10cSrcweir         xFrame->getContainerWindow()->setVisible(sal_True);
697*cdf0e10cSrcweir         pSourceViewFrm->GetDispatcher()->Execute(SID_SAVEDOC, SFX_CALLMODE_SYNCHRON);
698*cdf0e10cSrcweir         xFrame->getContainerWindow()->setVisible(sal_False);
699*cdf0e10cSrcweir         SwDocShell* pDocShell = pSourceView->GetDocShell();
700*cdf0e10cSrcweir         //if the document has been saved it's URL has to be stored for
701*cdf0e10cSrcweir         // later use and it can be closed now
702*cdf0e10cSrcweir         if(pDocShell->HasName() && !pDocShell->IsModified())
703*cdf0e10cSrcweir         {
704*cdf0e10cSrcweir             INetURLObject aURL = pDocShell->GetMedium()->GetURLObject();
705*cdf0e10cSrcweir             //update the attachment name
706*cdf0e10cSrcweir             if(!m_aAttachmentED.GetText().Len())
707*cdf0e10cSrcweir             {
708*cdf0e10cSrcweir                 if ( pDocShell->HasName() )
709*cdf0e10cSrcweir                 {
710*cdf0e10cSrcweir                     m_aAttachmentED.SetText(aURL.getName(
711*cdf0e10cSrcweir                             INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ));
712*cdf0e10cSrcweir                 }
713*cdf0e10cSrcweir             }
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir             rConfigItem.AddSavedDocument(
716*cdf0e10cSrcweir                     aURL.GetMainURL(INetURLObject::DECODE_TO_IURI));
717*cdf0e10cSrcweir             pButton->Enable(sal_False);
718*cdf0e10cSrcweir             m_pWizard->enableButtons(WZB_FINISH, sal_True);
719*cdf0e10cSrcweir             pButton->Enable(sal_False);
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir         }
722*cdf0e10cSrcweir     }
723*cdf0e10cSrcweir     return 0;
724*cdf0e10cSrcweir }
725*cdf0e10cSrcweir /*-- 17.07.2008 08:09:06---------------------------------------------------
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
728*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, SaveCancelHdl_Impl, Button*, EMPTYARG )
729*cdf0e10cSrcweir {
730*cdf0e10cSrcweir     m_bCancelSaving = true;
731*cdf0e10cSrcweir     return 0;
732*cdf0e10cSrcweir }
733*cdf0e10cSrcweir /*-- 17.05.2004 13:51:02---------------------------------------------------
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
736*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, SaveOutputHdl_Impl, PushButton*, pButton)
737*cdf0e10cSrcweir {
738*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
739*cdf0e10cSrcweir     SwView* pTargetView = rConfigItem.GetTargetView();
740*cdf0e10cSrcweir     DBG_ASSERT(pTargetView, "no target view exists");
741*cdf0e10cSrcweir     if(!pTargetView)
742*cdf0e10cSrcweir         return 0;
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir     if(m_aSaveAsOneRB.IsChecked())
745*cdf0e10cSrcweir     {
746*cdf0e10cSrcweir         String sFilter;
747*cdf0e10cSrcweir         String sPath = SwMailMergeHelper::CallSaveAsDialog(sFilter);
748*cdf0e10cSrcweir         if(!sPath.Len())
749*cdf0e10cSrcweir             return 0;
750*cdf0e10cSrcweir         uno::Sequence< beans::PropertyValue > aValues(1);
751*cdf0e10cSrcweir         beans::PropertyValue* pValues = aValues.getArray();
752*cdf0e10cSrcweir         pValues[0].Name = C2U("FilterName");
753*cdf0e10cSrcweir         pValues[0].Value <<= ::rtl::OUString(sFilter);
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir         uno::Reference< frame::XStorable > xStore( pTargetView->GetDocShell()->GetModel(), uno::UNO_QUERY);
756*cdf0e10cSrcweir         sal_uInt32 nErrorCode = ERRCODE_NONE;
757*cdf0e10cSrcweir         try
758*cdf0e10cSrcweir         {
759*cdf0e10cSrcweir             xStore->storeToURL( sPath, aValues );
760*cdf0e10cSrcweir         }
761*cdf0e10cSrcweir         catch( task::ErrorCodeIOException& aErrorEx )
762*cdf0e10cSrcweir         {
763*cdf0e10cSrcweir             nErrorCode = (sal_uInt32)aErrorEx.ErrCode;
764*cdf0e10cSrcweir         }
765*cdf0e10cSrcweir         catch( Exception& )
766*cdf0e10cSrcweir         {
767*cdf0e10cSrcweir             nErrorCode = ERRCODE_IO_GENERAL;
768*cdf0e10cSrcweir         }
769*cdf0e10cSrcweir         if( nErrorCode != ERRCODE_NONE )
770*cdf0e10cSrcweir         {
771*cdf0e10cSrcweir             SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC, pTargetView->GetDocShell()->GetTitle());
772*cdf0e10cSrcweir             ErrorHandler::HandleError( nErrorCode );
773*cdf0e10cSrcweir         }
774*cdf0e10cSrcweir     }
775*cdf0e10cSrcweir     else
776*cdf0e10cSrcweir     {
777*cdf0e10cSrcweir         sal_uInt32 nBegin = 0;
778*cdf0e10cSrcweir         sal_uInt32 nEnd = 0;
779*cdf0e10cSrcweir         if(m_aSaveIndividualRB.IsChecked())
780*cdf0e10cSrcweir         {
781*cdf0e10cSrcweir             nBegin = 0;
782*cdf0e10cSrcweir             nEnd = rConfigItem.GetMergedDocumentCount();
783*cdf0e10cSrcweir         }
784*cdf0e10cSrcweir         else
785*cdf0e10cSrcweir         {
786*cdf0e10cSrcweir             nBegin  = static_cast< sal_Int32 >(m_aFromNF.GetValue() - 1);
787*cdf0e10cSrcweir             nEnd    = static_cast< sal_Int32 >(m_aToNF.GetValue());
788*cdf0e10cSrcweir             if(nEnd > rConfigItem.GetMergedDocumentCount())
789*cdf0e10cSrcweir                 nEnd = rConfigItem.GetMergedDocumentCount();
790*cdf0e10cSrcweir         }
791*cdf0e10cSrcweir         String sFilter;
792*cdf0e10cSrcweir         String sPath = SwMailMergeHelper::CallSaveAsDialog(sFilter);
793*cdf0e10cSrcweir         if(!sPath.Len())
794*cdf0e10cSrcweir             return 0;
795*cdf0e10cSrcweir         String sTargetTempURL = URIHelper::SmartRel2Abs(
796*cdf0e10cSrcweir             INetURLObject(), utl::TempFile::CreateTempName(),
797*cdf0e10cSrcweir             URIHelper::GetMaybeFileHdl());
798*cdf0e10cSrcweir         const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
799*cdf0e10cSrcweir                 String::CreateFromAscii( FILTER_XML ),
800*cdf0e10cSrcweir                 SwDocShell::Factory().GetFilterContainer() );
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir         uno::Sequence< beans::PropertyValue > aValues(1);
803*cdf0e10cSrcweir         beans::PropertyValue* pValues = aValues.getArray();
804*cdf0e10cSrcweir         pValues[0].Name = C2U("FilterName");
805*cdf0e10cSrcweir         pValues[0].Value <<= ::rtl::OUString(pSfxFlt->GetFilterName());
806*cdf0e10cSrcweir 
807*cdf0e10cSrcweir         uno::Reference< frame::XStorable > xStore( pTargetView->GetDocShell()->GetModel(), uno::UNO_QUERY);
808*cdf0e10cSrcweir         sal_uInt32 nErrorCode = ERRCODE_NONE;
809*cdf0e10cSrcweir         try
810*cdf0e10cSrcweir         {
811*cdf0e10cSrcweir             xStore->storeToURL( sTargetTempURL, aValues );
812*cdf0e10cSrcweir         }
813*cdf0e10cSrcweir         catch( task::ErrorCodeIOException& aErrorEx )
814*cdf0e10cSrcweir         {
815*cdf0e10cSrcweir             nErrorCode = (sal_uInt32)aErrorEx.ErrCode;
816*cdf0e10cSrcweir         }
817*cdf0e10cSrcweir         catch( Exception& )
818*cdf0e10cSrcweir         {
819*cdf0e10cSrcweir             nErrorCode = ERRCODE_IO_GENERAL;
820*cdf0e10cSrcweir         }
821*cdf0e10cSrcweir         if( nErrorCode != ERRCODE_NONE )
822*cdf0e10cSrcweir         {
823*cdf0e10cSrcweir             SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC, pTargetView->GetDocShell()->GetTitle());
824*cdf0e10cSrcweir             ErrorHandler::HandleError( nErrorCode );
825*cdf0e10cSrcweir         }
826*cdf0e10cSrcweir 
827*cdf0e10cSrcweir         SwView* pSourceView = rConfigItem.GetSourceView();
828*cdf0e10cSrcweir         PrintMonitor aSaveMonitor(this, PrintMonitor::MONITOR_TYPE_SAVE);
829*cdf0e10cSrcweir         aSaveMonitor.aDocName.SetText(pSourceView->GetDocShell()->GetTitle(22));
830*cdf0e10cSrcweir         aSaveMonitor.aCancel.SetClickHdl(LINK(this, SwMailMergeOutputPage, SaveCancelHdl_Impl));
831*cdf0e10cSrcweir         aSaveMonitor.aPrinter.SetText( INetURLObject( sPath ).getFSysPath( INetURLObject::FSYS_DETECT ) );
832*cdf0e10cSrcweir 	    aSaveMonitor.ResizeControls();
833*cdf0e10cSrcweir 
834*cdf0e10cSrcweir         m_bCancelSaving = false;
835*cdf0e10cSrcweir         aSaveMonitor.Show();
836*cdf0e10cSrcweir         m_pWizard->enableButtons(WZB_CANCEL, sal_False);
837*cdf0e10cSrcweir 
838*cdf0e10cSrcweir         for(sal_uInt32 nDoc = nBegin; nDoc < nEnd && !m_bCancelSaving; ++nDoc)
839*cdf0e10cSrcweir         {
840*cdf0e10cSrcweir             SwDocMergeInfo& rInfo = rConfigItem.GetDocumentMergeInfo(nDoc);
841*cdf0e10cSrcweir             INetURLObject aURL(sPath);
842*cdf0e10cSrcweir             String sFile = aURL.GetBase();
843*cdf0e10cSrcweir             String sExtension = aURL.getExtension();
844*cdf0e10cSrcweir             if(!sExtension.Len())
845*cdf0e10cSrcweir             {
846*cdf0e10cSrcweir                 sExtension = pSfxFlt->GetWildcard()().GetToken(1, '.');
847*cdf0e10cSrcweir                 sPath += '.';
848*cdf0e10cSrcweir                 sPath += sExtension;
849*cdf0e10cSrcweir             }
850*cdf0e10cSrcweir             String sStat(SW_RES(STR_STATSTR_LETTER));
851*cdf0e10cSrcweir             sStat += ' ';
852*cdf0e10cSrcweir             sStat += String::CreateFromInt32( nDoc );
853*cdf0e10cSrcweir             aSaveMonitor.aPrintInfo.SetText(sStat);
854*cdf0e10cSrcweir 
855*cdf0e10cSrcweir             //now extract a document from the target document
856*cdf0e10cSrcweir             // the shell will be closed at the end, but it is more safe to use SfxObjectShellLock here
857*cdf0e10cSrcweir             SfxObjectShellLock xTempDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
858*cdf0e10cSrcweir             xTempDocShell->DoInitNew( 0 );
859*cdf0e10cSrcweir             SfxViewFrame* pTempFrame = SfxViewFrame::LoadHiddenDocument( *xTempDocShell, 0 );
860*cdf0e10cSrcweir //            pTempFrame->GetFrame().Appear();
861*cdf0e10cSrcweir             SwView* pTempView = static_cast<SwView*>( pTempFrame->GetViewShell() );
862*cdf0e10cSrcweir             pTargetView->GetWrtShell().StartAction();
863*cdf0e10cSrcweir             SwgReaderOption aOpt;
864*cdf0e10cSrcweir             aOpt.SetTxtFmts( sal_True );
865*cdf0e10cSrcweir             aOpt.SetFrmFmts( sal_True );
866*cdf0e10cSrcweir             aOpt.SetPageDescs( sal_True );
867*cdf0e10cSrcweir             aOpt.SetNumRules( sal_True );
868*cdf0e10cSrcweir             aOpt.SetMerge( sal_False );
869*cdf0e10cSrcweir             pTempView->GetDocShell()->LoadStylesFromFile(
870*cdf0e10cSrcweir                     sTargetTempURL, aOpt, sal_True );
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir             pTargetView->GetWrtShell().PastePages(pTempView->GetWrtShell(),
873*cdf0e10cSrcweir                     (sal_uInt16)rInfo.nStartPageInTarget, (sal_uInt16)rInfo.nEndPageInTarget );
874*cdf0e10cSrcweir             pTargetView->GetWrtShell().EndAction();
875*cdf0e10cSrcweir             //then save it
876*cdf0e10cSrcweir             String sOutPath = aURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
877*cdf0e10cSrcweir             String sCounter('_');
878*cdf0e10cSrcweir             sCounter += String::CreateFromInt32(nDoc);
879*cdf0e10cSrcweir             sOutPath.Insert(sCounter, sOutPath.Len() - sExtension.Len() - 1);
880*cdf0e10cSrcweir             //SfxStringItem aName(SID_FILE_NAME, sOutPath);
881*cdf0e10cSrcweir             //SfxStringItem aFilter(SID_FILTER_NAME, sFilter);
882*cdf0e10cSrcweir 
883*cdf0e10cSrcweir             while(true)
884*cdf0e10cSrcweir             {
885*cdf0e10cSrcweir                 //time for other slots is needed
886*cdf0e10cSrcweir                 for(sal_Int16 r = 0; r < 10; ++r)
887*cdf0e10cSrcweir                     Application::Reschedule();
888*cdf0e10cSrcweir                 bool bFailed = false;
889*cdf0e10cSrcweir                 try
890*cdf0e10cSrcweir                 {
891*cdf0e10cSrcweir                     pValues[0].Value <<= ::rtl::OUString(sFilter);
892*cdf0e10cSrcweir                     uno::Reference< frame::XStorable > xTempStore( xTempDocShell->GetModel(), uno::UNO_QUERY);
893*cdf0e10cSrcweir                     xTempStore->storeToURL( sOutPath, aValues   );
894*cdf0e10cSrcweir                 }
895*cdf0e10cSrcweir                 catch( const uno::Exception& )
896*cdf0e10cSrcweir                 {
897*cdf0e10cSrcweir                     bFailed = true;
898*cdf0e10cSrcweir                 }
899*cdf0e10cSrcweir 
900*cdf0e10cSrcweir                 if(bFailed)
901*cdf0e10cSrcweir                 {
902*cdf0e10cSrcweir                     SwSaveWarningBox_Impl aWarning( pButton, sOutPath );
903*cdf0e10cSrcweir                     if(RET_OK == aWarning.Execute())
904*cdf0e10cSrcweir                         sOutPath = aWarning.GetFileName();
905*cdf0e10cSrcweir                     else
906*cdf0e10cSrcweir                     {
907*cdf0e10cSrcweir                         xTempDocShell->DoClose();
908*cdf0e10cSrcweir                         return 0;
909*cdf0e10cSrcweir                     }
910*cdf0e10cSrcweir                 }
911*cdf0e10cSrcweir                 else
912*cdf0e10cSrcweir                 {
913*cdf0e10cSrcweir                     xTempDocShell->DoClose();
914*cdf0e10cSrcweir                     break;
915*cdf0e10cSrcweir                 }
916*cdf0e10cSrcweir             }
917*cdf0e10cSrcweir         }
918*cdf0e10cSrcweir         ::osl::File::remove( sTargetTempURL );
919*cdf0e10cSrcweir     }
920*cdf0e10cSrcweir     m_pWizard->enableButtons(WZB_CANCEL, sal_True);
921*cdf0e10cSrcweir     m_pWizard->enableButtons(WZB_FINISH, sal_True);
922*cdf0e10cSrcweir     return 0;
923*cdf0e10cSrcweir }
924*cdf0e10cSrcweir /*-- 22.06.2004 11:51:30---------------------------------------------------
925*cdf0e10cSrcweir 
926*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
927*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, PrinterChangeHdl_Impl, ListBox*, pBox)
928*cdf0e10cSrcweir {
929*cdf0e10cSrcweir     if( m_pDocumentPrinterCopy && pBox->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
930*cdf0e10cSrcweir     {
931*cdf0e10cSrcweir         const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->GetSelectEntry(), false );
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir         if( pInfo )
934*cdf0e10cSrcweir         {
935*cdf0e10cSrcweir             if ( !m_pTempPrinter )
936*cdf0e10cSrcweir             {
937*cdf0e10cSrcweir                 if( (m_pDocumentPrinterCopy->GetName() == pInfo->GetPrinterName()) &&
938*cdf0e10cSrcweir                      (m_pDocumentPrinterCopy->GetDriverName() == pInfo->GetDriver()) )
939*cdf0e10cSrcweir                     m_pTempPrinter = new Printer( m_pDocumentPrinterCopy->GetJobSetup() );
940*cdf0e10cSrcweir                 else
941*cdf0e10cSrcweir                     m_pTempPrinter = new Printer( *pInfo );
942*cdf0e10cSrcweir             }
943*cdf0e10cSrcweir             else
944*cdf0e10cSrcweir             {
945*cdf0e10cSrcweir                 if( (m_pTempPrinter->GetName() != pInfo->GetPrinterName()) ||
946*cdf0e10cSrcweir                      (m_pTempPrinter->GetDriverName() != pInfo->GetDriver()) )
947*cdf0e10cSrcweir                 {
948*cdf0e10cSrcweir                     delete m_pTempPrinter;
949*cdf0e10cSrcweir                     m_pTempPrinter = new Printer( *pInfo );
950*cdf0e10cSrcweir                 }
951*cdf0e10cSrcweir             }
952*cdf0e10cSrcweir         }
953*cdf0e10cSrcweir         else if( ! m_pTempPrinter )
954*cdf0e10cSrcweir             m_pTempPrinter = new Printer();
955*cdf0e10cSrcweir 
956*cdf0e10cSrcweir         m_aPrinterSettingsPB.Enable( m_pTempPrinter->HasSupport( SUPPORT_SETUPDIALOG ) );
957*cdf0e10cSrcweir     }
958*cdf0e10cSrcweir     else
959*cdf0e10cSrcweir         m_aPrinterSettingsPB.Disable();
960*cdf0e10cSrcweir     m_pWizard->GetConfigItem().SetSelectedPrinter( pBox->GetSelectEntry() );
961*cdf0e10cSrcweir 
962*cdf0e10cSrcweir //    return m_pTempPrinter;
963*cdf0e10cSrcweir     return 0;
964*cdf0e10cSrcweir }
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir /*-- 17.05.2004 13:51:02---------------------------------------------------
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
969*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, PrintHdl_Impl, PushButton*, EMPTYARG)
970*cdf0e10cSrcweir {
971*cdf0e10cSrcweir     SwView* pTargetView = m_pWizard->GetConfigItem().GetTargetView();
972*cdf0e10cSrcweir     DBG_ASSERT(pTargetView, "no target view exists");
973*cdf0e10cSrcweir     if(!pTargetView)
974*cdf0e10cSrcweir         return 0;
975*cdf0e10cSrcweir 
976*cdf0e10cSrcweir     sal_uInt32 nBegin = 0;
977*cdf0e10cSrcweir     sal_uInt32 nEnd = 0;
978*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
979*cdf0e10cSrcweir     if(m_aPrintAllRB.IsChecked())
980*cdf0e10cSrcweir     {
981*cdf0e10cSrcweir         nBegin = 0;
982*cdf0e10cSrcweir         nEnd = rConfigItem.GetMergedDocumentCount();
983*cdf0e10cSrcweir     }
984*cdf0e10cSrcweir     else
985*cdf0e10cSrcweir     {
986*cdf0e10cSrcweir         nBegin  = static_cast< sal_Int32 >(m_aFromNF.GetValue() - 1);
987*cdf0e10cSrcweir         nEnd    = static_cast< sal_Int32 >(m_aToNF.GetValue());
988*cdf0e10cSrcweir         if(nEnd > rConfigItem.GetMergedDocumentCount())
989*cdf0e10cSrcweir             nEnd = rConfigItem.GetMergedDocumentCount();
990*cdf0e10cSrcweir     }
991*cdf0e10cSrcweir     rConfigItem.SetPrintRange( (sal_uInt16)nBegin, (sal_uInt16)nEnd );
992*cdf0e10cSrcweir     SwDocMergeInfo& rStartInfo = rConfigItem.GetDocumentMergeInfo(nBegin);
993*cdf0e10cSrcweir     SwDocMergeInfo& rEndInfo = rConfigItem.GetDocumentMergeInfo(nEnd - 1);
994*cdf0e10cSrcweir 
995*cdf0e10cSrcweir     rtl::OUString sPages(rtl::OUString::valueOf( rStartInfo.nStartPageInTarget ));
996*cdf0e10cSrcweir     sPages += rtl::OUString::createFromAscii( " - ");
997*cdf0e10cSrcweir     sPages += rtl::OUString::valueOf(  rEndInfo.nEndPageInTarget );
998*cdf0e10cSrcweir 
999*cdf0e10cSrcweir     SwWrtShell& rSh = pTargetView->GetWrtShell();
1000*cdf0e10cSrcweir     pTargetView->SetMailMergeConfigItem(&rConfigItem, 0, sal_False);
1001*cdf0e10cSrcweir     if(m_pTempPrinter)
1002*cdf0e10cSrcweir     {
1003*cdf0e10cSrcweir         m_pDocumentPrinterCopy->SetPrinterProps(m_pTempPrinter);
1004*cdf0e10cSrcweir         pTargetView->SetPrinter(m_pDocumentPrinterCopy->Clone());
1005*cdf0e10cSrcweir     }
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir     SfxObjectShell* pObjSh = pTargetView->GetViewFrame()->GetObjectShell();
1008*cdf0e10cSrcweir     SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), pObjSh));
1009*cdf0e10cSrcweir     rSh.GetNewDBMgr()->SetMergeType( DBMGR_MERGE_DOCUMENTS );
1010*cdf0e10cSrcweir     //SfxDispatcher *pDis = pTargetView->GetViewFrame()->GetDispatcher();
1011*cdf0e10cSrcweir     SfxBoolItem aMergeSilent(SID_SILENT, sal_False);
1012*cdf0e10cSrcweir     m_pWizard->enableButtons(WZB_CANCEL, sal_False);
1013*cdf0e10cSrcweir 
1014*cdf0e10cSrcweir     uno::Sequence < beans::PropertyValue > aProps( 2 );
1015*cdf0e10cSrcweir     aProps[0]. Name = rtl::OUString::createFromAscii("MonitorVisible");
1016*cdf0e10cSrcweir     aProps[0].Value <<= sal_True;
1017*cdf0e10cSrcweir     aProps[1]. Name = rtl::OUString::createFromAscii("Pages");
1018*cdf0e10cSrcweir     aProps[1]. Value <<= sPages;
1019*cdf0e10cSrcweir 
1020*cdf0e10cSrcweir     pTargetView->ExecPrint( aProps, false, true );
1021*cdf0e10cSrcweir     SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), pObjSh));
1022*cdf0e10cSrcweir 
1023*cdf0e10cSrcweir     pTargetView->SetMailMergeConfigItem(0, 0, sal_False);
1024*cdf0e10cSrcweir     m_pWizard->enableButtons(WZB_CANCEL, sal_True);
1025*cdf0e10cSrcweir     m_pWizard->enableButtons(WZB_FINISH, sal_True);
1026*cdf0e10cSrcweir     return 0;
1027*cdf0e10cSrcweir }
1028*cdf0e10cSrcweir /*-- 17.05.2004 13:51:02---------------------------------------------------
1029*cdf0e10cSrcweir 
1030*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1031*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, PrinterSetupHdl_Impl, PushButton*, pButton)
1032*cdf0e10cSrcweir {
1033*cdf0e10cSrcweir     if( !m_pTempPrinter )
1034*cdf0e10cSrcweir         PrinterChangeHdl_Impl(&m_aPrinterLB);
1035*cdf0e10cSrcweir     if(m_pTempPrinter)
1036*cdf0e10cSrcweir         m_pTempPrinter->Setup(pButton);
1037*cdf0e10cSrcweir     return 0;
1038*cdf0e10cSrcweir }
1039*cdf0e10cSrcweir /*-- 14.06.2004 09:34:01---------------------------------------------------
1040*cdf0e10cSrcweir 
1041*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1042*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, SendTypeHdl_Impl, ListBox*, pBox)
1043*cdf0e10cSrcweir {
1044*cdf0e10cSrcweir     sal_uLong nDocType = (sal_uLong)pBox->GetEntryData(pBox->GetSelectEntryPos());
1045*cdf0e10cSrcweir     sal_Bool bEnable = MM_DOCTYPE_HTML != nDocType && MM_DOCTYPE_TEXT != nDocType;
1046*cdf0e10cSrcweir     m_aSendAsPB.Enable( bEnable );
1047*cdf0e10cSrcweir     m_aAttachmentFT.Enable( bEnable );
1048*cdf0e10cSrcweir     m_aAttachmentED.Enable( bEnable );
1049*cdf0e10cSrcweir     if(bEnable)
1050*cdf0e10cSrcweir     {
1051*cdf0e10cSrcweir         //add the correct extension
1052*cdf0e10cSrcweir         String sAttach(m_aAttachmentED.GetText());
1053*cdf0e10cSrcweir         //do nothing if the user has removed the name - the warning will come early enough
1054*cdf0e10cSrcweir         if(sAttach.Len())
1055*cdf0e10cSrcweir         {
1056*cdf0e10cSrcweir             xub_StrLen nTokenCount = sAttach.GetTokenCount( '.' );
1057*cdf0e10cSrcweir             if( 2 > nTokenCount)
1058*cdf0e10cSrcweir             {
1059*cdf0e10cSrcweir                 sAttach += '.';
1060*cdf0e10cSrcweir                 ++nTokenCount;
1061*cdf0e10cSrcweir             }
1062*cdf0e10cSrcweir             sAttach.SetToken( nTokenCount - 1, '.', lcl_GetExtensionForDocType( nDocType ));
1063*cdf0e10cSrcweir             m_aAttachmentED.SetText(sAttach);
1064*cdf0e10cSrcweir         }
1065*cdf0e10cSrcweir     }
1066*cdf0e10cSrcweir     return 0;
1067*cdf0e10cSrcweir }
1068*cdf0e10cSrcweir /*-- 17.05.2004 13:51:02---------------------------------------------------
1069*cdf0e10cSrcweir 
1070*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1071*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, SendAsHdl_Impl, PushButton*, pButton)
1072*cdf0e10cSrcweir {
1073*cdf0e10cSrcweir     SwMailBodyDialog* pDlg = new SwMailBodyDialog(pButton, m_pWizard);
1074*cdf0e10cSrcweir     pDlg->SetBody(m_sBody);
1075*cdf0e10cSrcweir     if(RET_OK == pDlg->Execute())
1076*cdf0e10cSrcweir     {
1077*cdf0e10cSrcweir         m_sBody = pDlg->GetBody();
1078*cdf0e10cSrcweir     }
1079*cdf0e10cSrcweir     return 0;
1080*cdf0e10cSrcweir }
1081*cdf0e10cSrcweir /*-- 21.05.2004 12:03:25---------------------------------------------------
1082*cdf0e10cSrcweir     Send documents as e-mail
1083*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1084*cdf0e10cSrcweir IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton)
1085*cdf0e10cSrcweir {
1086*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
1087*cdf0e10cSrcweir 
1088*cdf0e10cSrcweir     //get the composed document
1089*cdf0e10cSrcweir     SwView* pTargetView = rConfigItem.GetTargetView();
1090*cdf0e10cSrcweir     DBG_ASSERT(pTargetView, "no target view exists");
1091*cdf0e10cSrcweir     if(!pTargetView)
1092*cdf0e10cSrcweir         return 0;
1093*cdf0e10cSrcweir 
1094*cdf0e10cSrcweir     if(!rConfigItem.GetMailServer().getLength() ||
1095*cdf0e10cSrcweir             !SwMailMergeHelper::CheckMailAddress(rConfigItem.GetMailAddress()) )
1096*cdf0e10cSrcweir     {
1097*cdf0e10cSrcweir         QueryBox aQuery(pButton, WB_YES_NO_CANCEL, m_sConfigureMail);
1098*cdf0e10cSrcweir         sal_uInt16 nRet = aQuery.Execute();
1099*cdf0e10cSrcweir         if(RET_YES == nRet )
1100*cdf0e10cSrcweir         {
1101*cdf0e10cSrcweir             SfxAllItemSet aSet(pTargetView->GetPool());
1102*cdf0e10cSrcweir             SwMailConfigDlg* pDlg = new SwMailConfigDlg(pButton, aSet);
1103*cdf0e10cSrcweir             nRet = pDlg->Execute();
1104*cdf0e10cSrcweir             delete pDlg;
1105*cdf0e10cSrcweir         }
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir         if(nRet != RET_OK && nRet != RET_YES)
1108*cdf0e10cSrcweir             return 0;
1109*cdf0e10cSrcweir     }
1110*cdf0e10cSrcweir     //add the documents
1111*cdf0e10cSrcweir     sal_uInt32 nBegin = 0;
1112*cdf0e10cSrcweir     sal_uInt32 nEnd = 0;
1113*cdf0e10cSrcweir     if(m_aSendAllRB.IsChecked())
1114*cdf0e10cSrcweir     {
1115*cdf0e10cSrcweir         nBegin = 0;
1116*cdf0e10cSrcweir         nEnd = rConfigItem.GetMergedDocumentCount();
1117*cdf0e10cSrcweir     }
1118*cdf0e10cSrcweir     else
1119*cdf0e10cSrcweir     {
1120*cdf0e10cSrcweir         nBegin  = static_cast< sal_Int32 >(m_aFromNF.GetValue() - 1);
1121*cdf0e10cSrcweir         nEnd    = static_cast< sal_Int32 >(m_aToNF.GetValue());
1122*cdf0e10cSrcweir         if(nEnd > rConfigItem.GetMergedDocumentCount())
1123*cdf0e10cSrcweir             nEnd = rConfigItem.GetMergedDocumentCount();
1124*cdf0e10cSrcweir     }
1125*cdf0e10cSrcweir     bool bAsBody = false;
1126*cdf0e10cSrcweir     bool bIsPDF = false;
1127*cdf0e10cSrcweir     rtl_TextEncoding eEncoding = ::gsl_getSystemTextEncoding();
1128*cdf0e10cSrcweir     SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
1129*cdf0e10cSrcweir     const SfxFilter *pSfxFlt = 0;
1130*cdf0e10cSrcweir     sal_uLong nDocType = (sal_uLong)m_aSendAsLB.GetEntryData(m_aSendAsLB.GetSelectEntryPos());
1131*cdf0e10cSrcweir     String sExtension = lcl_GetExtensionForDocType(nDocType);
1132*cdf0e10cSrcweir     switch( nDocType )
1133*cdf0e10cSrcweir     {
1134*cdf0e10cSrcweir         case MM_DOCTYPE_OOO : break;
1135*cdf0e10cSrcweir         case MM_DOCTYPE_PDF : bIsPDF = true;
1136*cdf0e10cSrcweir         {
1137*cdf0e10cSrcweir             //the method SwIOSystemGetFilterOfFormat( ) returns the template filter
1138*cdf0e10cSrcweir             //because it uses the same user data :-(
1139*cdf0e10cSrcweir             SfxFilterMatcher aMatcher( pFilterContainer->GetName() );
1140*cdf0e10cSrcweir             SfxFilterMatcherIter aIter( &aMatcher );
1141*cdf0e10cSrcweir             const SfxFilter* pFilter = aIter.First();
1142*cdf0e10cSrcweir             String sFilterMime( String::CreateFromAscii( "application/pdf" ));
1143*cdf0e10cSrcweir             while ( pFilter )
1144*cdf0e10cSrcweir             {
1145*cdf0e10cSrcweir                 if( pFilter->GetMimeType() == sFilterMime  && pFilter->CanExport() )
1146*cdf0e10cSrcweir                 {
1147*cdf0e10cSrcweir                     pSfxFlt = pFilter;
1148*cdf0e10cSrcweir                     break;
1149*cdf0e10cSrcweir                 }
1150*cdf0e10cSrcweir                 pFilter = aIter.Next();
1151*cdf0e10cSrcweir             }
1152*cdf0e10cSrcweir 
1153*cdf0e10cSrcweir         }
1154*cdf0e10cSrcweir         break;
1155*cdf0e10cSrcweir         case MM_DOCTYPE_WORD:
1156*cdf0e10cSrcweir         {
1157*cdf0e10cSrcweir             //the method SwIOSystemGetFilterOfFormat( ) returns the template filter
1158*cdf0e10cSrcweir             //because it uses the same user data :-(
1159*cdf0e10cSrcweir             SfxFilterMatcher aMatcher( pFilterContainer->GetName() );
1160*cdf0e10cSrcweir             SfxFilterMatcherIter aIter( &aMatcher );
1161*cdf0e10cSrcweir             const SfxFilter* pFilter = aIter.First();
1162*cdf0e10cSrcweir             String sFilterUserData( String::CreateFromAscii( FILTER_WW8 ));
1163*cdf0e10cSrcweir             while ( pFilter )
1164*cdf0e10cSrcweir             {
1165*cdf0e10cSrcweir                 if( pFilter->GetUserData() == sFilterUserData   && pFilter->CanExport() )
1166*cdf0e10cSrcweir                 {
1167*cdf0e10cSrcweir                     pSfxFlt = pFilter;
1168*cdf0e10cSrcweir                     break;
1169*cdf0e10cSrcweir                 }
1170*cdf0e10cSrcweir                 pFilter = aIter.Next();
1171*cdf0e10cSrcweir             }
1172*cdf0e10cSrcweir 
1173*cdf0e10cSrcweir         }
1174*cdf0e10cSrcweir         break;
1175*cdf0e10cSrcweir         case MM_DOCTYPE_HTML:
1176*cdf0e10cSrcweir         {
1177*cdf0e10cSrcweir             bAsBody = true;
1178*cdf0e10cSrcweir             SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get();
1179*cdf0e10cSrcweir             eEncoding = pHtmlOptions->GetTextEncoding();
1180*cdf0e10cSrcweir         }
1181*cdf0e10cSrcweir         break;
1182*cdf0e10cSrcweir         case MM_DOCTYPE_TEXT:
1183*cdf0e10cSrcweir             bAsBody = true;
1184*cdf0e10cSrcweir         break;
1185*cdf0e10cSrcweir     }
1186*cdf0e10cSrcweir     if(!pSfxFlt)
1187*cdf0e10cSrcweir         pSfxFlt = pFilterContainer->GetFilter4Extension(sExtension, SFX_FILTER_EXPORT);
1188*cdf0e10cSrcweir 
1189*cdf0e10cSrcweir     if(!pSfxFlt)
1190*cdf0e10cSrcweir         return 0;
1191*cdf0e10cSrcweir     String sMimeType = pSfxFlt->GetMimeType();
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir     if(!m_aSubjectED.GetText().Len())
1194*cdf0e10cSrcweir     {
1195*cdf0e10cSrcweir         SwSendQueryBox_Impl aQuery(pButton, m_sNoSubjectQueryST);
1196*cdf0e10cSrcweir         aQuery.SetIsEmptyTextAllowed(true);
1197*cdf0e10cSrcweir         aQuery.SetValue(m_sNoSubjectST);
1198*cdf0e10cSrcweir         if(RET_OK == aQuery.Execute())
1199*cdf0e10cSrcweir         {
1200*cdf0e10cSrcweir             if(aQuery.GetValue() != m_sNoSubjectST)
1201*cdf0e10cSrcweir                 m_aSubjectED.SetText(aQuery.GetValue());
1202*cdf0e10cSrcweir         }
1203*cdf0e10cSrcweir         else
1204*cdf0e10cSrcweir             return 0;
1205*cdf0e10cSrcweir     }
1206*cdf0e10cSrcweir     if(!bAsBody && !m_aAttachmentED.GetText().Len())
1207*cdf0e10cSrcweir     {
1208*cdf0e10cSrcweir         SwSendQueryBox_Impl aQuery(pButton, m_sNoAttachmentNameST);
1209*cdf0e10cSrcweir         aQuery.SetIsEmptyTextAllowed(false);
1210*cdf0e10cSrcweir         if(RET_OK == aQuery.Execute())
1211*cdf0e10cSrcweir         {
1212*cdf0e10cSrcweir             String sAttach(aQuery.GetValue());
1213*cdf0e10cSrcweir             xub_StrLen nTokenCount = sAttach.GetTokenCount( '.' );
1214*cdf0e10cSrcweir             if( 2 > nTokenCount)
1215*cdf0e10cSrcweir             {
1216*cdf0e10cSrcweir                 sAttach += '.';
1217*cdf0e10cSrcweir                 ++nTokenCount;
1218*cdf0e10cSrcweir             }
1219*cdf0e10cSrcweir             sAttach.SetToken( nTokenCount - 1, '.', lcl_GetExtensionForDocType(
1220*cdf0e10cSrcweir                      (sal_uLong)m_aSendAsLB.GetEntryData(m_aSendAsLB.GetSelectEntryPos())));
1221*cdf0e10cSrcweir             m_aAttachmentED.SetText(sAttach);
1222*cdf0e10cSrcweir         }
1223*cdf0e10cSrcweir         else
1224*cdf0e10cSrcweir             return 0;
1225*cdf0e10cSrcweir     }
1226*cdf0e10cSrcweir     SfxStringItem aFilterName( SID_FILTER_NAME, pSfxFlt->GetFilterName() );
1227*cdf0e10cSrcweir     String sEMailColumn = m_aMailToLB.GetSelectEntry();
1228*cdf0e10cSrcweir     DBG_ASSERT( sEMailColumn.Len(), "No email column selected");
1229*cdf0e10cSrcweir     Reference< sdbcx::XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), UNO_QUERY);
1230*cdf0e10cSrcweir     Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
1231*cdf0e10cSrcweir     if(!sEMailColumn.Len() || !xColAccess.is() || !xColAccess->hasByName(sEMailColumn))
1232*cdf0e10cSrcweir         return 0;
1233*cdf0e10cSrcweir 
1234*cdf0e10cSrcweir     String sFilterOptions;
1235*cdf0e10cSrcweir     if(MM_DOCTYPE_TEXT == nDocType)
1236*cdf0e10cSrcweir     {
1237*cdf0e10cSrcweir         SwAsciiOptions aOpt;
1238*cdf0e10cSrcweir         sal_uInt16 nAppScriptType = GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() );
1239*cdf0e10cSrcweir         sal_uInt16 nWhich = GetWhichOfScript( RES_CHRATR_LANGUAGE, nAppScriptType);
1240*cdf0e10cSrcweir         aOpt.SetLanguage( ((SvxLanguageItem&)pTargetView->GetWrtShell().
1241*cdf0e10cSrcweir                             GetDefault( nWhich )).GetLanguage());
1242*cdf0e10cSrcweir         aOpt.SetParaFlags( LINEEND_CR );
1243*cdf0e10cSrcweir         aOpt.WriteUserData( sFilterOptions );
1244*cdf0e10cSrcweir     }
1245*cdf0e10cSrcweir     String sTargetTempURL = URIHelper::SmartRel2Abs(
1246*cdf0e10cSrcweir         INetURLObject(), utl::TempFile::CreateTempName(),
1247*cdf0e10cSrcweir         URIHelper::GetMaybeFileHdl());
1248*cdf0e10cSrcweir     const SfxFilter *pTargetSfxFlt = SwIoSystem::GetFilterOfFormat(
1249*cdf0e10cSrcweir             String::CreateFromAscii( FILTER_XML ),
1250*cdf0e10cSrcweir             SwDocShell::Factory().GetFilterContainer() );
1251*cdf0e10cSrcweir 
1252*cdf0e10cSrcweir     uno::Sequence< beans::PropertyValue > aValues(1);
1253*cdf0e10cSrcweir     beans::PropertyValue* pValues = aValues.getArray();
1254*cdf0e10cSrcweir     pValues[0].Name = C2U("FilterName");
1255*cdf0e10cSrcweir     pValues[0].Value <<= ::rtl::OUString(pTargetSfxFlt->GetFilterName());
1256*cdf0e10cSrcweir 
1257*cdf0e10cSrcweir     uno::Reference< frame::XStorable > xStore( pTargetView->GetDocShell()->GetModel(), uno::UNO_QUERY);
1258*cdf0e10cSrcweir     xStore->storeToURL( sTargetTempURL, aValues   );
1259*cdf0e10cSrcweir 
1260*cdf0e10cSrcweir     //create the send dialog
1261*cdf0e10cSrcweir     SwSendMailDialog* pDlg = new SwSendMailDialog( pButton, rConfigItem );
1262*cdf0e10cSrcweir     pDlg->SetDocumentCount( nEnd );
1263*cdf0e10cSrcweir     pDlg->ShowDialog();
1264*cdf0e10cSrcweir     //help to force painting the dialog
1265*cdf0e10cSrcweir     //TODO/CLEANUP
1266*cdf0e10cSrcweir     //Sollbruchstelle
1267*cdf0e10cSrcweir     for ( sal_Int16 i = 0; i < 25; i++)
1268*cdf0e10cSrcweir         Application::Reschedule();
1269*cdf0e10cSrcweir     for(sal_uInt32 nDoc = nBegin; nDoc < nEnd; ++nDoc)
1270*cdf0e10cSrcweir     {
1271*cdf0e10cSrcweir         m_pWizard->EnterWait();
1272*cdf0e10cSrcweir         SwDocMergeInfo& rInfo = rConfigItem.GetDocumentMergeInfo(nDoc);
1273*cdf0e10cSrcweir 
1274*cdf0e10cSrcweir         //now extract a document from the target document
1275*cdf0e10cSrcweir         // the shell will be closed at the end, but it is more safe to use SfxObjectShellLock here
1276*cdf0e10cSrcweir         SfxObjectShellLock xTempDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
1277*cdf0e10cSrcweir         xTempDocShell->DoInitNew( 0 );
1278*cdf0e10cSrcweir         SfxViewFrame* pTempFrame = SfxViewFrame::LoadHiddenDocument( *xTempDocShell, 0 );
1279*cdf0e10cSrcweir //        pTempFrame->GetFrame().Appear();
1280*cdf0e10cSrcweir         SwView* pTempView = static_cast<SwView*>( pTempFrame->GetViewShell() );
1281*cdf0e10cSrcweir         pTargetView->GetWrtShell().StartAction();
1282*cdf0e10cSrcweir         SwgReaderOption aOpt;
1283*cdf0e10cSrcweir         aOpt.SetTxtFmts( sal_True );
1284*cdf0e10cSrcweir         aOpt.SetFrmFmts( sal_True );
1285*cdf0e10cSrcweir         aOpt.SetPageDescs( sal_True );
1286*cdf0e10cSrcweir         aOpt.SetNumRules( sal_True );
1287*cdf0e10cSrcweir         aOpt.SetMerge( sal_False );
1288*cdf0e10cSrcweir         pTempView->GetDocShell()->LoadStylesFromFile(
1289*cdf0e10cSrcweir                 sTargetTempURL, aOpt, sal_True );
1290*cdf0e10cSrcweir         pTargetView->GetWrtShell().PastePages(pTempView->GetWrtShell(),
1291*cdf0e10cSrcweir                 (sal_uInt16)rInfo.nStartPageInTarget, (sal_uInt16)rInfo.nEndPageInTarget );
1292*cdf0e10cSrcweir         pTargetView->GetWrtShell().EndAction();
1293*cdf0e10cSrcweir 
1294*cdf0e10cSrcweir         //then save it
1295*cdf0e10cSrcweir         SfxStringItem aName(SID_FILE_NAME,
1296*cdf0e10cSrcweir                 URIHelper::SmartRel2Abs(
1297*cdf0e10cSrcweir                     INetURLObject(), utl::TempFile::CreateTempName(0),
1298*cdf0e10cSrcweir                     URIHelper::GetMaybeFileHdl()) );
1299*cdf0e10cSrcweir 
1300*cdf0e10cSrcweir /*        if(bIsPDF)
1301*cdf0e10cSrcweir         {
1302*cdf0e10cSrcweir             SfxDispatcher* pSfxDispatcher = pTempView->GetViewFrame()->GetDispatcher();
1303*cdf0e10cSrcweir             pSfxDispatcher->Execute(
1304*cdf0e10cSrcweir                             SID_DIRECTEXPORTDOCASPDF,
1305*cdf0e10cSrcweir                                   SFX_CALLMODE_SYNCHRON, &aName, &aFilterName, 0L );
1306*cdf0e10cSrcweir         }
1307*cdf0e10cSrcweir         else*/
1308*cdf0e10cSrcweir         {
1309*cdf0e10cSrcweir             uno::Sequence< beans::PropertyValue > aFilterValues(MM_DOCTYPE_TEXT == nDocType ? 2 : 1);
1310*cdf0e10cSrcweir             beans::PropertyValue* pFilterValues = aFilterValues.getArray();
1311*cdf0e10cSrcweir             pFilterValues[0].Name = C2U("FilterName");
1312*cdf0e10cSrcweir             pFilterValues[0].Value <<= ::rtl::OUString(pSfxFlt->GetFilterName());
1313*cdf0e10cSrcweir             if(MM_DOCTYPE_TEXT == nDocType)
1314*cdf0e10cSrcweir             {
1315*cdf0e10cSrcweir                 pFilterValues[1].Name = C2U("FilterOptions");
1316*cdf0e10cSrcweir                 pFilterValues[1].Value <<= ::rtl::OUString(sFilterOptions);
1317*cdf0e10cSrcweir             }
1318*cdf0e10cSrcweir 
1319*cdf0e10cSrcweir             uno::Reference< frame::XStorable > xTempStore( pTempView->GetDocShell()->GetModel(), uno::UNO_QUERY);
1320*cdf0e10cSrcweir             xTempStore->storeToURL( aName.GetValue(), aFilterValues );
1321*cdf0e10cSrcweir         }
1322*cdf0e10cSrcweir         xTempDocShell->DoClose();
1323*cdf0e10cSrcweir 
1324*cdf0e10cSrcweir #ifdef DBG_UTIL
1325*cdf0e10cSrcweir         sal_Int32 nTarget =
1326*cdf0e10cSrcweir #endif
1327*cdf0e10cSrcweir                 rConfigItem.MoveResultSet(rInfo.nDBRow);
1328*cdf0e10cSrcweir         DBG_ASSERT( nTarget == rInfo.nDBRow, "row of current document could not be selected");
1329*cdf0e10cSrcweir         DBG_ASSERT( sEMailColumn.Len(), "No email column selected");
1330*cdf0e10cSrcweir         ::rtl::OUString sEMail = lcl_GetColumnValueOf(sEMailColumn, xColAccess);
1331*cdf0e10cSrcweir         SwMailDescriptor aDesc;
1332*cdf0e10cSrcweir         aDesc.sEMail = sEMail;
1333*cdf0e10cSrcweir         rtl::OUString sBody;
1334*cdf0e10cSrcweir         if(bAsBody)
1335*cdf0e10cSrcweir         {
1336*cdf0e10cSrcweir             {
1337*cdf0e10cSrcweir                 //read in the temporary file and use it as mail body
1338*cdf0e10cSrcweir                 SfxMedium aMedium( aName.GetValue(),    STREAM_READ, sal_True);
1339*cdf0e10cSrcweir                 SvStream* pInStream = aMedium.GetInStream();
1340*cdf0e10cSrcweir                 if(pInStream)
1341*cdf0e10cSrcweir                     pInStream->SetStreamCharSet( eEncoding );
1342*cdf0e10cSrcweir                 else
1343*cdf0e10cSrcweir                 {
1344*cdf0e10cSrcweir                     DBG_ERROR("no output file created?");
1345*cdf0e10cSrcweir                     continue;
1346*cdf0e10cSrcweir                 }
1347*cdf0e10cSrcweir                 ByteString sLine;
1348*cdf0e10cSrcweir                 sal_Bool bDone = pInStream->ReadLine( sLine );
1349*cdf0e10cSrcweir                 while ( bDone )
1350*cdf0e10cSrcweir                 {
1351*cdf0e10cSrcweir                     sBody += rtl::OUString(String(sLine, eEncoding));
1352*cdf0e10cSrcweir                     sBody += rtl::OUString('\n');
1353*cdf0e10cSrcweir                     bDone = pInStream->ReadLine( sLine );
1354*cdf0e10cSrcweir                 }
1355*cdf0e10cSrcweir             }
1356*cdf0e10cSrcweir             //remove the temporary file
1357*cdf0e10cSrcweir             SWUnoHelper::UCB_DeleteFile( aName.GetValue() );
1358*cdf0e10cSrcweir         }
1359*cdf0e10cSrcweir         else
1360*cdf0e10cSrcweir         {
1361*cdf0e10cSrcweir             sBody = m_sBody;
1362*cdf0e10cSrcweir             aDesc.sAttachmentURL = aName.GetValue();
1363*cdf0e10cSrcweir             String sAttachment(m_aAttachmentED.GetText());
1364*cdf0e10cSrcweir             xub_StrLen nTokenCount = sAttachment.GetTokenCount( '.' );
1365*cdf0e10cSrcweir             if( 2 > nTokenCount)
1366*cdf0e10cSrcweir             {
1367*cdf0e10cSrcweir                 sAttachment += '.';
1368*cdf0e10cSrcweir                 sAttachment.SetToken( nTokenCount, '.', sExtension);
1369*cdf0e10cSrcweir             }
1370*cdf0e10cSrcweir             else if(sAttachment.GetToken( nTokenCount - 1, '.') != sExtension)
1371*cdf0e10cSrcweir                 sAttachment += sExtension;
1372*cdf0e10cSrcweir             aDesc.sAttachmentName = sAttachment;
1373*cdf0e10cSrcweir             aDesc.sMimeType = sMimeType;
1374*cdf0e10cSrcweir 
1375*cdf0e10cSrcweir             if(rConfigItem.IsGreetingLine(sal_True))
1376*cdf0e10cSrcweir             {
1377*cdf0e10cSrcweir                 ::rtl::OUString sNameColumn = rConfigItem.GetAssignedColumn(MM_PART_LASTNAME);
1378*cdf0e10cSrcweir                 ::rtl::OUString sName = lcl_GetColumnValueOf(sNameColumn, xColAccess);
1379*cdf0e10cSrcweir                 String sGreeting;
1380*cdf0e10cSrcweir                 if(sName.getLength() && rConfigItem.IsIndividualGreeting(sal_True))
1381*cdf0e10cSrcweir                 {
1382*cdf0e10cSrcweir                     ::rtl::OUString sGenderColumn = rConfigItem.GetAssignedColumn(MM_PART_GENDER);
1383*cdf0e10cSrcweir                     const ::rtl::OUString& sFemaleValue = rConfigItem.GetFemaleGenderValue();
1384*cdf0e10cSrcweir                     ::rtl::OUString sGenderValue = lcl_GetColumnValueOf(sGenderColumn, xColAccess);
1385*cdf0e10cSrcweir                     SwMailMergeConfigItem::Gender eGenderType = sGenderValue == sFemaleValue ?
1386*cdf0e10cSrcweir                         SwMailMergeConfigItem::FEMALE :
1387*cdf0e10cSrcweir                         SwMailMergeConfigItem::MALE;
1388*cdf0e10cSrcweir 
1389*cdf0e10cSrcweir                     sGreeting = SwAddressPreview::FillData(
1390*cdf0e10cSrcweir                         rConfigItem.GetGreetings(eGenderType)
1391*cdf0e10cSrcweir                         [rConfigItem.GetCurrentGreeting(eGenderType)],
1392*cdf0e10cSrcweir                             rConfigItem);
1393*cdf0e10cSrcweir                 }
1394*cdf0e10cSrcweir                 else
1395*cdf0e10cSrcweir                 {
1396*cdf0e10cSrcweir                     sGreeting =
1397*cdf0e10cSrcweir                         rConfigItem.GetGreetings(SwMailMergeConfigItem::NEUTRAL)
1398*cdf0e10cSrcweir                         [rConfigItem.GetCurrentGreeting(SwMailMergeConfigItem::NEUTRAL)];
1399*cdf0e10cSrcweir 
1400*cdf0e10cSrcweir                 }
1401*cdf0e10cSrcweir                 sGreeting += '\n';
1402*cdf0e10cSrcweir                 ::rtl::OUString sTemp( sGreeting );
1403*cdf0e10cSrcweir                 sTemp += sBody;
1404*cdf0e10cSrcweir                 sBody = sTemp;
1405*cdf0e10cSrcweir             }
1406*cdf0e10cSrcweir         }
1407*cdf0e10cSrcweir         aDesc.sBodyContent = sBody;
1408*cdf0e10cSrcweir         if(MM_DOCTYPE_HTML == nDocType)
1409*cdf0e10cSrcweir         {
1410*cdf0e10cSrcweir             aDesc.sBodyMimeType = ::rtl::OUString::createFromAscii("text/html; charset=");
1411*cdf0e10cSrcweir             aDesc.sBodyMimeType += ::rtl::OUString::createFromAscii(
1412*cdf0e10cSrcweir                                 rtl_getBestMimeCharsetFromTextEncoding( eEncoding ));
1413*cdf0e10cSrcweir         }
1414*cdf0e10cSrcweir         else
1415*cdf0e10cSrcweir             aDesc.sBodyMimeType =
1416*cdf0e10cSrcweir                 ::rtl::OUString::createFromAscii("text/plain; charset=UTF-8; format=flowed");
1417*cdf0e10cSrcweir 
1418*cdf0e10cSrcweir         aDesc.sSubject = m_aSubjectED.GetText();
1419*cdf0e10cSrcweir         aDesc.sCC = m_sCC;
1420*cdf0e10cSrcweir         aDesc.sBCC = m_sBCC;
1421*cdf0e10cSrcweir         pDlg->AddDocument( aDesc );
1422*cdf0e10cSrcweir         //help to force painting the dialog
1423*cdf0e10cSrcweir         for ( sal_Int16 i = 0; i < 25; i++)
1424*cdf0e10cSrcweir             Application::Reschedule();
1425*cdf0e10cSrcweir         //stop creating of data when dialog has been closed
1426*cdf0e10cSrcweir         if(!pDlg->IsVisible())
1427*cdf0e10cSrcweir         {
1428*cdf0e10cSrcweir             m_pWizard->LeaveWait();
1429*cdf0e10cSrcweir             break;
1430*cdf0e10cSrcweir         }
1431*cdf0e10cSrcweir         m_pWizard->LeaveWait();
1432*cdf0e10cSrcweir     }
1433*cdf0e10cSrcweir     pDlg->EnableDesctruction();
1434*cdf0e10cSrcweir     ::osl::File::remove( sTargetTempURL );
1435*cdf0e10cSrcweir 
1436*cdf0e10cSrcweir     m_pWizard->enableButtons(WZB_FINISH, sal_True);
1437*cdf0e10cSrcweir     //the dialog deletes itself
1438*cdf0e10cSrcweir     //delete pDlg;
1439*cdf0e10cSrcweir     return 0;
1440*cdf0e10cSrcweir }
1441