xref: /AOO41X/main/sw/source/ui/dbui/mmgreetingspage.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 
31*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
32*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir #include <mmgreetingspage.hxx>
35*cdf0e10cSrcweir #include <mailmergewizard.hxx>
36*cdf0e10cSrcweir #include <mmconfigitem.hxx>
37*cdf0e10cSrcweir #include <mmaddressblockpage.hxx>
38*cdf0e10cSrcweir #include <swtypes.hxx>
39*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
40*cdf0e10cSrcweir #include <mmgreetingspage.hrc>
41*cdf0e10cSrcweir #include <dbui.hrc>
42*cdf0e10cSrcweir #include <com/sun/star/sdb/XColumn.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
45*cdf0e10cSrcweir #include <helpid.h>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir using namespace svt;
48*cdf0e10cSrcweir using namespace ::com::sun::star;
49*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
50*cdf0e10cSrcweir // -----------------------------------------------------------------------
51*cdf0e10cSrcweir void lcl_FillGreetingsBox(ListBox& rBox,
52*cdf0e10cSrcweir                         SwMailMergeConfigItem& rConfig,
53*cdf0e10cSrcweir                         SwMailMergeConfigItem::Gender eType)
54*cdf0e10cSrcweir {
55*cdf0e10cSrcweir     const Sequence< ::rtl::OUString> rEntries = rConfig.GetGreetings(eType);
56*cdf0e10cSrcweir     for(sal_Int32 nEntry = 0; nEntry < rEntries.getLength(); ++nEntry)
57*cdf0e10cSrcweir         rBox.InsertEntry(rEntries[nEntry]);
58*cdf0e10cSrcweir     rBox.SelectEntryPos((sal_uInt16)rConfig.GetCurrentGreeting(eType));
59*cdf0e10cSrcweir }
60*cdf0e10cSrcweir // -----------------------------------------------------------------------
61*cdf0e10cSrcweir void lcl_FillGreetingsBox(ComboBox& rBox,
62*cdf0e10cSrcweir                         SwMailMergeConfigItem& rConfig,
63*cdf0e10cSrcweir                         SwMailMergeConfigItem::Gender eType)
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir     const Sequence< ::rtl::OUString> rEntries = rConfig.GetGreetings(eType);
66*cdf0e10cSrcweir     for(sal_Int32 nEntry = 0; nEntry < rEntries.getLength(); ++nEntry)
67*cdf0e10cSrcweir         rBox.InsertEntry(rEntries[nEntry]);
68*cdf0e10cSrcweir     rBox.SelectEntryPos((sal_uInt16)rConfig.GetCurrentGreeting(eType));
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir // -----------------------------------------------------------------------
71*cdf0e10cSrcweir void lcl_StoreGreetingsBox(ListBox& rBox,
72*cdf0e10cSrcweir                         SwMailMergeConfigItem& rConfig,
73*cdf0e10cSrcweir                         SwMailMergeConfigItem::Gender eType)
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir     Sequence< ::rtl::OUString> aEntries(rBox.GetEntryCount());
76*cdf0e10cSrcweir     ::rtl::OUString* pEntries = aEntries.getArray();
77*cdf0e10cSrcweir     for(sal_uInt16 nEntry = 0; nEntry < rBox.GetEntryCount(); ++nEntry)
78*cdf0e10cSrcweir         pEntries[nEntry] = rBox.GetEntry(nEntry);
79*cdf0e10cSrcweir     rConfig.SetGreetings(eType, aEntries);
80*cdf0e10cSrcweir     rConfig.SetCurrentGreeting(eType, rBox.GetSelectEntryPos());
81*cdf0e10cSrcweir }
82*cdf0e10cSrcweir // -----------------------------------------------------------------------
83*cdf0e10cSrcweir void lcl_StoreGreetingsBox(ComboBox& rBox,
84*cdf0e10cSrcweir                         SwMailMergeConfigItem& rConfig,
85*cdf0e10cSrcweir                         SwMailMergeConfigItem::Gender eType)
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir     Sequence< ::rtl::OUString> aEntries(rBox.GetEntryCount());
88*cdf0e10cSrcweir     ::rtl::OUString* pEntries = aEntries.getArray();
89*cdf0e10cSrcweir     for(sal_uInt16 nEntry = 0; nEntry < rBox.GetEntryCount(); ++nEntry)
90*cdf0e10cSrcweir         pEntries[nEntry] = rBox.GetEntry(nEntry);
91*cdf0e10cSrcweir     rConfig.SetGreetings(eType, aEntries);
92*cdf0e10cSrcweir     rConfig.SetCurrentGreeting(eType, rBox.GetSelectEntryPos());
93*cdf0e10cSrcweir }
94*cdf0e10cSrcweir /*-- 30.04.2004 10:42:57---------------------------------------------------
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
97*cdf0e10cSrcweir IMPL_LINK(SwGreetingsHandler, IndividualHdl_Impl, CheckBox*, EMPTYARG)
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir     sal_Bool bIndividual = m_pPersonalizedCB->IsEnabled() && m_pPersonalizedCB->IsChecked();
100*cdf0e10cSrcweir     m_pFemaleFT->Enable(bIndividual);
101*cdf0e10cSrcweir     m_pFemaleLB->Enable(bIndividual);
102*cdf0e10cSrcweir     m_pFemalePB->Enable(bIndividual);
103*cdf0e10cSrcweir     m_pMaleFT->Enable(bIndividual);
104*cdf0e10cSrcweir     m_pMaleLB->Enable(bIndividual);
105*cdf0e10cSrcweir     m_pMalePB->Enable(bIndividual);
106*cdf0e10cSrcweir     m_pFemaleFI->Enable(bIndividual);
107*cdf0e10cSrcweir     m_pFemaleColumnFT->Enable(bIndividual);
108*cdf0e10cSrcweir     m_pFemaleColumnLB->Enable(bIndividual);
109*cdf0e10cSrcweir     m_pFemaleFieldFT->Enable(bIndividual);
110*cdf0e10cSrcweir     m_pFemaleFieldCB->Enable(bIndividual);
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     if( m_bIsTabPage )
113*cdf0e10cSrcweir     {
114*cdf0e10cSrcweir         m_pWizard->GetConfigItem().SetIndividualGreeting(bIndividual, sal_False);
115*cdf0e10cSrcweir         m_pWizard->UpdateRoadmap();
116*cdf0e10cSrcweir         m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
117*cdf0e10cSrcweir     }
118*cdf0e10cSrcweir     UpdatePreview();
119*cdf0e10cSrcweir     return 0;
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir /*-- 30.04.2004 10:42:57---------------------------------------------------
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
124*cdf0e10cSrcweir IMPL_LINK(SwGreetingsHandler, GreetingHdl_Impl, PushButton*, pButton)
125*cdf0e10cSrcweir {
126*cdf0e10cSrcweir     SwCustomizeAddressBlockDialog* pDlg =
127*cdf0e10cSrcweir             new SwCustomizeAddressBlockDialog(pButton, m_pWizard->GetConfigItem(),
128*cdf0e10cSrcweir                         pButton == m_pMalePB ?
129*cdf0e10cSrcweir                         SwCustomizeAddressBlockDialog::GREETING_MALE :
130*cdf0e10cSrcweir                         SwCustomizeAddressBlockDialog::GREETING_FEMALE );
131*cdf0e10cSrcweir     if(RET_OK == pDlg->Execute())
132*cdf0e10cSrcweir     {
133*cdf0e10cSrcweir         ListBox* pToInsert = pButton == m_pMalePB ? m_pMaleLB : m_pFemaleLB;
134*cdf0e10cSrcweir         pToInsert->SelectEntryPos(pToInsert->InsertEntry(pDlg->GetAddress()));
135*cdf0e10cSrcweir         if(m_bIsTabPage)
136*cdf0e10cSrcweir         {
137*cdf0e10cSrcweir             m_pWizard->UpdateRoadmap();
138*cdf0e10cSrcweir             m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
139*cdf0e10cSrcweir         }
140*cdf0e10cSrcweir         UpdatePreview();
141*cdf0e10cSrcweir     }
142*cdf0e10cSrcweir     delete pDlg;
143*cdf0e10cSrcweir     return 0;
144*cdf0e10cSrcweir }
145*cdf0e10cSrcweir /*-- 16.06.2004 10:56:21---------------------------------------------------
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
148*cdf0e10cSrcweir void    SwGreetingsHandler::UpdatePreview()
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir     //the base class does nothing
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir /*-- 30.04.2004 10:42:59---------------------------------------------------
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
155*cdf0e10cSrcweir IMPL_LINK(SwMailMergeGreetingsPage, AssignHdl_Impl, PushButton*, pButton)
156*cdf0e10cSrcweir {
157*cdf0e10cSrcweir     String sPreview = m_aFemaleLB.GetSelectEntry();
158*cdf0e10cSrcweir     sPreview += '\n';
159*cdf0e10cSrcweir     sPreview += m_aMaleLB.GetSelectEntry();
160*cdf0e10cSrcweir     SwAssignFieldsDialog* pDlg =
161*cdf0e10cSrcweir             new SwAssignFieldsDialog(pButton, m_pWizard->GetConfigItem(), sPreview, false);
162*cdf0e10cSrcweir     if(RET_OK == pDlg->Execute())
163*cdf0e10cSrcweir     {
164*cdf0e10cSrcweir         UpdatePreview();
165*cdf0e10cSrcweir         m_pWizard->UpdateRoadmap();
166*cdf0e10cSrcweir         m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
167*cdf0e10cSrcweir     }
168*cdf0e10cSrcweir     delete pDlg;
169*cdf0e10cSrcweir     return 0;
170*cdf0e10cSrcweir }
171*cdf0e10cSrcweir /*-- 05.05.2004 15:25:56---------------------------------------------------
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
174*cdf0e10cSrcweir IMPL_LINK(SwMailMergeGreetingsPage, GreetingSelectHdl_Impl, ListBox*, EMPTYARG)
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir     UpdatePreview();
177*cdf0e10cSrcweir     return 0;
178*cdf0e10cSrcweir }
179*cdf0e10cSrcweir /*-- 05.05.2004 15:23:43---------------------------------------------------
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
182*cdf0e10cSrcweir void SwMailMergeGreetingsPage::UpdatePreview()
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir     //find out which type of greeting should be selected:
185*cdf0e10cSrcweir     bool bFemale = false;
186*cdf0e10cSrcweir     bool bNoValue = !m_pFemaleColumnLB->IsEnabled();
187*cdf0e10cSrcweir     if( !bNoValue )
188*cdf0e10cSrcweir     {
189*cdf0e10cSrcweir         ::rtl::OUString sFemaleValue = m_aFemaleFieldCB.GetText();
190*cdf0e10cSrcweir         ::rtl::OUString sFemaleColumn = m_aFemaleColumnLB.GetSelectEntry();
191*cdf0e10cSrcweir         Reference< sdbcx::XColumnsSupplier > xColsSupp( m_pWizard->GetConfigItem().GetResultSet(), UNO_QUERY);
192*cdf0e10cSrcweir         Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
193*cdf0e10cSrcweir         if(sFemaleValue.getLength() && sFemaleColumn.getLength() &&
194*cdf0e10cSrcweir                 xColAccess.is() &&
195*cdf0e10cSrcweir                 xColAccess->hasByName(sFemaleColumn))
196*cdf0e10cSrcweir         {
197*cdf0e10cSrcweir             //get the content and exchange it in the address string
198*cdf0e10cSrcweir             Any aCol = xColAccess->getByName(sFemaleColumn);
199*cdf0e10cSrcweir             Reference< sdb::XColumn > xColumn;
200*cdf0e10cSrcweir             aCol >>= xColumn;
201*cdf0e10cSrcweir             if(xColumn.is())
202*cdf0e10cSrcweir             {
203*cdf0e10cSrcweir                 try
204*cdf0e10cSrcweir                 {
205*cdf0e10cSrcweir                     ::rtl::OUString sFemaleColumnValue = xColumn->getString();
206*cdf0e10cSrcweir                     bFemale = sFemaleColumnValue == sFemaleValue;
207*cdf0e10cSrcweir                     //bNoValue = !sFemaleColumnValue.getLength();
208*cdf0e10cSrcweir                     if( !bNoValue )
209*cdf0e10cSrcweir                     {
210*cdf0e10cSrcweir                         //no last name value marks the greeting also als neutral
211*cdf0e10cSrcweir                         SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
212*cdf0e10cSrcweir                         ::rtl::OUString sLastNameColumn = rConfig.GetAssignedColumn(MM_PART_LASTNAME);
213*cdf0e10cSrcweir                         if ( xColAccess->hasByName(sLastNameColumn) )
214*cdf0e10cSrcweir                         {
215*cdf0e10cSrcweir                             aCol = xColAccess->getByName(sLastNameColumn);
216*cdf0e10cSrcweir                             aCol >>= xColumn;
217*cdf0e10cSrcweir                             ::rtl::OUString sLastNameColumnValue = xColumn->getString();
218*cdf0e10cSrcweir                             bNoValue = !sLastNameColumnValue.getLength();
219*cdf0e10cSrcweir                         }
220*cdf0e10cSrcweir                     }
221*cdf0e10cSrcweir                 }
222*cdf0e10cSrcweir                 catch( sdbc::SQLException& )
223*cdf0e10cSrcweir                 {
224*cdf0e10cSrcweir                     DBG_ERROR("SQLException caught");
225*cdf0e10cSrcweir                 }
226*cdf0e10cSrcweir             }
227*cdf0e10cSrcweir         }
228*cdf0e10cSrcweir     }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     String sPreview = bFemale ? m_aFemaleLB.GetSelectEntry() :
231*cdf0e10cSrcweir         bNoValue ? m_aNeutralCB.GetText() : m_aMaleLB.GetSelectEntry();
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir     sPreview = SwAddressPreview::FillData(sPreview, m_pWizard->GetConfigItem());
234*cdf0e10cSrcweir     m_aPreviewWIN.SetAddress(sPreview);
235*cdf0e10cSrcweir }
236*cdf0e10cSrcweir /*-- 17.05.2004 15:44:53---------------------------------------------------
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
239*cdf0e10cSrcweir void    SwGreetingsHandler::Contains(sal_Bool bContainsGreeting)
240*cdf0e10cSrcweir {
241*cdf0e10cSrcweir     m_pPersonalizedCB->Enable(bContainsGreeting);
242*cdf0e10cSrcweir     sal_Bool bEnablePersonal = bContainsGreeting && m_pPersonalizedCB->IsChecked();
243*cdf0e10cSrcweir     m_pFemaleFT->Enable(bEnablePersonal);
244*cdf0e10cSrcweir     m_pFemaleLB->Enable(bEnablePersonal);
245*cdf0e10cSrcweir     m_pFemalePB->Enable(bEnablePersonal);
246*cdf0e10cSrcweir     m_pMaleFT->Enable(bEnablePersonal);
247*cdf0e10cSrcweir     m_pMaleLB->Enable(bEnablePersonal);
248*cdf0e10cSrcweir     m_pMalePB->Enable(bEnablePersonal);
249*cdf0e10cSrcweir     m_pFemaleFI->Enable(bEnablePersonal);
250*cdf0e10cSrcweir     m_pFemaleColumnFT->Enable(bEnablePersonal);
251*cdf0e10cSrcweir     m_pFemaleColumnLB->Enable(bEnablePersonal);
252*cdf0e10cSrcweir     m_pFemaleFieldFT->Enable(bEnablePersonal);
253*cdf0e10cSrcweir     m_pFemaleFieldCB->Enable(bEnablePersonal);
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     m_pNeutralFT->Enable(bContainsGreeting);
256*cdf0e10cSrcweir     m_pNeutralCB->Enable(bContainsGreeting);
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir /*-- 02.04.2004 14:17:52---------------------------------------------------
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
261*cdf0e10cSrcweir SwMailMergeGreetingsPage::SwMailMergeGreetingsPage( SwMailMergeWizard* _pParent) :
262*cdf0e10cSrcweir     svt::OWizardPage(_pParent, SW_RES(DLG_MM_GREETINGS_PAGE)),
263*cdf0e10cSrcweir #ifdef MSC
264*cdf0e10cSrcweir #pragma warning (disable : 4355)
265*cdf0e10cSrcweir #endif
266*cdf0e10cSrcweir     m_aHeaderFI(this, SW_RES(          FI_HEADER     ) ),
267*cdf0e10cSrcweir     m_aGreetingLineCB(this, SW_RES(    CB_GREETINGLINE ) ),
268*cdf0e10cSrcweir     m_aPersonalizedCB(this, SW_RES(      CB_PERSONALIZED ) ),
269*cdf0e10cSrcweir     m_aFemaleFT(this, SW_RES(            FT_FEMALE   ) ),
270*cdf0e10cSrcweir     m_aFemaleLB(this, SW_RES(            LB_FEMALE   ) ),
271*cdf0e10cSrcweir     m_aFemalePB(this, SW_RES(            PB_FEMALE   ) ),
272*cdf0e10cSrcweir     m_aMaleFT(this, SW_RES(              FT_MALE     ) ),
273*cdf0e10cSrcweir     m_aMaleLB(this, SW_RES(              LB_MALE     ) ),
274*cdf0e10cSrcweir     m_aMalePB(this, SW_RES(              PB_MALE     ) ),
275*cdf0e10cSrcweir     m_aFemaleFI(this, SW_RES(            FI_FEMALE      ) ),
276*cdf0e10cSrcweir     m_aFemaleColumnFT(this, SW_RES(      FT_FEMALECOLUMN ) ),
277*cdf0e10cSrcweir     m_aFemaleColumnLB(this, SW_RES(      LB_FEMALECOLUMN ) ),
278*cdf0e10cSrcweir     m_aFemaleFieldFT(this, SW_RES(       FT_FEMALEFIELD  ) ),
279*cdf0e10cSrcweir     m_aFemaleFieldCB(this, SW_RES(       CB_FEMALEFIELD  ) ),
280*cdf0e10cSrcweir     m_aNeutralFT(this, SW_RES(           FT_NEUTRAL      ) ),
281*cdf0e10cSrcweir     m_aNeutralCB(this, SW_RES(         CB_NEUTRAL      ) ),
282*cdf0e10cSrcweir     m_aPreviewFI(       this, SW_RES( FI_PREVIEW     ) ),
283*cdf0e10cSrcweir     m_aPreviewWIN(      this, SW_RES( WIN_PREVIEW    ) ),
284*cdf0e10cSrcweir     m_aAssignPB(        this, SW_RES( PB_ASSIGN      ) ),
285*cdf0e10cSrcweir     m_aDocumentIndexFI( this, SW_RES( FI_DOCINDEX    ) ),
286*cdf0e10cSrcweir     m_aPrevSetIB(       this, SW_RES( IB_PREVSET     ) ),
287*cdf0e10cSrcweir     m_aNextSetIB(       this, SW_RES( IB_NEXTSET     ) ),
288*cdf0e10cSrcweir     m_sDocument(        SW_RES(       STR_DOCUMENT  ) )
289*cdf0e10cSrcweir #ifdef MSC
290*cdf0e10cSrcweir #pragma warning (default : 4355)
291*cdf0e10cSrcweir #endif
292*cdf0e10cSrcweir {
293*cdf0e10cSrcweir     m_pWizard = _pParent;
294*cdf0e10cSrcweir     m_pGreetingLineCB = &m_aGreetingLineCB;
295*cdf0e10cSrcweir     m_pPersonalizedCB = &m_aPersonalizedCB;
296*cdf0e10cSrcweir     m_pFemaleFT = &      m_aFemaleFT;
297*cdf0e10cSrcweir     m_pFemaleLB = &      m_aFemaleLB;
298*cdf0e10cSrcweir     m_pFemalePB = &      m_aFemalePB;
299*cdf0e10cSrcweir     m_pMaleFT = &        m_aMaleFT;
300*cdf0e10cSrcweir     m_pMaleLB = &        m_aMaleLB;
301*cdf0e10cSrcweir     m_pMalePB = &        m_aMalePB;
302*cdf0e10cSrcweir     m_pFemaleFI = &      m_aFemaleFI;
303*cdf0e10cSrcweir     m_pFemaleColumnFT = &m_aFemaleColumnFT;
304*cdf0e10cSrcweir     m_pFemaleColumnLB = &m_aFemaleColumnLB;
305*cdf0e10cSrcweir     m_pFemaleFieldFT = & m_aFemaleFieldFT;
306*cdf0e10cSrcweir     m_pFemaleFieldCB = & m_aFemaleFieldCB;
307*cdf0e10cSrcweir     m_pNeutralFT = &     m_aNeutralFT;
308*cdf0e10cSrcweir     m_pNeutralCB    = &m_aNeutralCB;
309*cdf0e10cSrcweir     m_bIsTabPage = true;
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir     m_pPersonalizedCB->SetHelpId(   HID_MM_GREETINGS_CB_PERSONALIZED);
312*cdf0e10cSrcweir     m_pFemaleLB->SetHelpId(         HID_MM_GREETINGS_LB_FEMALE      );
313*cdf0e10cSrcweir     m_pFemalePB->SetHelpId(         HID_MM_GREETINGS_PB_FEMALE      );
314*cdf0e10cSrcweir     m_pMaleLB->SetHelpId(           HID_MM_GREETINGS_LB_MALE        );
315*cdf0e10cSrcweir     m_pMalePB->SetHelpId(           HID_MM_GREETINGS_PB_MALE        );
316*cdf0e10cSrcweir     m_pFemaleColumnLB->SetHelpId(   HID_MM_GREETINGS_LB_FEMALECOLUMN);
317*cdf0e10cSrcweir     m_pFemaleFieldCB->SetHelpId(    HID_MM_GREETINGS_CB_FEMALEFIELD );
318*cdf0e10cSrcweir     m_pNeutralCB->SetHelpId(        HID_MM_GREETINGS_CB_NEUTRAL     );
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir     FreeResource();
321*cdf0e10cSrcweir     m_aGreetingLineCB.SetClickHdl(LINK(this, SwMailMergeGreetingsPage, ContainsHdl_Impl));
322*cdf0e10cSrcweir     Link aIndividualLink = LINK(this, SwGreetingsHandler, IndividualHdl_Impl);
323*cdf0e10cSrcweir     m_aPersonalizedCB.SetClickHdl(aIndividualLink);
324*cdf0e10cSrcweir     Link aGreetingLink = LINK(this, SwGreetingsHandler, GreetingHdl_Impl);
325*cdf0e10cSrcweir     m_aFemalePB.SetClickHdl(aGreetingLink);
326*cdf0e10cSrcweir     m_aMalePB.SetClickHdl(aGreetingLink);
327*cdf0e10cSrcweir     m_aAssignPB.SetClickHdl(LINK(this, SwMailMergeGreetingsPage, AssignHdl_Impl));
328*cdf0e10cSrcweir     Link aLBoxLink = LINK(this, SwMailMergeGreetingsPage, GreetingSelectHdl_Impl);
329*cdf0e10cSrcweir     m_aFemaleLB.SetSelectHdl(aLBoxLink);
330*cdf0e10cSrcweir     m_aMaleLB.SetSelectHdl(aLBoxLink);
331*cdf0e10cSrcweir     m_aFemaleColumnLB.SetSelectHdl(aLBoxLink);
332*cdf0e10cSrcweir     m_aFemaleFieldCB.SetSelectHdl(aLBoxLink);
333*cdf0e10cSrcweir     m_aFemaleFieldCB.SetModifyHdl(aLBoxLink);
334*cdf0e10cSrcweir     m_aNeutralCB.SetSelectHdl(aLBoxLink);
335*cdf0e10cSrcweir     m_aNeutralCB.SetModifyHdl(aLBoxLink);
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir     Link aDataLink = LINK(this, SwMailMergeGreetingsPage, InsertDataHdl_Impl);
338*cdf0e10cSrcweir     m_aPrevSetIB.SetClickHdl(aDataLink);
339*cdf0e10cSrcweir     m_aNextSetIB.SetClickHdl(aDataLink);
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
343*cdf0e10cSrcweir     m_aGreetingLineCB.Check(rConfig.IsGreetingLine(sal_False));
344*cdf0e10cSrcweir     m_aPersonalizedCB.Check(rConfig.IsIndividualGreeting(sal_False));
345*cdf0e10cSrcweir     ContainsHdl_Impl(&m_aGreetingLineCB);
346*cdf0e10cSrcweir     aIndividualLink.Call(0);
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir     lcl_FillGreetingsBox(m_aFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
349*cdf0e10cSrcweir     lcl_FillGreetingsBox(m_aMaleLB, rConfig, SwMailMergeConfigItem::MALE);
350*cdf0e10cSrcweir     lcl_FillGreetingsBox(m_aNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir     String sTemp(m_sDocument);
353*cdf0e10cSrcweir     sTemp.SearchAndReplaceAscii("%1", String::CreateFromInt32(1));
354*cdf0e10cSrcweir     m_aDocumentIndexFI.SetText(sTemp);
355*cdf0e10cSrcweir }
356*cdf0e10cSrcweir /*-- 02.04.2004 14:17:52---------------------------------------------------
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
359*cdf0e10cSrcweir SwMailMergeGreetingsPage::~SwMailMergeGreetingsPage()
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir }
362*cdf0e10cSrcweir /*-- 18.06.2004 12:13:53---------------------------------------------------
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
365*cdf0e10cSrcweir void SwMailMergeGreetingsPage::ActivatePage()
366*cdf0e10cSrcweir {
367*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir     //try to find the gender setting
370*cdf0e10cSrcweir     m_aFemaleColumnLB.Clear();
371*cdf0e10cSrcweir     Reference< sdbcx::XColumnsSupplier > xColsSupp = rConfig.GetColumnsSupplier();
372*cdf0e10cSrcweir     if(xColsSupp.is())
373*cdf0e10cSrcweir     {
374*cdf0e10cSrcweir         Reference < container::XNameAccess> xColAccess = xColsSupp->getColumns();
375*cdf0e10cSrcweir         Sequence< ::rtl::OUString > aColumns = xColAccess->getElementNames();
376*cdf0e10cSrcweir         for(sal_Int32 nName = 0; nName < aColumns.getLength(); ++nName)
377*cdf0e10cSrcweir             m_aFemaleColumnLB.InsertEntry(aColumns[nName]);
378*cdf0e10cSrcweir     }
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir     ::rtl::OUString sGenderColumn = rConfig.GetAssignedColumn(MM_PART_GENDER);
381*cdf0e10cSrcweir     m_aFemaleColumnLB.SelectEntry(sGenderColumn);
382*cdf0e10cSrcweir     m_aFemaleColumnLB.SaveValue();
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir     m_aFemaleFieldCB.SetText(rConfig.GetFemaleGenderValue());
385*cdf0e10cSrcweir     m_aFemaleFieldCB.SaveValue();
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir     UpdatePreview();
388*cdf0e10cSrcweir     m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
389*cdf0e10cSrcweir }
390*cdf0e10cSrcweir /*-- 11.05.2004 14:47:10---------------------------------------------------
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
393*cdf0e10cSrcweir sal_Bool    SwMailMergeGreetingsPage::commitPage( ::svt::WizardTypes::CommitPageReason )
394*cdf0e10cSrcweir {
395*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir     if(m_aFemaleColumnLB.GetSelectEntryPos() != m_aFemaleColumnLB.GetSavedValue())
398*cdf0e10cSrcweir     {
399*cdf0e10cSrcweir         const SwDBData& rDBData = rConfig.GetCurrentDBData();
400*cdf0e10cSrcweir         Sequence< ::rtl::OUString> aAssignment = rConfig.GetColumnAssignment( rDBData );
401*cdf0e10cSrcweir         if(aAssignment.getLength() <= MM_PART_GENDER)
402*cdf0e10cSrcweir             aAssignment.realloc(MM_PART_GENDER + 1);
403*cdf0e10cSrcweir         aAssignment[MM_PART_GENDER] = m_aFemaleColumnLB.GetSelectEntry();
404*cdf0e10cSrcweir         rConfig.SetColumnAssignment( rDBData, aAssignment );
405*cdf0e10cSrcweir     }
406*cdf0e10cSrcweir     if(m_aFemaleFieldCB.GetText() != m_aFemaleFieldCB.GetSavedValue())
407*cdf0e10cSrcweir         rConfig.SetFemaleGenderValue(m_aFemaleFieldCB.GetText());
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir     lcl_StoreGreetingsBox(m_aFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
410*cdf0e10cSrcweir     lcl_StoreGreetingsBox(m_aMaleLB, rConfig, SwMailMergeConfigItem::MALE);
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir     sal_uInt16 nCurrentTextPos = m_aNeutralCB.GetEntryPos( m_aNeutralCB.GetText() );
413*cdf0e10cSrcweir     if(LISTBOX_ENTRY_NOTFOUND == nCurrentTextPos)
414*cdf0e10cSrcweir     {
415*cdf0e10cSrcweir         sal_uInt16 nCount = m_aNeutralCB.GetEntryCount();
416*cdf0e10cSrcweir         m_aNeutralCB.InsertEntry( m_aNeutralCB.GetText(), nCount );
417*cdf0e10cSrcweir         m_aNeutralCB.SelectEntryPos(nCount);
418*cdf0e10cSrcweir     }
419*cdf0e10cSrcweir     lcl_StoreGreetingsBox(m_aNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
420*cdf0e10cSrcweir     rConfig.SetGreetingLine(m_aGreetingLineCB.IsChecked(), sal_False);
421*cdf0e10cSrcweir     rConfig.SetIndividualGreeting(m_aPersonalizedCB.IsChecked(), sal_False);
422*cdf0e10cSrcweir     return sal_True;
423*cdf0e10cSrcweir }
424*cdf0e10cSrcweir /*-- 30.04.2004 10:42:57---------------------------------------------------
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
427*cdf0e10cSrcweir IMPL_LINK(SwMailMergeGreetingsPage, ContainsHdl_Impl, CheckBox*, pBox)
428*cdf0e10cSrcweir {
429*cdf0e10cSrcweir     sal_Bool bContainsGreeting = pBox->IsChecked();
430*cdf0e10cSrcweir     SwGreetingsHandler::Contains(bContainsGreeting);
431*cdf0e10cSrcweir     m_aPreviewFI. Enable(bContainsGreeting);
432*cdf0e10cSrcweir     m_aPreviewWIN.Enable(bContainsGreeting);
433*cdf0e10cSrcweir     m_aAssignPB.  Enable(bContainsGreeting);
434*cdf0e10cSrcweir     m_aDocumentIndexFI.  Enable(bContainsGreeting);
435*cdf0e10cSrcweir     m_aPrevSetIB.Enable(bContainsGreeting);
436*cdf0e10cSrcweir     m_aNextSetIB.Enable(bContainsGreeting);
437*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
438*cdf0e10cSrcweir     rConfig.SetGreetingLine(m_aGreetingLineCB.IsChecked(), sal_False);
439*cdf0e10cSrcweir     m_pWizard->UpdateRoadmap();
440*cdf0e10cSrcweir     return 0;
441*cdf0e10cSrcweir }
442*cdf0e10cSrcweir /*-- 07.05.2004 12:56:42---------------------------------------------------
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
445*cdf0e10cSrcweir IMPL_LINK(SwMailMergeGreetingsPage, InsertDataHdl_Impl, ImageButton*, pButton)
446*cdf0e10cSrcweir {
447*cdf0e10cSrcweir     //if no pButton is given, the first set has to be pre-set
448*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
449*cdf0e10cSrcweir     if(!pButton)
450*cdf0e10cSrcweir     {
451*cdf0e10cSrcweir         rConfig.GetResultSet();
452*cdf0e10cSrcweir     }
453*cdf0e10cSrcweir     else
454*cdf0e10cSrcweir     {
455*cdf0e10cSrcweir         sal_Bool bNext = pButton == &m_aNextSetIB;
456*cdf0e10cSrcweir         sal_Int32 nPos = rConfig.GetResultSetPosition();
457*cdf0e10cSrcweir         rConfig.MoveResultSet( bNext ? ++nPos : --nPos);
458*cdf0e10cSrcweir     }
459*cdf0e10cSrcweir     sal_Int32 nPos = rConfig.GetResultSetPosition();
460*cdf0e10cSrcweir     sal_Bool bEnable = sal_True;
461*cdf0e10cSrcweir     if(nPos < 1)
462*cdf0e10cSrcweir     {
463*cdf0e10cSrcweir         bEnable = sal_False;
464*cdf0e10cSrcweir         nPos = 1;
465*cdf0e10cSrcweir     }
466*cdf0e10cSrcweir     else
467*cdf0e10cSrcweir         UpdatePreview();
468*cdf0e10cSrcweir     m_aPrevSetIB.Enable(bEnable);
469*cdf0e10cSrcweir     m_aNextSetIB.Enable(bEnable);
470*cdf0e10cSrcweir     m_aDocumentIndexFI.Enable(bEnable);
471*cdf0e10cSrcweir     String sTemp(m_sDocument);
472*cdf0e10cSrcweir     sTemp.SearchAndReplaceAscii("%1", String::CreateFromInt32(nPos));
473*cdf0e10cSrcweir     m_aDocumentIndexFI.SetText(sTemp);
474*cdf0e10cSrcweir     return 0;
475*cdf0e10cSrcweir }
476*cdf0e10cSrcweir /*-- 17.05.2004 15:11:19---------------------------------------------------
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
479*cdf0e10cSrcweir SwMailBodyDialog::SwMailBodyDialog(Window* pParent, SwMailMergeWizard* _pWizard) :
480*cdf0e10cSrcweir     SfxModalDialog(pParent, SW_RES(DLG_MM_MAILBODY)),
481*cdf0e10cSrcweir #ifdef MSC
482*cdf0e10cSrcweir #pragma warning (disable : 4355)
483*cdf0e10cSrcweir #endif
484*cdf0e10cSrcweir     m_aGreetingLineCB(this, SW_RES(    CB_GREETINGLINE ) ),
485*cdf0e10cSrcweir     m_aPersonalizedCB(this, SW_RES(      CB_PERSONALIZED ) ),
486*cdf0e10cSrcweir     m_aFemaleFT(this, SW_RES(            FT_FEMALE   ) ),
487*cdf0e10cSrcweir     m_aFemaleLB(this, SW_RES(            LB_FEMALE   ) ),
488*cdf0e10cSrcweir     m_aFemalePB(this, SW_RES(            PB_FEMALE   ) ),
489*cdf0e10cSrcweir     m_aMaleFT(this, SW_RES(              FT_MALE     ) ),
490*cdf0e10cSrcweir     m_aMaleLB(this, SW_RES(              LB_MALE     ) ),
491*cdf0e10cSrcweir     m_aMalePB(this, SW_RES(              PB_MALE     ) ),
492*cdf0e10cSrcweir     m_aFemaleFI(this, SW_RES(            FI_FEMALE      ) ),
493*cdf0e10cSrcweir     m_aFemaleColumnFT(this, SW_RES(      FT_FEMALECOLUMN ) ),
494*cdf0e10cSrcweir     m_aFemaleColumnLB(this, SW_RES(      LB_FEMALECOLUMN ) ),
495*cdf0e10cSrcweir     m_aFemaleFieldFT(this, SW_RES(       FT_FEMALEFIELD  ) ),
496*cdf0e10cSrcweir     m_aFemaleFieldCB(this, SW_RES(       CB_FEMALEFIELD  ) ),
497*cdf0e10cSrcweir     m_aNeutralFT(this, SW_RES(           FT_NEUTRAL      ) ),
498*cdf0e10cSrcweir     m_aNeutralCB(this, SW_RES(         CB_NEUTRAL      ) ),
499*cdf0e10cSrcweir     m_aBodyFT(   this, SW_RES(         FT_BODY         ) ),
500*cdf0e10cSrcweir     m_aBodyMLE(   this, SW_RES(        MLE_BODY        ) ),
501*cdf0e10cSrcweir     m_aSeparatorFL(   this, SW_RES(    FL_SEPARATOR    ) ),
502*cdf0e10cSrcweir     m_aOK(   this, SW_RES(             PB_OK           ) ),
503*cdf0e10cSrcweir     m_aCancel(   this, SW_RES(         PB_CANCEL       ) ),
504*cdf0e10cSrcweir     m_aHelp(   this, SW_RES(           PB_HELP         ) )
505*cdf0e10cSrcweir #ifdef MSC
506*cdf0e10cSrcweir #pragma warning (default : 4355)
507*cdf0e10cSrcweir #endif
508*cdf0e10cSrcweir {
509*cdf0e10cSrcweir     m_pWizard = _pWizard;
510*cdf0e10cSrcweir     m_pGreetingLineCB = &m_aGreetingLineCB;
511*cdf0e10cSrcweir     m_pPersonalizedCB = &m_aPersonalizedCB;
512*cdf0e10cSrcweir     m_pFemaleFT = &      m_aFemaleFT;
513*cdf0e10cSrcweir     m_pFemaleLB = &      m_aFemaleLB;
514*cdf0e10cSrcweir     m_pFemalePB = &      m_aFemalePB;
515*cdf0e10cSrcweir     m_pMaleFT = &        m_aMaleFT;
516*cdf0e10cSrcweir     m_pMaleLB = &        m_aMaleLB;
517*cdf0e10cSrcweir     m_pMalePB = &        m_aMalePB;
518*cdf0e10cSrcweir     m_pFemaleFI = &      m_aFemaleFI;
519*cdf0e10cSrcweir     m_pFemaleColumnFT = &m_aFemaleColumnFT;
520*cdf0e10cSrcweir     m_pFemaleColumnLB = &m_aFemaleColumnLB;
521*cdf0e10cSrcweir     m_pFemaleFieldFT = & m_aFemaleFieldFT;
522*cdf0e10cSrcweir     m_pFemaleFieldCB = & m_aFemaleFieldCB;
523*cdf0e10cSrcweir     m_pNeutralFT = &     m_aNeutralFT;
524*cdf0e10cSrcweir     m_pNeutralCB    = &m_aNeutralCB;
525*cdf0e10cSrcweir     m_bIsTabPage = false;
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir     m_pPersonalizedCB->SetHelpId(   HID_MM_BODY_CB_PERSONALIZED     );
528*cdf0e10cSrcweir     m_pFemaleLB->SetHelpId(         HID_MM_BODY_LB_FEMALE           );
529*cdf0e10cSrcweir     m_pFemalePB->SetHelpId(         HID_MM_BODY_PB_FEMALE           );
530*cdf0e10cSrcweir     m_pMaleLB->SetHelpId(           HID_MM_BODY_LB_MALE             );
531*cdf0e10cSrcweir     m_pMalePB->SetHelpId(           HID_MM_BODY_PB_MALE             );
532*cdf0e10cSrcweir     m_pFemaleColumnLB->SetHelpId(   HID_MM_BODY_LB_FEMALECOLUMN     );
533*cdf0e10cSrcweir     m_pFemaleFieldCB->SetHelpId(    HID_MM_BODY_CB_FEMALEFIELD      );
534*cdf0e10cSrcweir     m_pNeutralCB->SetHelpId(        HID_MM_BODY_CB_NEUTRAL          );
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir     FreeResource();
537*cdf0e10cSrcweir     m_aGreetingLineCB.SetClickHdl(LINK(this, SwMailBodyDialog, ContainsHdl_Impl));
538*cdf0e10cSrcweir     Link aIndividualLink = LINK(this, SwGreetingsHandler, IndividualHdl_Impl);
539*cdf0e10cSrcweir     m_aPersonalizedCB.SetClickHdl(aIndividualLink);
540*cdf0e10cSrcweir     Link aGreetingLink = LINK(this, SwGreetingsHandler, GreetingHdl_Impl);
541*cdf0e10cSrcweir     m_aFemalePB.SetClickHdl(aGreetingLink);
542*cdf0e10cSrcweir     m_aMalePB.SetClickHdl(aGreetingLink);
543*cdf0e10cSrcweir     m_aOK.SetClickHdl(LINK(this, SwMailBodyDialog, OKHdl));
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
546*cdf0e10cSrcweir     m_aGreetingLineCB.Check(rConfig.IsGreetingLine(sal_True));
547*cdf0e10cSrcweir     m_aPersonalizedCB.Check(rConfig.IsIndividualGreeting(sal_True));
548*cdf0e10cSrcweir     ContainsHdl_Impl(&m_aGreetingLineCB);
549*cdf0e10cSrcweir     aIndividualLink.Call(0);
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir     lcl_FillGreetingsBox(m_aFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
552*cdf0e10cSrcweir     lcl_FillGreetingsBox(m_aMaleLB, rConfig, SwMailMergeConfigItem::MALE);
553*cdf0e10cSrcweir     lcl_FillGreetingsBox(m_aNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir     //try to find the gender setting
556*cdf0e10cSrcweir     m_aFemaleColumnLB.Clear();
557*cdf0e10cSrcweir     Reference< sdbcx::XColumnsSupplier > xColsSupp = rConfig.GetColumnsSupplier();
558*cdf0e10cSrcweir     if(xColsSupp.is())
559*cdf0e10cSrcweir     {
560*cdf0e10cSrcweir         Reference < container::XNameAccess> xColAccess = xColsSupp->getColumns();
561*cdf0e10cSrcweir         Sequence< ::rtl::OUString > aColumns = xColAccess->getElementNames();
562*cdf0e10cSrcweir         for(sal_Int32 nName = 0; nName < aColumns.getLength(); ++nName)
563*cdf0e10cSrcweir             m_aFemaleColumnLB.InsertEntry(aColumns[nName]);
564*cdf0e10cSrcweir     }
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir     ::rtl::OUString sGenderColumn = rConfig.GetAssignedColumn(MM_PART_GENDER);
567*cdf0e10cSrcweir     m_aFemaleColumnLB.SelectEntry(sGenderColumn);
568*cdf0e10cSrcweir     m_aFemaleColumnLB.SaveValue();
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir     m_aFemaleFieldCB.SetText(rConfig.GetFemaleGenderValue());
571*cdf0e10cSrcweir     m_aFemaleFieldCB.SaveValue();
572*cdf0e10cSrcweir }
573*cdf0e10cSrcweir /*-- 17.05.2004 15:13:07---------------------------------------------------
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
576*cdf0e10cSrcweir SwMailBodyDialog::~SwMailBodyDialog()
577*cdf0e10cSrcweir {
578*cdf0e10cSrcweir }
579*cdf0e10cSrcweir 
580*cdf0e10cSrcweir /*-- 30.04.2004 10:42:57---------------------------------------------------
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
583*cdf0e10cSrcweir IMPL_LINK(SwMailBodyDialog, ContainsHdl_Impl, CheckBox*, pBox)
584*cdf0e10cSrcweir {
585*cdf0e10cSrcweir     SwGreetingsHandler::Contains(pBox->IsChecked());
586*cdf0e10cSrcweir     m_pWizard->GetConfigItem().SetGreetingLine(pBox->IsChecked(), sal_True);
587*cdf0e10cSrcweir     return 0;
588*cdf0e10cSrcweir }
589*cdf0e10cSrcweir /*-- 28.06.2004 11:22:42---------------------------------------------------
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
592*cdf0e10cSrcweir IMPL_LINK(SwMailBodyDialog, OKHdl, PushButton*, EMPTYARG)
593*cdf0e10cSrcweir {
594*cdf0e10cSrcweir     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
595*cdf0e10cSrcweir     rConfigItem.SetGreetingLine(
596*cdf0e10cSrcweir                 m_aGreetingLineCB.IsChecked(), sal_False);
597*cdf0e10cSrcweir     rConfigItem.SetIndividualGreeting(
598*cdf0e10cSrcweir                 m_aPersonalizedCB.IsChecked(), sal_False);
599*cdf0e10cSrcweir 
600*cdf0e10cSrcweir     if(m_aFemaleColumnLB.GetSelectEntryPos() != m_aFemaleColumnLB.GetSavedValue())
601*cdf0e10cSrcweir     {
602*cdf0e10cSrcweir         const SwDBData& rDBData = rConfigItem.GetCurrentDBData();
603*cdf0e10cSrcweir         Sequence< ::rtl::OUString> aAssignment = rConfigItem.GetColumnAssignment( rDBData );
604*cdf0e10cSrcweir         sal_Int32 nPos = m_aFemaleColumnLB.GetSelectEntryPos();
605*cdf0e10cSrcweir         if(aAssignment.getLength() < MM_PART_GENDER)
606*cdf0e10cSrcweir             aAssignment.realloc(MM_PART_GENDER);
607*cdf0e10cSrcweir         if( nPos > 0 )
608*cdf0e10cSrcweir             aAssignment[MM_PART_GENDER] = m_aFemaleColumnLB.GetSelectEntry();
609*cdf0e10cSrcweir         else
610*cdf0e10cSrcweir             aAssignment[MM_PART_GENDER] = ::rtl::OUString();
611*cdf0e10cSrcweir         rConfigItem.SetColumnAssignment( rDBData, aAssignment );
612*cdf0e10cSrcweir     }
613*cdf0e10cSrcweir     if(m_aFemaleFieldCB.GetText() != m_aFemaleFieldCB.GetSavedValue())
614*cdf0e10cSrcweir         rConfigItem.SetFemaleGenderValue(m_aFemaleFieldCB.GetText());
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir     EndDialog(RET_OK);
617*cdf0e10cSrcweir     return 0;
618*cdf0e10cSrcweir }
619*cdf0e10cSrcweir 
620