Files
libreoffice/sw/source/ui/dbui/mmgreetingspage.cxx

620 lines
26 KiB
C++
Raw Normal View History

/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
#ifdef SW_DLLIMPLEMENTATION
#undef SW_DLLIMPLEMENTATION
#endif
#include <mmgreetingspage.hxx>
#include <mailmergewizard.hxx>
#include <mmconfigitem.hxx>
#include <mmaddressblockpage.hxx>
#include <swtypes.hxx>
#include <vcl/msgbox.hxx>
#include <mmgreetingspage.hrc>
#include <dbui.hrc>
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
#include <com/sun/star/sdb/XColumn.hpp>
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <helpid.h>
using namespace svt;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
// -----------------------------------------------------------------------
void lcl_FillGreetingsBox(ListBox& rBox,
SwMailMergeConfigItem& rConfig,
SwMailMergeConfigItem::Gender eType)
{
const Sequence< ::rtl::OUString> rEntries = rConfig.GetGreetings(eType);
for(sal_Int32 nEntry = 0; nEntry < rEntries.getLength(); ++nEntry)
rBox.InsertEntry(rEntries[nEntry]);
rBox.SelectEntryPos((USHORT)rConfig.GetCurrentGreeting(eType));
}
// -----------------------------------------------------------------------
void lcl_FillGreetingsBox(ComboBox& rBox,
SwMailMergeConfigItem& rConfig,
SwMailMergeConfigItem::Gender eType)
{
const Sequence< ::rtl::OUString> rEntries = rConfig.GetGreetings(eType);
for(sal_Int32 nEntry = 0; nEntry < rEntries.getLength(); ++nEntry)
rBox.InsertEntry(rEntries[nEntry]);
rBox.SelectEntryPos((USHORT)rConfig.GetCurrentGreeting(eType));
}
// -----------------------------------------------------------------------
void lcl_StoreGreetingsBox(ListBox& rBox,
SwMailMergeConfigItem& rConfig,
SwMailMergeConfigItem::Gender eType)
{
Sequence< ::rtl::OUString> aEntries(rBox.GetEntryCount());
::rtl::OUString* pEntries = aEntries.getArray();
for(USHORT nEntry = 0; nEntry < rBox.GetEntryCount(); ++nEntry)
pEntries[nEntry] = rBox.GetEntry(nEntry);
rConfig.SetGreetings(eType, aEntries);
rConfig.SetCurrentGreeting(eType, rBox.GetSelectEntryPos());
}
// -----------------------------------------------------------------------
void lcl_StoreGreetingsBox(ComboBox& rBox,
SwMailMergeConfigItem& rConfig,
SwMailMergeConfigItem::Gender eType)
{
Sequence< ::rtl::OUString> aEntries(rBox.GetEntryCount());
::rtl::OUString* pEntries = aEntries.getArray();
for(USHORT nEntry = 0; nEntry < rBox.GetEntryCount(); ++nEntry)
pEntries[nEntry] = rBox.GetEntry(nEntry);
rConfig.SetGreetings(eType, aEntries);
rConfig.SetCurrentGreeting(eType, rBox.GetSelectEntryPos());
}
/*-- 30.04.2004 10:42:57---------------------------------------------------
-----------------------------------------------------------------------*/
IMPL_LINK(SwGreetingsHandler, IndividualHdl_Impl, CheckBox*, EMPTYARG)
{
BOOL bIndividual = m_pPersonalizedCB->IsEnabled() && m_pPersonalizedCB->IsChecked();
m_pFemaleFT->Enable(bIndividual);
m_pFemaleLB->Enable(bIndividual);
m_pFemalePB->Enable(bIndividual);
m_pMaleFT->Enable(bIndividual);
m_pMaleLB->Enable(bIndividual);
m_pMalePB->Enable(bIndividual);
m_pFemaleFI->Enable(bIndividual);
m_pFemaleColumnFT->Enable(bIndividual);
m_pFemaleColumnLB->Enable(bIndividual);
m_pFemaleFieldFT->Enable(bIndividual);
m_pFemaleFieldCB->Enable(bIndividual);
if( m_bIsTabPage )
{
m_pWizard->GetConfigItem().SetIndividualGreeting(bIndividual, sal_False);
m_pWizard->UpdateRoadmap();
m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
}
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
UpdatePreview();
return 0;
}
/*-- 30.04.2004 10:42:57---------------------------------------------------
-----------------------------------------------------------------------*/
IMPL_LINK(SwGreetingsHandler, GreetingHdl_Impl, PushButton*, pButton)
{
SwCustomizeAddressBlockDialog* pDlg =
new SwCustomizeAddressBlockDialog(pButton, m_pWizard->GetConfigItem(),
pButton == m_pMalePB ?
SwCustomizeAddressBlockDialog::GREETING_MALE :
SwCustomizeAddressBlockDialog::GREETING_FEMALE );
if(RET_OK == pDlg->Execute())
{
ListBox* pToInsert = pButton == m_pMalePB ? m_pMaleLB : m_pFemaleLB;
pToInsert->SelectEntryPos(pToInsert->InsertEntry(pDlg->GetAddress()));
if(m_bIsTabPage)
{
m_pWizard->UpdateRoadmap();
m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
}
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
UpdatePreview();
}
delete pDlg;
return 0;
}
/*-- 16.06.2004 10:56:21---------------------------------------------------
-----------------------------------------------------------------------*/
void SwGreetingsHandler::UpdatePreview()
{
//the base class does nothing
}
/*-- 30.04.2004 10:42:59---------------------------------------------------
-----------------------------------------------------------------------*/
IMPL_LINK(SwMailMergeGreetingsPage, AssignHdl_Impl, PushButton*, pButton)
{
String sPreview = m_aFemaleLB.GetSelectEntry();
sPreview += '\n';
sPreview += m_aMaleLB.GetSelectEntry();
SwAssignFieldsDialog* pDlg =
new SwAssignFieldsDialog(pButton, m_pWizard->GetConfigItem(), sPreview, false);
if(RET_OK == pDlg->Execute())
{
UpdatePreview();
m_pWizard->UpdateRoadmap();
m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
}
delete pDlg;
return 0;
}
/*-- 05.05.2004 15:25:56---------------------------------------------------
-----------------------------------------------------------------------*/
IMPL_LINK(SwMailMergeGreetingsPage, GreetingSelectHdl_Impl, ListBox*, EMPTYARG)
{
UpdatePreview();
return 0;
}
/*-- 05.05.2004 15:23:43---------------------------------------------------
-----------------------------------------------------------------------*/
void SwMailMergeGreetingsPage::UpdatePreview()
{
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
//find out which type of greeting should be selected:
bool bFemale = false;
bool bNoValue = !m_pFemaleColumnLB->IsEnabled();
if( !bNoValue )
{
::rtl::OUString sFemaleValue = m_aFemaleFieldCB.GetText();
::rtl::OUString sFemaleColumn = m_aFemaleColumnLB.GetSelectEntry();
Reference< sdbcx::XColumnsSupplier > xColsSupp( m_pWizard->GetConfigItem().GetResultSet(), UNO_QUERY);
Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
if(sFemaleValue.getLength() && sFemaleColumn.getLength() &&
xColAccess.is() &&
xColAccess->hasByName(sFemaleColumn))
{
//get the content and exchange it in the address string
Any aCol = xColAccess->getByName(sFemaleColumn);
Reference< sdb::XColumn > xColumn;
aCol >>= xColumn;
if(xColumn.is())
{
try
{
::rtl::OUString sFemaleColumnValue = xColumn->getString();
bFemale = sFemaleColumnValue == sFemaleValue;
//bNoValue = !sFemaleColumnValue.getLength();
if( !bNoValue )
{
//no last name value marks the greeting also als neutral
SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
::rtl::OUString sLastNameColumn = rConfig.GetAssignedColumn(MM_PART_LASTNAME);
if ( xColAccess->hasByName(sLastNameColumn) )
{
aCol = xColAccess->getByName(sLastNameColumn);
aCol >>= xColumn;
::rtl::OUString sLastNameColumnValue = xColumn->getString();
bNoValue = !sLastNameColumnValue.getLength();
}
}
}
catch( sdbc::SQLException& )
{
DBG_ERROR("SQLException caught");
}
}
}
}
String sPreview = bFemale ? m_aFemaleLB.GetSelectEntry() :
bNoValue ? m_aNeutralCB.GetText() : m_aMaleLB.GetSelectEntry();
sPreview = SwAddressPreview::FillData(sPreview, m_pWizard->GetConfigItem());
m_aPreviewWIN.SetAddress(sPreview);
}
/*-- 17.05.2004 15:44:53---------------------------------------------------
-----------------------------------------------------------------------*/
void SwGreetingsHandler::Contains(sal_Bool bContainsGreeting)
{
m_pPersonalizedCB->Enable(bContainsGreeting);
sal_Bool bEnablePersonal = bContainsGreeting && m_pPersonalizedCB->IsChecked();
m_pFemaleFT->Enable(bEnablePersonal);
m_pFemaleLB->Enable(bEnablePersonal);
m_pFemalePB->Enable(bEnablePersonal);
m_pMaleFT->Enable(bEnablePersonal);
m_pMaleLB->Enable(bEnablePersonal);
m_pMalePB->Enable(bEnablePersonal);
m_pFemaleFI->Enable(bEnablePersonal);
m_pFemaleColumnFT->Enable(bEnablePersonal);
m_pFemaleColumnLB->Enable(bEnablePersonal);
m_pFemaleFieldFT->Enable(bEnablePersonal);
m_pFemaleFieldCB->Enable(bEnablePersonal);
m_pNeutralFT->Enable(bContainsGreeting);
m_pNeutralCB->Enable(bContainsGreeting);
}
/*-- 02.04.2004 14:17:52---------------------------------------------------
-----------------------------------------------------------------------*/
SwMailMergeGreetingsPage::SwMailMergeGreetingsPage( SwMailMergeWizard* _pParent) :
svt::OWizardPage(_pParent, SW_RES(DLG_MM_GREETINGS_PAGE)),
#ifdef MSC
#pragma warning (disable : 4355)
#endif
m_aHeaderFI(this, SW_RES( FI_HEADER ) ),
m_aGreetingLineCB(this, SW_RES( CB_GREETINGLINE ) ),
m_aPersonalizedCB(this, SW_RES( CB_PERSONALIZED ) ),
m_aFemaleFT(this, SW_RES( FT_FEMALE ) ),
m_aFemaleLB(this, SW_RES( LB_FEMALE ) ),
m_aFemalePB(this, SW_RES( PB_FEMALE ) ),
m_aMaleFT(this, SW_RES( FT_MALE ) ),
m_aMaleLB(this, SW_RES( LB_MALE ) ),
m_aMalePB(this, SW_RES( PB_MALE ) ),
m_aFemaleFI(this, SW_RES( FI_FEMALE ) ),
m_aFemaleColumnFT(this, SW_RES( FT_FEMALECOLUMN ) ),
m_aFemaleColumnLB(this, SW_RES( LB_FEMALECOLUMN ) ),
m_aFemaleFieldFT(this, SW_RES( FT_FEMALEFIELD ) ),
m_aFemaleFieldCB(this, SW_RES( CB_FEMALEFIELD ) ),
m_aNeutralFT(this, SW_RES( FT_NEUTRAL ) ),
m_aNeutralCB(this, SW_RES( CB_NEUTRAL ) ),
m_aPreviewFI( this, SW_RES( FI_PREVIEW ) ),
m_aPreviewWIN( this, SW_RES( WIN_PREVIEW ) ),
m_aAssignPB( this, SW_RES( PB_ASSIGN ) ),
m_aDocumentIndexFI( this, SW_RES( FI_DOCINDEX ) ),
m_aPrevSetIB( this, SW_RES( IB_PREVSET ) ),
m_aNextSetIB( this, SW_RES( IB_NEXTSET ) ),
m_sDocument( SW_RES( STR_DOCUMENT ) )
#ifdef MSC
#pragma warning (default : 4355)
#endif
{
m_pWizard = _pParent;
m_pGreetingLineCB = &m_aGreetingLineCB;
m_pPersonalizedCB = &m_aPersonalizedCB;
m_pFemaleFT = & m_aFemaleFT;
m_pFemaleLB = & m_aFemaleLB;
m_pFemalePB = & m_aFemalePB;
m_pMaleFT = & m_aMaleFT;
m_pMaleLB = & m_aMaleLB;
m_pMalePB = & m_aMalePB;
m_pFemaleFI = & m_aFemaleFI;
m_pFemaleColumnFT = &m_aFemaleColumnFT;
m_pFemaleColumnLB = &m_aFemaleColumnLB;
m_pFemaleFieldFT = & m_aFemaleFieldFT;
m_pFemaleFieldCB = & m_aFemaleFieldCB;
m_pNeutralFT = & m_aNeutralFT;
m_pNeutralCB = &m_aNeutralCB;
m_bIsTabPage = true;
m_pPersonalizedCB->SetHelpId( HID_MM_GREETINGS_CB_PERSONALIZED);
m_pFemaleLB->SetHelpId( HID_MM_GREETINGS_LB_FEMALE );
m_pFemalePB->SetHelpId( HID_MM_GREETINGS_PB_FEMALE );
m_pMaleLB->SetHelpId( HID_MM_GREETINGS_LB_MALE );
m_pMalePB->SetHelpId( HID_MM_GREETINGS_PB_MALE );
m_pFemaleColumnLB->SetHelpId( HID_MM_GREETINGS_LB_FEMALECOLUMN);
m_pFemaleFieldCB->SetHelpId( HID_MM_GREETINGS_CB_FEMALEFIELD );
m_pNeutralCB->SetHelpId( HID_MM_GREETINGS_CB_NEUTRAL );
FreeResource();
m_aGreetingLineCB.SetClickHdl(LINK(this, SwMailMergeGreetingsPage, ContainsHdl_Impl));
Link aIndividualLink = LINK(this, SwGreetingsHandler, IndividualHdl_Impl);
m_aPersonalizedCB.SetClickHdl(aIndividualLink);
Link aGreetingLink = LINK(this, SwGreetingsHandler, GreetingHdl_Impl);
m_aFemalePB.SetClickHdl(aGreetingLink);
m_aMalePB.SetClickHdl(aGreetingLink);
m_aAssignPB.SetClickHdl(LINK(this, SwMailMergeGreetingsPage, AssignHdl_Impl));
Link aLBoxLink = LINK(this, SwMailMergeGreetingsPage, GreetingSelectHdl_Impl);
m_aFemaleLB.SetSelectHdl(aLBoxLink);
m_aMaleLB.SetSelectHdl(aLBoxLink);
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
m_aFemaleColumnLB.SetSelectHdl(aLBoxLink);
m_aFemaleFieldCB.SetSelectHdl(aLBoxLink);
m_aFemaleFieldCB.SetModifyHdl(aLBoxLink);
m_aNeutralCB.SetSelectHdl(aLBoxLink);
m_aNeutralCB.SetModifyHdl(aLBoxLink);
Link aDataLink = LINK(this, SwMailMergeGreetingsPage, InsertDataHdl_Impl);
m_aPrevSetIB.SetClickHdl(aDataLink);
m_aNextSetIB.SetClickHdl(aDataLink);
SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
m_aGreetingLineCB.Check(rConfig.IsGreetingLine(sal_False));
m_aPersonalizedCB.Check(rConfig.IsIndividualGreeting(sal_False));
ContainsHdl_Impl(&m_aGreetingLineCB);
aIndividualLink.Call(0);
lcl_FillGreetingsBox(m_aFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
lcl_FillGreetingsBox(m_aMaleLB, rConfig, SwMailMergeConfigItem::MALE);
lcl_FillGreetingsBox(m_aNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
String sTemp(m_sDocument);
sTemp.SearchAndReplaceAscii("%1", String::CreateFromInt32(1));
m_aDocumentIndexFI.SetText(sTemp);
}
/*-- 02.04.2004 14:17:52---------------------------------------------------
-----------------------------------------------------------------------*/
SwMailMergeGreetingsPage::~SwMailMergeGreetingsPage()
{
}
/*-- 18.06.2004 12:13:53---------------------------------------------------
-----------------------------------------------------------------------*/
void SwMailMergeGreetingsPage::ActivatePage()
{
SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
//try to find the gender setting
m_aFemaleColumnLB.Clear();
Reference< sdbcx::XColumnsSupplier > xColsSupp = rConfig.GetColumnsSupplier();
if(xColsSupp.is())
{
Reference < container::XNameAccess> xColAccess = xColsSupp->getColumns();
Sequence< ::rtl::OUString > aColumns = xColAccess->getElementNames();
for(sal_Int32 nName = 0; nName < aColumns.getLength(); ++nName)
m_aFemaleColumnLB.InsertEntry(aColumns[nName]);
}
::rtl::OUString sGenderColumn = rConfig.GetAssignedColumn(MM_PART_GENDER);
m_aFemaleColumnLB.SelectEntry(sGenderColumn);
m_aFemaleColumnLB.SaveValue();
m_aFemaleFieldCB.SetText(rConfig.GetFemaleGenderValue());
m_aFemaleFieldCB.SaveValue();
UpdatePreview();
m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
}
/*-- 11.05.2004 14:47:10---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwMailMergeGreetingsPage::commitPage( ::svt::WizardTypes::CommitPageReason )
{
SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
if(m_aFemaleColumnLB.GetSelectEntryPos() != m_aFemaleColumnLB.GetSavedValue())
{
const SwDBData& rDBData = rConfig.GetCurrentDBData();
Sequence< ::rtl::OUString> aAssignment = rConfig.GetColumnAssignment( rDBData );
if(aAssignment.getLength() <= MM_PART_GENDER)
aAssignment.realloc(MM_PART_GENDER + 1);
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
aAssignment[MM_PART_GENDER] = m_aFemaleColumnLB.GetSelectEntry();
rConfig.SetColumnAssignment( rDBData, aAssignment );
}
if(m_aFemaleFieldCB.GetText() != m_aFemaleFieldCB.GetSavedValue())
rConfig.SetFemaleGenderValue(m_aFemaleFieldCB.GetText());
lcl_StoreGreetingsBox(m_aFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
lcl_StoreGreetingsBox(m_aMaleLB, rConfig, SwMailMergeConfigItem::MALE);
USHORT nCurrentTextPos = m_aNeutralCB.GetEntryPos( m_aNeutralCB.GetText() );
if(LISTBOX_ENTRY_NOTFOUND == nCurrentTextPos)
{
USHORT nCount = m_aNeutralCB.GetEntryCount();
m_aNeutralCB.InsertEntry( m_aNeutralCB.GetText(), nCount );
m_aNeutralCB.SelectEntryPos(nCount);
}
lcl_StoreGreetingsBox(m_aNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
rConfig.SetGreetingLine(m_aGreetingLineCB.IsChecked(), sal_False);
rConfig.SetIndividualGreeting(m_aPersonalizedCB.IsChecked(), sal_False);
return sal_True;
}
/*-- 30.04.2004 10:42:57---------------------------------------------------
-----------------------------------------------------------------------*/
IMPL_LINK(SwMailMergeGreetingsPage, ContainsHdl_Impl, CheckBox*, pBox)
{
sal_Bool bContainsGreeting = pBox->IsChecked();
SwGreetingsHandler::Contains(bContainsGreeting);
m_aPreviewFI. Enable(bContainsGreeting);
m_aPreviewWIN.Enable(bContainsGreeting);
m_aAssignPB. Enable(bContainsGreeting);
m_aDocumentIndexFI. Enable(bContainsGreeting);
m_aPrevSetIB.Enable(bContainsGreeting);
m_aNextSetIB.Enable(bContainsGreeting);
SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
rConfig.SetGreetingLine(m_aGreetingLineCB.IsChecked(), sal_False);
m_pWizard->UpdateRoadmap();
return 0;
}
/*-- 07.05.2004 12:56:42---------------------------------------------------
-----------------------------------------------------------------------*/
IMPL_LINK(SwMailMergeGreetingsPage, InsertDataHdl_Impl, ImageButton*, pButton)
{
//if no pButton is given, the first set has to be pre-set
SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
if(!pButton)
{
rConfig.GetResultSet();
}
else
{
BOOL bNext = pButton == &m_aNextSetIB;
sal_Int32 nPos = rConfig.GetResultSetPosition();
rConfig.MoveResultSet( bNext ? ++nPos : --nPos);
}
sal_Int32 nPos = rConfig.GetResultSetPosition();
BOOL bEnable = TRUE;
if(nPos < 1)
{
bEnable = FALSE;
nPos = 1;
}
else
UpdatePreview();
m_aPrevSetIB.Enable(bEnable);
m_aNextSetIB.Enable(bEnable);
m_aDocumentIndexFI.Enable(bEnable);
String sTemp(m_sDocument);
sTemp.SearchAndReplaceAscii("%1", String::CreateFromInt32(nPos));
m_aDocumentIndexFI.SetText(sTemp);
return 0;
}
/*-- 17.05.2004 15:11:19---------------------------------------------------
-----------------------------------------------------------------------*/
SwMailBodyDialog::SwMailBodyDialog(Window* pParent, SwMailMergeWizard* _pWizard) :
SfxModalDialog(pParent, SW_RES(DLG_MM_MAILBODY)),
#ifdef MSC
#pragma warning (disable : 4355)
#endif
m_aGreetingLineCB(this, SW_RES( CB_GREETINGLINE ) ),
m_aPersonalizedCB(this, SW_RES( CB_PERSONALIZED ) ),
m_aFemaleFT(this, SW_RES( FT_FEMALE ) ),
m_aFemaleLB(this, SW_RES( LB_FEMALE ) ),
m_aFemalePB(this, SW_RES( PB_FEMALE ) ),
m_aMaleFT(this, SW_RES( FT_MALE ) ),
m_aMaleLB(this, SW_RES( LB_MALE ) ),
m_aMalePB(this, SW_RES( PB_MALE ) ),
m_aFemaleFI(this, SW_RES( FI_FEMALE ) ),
m_aFemaleColumnFT(this, SW_RES( FT_FEMALECOLUMN ) ),
m_aFemaleColumnLB(this, SW_RES( LB_FEMALECOLUMN ) ),
m_aFemaleFieldFT(this, SW_RES( FT_FEMALEFIELD ) ),
m_aFemaleFieldCB(this, SW_RES( CB_FEMALEFIELD ) ),
m_aNeutralFT(this, SW_RES( FT_NEUTRAL ) ),
m_aNeutralCB(this, SW_RES( CB_NEUTRAL ) ),
m_aBodyFT( this, SW_RES( FT_BODY ) ),
m_aBodyMLE( this, SW_RES( MLE_BODY ) ),
m_aSeparatorFL( this, SW_RES( FL_SEPARATOR ) ),
m_aOK( this, SW_RES( PB_OK ) ),
m_aCancel( this, SW_RES( PB_CANCEL ) ),
m_aHelp( this, SW_RES( PB_HELP ) )
#ifdef MSC
#pragma warning (default : 4355)
#endif
{
m_pWizard = _pWizard;
m_pGreetingLineCB = &m_aGreetingLineCB;
m_pPersonalizedCB = &m_aPersonalizedCB;
m_pFemaleFT = & m_aFemaleFT;
m_pFemaleLB = & m_aFemaleLB;
m_pFemalePB = & m_aFemalePB;
m_pMaleFT = & m_aMaleFT;
m_pMaleLB = & m_aMaleLB;
m_pMalePB = & m_aMalePB;
m_pFemaleFI = & m_aFemaleFI;
m_pFemaleColumnFT = &m_aFemaleColumnFT;
m_pFemaleColumnLB = &m_aFemaleColumnLB;
m_pFemaleFieldFT = & m_aFemaleFieldFT;
m_pFemaleFieldCB = & m_aFemaleFieldCB;
m_pNeutralFT = & m_aNeutralFT;
m_pNeutralCB = &m_aNeutralCB;
m_bIsTabPage = false;
m_pPersonalizedCB->SetHelpId( HID_MM_BODY_CB_PERSONALIZED );
m_pFemaleLB->SetHelpId( HID_MM_BODY_LB_FEMALE );
m_pFemalePB->SetHelpId( HID_MM_BODY_PB_FEMALE );
m_pMaleLB->SetHelpId( HID_MM_BODY_LB_MALE );
m_pMalePB->SetHelpId( HID_MM_BODY_PB_MALE );
m_pFemaleColumnLB->SetHelpId( HID_MM_BODY_LB_FEMALECOLUMN );
m_pFemaleFieldCB->SetHelpId( HID_MM_BODY_CB_FEMALEFIELD );
m_pNeutralCB->SetHelpId( HID_MM_BODY_CB_NEUTRAL );
FreeResource();
m_aGreetingLineCB.SetClickHdl(LINK(this, SwMailBodyDialog, ContainsHdl_Impl));
Link aIndividualLink = LINK(this, SwGreetingsHandler, IndividualHdl_Impl);
m_aPersonalizedCB.SetClickHdl(aIndividualLink);
Link aGreetingLink = LINK(this, SwGreetingsHandler, GreetingHdl_Impl);
m_aFemalePB.SetClickHdl(aGreetingLink);
m_aMalePB.SetClickHdl(aGreetingLink);
m_aOK.SetClickHdl(LINK(this, SwMailBodyDialog, OKHdl));
SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
m_aGreetingLineCB.Check(rConfig.IsGreetingLine(sal_True));
m_aPersonalizedCB.Check(rConfig.IsIndividualGreeting(sal_True));
ContainsHdl_Impl(&m_aGreetingLineCB);
aIndividualLink.Call(0);
lcl_FillGreetingsBox(m_aFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
lcl_FillGreetingsBox(m_aMaleLB, rConfig, SwMailMergeConfigItem::MALE);
lcl_FillGreetingsBox(m_aNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
//try to find the gender setting
m_aFemaleColumnLB.Clear();
Reference< sdbcx::XColumnsSupplier > xColsSupp = rConfig.GetColumnsSupplier();
if(xColsSupp.is())
{
Reference < container::XNameAccess> xColAccess = xColsSupp->getColumns();
Sequence< ::rtl::OUString > aColumns = xColAccess->getElementNames();
for(sal_Int32 nName = 0; nName < aColumns.getLength(); ++nName)
m_aFemaleColumnLB.InsertEntry(aColumns[nName]);
}
::rtl::OUString sGenderColumn = rConfig.GetAssignedColumn(MM_PART_GENDER);
m_aFemaleColumnLB.SelectEntry(sGenderColumn);
m_aFemaleColumnLB.SaveValue();
m_aFemaleFieldCB.SetText(rConfig.GetFemaleGenderValue());
m_aFemaleFieldCB.SaveValue();
}
/*-- 17.05.2004 15:13:07---------------------------------------------------
-----------------------------------------------------------------------*/
SwMailBodyDialog::~SwMailBodyDialog()
{
}
/*-- 30.04.2004 10:42:57---------------------------------------------------
-----------------------------------------------------------------------*/
IMPL_LINK(SwMailBodyDialog, ContainsHdl_Impl, CheckBox*, pBox)
{
SwGreetingsHandler::Contains(pBox->IsChecked());
m_pWizard->GetConfigItem().SetGreetingLine(pBox->IsChecked(), sal_True);
return 0;
}
/*-- 28.06.2004 11:22:42---------------------------------------------------
-----------------------------------------------------------------------*/
IMPL_LINK(SwMailBodyDialog, OKHdl, PushButton*, EMPTYARG)
{
SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
rConfigItem.SetGreetingLine(
m_aGreetingLineCB.IsChecked(), sal_False);
rConfigItem.SetIndividualGreeting(
m_aPersonalizedCB.IsChecked(), sal_False);
if(m_aFemaleColumnLB.GetSelectEntryPos() != m_aFemaleColumnLB.GetSavedValue())
{
const SwDBData& rDBData = rConfigItem.GetCurrentDBData();
Sequence< ::rtl::OUString> aAssignment = rConfigItem.GetColumnAssignment( rDBData );
sal_Int32 nPos = m_aFemaleColumnLB.GetSelectEntryPos();
if(aAssignment.getLength() < MM_PART_GENDER)
aAssignment.realloc(MM_PART_GENDER);
if( nPos > 0 )
aAssignment[MM_PART_GENDER] = m_aFemaleColumnLB.GetSelectEntry();
else
aAssignment[MM_PART_GENDER] = ::rtl::OUString();
rConfigItem.SetColumnAssignment( rDBData, aAssignment );
}
if(m_aFemaleFieldCB.GetText() != m_aFemaleFieldCB.GetSavedValue())
rConfigItem.SetFemaleGenderValue(m_aFemaleFieldCB.GetText());
EndDialog(RET_OK);
return 0;
}