summaryrefslogtreecommitdiff
path: root/sw/source/ui/dbui
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/ui/dbui')
-rw-r--r--sw/source/ui/dbui/addresslistdialog.cxx755
-rw-r--r--sw/source/ui/dbui/addresslistdialog.hrc51
-rw-r--r--sw/source/ui/dbui/addresslistdialog.hxx125
-rw-r--r--sw/source/ui/dbui/addresslistdialog.src129
-rw-r--r--sw/source/ui/dbui/createaddresslistdialog.cxx838
-rw-r--r--sw/source/ui/dbui/createaddresslistdialog.hrc67
-rw-r--r--sw/source/ui/dbui/createaddresslistdialog.hxx133
-rw-r--r--sw/source/ui/dbui/createaddresslistdialog.src228
-rw-r--r--sw/source/ui/dbui/customizeaddresslistdialog.cxx277
-rw-r--r--sw/source/ui/dbui/customizeaddresslistdialog.hrc52
-rw-r--r--sw/source/ui/dbui/customizeaddresslistdialog.hxx102
-rw-r--r--sw/source/ui/dbui/customizeaddresslistdialog.src165
-rw-r--r--sw/source/ui/dbui/dbinsdlg.cxx1967
-rw-r--r--sw/source/ui/dbui/dbinsdlg.hrc76
-rw-r--r--sw/source/ui/dbui/dbinsdlg.src312
-rw-r--r--sw/source/ui/dbui/dbmgr.cxx3403
-rw-r--r--sw/source/ui/dbui/dbtablepreviewdialog.cxx147
-rw-r--r--sw/source/ui/dbui/dbtablepreviewdialog.hrc38
-rw-r--r--sw/source/ui/dbui/dbtablepreviewdialog.hxx63
-rw-r--r--sw/source/ui/dbui/dbtablepreviewdialog.src64
-rw-r--r--sw/source/ui/dbui/dbtree.cxx625
-rw-r--r--sw/source/ui/dbui/dbui.cxx154
-rw-r--r--sw/source/ui/dbui/dbui.src286
-rw-r--r--sw/source/ui/dbui/maildispatcher.cxx308
-rw-r--r--sw/source/ui/dbui/mailmergechildwindow.cxx799
-rw-r--r--sw/source/ui/dbui/mailmergechildwindow.hrc64
-rw-r--r--sw/source/ui/dbui/mailmergechildwindow.src281
-rw-r--r--sw/source/ui/dbui/mailmergehelper.cxx1050
-rw-r--r--sw/source/ui/dbui/mailmergewizard.cxx339
-rw-r--r--sw/source/ui/dbui/mailmergewizard.hrc40
-rw-r--r--sw/source/ui/dbui/mailmergewizard.src82
-rw-r--r--sw/source/ui/dbui/makefile.mk126
-rw-r--r--sw/source/ui/dbui/mmaddressblockpage.cxx1830
-rw-r--r--sw/source/ui/dbui/mmaddressblockpage.hrc118
-rw-r--r--sw/source/ui/dbui/mmaddressblockpage.hxx335
-rw-r--r--sw/source/ui/dbui/mmaddressblockpage.src635
-rw-r--r--sw/source/ui/dbui/mmconfigitem.cxx1987
-rw-r--r--sw/source/ui/dbui/mmdocselectpage.cxx227
-rw-r--r--sw/source/ui/dbui/mmdocselectpage.hrc40
-rw-r--r--sw/source/ui/dbui/mmdocselectpage.hxx77
-rw-r--r--sw/source/ui/dbui/mmdocselectpage.src103
-rw-r--r--sw/source/ui/dbui/mmgreetingspage.cxx622
-rw-r--r--sw/source/ui/dbui/mmgreetingspage.hrc68
-rw-r--r--sw/source/ui/dbui/mmgreetingspage.hxx179
-rw-r--r--sw/source/ui/dbui/mmgreetingspage.src258
-rw-r--r--sw/source/ui/dbui/mmlayoutpage.cxx823
-rw-r--r--sw/source/ui/dbui/mmlayoutpage.hrc51
-rw-r--r--sw/source/ui/dbui/mmlayoutpage.hxx117
-rw-r--r--sw/source/ui/dbui/mmlayoutpage.src162
-rw-r--r--sw/source/ui/dbui/mmmergepage.cxx126
-rw-r--r--sw/source/ui/dbui/mmmergepage.hrc46
-rw-r--r--sw/source/ui/dbui/mmmergepage.hxx76
-rw-r--r--sw/source/ui/dbui/mmmergepage.src104
-rw-r--r--sw/source/ui/dbui/mmoutputpage.cxx1409
-rw-r--r--sw/source/ui/dbui/mmoutputpage.hrc106
-rw-r--r--sw/source/ui/dbui/mmoutputpage.hxx245
-rw-r--r--sw/source/ui/dbui/mmoutputpage.src466
-rw-r--r--sw/source/ui/dbui/mmoutputtypepage.cxx116
-rw-r--r--sw/source/ui/dbui/mmoutputtypepage.hrc47
-rw-r--r--sw/source/ui/dbui/mmoutputtypepage.hxx70
-rw-r--r--sw/source/ui/dbui/mmoutputtypepage.src102
-rw-r--r--sw/source/ui/dbui/mmpreparemergepage.cxx207
-rw-r--r--sw/source/ui/dbui/mmpreparemergepage.hrc49
-rw-r--r--sw/source/ui/dbui/mmpreparemergepage.hxx80
-rw-r--r--sw/source/ui/dbui/mmpreparemergepage.src128
-rw-r--r--sw/source/ui/dbui/selectdbtabledialog.cxx226
-rw-r--r--sw/source/ui/dbui/selectdbtabledialog.hrc46
-rw-r--r--sw/source/ui/dbui/selectdbtabledialog.hxx82
-rw-r--r--sw/source/ui/dbui/selectdbtabledialog.src101
-rw-r--r--sw/source/ui/dbui/swdbtoolsclient.cxx251
70 files changed, 24861 insertions, 0 deletions
diff --git a/sw/source/ui/dbui/addresslistdialog.cxx b/sw/source/ui/dbui/addresslistdialog.cxx
new file mode 100644
index 000000000000..91248fa1e422
--- /dev/null
+++ b/sw/source/ui/dbui/addresslistdialog.cxx
@@ -0,0 +1,755 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: addresslistdialog.cxx,v $
+ * $Revision: 1.21 $
+ *
+ * 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 <swtypes.hxx>
+#include <addresslistdialog.hxx>
+#include <selectdbtabledialog.hxx>
+#include <createaddresslistdialog.hxx>
+#include <mailmergewizard.hxx>
+#include <mmconfigitem.hxx>
+#include <mmaddressblockpage.hxx>
+#ifndef _DBMGR_HXX
+#include <dbmgr.hxx>
+#endif
+#include <dbconfig.hxx>
+#include <unotools/tempfile.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/urlobj.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSERFACTORY_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <swunohelper.hxx>
+#include <vcl/waitobj.hxx>
+#include <svtools/pathoptions.hxx>
+#include <svtools/urihelper.hxx>
+#include <addresslistdialog.hrc>
+#include <dbui.hrc>
+
+#include <helpid.h>
+#include <unomid.h>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::rtl;
+
+#define ITEMID_NAME 1
+#define ITEMID_TABLE 2
+
+//typedef SharedUNOComponent< XConnection > SharedConnection;
+
+static const char* cUTF8 = "UTF-8";
+/*-- 07.05.2004 14:11:34---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+struct AddressUserData_Impl
+{
+ uno::Reference<XDataSource> xSource;
+ SharedConnection xConnection;
+ uno::Reference< XColumnsSupplier> xColumnsSupplier;
+ uno::Reference< sdbc::XResultSet> xResultSet;
+ ::rtl::OUString sFilter;
+ ::rtl::OUString sURL; // data is editable
+ sal_Int32 nCommandType;
+ sal_Int32 nTableAndQueryCount;
+ AddressUserData_Impl() :
+ nCommandType(0),
+ nTableAndQueryCount(-1)
+ {}
+};
+::rtl::OUString lcl_getFlatURL( uno::Reference<beans::XPropertySet>& xSourceProperties )
+{
+ ::rtl::OUString sURL;
+ if(xSourceProperties.is())
+ {
+ rtl::OUString sDBURL;
+ xSourceProperties->getPropertyValue(C2U("URL")) >>= sDBURL;
+ if(String(sDBURL).SearchAscii("sdbc:flat:") == 0)
+ {
+ uno::Sequence<OUString> aFilters;
+ xSourceProperties->getPropertyValue(C2U("TableFilter")) >>= aFilters;
+ uno::Sequence<PropertyValue> aInfo;
+ xSourceProperties->getPropertyValue(C2U("Info")) >>= aInfo;
+ if(aFilters.getLength() == 1 && aInfo.getLength() )
+ {
+ ::rtl::OUString sFieldDelim;
+ ::rtl::OUString sStringDelim;
+ ::rtl::OUString sExtension;
+ ::rtl::OUString sCharSet;
+ for(sal_Int32 nInfo = 0; nInfo < aInfo.getLength(); ++nInfo)
+ {
+ if(aInfo[nInfo].Name == C2U("FieldDelimiter"))
+ aInfo[nInfo].Value >>= sFieldDelim;
+ else if(aInfo[nInfo].Name == C2U("StringDelimiter"))
+ aInfo[nInfo].Value >>= sStringDelim;
+ else if(aInfo[nInfo].Name == C2U("Extension"))
+ aInfo[nInfo].Value >>= sExtension;
+ else if(aInfo[nInfo].Name == C2U("CharSet"))
+ aInfo[nInfo].Value >>= sCharSet;
+ }
+ if(!sCharSet.compareToAscii( cUTF8 ))
+ {
+ sURL = String(sDBURL).Copy( 10 );
+ //#i97577# at this point the 'URL' can also be a file name!
+ sURL = URIHelper::SmartRel2Abs( INetURLObject(), sURL );
+ sURL += C2U("/");
+ sURL += aFilters[0];
+ sURL += C2U(".");
+ sURL += sExtension;
+ }
+ }
+ }
+ }
+ return sURL;
+}
+/*-- 07.04.2004 16:35:43---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent) :
+ SfxModalDialog(pParent, SW_RES(DLG_MM_ADDRESSLISTDIALOG)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aDescriptionFI( this, SW_RES( FI_DESCRIPTION )),
+ m_aListFT( this, SW_RES( FT_LIST )),
+ m_aListHB( this, WB_BUTTONSTYLE | WB_BOTTOMBORDER),
+ m_aListLB( this, SW_RES( LB_LIST )),
+ m_aLoadListPB( this, SW_RES( PB_LOADLIST )),
+ m_aCreateListPB(this, SW_RES( PB_CREATELIST )),
+ m_aFilterPB( this, SW_RES( PB_FILTER )),
+ m_aEditPB(this, SW_RES( PB_EDIT )),
+ m_aTablePB(this, SW_RES( PB_TABLE )),
+ 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_sName( SW_RES( ST_NAME )),
+ m_sTable( SW_RES( ST_TABLE )),
+ m_sConnecting( SW_RES( ST_CONNECTING )),
+ m_pCreatedDataSource(0),
+ m_bInSelectHdl(false),
+ m_pAddressPage(pParent)
+{
+ FreeResource();
+ String sTemp(m_aDescriptionFI.GetText());
+ sTemp.SearchAndReplaceAscii("%1", m_aLoadListPB.GetText());
+ sTemp.SearchAndReplaceAscii("%2", m_aCreateListPB.GetText());
+ m_aDescriptionFI.SetText(sTemp);
+ m_aFilterPB.SetClickHdl( LINK( this, SwAddressListDialog, FilterHdl_Impl ));
+ m_aLoadListPB.SetClickHdl( LINK( this, SwAddressListDialog, LoadHdl_Impl ));
+ m_aCreateListPB.SetClickHdl( LINK( this, SwAddressListDialog,CreateHdl_Impl ));
+ m_aEditPB.SetClickHdl(LINK( this, SwAddressListDialog, EditHdl_Impl));
+ m_aTablePB.SetClickHdl(LINK( this, SwAddressListDialog, TableSelectHdl_Impl));
+
+ Size aLBSize(m_aListLB.GetSizePixel());
+ m_aListHB.SetSizePixel(aLBSize);
+ Size aHeadSize(m_aListHB.CalcWindowSizePixel());
+ aHeadSize.Width() = aLBSize.Width();
+ m_aListHB.SetSizePixel(aHeadSize);
+ Point aLBPos(m_aListLB.GetPosPixel());
+ m_aListHB.SetPosPixel(aLBPos);
+ aLBPos.Y() += aHeadSize.Height();
+ aLBSize.Height() -= aHeadSize.Height();
+ m_aListLB.SetPosSizePixel(aLBPos, aLBSize);
+
+ Size aSz(m_aListHB.GetOutputSizePixel());
+ m_aListHB.InsertItem( ITEMID_NAME, m_sName,
+ aSz.Width()/2,
+ HIB_LEFT | HIB_VCENTER | HIB_FIXED | HIB_FIXEDPOS/*| HIB_CLICKABLE | HIB_UPARROW */);
+ m_aListHB.InsertItem( ITEMID_TABLE, m_sTable,
+ aSz.Width()/2,
+ HIB_LEFT | HIB_VCENTER | HIB_FIXED | HIB_FIXEDPOS /*| HIB_CLICKABLE | HIB_UPARROW */);
+ m_aListHB.SetHelpId(HID_MM_ADDRESSLIST_HB );
+ m_aListHB.Show();
+
+ m_aListLB.SetHelpId(HID_MM_ADDRESSLIST_TLB);
+ static long nTabs[] = {2, 0, aSz.Width()/2 };
+ m_aListLB.SetWindowBits( WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP );
+ m_aListLB.SetSelectionMode( SINGLE_SELECTION );
+ m_aListLB.SetTabs(&nTabs[0], MAP_PIXEL);
+ m_aOK.SetClickHdl( LINK( this, SwAddressListDialog, OKHdl_Impl));
+
+ uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ if( xMgr.is() )
+ {
+ uno::Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
+ m_xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ;
+ }
+ SwMailMergeConfigItem& rConfigItem = m_pAddressPage->GetWizard()->GetConfigItem();
+ const SwDBData& rCurrentData = rConfigItem.GetCurrentDBData();
+
+ DBG_ASSERT(m_xDBContext.is(), "service 'com.sun.star.sdb.DatabaseContext' not found!");
+ sal_Bool bEnableEdit = sal_False;
+ sal_Bool bEnableOK = sal_True;
+ m_aListLB.SelectAll( FALSE );
+
+ if(m_xDBContext.is())
+ {
+ SwDBConfig aDb;
+ ::rtl::OUString sBibliography = aDb.GetBibliographySource().sDataSource;
+ uno::Sequence< ::rtl::OUString> aNames = m_xDBContext->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ for(sal_Int32 nName = 0; nName < aNames.getLength(); ++nName)
+ {
+ if ( pNames[nName] == sBibliography )
+ continue;
+ SvLBoxEntry* pEntry = m_aListLB.InsertEntry(pNames[nName]);
+ AddressUserData_Impl* pUserData = new AddressUserData_Impl();
+ pEntry->SetUserData(pUserData);
+ if(pNames[nName] == rCurrentData.sDataSource)
+ {
+ m_aListLB.Select(pEntry);
+ m_aListLB.SetEntryText(rCurrentData.sCommand, pEntry, ITEMID_TABLE - 1);
+ pUserData->nCommandType = rCurrentData.nCommandType;
+ pUserData->xSource = rConfigItem.GetSource();
+ pUserData->xConnection = rConfigItem.GetConnection();
+ pUserData->xColumnsSupplier = rConfigItem.GetColumnsSupplier();
+ pUserData->xResultSet = rConfigItem.GetResultSet();
+ pUserData->sFilter = rConfigItem.GetFilter();
+ //is the data source editable (csv, Unicode, single table)
+ uno::Reference<beans::XPropertySet> xSourceProperties;
+ try
+ {
+ m_xDBContext->getByName(pNames[nName]) >>= xSourceProperties;
+ pUserData->sURL = lcl_getFlatURL( xSourceProperties );
+ bEnableEdit = pUserData->sURL.getLength() > 0 &&
+ SWUnoHelper::UCB_IsFile( pUserData->sURL ) && //#i97577#
+ !SWUnoHelper::UCB_IsReadOnlyFileName( pUserData->sURL );
+ }
+ catch(const uno::Exception& )
+ {
+ bEnableOK = sal_False;
+ }
+ m_aDBData = rCurrentData;
+ }
+ }
+ }
+ m_aOK.Enable(m_aListLB.GetEntryCount()>0 && bEnableOK);
+ m_aEditPB.Enable(bEnableEdit);
+ m_aListLB.SetSelectHdl(LINK(this, SwAddressListDialog, ListBoxSelectHdl_Impl));
+ TableSelectHdl_Impl(NULL);
+}
+/*-- 07.04.2004 16:35:43---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAddressListDialog::~SwAddressListDialog()
+{
+ SvLBoxEntry* pEntry = m_aListLB.First();
+ while(pEntry)
+ {
+ AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pEntry->GetUserData());
+ delete pUserData;
+ pEntry = m_aListLB.Next( pEntry );
+ }
+}
+/*-- 07.04.2004 16:35:44---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddressListDialog, FilterHdl_Impl, PushButton*, EMPTYARG)
+{
+ SvLBoxEntry* pSelect = m_aListLB.FirstSelected();
+ uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ if(pSelect && xMgr.is())
+ {
+ String sCommand = m_aListLB.GetEntryText(pSelect, ITEMID_TABLE - 1);
+ if ( !sCommand.Len() )
+ return 0;
+
+ AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ if(pUserData->xConnection.is() )
+ {
+ try
+ {
+ uno::Reference<lang::XMultiServiceFactory> xConnectFactory(pUserData->xConnection, UNO_QUERY_THROW);
+ uno::Reference<XSingleSelectQueryComposer> xComposer(
+ xConnectFactory->createInstance(C2U("com.sun.star.sdb.SingleSelectQueryComposer")), UNO_QUERY_THROW);
+
+ PropertyValue aSecond;
+ aSecond.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RowSet" ) );
+ uno::Reference<XRowSet> xRowSet(
+ xMgr->createInstance(C2U("com.sun.star.sdb.RowSet")), UNO_QUERY);
+ uno::Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY);
+ xRowProperties->setPropertyValue(C2U("DataSourceName"),
+ makeAny(OUString(m_aListLB.GetEntryText(pSelect, ITEMID_NAME - 1))));
+ xRowProperties->setPropertyValue(C2U("Command"), makeAny(
+ OUString(sCommand)));
+ xRowProperties->setPropertyValue(C2U("CommandType"), makeAny(pUserData->nCommandType));
+ xRowProperties->setPropertyValue(C2U("ActiveConnection"), makeAny(pUserData->xConnection.getTyped()));
+ xRowSet->execute();
+ aSecond.Value <<= xRowSet;
+
+ PropertyValue aFirst;
+ aFirst.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "QueryComposer" ) );
+ ::rtl::OUString sQuery;
+ xRowProperties->getPropertyValue(C2U("ActiveCommand"))>>= sQuery;
+ xComposer->setQuery(sQuery);
+ if(pUserData->sFilter.getLength())
+ xComposer->setFilter(pUserData->sFilter);
+ aFirst.Value <<= xComposer;
+
+ uno::Sequence<Any> aInit(2);
+ aInit[0] <<= aFirst;
+ aInit[1] <<= aSecond;
+
+ ::rtl::OUString sDialogServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.FilterDialog" ) );
+ uno::Reference< XExecutableDialog> xDialog(
+ xMgr->createInstanceWithArguments( sDialogServiceName, aInit ), UNO_QUERY);
+
+ if ( RET_OK == xDialog->execute() )
+ {
+ WaitObject aWO( NULL );
+ pUserData->sFilter = xComposer->getFilter();
+ }
+ ::comphelper::disposeComponent(xRowSet);
+ }
+ catch(Exception& )
+ {
+ DBG_ERROR("exception caught in SwAddressListDialog::FilterHdl_Impl");
+ }
+ }
+ }
+ return 0;
+}
+/*-- 07.04.2004 16:35:44---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddressListDialog, LoadHdl_Impl, PushButton*, EMPTYARG)
+{
+ String sNewSource = SwNewDBMgr::LoadAndRegisterDataSource();
+ if(sNewSource.Len())
+ {
+ SvLBoxEntry* pNewSource = m_aListLB.InsertEntry(sNewSource);
+ pNewSource->SetUserData(new AddressUserData_Impl());
+ m_aListLB.Select(pNewSource);
+ }
+ return 0;
+}
+/*-- 07.04.2004 16:35:44---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddressListDialog, CreateHdl_Impl, PushButton*, pButton)
+{
+ String sInputURL;
+ SwCreateAddressListDialog* pDlg =
+ new SwCreateAddressListDialog(
+ pButton,
+ sInputURL,
+ m_pAddressPage->GetWizard()->GetConfigItem());
+ if(RET_OK == pDlg->Execute())
+ {
+ //register the URL a new datasource
+ OUString sURL = pDlg->GetURL();
+ try
+ {
+ uno::Reference<XSingleServiceFactory> xFact( m_xDBContext, UNO_QUERY);
+ uno::Reference<XInterface> xNewInstance = xFact->createInstance();
+ INetURLObject aURL( sURL );
+ OUString sNewName = aURL.getBase();
+ //find a unique name if sNewName already exists
+ OUString sFind(sNewName);
+ sal_Int32 nIndex = 0;
+ while(m_xDBContext->hasByName(sFind))
+ {
+ sFind = sNewName;
+ sFind += OUString::valueOf(++nIndex);
+ }
+ uno::Reference<XPropertySet> xDataProperties(xNewInstance, UNO_QUERY);
+
+ OUString sDBURL(C2U("sdbc:flat:"));
+ //only the 'path' has to be added
+ INetURLObject aTempURL(aURL);
+ aTempURL.removeSegment();
+ aTempURL.removeFinalSlash();
+ sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
+ Any aAny(&sDBURL, ::getCppuType(&sDBURL));
+ xDataProperties->setPropertyValue(C2U("URL"), aAny);
+ //set the filter to the file name without extension
+ uno::Sequence<OUString> aFilters(1);
+ aFilters[0] = sNewName;
+ aAny <<= aFilters;
+ xDataProperties->setPropertyValue(C2U("TableFilter"), aAny);
+
+ uno::Sequence<PropertyValue> aInfo(4);
+ PropertyValue* pInfo = aInfo.getArray();
+ pInfo[0].Name = C2U("FieldDelimiter");
+ pInfo[0].Value <<= OUString(String('\t'));
+ pInfo[1].Name = C2U("StringDelimiter");
+ pInfo[1].Value <<= OUString('"');
+ pInfo[2].Name = C2U("Extension");
+ pInfo[2].Value <<= ::rtl::OUString(aURL.getExtension());//C2U("csv");
+ pInfo[3].Name = C2U("CharSet");
+ pInfo[3].Value <<= C2U(cUTF8);
+ aAny <<= aInfo;
+ xDataProperties->setPropertyValue(C2U("Info"), aAny);
+
+ uno::Reference<sdb::XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW);
+ uno::Reference<frame::XStorable> xStore(xDS->getDatabaseDocument(), UNO_QUERY_THROW);
+ String sExt = String::CreateFromAscii(".odb");
+ String sTmpName;
+ {
+ String sHomePath(SvtPathOptions().GetWorkPath());
+ utl::TempFile aTempFile(sFind , &sExt, &sHomePath);
+ aTempFile.EnableKillingFile(sal_True);
+ sTmpName = aTempFile.GetURL();
+ }
+ xStore->storeAsURL(sTmpName, Sequence< PropertyValue >());
+
+
+ uno::Reference<XNamingService> xNaming(m_xDBContext, UNO_QUERY);
+ xNaming->registerObject( sFind, xNewInstance );
+ //now insert the new source into the ListBox
+ String sEntry(sFind);
+ sEntry += '\t';
+ sEntry += String(aFilters[0]);
+ m_pCreatedDataSource = m_aListLB.InsertEntry(sEntry);
+ AddressUserData_Impl* pUserData = new AddressUserData_Impl();
+ pUserData->sURL = sURL;
+ m_pCreatedDataSource->SetUserData(pUserData);
+ m_aListLB.Select(m_pCreatedDataSource);
+ m_aCreateListPB.Enable(FALSE);
+
+ }
+ catch(Exception& )
+ {
+ }
+ }
+ delete pDlg;
+ return 0;
+}
+/*-- 22.04.2004 10:30:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddressListDialog, EditHdl_Impl, PushButton*, pButton)
+{
+ SvLBoxEntry* pEntry = m_aListLB.FirstSelected();
+ AddressUserData_Impl* pUserData = pEntry ? static_cast<AddressUserData_Impl*>(pEntry->GetUserData()) : 0;
+ if(pUserData && pUserData->sURL.getLength())
+ {
+ if(pUserData->xResultSet.is())
+ {
+ SwMailMergeConfigItem& rConfigItem = m_pAddressPage->GetWizard()->GetConfigItem();
+ if(rConfigItem.GetResultSet() != pUserData->xResultSet)
+ ::comphelper::disposeComponent( pUserData->xResultSet );
+ pUserData->xResultSet = 0;
+
+ rConfigItem.DisposeResultSet();
+ }
+ pUserData->xSource.clear();
+ pUserData->xColumnsSupplier.clear();
+ pUserData->xConnection.clear();
+ // will automatically close if it was the las reference
+ SwCreateAddressListDialog* pDlg =
+ new SwCreateAddressListDialog(
+ pButton,
+ pUserData->sURL,
+ m_pAddressPage->GetWizard()->GetConfigItem());
+ if(RET_OK == pDlg->Execute())
+ {
+ }
+ delete pDlg;
+ }
+ return 0;
+};
+/*-- 19.04.2004 09:41:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddressListDialog, ListBoxSelectHdl_Impl, SvTabListBox*, EMPTYARG)
+{
+ SvLBoxEntry* pSelect = m_aListLB.FirstSelected();
+ Application::PostUserEvent( STATIC_LINK( this, SwAddressListDialog,
+ StaticListBoxSelectHdl_Impl ), pSelect );
+ return 0;
+}
+IMPL_STATIC_LINK(SwAddressListDialog, StaticListBoxSelectHdl_Impl, SvLBoxEntry*, pSelect)
+{
+ //prevent nested calls of the select handler
+ if(pThis->m_bInSelectHdl)
+ return 0;
+ pThis->EnterWait();
+ pThis->m_bInSelectHdl = true;
+ AddressUserData_Impl* pUserData = 0;
+ if(pSelect)
+ {
+ String sTable = pThis->m_aListLB.GetEntryText(pSelect, ITEMID_TABLE - 1);
+ if(!sTable.Len())
+ {
+ pThis->m_aListLB.SetEntryText(pThis->m_sConnecting, pSelect, ITEMID_TABLE - 1);
+ // allow painting of the new entry
+ pThis->m_aListLB.Window::Invalidate(INVALIDATE_UPDATE);
+ for (USHORT i = 0; i < 10; i++)
+ Application::Reschedule();
+ }
+
+ pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ if(pUserData->nTableAndQueryCount > 1 || pUserData->nTableAndQueryCount == -1)
+ {
+ pThis->DetectTablesAndQueries(pSelect, !sTable.Len());
+ }
+ else
+ {
+ //otherwise set the selected db-data
+ pThis->m_aDBData.sDataSource = pThis->m_aListLB.GetEntryText(pSelect, ITEMID_NAME - 1);
+ pThis->m_aDBData.sCommand = pThis->m_aListLB.GetEntryText(pSelect, ITEMID_TABLE - 1);
+ pThis->m_aDBData.nCommandType = pUserData->nCommandType;
+ pThis->m_aOK.Enable(sal_True);
+ }
+ sTable = pThis->m_aListLB.GetEntryText(pSelect, ITEMID_TABLE - 1);
+ if(sTable == pThis->m_sConnecting)
+ pThis->m_aListLB.SetEntryText(String(), pSelect, ITEMID_TABLE - 1);
+ }
+ pThis->m_aEditPB.Enable(pUserData && pUserData->sURL.getLength() &&
+ SWUnoHelper::UCB_IsFile( pUserData->sURL ) && //#i97577#
+ !SWUnoHelper::UCB_IsReadOnlyFileName( pUserData->sURL ) );
+ pThis->m_bInSelectHdl = false;
+ pThis->LeaveWait();
+ return 0;
+}
+
+/*-- 13.05.2004 14:59:25---------------------------------------------------
+ detect the number of tables for a data source
+ if only one is available then set it at the entry
+ -----------------------------------------------------------------------*/
+void SwAddressListDialog::DetectTablesAndQueries(
+ SvLBoxEntry* pSelect,
+ bool bWidthDialog)
+{
+ try
+ {
+ AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ uno::Reference<XCompletedConnection> xComplConnection;
+ if(!pUserData->xConnection.is())
+ {
+ m_aDBData.sDataSource = m_aListLB.GetEntryText(pSelect, ITEMID_NAME - 1);
+ m_xDBContext->getByName(m_aDBData.sDataSource) >>= xComplConnection;
+ pUserData->xSource = uno::Reference<XDataSource>(xComplConnection, UNO_QUERY);
+
+ uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ uno::Reference< XInteractionHandler > xHandler(
+ xMgr->createInstance( C2U( "com.sun.star.sdb.InteractionHandler" )), UNO_QUERY);
+ pUserData->xConnection = SharedConnection( xComplConnection->connectWithCompletion( xHandler ) );
+ }
+ if(pUserData->xConnection.is())
+ {
+ sal_Int32 nTables = 0;
+ uno::Sequence<rtl::OUString> aTables;
+ uno::Sequence<rtl::OUString> aQueries;
+ uno::Reference<XTablesSupplier> xTSupplier(pUserData->xConnection, UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ uno::Reference<XNameAccess> xTbls = xTSupplier->getTables();
+ aTables = xTbls->getElementNames();
+ nTables += aTables.getLength();
+ }
+ uno::Reference<XQueriesSupplier> xQSupplier(pUserData->xConnection, UNO_QUERY);
+ if(xQSupplier.is())
+ {
+ uno::Reference<XNameAccess> xQueries = xQSupplier->getQueries();
+ aQueries = xQueries->getElementNames();
+ nTables += aQueries.getLength();
+ }
+ pUserData->nTableAndQueryCount = nTables;
+ if(nTables > 1 && bWidthDialog)
+ {
+ //now call the table select dialog - if more than one table exists
+ SwSelectDBTableDialog* pDlg = new SwSelectDBTableDialog(this, pUserData->xConnection);
+ String sTable = m_aListLB.GetEntryText(pSelect, ITEMID_TABLE - 1);
+ if(sTable.Len())
+ pDlg->SetSelectedTable(sTable, pUserData->nCommandType == CommandType::TABLE);
+ if(RET_OK == pDlg->Execute())
+ {
+ bool bIsTable;
+ m_aDBData.sCommand = pDlg->GetSelectedTable(bIsTable);
+ m_aDBData.nCommandType = bIsTable ? CommandType::TABLE : CommandType::QUERY;
+ pUserData->nCommandType = m_aDBData.nCommandType;
+ }
+ delete pDlg;
+ }
+ else if(nTables == 1)
+ {
+ if(aTables.getLength())
+ {
+ m_aDBData.sCommand = aTables[0];
+ m_aDBData.nCommandType = CommandType::TABLE;
+ }
+ else
+ {
+ m_aDBData.sCommand = aQueries[0];
+ m_aDBData.nCommandType = CommandType::QUERY;
+ }
+ }
+ }
+ if ( m_aDBData.sCommand.getLength() )
+ {
+ uno::Reference<beans::XPropertySet> xSourceProperties;
+ m_xDBContext->getByName(m_aDBData.sDataSource) >>= xSourceProperties;
+ pUserData->sURL = lcl_getFlatURL( xSourceProperties );
+
+ pUserData->xColumnsSupplier = SwNewDBMgr::GetColumnSupplier(pUserData->xConnection,
+ m_aDBData.sCommand,
+ m_aDBData.nCommandType == CommandType::TABLE ?
+ SW_DB_SELECT_TABLE : SW_DB_SELECT_QUERY );
+ //#i97577#
+ if( pUserData->xColumnsSupplier.is() )
+ m_aListLB.SetEntryText(m_aDBData.sCommand, pSelect, ITEMID_TABLE - 1);
+ else
+ m_aListLB.SetEntryText(String(), pSelect, ITEMID_TABLE - 1);
+ }
+ String sCommand = m_aListLB.GetEntryText(pSelect, ITEMID_TABLE - 1);
+ m_aOK.Enable(pSelect && sCommand.Len());
+ m_aFilterPB.Enable( pUserData->xConnection.is() && sCommand.Len() );
+ m_aTablePB.Enable( pUserData->nTableAndQueryCount > 1 );
+ }
+ catch(Exception& )
+ {
+ DBG_ERROR("exception caught in SwAddressListDialog::DetectTablesAndQueries");
+ m_aOK.Enable( sal_False );
+ }
+}
+
+/*-- 13.05.2004 12:55:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddressListDialog, TableSelectHdl_Impl, PushButton*, pButton)
+{
+ EnterWait();
+ SvLBoxEntry* pSelect = m_aListLB.FirstSelected();
+ if(pSelect)
+ {
+ AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ //only call the table select dialog if tables have not been searched for or there
+ //are more than 1
+ String sTable = m_aListLB.GetEntryText(pSelect, ITEMID_TABLE - 1);
+ if( pUserData->nTableAndQueryCount > 1 || pUserData->nTableAndQueryCount == -1)
+ {
+ DetectTablesAndQueries(pSelect, (pButton != 0) || (!sTable.Len()));
+ }
+ }
+
+ LeaveWait();
+ return 0;
+}
+
+/*-- 08.04.2004 14:52:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddressListDialog, OKHdl_Impl, PushButton*, EMPTYARG)
+{
+ EndDialog(TRUE);
+ return 0;
+}
+
+/*-- 07.05.2004 14:17:47---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Reference< XDataSource> SwAddressListDialog::GetSource()
+{
+ uno::Reference< XDataSource> xRet;
+ SvLBoxEntry* pSelect = m_aListLB.FirstSelected();
+ if(pSelect)
+ {
+ AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ xRet = pUserData->xSource;
+ }
+ return xRet;
+
+}
+/*-- 07.05.2004 14:17:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SharedConnection SwAddressListDialog::GetConnection()
+{
+ SharedConnection xRet;
+ SvLBoxEntry* pSelect = m_aListLB.FirstSelected();
+ if(pSelect)
+ {
+ AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ xRet = pUserData->xConnection;
+ }
+ return xRet;
+}
+/*-- 07.05.2004 14:17:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Reference< XColumnsSupplier> SwAddressListDialog::GetColumnsSupplier()
+{
+ uno::Reference< XColumnsSupplier> xRet;
+ SvLBoxEntry* pSelect = m_aListLB.FirstSelected();
+ if(pSelect)
+ {
+ AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ xRet = pUserData->xColumnsSupplier;
+ }
+ return xRet;
+}
+/*-- 14.05.2004 15:04:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwAddressListDialog::GetFilter()
+{
+ ::rtl::OUString sRet;
+ SvLBoxEntry* pSelect = m_aListLB.FirstSelected();
+ if(pSelect)
+ {
+ AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ sRet = pUserData->sFilter;
+ }
+ return sRet;
+}
diff --git a/sw/source/ui/dbui/addresslistdialog.hrc b/sw/source/ui/dbui/addresslistdialog.hrc
new file mode 100644
index 000000000000..39d1c8809de1
--- /dev/null
+++ b/sw/source/ui/dbui/addresslistdialog.hrc
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: addresslistdialog.hrc,v $
+ * $Revision: 1.5 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _ADDRESSLISTDIALOG_HRC
+#define _ADDRESSLISTDIALOG_HRC
+
+#define FI_DESCRIPTION 1
+#define FT_LIST 2
+
+#define PB_EDIT 4
+#define LB_LIST 5
+#define PB_FILTER 6
+#define PB_LOADLIST 7
+#define PB_CREATELIST 8
+#define FL_SEPARATOR 9
+#define PB_OK 12
+#define PB_CANCEL 13
+#define PB_HELP 14
+#define ST_NAME 15
+#define ST_TABLE 16
+#define PB_TABLE 17
+#define ST_CONNECTING 18
+
+#endif
+
diff --git a/sw/source/ui/dbui/addresslistdialog.hxx b/sw/source/ui/dbui/addresslistdialog.hxx
new file mode 100644
index 000000000000..1b3c86ce0823
--- /dev/null
+++ b/sw/source/ui/dbui/addresslistdialog.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: addresslistdialog.hxx,v $
+ * $Revision: 1.7 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _ADDRESSLISTDIALOG_HXX
+#define _ADDRESSLISTDIALOG_HXX
+
+#include <sfx2/basedlgs.hxx>
+#include <svtools/stdctrl.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <svtools/svtabbx.hxx>
+#include <svtools/headbar.hxx>
+#include <swdbdata.hxx>
+#include "sharedconnection.hxx"
+
+
+namespace com{namespace sun{namespace star{
+ namespace container{
+ class XNameAccess;
+ }
+ namespace sdbc{
+ class XDataSource;
+ class XConnection;
+ }
+ namespace sdbcx{
+ class XColumnsSupplier;
+ }
+}}}
+class SwMailMergeAddressBlockPage;
+/*-- 08.04.2004 14:04:29---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwAddressListDialog : public SfxModalDialog
+{
+ FixedInfo m_aDescriptionFI;
+
+ FixedInfo m_aListFT;
+ HeaderBar m_aListHB;
+ SvTabListBox m_aListLB;
+
+ PushButton m_aLoadListPB;
+ PushButton m_aCreateListPB;
+ PushButton m_aFilterPB;
+ PushButton m_aEditPB;
+ PushButton m_aTablePB;
+
+ FixedLine m_aSeparatorFL;
+
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ String m_sName;
+ String m_sTable;
+ String m_sConnecting;
+
+ String m_sCreatedURL;
+ SvLBoxEntry* m_pCreatedDataSource;
+
+ bool m_bInSelectHdl;
+
+ SwMailMergeAddressBlockPage* m_pAddressPage;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xDBContext;
+// ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> m_xSource;
+// ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+// ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> m_xColumnsSupplier;
+ SwDBData m_aDBData;
+
+ void DetectTablesAndQueries(SvLBoxEntry* pSelect, bool bWidthDialog);
+
+ DECL_LINK(FilterHdl_Impl, PushButton*);
+ DECL_LINK(LoadHdl_Impl, PushButton*);
+ DECL_LINK(CreateHdl_Impl, PushButton*);
+ DECL_LINK(ListBoxSelectHdl_Impl, SvTabListBox*);
+ DECL_LINK(EditHdl_Impl, PushButton*);
+ DECL_LINK(TableSelectHdl_Impl, PushButton*);
+ DECL_LINK(OKHdl_Impl, PushButton*);
+
+ DECL_STATIC_LINK(SwAddressListDialog, StaticListBoxSelectHdl_Impl, SvLBoxEntry*);
+
+public:
+ SwAddressListDialog(SwMailMergeAddressBlockPage* pParent);
+ ~SwAddressListDialog();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>
+ GetSource();
+
+ SharedConnection GetConnection();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier>
+ GetColumnsSupplier();
+
+ const SwDBData& GetDBData() const {return m_aDBData;}
+ ::rtl::OUString GetFilter();
+};
+#endif
+
diff --git a/sw/source/ui/dbui/addresslistdialog.src b/sw/source/ui/dbui/addresslistdialog.src
new file mode 100644
index 000000000000..94e179da17ae
--- /dev/null
+++ b/sw/source/ui/dbui/addresslistdialog.src
@@ -0,0 +1,129 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: addresslistdialog.src,v $
+ * $Revision: 1.8 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <addresslistdialog.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+
+ModalDialog DLG_MM_ADDRESSLISTDIALOG
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_ADDRESSLISTDIALOG;
+ Size = MAP_APPFONT ( 260 , 182 ) ;
+ Moveable = TRUE ;
+
+ Text [ en-US ] = "Select Address List";
+
+ FixedText FI_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 24 ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "Select an address list. Click '%1' to select recipients from a different list. If you do not have an address list you can create one by clicking '%2'.";
+ };
+ FixedText FT_LIST
+ {
+ Pos = MAP_APPFONT ( 6 , 30 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Your recipients are currently selected from:";
+ };
+ Control LB_LIST
+ {
+ Pos = MAP_APPFONT ( 6 , 43 ) ;
+ Size = MAP_APPFONT ( 182 , 102 ) ;
+ Border = TRUE;
+ TabStop = TRUE ;
+ };
+ PushButton PB_LOADLIST
+ {
+ Pos = MAP_APPFONT ( 194 , 43 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~Add...";
+ };
+ PushButton PB_CREATELIST
+ {
+ Pos = MAP_APPFONT ( 194 , 60 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~Create...";
+ };
+ PushButton PB_FILTER
+ {
+ Pos = MAP_APPFONT ( 194 , 77 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~Filter...";
+ };
+ PushButton PB_EDIT
+ {
+ Pos = MAP_APPFONT ( 194 , 94 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~Edit...";
+ };
+ PushButton PB_TABLE
+ {
+ Pos = MAP_APPFONT ( 194 , 111 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "Change ~Table...";
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 151 ) ;
+ Size = MAP_APPFONT ( 260 , 8 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 95 , 162 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 148 , 162 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 204 , 162 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String ST_NAME
+ {
+ Text [ en-US ] = "Name";
+ };
+ String ST_TABLE
+ {
+ Text [ en-US ] = "Table";
+ };
+ String ST_CONNECTING
+ {
+ Text [ en-US ] = "Connecting to data source...";
+ };
+};
+
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx
new file mode 100644
index 000000000000..3f7484932010
--- /dev/null
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -0,0 +1,838 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: createaddresslistdialog.cxx,v $
+ * $Revision: 1.16 $
+ *
+ * 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 <swtypes.hxx>
+#include <createaddresslistdialog.hxx>
+#include <customizeaddresslistdialog.hxx>
+#include <mmconfigitem.hxx>
+#include <vcl/scrbar.hxx>
+#include <vcl/msgbox.hxx>
+#ifndef _SVT_CONTROLDIMS_HRC_
+#include <svtools/controldims.hrc>
+#endif
+#include <svtools/pathoptions.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/docfac.hxx>
+#include <sfx2/docfile.hxx>
+#include <rtl/textenc.h>
+#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <tools/urlobj.hxx>
+#include <createaddresslistdialog.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+#include <unomid.h>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::ui::dialogs;
+using ::rtl::OUString;
+
+/*-- 19.04.2004 12:19:50---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwAddressControl_Impl : public Control
+{
+ ScrollBar m_aScrollBar;
+ Window m_aWindow;
+
+ ::std::vector<FixedText*> m_aFixedTexts;
+ ::std::vector<Edit*> m_aEdits;
+
+ SwCSVData* m_pData;
+ Size m_aWinOutputSize;
+ sal_Int32 m_nLineHeight;
+ sal_uInt32 m_nCurrentDataSet;
+
+ bool m_bNoDataSet;
+
+ DECL_LINK(ScrollHdl_Impl, ScrollBar*);
+ DECL_LINK(GotFocusHdl_Impl, Edit*);
+ DECL_LINK(EditModifyHdl_Impl, Edit*);
+
+ void MakeVisible(const Rectangle& aRect);
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+
+ using Window::SetData;
+
+public:
+ SwAddressControl_Impl(Window* pParent, const ResId& rResId );
+ ~SwAddressControl_Impl();
+
+ void SetData(SwCSVData& rDBData);
+
+ void SetCurrentDataSet(sal_uInt32 nSet);
+ sal_uInt32 GetCurrentDataSet() const { return m_nCurrentDataSet;}
+ void SetCursorTo(sal_uInt32 nElement);
+};
+
+/*-- 13.04.2004 10:09:42---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAddressControl_Impl::SwAddressControl_Impl(Window* pParent, const ResId& rResId ) :
+ Control(pParent, rResId),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aScrollBar(this, ResId(SCR_1,*rResId.GetResMgr())),
+ m_aWindow(this, ResId(WIN_DATA,*rResId.GetResMgr())),
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+ m_pData(0),
+ m_aWinOutputSize( m_aWindow.GetOutputSizePixel() ),
+ m_nLineHeight(0),
+ m_nCurrentDataSet(0),
+ m_bNoDataSet(true)
+{
+ FreeResource();
+ Link aScrollLink = LINK(this, SwAddressControl_Impl, ScrollHdl_Impl);
+ m_aScrollBar.SetScrollHdl(aScrollLink);
+ m_aScrollBar.SetEndScrollHdl(aScrollLink);
+ m_aScrollBar.EnableDrag();
+
+}
+/*-- 13.04.2004 10:09:43---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAddressControl_Impl::~SwAddressControl_Impl()
+{
+ ::std::vector<FixedText*>::iterator aTextIter;
+ for(aTextIter = m_aFixedTexts.begin(); aTextIter != m_aFixedTexts.end(); ++aTextIter)
+ delete *aTextIter;
+ ::std::vector<Edit*>::iterator aEditIter;
+ for(aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter)
+ delete *aEditIter;
+}
+/*-- 19.04.2004 12:22:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressControl_Impl::SetData(SwCSVData& rDBData)
+{
+ m_pData = &rDBData;
+ //when the address data is updated then remove the controls an build again
+ if(m_aFixedTexts.size())
+ {
+ ::std::vector<FixedText*>::iterator aTextIter;
+ for(aTextIter = m_aFixedTexts.begin(); aTextIter != m_aFixedTexts.end(); ++aTextIter)
+ delete *aTextIter;
+ ::std::vector<Edit*>::iterator aEditIter;
+ for(aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter)
+ delete *aEditIter;
+ m_aFixedTexts.clear();
+ m_aEdits.clear();
+ m_bNoDataSet = true;
+ }
+ //now create appropriate controls
+
+ ::std::vector< OUString >::iterator aHeaderIter;
+
+ long nFTXPos = m_aWindow.LogicToPixel(Point(RSC_SP_CTRL_X, RSC_SP_CTRL_X), MAP_APPFONT).X();
+ long nFTHeight = m_aWindow.LogicToPixel(Size(RSC_BS_CHARHEIGHT, RSC_BS_CHARHEIGHT), MAP_APPFONT).Height();
+ long nFTWidth = 0;
+
+ //determine the width of the FixedTexts
+ for(aHeaderIter = m_pData->aDBColumnHeaders.begin();
+ aHeaderIter != m_pData->aDBColumnHeaders.end();
+ ++aHeaderIter)
+ {
+ sal_Int32 nTemp = m_aWindow.GetTextWidth(*aHeaderIter);
+ if(nTemp > nFTWidth)
+ nFTWidth = nTemp;
+ }
+ //add some pixels
+ nFTWidth += 2;
+ long nEDXPos = nFTWidth + nFTXPos +
+ m_aWindow.LogicToPixel(Size(RSC_SP_CTRL_DESC_X, RSC_SP_CTRL_DESC_X), MAP_APPFONT).Width();
+ long nEDHeight = m_aWindow.LogicToPixel(Size(RSC_CD_TEXTBOX_HEIGHT, RSC_CD_TEXTBOX_HEIGHT), MAP_APPFONT).Height();
+ long nEDWidth = m_aWinOutputSize.Width() - nEDXPos - nFTXPos;
+ m_nLineHeight = nEDHeight + m_aWindow.LogicToPixel(Size(RSC_SP_CTRL_GROUP_Y, RSC_SP_CTRL_GROUP_Y), MAP_APPFONT).Height();
+
+ long nEDYPos = m_aWindow.LogicToPixel(Size(RSC_SP_CTRL_DESC_Y, RSC_SP_CTRL_DESC_Y), MAP_APPFONT).Height();
+ long nFTYPos = nEDYPos + nEDHeight - nFTHeight;
+
+ Link aFocusLink = LINK(this, SwAddressControl_Impl, GotFocusHdl_Impl);
+ Link aEditModifyLink = LINK(this, SwAddressControl_Impl, EditModifyHdl_Impl);
+ Edit* pLastEdit = 0;
+ sal_Int32 nVisibleLines = 0;
+ sal_Int32 nLines = 0;
+ for(aHeaderIter = m_pData->aDBColumnHeaders.begin();
+ aHeaderIter != m_pData->aDBColumnHeaders.end();
+ ++aHeaderIter, nEDYPos += m_nLineHeight, nFTYPos += m_nLineHeight, nLines++)
+ {
+ FixedText* pNewFT = new FixedText(&m_aWindow, WB_RIGHT);
+ Edit* pNewED = new Edit(&m_aWindow, WB_BORDER);
+ //set nLines a position identifier - used in the ModifyHdl
+ pNewED->SetData((void*)nLines);
+ pNewED->SetGetFocusHdl(aFocusLink);
+ pNewED->SetModifyHdl(aEditModifyLink);
+
+ pNewFT->SetPosSizePixel(Point(nFTXPos, nFTYPos), Size(nFTWidth, nFTHeight));
+ pNewED->SetPosSizePixel(Point(nEDXPos, nEDYPos), Size(nEDWidth, nEDHeight));
+ if(nEDYPos + nEDHeight < m_aWinOutputSize.Height())
+ ++nVisibleLines;
+
+ pNewFT->SetText(*aHeaderIter);
+
+ pNewFT->Show();
+ pNewED->Show();
+ m_aFixedTexts.push_back(pNewFT);
+ m_aEdits.push_back(pNewED);
+ pLastEdit = pNewED;
+ }
+ //scrollbar adjustment
+ if(pLastEdit)
+ {
+ //the m_aWindow has to be at least as high as the ScrollBar and it must include the last Edit
+ sal_Int32 nContentHeight = pLastEdit->GetPosPixel().Y() + nEDHeight +
+ m_aWindow.LogicToPixel(Size(RSC_SP_CTRL_GROUP_Y, RSC_SP_CTRL_GROUP_Y), MAP_APPFONT).Height();
+ if(nContentHeight < m_aScrollBar.GetSizePixel().Height())
+ {
+ nContentHeight = m_aScrollBar.GetSizePixel().Height();
+ m_aScrollBar.Enable(FALSE);
+ }
+ else
+ {
+ m_aScrollBar.Enable(TRUE);
+ m_aScrollBar.SetRange(Range(0, nLines));
+ m_aScrollBar.SetThumbPos(0);
+ m_aScrollBar.SetVisibleSize(nVisibleLines);
+ }
+ Size aWinOutputSize(m_aWinOutputSize);
+ aWinOutputSize.Height() = nContentHeight;
+ m_aWindow.SetOutputSizePixel(aWinOutputSize);
+
+ }
+}
+/*-- 21.04.2004 11:37:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressControl_Impl::SetCurrentDataSet(sal_uInt32 nSet)
+{
+ if(m_bNoDataSet || m_nCurrentDataSet != nSet)
+ {
+ m_bNoDataSet = false;
+ m_nCurrentDataSet = nSet;
+ DBG_ASSERT(m_pData->aDBData.size() > m_nCurrentDataSet, "wrong data set index");
+ if(m_pData->aDBData.size() > m_nCurrentDataSet)
+ {
+ ::std::vector<Edit*>::iterator aEditIter;
+ sal_uInt32 nIndex = 0;
+ for(aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter, ++nIndex)
+ {
+ DBG_ASSERT(nIndex < m_pData->aDBData[m_nCurrentDataSet].size(),
+ "number of colums doesn't match number of Edits");
+ (*aEditIter)->SetText(m_pData->aDBData[m_nCurrentDataSet][nIndex]);
+ }
+ }
+ }
+}
+
+/*-- 19.04.2004 14:17:50---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddressControl_Impl, ScrollHdl_Impl, ScrollBar*, pScroll)
+{
+ long nThumb = pScroll->GetThumbPos();
+ m_aWindow.SetPosPixel(Point(0, - (m_nLineHeight * nThumb)));
+
+ return 0;
+}
+/*-- 19.04.2004 16:16:25---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddressControl_Impl, GotFocusHdl_Impl, Edit*, pEdit)
+{
+ if(0 != (GETFOCUS_TAB & pEdit->GetGetFocusFlags()))
+ {
+ Rectangle aRect(pEdit->GetPosPixel(), pEdit->GetSizePixel());
+ MakeVisible(aRect);
+ }
+ return 0;
+}
+/*-- 21.04.2004 14:56:54---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressControl_Impl::MakeVisible(const Rectangle & rRect)
+{
+ long nThumb = m_aScrollBar.GetThumbPos();
+ //determine range of visible positions
+ long nMinVisiblePos = - m_aWindow.GetPosPixel().Y();
+ long nMaxVisiblePos = m_aScrollBar.GetSizePixel().Height() + nMinVisiblePos;
+ if( rRect.TopLeft().Y() < nMinVisiblePos)
+ {
+ nThumb -= 1 + ((nMinVisiblePos - rRect.TopLeft().Y()) / m_nLineHeight);
+ }
+ else if(rRect.BottomLeft().Y() > nMaxVisiblePos)
+ {
+ nThumb += 1 + ((nMaxVisiblePos - rRect.BottomLeft().Y()) / m_nLineHeight);
+ }
+ if(nThumb != m_aScrollBar.GetThumbPos())
+ {
+ m_aScrollBar.SetThumbPos(nThumb);
+ ScrollHdl_Impl(&m_aScrollBar);
+ }
+}
+/*-- 19.04.2004 16:16:25---------------------------------------------------
+ copy data changes into database
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddressControl_Impl, EditModifyHdl_Impl, Edit*, pEdit)
+{
+ //get the data element number of the current set
+ sal_Int32 nIndex = (sal_Int32)(sal_IntPtr)pEdit->GetData();
+ //get the index of the set
+ DBG_ASSERT(m_pData->aDBData.size() > m_nCurrentDataSet, "wrong data set index" );
+ if(m_pData->aDBData.size() > m_nCurrentDataSet)
+ {
+ m_pData->aDBData[m_nCurrentDataSet][nIndex] = pEdit->GetText();
+ }
+ return 0;
+}
+/*-- 21.04.2004 14:51:54---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressControl_Impl::SetCursorTo(sal_uInt32 nElement)
+{
+ if(nElement < m_aEdits.size())
+ {
+ Edit* pEdit = m_aEdits[nElement];
+ pEdit->GrabFocus();
+ Rectangle aRect(pEdit->GetPosPixel(), pEdit->GetSizePixel());
+ MakeVisible(aRect);
+ }
+
+}
+/*-- 19.04.2004 16:16:25---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressControl_Impl::Command( const CommandEvent& rCEvt )
+{
+ switch ( rCEvt.GetCommand() )
+ {
+ case COMMAND_WHEEL:
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ {
+ const CommandWheelData* pWheelData = rCEvt.GetWheelData();
+ if(pWheelData && !pWheelData->IsHorz() && COMMAND_WHEEL_ZOOM != pWheelData->GetMode())
+ {
+ HandleScrollCommand( rCEvt, 0, &m_aScrollBar );
+ }
+ }
+ break;
+ default:
+ Control::Command(rCEvt);
+ }
+}
+/*-- 19.04.2004 16:16:25---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+long SwAddressControl_Impl::PreNotify( NotifyEvent& rNEvt )
+{
+ if(rNEvt.GetType() == EVENT_COMMAND)
+ {
+ const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
+ USHORT nCmd = pCEvt->GetCommand();
+ if( COMMAND_WHEEL == nCmd )
+ {
+ Command(*pCEvt);
+ return 1;
+ }
+ }
+ return Control::PreNotify(rNEvt);
+}
+/*-- 13.04.2004 10:08:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwCreateAddressListDialog::SwCreateAddressListDialog(
+ Window* pParent, const String& rURL, SwMailMergeConfigItem& rConfig) :
+ SfxModalDialog(pParent, SW_RES(DLG_MM_CREATEADDRESSLIST)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aAddressInformation( this, SW_RES( FI_ADDRESSINFORMATION)),
+ m_pAddressControl(new SwAddressControl_Impl(this, SW_RES(CT_ADDRESS))),
+ m_aNewPB( this, SW_RES( PB_NEW)),
+ m_aDeletePB( this, SW_RES( PB_DELETE)),
+ m_aFindPB( this, SW_RES( PB_FIND)),
+ m_aCustomizePB( this, SW_RES( PB_CUSTOMIZE)),
+
+ m_aViewEntriesFI( this, SW_RES( FI_VIEWENTRIES)),
+ m_aStartPB( this, SW_RES( PB_START)),
+ m_aPrevPB( this, SW_RES( PB_PREV)),
+ m_aSetNoNF( this, SW_RES( NF_SETNO)),
+ m_aNextPB( this, SW_RES( PB_NEXT )),
+ m_aEndPB( this, SW_RES( PB_END)),
+
+ 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_sAddressListFilterName( SW_RES( ST_FILTERNAME)),
+ m_sURL(rURL),
+ m_pCSVData( new SwCSVData ),
+ m_pFindDlg(0)
+{
+ FreeResource();
+ m_aNewPB.SetClickHdl(LINK(this, SwCreateAddressListDialog, NewHdl_Impl));
+ m_aDeletePB.SetClickHdl(LINK(this, SwCreateAddressListDialog, DeleteHdl_Impl));
+ m_aFindPB.SetClickHdl(LINK(this, SwCreateAddressListDialog, FindHdl_Impl));
+ m_aCustomizePB.SetClickHdl(LINK(this, SwCreateAddressListDialog, CustomizeHdl_Impl));
+ m_aOK.SetClickHdl(LINK(this, SwCreateAddressListDialog, OkHdl_Impl));
+
+ Link aLk = LINK(this, SwCreateAddressListDialog, DBCursorHdl_Impl);
+ m_aStartPB.SetClickHdl(aLk);
+ m_aPrevPB.SetClickHdl(aLk);
+ m_aSetNoNF.SetModifyHdl(LINK(this, SwCreateAddressListDialog, DBNumCursorHdl_Impl));
+ m_aNextPB.SetClickHdl(aLk);
+ m_aEndPB.SetClickHdl(aLk);
+
+ if(m_sURL.Len())
+ {
+ //file exists, has to be loaded here
+ SfxMedium aMedium( m_sURL, STREAM_READ, TRUE );
+ SvStream* pStream = aMedium.GetInStream();
+ if(pStream)
+ {
+ pStream->SetLineDelimiter( LINEEND_LF );
+ pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
+
+ OUString sSemi(';');
+ OUString sQuote('"');
+ String sTempMiddle(sQuote);
+ sTempMiddle += sal_Unicode(9);
+ OUString sMiddle(sTempMiddle);
+
+ String sLine;
+ BOOL bRead = pStream->ReadUniOrByteStringLine( sLine, RTL_TEXTENCODING_UTF8 );
+
+ if(bRead)
+ {
+ //header line
+ xub_StrLen nHeaders = sLine.GetTokenCount('\t');
+ xub_StrLen nIndex = 0;
+ for( xub_StrLen nToken = 0; nToken < nHeaders; ++nToken)
+ {
+ String sHeader = sLine.GetToken( 0, '\t', nIndex );
+ DBG_ASSERT(sHeader.Len() > 2 &&
+ sHeader.GetChar(0) == '\"' && sHeader.GetChar(sHeader.Len() - 1) == '\"',
+ "Wrong format of header");
+ if(sHeader.Len() > 2)
+ {
+ m_pCSVData->aDBColumnHeaders.push_back( sHeader.Copy(1, sHeader.Len() -2));
+ }
+ }
+ }
+ while(pStream->ReadUniOrByteStringLine( sLine, RTL_TEXTENCODING_UTF8 ))
+ {
+ ::std::vector<OUString> aNewData;
+ //analyze data line
+ xub_StrLen nDataCount = sLine.GetTokenCount('\t');
+ xub_StrLen nIndex = 0;
+ for( xub_StrLen nToken = 0; nToken < nDataCount; ++nToken)
+ {
+ String sData = sLine.GetToken( 0, '\t', nIndex );
+ DBG_ASSERT(sData.Len() >= 2 &&
+ sData.GetChar(0) == '\"' && sData.GetChar(sData.Len() - 1) == '\"',
+ "Wrong format of line");
+ if(sData.Len() >= 2)
+ aNewData.push_back(sData.Copy(1, sData.Len() - 2));
+ else
+ aNewData.push_back(sData);
+ }
+ m_pCSVData->aDBData.push_back( aNewData );
+ }
+ }
+ }
+ else
+ {
+ //database has to be created
+ const ResStringArray& rAddressHeader = rConfig.GetDefaultAddressHeaders();
+ sal_uInt32 nCount = rAddressHeader.Count();
+ for(USHORT nHeader = 0; nHeader < nCount; ++nHeader)
+ m_pCSVData->aDBColumnHeaders.push_back( rAddressHeader.GetString(nHeader));
+ ::std::vector<OUString> aNewData;
+ String sTemp;
+ aNewData.insert(aNewData.begin(), nCount, sTemp);
+ m_pCSVData->aDBData.push_back(aNewData);
+ }
+ //now fill the address control
+ m_pAddressControl->SetData(*m_pCSVData);
+ m_pAddressControl->SetCurrentDataSet(0);
+ m_aSetNoNF.SetMax(m_pCSVData->aDBData.size());
+ UpdateButtons();
+}
+/*-- 13.04.2004 10:08:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwCreateAddressListDialog::~SwCreateAddressListDialog()
+{
+ delete m_pAddressControl;
+ delete m_pCSVData;
+ delete m_pFindDlg;
+}
+/*-- 13.04.2004 10:08:59---------------------------------------------------
+ add a new data set of empty strings and set the address input control
+ to that new set
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCreateAddressListDialog, NewHdl_Impl, PushButton*, EMPTYARG)
+{
+ sal_uInt32 nCurrent = m_pAddressControl->GetCurrentDataSet();
+ ::std::vector<OUString> aNewData;
+ String sTemp;
+ aNewData.insert(aNewData.begin(), m_pCSVData->aDBColumnHeaders.size(), sTemp);
+ m_pCSVData->aDBData.insert(m_pCSVData->aDBData.begin() + ++nCurrent, aNewData);
+ m_aSetNoNF.SetMax(m_pCSVData->aDBData.size());
+ //the NumericField start at 1
+ m_aSetNoNF.SetValue(nCurrent + 1);
+ //the address control starts at 0
+ m_pAddressControl->SetCurrentDataSet(nCurrent);
+ UpdateButtons();
+ return 0;
+}
+/*-- 13.04.2004 10:09:00---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCreateAddressListDialog, DeleteHdl_Impl, PushButton*, EMPTYARG)
+{
+ sal_uInt32 nCurrent = m_pAddressControl->GetCurrentDataSet();
+ if(m_pCSVData->aDBData.size() > 1)
+ {
+ m_pCSVData->aDBData.erase(m_pCSVData->aDBData.begin() + nCurrent);
+ if(nCurrent)
+ --nCurrent;
+ }
+ else
+ {
+ // if only one set is available then clear the data
+ String sTemp;
+ m_pCSVData->aDBData[0].assign(m_pCSVData->aDBData[0].size(), sTemp);
+ m_aDeletePB.Enable(FALSE);
+ }
+ m_pAddressControl->SetCurrentDataSet(nCurrent);
+ m_aSetNoNF.SetMax(m_pCSVData->aDBData.size());
+ UpdateButtons();
+ return 0;
+}
+/*-- 13.04.2004 10:09:00---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCreateAddressListDialog, FindHdl_Impl, PushButton*, EMPTYARG)
+{
+ if(!m_pFindDlg)
+ {
+ m_pFindDlg = new SwFindEntryDialog(this);
+ ListBox& rColumnBox = m_pFindDlg->GetFieldsListBox();
+ ::std::vector< OUString >::iterator aHeaderIter;
+ for(aHeaderIter = m_pCSVData->aDBColumnHeaders.begin();
+ aHeaderIter != m_pCSVData->aDBColumnHeaders.end();
+ ++aHeaderIter)
+ rColumnBox.InsertEntry(*aHeaderIter);
+ rColumnBox.SelectEntryPos( 0 );
+ }
+ else
+ m_pFindDlg->Show(!m_pFindDlg->IsVisible());
+ return 0;
+}
+/*-- 13.04.2004 10:09:00---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCreateAddressListDialog, CustomizeHdl_Impl, PushButton*, pButton)
+{
+ SwCustomizeAddressListDialog* pDlg = new SwCustomizeAddressListDialog(pButton, *m_pCSVData);
+ if(RET_OK == pDlg->Execute())
+ {
+ delete m_pCSVData;
+ m_pCSVData = pDlg->GetNewData();
+ m_pAddressControl->SetData(*m_pCSVData);
+ m_pAddressControl->SetCurrentDataSet(m_pAddressControl->GetCurrentDataSet());
+ }
+ delete pDlg;
+
+ //update find dialog
+ if(m_pFindDlg)
+ {
+ ListBox& rColumnBox = m_pFindDlg->GetFieldsListBox();
+ rColumnBox.Clear();
+ ::std::vector< OUString >::iterator aHeaderIter;
+ for(aHeaderIter = m_pCSVData->aDBColumnHeaders.begin();
+ aHeaderIter != m_pCSVData->aDBColumnHeaders.end();
+ ++aHeaderIter)
+ rColumnBox.InsertEntry(*aHeaderIter);
+ }
+ return 0;
+}
+/*-- 23.04.2004 09:02:51---------------------------------------------------
+ writes the data into a .csv file
+ encoding is UTF8, separator is tab, strings are enclosed into "
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCreateAddressListDialog, OkHdl_Impl, PushButton*, EMPTYARG)
+{
+ if(!m_sURL.Len())
+ {
+ sfx2::FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_SIMPLE, 0 );
+ uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
+
+ String sPath( SvtPathOptions().SubstituteVariable(
+ String::CreateFromAscii("$(userurl)/database") ));
+ aDlgHelper.SetDisplayDirectory( sPath );
+ uno::Reference< XFilterManager > xFltMgr(xFP, uno::UNO_QUERY);
+ ::rtl::OUString sCSV(C2U("*.csv"));
+ xFltMgr->appendFilter( m_sAddressListFilterName, sCSV );
+ xFltMgr->setCurrentFilter( m_sAddressListFilterName ) ;
+
+ if( ERRCODE_NONE == aDlgHelper.Execute() )
+ {
+ m_sURL = xFP->getFiles().getConstArray()[0];
+ INetURLObject aResult( m_sURL );
+ aResult.setExtension(String::CreateFromAscii("csv"));
+ m_sURL = aResult.GetMainURL(INetURLObject::NO_DECODE);
+ }
+ }
+ if(m_sURL.Len())
+ {
+ SfxMedium aMedium( m_sURL, STREAM_READWRITE|STREAM_TRUNC, TRUE );
+ SvStream* pStream = aMedium.GetOutStream();
+ pStream->SetLineDelimiter( LINEEND_LF );
+ pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
+
+ OUString sSemi(';');
+ OUString sQuote('"');
+ String sTempMiddle(sQuote);
+ sTempMiddle += sal_Unicode(9);
+ OUString sMiddle(sTempMiddle);
+ sMiddle += sQuote;
+
+ //create a string for the header line
+ OUString sLine(sQuote);
+ ::std::vector< OUString >::iterator aHeaderIter;
+ for(aHeaderIter = m_pCSVData->aDBColumnHeaders.begin();
+ aHeaderIter != m_pCSVData->aDBColumnHeaders.end();
+ ++aHeaderIter)
+ {
+ sLine += *aHeaderIter;
+ sLine += sMiddle;
+ }
+ //remove tab and quote
+ sLine = sLine.copy( 0, sLine.getLength() - 2 );
+ pStream->WriteUnicodeOrByteText( sLine, RTL_TEXTENCODING_UTF8 );
+ endl(*pStream);
+
+ ::std::vector< ::std::vector< OUString > >::iterator aDataIter;
+ for( aDataIter = m_pCSVData->aDBData.begin(); aDataIter != m_pCSVData->aDBData.end(); ++aDataIter)
+ {
+ sLine = sQuote;
+ ::std::vector< OUString >::iterator aColumnIter;
+ for(aColumnIter = aDataIter->begin(); aColumnIter != aDataIter->end(); ++aColumnIter)
+ {
+ sLine += *aColumnIter;
+ sLine += sMiddle;
+ }
+ //remove tab and quote
+ sLine = sLine.copy( 0, sLine.getLength() - 2 );
+ pStream->WriteUnicodeOrByteText( sLine, RTL_TEXTENCODING_UTF8 );
+ endl(*pStream);
+ }
+ aMedium.Commit();
+ EndDialog(RET_OK);
+ }
+
+ return 0;
+}
+/*-- 13.04.2004 10:09:01---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCreateAddressListDialog, DBCursorHdl_Impl, PushButton*, pButton)
+{
+ sal_uInt32 nValue = static_cast< sal_uInt32 >(m_aSetNoNF.GetValue());
+
+ if(pButton == &m_aStartPB)
+ nValue = 1;
+ else if(pButton == &m_aPrevPB)
+ {
+ if(nValue > 1)
+ --nValue;
+ }
+ else if(pButton == &m_aNextPB)
+ {
+ if(nValue < (sal_uInt32)m_aSetNoNF.GetMax())
+ ++nValue;
+ }
+ else //m_aEndPB
+ nValue = static_cast< sal_uInt32 >(m_aSetNoNF.GetMax());
+ if(nValue != m_aSetNoNF.GetValue())
+ {
+ m_aSetNoNF.SetValue(nValue);
+ DBNumCursorHdl_Impl(&m_aSetNoNF);
+ }
+ return 0;
+}
+/*-- 21.04.2004 12:06:47---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCreateAddressListDialog, DBNumCursorHdl_Impl, NumericField*, EMPTYARG)
+{
+ m_pAddressControl->SetCurrentDataSet( static_cast< sal_uInt32 >(m_aSetNoNF.GetValue() - 1) );
+ UpdateButtons();
+ return 0;
+}
+/*-- 21.04.2004 13:22:27---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwCreateAddressListDialog::UpdateButtons()
+{
+ sal_uInt32 nCurrent = static_cast< sal_uInt32 >(m_aSetNoNF.GetValue() );
+ sal_uInt32 nSize = (sal_uInt32 )m_pCSVData->aDBData.size();
+ m_aStartPB.Enable(nCurrent != 1);
+ m_aPrevPB.Enable(nCurrent != 1);
+ m_aNextPB.Enable(nCurrent != nSize);
+ m_aEndPB.Enable(nCurrent != nSize);
+ m_aDeletePB.Enable(nSize > 0);
+}
+/*-- 21.04.2004 13:22:27---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwCreateAddressListDialog::Find(const String& rSearch, sal_Int32 nColumn)
+{
+ OUString sSearch = rSearch;
+ sSearch.toAsciiLowerCase();
+ sal_uInt32 nCurrent = m_pAddressControl->GetCurrentDataSet();
+ //search forward
+ bool bFound = false;
+ sal_uInt32 nStart = nCurrent + 1;
+ sal_uInt32 nEnd = m_pCSVData->aDBData.size();
+ sal_uInt32 nElement = 0;
+ sal_uInt32 nPos = 0;
+ for(short nTemp = 0; nTemp < 2 && !bFound; nTemp++)
+ {
+ for(nPos = nStart; nPos < nEnd; ++nPos)
+ {
+ ::std::vector< OUString> aData = m_pCSVData->aDBData[nPos];
+ if(nColumn >=0)
+ bFound = -1 != aData[(sal_uInt32)nColumn].toAsciiLowerCase().indexOf(sSearch);
+ else
+ {
+ for( nElement = 0; nElement < aData.size(); ++nElement)
+ {
+ bFound = -1 != aData[nElement].toAsciiLowerCase().indexOf(sSearch);
+ if(bFound)
+ {
+ nColumn = nElement;
+ break;
+ }
+ }
+ }
+ if(bFound)
+ break;
+ }
+ nStart = 0;
+ nEnd = nCurrent + 1;
+ }
+ if(bFound)
+ {
+ m_pAddressControl->SetCurrentDataSet(nPos);
+ m_aSetNoNF.SetValue( nPos + 1 );
+ UpdateButtons();
+ m_pAddressControl->SetCursorTo(nElement);
+ }
+}
+/*-- 13.04.2004 13:48:38---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwFindEntryDialog::SwFindEntryDialog(SwCreateAddressListDialog* pParent) :
+ ModelessDialog(pParent, SW_RES(DLG_MM_FIND_ENTRY)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aFindFT( this, SW_RES( FT_FIND )),
+ m_aFindED( this, SW_RES( ED_FIND )),
+ m_aFindOnlyCB( this, SW_RES( CB_FINDONLY )),
+ m_aFindOnlyLB( this, SW_RES( LB_FINDONLY )),
+ m_aFindPB( this, SW_RES( PB_FIND)),
+ m_aCancel( this, SW_RES( PB_CANCEL)),
+ m_aHelp( this, SW_RES( PB_HELP)),
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+ m_pParent(pParent)
+{
+ FreeResource();
+ m_aFindPB.SetClickHdl(LINK(this, SwFindEntryDialog, FindHdl_Impl));
+ m_aFindED.SetModifyHdl(LINK(this, SwFindEntryDialog, FindEnableHdl_Impl));
+ m_aCancel.SetClickHdl(LINK(this, SwFindEntryDialog, CloseHdl_Impl));
+}
+/*-- 13.04.2004 13:48:38---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwFindEntryDialog::~SwFindEntryDialog()
+{
+}
+/*-- 21.04.2004 13:37:46---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwFindEntryDialog, FindHdl_Impl, PushButton*, EMPTYARG)
+{
+ sal_Int32 nColumn = -1;
+ if(m_aFindOnlyCB.IsChecked())
+ nColumn = m_aFindOnlyLB.GetSelectEntryPos();
+ if(nColumn != LISTBOX_ENTRY_NOTFOUND)
+ m_pParent->Find(m_aFindED.GetText(), nColumn);
+ return 0;
+}
+/*-- 21.04.2004 13:37:46---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwFindEntryDialog, FindEnableHdl_Impl, Edit*, EMPTYARG)
+{
+ m_aFindPB.Enable(m_aFindED.GetText().Len() > 0);
+ return 0;
+}
+/*-- 21.04.2004 15:36:36---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwFindEntryDialog, CloseHdl_Impl, PushButton*, EMPTYARG)
+{
+ Show(FALSE);
+ return 0;
+}
diff --git a/sw/source/ui/dbui/createaddresslistdialog.hrc b/sw/source/ui/dbui/createaddresslistdialog.hrc
new file mode 100644
index 000000000000..163b67bc6588
--- /dev/null
+++ b/sw/source/ui/dbui/createaddresslistdialog.hrc
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: createaddresslistdialog.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _CREATEADDRESSLISTDIALOG_HRC
+#define _CREATEADDRESSLISTDIALOG_HRC
+
+#define FI_ADDRESSINFORMATION 1
+#define CT_ADDRESS 2
+#define PB_NEW 3
+#define PB_DELETE 4
+#define PB_FIND 5
+#define PB_CUSTOMIZE 6
+#define FI_VIEWENTRIES 7
+#define PB_START 8
+#define PB_PREV 9
+#define NF_SETNO 10
+#define PB_NEXT 11
+#define PB_END 12
+#define FL_SEPARATOR 13
+#define PB_OK 14
+#define PB_CANCEL 15
+#define PB_HELP 16
+
+#define ST_FILTERNAME 18
+
+#define SCR_1 1
+#define WIN_DATA 2
+
+#define FT_FIND 1
+#define ED_FIND 2
+#define CB_FINDONLY 3
+#define LB_FINDONLY 4
+
+#define FT_FIELDNAME 1
+#define ED_FIELDNAME 2
+#define ST_RENAME_TITLE 3
+#define ST_ADD_BUTTON 4
+#define PB_FIND 5
+
+
+#endif
diff --git a/sw/source/ui/dbui/createaddresslistdialog.hxx b/sw/source/ui/dbui/createaddresslistdialog.hxx
new file mode 100644
index 000000000000..51197b03952e
--- /dev/null
+++ b/sw/source/ui/dbui/createaddresslistdialog.hxx
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: createaddresslistdialog.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _CREATEADDRESSLISTDIALOG_HXX
+#define _CREATEADDRESSLISTDIALOG_HXX
+
+#include <sfx2/basedlgs.hxx>
+
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <svtools/stdctrl.hxx>
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+#include <vector>
+
+class SwAddressControl_Impl;
+class SwMailMergeConfigItem;
+/*-- 19.04.2004 12:09:46---------------------------------------------------
+ container of the created database
+ -----------------------------------------------------------------------*/
+struct SwCSVData
+{
+ ::std::vector< ::rtl::OUString > aDBColumnHeaders;
+ ::std::vector< ::std::vector< ::rtl::OUString> > aDBData;
+};
+/*-- 08.04.2004 14:04:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwFindEntryDialog;
+class SwCreateAddressListDialog : public SfxModalDialog
+{
+ FixedInfo m_aAddressInformation;
+ SwAddressControl_Impl* m_pAddressControl;
+
+ PushButton m_aNewPB;
+ PushButton m_aDeletePB;
+ PushButton m_aFindPB;
+ PushButton m_aCustomizePB;
+
+ FixedInfo m_aViewEntriesFI;
+ PushButton m_aStartPB;
+ PushButton m_aPrevPB;
+ NumericField m_aSetNoNF;
+ PushButton m_aNextPB;
+ PushButton m_aEndPB;
+
+ FixedLine m_aSeparatorFL;
+
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ String m_sAddressListFilterName;
+ String m_sURL;
+
+ SwCSVData* m_pCSVData;
+ SwFindEntryDialog* m_pFindDlg;
+
+ DECL_LINK(NewHdl_Impl, PushButton*);
+ DECL_LINK(DeleteHdl_Impl, PushButton*);
+ DECL_LINK(FindHdl_Impl, PushButton*);
+ DECL_LINK(CustomizeHdl_Impl, PushButton*);
+ DECL_LINK(OkHdl_Impl, PushButton*);
+ DECL_LINK(DBCursorHdl_Impl, PushButton*);
+ DECL_LINK(DBNumCursorHdl_Impl, NumericField*);
+
+ void UpdateButtons();
+
+public:
+ SwCreateAddressListDialog(
+ Window* pParent, const String& rURL, SwMailMergeConfigItem& rConfig);
+ ~SwCreateAddressListDialog();
+
+ const String& GetURL() const { return m_sURL; }
+ void Find( const String& rSearch, sal_Int32 nColumn);
+};
+/*-- 13.04.2004 13:30:21---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwFindEntryDialog : public ModelessDialog
+{
+ FixedText m_aFindFT;
+ Edit m_aFindED;
+ CheckBox m_aFindOnlyCB;
+ ListBox m_aFindOnlyLB;
+
+ PushButton m_aFindPB;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ SwCreateAddressListDialog* m_pParent;
+
+ DECL_LINK(FindHdl_Impl, PushButton*);
+ DECL_LINK(FindEnableHdl_Impl, Edit*);
+ DECL_LINK(CloseHdl_Impl, PushButton*);
+
+public:
+ SwFindEntryDialog(SwCreateAddressListDialog* pParent);
+ ~SwFindEntryDialog();
+
+ ListBox& GetFieldsListBox(){return m_aFindOnlyLB;}
+ String GetFindString() const {return m_aFindED.GetText();}
+};
+
+#endif
+
diff --git a/sw/source/ui/dbui/createaddresslistdialog.src b/sw/source/ui/dbui/createaddresslistdialog.src
new file mode 100644
index 000000000000..7e10679f02af
--- /dev/null
+++ b/sw/source/ui/dbui/createaddresslistdialog.src
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: createaddresslistdialog.src,v $
+ * $Revision: 1.9 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <createaddresslistdialog.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+/*-- 13.04.2004 13:58:13---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+ModalDialog DLG_MM_CREATEADDRESSLIST
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_CREATEADDRESSLIST;
+ Size = MAP_APPFONT ( 318 , 231 ) ;
+ Moveable = TRUE ;
+
+ Text [ en-US ] = "New Address List";
+
+ FixedText FI_ADDRESSINFORMATION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 150 , 8 ) ;
+ Text [ en-US ] = "Address Information";
+ };
+ Control CT_ADDRESS
+ {
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 250 , 160 ) ;
+ Border = TRUE;
+ DialogControl = TRUE;
+ OutputSize = TRUE ;
+
+ ScrollBar SCR_1
+ {
+ Pos = MAP_APPFONT ( 240 , 0 ) ;
+ Size = MAP_APPFONT ( 10 , 160 ) ;
+ };
+ Window WIN_DATA
+ {
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 240 , 160 ) ;
+ DialogControl = TRUE;
+ };
+ };
+ PushButton PB_NEW
+ {
+ Pos = MAP_APPFONT ( 262 , 14 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~New";
+ };
+ PushButton PB_DELETE
+ {
+ Pos = MAP_APPFONT ( 262 , 32 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Delete";
+ };
+ PushButton PB_FIND
+ {
+ Pos = MAP_APPFONT ( 262 , 50 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Find...";
+ };
+ PushButton PB_CUSTOMIZE
+ {
+ Pos = MAP_APPFONT ( 262 , 68 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "C~ustomize...";
+ };
+ FixedText FI_VIEWENTRIES
+ {
+ Pos = MAP_APPFONT ( 6 , 183 ) ;
+ Size = MAP_APPFONT ( 92 , 8 ) ;
+ Text [ en-US ] = "Sho~w entry number";
+ };
+ PushButton PB_START
+ {
+ Pos = MAP_APPFONT ( 100 , 180 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ Text = "|<";
+ };
+ PushButton PB_PREV
+ {
+ Pos = MAP_APPFONT ( 123 , 180 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ Text = "<";
+ };
+ NumericField NF_SETNO
+ {
+ Pos = MAP_APPFONT ( 146 , 180 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ Border = TRUE;
+ Left = TRUE ;
+ First = 1 ;
+ Minimum = 1 ;
+ Value = 1;
+ Repeat = TRUE ;
+ Spin = FALSE ;
+ TabStop = TRUE ;
+ };
+ PushButton PB_NEXT
+ {
+ Pos = MAP_APPFONT ( 169 , 180 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ Text = ">";
+ };
+ PushButton PB_END
+ {
+ Pos = MAP_APPFONT ( 192 , 180 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ Text = ">|";
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 200 ) ;
+ Size = MAP_APPFONT ( 318 , 8 ) ;
+ };
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 153 , 211 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 206 , 211 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 262 , 211 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+
+ String ST_FILTERNAME
+ {
+ Text [ en-US ] = "%PRODUCTNAME Address List (.csv)";
+ };
+};
+
+/*-- 13.04.2004 13:58:13---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+ModelessDialog DLG_MM_FIND_ENTRY
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_FIND_ENTRY;
+ Size = MAP_APPFONT ( 188 , 63 ) ;
+ Moveable = TRUE ;
+
+ Text [ en-US ] = "Find Entry";
+
+ FixedText FT_FIND
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 120 , 8 ) ;
+ Text [ en-US ] = "F~ind";
+ };
+ Edit ED_FIND
+ {
+ Pos = MAP_APPFONT ( 6 , 14) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ Border = TRUE;
+ };
+ CheckBox CB_FINDONLY
+ {
+ Pos = MAP_APPFONT ( 6 , 32 ) ;
+ Size = MAP_APPFONT ( 120 , 10 ) ;
+ Text [ en-US ] = "Find ~only in";
+ };
+ ListBox LB_FINDONLY
+ {
+ Pos = MAP_APPFONT ( 12 , 45 ) ;
+ Size = MAP_APPFONT ( 114 , 50 ) ;
+ Border = TRUE;
+ DropDown = TRUE;
+ };
+ PushButton PB_FIND
+ {
+ Pos = MAP_APPFONT ( 132 , 3 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE;
+ Text [ en-US ] = "~Find";
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 132 , 20 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Close";
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 132 , 40 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
+
diff --git a/sw/source/ui/dbui/customizeaddresslistdialog.cxx b/sw/source/ui/dbui/customizeaddresslistdialog.cxx
new file mode 100644
index 000000000000..dd4258f7bae8
--- /dev/null
+++ b/sw/source/ui/dbui/customizeaddresslistdialog.cxx
@@ -0,0 +1,277 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: customizeaddresslistdialog.cxx,v $
+ * $Revision: 1.10 $
+ *
+ * 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 <swtypes.hxx>
+#include <customizeaddresslistdialog.hxx>
+#include <createaddresslistdialog.hxx>
+#include <vcl/scrbar.hxx>
+#include <vcl/msgbox.hxx>
+#include <customizeaddresslistdialog.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+
+
+/*-- 13.04.2004 14:27:21---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwCustomizeAddressListDialog::SwCustomizeAddressListDialog(
+ Window* pParent, const SwCSVData& rOldData) :
+ SfxModalDialog(pParent, SW_RES(DLG_MM_CUSTOMIZE_ADDRESS_LIST)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aFieldsFT( this, SW_RES( FT_FIELDS)),
+ m_aFieldsLB( this, SW_RES( LB_FIELDS)),
+ m_aAddPB( this, SW_RES( PB_ADD)),
+ m_aDeletePB( this, SW_RES( PB_DELETE)),
+ m_aRenamePB( this, SW_RES( PB_RENAME)),
+ m_aUpPB( this, SW_RES( PB_UP)),
+ m_aDownPB( this, SW_RES( PB_DOWN)),
+ 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_pNewData( new SwCSVData(rOldData))
+{
+ FreeResource();
+ m_aFieldsLB.SetSelectHdl(LINK(this, SwCustomizeAddressListDialog, ListBoxSelectHdl_Impl));
+ Link aAddRenameLk = LINK(this, SwCustomizeAddressListDialog, AddRenameHdl_Impl );
+ m_aAddPB.SetClickHdl(aAddRenameLk);
+ m_aRenamePB.SetClickHdl(aAddRenameLk);
+ m_aDeletePB.SetClickHdl(LINK(this, SwCustomizeAddressListDialog, DeleteHdl_Impl ));
+ Link aUpDownLk = LINK(this, SwCustomizeAddressListDialog, UpDownHdl_Impl);
+ m_aUpPB.SetClickHdl(aUpDownLk);
+ m_aDownPB.SetClickHdl(aUpDownLk);
+
+ ::std::vector< ::rtl::OUString >::iterator aHeaderIter;
+
+ for(aHeaderIter = m_pNewData->aDBColumnHeaders.begin();
+ aHeaderIter != m_pNewData->aDBColumnHeaders.end(); ++aHeaderIter)
+ m_aFieldsLB.InsertEntry(*aHeaderIter);
+
+ m_aFieldsLB.SelectEntryPos(0);
+ UpdateButtons();
+}
+/*-- 13.04.2004 14:34:07---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwCustomizeAddressListDialog::~SwCustomizeAddressListDialog()
+{
+}
+
+/*-- 12.08.2004 12:58:00---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCustomizeAddressListDialog, ListBoxSelectHdl_Impl, ListBox*, EMPTYARG)
+{
+ UpdateButtons();
+ return 0;
+}
+/*-- 13.04.2004 15:02:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCustomizeAddressListDialog, AddRenameHdl_Impl, PushButton*, pButton)
+{
+ bool bRename = pButton == &m_aRenamePB;
+ USHORT nPos = m_aFieldsLB.GetSelectEntryPos();
+ if(nPos == LISTBOX_ENTRY_NOTFOUND)
+ nPos = 0;
+
+ SwAddRenameEntryDialog* pDlg =
+ new SwAddRenameEntryDialog(pButton, bRename, m_pNewData->aDBColumnHeaders);
+ if(bRename)
+ {
+ String aTemp = m_aFieldsLB.GetEntry(nPos);
+ pDlg->SetFieldName(aTemp);
+ }
+ if(RET_OK == pDlg->Execute())
+ {
+ String sNew = pDlg->GetFieldName();
+ if(bRename)
+ {
+ m_pNewData->aDBColumnHeaders[nPos] = sNew;
+ m_aFieldsLB.RemoveEntry(nPos);
+ }
+ else
+ {
+ if ( m_aFieldsLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
+ ++nPos; // append the new entry behind the selected
+ //add the new column
+ m_pNewData->aDBColumnHeaders.insert(m_pNewData->aDBColumnHeaders.begin() + nPos, sNew);
+ //add a new entry into all data arrays
+ String sTemp;
+ ::std::vector< ::std::vector< ::rtl::OUString > >::iterator aDataIter;
+ for( aDataIter = m_pNewData->aDBData.begin(); aDataIter != m_pNewData->aDBData.end(); ++aDataIter)
+ aDataIter->insert(aDataIter->begin() + nPos, sTemp);
+
+ }
+
+ m_aFieldsLB.InsertEntry(sNew, nPos);
+ m_aFieldsLB.SelectEntryPos(nPos);
+ }
+ delete pDlg;
+ UpdateButtons();
+ return 0;
+}
+/*-- 13.04.2004 15:02:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCustomizeAddressListDialog, DeleteHdl_Impl, PushButton*, EMPTYARG)
+{
+ USHORT nPos = m_aFieldsLB.GetSelectEntryPos();
+ m_aFieldsLB.RemoveEntry(m_aFieldsLB.GetSelectEntryPos());
+ m_aFieldsLB.SelectEntryPos(nPos > m_aFieldsLB.GetEntryCount() - 1 ? nPos - 1 : nPos);
+
+ //remove the column
+ m_pNewData->aDBColumnHeaders.erase(m_pNewData->aDBColumnHeaders.begin() + nPos);
+ //remove the data
+ ::std::vector< ::std::vector< ::rtl::OUString > >::iterator aDataIter;
+ for( aDataIter = m_pNewData->aDBData.begin(); aDataIter != m_pNewData->aDBData.end(); ++aDataIter)
+ aDataIter->erase(aDataIter->begin() + nPos);
+
+ UpdateButtons();
+ return 0;
+}
+/*-- 13.04.2004 15:02:15---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCustomizeAddressListDialog, UpDownHdl_Impl, PushButton*, pButton)
+{
+ USHORT nPos;
+ USHORT nOldPos = nPos = m_aFieldsLB.GetSelectEntryPos();
+ String aTemp = m_aFieldsLB.GetEntry(nPos);
+ m_aFieldsLB.RemoveEntry( nPos );
+ if(pButton == &m_aUpPB)
+ --nPos;
+ else
+ ++nPos;
+ m_aFieldsLB.InsertEntry(aTemp, nPos);
+ m_aFieldsLB.SelectEntryPos(nPos);
+ //align m_pNewData
+ ::rtl::OUString sHeader = m_pNewData->aDBColumnHeaders[nOldPos];
+ m_pNewData->aDBColumnHeaders.erase(m_pNewData->aDBColumnHeaders.begin() + nOldPos);
+ m_pNewData->aDBColumnHeaders.insert(m_pNewData->aDBColumnHeaders.begin() + nPos, sHeader);
+ ::std::vector< ::std::vector< ::rtl::OUString > >::iterator aDataIter;
+ for( aDataIter = m_pNewData->aDBData.begin(); aDataIter != m_pNewData->aDBData.end(); ++aDataIter)
+ {
+ ::rtl::OUString sData = (*aDataIter)[nOldPos];
+ aDataIter->erase(aDataIter->begin() + nOldPos);
+ aDataIter->insert(aDataIter->begin() + nPos, sData);
+ }
+
+ UpdateButtons();
+ return 0;
+}
+/*-- 19.04.2004 14:51:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwCustomizeAddressListDialog::UpdateButtons()
+{
+ USHORT nPos = m_aFieldsLB.GetSelectEntryPos();
+ USHORT nEntries = m_aFieldsLB.GetEntryCount();
+ m_aUpPB.Enable(nPos > 0 && nEntries > 0);
+ m_aDownPB.Enable(nPos < nEntries -1);
+ m_aDeletePB.Enable(nEntries > 0);
+ m_aRenamePB.Enable(nEntries > 0);
+}
+/*-- 19.04.2004 14:51:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwCSVData* SwCustomizeAddressListDialog::GetNewData()
+{
+ return m_pNewData;
+}
+
+/*-- 13.04.2004 13:48:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAddRenameEntryDialog::SwAddRenameEntryDialog(
+ Window* pParent, bool bRename, const ::std::vector< ::rtl::OUString >& rCSVHeader) :
+ SfxModalDialog(pParent, SW_RES(DLG_MM_ADD_RENAME_ENTRY)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aFieldNameFT( this, SW_RES( FT_FIELDNAME)),
+ m_aFieldNameED( this, SW_RES( ED_FIELDNAME)),
+ 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_rCSVHeader(rCSVHeader)
+{
+ if(bRename)
+ SetText(String(SW_RES(ST_RENAME_TITLE)));
+ else
+ m_aOK.SetText(String(SW_RES(ST_ADD_BUTTON)));
+ FreeResource();
+ m_aFieldNameED.SetModifyHdl(LINK(this, SwAddRenameEntryDialog, ModifyHdl_Impl));
+ ModifyHdl_Impl( &m_aFieldNameED );
+}
+/*-- 13.04.2004 13:48:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAddRenameEntryDialog::~SwAddRenameEntryDialog()
+{
+}
+/*-- 19.04.2004 15:31:34---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddRenameEntryDialog, ModifyHdl_Impl, Edit*, pEdit)
+{
+ ::rtl::OUString sEntry = pEdit->GetText();
+ BOOL bFound = sEntry.getLength() ? FALSE : TRUE;
+
+ if(!bFound)
+ {
+ ::std::vector< ::rtl::OUString >::const_iterator aHeaderIter;
+ for(aHeaderIter = m_rCSVHeader.begin();
+ aHeaderIter != m_rCSVHeader.end();
+ ++aHeaderIter)
+ if(*aHeaderIter == sEntry)
+ {
+ bFound = TRUE;
+ break;
+ }
+ }
+ m_aOK.Enable(!bFound);
+ return 0;
+}
diff --git a/sw/source/ui/dbui/customizeaddresslistdialog.hrc b/sw/source/ui/dbui/customizeaddresslistdialog.hrc
new file mode 100644
index 000000000000..b190ee1e5e82
--- /dev/null
+++ b/sw/source/ui/dbui/customizeaddresslistdialog.hrc
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: customizeaddresslistdialog.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _CUSTOMIZEADDRESSLISTDIALOG_HRC
+#define _CUSTOMIZEADDRESSLISTDIALOG_HRC
+
+#define FT_FIELDS 1
+#define LB_FIELDS 2
+#define PB_ADD 3
+#define PB_DELETE 4
+#define PB_RENAME 5
+#define PB_UP 6
+#define PB_DOWN 7
+#define FL_SEPARATOR 8
+
+#define PB_OK 14
+#define PB_CANCEL 15
+#define PB_HELP 16
+
+#define FT_FIELDNAME 1
+#define ED_FIELDNAME 2
+#define ST_RENAME_TITLE 3
+#define ST_ADD_BUTTON 4
+
+
+#endif
diff --git a/sw/source/ui/dbui/customizeaddresslistdialog.hxx b/sw/source/ui/dbui/customizeaddresslistdialog.hxx
new file mode 100644
index 000000000000..a2e0ce35ae17
--- /dev/null
+++ b/sw/source/ui/dbui/customizeaddresslistdialog.hxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: customizeaddresslistdialog.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _CUSTOMIZEADDRESSLISTDIALOG_HXX
+#define _CUSTOMIZEADDRESSLISTDIALOG_HXX
+#include <sfx2/basedlgs.hxx>
+
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <svtools/stdctrl.hxx>
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+
+struct SwCSVData;
+/*-- 08.04.2004 14:04:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwCustomizeAddressListDialog : public SfxModalDialog
+{
+ FixedText m_aFieldsFT;
+ ListBox m_aFieldsLB;
+
+ PushButton m_aAddPB;
+ PushButton m_aDeletePB;
+ PushButton m_aRenamePB;
+
+ ImageButton m_aUpPB;
+ ImageButton m_aDownPB;
+
+ FixedLine m_aSeparatorFL;
+
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ SwCSVData* m_pNewData;
+
+ DECL_LINK(AddRenameHdl_Impl, PushButton*);
+ DECL_LINK(DeleteHdl_Impl, PushButton*);
+ DECL_LINK(UpDownHdl_Impl, PushButton*);
+ DECL_LINK(ListBoxSelectHdl_Impl, ListBox*);
+
+ void UpdateButtons();
+public:
+ SwCustomizeAddressListDialog(Window* pParent, const SwCSVData& rOldData);
+ ~SwCustomizeAddressListDialog();
+
+ SwCSVData* GetNewData();
+};
+/*-- 13.04.2004 13:30:21---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwAddRenameEntryDialog : public SfxModalDialog
+{
+ FixedText m_aFieldNameFT;
+ Edit m_aFieldNameED;
+
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ const ::std::vector< ::rtl::OUString >& m_rCSVHeader;
+
+ DECL_LINK(ModifyHdl_Impl, Edit*);
+public:
+ SwAddRenameEntryDialog(Window* pParent, bool bRename, const ::std::vector< ::rtl::OUString >& aCSVHeader);
+ ~SwAddRenameEntryDialog();
+
+ void SetFieldName(const String& rName) {m_aFieldNameED.SetText(rName);}
+ String GetFieldName() const {return m_aFieldNameED.GetText();};
+
+};
+
+#endif
+
diff --git a/sw/source/ui/dbui/customizeaddresslistdialog.src b/sw/source/ui/dbui/customizeaddresslistdialog.src
new file mode 100644
index 000000000000..7f0f74788198
--- /dev/null
+++ b/sw/source/ui/dbui/customizeaddresslistdialog.src
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: customizeaddresslistdialog.src,v $
+ * $Revision: 1.6 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <customizeaddresslistdialog.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+/*-- 13.04.2004 13:58:13---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+ModalDialog DLG_MM_CUSTOMIZE_ADDRESS_LIST
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_CUSTOMIZE_ADDRESS_LIST;
+ Size = MAP_APPFONT ( 200 , 171 ) ;
+ Moveable = TRUE ;
+
+ Text [ en-US ] = "Customize Address List";
+
+ FixedText FT_FIELDS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 100 , 8 ) ;
+ Text [ en-US ] = "A~ddress list elements";
+ };
+ ListBox LB_FIELDS
+ {
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 112 , 120 ) ;
+ Border = TRUE;
+ };
+ PushButton PB_ADD
+ {
+ Pos = MAP_APPFONT ( 144 , 3 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Add...";
+ };
+ PushButton PB_DELETE
+ {
+ Pos = MAP_APPFONT ( 144 , 20 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Delete";
+ };
+ PushButton PB_RENAME
+ {
+ Pos = MAP_APPFONT ( 144 , 37 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Rename...";
+ };
+ ImageButton PB_UP
+ {
+ Pos = MAP_APPFONT ( 124 , 58 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ SYMBOL = IMAGEBUTTON_ARROW_UP;
+ QuickHelpText[ en-US ] = "Move up";
+ };
+ ImageButton PB_DOWN
+ {
+ Pos = MAP_APPFONT ( 124 , 75 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ SYMBOL = IMAGEBUTTON_ARROW_DOWN;
+ QuickHelpText[ en-US ] = "Move down";
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 140 ) ;
+ Size = MAP_APPFONT ( 200 , 8 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 35 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 88 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 144 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+/*-- 13.04.2004 13:58:13---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+ModalDialog DLG_MM_ADD_RENAME_ENTRY
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_ADD_RENAME_ENTRY;
+ Size = MAP_APPFONT ( 188 , 60 ) ;
+ Moveable = TRUE ;
+
+ Text [ en-US ] = "Add Element";
+
+ FixedText FT_FIELDNAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "Element ~name";
+ };
+ Edit ED_FIELDNAME
+ {
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ Border = TRUE;
+ };
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 132 , 3 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 132 , 20 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 132 , 40 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String ST_RENAME_TITLE
+ {
+ Text [ en-US ] = "Rename Element";
+ };
+ String ST_ADD_BUTTON
+ {
+ Text [ en-US ] = "Add";
+ };
+};
+
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
new file mode 100644
index 000000000000..cb815a93f1a6
--- /dev/null
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -0,0 +1,1967 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbinsdlg.cxx,v $
+ * $Revision: 1.63 $
+ *
+ * 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 "dbinsdlg.hxx"
+
+#ifndef INCLUDED_MEMORY
+#include <memory>
+#define INCLUDED_MEMORY
+#endif
+
+#ifndef INCLUDED_FLOAT_H
+#include <float.h>
+#define INCLUDED_FLOAT_H
+#endif
+#include <hintids.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/sdb/XDatabaseAccess.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <comphelper/processfactory.hxx>
+#include <svx/langitem.hxx>
+#include <svtools/numuno.hxx>
+#include <svtools/stritem.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#ifndef __SV_MNEMONIC_HXX
+#include <vcl/mnemonic.hxx>
+#endif
+#include <svtools/style.hxx>
+#include <svtools/zformat.hxx>
+#include <svx/htmlmode.hxx>
+#include <svx/unolingu.hxx>
+#include <sfx2/app.hxx>
+#include <svtools/itemset.hxx>
+#include <svx/brshitem.hxx>
+#include <svx/boxitem.hxx>
+#include <svx/rulritem.hxx>
+#include <swdbtoolsclient.hxx>
+#ifndef _SWTABLEREP_HXX //autogen
+#include <tabledlg.hxx>
+#endif
+#include <fmtclds.hxx>
+#include <tabcol.hxx>
+#include <uiitems.hxx>
+#include <viewopt.hxx>
+#include <uitool.hxx>
+#include <wrtsh.hxx>
+#ifndef _WVIEW_HXX
+#include <wview.hxx>
+#endif
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#ifndef _DBMGR_HXX
+#include <dbmgr.hxx>
+#endif
+#include <tblafmt.hxx>
+#include <cellatr.hxx>
+#include <swtable.hxx>
+#include <dbfld.hxx>
+#include <fmtcol.hxx>
+#include <section.hxx>
+#include <swwait.hxx>
+#include <modcfg.hxx>
+#include <swmodule.hxx>
+#include <poolfmt.hxx>
+#include <crsskip.hxx>
+
+#ifndef _DBINSDLG_HRC
+#include <dbinsdlg.hrc>
+#endif
+#ifndef _DBUI_HRC
+#include <dbui.hrc>
+#endif
+
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+#ifndef _HELPID_H
+#include <helpid.h>
+#endif
+#include <cfgid.h>
+#include <SwStyleNameMapper.hxx>
+#include <comphelper/uno3.hxx>
+#include "tabsh.hxx"
+#include "swabstdlg.hxx"
+#include "table.hrc"
+#include <unomid.h>
+#include <IDocumentMarkAccess.hxx>
+
+
+namespace swui
+{
+ SwAbstractDialogFactory * GetFactory();
+}
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+
+// tblafmt.hxx
+SV_IMPL_PTRARR( _SwTableAutoFmtTbl, SwTableAutoFmt* )
+
+const char cDBFldStart = '<';
+const char cDBFldEnd = '>';
+
+// Hilfsstruktur fuers einfuegen von Datenbankspalten als Felder oder Text
+struct _DB_Column
+{
+ enum ColType { DB_FILLTEXT, DB_COL_FIELD, DB_COL_TEXT, DB_SPLITPARA } eColType;
+
+ union {
+ String* pText;
+ SwField* pField;
+ ULONG nFormat;
+ } DB_ColumnData;
+ const SwInsDBColumn* pColInfo;
+
+ _DB_Column()
+ {
+ pColInfo = 0;
+ DB_ColumnData.pText = 0;
+ eColType = DB_SPLITPARA;
+ }
+
+ _DB_Column( const String& rTxt )
+ {
+ pColInfo = 0;
+ DB_ColumnData.pText = new String( rTxt );
+ eColType = DB_FILLTEXT;
+ }
+
+ _DB_Column( const SwInsDBColumn& rInfo, ULONG nFormat )
+ {
+ pColInfo = &rInfo;
+ DB_ColumnData.nFormat = nFormat;
+ eColType = DB_COL_TEXT;
+ }
+
+ _DB_Column( const SwInsDBColumn& rInfo, SwDBField& rFld )
+ {
+ pColInfo = &rInfo;
+ DB_ColumnData.pField = &rFld;
+ eColType = DB_COL_FIELD;
+ }
+
+ ~_DB_Column()
+ {
+ if( DB_COL_FIELD == eColType )
+ delete DB_ColumnData.pField;
+ else if( DB_FILLTEXT == eColType )
+ delete DB_ColumnData.pText;
+ }
+};
+
+typedef _DB_Column* _DB_ColumnPtr;
+SV_DECL_PTRARR_DEL( _DB_Columns, _DB_ColumnPtr, 32, 32 )
+SV_IMPL_PTRARR( _DB_Columns, _DB_ColumnPtr )
+
+SV_IMPL_OP_PTRARR_SORT( SwInsDBColumns, SwInsDBColumnPtr )
+
+/* */
+
+#define DBCOLUMN_CONFIG_VERSION1 1
+#define DBCOLUMN_CONFIG_VERSION DBCOLUMN_CONFIG_VERSION1
+#define DBCOLUMN_MAXDATA 5
+
+struct _DB_ColumnConfigData
+{
+ SwInsDBColumns aDBColumns;
+ rtl::OUString sSource, sTable, sEdit, sTblList, sTmplNm, sTAutoFmtNm;
+ BOOL bIsTable : 1,
+ bIsField : 1,
+ bIsHeadlineOn : 1,
+ bIsEmptyHeadln : 1;
+
+ _DB_ColumnConfigData()
+ {
+ bIsTable = bIsHeadlineOn = TRUE;
+ bIsField = bIsEmptyHeadln = FALSE;
+ }
+
+ ~_DB_ColumnConfigData();
+private:
+ _DB_ColumnConfigData( const _DB_ColumnConfigData& );
+ _DB_ColumnConfigData& operator =( const _DB_ColumnConfigData& );
+};
+
+/* */
+
+int SwInsDBColumn::operator<( const SwInsDBColumn& rCmp ) const
+{
+ return 0 > GetAppCollator().compareString( sColumn, rCmp.sColumn );
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView,
+ Reference<XDataSource> xDataSource,
+ Reference<sdbcx::XColumnsSupplier> xColSupp,
+ const SwDBData& rData )
+ : SfxModalDialog( rView.GetWindow(), SW_RES( DLG_AP_INSERT_DB_SEL )),
+ ConfigItem(C2U("Office.Writer/InsertData/DataSet"), CONFIG_MODE_DELAYED_UPDATE),
+ aFtInsertData( this, SW_RES( FT_INSERT_DATA )),
+ aRbAsTable( this, SW_RES( RB_AS_TABLE )),
+ aRbAsField( this, SW_RES( RB_AS_FIELD )),
+ aRbAsText( this, SW_RES( RB_AS_TEXT )),
+
+ aFlHead( this, SW_RES( FL_HEAD )),
+ aFtDbColumn( this, SW_RES( FT_DB_COLUMN )),
+
+ aLbTblDbColumn( this, SW_RES( LB_TBL_DB_COLUMN )),
+ aLbTxtDbColumn( this, SW_RES( LB_TXT_DB_COLUMN )),
+
+ aFlFormat( this, SW_RES( FL_FORMAT )),
+ aRbDbFmtFromDb( this, SW_RES( RB_DBFMT_FROM_DB )),
+ aRbDbFmtFromUsr( this, SW_RES( RB_DBFMT_FROM_USR )),
+ aLbDbFmtFromUsr( this, &rView, SW_RES( LB_DBFMT_FROM_USR )),
+
+ aIbDbcolToEdit( this, SW_RES( IB_DBCOL_TOEDIT )),
+ aEdDbText( this, SW_RES( ED_DB_TEXT )),
+ aFtDbParaColl( this, SW_RES( FT_DB_PARA_COLL )),
+ aLbDbParaColl( this, SW_RES( LB_DB_PARA_COLL )),
+
+ aIbDbcolAllTo( this, SW_RES( IB_DBCOL_ALL_TO )),
+ aIbDbcolOneTo( this, SW_RES( IB_DBCOL_ONE_TO )),
+ aIbDbcolOneFrom( this, SW_RES( IB_DBCOL_ONE_FROM )),
+ aIbDbcolAllFrom( this, SW_RES( IB_DBCOL_ALL_FROM )),
+ aFtTableCol( this, SW_RES( FT_TABLE_COL )),
+ aLbTableCol( this, SW_RES( LB_TABLE_COL )),
+ aCbTableHeadon( this, SW_RES( CB_TABLE_HEADON )),
+ aRbHeadlColnms( this, SW_RES( RB_HEADL_COLNMS )),
+ aRbHeadlEmpty( this, SW_RES( RB_HEADL_EMPTY )),
+ aPbTblFormat( this, SW_RES( PB_TBL_FORMAT )),
+ aPbTblAutofmt( this, SW_RES( PB_TBL_AUTOFMT )),
+
+ aBtOk( this, SW_RES( BT_OK )),
+ aBtCancel( this, SW_RES( BT_CANCEL )),
+ aBtHelp( this, SW_RES( BT_HELP )),
+
+ aFlBottom( this, SW_RES( FL_BOTTOM )),
+
+ aDBData(rData),
+
+ aOldNumFmtLnk( aLbDbFmtFromUsr.GetSelectHdl() ),
+ sNoTmpl( SW_RES( STR_NOTEMPL )),
+ pView( &rView ),
+ pTAutoFmt( 0 ),
+ pTblSet( 0 ),
+ pRep( 0 )
+{
+ FreeResource();
+
+ nGBFmtLen = aFlFormat.GetText().Len();
+
+ if(xColSupp.is())
+ {
+ SwWrtShell& rSh = pView->GetWrtShell();
+ Locale aDocLocale( SvxCreateLocale( rSh.GetCurLang() ));
+ SvNumberFormatter* pNumFmtr = rSh.GetNumberFormatter();
+ SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj( pNumFmtr );
+ Reference< util::XNumberFormatsSupplier > xDocNumFmtsSupplier = pNumFmt;
+ Reference< util::XNumberFormats > xDocNumberFormats = xDocNumFmtsSupplier->getNumberFormats();
+ Reference< util::XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY);
+
+ Reference<XPropertySet> xSourceProps(xDataSource, UNO_QUERY);
+ Reference< util::XNumberFormats > xNumberFormats;
+ if(xSourceProps.is())
+ {
+ Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
+ if(aFormats.hasValue())
+ {
+ Reference< util::XNumberFormatsSupplier> xSuppl;
+ aFormats >>= xSuppl;
+ if(xSuppl.is())
+ {
+ xNumberFormats = xSuppl->getNumberFormats( );
+ }
+ }
+ }
+ Reference <XNameAccess> xCols = xColSupp->getColumns();
+ Sequence<rtl::OUString> aColNames = xCols->getElementNames();
+ const rtl::OUString* pColNames = aColNames.getConstArray();
+ long nCount = aColNames.getLength();
+ for (long n = 0; n < nCount; n++)
+ {
+ SwInsDBColumn* pNew = new SwInsDBColumn( pColNames[n], (USHORT)n );
+ Any aCol = xCols->getByName(pColNames[n]);
+ Reference <XPropertySet> xCol;
+ aCol >>= xCol;
+ Any aType = xCol->getPropertyValue(C2S("Type"));
+ sal_Int32 eDataType = 0;
+ aType >>= eDataType;
+ switch(eDataType)
+ {
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::BIGINT:
+ case DataType::FLOAT:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ {
+ pNew->bHasFmt = TRUE;
+ Any aFormat = xCol->getPropertyValue(C2U("FormatKey"));
+ if(aFormat.hasValue())
+ {
+ sal_Int32 nFmt = 0;
+ aFormat >>= nFmt;
+ if(xNumberFormats.is())
+ {
+ try
+ {
+ Reference<XPropertySet> xNumProps = xNumberFormats->getByKey( nFmt );
+ Any aFormatVal = xNumProps->getPropertyValue(C2U("FormatString"));
+ Any aLocale = xNumProps->getPropertyValue(C2U("Locale"));
+ rtl::OUString sFormat;
+ aFormatVal >>= sFormat;
+ lang::Locale aLoc;
+ aLocale >>= aLoc;
+ long nKey = xDocNumberFormats->queryKey( sFormat, aLoc, sal_True);
+ if(nKey < 0)
+ {
+ nKey = xDocNumberFormats->addNew( sFormat, aLoc );
+ }
+ pNew->nDBNumFmt = nKey;
+ }
+ catch(const Exception& )
+ {
+ DBG_ERROR("illegal number format key");
+ }
+ }
+ }
+ else
+ {
+ pNew->nDBNumFmt = SwNewDBMgr::GetDbtoolsClient().getDefaultNumberFormat(xCol,
+ xDocNumberFormatTypes, aDocLocale);
+ }
+
+ }
+ break;
+ }
+ if( !aDBColumns.Insert( pNew ))
+ {
+ ASSERT( !this, "Spaltenname mehrfach vergeben?" );
+ delete pNew;
+ }
+ }
+ }
+
+ // Absatzvorlagen-ListBox fuellen
+ {
+ SfxStyleSheetBasePool* pPool = pView->GetDocShell()->GetStyleSheetPool();
+ pPool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
+ aLbDbParaColl.InsertEntry( sNoTmpl );
+
+ const SfxStyleSheetBase* pBase = pPool->First();
+ while( pBase )
+ {
+ aLbDbParaColl.InsertEntry( pBase->GetName() );
+ pBase = pPool->Next();
+ }
+ aLbDbParaColl.SelectEntryPos( 0 );
+ }
+
+ // steht der Cursor in einer Tabelle, darf NIE Tabelle auswaehlbar sein
+ if( pView->GetWrtShell().GetTableFmt() )
+ {
+ aRbAsTable.Enable( FALSE );
+ aRbAsField.Check( TRUE );
+ aRbDbFmtFromDb.Check( TRUE );
+ }
+ else
+ {
+ aRbAsTable.Check( TRUE );
+ aRbDbFmtFromDb.Check( TRUE );
+ aIbDbcolOneFrom.Enable( FALSE );
+ aIbDbcolAllFrom.Enable( FALSE );
+ }
+
+ aRbAsTable.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
+ aRbAsField.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
+ aRbAsText.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
+
+ aRbDbFmtFromDb.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl ));
+ aRbDbFmtFromUsr.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl ));
+
+ aPbTblFormat.SetClickHdl(LINK(this, SwInsertDBColAutoPilot, TblFmtHdl ));
+ aPbTblAutofmt.SetClickHdl(LINK(this, SwInsertDBColAutoPilot, AutoFmtHdl ));
+
+ aIbDbcolAllTo.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
+ aIbDbcolOneTo.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
+ aIbDbcolOneFrom.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
+ aIbDbcolAllFrom.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
+ aIbDbcolToEdit.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
+
+ aCbTableHeadon.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl ));
+ aRbHeadlColnms.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl ));
+ aRbHeadlEmpty.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl ));
+
+ aLbTxtDbColumn.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
+ aLbTblDbColumn.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
+ aLbDbFmtFromUsr.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
+ aLbTableCol.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
+
+ aLbTxtDbColumn.SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
+ aLbTblDbColumn.SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
+ aLbTableCol.SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
+
+ for( USHORT n = 0; n < aDBColumns.Count(); ++n )
+ {
+ const String& rS = aDBColumns[ n ]->sColumn;
+ aLbTblDbColumn.InsertEntry( rS, n );
+ aLbTxtDbColumn.InsertEntry( rS, n );
+ }
+ aLbTxtDbColumn.SelectEntryPos( 0 );
+ aLbTblDbColumn.SelectEntryPos( 0 );
+
+ // read configuration
+ Load();
+
+ // Controls initialisieren:
+ PageHdl( aRbAsTable.IsChecked() ? &aRbAsTable : &aRbAsField );
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwInsertDBColAutoPilot::~SwInsertDBColAutoPilot()
+{
+ delete pTblSet;
+ delete pRep;
+
+// delete pConfig;
+ delete pTAutoFmt;
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK( SwInsertDBColAutoPilot, PageHdl, Button*, pButton )
+{
+ BOOL bShowTbl = pButton == &aRbAsTable;
+
+ String sTxt( pButton->GetText() );
+ aFlHead.SetText( MnemonicGenerator::EraseAllMnemonicChars( sTxt ) );
+
+ aLbTxtDbColumn.Show( !bShowTbl );
+ aIbDbcolToEdit.Show( !bShowTbl );
+ aEdDbText.Show( !bShowTbl );
+ aFtDbParaColl.Show( !bShowTbl );
+ aLbDbParaColl.Show( !bShowTbl );
+
+ aLbTblDbColumn.Show( bShowTbl );
+ aIbDbcolAllTo.Show( bShowTbl );
+ aIbDbcolOneTo.Show( bShowTbl );
+ aIbDbcolOneFrom.Show( bShowTbl );
+ aIbDbcolAllFrom.Show( bShowTbl );
+ aFtTableCol.Show( bShowTbl );
+ aLbTableCol.Show( bShowTbl );
+ aCbTableHeadon.Show( bShowTbl );
+ aRbHeadlColnms.Show( bShowTbl );
+ aRbHeadlEmpty.Show( bShowTbl );
+ aPbTblFormat.Show( bShowTbl );
+ aPbTblAutofmt.Show( bShowTbl );
+
+ if( bShowTbl )
+ aPbTblFormat.Enable( 0 != aLbTableCol.GetEntryCount() );
+
+ SelectHdl( bShowTbl ? &aLbTblDbColumn : &aLbTxtDbColumn );
+
+ return 0;
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK( SwInsertDBColAutoPilot, DBFormatHdl, Button*, pButton )
+{
+ USHORT nFndPos;
+ ListBox& rBox = aRbAsTable.IsChecked()
+ ? ( 0 == aLbTableCol.GetEntryData( 0 )
+ ? aLbTblDbColumn
+ : aLbTableCol )
+ : aLbTxtDbColumn;
+
+ SwInsDBColumn aSrch( rBox.GetSelectEntry(), 0 );
+ aDBColumns.Seek_Entry( &aSrch, &nFndPos );
+
+ BOOL bFromDB = &aRbDbFmtFromDb == pButton;
+ aDBColumns[ nFndPos ]->bIsDBFmt = bFromDB;
+ aLbDbFmtFromUsr.Enable( !bFromDB );
+
+ return 0;
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK( SwInsertDBColAutoPilot, TblToFromHdl, Button*, pButton )
+{
+ BOOL bChgEnable = TRUE, bEnableTo = TRUE, bEnableFrom = TRUE;
+ aLbTblDbColumn.SetUpdateMode( FALSE );
+ aLbTableCol.SetUpdateMode( FALSE );
+
+ if( pButton == &aIbDbcolAllTo )
+ {
+ bEnableTo = FALSE;
+
+ USHORT n, nInsPos = aLbTableCol.GetSelectEntryPos(),
+ nCnt = aLbTblDbColumn.GetEntryCount();
+ if( LISTBOX_APPEND == nInsPos )
+ for( n = 0; n < nCnt; ++n )
+ aLbTableCol.InsertEntry( aLbTblDbColumn.GetEntry( n ),
+ LISTBOX_APPEND );
+ else
+ for( n = 0; n < nCnt; ++n, ++nInsPos )
+ aLbTableCol.InsertEntry( aLbTblDbColumn.GetEntry( n ), nInsPos );
+ aLbTblDbColumn.Clear();
+ aLbTableCol.SelectEntryPos( nInsPos );
+ aLbTblDbColumn.SelectEntryPos( LISTBOX_APPEND );
+ }
+ else if( pButton == &aIbDbcolOneTo &&
+ LISTBOX_ENTRY_NOTFOUND != aLbTblDbColumn.GetSelectEntryPos() )
+ {
+ USHORT nInsPos = aLbTableCol.GetSelectEntryPos(),
+ nDelPos = aLbTblDbColumn.GetSelectEntryPos(),
+ nTopPos = aLbTblDbColumn.GetTopEntry();
+ aLbTableCol.InsertEntry( aLbTblDbColumn.GetEntry( nDelPos ), nInsPos );
+ aLbTblDbColumn.RemoveEntry( nDelPos );
+
+ aLbTableCol.SelectEntryPos( nInsPos );
+ if( nDelPos >= aLbTblDbColumn.GetEntryCount() )
+ nDelPos = aLbTblDbColumn.GetEntryCount() - 1;
+ aLbTblDbColumn.SelectEntryPos( nDelPos );
+ aLbTblDbColumn.SetTopEntry( nTopPos );
+
+ bEnableTo = 0 != aLbTblDbColumn.GetEntryCount();
+ }
+ else if( pButton == &aIbDbcolOneFrom )
+ {
+ if( LISTBOX_ENTRY_NOTFOUND != aLbTableCol.GetSelectEntryPos() )
+ {
+ USHORT nFndPos, nInsPos,
+ nDelPos = aLbTableCol.GetSelectEntryPos(),
+ nTopPos = aLbTableCol.GetTopEntry();
+
+ // die richtige InsertPos suchen!!
+ SwInsDBColumn aSrch( aLbTableCol.GetEntry( nDelPos ), 0 );
+ aDBColumns.Seek_Entry( &aSrch, &nFndPos );
+ if( !nFndPos || nFndPos == aDBColumns.Count()-1 )
+ nInsPos = nFndPos;
+ else
+ {
+ nInsPos = LISTBOX_ENTRY_NOTFOUND;
+ while( ++nFndPos < aDBColumns.Count() &&
+ LISTBOX_ENTRY_NOTFOUND == (nInsPos = aLbTblDbColumn.
+ GetEntryPos( String(aDBColumns[ nFndPos ]->sColumn ))) )
+ ;
+ }
+
+ aLbTblDbColumn.InsertEntry( aSrch.sColumn, nInsPos );
+ aLbTableCol.RemoveEntry( nDelPos );
+
+ if( nInsPos >= aLbTblDbColumn.GetEntryCount() )
+ nInsPos = aLbTblDbColumn.GetEntryCount() - 1;
+ aLbTblDbColumn.SelectEntryPos( nInsPos );
+
+ if( nDelPos >= aLbTableCol.GetEntryCount() )
+ nDelPos = aLbTableCol.GetEntryCount() - 1;
+ aLbTableCol.SelectEntryPos( nDelPos );
+ aLbTableCol.SetTopEntry( nTopPos );
+ }
+ else
+ bEnableTo = 0 != aLbTblDbColumn.GetEntryCount();
+
+ bEnableFrom = 0 != aLbTableCol.GetEntryCount();
+ }
+ else if( pButton == &aIbDbcolAllFrom )
+ {
+ bEnableFrom = FALSE;
+
+ aLbTblDbColumn.Clear();
+ aLbTableCol.Clear();
+ for( USHORT n = 0; n < aDBColumns.Count(); ++n )
+ aLbTblDbColumn.InsertEntry( aDBColumns[ n ]->sColumn, n );
+ aLbTblDbColumn.SelectEntryPos( 0 );
+ }
+ else if( pButton == &aIbDbcolToEdit )
+ {
+ bChgEnable = FALSE;
+ // Daten ins Edit moven:
+ String aFld( aLbTxtDbColumn.GetSelectEntry() );
+ if( aFld.Len() )
+ {
+ String aStr( aEdDbText.GetText() );
+ USHORT nPos = (USHORT)aEdDbText.GetSelection().Min();
+ USHORT nSel = USHORT(aEdDbText.GetSelection().Max()) - nPos;
+ if( nSel )
+ // dann loesche erstmal die bestehende Selektion
+ aStr.Erase( nPos, nSel );
+
+ aFld.Insert( cDBFldStart, 0 );
+ aFld += cDBFldEnd;
+ if( aStr.Len() )
+ {
+ if( nPos ) // ein Space davor
+ {
+ sal_Unicode c = aStr.GetChar( nPos-1 );
+ if( '\n' != c && '\r' != c )
+ aFld.Insert( ' ', 0 );
+ }
+ if( nPos < aStr.Len() ) // ein Space dahinter
+ {
+ sal_Unicode c = aStr.GetChar( nPos );
+ if( '\n' != c && '\r' != c )
+ aFld += ' ';
+ }
+ }
+
+ aStr.Insert( aFld, nPos );
+ aEdDbText.SetText( aStr );
+ nPos = nPos + aFld.Len();
+ aEdDbText.SetSelection( Selection( nPos ));
+ }
+ }
+
+ if( bChgEnable )
+ {
+ aIbDbcolOneTo.Enable( bEnableTo );
+ aIbDbcolAllTo.Enable( bEnableTo );
+ aIbDbcolOneFrom.Enable( bEnableFrom );
+ aIbDbcolAllFrom.Enable( bEnableFrom );
+
+ aRbDbFmtFromDb.Enable( FALSE );
+ aRbDbFmtFromUsr.Enable( FALSE );
+ aLbDbFmtFromUsr.Enable( FALSE );
+
+ aPbTblFormat.Enable( bEnableFrom );
+ }
+ aLbTblDbColumn.SetUpdateMode( TRUE );
+ aLbTableCol.SetUpdateMode( TRUE );
+
+ return 0;
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK( SwInsertDBColAutoPilot, DblClickHdl, ListBox*, pBox )
+{
+ Button* pButton = 0;
+ if( pBox == &aLbTxtDbColumn )
+ pButton = &aIbDbcolToEdit;
+ else if( pBox == &aLbTblDbColumn && aIbDbcolOneTo.IsEnabled() )
+ pButton = &aIbDbcolOneTo;
+ else if( pBox == &aLbTableCol && aIbDbcolOneFrom.IsEnabled() )
+ pButton = &aIbDbcolOneFrom;
+
+ if( pButton )
+ TblToFromHdl( pButton );
+
+ return 0;
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK( SwInsertDBColAutoPilot, TblFmtHdl, PushButton*, pButton )
+{
+ SwWrtShell& rSh = pView->GetWrtShell();
+ BOOL bNewSet = FALSE;
+ if( !pTblSet )
+ {
+ bNewSet = TRUE;
+ pTblSet = new SfxItemSet( rSh.GetAttrPool(), SwuiGetUITableAttrRange() );
+
+ //Ersteinmal die einfachen Attribute besorgen.
+ pTblSet->Put( SfxStringItem( FN_PARAM_TABLE_NAME, rSh.GetUniqueTblName() ));
+ pTblSet->Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, 1 ) );
+
+ pTblSet->Put( SfxUInt16Item( SID_BACKGRND_DESTINATION,
+ rSh.GetViewOptions()->GetTblDest() ));
+
+ SvxBrushItem aBrush( RES_BACKGROUND );
+ pTblSet->Put( aBrush );
+ pTblSet->Put( aBrush, SID_ATTR_BRUSH_ROW );
+ pTblSet->Put( aBrush, SID_ATTR_BRUSH_TABLE );
+
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ // Tabellenvariante, wenn mehrere Tabellenzellen selektiert
+ aBoxInfo.SetTable( TRUE );
+ // Abstandsfeld immer anzeigen
+ aBoxInfo.SetDist( TRUE);
+ // Minimalgroesse in Tabellen und Absaetzen setzen
+ aBoxInfo.SetMinDist( FALSE );
+ // Default-Abstand immer setzen
+ aBoxInfo.SetDefDist( MIN_BORDER_DIST );
+ // Einzelne Linien koennen nur in Tabellen DontCare-Status haben
+ aBoxInfo.SetValid( VALID_DISABLE, TRUE );
+ pTblSet->Put( aBoxInfo );
+
+ SwGetCurColNumPara aPara;
+ const USHORT nNum = rSh.GetCurColNum( &aPara );
+ long nWidth;
+
+ if( nNum )
+ {
+ nWidth = aPara.pPrtRect->Width();
+ const SwFmtCol& rCol = aPara.pFrmFmt->GetCol();
+ const SwColumns& rCols = rCol.GetColumns();
+
+ //nStart und nEnd initialisieren fuer nNum == 0
+ long nWidth1 = 0,
+ nStart1 = 0,
+ nEnd1 = nWidth;
+ for( USHORT i = 0; i < nNum; ++i )
+ {
+ SwColumn* pCol = rCols[i];
+ nStart1 = pCol->GetLeft() + nWidth1;
+ nWidth1 += (long)rCol.CalcColWidth( i, (USHORT)nWidth );
+ nEnd1 = nWidth1 - pCol->GetRight();
+ }
+ if(nStart1 || nEnd1 != nWidth)
+ nWidth = nEnd1 - nStart1;
+ }
+ else
+ nWidth = rSh.GetAnyCurRect(
+ FRMTYPE_FLY_ANY & rSh.GetFrmType( 0, TRUE )
+ ? RECT_FLY_PRT_EMBEDDED
+ : RECT_PAGE_PRT ).Width();
+
+ SwTabCols aTabCols;
+ aTabCols.SetRight( nWidth );
+ aTabCols.SetRightMax( nWidth );
+ pRep = new SwTableRep( aTabCols, FALSE );
+ pRep->SetAlign( text::HoriOrientation::NONE );
+ pRep->SetSpace( nWidth );
+ pRep->SetWidth( nWidth );
+ pRep->SetWidthPercent( 100 );
+ pTblSet->Put( SwPtrItem( FN_TABLE_REP, pRep ));
+
+ pTblSet->Put( SfxUInt16Item( SID_HTML_MODE,
+ ::GetHtmlMode( pView->GetDocShell() )));
+ }
+
+ if( aLbTableCol.GetEntryCount() != pRep->GetAllColCount() )
+ {
+ // Anzahl der Spalten hat sich geaendert: dann muessen die
+ // TabCols angepasst werden
+ long nWidth = pRep->GetWidth();
+ USHORT nCols = aLbTableCol.GetEntryCount() - 1;
+ SwTabCols aTabCols( nCols );
+ aTabCols.SetRight( nWidth );
+ aTabCols.SetRightMax( nWidth );
+ if( nCols )
+ for( USHORT n = 0, nStep = (USHORT)(nWidth / (nCols+1)), nW = nStep;
+ n < nCols; ++n, nW = nW + nStep )
+ {
+ aTabCols.Insert( nW, FALSE, n );
+ }
+ delete pRep;
+ pRep = new SwTableRep( aTabCols, FALSE );
+ pRep->SetAlign( text::HoriOrientation::NONE );
+ pRep->SetSpace( nWidth );
+ pRep->SetWidth( nWidth );
+ pRep->SetWidthPercent( 100 );
+ pTblSet->Put( SwPtrItem( FN_TABLE_REP, pRep ));
+ }
+
+ SwAbstractDialogFactory* pFact = swui::GetFactory();
+ DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateSwTableTabDlg( pButton, rSh.GetAttrPool(),pTblSet, &rSh, DLG_FORMAT_TABLE );
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ if( RET_OK == pDlg->Execute() )
+ pTblSet->Put( *pDlg->GetOutputItemSet() );
+ else if( bNewSet )
+ {
+ delete pTblSet, pTblSet = 0;
+ delete pRep, pRep = 0;
+ }
+ delete pDlg;
+
+ return 0;
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK( SwInsertDBColAutoPilot, AutoFmtHdl, PushButton*, pButton )
+{
+ SwAbstractDialogFactory* pFact = swui::GetFactory();
+ DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(pButton, pView->GetWrtShellPtr(),DLG_AUTOFMT_TABLE, FALSE, pTAutoFmt);
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ if( RET_OK == pDlg->Execute())
+ pDlg->FillAutoFmtOfIndex( pTAutoFmt );
+ delete pDlg;
+ return 0;
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK( SwInsertDBColAutoPilot, SelectHdl, ListBox*, pBox )
+{
+ ListBox* pGetBox = pBox == &aLbDbFmtFromUsr
+ ? ( aRbAsTable.IsChecked()
+ ? ( 0 == aLbTableCol.GetEntryData( 0 )
+ ? &aLbTblDbColumn
+ : &aLbTableCol )
+ : &aLbTxtDbColumn )
+ : pBox;
+
+ USHORT nFndPos;
+ SwInsDBColumn aSrch( pGetBox->GetSelectEntry(), 0 );
+ aDBColumns.Seek_Entry( &aSrch, &nFndPos );
+
+ if( pBox == &aLbDbFmtFromUsr )
+ {
+ if( aSrch.sColumn.getLength() )
+ {
+ aOldNumFmtLnk.Call( pBox );
+ aDBColumns[ nFndPos ]->nUsrNumFmt = aLbDbFmtFromUsr.GetFormat();
+ }
+ }
+ else
+ {
+ // an der FormatGroupBox den ausgewaehlten FeldNamen setzen, damit
+ // klar ist, welches Feld ueber das Format eingestellt wird!
+ String sTxt( aFlFormat.GetText().Copy( 0, nGBFmtLen ));
+ if( !aSrch.sColumn.getLength() )
+ {
+ aRbDbFmtFromDb.Enable( FALSE );
+ aRbDbFmtFromUsr.Enable( FALSE );
+ aLbDbFmtFromUsr.Enable( FALSE );
+ }
+ else
+ {
+ BOOL bEnableFmt = aDBColumns[ nFndPos ]->bHasFmt;
+ aRbDbFmtFromDb.Enable( bEnableFmt );
+ aRbDbFmtFromUsr.Enable( bEnableFmt );
+
+ if( bEnableFmt )
+ {
+ (( sTxt += C2S(" (" )) += String(aSrch.sColumn) ) += (sal_Unicode)')';
+ }
+
+ BOOL bIsDBFmt = aDBColumns[ nFndPos ]->bIsDBFmt;
+ aRbDbFmtFromDb.Check( bIsDBFmt );
+ aRbDbFmtFromUsr.Check( !bIsDBFmt );
+ aLbDbFmtFromUsr.Enable( !bIsDBFmt );
+ if( !bIsDBFmt )
+ aLbDbFmtFromUsr.SetDefFormat( aDBColumns[ nFndPos ]->nUsrNumFmt );
+ }
+
+ aFlFormat.SetText( sTxt );
+
+ // um spaeter zu wissen, welche ListBox die "aktive" war, wird sich
+ // im 1. Eintrag ein Flag gemerkt,
+ void* pPtr = pBox == &aLbTableCol ? &aLbTableCol : 0;
+ aLbTableCol.SetEntryData( 0, pPtr );
+ }
+ return 0;
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK( SwInsertDBColAutoPilot, HeaderHdl, Button*, pButton )
+{
+ if( pButton == &aCbTableHeadon )
+ {
+ BOOL bEnable = aCbTableHeadon.IsChecked();
+
+ aRbHeadlColnms.Enable( bEnable );
+ aRbHeadlEmpty.Enable( bEnable );
+ }
+ return 0;
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+static void lcl_InsTextInArr( const String& rTxt, _DB_Columns& rColArr )
+{
+ _DB_Column* pNew;
+ USHORT nSttPos = 0, nFndPos;
+ while( STRING_NOTFOUND != ( nFndPos = rTxt.Search( '\x0A', nSttPos )) )
+ {
+ if( 1 < nFndPos )
+ {
+ pNew = new _DB_Column( rTxt.Copy( nSttPos, nFndPos -1 ) );
+ rColArr.Insert( pNew, rColArr.Count() );
+ }
+ pNew = new _DB_Column;
+ rColArr.Insert( pNew, rColArr.Count() );
+ nSttPos = nFndPos + 1;
+ }
+ if( nSttPos < rTxt.Len() )
+ {
+ pNew = new _DB_Column( rTxt.Copy( nSttPos ) );
+ rColArr.Insert( pNew, rColArr.Count() );
+ }
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL SwInsertDBColAutoPilot::SplitTextToColArr( const String& rTxt,
+ _DB_Columns& rColArr,
+ BOOL bInsField )
+{
+ // aus dem Text wieder die einzelnen Datenbank - Spalten erzeugen
+ // und dann in einem Array speichern
+ // Die Datenbankspalten stehen in <> und muessen im Array der Spalten
+ // vorhanden sein:
+ String sTxt( rTxt );
+ USHORT nFndPos, nEndPos, nSttPos = 0;
+
+ while( STRING_NOTFOUND != ( nFndPos = sTxt.Search( cDBFldStart, nSttPos )))
+ {
+ nSttPos = nFndPos + 1;
+ if( STRING_NOTFOUND != ( nEndPos = sTxt.Search( cDBFldEnd, nSttPos+1 )))
+ {
+ // Text in <> geklammert gefunden: was ist es denn:
+ SwInsDBColumn aSrch( sTxt.Copy( nSttPos, nEndPos - nSttPos ), 0);
+ if( aDBColumns.Seek_Entry( &aSrch, &nFndPos ) )
+ {
+ // das ist ein gueltiges Feld
+ // also sicher den Text "davor":
+ const SwInsDBColumn& rFndCol = *aDBColumns[ nFndPos ];
+
+ _DB_Column* pNew;
+
+ if( 1 < nSttPos )
+ {
+ ::lcl_InsTextInArr( sTxt.Copy( 0, nSttPos-1 ), rColArr );
+ sTxt.Erase( 0, nSttPos-1 );
+ }
+
+ sTxt.Erase( 0, (xub_StrLen)(rFndCol.sColumn.getLength() + 2) );
+ nSttPos = 0;
+
+ USHORT nSubType = 0;
+ ULONG nFormat;
+ if( rFndCol.bHasFmt )
+ {
+ if( rFndCol.bIsDBFmt )
+ nFormat = rFndCol.nDBNumFmt;
+ else
+ {
+ nFormat = rFndCol.nUsrNumFmt;
+ nSubType = nsSwExtendedSubType::SUB_OWN_FMT;
+ }
+ }
+ else
+ nFormat = 0;
+
+ if( bInsField )
+ {
+ SwWrtShell& rSh = pView->GetWrtShell();
+ SwDBFieldType aFldType( rSh.GetDoc(), aSrch.sColumn,
+ aDBData );
+ pNew = new _DB_Column( rFndCol, *new SwDBField(
+ (SwDBFieldType*)rSh.InsertFldType( aFldType ),
+ nFormat ) );
+ if( nSubType )
+ pNew->DB_ColumnData.pField->SetSubType( nSubType );
+ }
+ else
+ pNew = new _DB_Column( rFndCol, nFormat );
+
+ rColArr.Insert( pNew, rColArr.Count() );
+ }
+ }
+ }
+
+ // den letzten Text nicht vergessen
+ if( sTxt.Len() )
+ ::lcl_InsTextInArr( sTxt, rColArr );
+
+ return 0 != rColArr.Count();
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
+ Reference< XDataSource> xSource,
+ Reference< XConnection> xConnection,
+ Reference< sdbc::XResultSet > xResultSet )
+{
+ const Any* pSelection = rSelection.getLength() ? rSelection.getConstArray() : 0;
+ SwWrtShell& rSh = pView->GetWrtShell();
+
+ //with the drag and drop interface no result set is initially available
+ BOOL bDisposeResultSet = FALSE;
+ // we don't have a cursor, so we have to create our own RowSet
+ if ( !xResultSet.is() )
+ {
+ xResultSet = SwNewDBMgr::createCursor(aDBData.sDataSource,aDBData.sCommand,aDBData.nCommandType,xConnection);
+ bDisposeResultSet = xResultSet.is();
+ }
+
+ Reference< sdbc::XRow > xRow(xResultSet, UNO_QUERY);
+ if ( !xRow.is() )
+ return;
+
+ rSh.StartAllAction();
+ BOOL bUndo = rSh.DoesUndo();
+ if( bUndo )
+ rSh.StartUndo( UNDO_EMPTY );
+
+ BOOL bAsTable = aRbAsTable.IsChecked();
+ SvNumberFormatter& rNumFmtr = *rSh.GetNumberFormatter();
+
+ if( rSh.HasSelection() )
+ rSh.DelRight();
+
+ ::std::auto_ptr<SwWait> pWait;
+
+ Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
+ Reference <XNameAccess> xCols = xColsSupp->getColumns();
+
+ do{ // middle checked loop!!
+ if( bAsTable ) // Daten als Tabelle einfuegen
+ {
+ rSh.DoUndo( FALSE );
+
+ USHORT n, nRows = 0, nCols = aLbTableCol.GetEntryCount();
+ if( aCbTableHeadon.IsChecked() )
+ nRows++;
+
+ if( pSelection )
+ nRows = nRows + (USHORT)rSelection.getLength();
+ else
+ ++nRows;
+
+ // bereite das Array fuer die ausgewaehlten Spalten auf
+ SwInsDBColumns_SAR aColFlds( 255 >= nCols ? (BYTE)nCols : 255, 5 );
+ for( n = 0; n < nCols; ++n )
+ {
+ USHORT nFndPos;
+ SwInsDBColumn aSrch( aLbTableCol.GetEntry( n ), 0 );
+ if( aDBColumns.Seek_Entry( &aSrch, &nFndPos ) )
+ aColFlds.Insert( aDBColumns[ nFndPos ], n );
+ else {
+ ASSERT( !this, "Datenbankspalte nicht mehr gefunden" );
+ }
+ }
+
+ if( nCols != aColFlds.Count() )
+ {
+ ASSERT( !this, "nicht alle Datenbankspalten gefunden" );
+ nCols = aColFlds.Count();
+ }
+
+ if(!nRows || !nCols)
+ {
+ ASSERT( !this, "wrong parameters" );
+ break;
+ }
+
+ const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+
+ BOOL bHTML = 0 != (::GetHtmlMode( pView->GetDocShell() ) & HTMLMODE_ON);
+ rSh.InsertTable(
+ pModOpt->GetInsTblFlags(bHTML),
+ nRows, nCols, text::HoriOrientation::FULL, (pSelection ? pTAutoFmt : 0) );
+ rSh.MoveTable( GetfnTablePrev(), GetfnTableStart() );
+
+ if( pSelection && pTblSet )
+ SetTabSet();
+
+ SfxItemSet aTblSet( rSh.GetAttrPool(), RES_BOXATR_FORMAT,
+ RES_BOXATR_VALUE );
+ BOOL bIsAutoUpdateCells = rSh.IsAutoUpdateCells();
+ rSh.SetAutoUpdateCells( FALSE );
+
+
+ if( aCbTableHeadon.IsChecked() )
+ {
+ for( n = 0; n < nCols; ++n )
+ {
+ if( aRbHeadlColnms.IsChecked() )
+ {
+ rSh.SwEditShell::Insert2( aColFlds[ n ]->sColumn );
+ }
+ rSh.GoNextCell();
+ }
+ }
+ else
+ rSh.SetRowsToRepeat( 0 );
+
+ for( sal_Int32 i = 0 ; ; ++i )
+ {
+ BOOL bBreak = FALSE;
+ try
+ {
+ if(pSelection)
+ {
+ sal_Int32 nPos = 0;
+ pSelection[i] >>= nPos;
+ bBreak = !xResultSet->absolute(nPos);
+ }
+ else if(!i)
+ bBreak = !xResultSet->first();
+ }
+ catch(const Exception& )
+ {
+ bBreak = TRUE;
+ }
+ if(bBreak)
+ break;
+
+ for( n = 0; n < nCols; ++n )
+ {
+ // beim aller erstenmal KEIN GoNextCell, weil wir schon
+ // drin stehen. Auch nicht nach dem Insert das GoNextCell,
+ // weil am Ende eine leere Zeile einfuegt wird.
+ if( i || n )
+ rSh.GoNextCell();
+
+ const SwInsDBColumn* pEntry = aColFlds[ n ];
+
+ Reference< XColumn > xColumn;
+ xCols->getByName(pEntry->sColumn) >>= xColumn;
+ Reference< XPropertySet > xColumnProps( xColumn, UNO_QUERY );
+ sal_Int32 eDataType = 0;
+ if( xColumnProps.is() )
+ {
+ Any aType = xColumnProps->getPropertyValue(C2U("Type"));
+ aType >>= eDataType;
+ }
+ try
+ {
+ if( pEntry->bHasFmt )
+ {
+ SwTblBoxNumFormat aNumFmt(
+ pEntry->bIsDBFmt ? pEntry->nDBNumFmt
+ : pEntry->nUsrNumFmt );
+ aTblSet.Put(aNumFmt);
+ if( xColumn.is() )
+ {
+ double fVal = xColumn->getDouble();
+ if( xColumn->wasNull() )
+ aTblSet.ClearItem( RES_BOXATR_VALUE );
+ else
+ {
+ if(rNumFmtr.GetType(aNumFmt.GetValue()) & NUMBERFORMAT_DATE)
+ {
+ ::Date aStandard(1,1,1900);
+ if (*rNumFmtr.GetNullDate() != aStandard)
+ fVal += (aStandard - *rNumFmtr.GetNullDate());
+ }
+ aTblSet.Put( SwTblBoxValue( fVal ));
+ }
+ }
+ else
+ aTblSet.ClearItem( RES_BOXATR_VALUE );
+ rSh.SetTblBoxFormulaAttrs( aTblSet );
+ }
+ //#i60207# don't insert binary data as string - creates a loop
+ else if( DataType::BINARY == eDataType ||
+ DataType::VARBINARY == eDataType ||
+ DataType::LONGVARBINARY== eDataType ||
+ DataType::SQLNULL == eDataType ||
+ DataType::OTHER == eDataType ||
+ DataType::OBJECT == eDataType ||
+ DataType::DISTINCT == eDataType ||
+ DataType::STRUCT == eDataType ||
+ DataType::ARRAY == eDataType ||
+ DataType::BLOB == eDataType ||
+ DataType::CLOB == eDataType ||
+ DataType::REF == eDataType
+ )
+ {
+ // do nothing
+ }
+ else
+ {
+ rtl::OUString sVal = xColumn->getString();
+ if(!xColumn->wasNull())
+ {
+ rSh.SwEditShell::Insert2( sVal );
+ }
+ }
+ }
+ catch(Exception&
+#ifdef DBG_UTIL
+ aExcept
+#endif
+ )
+ {
+ DBG_ERROR(ByteString(String(aExcept.Message), gsl_getSystemTextEncoding()).GetBuffer());
+ }
+ }
+
+ if( !pSelection )
+ {
+ if ( !xResultSet->next() )
+ break;
+ }
+ else if( i+1 >= rSelection.getLength() )
+ break;
+
+ if( 10 == i )
+ pWait = ::std::auto_ptr<SwWait>(new SwWait( *pView->GetDocShell(), TRUE ));
+ }
+
+ rSh.MoveTable( GetfnTableCurr(), GetfnTableStart() );
+ if( !pSelection && ( pTblSet || pTAutoFmt ))
+ {
+ if( pTblSet )
+ SetTabSet();
+
+ if( pTAutoFmt )
+ rSh.SetTableAutoFmt( *pTAutoFmt );
+ }
+ rSh.SetAutoUpdateCells( bIsAutoUpdateCells );
+ }
+ else // Daten als Felder/Text einfuegen
+ {
+ _DB_Columns aColArr;
+ if( SplitTextToColArr( aEdDbText.GetText(), aColArr, aRbAsField.IsChecked() ) )
+ {
+ // jetzt kann bei jedem Datensatz einfach ueber das Array iteriert
+ // und die Daten eingefuegt werden
+
+ if( !rSh.IsSttPara() )
+ rSh.SwEditShell::SplitNode();
+ if( !rSh.IsEndPara() )
+ {
+ rSh.SwEditShell::SplitNode();
+ rSh.SwCrsrShell::Left(1,CRSR_SKIP_CHARS);
+ }
+
+ rSh.DoUndo( FALSE );
+
+ SwTxtFmtColl* pColl = 0;
+ {
+ String sTmplNm( aLbDbParaColl.GetSelectEntry() );
+ if( sNoTmpl != sTmplNm )
+ {
+ pColl = rSh.FindTxtFmtCollByName( sTmplNm );
+ if( !pColl )
+ {
+ USHORT nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmplNm, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
+ if( USHRT_MAX != nId )
+ pColl = rSh.GetTxtCollFromPool( nId );
+ else
+ pColl = rSh.MakeTxtFmtColl( sTmplNm );
+ }
+ rSh.SetTxtFmtColl( pColl );
+ }
+ }
+
+ // fuers Einfuegen als Felder -> nach jedem Datensatz ein
+ // "NextField" einfuegen
+ SwDBFormatData aDBFormatData;
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ if( xMgr.is() )
+ {
+ Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.util.NumberFormatter" ));
+ aDBFormatData.xFormatter = Reference<util::XNumberFormatter>(xInstance, UNO_QUERY) ;
+ }
+
+ Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
+ if(xSourceProps.is())
+ {
+ Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
+ if(aFormats.hasValue())
+ {
+ Reference< util::XNumberFormatsSupplier> xSuppl;
+ aFormats >>= xSuppl;
+ if(xSuppl.is())
+ {
+ Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
+ Any aNull = xSettings->getPropertyValue(C2U("NullDate"));
+ aNull >>= aDBFormatData.aNullDate;
+ if(aDBFormatData.xFormatter.is())
+ aDBFormatData.xFormatter->attachNumberFormatsSupplier(xSuppl);
+ }
+ }
+ }
+ aDBFormatData.aLocale = SvxCreateLocale( rSh.GetCurLang() );
+ SwDBNextSetField aNxtDBFld( (SwDBNextSetFieldType*)rSh.
+ GetFldType( 0, RES_DBNEXTSETFLD ),
+ C2S("1"), aEmptyStr, aDBData );
+
+
+ BOOL bSetCrsr = TRUE;
+ USHORT n = 0, nCols = aColArr.Count();
+ ::sw::mark::IMark* pMark = NULL;
+ for( sal_Int32 i = 0 ; ; ++i )
+ {
+ BOOL bBreak = FALSE;
+ try
+ {
+ if(pSelection)
+ {
+ sal_Int32 nPos = 0;
+ pSelection[i] >>= nPos;
+ bBreak = !xResultSet->absolute(nPos);
+ }
+ else if(!i)
+ bBreak = !xResultSet->first();
+ }
+ catch(Exception&)
+ {
+ bBreak = TRUE;
+ }
+
+ if(bBreak)
+ break;
+
+
+ for( n = 0; n < nCols; ++n )
+ {
+ _DB_Column* pDBCol = aColArr[ n ];
+ String sIns;
+ switch( pDBCol->eColType )
+ {
+ case _DB_Column::DB_FILLTEXT:
+ sIns = *pDBCol->DB_ColumnData.pText;
+ break;
+
+ case _DB_Column::DB_SPLITPARA:
+ rSh.SplitNode();
+ // wenn nicht die gleiche Vorlage die Follow Vorlage
+ // ist, dann muss die ausgewaehlte neu gesetzt werden
+ if( pColl && &pColl->GetNextTxtFmtColl() != pColl )
+ rSh.SetTxtFmtColl( pColl );
+ break;
+
+ case _DB_Column::DB_COL_FIELD:
+ {
+ SwDBField* pFld = (SwDBField*)pDBCol->DB_ColumnData.
+ pField->Copy();
+ double nValue = DBL_MAX;
+
+ Reference< XPropertySet > xColumnProps;
+ xCols->getByName(pDBCol->pColInfo->sColumn) >>= xColumnProps;
+
+ pFld->SetExpansion( SwNewDBMgr::GetDBField(
+ xColumnProps,
+ aDBFormatData,
+ &nValue ) );
+ if( DBL_MAX != nValue )
+ {
+ Any aType = xColumnProps->getPropertyValue(C2U("Type"));
+ sal_Int32 eDataType = 0;
+ aType >>= eDataType;
+ if( DataType::DATE == eDataType || DataType::TIME == eDataType ||
+ DataType::TIMESTAMP == eDataType)
+
+ {
+ ::Date aStandard(1,1,1900);
+ ::Date aCompare(aDBFormatData.aNullDate.Day ,
+ aDBFormatData.aNullDate.Month,
+ aDBFormatData.aNullDate.Year);
+ if(aStandard != aCompare)
+ nValue += (aStandard - aCompare);
+ }
+ pFld->ChgValue( nValue, TRUE );
+ }
+ pFld->SetInitialized();
+
+ rSh.Insert( *pFld );
+ delete pFld;
+ }
+ break;
+
+ case _DB_Column::DB_COL_TEXT:
+ {
+ double nValue = DBL_MAX;
+ Reference< XPropertySet > xColumnProps;
+ xCols->getByName(pDBCol->pColInfo->sColumn) >>= xColumnProps;
+ sIns = SwNewDBMgr::GetDBField(
+ xColumnProps,
+ aDBFormatData,
+ &nValue );
+ if( pDBCol->DB_ColumnData.nFormat &&
+ DBL_MAX != nValue )
+ {
+ Color* pCol;
+ if(rNumFmtr.GetType(pDBCol->DB_ColumnData.nFormat) & NUMBERFORMAT_DATE)
+ {
+ ::Date aStandard(1,1,1900);
+ if (*rNumFmtr.GetNullDate() != aStandard)
+ nValue += (aStandard - *rNumFmtr.GetNullDate());
+ }
+ rNumFmtr.GetOutputString( nValue,
+ pDBCol->DB_ColumnData.nFormat,
+ sIns, &pCol );
+ }
+ }
+ break;
+ }
+
+ if( sIns.Len() )
+ rSh.Insert( sIns );
+
+ if( bSetCrsr && sIns.Len() )
+ {
+ // zum Anfang und eine Mark setzen, damit der
+ // Cursor am Ende wieder auf Anfangsposition
+ // gesetzt werden kann.
+
+ // rSh.SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
+ rSh.SwCrsrShell::MovePara(
+ GetfnParaCurr(), GetfnParaStart() );
+ pMark = rSh.SetBookmark(
+ KeyCode(),
+ ::rtl::OUString(),
+ ::rtl::OUString(), IDocumentMarkAccess::UNO_BOOKMARK );
+ // rSh.SwCrsrShell::MovePara( fnParaCurr, fnParaEnd );
+ rSh.SwCrsrShell::MovePara(
+ GetfnParaCurr(), GetfnParaEnd() );
+ bSetCrsr = FALSE;
+ }
+ }
+
+ if( !pSelection )
+ {
+ BOOL bNext = xResultSet->next();
+ if(!bNext)
+ break;
+ }
+ else if( i+1 >= rSelection.getLength() )
+ break;
+
+ if( aRbAsField.IsChecked() )
+ rSh.Insert( aNxtDBFld );
+
+ if( !rSh.IsSttPara() )
+ rSh.SwEditShell::SplitNode();
+
+ if( 10 == i )
+ pWait = ::std::auto_ptr<SwWait>(new SwWait( *pView->GetDocShell(), TRUE ));
+ }
+
+ if( !bSetCrsr && pMark != NULL)
+ {
+ rSh.SetMark();
+ rSh.GotoMark( pMark );
+ rSh.getIDocumentMarkAccess()->deleteMark( pMark );
+ break;
+ }
+ }
+ }
+ // write configuration
+ Commit();
+ }while( FALSE ); // middle checked loop
+
+ if( bUndo )
+ {
+ rSh.DoUndo( TRUE );
+ rSh.AppendUndoForInsertFromDB( bAsTable );
+ rSh.EndUndo( UNDO_EMPTY );
+ }
+ rSh.ClearMark();
+ rSh.EndAllAction();
+
+ if ( bDisposeResultSet )
+ ::comphelper::disposeComponent(xResultSet);
+}
+void SwInsertDBColAutoPilot::SetTabSet()
+{
+ SwWrtShell& rSh = pView->GetWrtShell();
+ const SfxPoolItem* pItem;
+
+ if( pTAutoFmt )
+ {
+ if( pTAutoFmt->IsFrame() )
+ {
+ // Umrandung kommt vom AutoFormat
+ pTblSet->ClearItem( RES_BOX );
+ pTblSet->ClearItem( SID_ATTR_BORDER_INNER );
+ }
+ if( pTAutoFmt->IsBackground() )
+ {
+ pTblSet->ClearItem( RES_BACKGROUND );
+ pTblSet->ClearItem( SID_ATTR_BRUSH_ROW );
+ pTblSet->ClearItem( SID_ATTR_BRUSH_TABLE );
+ }
+ }
+ else
+ {
+ // die Defaults wieder entfernen, es macht keinen Sinn sie zu setzen
+ SvxBrushItem aBrush( RES_BACKGROUND );
+ static USHORT __READONLY_DATA aIds[3] =
+ { RES_BACKGROUND, SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE };
+ for( int i = 0; i < 3; ++i )
+ if( SFX_ITEM_SET == pTblSet->GetItemState( aIds[ i ],
+ FALSE, &pItem ) && *pItem == aBrush )
+ pTblSet->ClearItem( aIds[ i ] );
+ }
+
+ if( SFX_ITEM_SET == pTblSet->GetItemState( FN_PARAM_TABLE_NAME, FALSE,
+ &pItem ) && ((const SfxStringItem*)pItem)->GetValue() ==
+ rSh.GetTableFmt()->GetName() )
+ pTblSet->ClearItem( FN_PARAM_TABLE_NAME );
+
+ rSh.MoveTable( GetfnTableCurr(), GetfnTableStart() );
+ rSh.SetMark();
+ rSh.MoveTable( GetfnTableCurr(), GetfnTableEnd() );
+
+ ItemSetToTableParam( *pTblSet, rSh );
+
+ rSh.ClearMark();
+ rSh.MoveTable( GetfnTableCurr(), GetfnTableStart() );
+}
+
+/* */
+
+
+_DB_ColumnConfigData::~_DB_ColumnConfigData() {}
+
+/* -----------------------------05.12.00 16:15--------------------------------
+
+ ---------------------------------------------------------------------------*/
+static Sequence<rtl::OUString> lcl_createSourceNames(const String& rNodeName)
+{
+ Sequence<rtl::OUString> aSourceNames(11);
+ rtl::OUString* pNames = aSourceNames.getArray();
+
+ String sTmp( rNodeName );
+ const xub_StrLen nPos = sTmp.Len();
+ pNames[0] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/DataSource" ));
+ pNames[1] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/Command" ));
+ pNames[2] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/CommandType" ));
+ pNames[3] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/ColumnsToText" ));
+ pNames[4] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/ColumnsToTable" ));
+ pNames[5] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/ParaStyle" ));
+ pNames[6] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/TableAutoFormat" ));
+ pNames[7] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/IsTable" ));
+ pNames[8] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/IsField" ));
+ pNames[9] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/IsHeadlineOn" ));
+ pNames[10] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/IsEmptyHeadline" ));
+ return aSourceNames;
+}
+/* -----------------------------05.12.00 16:25--------------------------------
+
+ ---------------------------------------------------------------------------*/
+static Sequence<rtl::OUString> lcl_CreateSubNames( const String& rSubNodeName )
+{
+ Sequence<rtl::OUString> aSubSourceNames(6);
+ rtl::OUString* pNames = aSubSourceNames.getArray();
+ String sTmp( rSubNodeName );
+ const xub_StrLen nPos = sTmp.Len();
+ pNames[0] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/ColumnName" ));
+ pNames[1] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/ColumnIndex" ));
+ pNames[2] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/IsNumberFormat" ));
+ pNames[3] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/IsNumberFormatFromDataBase" ));
+ pNames[4] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/NumberFormat" ));
+ pNames[5] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
+ RTL_CONSTASCII_STRINGPARAM( "/NumberFormatLocale" ));
+ return aSubSourceNames;
+}
+/* -----------------------------06.12.00 13:03--------------------------------
+
+ ---------------------------------------------------------------------------*/
+static rtl::OUString lcl_CreateUniqueName(const Sequence<rtl::OUString>& aNames)
+{
+ sal_Int32 nIdx = aNames.getLength();
+ const rtl::OUString* pNames = aNames.getConstArray();
+ rtl::OUString sTest(C2U("_"));
+ rtl::OUString sRet;
+ while(sal_True)
+ {
+ sRet = sTest; sRet += rtl::OUString::valueOf(nIdx++);
+ sal_Bool bFound = sal_False;
+ for(sal_Int32 i = 0; i < aNames.getLength(); i++)
+ {
+ if(pNames[i] == sRet)
+ {
+ bFound = sal_True;
+ break;
+ }
+ }
+ if(!bFound)
+ break;
+ }
+ return sRet;
+}
+/* -----------------------------05.12.00 15:00--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwInsertDBColAutoPilot::Commit()
+{
+ Sequence <rtl::OUString> aNames = GetNodeNames(rtl::OUString());
+ const rtl::OUString* pNames = aNames.getArray();
+ //remove entries that contain this data source + table at first
+ for(sal_Int32 nNode = 0; nNode < aNames.getLength(); nNode++)
+ {
+ Sequence<rtl::OUString> aSourceNames(2);
+ rtl::OUString* pSourceNames = aSourceNames.getArray();
+ pSourceNames[0] = pNames[nNode];
+ pSourceNames[0] += C2U("/DataSource");
+ pSourceNames[1] = pNames[nNode];
+ pSourceNames[1] += C2U("/Command");
+ Sequence<Any> aSourceProperties = GetProperties(aSourceNames);
+ const Any* pSourceProps = aSourceProperties.getArray();
+ rtl::OUString sSource, sCommand;
+ pSourceProps[0] >>= sSource;
+ pSourceProps[1] >>= sCommand;
+ if(sSource.equals(aDBData.sDataSource) && sCommand.equals(aDBData.sCommand))
+ {
+ Sequence<rtl::OUString> aElements(1);
+ aElements.getArray()[0] = pNames[nNode];
+ ClearNodeElements(rtl::OUString(), aElements);
+ }
+ }
+
+ aNames = GetNodeNames(rtl::OUString());
+ rtl::OUString sNewNode = lcl_CreateUniqueName(aNames);
+ Sequence<rtl::OUString> aNodeNames = lcl_createSourceNames(sNewNode);
+ Sequence<PropertyValue> aValues(aNodeNames.getLength());
+ PropertyValue* pValues = aValues.getArray();
+ const rtl::OUString* pNodeNames = aNodeNames.getConstArray();
+ rtl::OUString sSlash(C2U("/"));
+ for(sal_Int32 i = 0; i < aNodeNames.getLength(); i++)
+ {
+ pValues[i].Name = sSlash;
+ pValues[i].Name += pNodeNames[i];
+ }
+
+ pValues[0].Value <<= rtl::OUString(aDBData.sDataSource);
+ pValues[1].Value <<= rtl::OUString(aDBData.sCommand);
+ pValues[2].Value <<= aDBData.nCommandType;
+ pValues[3].Value <<= rtl::OUString(aEdDbText.GetText());
+
+ String sTmp;
+ for( USHORT n = 0, nCnt = aLbTableCol.GetEntryCount(); n < nCnt; ++n )
+ ( sTmp += aLbTableCol.GetEntry( n ) ) += '\x0a';
+
+ if( sTmp.Len() )
+ pValues[4].Value <<= rtl::OUString(sTmp);
+
+ if( sNoTmpl != (sTmp = aLbDbParaColl.GetSelectEntry()) )
+ pValues[5].Value <<= rtl::OUString(sTmp);
+
+ if( pTAutoFmt )
+ pValues[6].Value <<= rtl::OUString(pTAutoFmt->GetName());
+
+ const Type& rBoolType = ::getBooleanCppuType();
+ sal_Bool bTmp = aRbAsTable.IsChecked();
+ pValues[7].Value.setValue(&bTmp, rBoolType);
+
+ bTmp = aRbAsField.IsChecked();
+ pValues[8].Value.setValue(&bTmp, rBoolType);
+
+ bTmp = aCbTableHeadon.IsChecked();
+ pValues[9].Value.setValue(&bTmp, rBoolType);
+
+ bTmp = aRbHeadlEmpty.IsChecked();
+ pValues[10].Value.setValue(&bTmp, rBoolType);
+
+ SetSetProperties(rtl::OUString(), aValues);
+
+ sNewNode += C2U("/ColumnSet");
+ String sDelim( String::CreateFromAscii( "/__" ));
+
+ LanguageType ePrevLang = (LanguageType)-1;
+ rtl::OUString sPrevLang;
+
+ SvNumberFormatter& rNFmtr = *pView->GetWrtShell().GetNumberFormatter();
+ for(USHORT nCol = 0; nCol < aDBColumns.Count(); nCol++)
+ {
+ rtl::OUString sColumnNode = sNewNode;
+ SwInsDBColumn* pColumn = aDBColumns[nCol];
+ String sColumnInsertNode(sColumnNode);
+ sColumnInsertNode += sDelim;
+ if( nCol < 100 )
+ sColumnInsertNode += '0';
+ if( nCol < 10 )
+ sColumnInsertNode += '0';
+ sColumnInsertNode += String::CreateFromInt32( nCol );
+
+ Sequence <rtl::OUString> aSubNodeNames = lcl_CreateSubNames(sColumnInsertNode);
+ Sequence<PropertyValue> aSubValues(aSubNodeNames.getLength());
+ PropertyValue* pSubValues = aSubValues.getArray();
+ const rtl::OUString* pSubNodeNames = aSubNodeNames.getConstArray();
+ sal_Int32 i;
+
+ for( i = 0; i < aSubNodeNames.getLength(); i++)
+ pSubValues[i].Name = pSubNodeNames[i];
+ pSubValues[0].Value <<= pColumn->sColumn;
+ pSubValues[1].Value <<= i;
+
+ sal_Bool bVal = pColumn->bHasFmt;
+ pSubValues[2].Value.setValue(&bVal, rBoolType);
+ bVal = pColumn->bIsDBFmt;
+ pSubValues[3].Value.setValue(&bVal, rBoolType);
+
+ SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sTmp );
+ const SvNumberformat* pNF = rNFmtr.GetEntry( pColumn->nUsrNumFmt );
+ LanguageType eLang;
+ if( pNF )
+ {
+ pSubValues[4].Value <<= rtl::OUString(pNF->GetFormatstring());
+ eLang = pNF->GetLanguage();
+ }
+ else
+ {
+ pSubValues[4].Value <<= rtl::OUString(sTmp);
+ eLang = (LanguageType)GetAppLanguage();
+ }
+
+ if( eLang != ePrevLang )
+ {
+ Locale aLocale;
+ aLocale = SvxLanguageToLocale( aLocale, eLang );
+ (( sPrevLang = aLocale.Country ) += rtl::OUString( '-' )) += aLocale.Language;
+ ePrevLang = eLang;
+ }
+
+ pSubValues[5].Value <<= sPrevLang;
+ SetSetProperties(sColumnNode, aSubValues);
+ }
+}
+/* -----------------------------05.12.00 15:00--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwInsertDBColAutoPilot::Load()
+{
+ Sequence <rtl::OUString> aNames = GetNodeNames(rtl::OUString());
+ const rtl::OUString* pNames = aNames.getArray();
+ SvNumberFormatter& rNFmtr = *pView->GetWrtShell().GetNumberFormatter();
+ for(sal_Int32 nNode = 0; nNode < aNames.getLength(); nNode++)
+ {
+ //search for entries with the appropriate data source and table
+ Sequence<rtl::OUString> aSourceNames = lcl_createSourceNames(pNames[nNode]);
+
+ Sequence< Any> aDataSourceProps = GetProperties(aSourceNames);
+ const Any* pDataSourceProps = aDataSourceProps.getConstArray();
+ rtl::OUString sSource, sCommand;
+ sal_Int16 nCommandType;
+ pDataSourceProps[0] >>= sSource;
+ pDataSourceProps[1] >>= sCommand;
+ pDataSourceProps[2] >>= nCommandType;
+ if(sSource.equals(aDBData.sDataSource) && sCommand.equals(aDBData.sCommand))
+ {
+ _DB_ColumnConfigData* pNewData = new _DB_ColumnConfigData;
+ pNewData->sSource = sSource;
+ pNewData->sTable = sCommand;
+
+ pDataSourceProps[3] >>= pNewData->sEdit;
+ pDataSourceProps[4] >>= pNewData->sTblList;
+ pDataSourceProps[5] >>= pNewData->sTmplNm;
+ pDataSourceProps[6] >>= pNewData->sTAutoFmtNm;
+ if(pDataSourceProps[7].hasValue())
+ pNewData->bIsTable = *(sal_Bool*)pDataSourceProps[7].getValue();
+ if(pDataSourceProps[8].hasValue())
+ pNewData->bIsField = *(sal_Bool*)pDataSourceProps[8].getValue();
+ if(pDataSourceProps[9].hasValue())
+ pNewData->bIsHeadlineOn = *(sal_Bool*)pDataSourceProps[9].getValue();
+ if(pDataSourceProps[10].hasValue())
+ pNewData->bIsEmptyHeadln = *(sal_Bool*)pDataSourceProps[10].getValue();
+
+ rtl::OUString sSubNodeName(pNames[nNode]);
+ sSubNodeName += C2U("/ColumnSet/");
+ Sequence <rtl::OUString> aSubNames = GetNodeNames(sSubNodeName);
+ const rtl::OUString* pSubNames = aSubNames.getConstArray();
+ for(sal_Int32 nSub = 0; nSub < aSubNames.getLength(); nSub++)
+ {
+ rtl::OUString sSubSubNodeName(sSubNodeName);
+ sSubSubNodeName += pSubNames[nSub];
+ Sequence <rtl::OUString> aSubNodeNames = lcl_CreateSubNames(sSubSubNodeName);
+ Sequence< Any> aSubProps = GetProperties(aSubNodeNames);
+ const Any* pSubProps = aSubProps.getConstArray();
+
+ rtl::OUString sColumn;
+ pSubProps[0] >>= sColumn;
+ //check for existance of the loaded column name
+ sal_Bool bFound = sal_False;
+ for(sal_Int32 nRealColumn = 0; nRealColumn < aDBColumns.Count(); nRealColumn++)
+ {
+ if(aDBColumns[(USHORT)nRealColumn]->sColumn == sColumn)
+ {
+ bFound = sal_True;
+ break;
+ }
+ }
+ if(!bFound)
+ continue;
+ sal_Int16 nIndex = 0;
+ pSubProps[1] >>= nIndex;
+ SwInsDBColumnPtr pInsDBColumn = new SwInsDBColumn(sColumn, nIndex);
+ if(pSubProps[2].hasValue())
+ pInsDBColumn->bHasFmt = *(sal_Bool*)pSubProps[2].getValue();
+ if(pSubProps[3].hasValue())
+ pInsDBColumn->bIsDBFmt = *(sal_Bool*)pSubProps[3].getValue();
+
+ pSubProps[4] >>= pInsDBColumn->sUsrNumFmt;
+ rtl::OUString sNumberFormatLocale;
+ pSubProps[5] >>= sNumberFormatLocale;
+
+ Locale aLocale;
+ aLocale.Language = sNumberFormatLocale.copy(0, 2);
+ aLocale.Country = sNumberFormatLocale.copy(3, 2);
+ pInsDBColumn->eUsrNumFmtLng = SvxLocaleToLanguage( aLocale );
+
+ pInsDBColumn->nUsrNumFmt = rNFmtr.GetEntryKey( pInsDBColumn->sUsrNumFmt,
+ pInsDBColumn->eUsrNumFmtLng );
+
+// pInsDBColumn->nDBNumFmt
+
+ pNewData->aDBColumns.Insert(pInsDBColumn);
+ }
+ USHORT n = 0;
+ String sTmp( pNewData->sTblList );
+ if( sTmp.Len() )
+ {
+ do {
+ String sEntry( sTmp.GetToken( 0, '\x0a', n ) );
+ //preselect column - if they still exist!
+ if(aLbTblDbColumn.GetEntryPos(sEntry) != LISTBOX_ENTRY_NOTFOUND)
+ {
+ aLbTableCol.InsertEntry( sEntry );
+ aLbTblDbColumn.RemoveEntry( sEntry );
+ }
+ } while( n < sTmp.Len() );
+
+ if( !aLbTblDbColumn.GetEntryCount() )
+ {
+ aIbDbcolAllTo.Enable( FALSE );
+ aIbDbcolOneTo.Enable( FALSE );
+ }
+ aIbDbcolOneFrom.Enable( TRUE );
+ aIbDbcolAllFrom.Enable( TRUE );
+ }
+ aEdDbText.SetText( pNewData->sEdit );
+
+ sTmp = pNewData->sTmplNm;
+ if( sTmp.Len() )
+ aLbDbParaColl.SelectEntry( sTmp );
+ else
+ aLbDbParaColl.SelectEntryPos( 0 );
+
+ if( pTAutoFmt )
+ delete pTAutoFmt, pTAutoFmt = 0;
+ sTmp = pNewData->sTAutoFmtNm;
+ if( sTmp.Len() )
+ {
+ // dann erstmal die AutoFmt-Datei laden und das Autoformat suchen
+ SwTableAutoFmtTbl aAutoFmtTbl;
+ aAutoFmtTbl.Load();
+ for( USHORT nAutoFmt = aAutoFmtTbl.Count(); nAutoFmt; )
+ if( sTmp == aAutoFmtTbl[ --nAutoFmt ]->GetName() )
+ {
+ pTAutoFmt = new SwTableAutoFmt( *aAutoFmtTbl[ nAutoFmt ] );
+ break;
+ }
+ }
+
+ aRbAsTable.Check( pNewData->bIsTable );
+ aRbAsField.Check( pNewData->bIsField );
+ aRbAsText.Check( !pNewData->bIsTable && !pNewData->bIsField );
+
+ aCbTableHeadon.Check( pNewData->bIsHeadlineOn );
+ aRbHeadlColnms.Check( !pNewData->bIsEmptyHeadln );
+ aRbHeadlEmpty.Check( pNewData->bIsEmptyHeadln );
+ HeaderHdl(&aCbTableHeadon);
+
+ // jetzt noch die benutzerdefinierten Numberformat Strings in die
+ // Shell kopieren. Nur diese sind dann als ID verfuegbar
+ for( n = 0; n < aDBColumns.Count() ; ++n )
+ {
+ SwInsDBColumn& rSet = *aDBColumns[ n ];
+ for( USHORT m = 0; m < pNewData->aDBColumns.Count() ; ++m )
+ {
+ const SwInsDBColumn& rGet = *pNewData->aDBColumns[ m ];
+ if(rGet.sColumn == rSet.sColumn)
+ {
+ if( rGet.bHasFmt && !rGet.bIsDBFmt )
+ {
+ rSet.bIsDBFmt = FALSE;
+ rSet.nUsrNumFmt = rNFmtr.GetEntryKey( rGet.sUsrNumFmt,
+ rGet.eUsrNumFmtLng );
+ if( NUMBERFORMAT_ENTRY_NOT_FOUND == rSet.nUsrNumFmt )
+ {
+ xub_StrLen nCheckPos;
+ short nType;
+ rNFmtr.PutEntry( (String&)rGet.sUsrNumFmt, nCheckPos, nType,
+ rSet.nUsrNumFmt, rGet.eUsrNumFmtLng );
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ // steht der Cursor in einer Tabelle, darf NIE Tabelle auswaehlbar sein
+ if( !aRbAsTable.IsEnabled() && aRbAsTable.IsChecked() )
+ aRbAsField.Check( TRUE );
+ delete pNewData;
+ break;
+ }
+ }
+}
+
diff --git a/sw/source/ui/dbui/dbinsdlg.hrc b/sw/source/ui/dbui/dbinsdlg.hrc
new file mode 100644
index 000000000000..b1ea954a2974
--- /dev/null
+++ b/sw/source/ui/dbui/dbinsdlg.hrc
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbinsdlg.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBINSDLG_HRC
+#define _DBINSDLG_HRC
+
+
+#define FT_INSERT_DATA 1
+#define RB_AS_TABLE 2
+#define RB_AS_FIELD 3
+#define RB_AS_TEXT 4
+#define BT_OK 5
+#define BT_CANCEL 6
+#define BT_HELP 7
+#define FL_HEAD 8
+#define FT_DB_COLUMN 10
+#define FL_FORMAT 11
+#define RB_DBFMT_FROM_DB 12
+#define RB_DBFMT_FROM_USR 13
+#define LB_DBFMT_FROM_USR 14
+
+/* ------------- Page Text/Field ------------------ */
+#define LB_TXT_DB_COLUMN 15
+
+#define IB_DBCOL_TOEDIT 16
+#define ED_DB_TEXT 17
+#define FT_DB_PARA_COLL 18
+#define LB_DB_PARA_COLL 19
+
+/* ------------- Page Table -------------------- */
+#define LB_TBL_DB_COLUMN 20
+
+#define IB_DBCOL_ALL_TO 21
+#define IB_DBCOL_ONE_TO 22
+#define IB_DBCOL_ONE_FROM 23
+#define IB_DBCOL_ALL_FROM 24
+#define FT_TABLE_COL 25
+#define LB_TABLE_COL 26
+#define FL_BOTTOM 27
+#define CB_TABLE_HEADON 28
+#define RB_HEADL_COLNMS 29
+#define RB_HEADL_EMPTY 30
+#define PB_TBL_FORMAT 31
+#define PB_TBL_AUTOFMT 32
+
+#define STR_NOTEMPL 33
+
+
+#endif
diff --git a/sw/source/ui/dbui/dbinsdlg.src b/sw/source/ui/dbui/dbinsdlg.src
new file mode 100644
index 000000000000..5b0cc5074756
--- /dev/null
+++ b/sw/source/ui/dbui/dbinsdlg.src
@@ -0,0 +1,312 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbinsdlg.src,v $
+ * $Revision: 1.48 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "dbinsdlg.hrc"
+#include "dbui.hrc"
+#include "cmdid.h"
+#include "helpid.h"
+ModalDialog DLG_AP_INSERT_DB_SEL
+{
+ HelpID = HID_AP_INSERT_DB_SEL ;
+ OUTPUTSIZE = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 291 , 189 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ SVLOOK = TRUE ;
+ FixedText FT_INSERT_DATA
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 66 , 8 ) ;
+ Text [ en-US ] = "Insert data as:" ;
+ };
+ RadioButton RB_AS_TABLE
+ {
+ Pos = MAP_APPFONT ( 80 , 6 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ TabStop = TRUE ;
+ Check = TRUE ;
+ Text [ en-US ] = "T~able" ;
+ };
+ RadioButton RB_AS_FIELD
+ {
+ Pos = MAP_APPFONT ( 145 , 6 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Fields" ;
+ };
+ RadioButton RB_AS_TEXT
+ {
+ Pos = MAP_APPFONT ( 210 , 6 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Text" ;
+ };
+ OKButton BT_OK
+ {
+ Pos = MAP_APPFONT ( 123 , 172 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BT_CANCEL
+ {
+ Pos = MAP_APPFONT ( 179 , 172 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BT_HELP
+ {
+ Pos = MAP_APPFONT ( 235 , 172 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_HEAD
+ {
+ Pos = MAP_APPFONT ( 6 , 19 ) ;
+ Size = MAP_APPFONT ( 279 , 8 ) ;
+ /* wird dynamisch gesetzt! */
+ Text = "" ;
+ };
+ FixedText FT_DB_COLUMN
+ {
+ Pos = MAP_APPFONT ( 12 , 31 ) ;
+ Size = MAP_APPFONT ( 72 , 8 ) ;
+ Text [ en-US ] = "Database ~columns" ;
+ };
+ FixedLine FL_FORMAT
+ {
+ Pos = MAP_APPFONT ( 6 , 117 ) ;
+ Size = MAP_APPFONT ( 279 , 8 ) ;
+ Text [ en-US ] = "For~mat" ;
+ };
+ RadioButton RB_DBFMT_FROM_DB
+ {
+ Pos = MAP_APPFONT ( 15 , 128 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+ TabStop = TRUE ;
+ Check = TRUE ;
+ Text [ en-US ] = "From ~database" ;
+ };
+ RadioButton RB_DBFMT_FROM_USR
+ {
+ Pos = MAP_APPFONT ( 15 , 143 ) ;
+ Size = MAP_APPFONT ( 10 , 10 ) ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_DBFMT_FROM_USR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 30 , 142 ) ;
+ Size = MAP_APPFONT ( 75 , 44 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoHScroll = TRUE ;
+ };
+ /* -------------- Page Text / Fields -------------------------------- */
+ ListBox LB_TXT_DB_COLUMN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 41 ) ;
+ Size = MAP_APPFONT ( 93 , 70 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ ImageButton IB_DBCOL_TOEDIT
+ {
+ Pos = MAP_APPFONT ( 111 , 41 ) ;
+ Size = MAP_APPFONT ( 20 , 12 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "one_right.bmp" ;
+ };
+ MaskColor = IMAGE_MASK_COLOR ;
+ };
+ };
+ MultiLineEdit ED_DB_TEXT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 137 , 41 ) ;
+ Size = MAP_APPFONT ( 142 , 70 ) ;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ VScroll = TRUE ;
+ HScroll = TRUE ;
+ Hide = TRUE ;
+ IgnoreTab = TRUE;
+ };
+ FixedText FT_DB_PARA_COLL
+ {
+ Pos = MAP_APPFONT ( 118 , 129 ) ;
+ Size = MAP_APPFONT ( 58 , 8 ) ;
+ Text [ en-US ] = "Paragraph ~Style:" ;
+ Hide = TRUE ;
+ };
+ ListBox LB_DB_PARA_COLL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 182 , 127 ) ;
+ Size = MAP_APPFONT ( 97 , 59 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Hide = TRUE ;
+ Sort = TRUE ;
+ };
+ /* -------------- Page Table ---------------------------------------- */
+ ListBox LB_TBL_DB_COLUMN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 41 ) ;
+ Size = MAP_APPFONT ( 93 , 70 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_DBCOL_ALL_TO
+ {
+ Pos = MAP_APPFONT ( 111 , 41 ) ;
+ Size = MAP_APPFONT ( 20 , 12 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "all_right.bmp" ;
+ };
+ MaskColor = IMAGE_MASK_COLOR ;
+ };
+ };
+ ImageButton IB_DBCOL_ONE_TO
+ {
+ Pos = MAP_APPFONT ( 111 , 56 ) ;
+ Size = MAP_APPFONT ( 20 , 12 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "one_right.bmp" ;
+ };
+ MaskColor = IMAGE_MASK_COLOR ;
+ };
+ };
+ ImageButton IB_DBCOL_ONE_FROM
+ {
+ Pos = MAP_APPFONT ( 111 , 84 ) ;
+ Size = MAP_APPFONT ( 20 , 12 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "one_left.bmp" ;
+ };
+ MaskColor = IMAGE_MASK_COLOR ;
+ };
+ };
+ ImageButton IB_DBCOL_ALL_FROM
+ {
+ Pos = MAP_APPFONT ( 111 , 99 ) ;
+ Size = MAP_APPFONT ( 20 , 12 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "all_left.bmp" ;
+ };
+ MaskColor = IMAGE_MASK_COLOR ;
+ };
+ };
+ FixedText FT_TABLE_COL
+ {
+ Pos = MAP_APPFONT ( 137 , 31 ) ;
+ Size = MAP_APPFONT ( 75 , 8 ) ;
+
+ Text [ en-US ] = "Tab~le column(s)" ;
+ };
+ ListBox LB_TABLE_COL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 137 , 41 ) ;
+ Size = MAP_APPFONT ( 75 , 70 ) ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_BOTTOM
+ {
+ Pos = MAP_APPFONT ( 0 , 164 ) ;
+ Size = MAP_APPFONT ( 291, 8 ) ;
+ };
+ CheckBox CB_TABLE_HEADON
+ {
+ Pos = MAP_APPFONT ( 111 , 128 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ TabStop = TRUE ;
+ Check = TRUE ;
+ Text [ en-US ] = "Insert table heading";
+ };
+ RadioButton RB_HEADL_COLNMS
+ {
+ Pos = MAP_APPFONT ( 120 , 142 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+ TabStop = TRUE ;
+ Check = TRUE ;
+ Text [ en-US ] = "Apply column ~name";
+ };
+ RadioButton RB_HEADL_EMPTY
+ {
+ Pos = MAP_APPFONT ( 120 , 155 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Create row only";
+ };
+ PushButton PB_TBL_FORMAT
+ {
+ Pos = MAP_APPFONT ( 214 , 128 ) ;
+ Size = MAP_APPFONT ( 65 , 12 ) ;
+ Text [ en-US ] = "Pr~operties..." ;
+ TabStop = TRUE ;
+ };
+ PushButton PB_TBL_AUTOFMT
+ {
+ Pos = MAP_APPFONT ( 214 , 144 ) ;
+ Size = MAP_APPFONT ( 65 , 12 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Aut~oFormat..." ;
+ };
+ String STR_NOTEMPL
+ {
+ Text [ en-US ] = "<none>" ;
+ };
+ Text [ en-US ] = "Insert Database Columns" ;
+};
+
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
new file mode 100644
index 000000000000..603af1c31111
--- /dev/null
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -0,0 +1,3403 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbmgr.cxx,v $
+ * $Revision: 1.132.44.2 $
+ *
+ * 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"
+#if STLPORT_VERSION>=321
+#include <cstdarg>
+#endif
+
+#include <stdio.h>
+#include <unotxdoc.hxx>
+#include <com/sun/star/text/NotePrintMode.hpp>
+#include <sfx2/app.hxx>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/XCompletedExecution.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/text/MailMergeEvent.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <dbconfig.hxx>
+#include <swdbtoolsclient.hxx>
+#include <pagedesc.hxx>
+#include <vcl/lstbox.hxx>
+#include <unotools/tempfile.hxx>
+#include <svtools/pathoptions.hxx>
+#include <svtools/urihelper.hxx>
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_STRINGSDTOR
+#include <svtools/svstdarr.hxx>
+#endif
+#include <svtools/zforlist.hxx>
+#include <svtools/zformat.hxx>
+#include <svtools/stritem.hxx>
+#include <svtools/eitem.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/progress.hxx>
+#include <sfx2/dispatch.hxx>
+#include <goodies/mailenum.hxx>
+#include <cmdid.h>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <edtwin.hxx>
+#include <wrtsh.hxx>
+#include <fldbas.hxx>
+#include <initui.hxx>
+#include <swundo.hxx>
+#include <flddat.hxx>
+#include <modcfg.hxx>
+#include <swprtopt.hxx>
+#include <shellio.hxx>
+#include <dbui.hxx>
+#include <dbmgr.hxx>
+#include <doc.hxx>
+#include <swwait.hxx>
+#include <swunohelper.hxx>
+#include <dbui.hrc>
+#include <globals.hrc>
+#include <statstr.hrc>
+#include <mmconfigitem.hxx>
+#include <sfx2/request.hxx>
+#include <hintids.hxx>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/mail/MailAttachment.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/property.hxx>
+#include <mailmergehelper.hxx>
+#include <maildispatcher.hxx>
+#include <svx/htmlcfg.hxx>
+#include <i18npool/mslangid.hxx>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <svx/langitem.hxx>
+#include <svtools/numuno.hxx>
+
+#include <unomailmerge.hxx>
+#include <sfx2/event.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <vos/mutex.hxx>
+#include <rtl/textenc.h>
+#include <ndindex.hxx>
+#include <pam.hxx>
+#include <swcrsr.hxx>
+#include <swevent.hxx>
+#include <osl/file.hxx>
+#include <swabstdlg.hxx>
+#include <fmthdft.hxx>
+#include <dbui.hrc>
+#include <envelp.hrc>
+#include <memory>
+#include <vector>
+#include <unomid.h>
+
+using namespace ::osl;
+using namespace ::svx;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::ui::dialogs;
+
+#define DB_SEP_SPACE 0
+#define DB_SEP_TAB 1
+#define DB_SEP_RETURN 2
+#define DB_SEP_NEWLINE 3
+
+SV_IMPL_PTRARR(SwDSParamArr, SwDSParamPtr);
+const sal_Char cCursor[] = "Cursor";
+const sal_Char cCommand[] = "Command";
+const sal_Char cCommandType[] = "CommandType";
+const sal_Char cDataSourceName[] = "DataSourceName";
+const sal_Char cSelection[] = "Selection";
+const sal_Char cActiveConnection[] = "ActiveConnection";
+
+// -----------------------------------------------------------------------------
+// Use nameless namespace to avoid to rubbish the global namespace
+// -----------------------------------------------------------------------------
+namespace
+{
+
+bool lcl_getCountFromResultSet( sal_Int32& rCount, const uno::Reference<XResultSet>& xResultSet )
+{
+ uno::Reference<XPropertySet> xPrSet(xResultSet, UNO_QUERY);
+ if(xPrSet.is())
+ {
+ try
+ {
+ sal_Bool bFinal = sal_False;
+ Any aFinal = xPrSet->getPropertyValue(C2U("IsRowCountFinal"));
+ aFinal >>= bFinal;
+ if(!bFinal)
+ {
+ xResultSet->last();
+ xResultSet->first();
+ }
+ Any aCount = xPrSet->getPropertyValue(C2U("RowCount"));
+ if( aCount >>= rCount )
+ return true;
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ return false;
+}
+// #122799# copy compatibility options
+void lcl_CopyCompatibilityOptions( SwWrtShell& rSourceShell, SwWrtShell& rTargetShell)
+{
+ IDocumentSettingAccess* pIDsa = rSourceShell.getIDocumentSettingAccess();
+
+ rTargetShell.SetParaSpaceMax( pIDsa->get(IDocumentSettingAccess::PARA_SPACE_MAX));
+ rTargetShell.SetParaSpaceMaxAtPages(pIDsa->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES));
+ rTargetShell.SetTabCompat( pIDsa->get(IDocumentSettingAccess::TAB_COMPAT));
+ rTargetShell.SetAddExtLeading( pIDsa->get(IDocumentSettingAccess::ADD_EXT_LEADING));
+ rTargetShell.SetUseVirDev( pIDsa->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE));
+ rTargetShell.SetAddParaSpacingToTableCells( pIDsa->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS));
+ rTargetShell.SetUseFormerLineSpacing( pIDsa->get(IDocumentSettingAccess::OLD_LINE_SPACING));
+ rTargetShell.SetUseFormerObjectPositioning( pIDsa->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS));
+ rTargetShell.SetConsiderWrapOnObjPos( pIDsa->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION));
+ rTargetShell.SetUseFormerTextWrapping( pIDsa->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING));
+}
+}
+/* -----------------09.12.2002 12:35-----------------
+ *
+ * --------------------------------------------------*/
+
+class SwConnectionDisposedListener_Impl : public cppu::WeakImplHelper1
+< lang::XEventListener >
+{
+ SwNewDBMgr& rDBMgr;
+
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
+public:
+ SwConnectionDisposedListener_Impl(SwNewDBMgr& rMgr);
+ ~SwConnectionDisposedListener_Impl();
+
+};
+// -----------------------------------------------------------------------------
+struct SwNewDBMgr_Impl
+{
+ SwDSParam* pMergeData;
+ AbstractMailMergeDlg* pMergeDialog;
+ uno::Reference<lang::XEventListener> xDisposeListener;
+
+ SwNewDBMgr_Impl(SwNewDBMgr& rDBMgr)
+ :pMergeData(0)
+ ,pMergeDialog(0)
+ ,xDisposeListener(new SwConnectionDisposedListener_Impl(rDBMgr))
+ {}
+};
+/*-- 24.10.2003 15:54:18---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void lcl_InitNumberFormatter(SwDSParam& rParam, uno::Reference<XDataSource> xSource)
+{
+ uno::Reference<XMultiServiceFactory> xMgr = ::comphelper::getProcessServiceFactory();
+ if( xMgr.is() )
+ {
+ uno::Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.util.NumberFormatter" ));
+ rParam.xFormatter = uno::Reference<util::XNumberFormatter>(xInstance, UNO_QUERY) ;
+ }
+ if(!xSource.is())
+ xSource = SwNewDBMgr::getDataSourceAsParent(rParam.xConnection, rParam.sDataSource);
+
+ uno::Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
+ if(xSourceProps.is())
+ {
+ Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
+ if(aFormats.hasValue())
+ {
+ uno::Reference<XNumberFormatsSupplier> xSuppl;
+ aFormats >>= xSuppl;
+ if(xSuppl.is())
+ {
+ uno::Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
+ Any aNull = xSettings->getPropertyValue(C2U("NullDate"));
+ aNull >>= rParam.aNullDate;
+ if(rParam.xFormatter.is())
+ rParam.xFormatter->attachNumberFormatsSupplier(xSuppl);
+ }
+ }
+ }
+}
+/* -----------------------------17.07.00 17:04--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL lcl_MoveAbsolute(SwDSParam* pParam, long nAbsPos)
+{
+ BOOL bRet = FALSE;
+ try
+ {
+ if(pParam->bScrollable)
+ {
+ bRet = pParam->xResultSet->absolute( nAbsPos );
+ }
+ else
+ {
+ DBG_ERROR("no absolute positioning available");
+ }
+ }
+ catch(Exception aExcept)
+ {
+ }
+ return bRet;
+}
+/* -----------------------------17.07.00 17:23--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL lcl_GetColumnCnt(SwDSParam* pParam,
+ const String& rColumnName, long nLanguage, String& rResult, double* pNumber)
+{
+ uno::Reference< XColumnsSupplier > xColsSupp( pParam->xResultSet, UNO_QUERY );
+ uno::Reference<XNameAccess> xCols;
+ try
+ {
+ xCols = xColsSupp->getColumns();
+ }
+ catch( lang::DisposedException& )
+ {
+ }
+ if(!xCols.is() || !xCols->hasByName(rColumnName))
+ return FALSE;
+ Any aCol = xCols->getByName(rColumnName);
+ uno::Reference< XPropertySet > xColumnProps;
+ aCol >>= xColumnProps;
+
+ SwDBFormatData aFormatData;
+ if(!pParam->xFormatter.is())
+ {
+ uno::Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(
+ pParam->xConnection,pParam->sDataSource);
+ lcl_InitNumberFormatter(*pParam, xSource );
+ }
+ aFormatData.aNullDate = pParam->aNullDate;
+ aFormatData.xFormatter = pParam->xFormatter;
+
+ MsLangId::convertLanguageToLocale( (LanguageType)nLanguage, aFormatData.aLocale );
+
+ rResult = SwNewDBMgr::GetDBField( xColumnProps, aFormatData, pNumber);
+ return TRUE;
+};
+/*--------------------------------------------------------------------
+ Beschreibung: Daten importieren
+ --------------------------------------------------------------------*/
+BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc )
+{
+ SetMergeType( rMergeDesc.nMergeType );
+
+ DBG_ASSERT(!bInMerge && !pImpl->pMergeData, "merge already activated!");
+
+ SwDBData aData;
+ aData.nCommandType = CommandType::TABLE;
+ uno::Reference<XResultSet> xResSet;
+ Sequence<Any> aSelection;
+ uno::Reference< XConnection> xConnection;
+
+ aData.sDataSource = rMergeDesc.rDescriptor.getDataSource();
+ rMergeDesc.rDescriptor[daCommand] >>= aData.sCommand;
+ rMergeDesc.rDescriptor[daCommandType] >>= aData.nCommandType;
+
+ if ( rMergeDesc.rDescriptor.has(daCursor) )
+ rMergeDesc.rDescriptor[daCursor] >>= xResSet;
+ if ( rMergeDesc.rDescriptor.has(daSelection) )
+ rMergeDesc.rDescriptor[daSelection] >>= aSelection;
+ if ( rMergeDesc.rDescriptor.has(daConnection) )
+ rMergeDesc.rDescriptor[daConnection] >>= xConnection;
+
+ if(!aData.sDataSource.getLength() || !aData.sCommand.getLength() || !xResSet.is())
+ {
+ return FALSE;
+ }
+
+ pImpl->pMergeData = new SwDSParam(aData, xResSet, aSelection);
+ SwDSParam* pTemp = FindDSData(aData, FALSE);
+ if(pTemp)
+ *pTemp = *pImpl->pMergeData;
+ else
+ {
+ //#94779# calls from the calculator may have added a connection with an invalid commandtype
+ //"real" data base connections added here have to re-use the already available
+ //DSData and set the correct CommandType
+ SwDBData aTempData(aData);
+ aData.nCommandType = -1;
+ pTemp = FindDSData(aData, FALSE);
+ if(pTemp)
+ *pTemp = *pImpl->pMergeData;
+ else
+ {
+ SwDSParam* pInsert = new SwDSParam(*pImpl->pMergeData);
+ aDataSourceParams.Insert(pInsert, aDataSourceParams.Count());
+ try
+ {
+ uno::Reference<XComponent> xComponent(pInsert->xConnection, UNO_QUERY);
+ if(xComponent.is())
+ xComponent->addEventListener(pImpl->xDisposeListener);
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ }
+ if(!pImpl->pMergeData->xConnection.is())
+ pImpl->pMergeData->xConnection = xConnection;
+ // add an XEventListener
+
+ try{
+ //set to start position
+ if(pImpl->pMergeData->aSelection.getLength())
+ {
+ sal_Int32 nPos = 0;
+ pImpl->pMergeData->aSelection.getConstArray()[ pImpl->pMergeData->nSelectionIndex++ ] >>= nPos;
+ pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->absolute( nPos );
+ pImpl->pMergeData->CheckEndOfDB();
+ if(pImpl->pMergeData->nSelectionIndex >= pImpl->pMergeData->aSelection.getLength())
+ pImpl->pMergeData->bEndOfDB = TRUE;
+ }
+ else
+ {
+ pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->first();
+ pImpl->pMergeData->CheckEndOfDB();
+ }
+ }
+ catch(Exception&)
+ {
+ pImpl->pMergeData->bEndOfDB = TRUE;
+ pImpl->pMergeData->CheckEndOfDB();
+ DBG_ERROR("exception in MergeNew()");
+ }
+
+ uno::Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,aData.sDataSource);
+
+ lcl_InitNumberFormatter(*pImpl->pMergeData, xSource);
+
+ rMergeDesc.rSh.ChgDBData(aData);
+ bInMerge = TRUE;
+
+ if (IsInitDBFields())
+ {
+ // Bei Datenbankfeldern ohne DB-Name DB-Name von Dok einsetzen
+ SvStringsDtor aDBNames(1, 1);
+ aDBNames.Insert( new String(), 0);
+ SwDBData aInsertData = rMergeDesc.rSh.GetDBData();
+ String sDBName = aInsertData.sDataSource;
+ sDBName += DB_DELIM;
+ sDBName += (String)aInsertData.sCommand;
+ sDBName += DB_DELIM;
+ sDBName += String::CreateFromInt32(aInsertData.nCommandType);
+ rMergeDesc.rSh.ChangeDBFields( aDBNames, sDBName);
+ SetInitDBFields(FALSE);
+ }
+
+ BOOL bRet = TRUE;
+ switch(rMergeDesc.nMergeType)
+ {
+ case DBMGR_MERGE:
+ bRet = Merge(&rMergeDesc.rSh); // Mischen
+ break;
+
+ case DBMGR_MERGE_MAILMERGE: // Serienbrief
+ {
+ SwView& rView = rMergeDesc.rSh.GetView();
+ SfxDispatcher *pDis = rView.GetViewFrame()->GetDispatcher();
+ SfxItemSet aPrintArgs( rView.GetPool(),
+ SID_SILENT, SID_SILENT, //5528
+ SID_ASYNCHRON, SID_ASYNCHRON, //5811
+ SID_PRINT_FIRST_PAGE, SID_PRINT_FIRST_PAGE, // 5001
+ SID_PRINT_LAST_PAGE, SID_PRINT_LAST_PAGE, // 5002
+ SID_PRINT_COPIES, SID_PRINT_COPIES, // 5003
+ SID_PRINTER_NAME, SID_PRINTER_NAME, //5322
+ SID_SELECTION, SID_SELECTION, //5346
+ SID_FILE_NAME, SID_FILE_NAME, // 5507
+ SID_PRINT_PAGES, SID_PRINT_PAGES, //6589
+ SID_PRINT_COLLATE, SID_PRINT_COLLATE, //6590
+ FN_QRY_MERGE, FN_QRY_MERGE,
+ 0 );
+ aPrintArgs.Put(SfxBoolItem(FN_QRY_MERGE, TRUE) );
+
+ // !! Currently (Jan-2003) silent is defined by supplying *any*
+ // !! item!! (Thus according to OS it would be silent even when
+ // !! other items then SID_SILENT would be supplied!)
+ // !! Therefore it has to be the 0 pointer when not silent.
+ if(IsMergeSilent())
+ {
+ aPrintArgs.Put( SfxBoolItem(SID_SILENT, TRUE) );
+ // #i25686# printing should be done asynchronously to prevent dangling offices
+ // when mail merge is called as command line macro
+ // #i52629# aynchronous printing should only be done in silent mode - otherwise
+ // the printer dialog does not come up
+ aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, rMergeDesc.bPrintAsync ));
+ }
+ // convert PropertyValues
+ const beans::PropertyValue* pPrintOptions = rMergeDesc.aPrintOptions.getConstArray();
+ for( sal_Int32 nOption = 0; nOption < rMergeDesc.aPrintOptions.getLength(); ++nOption)
+ {
+ if( pPrintOptions[nOption].Name.equalsAscii( "CopyCount" ))
+ {
+ sal_Int16 nCopies = 0;
+ if((pPrintOptions[nOption].Value >>= nCopies) && nCopies > 0)
+ aPrintArgs.Put( SfxInt16Item( SID_PRINT_COPIES, nCopies ));
+ }
+ else if( pPrintOptions[nOption].Name.equalsAscii( "FileName" ))
+ {
+ ::rtl::OUString sFileName;
+ if( (pPrintOptions[nOption].Value >>= sFileName) && sFileName.getLength() > 0)
+ aPrintArgs.Put( SfxStringItem( SID_FILE_NAME, sFileName ));
+ }
+ else if( pPrintOptions[nOption].Name.equalsAscii( "Collate" ))
+ {
+ sal_Bool bCollate = sal_False;
+ if( pPrintOptions[nOption].Value >>= bCollate )
+ aPrintArgs.Put( SfxBoolItem( SID_PRINT_COLLATE, bCollate ));
+ }
+ else if( pPrintOptions[nOption].Name.equalsAscii( "Pages" ))
+ {
+ ::rtl::OUString sPages;
+ if( (pPrintOptions[nOption].Value >>= sPages) && sPages.getLength() )
+ aPrintArgs.Put( SfxStringItem( SID_PRINT_PAGES, sPages ));
+ }
+ else if( pPrintOptions[nOption].Name.equalsAscii( "Wait" ))
+ {
+ sal_Bool bWait = sal_False;
+ if( pPrintOptions[nOption].Value >>= bWait )
+ aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, !bWait ));
+ }
+
+ }
+ pDis->Execute( SID_PRINTDOC,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
+ aPrintArgs );
+ }
+ break;
+
+ case DBMGR_MERGE_MAILING:
+ case DBMGR_MERGE_MAILFILES:
+ case DBMGR_MERGE_SINGLE_FILE:
+ // save files and send them as e-Mail if required
+ bRet = MergeMailFiles(&rMergeDesc.rSh,
+ rMergeDesc);
+ break;
+
+ default: // Einfuegen der selektierten Eintraege
+ // (war: InsertRecord)
+ ImportFromConnection(&rMergeDesc.rSh);
+ break;
+ }
+
+ EndMerge();
+ return bRet;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Daten importieren
+ --------------------------------------------------------------------*/
+
+
+BOOL SwNewDBMgr::Merge(SwWrtShell* pSh)
+{
+ pSh->StartAllAction();
+
+ pSh->ViewShell::UpdateFlds(TRUE);
+ pSh->SetModified();
+
+ pSh->EndAllAction();
+
+ return TRUE;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+void SwNewDBMgr::ImportFromConnection( SwWrtShell* pSh )
+{
+ if(pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB)
+ {
+ {
+ pSh->StartAllAction();
+ pSh->StartUndo(UNDO_EMPTY);
+ BOOL bGroupUndo(pSh->DoesGroupUndo());
+ pSh->DoGroupUndo(FALSE);
+
+ if( pSh->HasSelection() )
+ pSh->DelRight();
+
+ SwWait *pWait = 0;
+
+ {
+ ULONG i = 0;
+ do {
+
+ ImportDBEntry(pSh);
+ if( 10 == ++i )
+ pWait = new SwWait( *pSh->GetView().GetDocShell(), TRUE);
+
+ } while(ToNextMergeRecord());
+ }
+
+ pSh->DoGroupUndo(bGroupUndo);
+ pSh->EndUndo(UNDO_EMPTY);
+ pSh->EndAllAction();
+ delete pWait;
+ }
+ }
+}
+/*-----------------24.02.97 10.30-------------------
+
+--------------------------------------------------*/
+
+String lcl_FindColumn(const String& sFormatStr,USHORT &nUsedPos, BYTE &nSeparator)
+{
+ String sReturn;
+ USHORT nLen = sFormatStr.Len();
+ nSeparator = 0xff;
+ while(nUsedPos < nLen && nSeparator == 0xff)
+ {
+ sal_Unicode cAkt = sFormatStr.GetChar(nUsedPos);
+ switch(cAkt)
+ {
+ case ',':
+ nSeparator = DB_SEP_SPACE;
+ break;
+ case ';':
+ nSeparator = DB_SEP_RETURN;
+ break;
+ case ':':
+ nSeparator = DB_SEP_TAB;
+ break;
+ case '#':
+ nSeparator = DB_SEP_NEWLINE;
+ break;
+ default:
+ sReturn += cAkt;
+ }
+ nUsedPos++;
+
+ }
+ return sReturn;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+void SwNewDBMgr::ImportDBEntry(SwWrtShell* pSh)
+{
+ if(pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB)
+ {
+ uno::Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
+ uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
+ String sFormatStr;
+ USHORT nFmtLen = sFormatStr.Len();
+ if( nFmtLen )
+ {
+ const char cSpace = ' ';
+ const char cTab = '\t';
+ USHORT nUsedPos = 0;
+ BYTE nSeparator;
+ String sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator);
+ while( sColumn.Len() )
+ {
+ if(!xCols->hasByName(sColumn))
+ return;
+ Any aCol = xCols->getByName(sColumn);
+ uno::Reference< XPropertySet > xColumnProp;
+ aCol >>= xColumnProp;
+ if(xColumnProp.is())
+ {
+ SwDBFormatData aDBFormat;
+ String sInsert = GetDBField( xColumnProp, aDBFormat);
+ if( DB_SEP_SPACE == nSeparator )
+ sInsert += cSpace;
+ else if( DB_SEP_TAB == nSeparator)
+ sInsert += cTab;
+ pSh->Insert(sInsert);
+ if( DB_SEP_RETURN == nSeparator)
+ pSh->SplitNode();
+ else if(DB_SEP_NEWLINE == nSeparator)
+ pSh->InsertLineBreak();
+ }
+ else
+ {
+ // Spalte nicht gefunden -> Fehler anzeigen
+ String sInsert = '?';
+ sInsert += sColumn;
+ sInsert += '?';
+ pSh->Insert(sInsert);
+ }
+ sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator);
+ }
+ pSh->SplitNode();
+ }
+ else
+ {
+ String sStr;
+ Sequence<rtl::OUString> aColNames = xCols->getElementNames();
+ const rtl::OUString* pColNames = aColNames.getConstArray();
+ long nLength = aColNames.getLength();
+ for(long i = 0; i < nLength; i++)
+ {
+ Any aCol = xCols->getByName(pColNames[i]);
+ uno::Reference< XPropertySet > xColumnProp;
+ aCol >>= xColumnProp;
+ SwDBFormatData aDBFormat;
+ sStr += GetDBField( xColumnProp, aDBFormat);
+ if (i < nLength - 1)
+ sStr += '\t';
+ }
+ pSh->SwEditShell::Insert2(sStr);
+ pSh->SwFEShell::SplitNode(); // Zeilenvorschub
+ }
+ }
+}
+/*--------------------------------------------------------------------
+ Beschreibung: Listbox mit Tabellenliste fuellen
+ --------------------------------------------------------------------*/
+BOOL SwNewDBMgr::GetTableNames(ListBox* pListBox, const String& rDBName)
+{
+ BOOL bRet = FALSE;
+ String sOldTableName(pListBox->GetSelectEntry());
+ pListBox->Clear();
+ SwDSParam* pParam = FindDSConnection(rDBName, FALSE);
+ uno::Reference< XConnection> xConnection;
+ if(pParam && pParam->xConnection.is())
+ xConnection = pParam->xConnection;
+ else
+ {
+ rtl::OUString sDBName(rDBName);
+ xConnection = RegisterConnection( sDBName );
+ }
+ if(xConnection.is())
+ {
+ uno::Reference<XTablesSupplier> xTSupplier = uno::Reference<XTablesSupplier>(xConnection, UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ uno::Reference<XNameAccess> xTbls = xTSupplier->getTables();
+ Sequence<rtl::OUString> aTbls = xTbls->getElementNames();
+ const rtl::OUString* pTbls = aTbls.getConstArray();
+ for(long i = 0; i < aTbls.getLength(); i++)
+ {
+ USHORT nEntry = pListBox->InsertEntry(pTbls[i]);
+ pListBox->SetEntryData(nEntry, (void*)0);
+ }
+ }
+ uno::Reference<XQueriesSupplier> xQSupplier = uno::Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
+ if(xQSupplier.is())
+ {
+ uno::Reference<XNameAccess> xQueries = xQSupplier->getQueries();
+ Sequence<rtl::OUString> aQueries = xQueries->getElementNames();
+ const rtl::OUString* pQueries = aQueries.getConstArray();
+ for(long i = 0; i < aQueries.getLength(); i++)
+ {
+ USHORT nEntry = pListBox->InsertEntry(pQueries[i]);
+ pListBox->SetEntryData(nEntry, (void*)1);
+ }
+ }
+ if (sOldTableName.Len())
+ pListBox->SelectEntry(sOldTableName);
+ bRet = TRUE;
+ }
+ return bRet;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Listbox mit Spaltennamen einer Datenbank fuellen
+ --------------------------------------------------------------------*/
+BOOL SwNewDBMgr::GetColumnNames(ListBox* pListBox,
+ const String& rDBName, const String& rTableName, BOOL bAppend)
+{
+ if (!bAppend)
+ pListBox->Clear();
+ SwDBData aData;
+ aData.sDataSource = rDBName;
+ aData.sCommand = rTableName;
+ aData.nCommandType = -1;
+ SwDSParam* pParam = FindDSData(aData, FALSE);
+ uno::Reference< XConnection> xConnection;
+ if(pParam && pParam->xConnection.is())
+ xConnection = pParam->xConnection;
+ else
+ {
+ rtl::OUString sDBName(rDBName);
+ xConnection = RegisterConnection( sDBName );
+ }
+ uno::Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
+ if(xColsSupp.is())
+ {
+ uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
+ const Sequence<rtl::OUString> aColNames = xCols->getElementNames();
+ const rtl::OUString* pColNames = aColNames.getConstArray();
+ for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
+ {
+ pListBox->InsertEntry(pColNames[nCol]);
+ }
+ ::comphelper::disposeComponent( xColsSupp );
+ }
+ return(TRUE);
+}
+/* -----------------------------08.06.01 15:11--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL SwNewDBMgr::GetColumnNames(ListBox* pListBox,
+ uno::Reference< XConnection> xConnection,
+ const String& rTableName, BOOL bAppend)
+{
+ if (!bAppend)
+ pListBox->Clear();
+ uno::Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
+ if(xColsSupp.is())
+ {
+ uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
+ const Sequence<rtl::OUString> aColNames = xCols->getElementNames();
+ const rtl::OUString* pColNames = aColNames.getConstArray();
+ for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
+ {
+ pListBox->InsertEntry(pColNames[nCol]);
+ }
+ ::comphelper::disposeComponent( xColsSupp );
+ }
+ return(TRUE);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: CTOR
+ --------------------------------------------------------------------*/
+
+SwNewDBMgr::SwNewDBMgr() :
+ nMergeType(DBMGR_INSERT),
+ bInitDBFields(FALSE),
+ bInMerge(FALSE),
+ bMergeSilent(FALSE),
+ bMergeLock(FALSE),
+ pImpl(new SwNewDBMgr_Impl(*this)),
+ pMergeEvtSrc(NULL)
+{
+}
+/* -----------------------------18.07.00 08:56--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwNewDBMgr::~SwNewDBMgr()
+{
+ for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++)
+ {
+ SwDSParam* pParam = aDataSourceParams[nPos];
+ if(pParam->xConnection.is())
+ {
+ try
+ {
+ uno::Reference<XComponent> xComp(pParam->xConnection, UNO_QUERY);
+ if(xComp.is())
+ xComp->dispose();
+ }
+ catch(const RuntimeException& )
+ {
+ //may be disposed already since multiple entries may have used the same connection
+ }
+ }
+ }
+ delete pImpl;
+}
+/*--------------------------------------------------------------------
+ Beschreibung: Serienbrief drucken
+ --------------------------------------------------------------------*/
+
+
+BOOL SwNewDBMgr::MergePrint( SwView& rView,
+ SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI )
+{
+ SwWrtShell* pSh = &rView.GetWrtShell();
+ //check if the doc is synchronized and contains at least one linked section
+ BOOL bSynchronizedDoc = pSh->IsLabelDoc() && pSh->GetSectionFmtCount() > 1;
+ //merge source is already open
+ rOpt.nMergeCnt = 0;
+ //#i56195# no field update while printing mail merge documents
+ rOpt.bUpdateFieldsInPrinting = sal_False;
+ if(pImpl->pMergeData)
+ {
+ if(pImpl->pMergeData->aSelection.getLength())
+ rOpt.nMergeCnt = pImpl->pMergeData->aSelection.getLength();
+ else if(pImpl->pMergeData->xResultSet.is())
+ {
+ sal_Int32 nCount;
+ if( lcl_getCountFromResultSet( nCount, pImpl->pMergeData->xResultSet ) )
+ rOpt.nMergeCnt = (ULONG)nCount;
+ }
+ }
+
+ SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+ pModOpt->SetSinglePrintJob(rOpt.IsPrintSingleJobs());
+
+ SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false );
+ Link aSfxSaveLnk = pPrt->GetEndPrintHdl();
+ if( rOpt.IsPrintSingleJobs() )
+ pPrt->SetEndPrintHdl( Link() );
+
+ BOOL bUserBreak = FALSE,
+ bRet = FALSE;
+ long nStartRow, nEndRow;
+ //calculate number of data sets to be printed
+
+ Sequence<PropertyValue> aViewProperties(16);
+ PropertyValue* pViewProperties = aViewProperties.getArray();
+ pViewProperties[0].Name = C2U("MailMergeCount");
+ pViewProperties[0].Value <<= (sal_Int32)rOpt.nMergeCnt;
+ pViewProperties[1].Name = C2U("PrintGraphics");
+ pViewProperties[1].Value <<= (sal_Bool)rOpt.IsPrintGraphic();
+ pViewProperties[2].Name = C2U("PrintTables");
+ pViewProperties[2].Value <<= (sal_Bool)rOpt.IsPrintTable();
+ pViewProperties[3].Name = C2U("PrintDrawings");
+ pViewProperties[3].Value <<= (sal_Bool)rOpt.IsPrintDraw();
+ pViewProperties[4].Name = C2U("PrintLeftPages");
+ pViewProperties[4].Value <<= (sal_Bool)rOpt.IsPrintLeftPage();
+ pViewProperties[5].Name = C2U("PrintRightPages");
+ pViewProperties[5].Value <<= (sal_Bool)rOpt.IsPrintRightPage();
+ pViewProperties[6].Name = C2U("PrintControls");
+ pViewProperties[6].Value <<= (sal_Bool)rOpt.IsPrintControl();
+ pViewProperties[7].Name = C2U("PrintReversed");
+ pViewProperties[7].Value <<= (sal_Bool)rOpt.IsPrintReverse();
+ pViewProperties[8].Name = C2U("PrintPaperFromSetup");
+ pViewProperties[8].Value <<= (sal_Bool)rOpt.IsPaperFromSetup();
+ pViewProperties[9].Name = C2U("PrintFaxName");
+ pViewProperties[9].Value <<= rOpt.GetFaxName();
+ pViewProperties[10].Name = C2U("PrintAnnotationMode");
+ pViewProperties[10].Value <<= (text::NotePrintMode) rOpt.GetPrintPostIts();
+ pViewProperties[11].Name = C2U("PrintProspect");
+ pViewProperties[11].Value <<= (sal_Bool)rOpt.IsPrintProspect();
+ pViewProperties[12].Name = C2U("PrintPageBackground");
+ pViewProperties[12].Value <<= (sal_Bool)rOpt.IsPrintPageBackground();
+ pViewProperties[13].Name = C2U("PrintBlackFonts");
+ pViewProperties[13].Value <<= (sal_Bool)rOpt.IsPrintBlackFont();
+ pViewProperties[14].Name = C2U("IsSinglePrintJob");
+ pViewProperties[14].Value <<= (sal_Bool)rOpt.IsPrintSingleJobs();
+ pViewProperties[15].Name = C2U("PrintEmptyPages");
+ pViewProperties[15].Value <<= (sal_Bool)rOpt.IsPrintEmptyPages();
+
+ rView.SetAdditionalPrintOptions(aViewProperties);
+ do {
+ nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
+ {
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), pSh->GetView().GetViewFrame()->GetObjectShell()));
+ pSh->ViewShell::UpdateFlds();
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), pSh->GetView().GetViewFrame()->GetObjectShell()));
+ ++rOpt.nMergeAct;
+
+ // launch MailMergeEvent if required
+ const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc();
+ if (pEvtSrc)
+ {
+ uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc );
+ text::MailMergeEvent aEvt( xRef, rView.GetDocShell()->GetModel() );
+ pEvtSrc->LaunchMailMergeEvent( aEvt );
+ }
+
+ rView.SfxViewShell::Print( rProgress, bIsAPI ); // ggf Basic-Macro ausfuehren
+ if( rOpt.IsPrintSingleJobs() && bRet )
+ {
+ //rOpt.bJobStartet = FALSE;
+ bRet = FALSE;
+ }
+
+ bMergeLock = TRUE;
+ if(rOpt.IsPrintProspect())
+ {
+ if( ! pPrt->IsJobActive() )
+ {
+ pPrt->SetJobValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ),
+ String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) );
+ pPrt->StartJob( rOpt.GetJobName() );
+ }
+ if( pPrt->IsJobActive() )
+ {
+ pSh->PrintProspect( rOpt, rProgress, rOpt.IsPrintProspect_RTL() );
+ bRet = TRUE;
+ }
+ }
+ else if( pSh->Prt( rOpt, &rProgress ) )
+ bRet = TRUE;
+ bMergeLock = FALSE;
+
+ if( !pPrt->IsJobActive() )
+ {
+ bUserBreak = TRUE;
+ bRet = FALSE;
+ break;
+ }
+ if( !rOpt.IsPrintSingleJobs() )
+ {
+ String& rJNm = (String&)rOpt.GetJobName();
+ rJNm.Erase();
+ }
+ }
+ nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
+ } while( bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord());
+
+ if( rOpt.IsPrintSingleJobs() )
+ {
+ SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true );
+ pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk );
+ if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet?
+ aSfxSaveLnk.Call( pTmpPrinter );
+ }
+
+ rOpt.nMergeCnt = 0;
+ rOpt.nMergeAct = 0;
+
+ nMergeType = DBMGR_INSERT;
+
+ SwDocShell* pDocSh = rView.GetDocShell();
+ SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(pDocSh);
+
+ while (pTmpFrm) // Alle Views Invalidieren
+ {
+ SwView *pVw = PTR_CAST(SwView, pTmpFrm->GetViewShell());
+ if (pVw)
+ pVw->GetEditWin().Invalidate();
+ pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, pDocSh);
+ }
+
+ return bRet;
+}
+/*-- 21.06.2004 09:08:16---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView,
+ SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI )
+{
+ SwWrtShell* pSh = &rView.GetWrtShell();
+ //check if the doc is synchronized and contains at least one linked section
+ //merge source is already open
+ rOpt.nMergeCnt = 0;
+ rOpt.SetPrintSingleJobs( sal_True );
+
+ SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false );
+ Link aSfxSaveLnk = pPrt->GetEndPrintHdl();
+ if( rOpt.IsPrintSingleJobs() )
+ pPrt->SetEndPrintHdl( Link() );
+
+ BOOL bUserBreak = FALSE,
+ bRet = FALSE;
+ //calculate number of data sets to be printed
+
+ Sequence<PropertyValue> aViewProperties(16);
+ PropertyValue* pViewProperties = aViewProperties.getArray();
+ pViewProperties[0].Name = C2U("MailMergeCount");
+ pViewProperties[0].Value <<= (sal_Int32)rOpt.nMergeCnt;
+ pViewProperties[1].Name = C2U("PrintGraphics");
+ pViewProperties[1].Value <<= (sal_Bool)rOpt.IsPrintGraphic();
+ pViewProperties[2].Name = C2U("PrintTables");
+ pViewProperties[2].Value <<= (sal_Bool)rOpt.IsPrintTable();
+ pViewProperties[3].Name = C2U("PrintDrawings");
+ pViewProperties[3].Value <<= (sal_Bool)rOpt.IsPrintDraw();
+ pViewProperties[4].Name = C2U("PrintLeftPages");
+ pViewProperties[4].Value <<= (sal_Bool)rOpt.IsPrintLeftPage();
+ pViewProperties[5].Name = C2U("PrintRightPages");
+ pViewProperties[5].Value <<= (sal_Bool)rOpt.IsPrintRightPage();
+ pViewProperties[6].Name = C2U("PrintControls");
+ pViewProperties[6].Value <<= (sal_Bool)rOpt.IsPrintControl();
+ pViewProperties[7].Name = C2U("PrintReversed");
+ pViewProperties[7].Value <<= (sal_Bool)rOpt.IsPrintReverse();
+ pViewProperties[8].Name = C2U("PrintPaperFromSetup");
+ pViewProperties[8].Value <<= (sal_Bool)rOpt.IsPaperFromSetup();
+ pViewProperties[9].Name = C2U("PrintFaxName");
+ pViewProperties[9].Value <<= rOpt.GetFaxName();
+ pViewProperties[10].Name = C2U("PrintAnnotationMode");
+ pViewProperties[10].Value <<= (text::NotePrintMode) rOpt.GetPrintPostIts();
+ pViewProperties[11].Name = C2U("PrintProspect");
+ pViewProperties[11].Value <<= (sal_Bool)rOpt.IsPrintProspect();
+ pViewProperties[12].Name = C2U("PrintPageBackground");
+ pViewProperties[12].Value <<= (sal_Bool)rOpt.IsPrintPageBackground();
+ pViewProperties[13].Name = C2U("PrintBlackFonts");
+ pViewProperties[13].Value <<= (sal_Bool)rOpt.IsPrintBlackFont();
+ pViewProperties[14].Name = C2U("IsSinglePrintJob");
+ pViewProperties[14].Value <<= (sal_Bool)rOpt.IsPrintSingleJobs();
+ pViewProperties[15].Name = C2U("PrintEmptyPages");
+ pViewProperties[15].Value <<= (sal_Bool)rOpt.IsPrintEmptyPages();
+
+ rView.SetAdditionalPrintOptions(aViewProperties);
+
+ SwMailMergeConfigItem* pConfigItem = rView.GetMailMergeConfigItem();
+ DBG_ASSERT(pConfigItem, "mail merge config item is missing");
+ if(!pConfigItem)
+ return sal_False;
+
+ USHORT nDocStart = pConfigItem->GetPrintRangeStart();
+ USHORT nDocEnd = pConfigItem->GetPrintRangeEnd();
+ DBG_ASSERT(nDocStart < nDocEnd && nDocEnd <= pConfigItem->GetMergedDocumentCount(),
+ "merge print settings are not correct");
+
+ for( sal_uInt32 nPrintDocument = nDocStart; nPrintDocument < nDocEnd; ++nPrintDocument)
+ {
+ SwDocMergeInfo& rDocInfo = pConfigItem->GetDocumentMergeInfo(nPrintDocument);
+ rOpt.aMulti.SelectAll(FALSE);
+ rOpt.aMulti.Select(Range( rDocInfo.nStartPageInTarget, rDocInfo.nEndPageInTarget ), TRUE );
+
+ ++rOpt.nMergeAct;
+
+ // launch MailMergeEvent if required
+ const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc();
+ if (pEvtSrc)
+ {
+ uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc );
+ text::MailMergeEvent aEvt( xRef, rView.GetDocShell()->GetModel() );
+ pEvtSrc->LaunchMailMergeEvent( aEvt );
+ }
+
+ String aTmp;
+ aTmp += String::CreateFromInt32( rDocInfo.nStartPageInTarget );
+ aTmp += '-';
+ aTmp += String::CreateFromInt32( rDocInfo.nEndPageInTarget );
+
+ Sequence<PropertyValue> aAddViewProperties(1);
+ PropertyValue* pAddViewProperties = aAddViewProperties.getArray();
+ pAddViewProperties[0].Name = C2U("Pages");
+ pAddViewProperties[0].Value <<= ::rtl::OUString( aTmp );
+ rView.SetAdditionalPrintOptions(aAddViewProperties);
+
+ rView.SfxViewShell::Print( rProgress, bIsAPI ); // ggf Basic-Macro ausfuehren
+ if( rOpt.IsPrintSingleJobs() && bRet )
+ {
+ //rOpt.bJobStartet = FALSE;
+ bRet = FALSE;
+ }
+
+ bMergeLock = TRUE;
+ if(rOpt.IsPrintProspect())
+ {
+ if( pPrt->IsJobActive() || pPrt->StartJob( rOpt.GetJobName() ))
+ {
+ pSh->PrintProspect( rOpt, rProgress, rOpt.IsPrintProspect_RTL() );
+ bRet = TRUE;
+ }
+ }
+ else if( pSh->Prt( rOpt, &rProgress ) )
+ bRet = TRUE;
+ bMergeLock = FALSE;
+
+ if( !pPrt->IsJobActive() )
+ {
+ bUserBreak = TRUE;
+ bRet = FALSE;
+ break;
+ }
+ if( !rOpt.IsPrintSingleJobs() )
+ {
+ String& rJNm = (String&)rOpt.GetJobName();
+ rJNm.Erase();
+ }
+ }
+
+ if( rOpt.IsPrintSingleJobs() )
+ {
+ SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true );
+ pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk );
+ if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet?
+ aSfxSaveLnk.Call( pTmpPrinter );
+ }
+
+ rOpt.nMergeCnt = 0;
+ rOpt.nMergeAct = 0;
+
+ nMergeType = DBMGR_INSERT;
+
+ SwDocShell* pDocSh = rView.GetDocShell();
+ SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(pDocSh);
+
+ while (pTmpFrm) // Alle Views Invalidieren
+ {
+ SwView *pVw = PTR_CAST(SwView, pTmpFrm->GetViewShell());
+ if (pVw)
+ pVw->GetEditWin().Invalidate();
+ pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, pDocSh);
+ }
+
+ return bRet;
+}
+
+
+
+/*--------------------------------------------------------------------
+ Beschreibung: Serienbriefe als einzelne Dokumente speichern
+ --------------------------------------------------------------------*/
+String lcl_FindUniqueName(SwWrtShell* pTargetShell, const String& rStartingPageDesc, ULONG nDocNo )
+{
+ do
+ {
+ String sTest = rStartingPageDesc;
+ sTest += String::CreateFromInt32( nDocNo );
+ if( !pTargetShell->FindPageDescByName( sTest ) )
+ return sTest;
+ ++nDocNo;
+ }while(true);
+}
+void lcl_CopyDynamicDefaults( const SwDoc& rSource, SwDoc& rTarget )
+{
+ USHORT __FAR_DATA aRangeOfDefaults[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ // --> OD 2008-02-25 #refactorlists##
+ RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
+ // <--
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+ };
+
+ SfxItemSet aNewDefaults( rTarget.GetAttrPool(), aRangeOfDefaults );
+
+ USHORT nWhich;
+ USHORT nRange = 0;
+ while( aRangeOfDefaults[nRange] != 0)
+ {
+ for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich )
+ {
+ const SfxPoolItem& rSourceAttr = rSource.GetDefault( nWhich );
+ if( rSourceAttr != rTarget.GetDefault( nWhich ) )
+ aNewDefaults.Put( rSourceAttr );
+ }
+ nRange += 2;
+ }
+ if( aNewDefaults.Count() )
+ rTarget.SetDefault( aNewDefaults );
+}
+void lcl_CopyFollowPageDesc(
+ SwWrtShell& rTargetShell,
+ const SwPageDesc& rSourcePageDesc,
+ const SwPageDesc& rTargetPageDesc,
+ const ULONG nDocNo )
+{
+ //now copy the follow page desc, too
+ const SwPageDesc* pFollowPageDesc = rSourcePageDesc.GetFollow();
+ String sFollowPageDesc = pFollowPageDesc->GetName();
+ if( sFollowPageDesc != rSourcePageDesc.GetName() )
+ {
+ SwDoc* pTargetDoc = rTargetShell.GetDoc();
+ String sNewFollowPageDesc = lcl_FindUniqueName(&rTargetShell, sFollowPageDesc, nDocNo );
+ sal_uInt16 nNewDesc = pTargetDoc->MakePageDesc( sNewFollowPageDesc );
+ SwPageDesc& rTargetFollowPageDesc = pTargetDoc->_GetPageDesc( nNewDesc );
+
+ pTargetDoc->CopyPageDesc( *pFollowPageDesc, rTargetFollowPageDesc, sal_False );
+ SwPageDesc aDesc( rTargetPageDesc );
+ aDesc.SetFollow( &rTargetFollowPageDesc );
+ pTargetDoc->ChgPageDesc( rTargetPageDesc.GetName(), aDesc );
+ }
+}
+
+BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
+ const SwMergeDescriptor& rMergeDescriptor)
+{
+ //check if the doc is synchronized and contains at least one linked section
+ BOOL bSynchronizedDoc = pSourceShell->IsLabelDoc() && pSourceShell->GetSectionFmtCount() > 1;
+ BOOL bLoop = TRUE;
+ BOOL bEMail = rMergeDescriptor.nMergeType == DBMGR_MERGE_MAILING;
+ const bool bAsSingleFile = rMergeDescriptor.nMergeType == DBMGR_MERGE_SINGLE_FILE;
+
+ ::rtl::Reference< MailDispatcher > xMailDispatcher;
+ ::rtl::OUString sBodyMimeType;
+ rtl_TextEncoding eEncoding = ::gsl_getSystemTextEncoding();
+
+ if(bEMail)
+ {
+ xMailDispatcher.set( new MailDispatcher(rMergeDescriptor.xSmtpServer));
+ if(!rMergeDescriptor.bSendAsAttachment && rMergeDescriptor.bSendAsHTML)
+ {
+ sBodyMimeType = ::rtl::OUString::createFromAscii("text/html; charset=");
+ sBodyMimeType += ::rtl::OUString::createFromAscii(
+ rtl_getBestMimeCharsetFromTextEncoding( eEncoding ));
+ SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get();
+ eEncoding = pHtmlOptions->GetTextEncoding();
+ }
+ else
+ sBodyMimeType =
+ ::rtl::OUString::createFromAscii("text/plain; charset=UTF-8; format=flowed");
+ }
+
+ uno::Reference< XPropertySet > xColumnProp;
+ {
+ BOOL bColumnName = sEMailAddrFld.Len() > 0;
+
+ if (bColumnName)
+ {
+ uno::Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
+ uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
+ if(!xCols->hasByName(sEMailAddrFld))
+ return FALSE;
+ Any aCol = xCols->getByName(sEMailAddrFld);
+ aCol >>= xColumnProp;
+ }
+
+ SfxDispatcher* pSfxDispatcher = pSourceShell->GetView().GetViewFrame()->GetDispatcher();
+ SwDocShell* pSourrceDocSh = pSourceShell->GetView().GetDocShell();
+ pSfxDispatcher->Execute( pSourrceDocSh->HasName() ? SID_SAVEDOC : SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD);
+ // has document been saved successfully?
+ if( !pSourrceDocSh->IsModified() )
+ {
+ SfxMedium* pOrig = pSourceShell->GetView().GetDocShell()->GetMedium();
+ String sSourceDocumentURL(pOrig->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ));
+ const SfxFilter* pSfxFlt = SwIoSystem::GetFileFilter(
+ sSourceDocumentURL, ::aEmptyStr );
+ const SfxFilter* pStoreToFilter = pSfxFlt;
+ SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
+ const String* pStoreToFilterOptions = 0;
+ // if a save_to filter is set then use it - otherwise use the default
+ if( bEMail && !rMergeDescriptor.bSendAsAttachment )
+ {
+ String sExtension( String::CreateFromAscii(
+ rMergeDescriptor.bSendAsHTML ? "html" : "txt" ));
+ pStoreToFilter = pFilterContainer->GetFilter4Extension(sExtension, SFX_FILTER_EXPORT);
+ }
+ else if( rMergeDescriptor.sSaveToFilter.Len())
+ {
+ const SfxFilter* pFilter =
+ pFilterContainer->GetFilter4FilterName( rMergeDescriptor.sSaveToFilter );
+ if(pFilter)
+ {
+ pStoreToFilter = pFilter;
+ if(rMergeDescriptor.sSaveToFilterOptions.Len())
+ pStoreToFilterOptions = &rMergeDescriptor.sSaveToFilterOptions;
+ }
+ }
+ bCancel = FALSE;
+
+ // in case of creating a single resulting file this has to be created here
+ SwWrtShell* pTargetShell = 0;
+ SfxObjectShellRef xTargetDocShell;
+ std::auto_ptr< utl::TempFile > aTempFile;
+ String sModifiedStartingPageDesc;
+ String sStartingPageDesc;
+ USHORT nStartingPageNo = 0;
+ bool bPageStylesWithHeaderFooter = false;
+ if(bAsSingleFile || rMergeDescriptor.bCreateSingleFile)
+ {
+ // create a target docshell to put the merged document into
+ xTargetDocShell = new SwDocShell( SFX_CREATE_MODE_STANDARD );
+ xTargetDocShell->DoInitNew( 0 );
+ SfxViewFrame* pTargetFrame = SfxViewFrame::CreateViewFrame( *xTargetDocShell, 0, TRUE );
+
+ SwView* pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() );
+
+ //initiate SelectShell() to create sub shells
+ pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() );
+ pTargetShell = pTargetView->GetWrtShellPtr();
+ //copy the styles from the source to the target document
+ SwgReaderOption aOpt;
+ aOpt.SetTxtFmts( sal_True );
+ aOpt.SetFrmFmts( sal_True );
+ aOpt.SetPageDescs( sal_True );
+ aOpt.SetNumRules( sal_True );
+ aOpt.SetMerge( sal_False );
+ pTargetView->GetDocShell()->LoadStylesFromFile(
+ sSourceDocumentURL, aOpt, sal_True );
+ //determine the page style and number used at the start of the source document
+ pSourceShell->SttEndDoc(TRUE);
+ nStartingPageNo = pSourceShell->GetVirtPageNum();
+ sStartingPageDesc = sModifiedStartingPageDesc = pSourceShell->GetPageDesc(
+ pSourceShell->GetCurPageDesc()).GetName();
+ // #122799# copy compatibility options
+ lcl_CopyCompatibilityOptions( *pSourceShell, *pTargetShell);
+ // #72821# copy dynamic defaults
+ lcl_CopyDynamicDefaults( *pSourceShell->GetDoc(), *pTargetShell->GetDoc() );
+ // #i72517#
+ const SwPageDesc* pSourcePageDesc = pSourceShell->FindPageDescByName( sStartingPageDesc );
+ const SwFrmFmt& rMaster = pSourcePageDesc->GetMaster();
+ bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive() ||
+ rMaster.GetFooter().IsActive();
+
+ }
+
+ PrintMonitor aPrtMonDlg(&pSourceShell->GetView().GetEditWin(), PrintMonitor::MONITOR_TYPE_PRINT);
+ aPrtMonDlg.aDocName.SetText(pSourceShell->GetView().GetDocShell()->GetTitle(22));
+
+ aPrtMonDlg.aCancel.SetClickHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
+ if (!IsMergeSilent())
+ aPrtMonDlg.Show();
+
+ // Progress, um KeyInputs zu unterbinden
+ SfxProgress aProgress(pSourrceDocSh, ::aEmptyStr, 1);
+
+ // Alle Dispatcher sperren
+ SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst(pSourrceDocSh);
+ while (pViewFrm)
+ {
+ pViewFrm->GetDispatcher()->Lock(TRUE);
+ pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourrceDocSh);
+ }
+ ULONG nDocNo = 1;
+
+ long nStartRow, nEndRow;
+ // collect temporary files
+ ::std::vector< String> aFilesToRemove;
+ do
+ {
+ nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
+ {
+ String sPath(sSubject);
+
+ String sAddress;
+ if( !bEMail && bColumnName )
+ {
+ SwDBFormatData aDBFormat;
+ aDBFormat.xFormatter = pImpl->pMergeData->xFormatter;
+ aDBFormat.aNullDate = pImpl->pMergeData->aNullDate;
+ sAddress = GetDBField( xColumnProp, aDBFormat);
+ if (!sAddress.Len())
+ sAddress = '_';
+ sPath += sAddress;
+ }
+
+ // create a new temporary file name - only done once in case of bCreateSingleFile
+ if( 1 == nDocNo || (!rMergeDescriptor.bCreateSingleFile && !bAsSingleFile) )
+ {
+ INetURLObject aEntry(sPath);
+ String sLeading;
+ //#i97667# if the name is from a database field then it will be used _as is_
+ if( sAddress.Len() )
+ sLeading = sAddress;
+ else
+ sLeading = aEntry.GetBase();
+ aEntry.removeSegment();
+ sPath = aEntry.GetMainURL( INetURLObject::NO_DECODE );
+ String sExt( pStoreToFilter->GetDefaultExtension() );
+ sExt.EraseLeadingChars('*');
+ aTempFile = std::auto_ptr< utl::TempFile >(
+ new utl::TempFile(sLeading,&sExt,&sPath ));
+ if( bAsSingleFile )
+ aTempFile->EnableKillingFile();
+ }
+
+ if( !aTempFile->IsValid() )
+ {
+ ErrorHandler::HandleError( ERRCODE_IO_NOTSUPPORTED );
+ bLoop = FALSE;
+ bCancel = TRUE;
+ }
+ else
+ {
+ INetURLObject aTempFileURL(aTempFile->GetURL());
+ aPrtMonDlg.aPrinter.SetText( aTempFileURL.GetBase() );
+ String sStat(SW_RES(STR_STATSTR_LETTER)); // Brief
+ sStat += ' ';
+ sStat += String::CreateFromInt32( nDocNo );
+ aPrtMonDlg.aPrintInfo.SetText(sStat);
+
+ // Rechenzeit fuer Save-Monitor:
+ for (USHORT i = 0; i < 10; i++)
+ Application::Reschedule();
+
+ // Neues Dokument erzeugen und speichern
+ SfxObjectShellRef xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL ));
+ SfxMedium* pWorkMed = new SfxMedium( sSourceDocumentURL, STREAM_STD_READ, TRUE );
+ pWorkMed->SetFilter( pSfxFlt );
+
+ if (xWorkDocSh->DoLoad(pWorkMed))
+ {
+ //create a view frame for the document
+ SfxViewFrame* pWorkFrame = SfxViewFrame::CreateViewFrame( *xWorkDocSh, 0, TRUE );
+ //request the layout calculation
+ SwWrtShell& rWorkShell =
+ static_cast< SwView* >(pWorkFrame->GetViewShell())->GetWrtShell();
+ rWorkShell.CalcLayout();
+ SwDoc* pWorkDoc = ((SwDocShell*)(&xWorkDocSh))->GetDoc();
+ SwNewDBMgr* pOldDBMgr = pWorkDoc->GetNewDBMgr();
+ pWorkDoc->SetNewDBMgr( this );
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), xWorkDocSh));
+ pWorkDoc->UpdateFlds(NULL, false);
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), xWorkDocSh));
+
+ // alle versteckten Felder/Bereiche entfernen
+ pWorkDoc->RemoveInvisibleContent();
+
+ // launch MailMergeEvent if required
+ const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc();
+ if(pEvtSrc)
+ {
+ uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc );
+ text::MailMergeEvent aEvt( xRef, xWorkDocSh->GetModel() );
+ pEvtSrc->LaunchMailMergeEvent( aEvt );
+ }
+
+ if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile )
+ {
+ DBG_ASSERT( pTargetShell, "no target shell available!" );
+ // copy created file into the target document
+ rWorkShell.ConvertFieldsToText();
+ rWorkShell.SetNumberingRestart();
+
+ // insert the document into the target document
+ rWorkShell.SttEndDoc(FALSE);
+ rWorkShell.SttEndDoc(TRUE);
+ rWorkShell.SelAll();
+ pTargetShell->SwCrsrShell::SttEndDoc( FALSE );
+ //#i72517# the headers and footers are still those from the source - update in case of fields inside header/footer
+ if( !nDocNo && bPageStylesWithHeaderFooter )
+ pTargetShell->GetView().GetDocShell()->_LoadStyles( *rWorkShell.GetView().GetDocShell(), sal_True );
+ //#i72517# put the styles to the target document
+ //if the source uses headers or footers each new copy need to copy a new page styles
+ if(bPageStylesWithHeaderFooter)
+ {
+ //create a new pagestyle
+ //copy the pagedesc from the current document to the new document and change the name of the to-be-applied style
+
+ SwDoc* pTargetDoc = pTargetShell->GetDoc();
+ SwPageDesc* pSourcePageDesc = rWorkShell.FindPageDescByName( sStartingPageDesc );
+ String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
+ pTargetDoc->MakePageDesc( sNewPageDescName );
+ SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
+ if(pSourcePageDesc && pTargetPageDesc)
+ {
+ pTargetDoc->CopyPageDesc( *pSourcePageDesc, *pTargetPageDesc, sal_False );
+ sModifiedStartingPageDesc = sNewPageDescName;
+ lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo );
+ }
+ }
+
+ if(nDocNo > 1)
+ pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
+ else
+ pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
+ DBG_ASSERT(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
+ //#i51359# add a second paragraph in case there's only one
+ {
+ SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
+ SwPosition aTestPos( aIdx );
+ SwCursor aTestCrsr(aTestPos,0,false);
+ if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
+ {
+ //append a paragraph
+ pWorkDoc->AppendTxtNode( aTestPos );
+ }
+ }
+ pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
+
+ //convert fields in page styles (header/footer - has to be done after the first document has been pasted
+ if(1 == nDocNo)
+ {
+ pTargetShell->CalcLayout();
+ pTargetShell->ConvertFieldsToText();
+ }
+ }
+ else
+ {
+ String sFileURL = aTempFileURL.GetMainURL( INetURLObject::NO_DECODE );
+ SfxMedium* pDstMed = new SfxMedium(
+ sFileURL,
+ STREAM_STD_READWRITE, TRUE );
+ pDstMed->SetFilter( pStoreToFilter );
+ if(pDstMed->GetItemSet())
+ {
+ if(pStoreToFilterOptions )
+ pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions));
+ if(rMergeDescriptor.aSaveToFilterData.getLength())
+ pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData)));
+ }
+
+ //convert fields to text if we are exporting to PDF
+ //this prevents a second merge while updating the fields in SwXTextDocument::getRendererCount()
+ if( pStoreToFilter && pStoreToFilter->GetFilterName().EqualsAscii("writer_pdf_Export"))
+ rWorkShell.ConvertFieldsToText();
+ xWorkDocSh->DoSaveAs(*pDstMed);
+ xWorkDocSh->DoSaveCompleted(pDstMed);
+ if( xWorkDocSh->GetError() )
+ {
+ // error message ??
+ ErrorHandler::HandleError( xWorkDocSh->GetError() );
+ bCancel = TRUE;
+ bLoop = FALSE;
+ }
+ if( bEMail )
+ {
+ SwDBFormatData aDBFormat;
+ aDBFormat.xFormatter = pImpl->pMergeData->xFormatter;
+ aDBFormat.aNullDate = pImpl->pMergeData->aNullDate;
+ String sMailAddress = GetDBField( xColumnProp, aDBFormat);
+ if(!SwMailMergeHelper::CheckMailAddress( sMailAddress ))
+ {
+ DBG_ERROR("invalid e-Mail address in database column");
+ }
+ else
+ {
+ SwMailMessage* pMessage = 0;
+ uno::Reference< mail::XMailMessage > xMessage =
+ pMessage = new SwMailMessage;
+ if(rMergeDescriptor.pMailMergeConfigItem->IsMailReplyTo())
+ pMessage->setReplyToAddress(rMergeDescriptor.pMailMergeConfigItem->GetMailReplyTo());
+ pMessage->addRecipient( sMailAddress );
+ pMessage->SetSenderAddress( rMergeDescriptor.pMailMergeConfigItem->GetMailAddress() );
+ ::rtl::OUString sBody;
+ if(rMergeDescriptor.bSendAsAttachment)
+ {
+ sBody = rMergeDescriptor.sMailBody;
+ mail::MailAttachment aAttach;
+ aAttach.Data = new SwMailTransferable(
+ sFileURL,
+ rMergeDescriptor.sAttachmentName,
+ pStoreToFilter->GetMimeType());
+ aAttach.ReadableName = rMergeDescriptor.sAttachmentName;
+ pMessage->addAttachment( aAttach );
+ }
+ else
+ {
+ {
+ //read in the temporary file and use it as mail body
+ SfxMedium aMedium( sFileURL, STREAM_READ, TRUE);
+ SvStream* pInStream = aMedium.GetInStream();
+ DBG_ASSERT(pInStream, "no output file created?");
+ if(pInStream)
+ {
+ pInStream->SetStreamCharSet( eEncoding );
+ ByteString sLine;
+ sal_Bool bDone = pInStream->ReadLine( sLine );
+ while ( bDone )
+ {
+ sBody += String(sLine, eEncoding);
+ sBody += ::rtl::OUString('\n');
+ bDone = pInStream->ReadLine( sLine );
+ }
+ }
+ }
+ }
+ pMessage->setSubject( rMergeDescriptor.sSubject );
+ uno::Reference< datatransfer::XTransferable> xBody =
+ new SwMailTransferable(
+ sBody,
+ sBodyMimeType);
+ pMessage->setBody( xBody );
+
+ if(rMergeDescriptor.aCopiesTo.getLength())
+ {
+ const ::rtl::OUString* pCopies = rMergeDescriptor.aCopiesTo.getConstArray();
+ for( sal_Int32 nToken = 0; nToken < rMergeDescriptor.aCopiesTo.getLength(); ++nToken)
+ pMessage->addCcRecipient( pCopies[nToken] );
+ }
+ if(rMergeDescriptor.aBlindCopiesTo.getLength())
+ {
+ const ::rtl::OUString* pCopies = rMergeDescriptor.aBlindCopiesTo.getConstArray();
+ for( sal_Int32 nToken = 0; nToken < rMergeDescriptor.aBlindCopiesTo.getLength(); ++nToken)
+ pMessage->addBccRecipient( pCopies[nToken] );
+ }
+ xMailDispatcher->enqueueMailMessage( xMessage );
+ if(!xMailDispatcher->isStarted())
+ xMailDispatcher->start();
+ //schedule for removal
+ aFilesToRemove.push_back(sFileURL);
+ }
+ }
+ }
+ pWorkDoc->SetNewDBMgr( pOldDBMgr );
+ }
+ xWorkDocSh->DoClose();
+ }
+ }
+ nDocNo++;
+ nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
+ } while( !bCancel &&
+ (bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
+ // save the single output document
+ if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile)
+ {
+ DBG_ASSERT( aTempFile.get(), "Temporary file not available" );
+ INetURLObject aTempFileURL(bAsSingleFile ? sSubject : aTempFile->GetURL());
+ SfxMedium* pDstMed = new SfxMedium(
+ aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ),
+ STREAM_STD_READWRITE, TRUE );
+ pDstMed->SetFilter( pStoreToFilter );
+ if(pDstMed->GetItemSet())
+ {
+ if(pStoreToFilterOptions )
+ pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions));
+ if(rMergeDescriptor.aSaveToFilterData.getLength())
+ pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData)));
+ }
+
+ xTargetDocShell->DoSaveAs(*pDstMed);
+ xTargetDocShell->DoSaveCompleted(pDstMed);
+ if( xTargetDocShell->GetError() )
+ {
+ // error message ??
+ ErrorHandler::HandleError( xTargetDocShell->GetError() );
+ bLoop = FALSE;
+ }
+ xTargetDocShell->DoClose();
+ }
+
+ //remove the temporary files
+ ::std::vector<String>::iterator aFileIter;
+ for(aFileIter = aFilesToRemove.begin();
+ aFileIter != aFilesToRemove.end(); aFileIter++)
+ SWUnoHelper::UCB_DeleteFile( *aFileIter );
+
+ // Alle Dispatcher freigeben
+ pViewFrm = SfxViewFrame::GetFirst(pSourrceDocSh);
+ while (pViewFrm)
+ {
+ pViewFrm->GetDispatcher()->Lock(FALSE);
+ pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourrceDocSh);
+ }
+
+ SW_MOD()->SetView(&pSourceShell->GetView());
+ }
+
+ nMergeType = DBMGR_INSERT;
+ }
+
+ if(bEMail)
+ {
+ xMailDispatcher->stop();
+ xMailDispatcher->shutdown();
+
+ }
+
+ return bLoop;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+IMPL_LINK_INLINE_START( SwNewDBMgr, PrtCancelHdl, Button *, pButton )
+{
+ pButton->GetParent()->Hide();
+ bCancel = TRUE;
+ return 0;
+}
+IMPL_LINK_INLINE_END( SwNewDBMgr, PrtCancelHdl, Button *, pButton )
+
+
+/*--------------------------------------------------------------------
+ Beschreibung: Numberformat der Spalte ermitteln und ggfs. in
+ den uebergebenen Formatter uebertragen
+ --------------------------------------------------------------------*/
+
+ULONG SwNewDBMgr::GetColumnFmt( const String& rDBName,
+ const String& rTableName,
+ const String& rColNm,
+ SvNumberFormatter* pNFmtr,
+ long nLanguage )
+{
+ ULONG nRet = 0;
+ if(pNFmtr)
+ {
+ uno::Reference< XDataSource> xSource;
+ uno::Reference< XConnection> xConnection;
+ sal_Bool bUseMergeData = sal_False;
+ uno::Reference< XColumnsSupplier> xColsSupp;
+ bool bDisposeConnection = false;
+ if(pImpl->pMergeData &&
+ pImpl->pMergeData->sDataSource.equals(rDBName) && pImpl->pMergeData->sCommand.equals(rTableName))
+ {
+ xConnection = pImpl->pMergeData->xConnection;
+ xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,rDBName);
+ bUseMergeData = sal_True;
+ xColsSupp = xColsSupp.query( pImpl->pMergeData->xResultSet );
+ }
+ if(!xConnection.is())
+ {
+ SwDBData aData;
+ aData.sDataSource = rDBName;
+ aData.sCommand = rTableName;
+ aData.nCommandType = -1;
+ SwDSParam* pParam = FindDSData(aData, FALSE);
+ if(pParam && pParam->xConnection.is())
+ {
+ xConnection = pParam->xConnection;
+ xColsSupp = xColsSupp.query( pParam->xResultSet );
+ }
+ else
+ {
+ rtl::OUString sDBName(rDBName);
+ xConnection = RegisterConnection( sDBName );
+ bDisposeConnection = true;
+ }
+ if(bUseMergeData)
+ pImpl->pMergeData->xConnection = xConnection;
+ }
+ bool bDispose = !xColsSupp.is();
+ if(bDispose)
+ {
+ xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
+ }
+ if(xColsSupp.is())
+ {
+ uno::Reference<XNameAccess> xCols;
+ try
+ {
+ xCols = xColsSupp->getColumns();
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("Exception in getColumns()");
+ }
+ if(!xCols.is() || !xCols->hasByName(rColNm))
+ return nRet;
+ Any aCol = xCols->getByName(rColNm);
+ uno::Reference< XPropertySet > xColumn;
+ aCol >>= xColumn;
+ nRet = GetColumnFmt(xSource, xConnection, xColumn, pNFmtr, nLanguage);
+ if(bDispose)
+ {
+ ::comphelper::disposeComponent( xColsSupp );
+ }
+ if(bDisposeConnection)
+ {
+ ::comphelper::disposeComponent( xConnection );
+ }
+ }
+ else
+ nRet = pNFmtr->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM );
+ }
+ return nRet;
+}
+/* -----------------------------07.06.01 15:43--------------------------------
+
+ ---------------------------------------------------------------------------*/
+ULONG SwNewDBMgr::GetColumnFmt( uno::Reference< XDataSource> xSource,
+ uno::Reference< XConnection> xConnection,
+ uno::Reference< XPropertySet> xColumn,
+ SvNumberFormatter* pNFmtr,
+ long nLanguage )
+{
+ //JP 12.01.99: ggfs. das NumberFormat im Doc setzen
+ ULONG nRet = 0;
+
+ if(!xSource.is())
+ {
+ uno::Reference<XChild> xChild(xConnection, UNO_QUERY);
+ xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
+ }
+ if(xSource.is() && xConnection.is() && xColumn.is() && pNFmtr)
+ {
+ SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj( pNFmtr );
+ uno::Reference< util::XNumberFormatsSupplier > xDocNumFmtsSupplier = pNumFmt;
+ uno::Reference< XNumberFormats > xDocNumberFormats = xDocNumFmtsSupplier->getNumberFormats();
+ uno::Reference< XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY);
+
+ Locale aLocale( MsLangId::convertLanguageToLocale( (LanguageType)nLanguage ));
+
+ //get the number formatter of the data source
+ uno::Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
+ uno::Reference< XNumberFormats > xNumberFormats;
+ if(xSourceProps.is())
+ {
+ Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
+ if(aFormats.hasValue())
+ {
+ uno::Reference<XNumberFormatsSupplier> xSuppl;
+ aFormats >>= xSuppl;
+ if(xSuppl.is())
+ {
+ xNumberFormats = xSuppl->getNumberFormats();
+ }
+ }
+ }
+ bool bUseDefault = true;
+ try
+ {
+ Any aFormatKey = xColumn->getPropertyValue(C2U("FormatKey"));
+ if(aFormatKey.hasValue())
+ {
+ sal_Int32 nFmt = 0;
+ aFormatKey >>= nFmt;
+ if(xNumberFormats.is())
+ {
+ try
+ {
+ uno::Reference<XPropertySet> xNumProps = xNumberFormats->getByKey( nFmt );
+ Any aFormatString = xNumProps->getPropertyValue(C2U("FormatString"));
+ Any aLocaleVal = xNumProps->getPropertyValue(C2U("Locale"));
+ rtl::OUString sFormat;
+ aFormatString >>= sFormat;
+ lang::Locale aLoc;
+ aLocaleVal >>= aLoc;
+ nFmt = xDocNumberFormats->queryKey( sFormat, aLoc, sal_False );
+ if(NUMBERFORMAT_ENTRY_NOT_FOUND == sal::static_int_cast< sal_uInt32, sal_Int32>(nFmt))
+ nFmt = xDocNumberFormats->addNew( sFormat, aLoc );
+ nRet = nFmt;
+ bUseDefault = false;
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR("illegal number format key");
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR("no FormatKey property found");
+ }
+ if(bUseDefault)
+ nRet = SwNewDBMgr::GetDbtoolsClient().getDefaultNumberFormat(xColumn, xDocNumberFormatTypes, aLocale);
+ }
+ return nRet;
+}
+
+/* -----------------------------17.07.00 09:47--------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Int32 SwNewDBMgr::GetColumnType( const String& rDBName,
+ const String& rTableName,
+ const String& rColNm )
+{
+ sal_Int32 nRet = DataType::SQLNULL;
+ SwDBData aData;
+ aData.sDataSource = rDBName;
+ aData.sCommand = rTableName;
+ aData.nCommandType = -1;
+ SwDSParam* pParam = FindDSData(aData, FALSE);
+ uno::Reference< XConnection> xConnection;
+ uno::Reference< XColumnsSupplier > xColsSupp;
+ bool bDispose = false;
+ if(pParam && pParam->xConnection.is())
+ {
+ xConnection = pParam->xConnection;
+ xColsSupp = uno::Reference< XColumnsSupplier >( pParam->xResultSet, UNO_QUERY );
+ }
+ else
+ {
+ rtl::OUString sDBName(rDBName);
+ xConnection = RegisterConnection( sDBName );
+ }
+ if( !xColsSupp.is() )
+ {
+ xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
+ bDispose = true;
+ }
+ if(xColsSupp.is())
+ {
+ uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
+ if(xCols->hasByName(rColNm))
+ {
+ Any aCol = xCols->getByName(rColNm);
+ uno::Reference<XPropertySet> xCol;
+ aCol >>= xCol;
+ Any aType = xCol->getPropertyValue(C2S("Type"));
+ aType >>= nRet;
+ }
+ if(bDispose)
+ ::comphelper::disposeComponent( xColsSupp );
+ }
+ return nRet;
+}
+
+/* -----------------------------03.07.00 17:12--------------------------------
+
+ ---------------------------------------------------------------------------*/
+uno::Reference< sdbc::XConnection> SwNewDBMgr::GetConnection(const String& rDataSource,
+ uno::Reference<XDataSource>& rxSource)
+{
+ Reference< sdbc::XConnection> xConnection;
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ try
+ {
+ Reference<XCompletedConnection> xComplConnection(SwNewDBMgr::GetDbtoolsClient().getDataSource(rDataSource, xMgr),UNO_QUERY);
+ if ( xComplConnection.is() )
+ {
+ rxSource.set(xComplConnection,UNO_QUERY);
+ Reference< XInteractionHandler > xHandler(
+ xMgr->createInstance( C2U( "com.sun.star.sdb.InteractionHandler" )), UNO_QUERY);
+ xConnection = xComplConnection->connectWithCompletion( xHandler );
+ }
+ }
+ catch(Exception&) {}
+
+ return xConnection;
+}
+/* -----------------------------03.07.00 17:12--------------------------------
+
+ ---------------------------------------------------------------------------*/
+uno::Reference< sdbcx::XColumnsSupplier> SwNewDBMgr::GetColumnSupplier(uno::Reference<sdbc::XConnection> xConnection,
+ const String& rTableOrQuery,
+ BYTE eTableOrQuery)
+{
+ Reference< sdbcx::XColumnsSupplier> xRet;
+ try
+ {
+ if(eTableOrQuery == SW_DB_SELECT_UNKNOWN)
+ {
+ //search for a table with the given command name
+ Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ Reference<XNameAccess> xTbls = xTSupplier->getTables();
+ eTableOrQuery = xTbls->hasByName(rTableOrQuery) ?
+ SW_DB_SELECT_TABLE : SW_DB_SELECT_QUERY;
+ }
+ }
+ sal_Int32 nCommandType = SW_DB_SELECT_TABLE == eTableOrQuery ?
+ CommandType::TABLE : CommandType::QUERY;
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ Reference<XRowSet> xRowSet(
+ xMgr->createInstance(C2U("com.sun.star.sdb.RowSet")), UNO_QUERY);
+
+ ::rtl::OUString sDataSource;
+ Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(xConnection, sDataSource);
+ Reference<XPropertySet> xSourceProperties(xSource, UNO_QUERY);
+ if(xSourceProperties.is())
+ {
+ xSourceProperties->getPropertyValue(C2U("Name")) >>= sDataSource;
+ }
+
+ Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY);
+ xRowProperties->setPropertyValue(C2U("DataSourceName"), makeAny(sDataSource));
+ xRowProperties->setPropertyValue(C2U("Command"), makeAny(::rtl::OUString(rTableOrQuery)));
+ xRowProperties->setPropertyValue(C2U("CommandType"), makeAny(nCommandType));
+ xRowProperties->setPropertyValue(C2U("FetchSize"), makeAny((sal_Int32)10));
+ xRowProperties->setPropertyValue(C2U("ActiveConnection"), makeAny(xConnection));
+ xRowSet->execute();
+ xRet = Reference<XColumnsSupplier>( xRowSet, UNO_QUERY );
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_ERROR("Exception in SwDBMgr::GetColumnSupplier");
+ }
+
+ return xRet;
+}
+/* -----------------------------05.07.00 13:44--------------------------------
+
+ ---------------------------------------------------------------------------*/
+String SwNewDBMgr::GetDBField(uno::Reference<XPropertySet> xColumnProps,
+ const SwDBFormatData& rDBFormatData,
+ double* pNumber)
+{
+ uno::Reference< XColumn > xColumn(xColumnProps, UNO_QUERY);
+ String sRet;
+ DBG_ASSERT(xColumn.is(), "SwNewDBMgr::::ImportDBField: illegal arguments");
+ if(!xColumn.is())
+ return sRet;
+
+ Any aType = xColumnProps->getPropertyValue(C2U("Type"));
+ sal_Int32 eDataType = 0;
+ aType >>= eDataType;
+ switch(eDataType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ try
+ {
+ sRet = xColumn->getString();
+ }
+ catch( SQLException& )
+ {
+ }
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::BIGINT:
+ case DataType::FLOAT:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ {
+// ::Date aTempDate(rDBFormatData.aNullDate.Day,
+// rDBFormatData.aNullDate.Month, rDBFormatData.aNullDate.Year);
+
+ try
+ {
+ SwDbtoolsClient& aClient = SwNewDBMgr::GetDbtoolsClient();
+ sRet = aClient.getValue(
+ xColumnProps,
+ rDBFormatData.xFormatter,
+ rDBFormatData.aLocale,
+ rDBFormatData.aNullDate);
+ if (pNumber)
+ {
+ double fVal = xColumn->getDouble();
+ if(!xColumn->wasNull())
+ {
+ *pNumber = fVal;
+ }
+ }
+ }
+ catch(Exception& )
+ {
+ DBG_ERROR("exception caught");
+ }
+
+ }
+ break;
+
+// case DataType::BINARY:
+// case DataType::VARBINARY:
+// case DataType::LONGVARBINARY:
+// case DataType::SQLNULL:
+// case DataType::OTHER:
+// case DataType::OBJECT:
+// case DataType::DISTINCT:
+// case DataType::STRUCT:
+// case DataType::ARRAY:
+// case DataType::BLOB:
+// case DataType::CLOB:
+// case DataType::REF:
+// default:
+ }
+// if (pFormat)
+// {
+// SFX_ITEMSET_GET(*pCol, pFormatItem, SfxUInt32Item, SBA_DEF_FMTVALUE, sal_True);
+// *pFormat = pFormatItem->GetValue();
+// }
+
+ return sRet;
+}
+/* -----------------------------06.07.00 14:28--------------------------------
+ releases the merge data source table or query after merge is completed
+ ---------------------------------------------------------------------------*/
+void SwNewDBMgr::EndMerge()
+{
+ DBG_ASSERT(bInMerge, "merge is not active");
+ bInMerge = FALSE;
+ delete pImpl->pMergeData;
+ pImpl->pMergeData = 0;
+}
+/* -----------------------------06.07.00 14:28--------------------------------
+ checks if a desired data source table or query is open
+ ---------------------------------------------------------------------------*/
+BOOL SwNewDBMgr::IsDataSourceOpen(const String& rDataSource,
+ const String& rTableOrQuery, sal_Bool bMergeOnly)
+{
+ if(pImpl->pMergeData)
+ {
+ return !bMergeLock &&
+ ((rDataSource == (String)pImpl->pMergeData->sDataSource &&
+ rTableOrQuery == (String)pImpl->pMergeData->sCommand)
+ ||(!rDataSource.Len() && !rTableOrQuery.Len()))
+ &&
+ pImpl->pMergeData->xResultSet.is();
+ }
+ else if(!bMergeOnly)
+ {
+ SwDBData aData;
+ aData.sDataSource = rDataSource;
+ aData.sCommand = rTableOrQuery;
+ aData.nCommandType = -1;
+ SwDSParam* pFound = FindDSData(aData, FALSE);
+ return (pFound && pFound->xResultSet.is());
+ }
+ return sal_False;
+}
+/* -----------------------------17.07.00 16:44--------------------------------
+ read column data a a specified position
+ ---------------------------------------------------------------------------*/
+BOOL SwNewDBMgr::GetColumnCnt(const String& rSourceName, const String& rTableName,
+ const String& rColumnName, sal_uInt32 nAbsRecordId,
+ long nLanguage,
+ String& rResult, double* pNumber)
+{
+ BOOL bRet = FALSE;
+ SwDSParam* pFound = 0;
+ //check if it's the merge data source
+ if(pImpl->pMergeData &&
+ rSourceName == (String)pImpl->pMergeData->sDataSource &&
+ rTableName == (String)pImpl->pMergeData->sCommand)
+ {
+ pFound = pImpl->pMergeData;
+ }
+ else
+ {
+ SwDBData aData;
+ aData.sDataSource = rSourceName;
+ aData.sCommand = rTableName;
+ aData.nCommandType = -1;
+ pFound = FindDSData(aData, FALSE);
+ }
+ //check validity of supplied record Id
+ if(pFound->aSelection.getLength())
+ {
+ //the destination has to be an element of the selection
+ const Any* pSelection = pFound->aSelection.getConstArray();
+ sal_Bool bFound = sal_False;
+ for(sal_Int32 nPos = 0; !bFound && nPos < pFound->aSelection.getLength(); nPos++)
+ {
+ sal_Int32 nSelection = 0;
+ pSelection[nPos] >>= nSelection;
+ if(nSelection == static_cast<sal_Int32>(nAbsRecordId))
+ bFound = sal_True;
+ }
+ if(!bFound)
+ return FALSE;
+ }
+ if(pFound && pFound->xResultSet.is() && !pFound->bAfterSelection)
+ {
+ sal_Int32 nOldRow = 0;
+ try
+ {
+ nOldRow = pFound->xResultSet->getRow();
+ }
+ catch(const Exception& )
+ {
+ return FALSE;
+ }
+ //position to the desired index
+ BOOL bMove = TRUE;
+ if ( nOldRow != static_cast<sal_Int32>(nAbsRecordId) )
+ bMove = lcl_MoveAbsolute(pFound, nAbsRecordId);
+ if(bMove)
+ {
+ bRet = lcl_GetColumnCnt(pFound, rColumnName, nLanguage, rResult, pNumber);
+ }
+ if ( nOldRow != static_cast<sal_Int32>(nAbsRecordId) )
+ bMove = lcl_MoveAbsolute(pFound, nOldRow);
+ }
+ return bRet;
+}
+/* -----------------------------06.07.00 16:47--------------------------------
+ reads the column data at the current position
+ ---------------------------------------------------------------------------*/
+BOOL SwNewDBMgr::GetMergeColumnCnt(const String& rColumnName, USHORT nLanguage,
+ String &rResult, double *pNumber, sal_uInt32 * /*pFormat*/)
+{
+ if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is() || pImpl->pMergeData->bAfterSelection )
+ {
+ rResult.Erase();
+ return FALSE;
+ }
+
+ BOOL bRet = lcl_GetColumnCnt(pImpl->pMergeData, rColumnName, nLanguage, rResult, pNumber);
+ return bRet;
+}
+/* -----------------------------07.07.00 14:28--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL SwNewDBMgr::ToNextMergeRecord()
+{
+ DBG_ASSERT(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
+ return ToNextRecord(pImpl->pMergeData);
+}
+/* -----------------------------10.07.01 14:28--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL SwNewDBMgr::ToNextRecord(
+ const String& rDataSource, const String& rCommand, sal_Int32 /*nCommandType*/)
+{
+ SwDSParam* pFound = 0;
+ if(pImpl->pMergeData &&
+ rDataSource == (String)pImpl->pMergeData->sDataSource &&
+ rCommand == (String)pImpl->pMergeData->sCommand)
+ pFound = pImpl->pMergeData;
+ else
+ {
+ SwDBData aData;
+ aData.sDataSource = rDataSource;
+ aData.sCommand = rCommand;
+ aData.nCommandType = -1;
+ pFound = FindDSData(aData, FALSE);
+ }
+ return ToNextRecord(pFound);
+}
+/* -----------------------------10.07.01 14:38--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL SwNewDBMgr::ToNextRecord(SwDSParam* pParam)
+{
+ BOOL bRet = TRUE;
+ if(!pParam || !pParam->xResultSet.is() || pParam->bEndOfDB ||
+ (pParam->aSelection.getLength() && pParam->aSelection.getLength() <= pParam->nSelectionIndex))
+ {
+ if(pParam)
+ pParam->CheckEndOfDB();
+ return FALSE;
+ }
+ try
+ {
+ if(pParam->aSelection.getLength())
+ {
+ sal_Int32 nPos = 0;
+ pParam->aSelection.getConstArray()[ pParam->nSelectionIndex++ ] >>= nPos;
+ pParam->bEndOfDB = !pParam->xResultSet->absolute( nPos );
+ pParam->CheckEndOfDB();
+ bRet = !pParam->bEndOfDB;
+ if(pParam->nSelectionIndex >= pParam->aSelection.getLength())
+ pParam->bEndOfDB = TRUE;
+ }
+ else
+ {
+ sal_Int32 nBefore = pParam->xResultSet->getRow();
+ pParam->bEndOfDB = !pParam->xResultSet->next();
+ if( !pParam->bEndOfDB && nBefore == pParam->xResultSet->getRow())
+ {
+ //next returned true but it didn't move
+ pParam->bEndOfDB = sal_True;
+ }
+
+ pParam->CheckEndOfDB();
+ bRet = !pParam->bEndOfDB;
+ ++pParam->nSelectionIndex;
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ return bRet;
+}
+
+/* -----------------------------13.07.00 17:23--------------------------------
+ synchronized labels contain a next record field at their end
+ to assure that the next page can be created in mail merge
+ the cursor position must be validated
+ ---------------------------------------------------------------------------*/
+BOOL SwNewDBMgr::ExistsNextRecord() const
+{
+ return pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB;
+}
+/* -----------------------------13.07.00 10:41--------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_uInt32 SwNewDBMgr::GetSelectedRecordId()
+{
+ sal_uInt32 nRet = 0;
+ DBG_ASSERT(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
+ if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is())
+ return FALSE;
+ try
+ {
+ nRet = pImpl->pMergeData->xResultSet->getRow();
+ }
+ catch(Exception& )
+ {
+ }
+ return nRet;
+}
+/* -----------------------------13.07.00 10:58--------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Bool SwNewDBMgr::ToRecordId(sal_Int32 nSet)
+{
+ DBG_ASSERT(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
+ if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is()|| nSet < 0)
+ return FALSE;
+ sal_Bool bRet = FALSE;
+ sal_Int32 nAbsPos = nSet;
+
+ if(nAbsPos >= 0)
+ {
+ bRet = lcl_MoveAbsolute(pImpl->pMergeData, nAbsPos);
+ pImpl->pMergeData->bEndOfDB = !bRet;
+ pImpl->pMergeData->CheckEndOfDB();
+ }
+ return bRet;
+}
+
+/* -----------------------------17.07.00 14:17--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL SwNewDBMgr::OpenDataSource(const String& rDataSource, const String& rTableOrQuery,
+ sal_Int32 nCommandType, bool bCreate)
+{
+ SwDBData aData;
+ aData.sDataSource = rDataSource;
+ aData.sCommand = rTableOrQuery;
+ aData.nCommandType = nCommandType;
+
+ SwDSParam* pFound = FindDSData(aData, TRUE);
+ uno::Reference< XDataSource> xSource;
+ if(pFound->xResultSet.is())
+ return TRUE;
+ SwDSParam* pParam = FindDSConnection(rDataSource, FALSE);
+ uno::Reference< XConnection> xConnection;
+ if(pParam && pParam->xConnection.is())
+ pFound->xConnection = pParam->xConnection;
+ else if(bCreate)
+ {
+ rtl::OUString sDataSource(rDataSource);
+ pFound->xConnection = RegisterConnection( sDataSource );
+ }
+ if(pFound->xConnection.is())
+ {
+ try
+ {
+ uno::Reference< sdbc::XDatabaseMetaData > xMetaData = pFound->xConnection->getMetaData();
+ try
+ {
+ pFound->bScrollable = xMetaData
+ ->supportsResultSetType((sal_Int32)ResultSetType::SCROLL_INSENSITIVE);
+ }
+ catch(Exception&)
+ {
+ //#98373# DB driver may not be ODBC 3.0 compliant
+ pFound->bScrollable = TRUE;
+ }
+ pFound->xStatement = pFound->xConnection->createStatement();
+ rtl::OUString aQuoteChar = xMetaData->getIdentifierQuoteString();
+ rtl::OUString sStatement(C2U("SELECT * FROM "));
+ sStatement = C2U("SELECT * FROM ");
+ sStatement += aQuoteChar;
+ sStatement += rTableOrQuery;
+ sStatement += aQuoteChar;
+ pFound->xResultSet = pFound->xStatement->executeQuery( sStatement );
+
+ //after executeQuery the cursor must be positioned
+ pFound->bEndOfDB = !pFound->xResultSet->next();
+ pFound->bAfterSelection = sal_False;
+ pFound->CheckEndOfDB();
+ ++pFound->nSelectionIndex;
+ }
+ catch (Exception&)
+ {
+ pFound->xResultSet = 0;
+ pFound->xStatement = 0;
+ pFound->xConnection = 0;
+ }
+ }
+ return pFound->xResultSet.is();
+}
+/* -----------------------------14.08.2001 10:26------------------------------
+
+ ---------------------------------------------------------------------------*/
+uno::Reference< XConnection> SwNewDBMgr::RegisterConnection(rtl::OUString& rDataSource)
+{
+ SwDSParam* pFound = SwNewDBMgr::FindDSConnection(rDataSource, TRUE);
+ uno::Reference< XDataSource> xSource;
+ if(!pFound->xConnection.is())
+ {
+ pFound->xConnection = SwNewDBMgr::GetConnection(rDataSource, xSource );
+ try
+ {
+ uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
+ if(xComponent.is())
+ xComponent->addEventListener(pImpl->xDisposeListener);
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ return pFound->xConnection;
+}
+/* -----------------------------17.07.00 15:55--------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_uInt32 SwNewDBMgr::GetSelectedRecordId(
+ const String& rDataSource, const String& rTableOrQuery, sal_Int32 nCommandType)
+{
+ sal_uInt32 nRet = 0xffffffff;
+ //check for merge data source first
+ if(pImpl->pMergeData && rDataSource == (String)pImpl->pMergeData->sDataSource &&
+ rTableOrQuery == (String)pImpl->pMergeData->sCommand &&
+ (nCommandType == -1 || nCommandType == pImpl->pMergeData->nCommandType) &&
+ pImpl->pMergeData->xResultSet.is())
+ nRet = GetSelectedRecordId();
+ else
+ {
+ SwDBData aData;
+ aData.sDataSource = rDataSource;
+ aData.sCommand = rTableOrQuery;
+ aData.nCommandType = nCommandType;
+ SwDSParam* pFound = FindDSData(aData, FALSE);
+ if(pFound && pFound->xResultSet.is())
+ {
+ try
+ { //if a selection array is set the current row at the result set may not be set yet
+ if(pFound->aSelection.getLength())
+ {
+ sal_Int32 nSelIndex = pFound->nSelectionIndex;
+ if(nSelIndex >= pFound->aSelection.getLength())
+ nSelIndex = pFound->aSelection.getLength() -1;
+ pFound->aSelection.getConstArray()[nSelIndex] >>= nRet;
+
+ }
+ else
+ nRet = pFound->xResultSet->getRow();
+ }
+ catch(Exception&){}
+ }
+ }
+ return nRet;
+}
+
+/* -----------------------------17.07.00 14:18--------------------------------
+ close all data sources - after fields were updated
+ ---------------------------------------------------------------------------*/
+void SwNewDBMgr::CloseAll(BOOL bIncludingMerge)
+{
+ //the only thing done here is to reset the selection index
+ //all connections stay open
+ for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++)
+ {
+ SwDSParam* pParam = aDataSourceParams[nPos];
+ if(bIncludingMerge || pParam != pImpl->pMergeData)
+ {
+ pParam->nSelectionIndex = 0;
+ pParam->bAfterSelection = sal_False;
+ pParam->bEndOfDB = sal_False;
+ try
+ {
+ if(!bInMerge && pParam->xResultSet.is())
+ pParam->xResultSet->first();
+ }
+ catch(Exception& )
+ {}
+ }
+ }
+}
+/* -----------------------------17.07.00 14:54--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwDSParam* SwNewDBMgr::FindDSData(const SwDBData& rData, BOOL bCreate)
+{
+ //prefer merge data if available
+ if(pImpl->pMergeData && rData.sDataSource == pImpl->pMergeData->sDataSource &&
+ rData.sCommand == pImpl->pMergeData->sCommand &&
+ (rData.nCommandType == -1 || rData.nCommandType == pImpl->pMergeData->nCommandType ||
+ (bCreate && pImpl->pMergeData->nCommandType == -1)))
+ {
+ return pImpl->pMergeData;
+ }
+
+ SwDSParam* pFound = 0;
+ for(USHORT nPos = aDataSourceParams.Count(); nPos; nPos--)
+ {
+ SwDSParam* pParam = aDataSourceParams[nPos - 1];
+ if(rData.sDataSource == pParam->sDataSource &&
+ rData.sCommand == pParam->sCommand &&
+ (rData.nCommandType == -1 || rData.nCommandType == pParam->nCommandType ||
+ (bCreate && pParam->nCommandType == -1)))
+ {
+ //#94779# calls from the calculator may add a connection with an invalid commandtype
+ //later added "real" data base connections have to re-use the already available
+ //DSData and set the correct CommandType
+ if(bCreate && pParam->nCommandType == -1)
+ pParam->nCommandType = rData.nCommandType;
+ pFound = pParam;
+ break;
+ }
+ }
+ if(bCreate)
+ {
+ if(!pFound)
+ {
+ pFound = new SwDSParam(rData);
+ aDataSourceParams.Insert(pFound, aDataSourceParams.Count());
+ try
+ {
+ uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
+ if(xComponent.is())
+ xComponent->addEventListener(pImpl->xDisposeListener);
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ }
+ return pFound;
+}
+/* -----------------------------14.08.2001 10:27------------------------------
+
+ ---------------------------------------------------------------------------*/
+
+SwDSParam* SwNewDBMgr::FindDSConnection(const rtl::OUString& rDataSource, BOOL bCreate)
+{
+ //prefer merge data if available
+ if(pImpl->pMergeData && rDataSource == pImpl->pMergeData->sDataSource )
+ {
+ return pImpl->pMergeData;
+ }
+ SwDSParam* pFound = 0;
+ for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++)
+ {
+ SwDSParam* pParam = aDataSourceParams[nPos];
+ if(rDataSource == pParam->sDataSource)
+ {
+ pFound = pParam;
+ break;
+ }
+ }
+ if(bCreate && !pFound)
+ {
+ SwDBData aData;
+ aData.sDataSource = rDataSource;
+ pFound = new SwDSParam(aData);
+ aDataSourceParams.Insert(pFound, aDataSourceParams.Count());
+ try
+ {
+ uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
+ if(xComponent.is())
+ xComponent->addEventListener(pImpl->xDisposeListener);
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ return pFound;
+}
+
+/* -----------------------------17.07.00 14:34--------------------------------
+
+ ---------------------------------------------------------------------------*/
+const SwDBData& SwNewDBMgr::GetAddressDBName()
+{
+ return SW_MOD()->GetDBConfig()->GetAddressSource();
+}
+/* -----------------------------18.07.00 13:13--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Sequence<rtl::OUString> SwNewDBMgr::GetExistingDatabaseNames()
+{
+ uno::Reference<XNameAccess> xDBContext;
+ uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ if( xMgr.is() )
+ {
+ uno::Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
+ xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ;
+ }
+ if(xDBContext.is())
+ {
+ return xDBContext->getElementNames();
+ }
+ return Sequence<rtl::OUString>();
+}
+/*-- 26.05.2004 14:33:13---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+String SwNewDBMgr::LoadAndRegisterDataSource()
+{
+ sfx2::FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
+ Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
+
+ String sHomePath(SvtPathOptions().GetWorkPath());
+ aDlgHelper.SetDisplayDirectory( sHomePath );
+
+ Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
+
+ String sFilterAll(SW_RES(STR_FILTER_ALL));
+ String sFilterAllData(SW_RES(STR_FILTER_ALL_DATA));
+ String sFilterSXB(SW_RES(STR_FILTER_SXB));
+ String sFilterSXC(SW_RES(STR_FILTER_SXC));
+ String sFilterDBF(SW_RES(STR_FILTER_DBF));
+ String sFilterXLS(SW_RES(STR_FILTER_XLS));
+ String sFilterTXT(SW_RES(STR_FILTER_TXT));
+ String sFilterCSV(SW_RES(STR_FILTER_CSV));
+#ifdef WNT
+ String sFilterMDB(SW_RES(STR_FILTER_MDB));
+ String sFilterACCDB(SW_RES(STR_FILTER_ACCDB));
+#endif
+ xFltMgr->appendFilter( sFilterAll, C2U("*") );
+ xFltMgr->appendFilter( sFilterAllData, C2U("*.ods;*.sxc;*.dbf;*.xls;*.txt;*.csv"));
+
+ xFltMgr->appendFilter( sFilterSXB, C2U("*.odb") );
+ xFltMgr->appendFilter( sFilterSXC, C2U("*.ods;*.sxc") );
+ xFltMgr->appendFilter( sFilterDBF, C2U("*.dbf") );
+ xFltMgr->appendFilter( sFilterXLS, C2U("*.xls") );
+ xFltMgr->appendFilter( sFilterTXT, C2U("*.txt") );
+ xFltMgr->appendFilter( sFilterCSV, C2U("*.csv") );
+#ifdef WNT
+ xFltMgr->appendFilter( sFilterMDB, C2U("*.mdb") );
+ xFltMgr->appendFilter( sFilterACCDB, C2U("*.accdb") );
+#endif
+
+ xFltMgr->setCurrentFilter( sFilterAll ) ;
+ String sFind;
+ bool bTextConnection = false;
+ if( ERRCODE_NONE == aDlgHelper.Execute() )
+ {
+ String sURL = xFP->getFiles().getConstArray()[0];
+ //data sources have to be registered depending on their extensions
+ INetURLObject aURL( sURL );
+ String sExt( aURL.GetExtension() );
+ Any aURLAny;
+ Any aTableFilterAny;
+ Any aSuppressVersionsAny;
+ Any aInfoAny;
+ INetURLObject aTempURL(aURL);
+ bool bStore = true;
+ if(sExt.EqualsAscii("odb"))
+ {
+ bStore = false;
+ }
+ else if(sExt.EqualsIgnoreCaseAscii("sxc")
+ || sExt.EqualsIgnoreCaseAscii("ods")
+ || sExt.EqualsIgnoreCaseAscii("xls"))
+ {
+ rtl::OUString sDBURL(C2U("sdbc:calc:"));
+ sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
+ aURLAny <<= sDBURL;
+ }
+ else if(sExt.EqualsIgnoreCaseAscii("dbf"))
+ {
+ aTempURL.removeSegment();
+ aTempURL.removeFinalSlash();
+ rtl::OUString sDBURL(C2U("sdbc:dbase:"));
+ sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
+ aURLAny <<= sDBURL;
+ //set the filter to the file name without extension
+ Sequence<rtl::OUString> aFilters(1);
+ rtl::OUString sTmp(aURL.getBase());
+ aFilters[0] = aURL.getBase();
+ aTableFilterAny <<= aFilters;
+ }
+ else if(sExt.EqualsIgnoreCaseAscii("csv") || sExt.EqualsIgnoreCaseAscii("txt"))
+ {
+ aTempURL.removeSegment();
+ aTempURL.removeFinalSlash();
+ rtl::OUString sDBURL(C2U("sdbc:flat:"));
+ //only the 'path' has to be added
+ sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
+ aURLAny <<= sDBURL;
+
+ bTextConnection = true;
+ //set the filter to the file name without extension
+ Sequence<rtl::OUString> aFilters(1);
+ rtl::OUString sTmp(aURL.getBase());
+ aFilters[0] = aURL.getBase();
+ aTableFilterAny <<= aFilters;
+ }
+#ifdef WNT
+ else if(sExt.EqualsIgnoreCaseAscii("mdb"))
+ {
+ rtl::OUString sDBURL(C2U("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="));
+ sDBURL += aTempURL.PathToFileName();
+ aURLAny <<= sDBURL;
+ aSuppressVersionsAny <<= makeAny(true);
+ }
+ else if(sExt.EqualsIgnoreCaseAscii("accdb"))
+ {
+ rtl::OUString sDBURL(C2U("sdbc:ado:PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE="));
+ sDBURL += aTempURL.PathToFileName();
+ aURLAny <<= sDBURL;
+ aSuppressVersionsAny <<= makeAny(true);
+ }
+#endif
+ try
+ {
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
+ Reference<XNameAccess> xDBContext(xInstance, UNO_QUERY_THROW);
+ Reference<XSingleServiceFactory> xFact( xDBContext, UNO_QUERY);
+
+ String sNewName = INetURLObject::decode( aURL.getName(),
+ INET_HEX_ESCAPE,
+ INetURLObject::DECODE_UNAMBIGUOUS,
+ RTL_TEXTENCODING_UTF8 );
+ xub_StrLen nExtLen = static_cast< xub_StrLen >(aURL.GetExtension().getLength());
+ sNewName.Erase( sNewName.Len() - nExtLen - 1, nExtLen + 1 );
+
+ //find a unique name if sNewName already exists
+ sFind = sNewName;
+ sal_Int32 nIndex = 0;
+ while(xDBContext->hasByName(sFind))
+ {
+ sFind = sNewName;
+ sFind += String::CreateFromInt32(++nIndex);
+ }
+
+ Reference<XInterface> xNewInstance;
+ if(!bStore)
+ {
+ //odb-file
+ Any aDataSource = xDBContext->getByName(aTempURL.GetMainURL(INetURLObject::NO_DECODE));
+ aDataSource >>= xNewInstance;
+ }
+ else
+ {
+ xNewInstance = xFact->createInstance();
+ Reference<XPropertySet> xDataProperties(xNewInstance, UNO_QUERY);
+
+ if(aURLAny.hasValue())
+ xDataProperties->setPropertyValue(C2U("URL"), aURLAny);
+ if(aTableFilterAny.hasValue())
+ xDataProperties->setPropertyValue(C2U("TableFilter"), aTableFilterAny);
+ if(aSuppressVersionsAny.hasValue())
+ xDataProperties->setPropertyValue(C2U("SuppressVersionColumns"), aSuppressVersionsAny);
+ if(aInfoAny.hasValue())
+ xDataProperties->setPropertyValue(C2U("Info"), aInfoAny);
+
+ if( bTextConnection )
+ {
+ uno::Reference < ui::dialogs::XExecutableDialog > xSettingsDlg(
+ xMgr->createInstance( C2U( "com.sun.star.sdb.TextConnectionSettings" ) ), uno::UNO_QUERY);
+ if( xSettingsDlg->execute() )
+ {
+ uno::Any aSettings = xDataProperties->getPropertyValue( C2U( "Settings" ) );
+ uno::Reference < beans::XPropertySet > xDSSettings;
+ aSettings >>= xDSSettings;
+ ::comphelper::copyProperties(
+ uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY ),
+ xDSSettings );
+ xDSSettings->setPropertyValue( C2U("Extension"), uno::makeAny( ::rtl::OUString( sExt )));
+ }
+ }
+
+ Reference<XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW);
+ Reference<XStorable> xStore(xDS->getDatabaseDocument(), UNO_QUERY_THROW);
+ String sOutputExt = String::CreateFromAscii(".odb");
+ String sTmpName;
+ {
+ utl::TempFile aTempFile(sNewName , &sOutputExt, &sHomePath);
+ aTempFile.EnableKillingFile(sal_True);
+ sTmpName = aTempFile.GetURL();
+ }
+ xStore->storeAsURL(sTmpName, Sequence< PropertyValue >());
+ }
+ Reference<XNamingService> xNaming(xDBContext, UNO_QUERY);
+ xNaming->registerObject( sFind, xNewInstance );
+
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ return sFind;
+
+}
+/* -----------------------------10.11.00 17:10--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh,
+ const Sequence<PropertyValue>& rProperties,
+ BOOL bWithDataSourceBrowser)
+{
+ //prevent second call
+ if(pImpl->pMergeDialog)
+ return ;
+ rtl::OUString sDataSource, sDataTableOrQuery;
+ Sequence<Any> aSelection;
+
+ sal_Int16 nCmdType = CommandType::TABLE;
+ uno::Reference< XConnection> xConnection;
+
+ ODataAccessDescriptor aDescriptor(rProperties);
+ sDataSource = aDescriptor.getDataSource();
+ aDescriptor[daCommand] >>= sDataTableOrQuery;
+ aDescriptor[daCommandType] >>= nCmdType;
+
+ if ( aDescriptor.has(daSelection) )
+ aDescriptor[daSelection] >>= aSelection;
+ if ( aDescriptor.has(daConnection) )
+ aDescriptor[daConnection] >>= xConnection;
+
+ if(!sDataSource.getLength() || !sDataTableOrQuery.getLength())
+ {
+ DBG_ERROR("PropertyValues missing or unset");
+ return;
+ }
+
+ //always create a connection for the dialog and dispose it after the dialog has been closed
+ SwDSParam* pFound = 0;
+ if(!xConnection.is())
+ {
+ xConnection = SwNewDBMgr::RegisterConnection(sDataSource);
+ pFound = FindDSConnection(sDataSource, TRUE);
+ }
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet fail!");
+ pImpl->pMergeDialog = pFact->CreateMailMergeDlg( DLG_MAILMERGE,
+ &rSh.GetView().GetViewFrame()->GetWindow(), rSh,
+ sDataSource,
+ sDataTableOrQuery,
+ nCmdType,
+ xConnection,
+ bWithDataSourceBrowser ? 0 : &aSelection);
+ DBG_ASSERT(pImpl->pMergeDialog, "Dialogdiet fail!");
+ if(pImpl->pMergeDialog->Execute() == RET_OK)
+ {
+ aDescriptor[daSelection] <<= pImpl->pMergeDialog->GetSelection();
+
+ uno::Reference<XResultSet> xResSet = pImpl->pMergeDialog->GetResultSet();
+ if(xResSet.is())
+ aDescriptor[daCursor] <<= xResSet;
+
+ SfxObjectShellRef xDocShell = rSh.GetView().GetViewFrame()->GetObjectShell();
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xDocShell));
+ {
+ //copy rSh to aTempFile
+ ::rtl::OUString sTempURL;
+ const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
+ String::CreateFromAscii( FILTER_XML ),
+ SwDocShell::Factory().GetFilterContainer() );
+ try
+ {
+
+ uno::Sequence< beans::PropertyValue > aValues(1);
+ beans::PropertyValue* pValues = aValues.getArray();
+ pValues[0].Name = C2U("FilterName");
+ pValues[0].Value <<= ::rtl::OUString(pSfxFlt->GetFilterName());
+ uno::Reference< frame::XStorable > xStore( xDocShell->GetModel(), uno::UNO_QUERY);
+ sTempURL = URIHelper::SmartRel2Abs( INetURLObject(), utl::TempFile::CreateTempName() );
+ xStore->storeToURL( sTempURL, aValues );
+ }
+ catch( const uno::Exception& rEx )
+ {
+ (void) rEx;
+ }
+ if( xDocShell->GetError() )
+ {
+ // error message ??
+ ErrorHandler::HandleError( xDocShell->GetError() );
+ }
+ else
+ {
+ SfxObjectShellRef xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL ));
+ SfxMedium* pWorkMed = new SfxMedium( sTempURL, STREAM_STD_READ, TRUE );
+ pWorkMed->SetFilter( pSfxFlt );
+ if( xWorkDocSh->DoLoad(pWorkMed) )
+ {
+ SfxViewFrame *pFrame = SfxViewFrame::CreateViewFrame( *xWorkDocSh, 0, TRUE );
+ SwView *pView = (SwView*) pFrame->GetViewShell();
+ pView->AttrChangedNotify( &pView->GetWrtShell() );//Damit SelectShell gerufen wird.
+ //set the current DBMgr
+ SwDoc* pWorkDoc = pView->GetWrtShell().GetDoc();
+ SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
+ pWorkDoc->SetNewDBMgr( this );
+
+ SwMergeDescriptor aMergeDesc( pImpl->pMergeDialog->GetMergeType(), pView->GetWrtShell(), aDescriptor );
+ aMergeDesc.sSaveToFilter = pImpl->pMergeDialog->GetSaveFilter();
+ MergeNew(aMergeDesc);
+
+ pWorkDoc->SetNewDBMgr( pWorkDBMgr );
+ //close the temporary file
+ uno::Reference< util::XCloseable > xClose( xWorkDocSh->GetModel(), uno::UNO_QUERY );
+ if (xClose.is())
+ {
+ try
+ {
+ //! 'sal_True' -> transfer ownership to vetoing object if vetoed!
+ //! I.e. now that object is responsible for closing the model and doc shell.
+ xClose->close( sal_True );
+ }
+ catch ( const uno::Exception& )
+ {
+ }
+ }
+ }
+ }
+ //remove the temporary file
+ SWUnoHelper::UCB_DeleteFile( sTempURL );
+ }
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), rSh.GetView().GetViewFrame()->GetObjectShell()));
+
+ // reset the cursor inside
+ xResSet = NULL;
+ aDescriptor[daCursor] <<= xResSet;
+ }
+ if(pFound)
+ {
+ for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++)
+ {
+ SwDSParam* pParam = aDataSourceParams[nPos];
+ if(pParam == pFound)
+ {
+ try
+ {
+ uno::Reference<XComponent> xComp(pParam->xConnection, UNO_QUERY);
+ if(xComp.is())
+ xComp->dispose();
+ }
+ catch(const RuntimeException& )
+ {
+ //may be disposed already since multiple entries may have used the same connection
+ }
+ break;
+ }
+ //pFound doesn't need to be removed/deleted -
+ //this has been done by the SwConnectionDisposedListener_Impl already
+ }
+ }
+ DELETEZ(pImpl->pMergeDialog);
+}
+/* -----------------------------13.11.00 08:20--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwNewDBMgr::InsertText(SwWrtShell& rSh,
+ const Sequence< PropertyValue>& rProperties)
+{
+ rtl::OUString sDataSource, sDataTableOrQuery;
+ uno::Reference<XResultSet> xResSet;
+ Sequence<Any> aSelection;
+ BOOL bHasSelectionProperty = FALSE;
+ sal_Int32 nSelectionPos = 0;
+ sal_Int16 nCmdType = CommandType::TABLE;
+ const PropertyValue* pValues = rProperties.getConstArray();
+ uno::Reference< XConnection> xConnection;
+ for(sal_Int32 nPos = 0; nPos < rProperties.getLength(); nPos++)
+ {
+ if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cDataSourceName)))
+ pValues[nPos].Value >>= sDataSource;
+ else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCommand)))
+ pValues[nPos].Value >>= sDataTableOrQuery;
+ else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCursor)))
+ pValues[nPos].Value >>= xResSet;
+ else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cSelection)))
+ {
+ bHasSelectionProperty = TRUE;
+ nSelectionPos = nPos;
+ pValues[nPos].Value >>= aSelection;
+ }
+ else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCommandType)))
+ pValues[nPos].Value >>= nCmdType;
+ else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cActiveConnection)))
+ pValues[nPos].Value >>= xConnection;
+ }
+ if(!sDataSource.getLength() || !sDataTableOrQuery.getLength() || !xResSet.is())
+ {
+ DBG_ERROR("PropertyValues missing or unset");
+ return;
+ }
+ uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ uno::Reference<XDataSource> xSource;
+ uno::Reference<XChild> xChild(xConnection, UNO_QUERY);
+ if(xChild.is())
+ xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
+ if(!xSource.is())
+ xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(sDataSource, xMgr);
+ uno::Reference< XColumnsSupplier > xColSupp( xResSet, UNO_QUERY );
+ SwDBData aDBData;
+ aDBData.sDataSource = sDataSource;
+ aDBData.sCommand = sDataTableOrQuery;
+ aDBData.nCommandType = nCmdType;
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwInsertDBColAutoPilot* pDlg = pFact->CreateSwInsertDBColAutoPilot( rSh.GetView(),
+ xSource,
+ xColSupp,
+ aDBData,
+ DLG_AP_INSERT_DB_SEL );
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ if( RET_OK == pDlg->Execute() )
+ {
+ rtl::OUString sDummy;
+ if(!xConnection.is())
+ xConnection = xSource->getConnection(sDummy, sDummy);
+ try
+ {
+ pDlg->DataToDoc( aSelection , xSource, xConnection, xResSet);
+ }
+ catch(Exception& )
+ {
+ DBG_ERROR("exception caught");
+ }
+ }
+ delete pDlg;
+
+}
+/* -----------------------------30.08.2001 12:00------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwDbtoolsClient* SwNewDBMgr::pDbtoolsClient = NULL;
+
+SwDbtoolsClient& SwNewDBMgr::GetDbtoolsClient()
+{
+ if ( !pDbtoolsClient )
+ pDbtoolsClient = new SwDbtoolsClient;
+ return *pDbtoolsClient;
+}
+/* -----------------13.05.2003 15:34-----------------
+
+ --------------------------------------------------*/
+void SwNewDBMgr::RemoveDbtoolsClient()
+{
+ delete pDbtoolsClient;
+ pDbtoolsClient = 0;
+}
+/* -----------------------------20.08.2002 12:00------------------------------
+
+ ---------------------------------------------------------------------------*/
+uno::Reference<XDataSource> SwNewDBMgr::getDataSourceAsParent(const uno::Reference< XConnection>& _xConnection,const ::rtl::OUString& _sDataSourceName)
+{
+ uno::Reference<XDataSource> xSource;
+ try
+ {
+ uno::Reference<XChild> xChild(_xConnection, UNO_QUERY);
+ if ( xChild.is() )
+ xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
+ if ( !xSource.is() )
+ xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(_sDataSourceName, ::comphelper::getProcessServiceFactory());
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR("exception in getDataSourceAsParent caught");
+ }
+ return xSource;
+}
+/* -----------------------------20.08.2002 12:00------------------------------
+
+ ---------------------------------------------------------------------------*/
+uno::Reference<XResultSet> SwNewDBMgr::createCursor(const ::rtl::OUString& _sDataSourceName,
+ const ::rtl::OUString& _sCommand,
+ sal_Int32 _nCommandType,
+ const uno::Reference<XConnection>& _xConnection
+ )
+{
+ uno::Reference<XResultSet> xResultSet;
+ try
+ {
+ uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ if( xMgr.is() )
+ {
+ uno::Reference<XInterface> xInstance = xMgr->createInstance(
+ C2U( "com.sun.star.sdb.RowSet" ));
+ uno::Reference<XPropertySet> xRowSetPropSet(xInstance, UNO_QUERY);
+ if(xRowSetPropSet.is())
+ {
+ xRowSetPropSet->setPropertyValue(C2U("DataSourceName"), makeAny(_sDataSourceName));
+ xRowSetPropSet->setPropertyValue(C2U("ActiveConnection"), makeAny(_xConnection));
+ xRowSetPropSet->setPropertyValue(C2U("Command"), makeAny(_sCommand));
+ xRowSetPropSet->setPropertyValue(C2U("CommandType"), makeAny(_nCommandType));
+
+ uno::Reference< XCompletedExecution > xRowSet(xInstance, UNO_QUERY);
+
+ if ( xRowSet.is() )
+ {
+ uno::Reference< XInteractionHandler > xHandler(xMgr->createInstance(C2U("com.sun.star.sdb.InteractionHandler")), UNO_QUERY);
+ xRowSet->executeWithCompletion(xHandler);
+ }
+ xResultSet = uno::Reference<XResultSet>(xRowSet, UNO_QUERY);
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_ASSERT(0,"Caught exception while creating a new RowSet!");
+ }
+ return xResultSet;
+}
+/*-- 13.05.2004 16:14:15---------------------------------------------------
+ merge all data into one resulting document and return the number of
+ merged documents
+ -----------------------------------------------------------------------*/
+
+sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
+ SwView& rSourceView )
+{
+ // check the availability of all data in the config item
+ uno::Reference< XResultSet> xResultSet = rMMConfig.GetResultSet();
+ if(!xResultSet.is())
+ return false;
+ bInMerge = TRUE;
+ sal_Int32 nRet = 0;
+ pImpl->pMergeData = new SwDSParam(
+ rMMConfig.GetCurrentDBData(), xResultSet, rMMConfig.GetSelection());
+
+ try{
+ //set to start position
+ if(pImpl->pMergeData->aSelection.getLength())
+ {
+ sal_Int32 nPos = 0;
+ pImpl->pMergeData->aSelection.getConstArray()[ pImpl->pMergeData->nSelectionIndex++ ] >>= nPos;
+ pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->absolute( nPos );
+ pImpl->pMergeData->CheckEndOfDB();
+ if(pImpl->pMergeData->nSelectionIndex >= pImpl->pMergeData->aSelection.getLength())
+ pImpl->pMergeData->bEndOfDB = TRUE;
+ }
+ else
+ {
+ pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->first();
+ pImpl->pMergeData->CheckEndOfDB();
+ }
+ }
+ catch(Exception&)
+ {
+ pImpl->pMergeData->bEndOfDB = TRUE;
+ pImpl->pMergeData->CheckEndOfDB();
+ DBG_ERROR("exception in MergeNew()");
+ }
+
+ //bCancel is set from the PrintMonitor
+ bCancel = FALSE;
+
+ CreateMonitor aMonitorDlg(&rSourceView.GetEditWin());
+ aMonitorDlg.SetCancelHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
+ if (!IsMergeSilent())
+ {
+ aMonitorDlg.Show();
+ aMonitorDlg.Invalidate();
+ aMonitorDlg.Update();
+ // the print monitor needs some time to act
+ for( USHORT i = 0; i < 25; i++)
+ Application::Reschedule();
+ }
+
+ SwWrtShell& rSourceShell = rSourceView.GetWrtShell();
+ BOOL bSynchronizedDoc = rSourceShell.IsLabelDoc() && rSourceShell.GetSectionFmtCount() > 1;
+ //save the settings of the first
+ rSourceShell.SttEndDoc(TRUE);
+ USHORT nStartingPageNo = rSourceShell.GetVirtPageNum();
+ String sModifiedStartingPageDesc;
+ String sStartingPageDesc = sModifiedStartingPageDesc = rSourceShell.GetPageDesc(
+ rSourceShell.GetCurPageDesc()).GetName();
+
+ try
+ {
+ // create a target docshell to put the merged document into
+ SfxObjectShellRef xTargetDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
+ xTargetDocShell->DoInitNew( 0 );
+ SfxViewFrame* pTargetFrame = SfxViewFrame::CreateViewFrame( *xTargetDocShell, 0, TRUE );
+
+ //the created window has to be located at the same position as the source window
+ Window& rTargetWindow = pTargetFrame->GetFrame()->GetWindow();
+ Window& rSourceWindow = rSourceView.GetViewFrame()->GetFrame()->GetWindow();
+ rTargetWindow.SetPosPixel(rSourceWindow.GetPosPixel());
+
+// pTargetFrame->GetFrame()->Appear();
+ SwView* pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() );
+ rMMConfig.SetTargetView(pTargetView);
+ //initiate SelectShell() to create sub shells
+ pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() );
+ SwWrtShell* pTargetShell = pTargetView->GetWrtShellPtr();
+ // #i63806#
+ const SwPageDesc* pSourcePageDesc = rSourceShell.FindPageDescByName( sStartingPageDesc );
+ const SwFrmFmt& rMaster = pSourcePageDesc->GetMaster();
+ bool bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive() ||
+ rMaster.GetFooter().IsActive();
+
+
+ // #122799# copy compatibility options
+ lcl_CopyCompatibilityOptions( rSourceShell, *pTargetShell);
+ // #72821# copy dynamic defaults
+ lcl_CopyDynamicDefaults( *rSourceShell.GetDoc(), *pTargetShell->GetDoc() );
+
+
+ long nStartRow, nEndRow;
+ ULONG nDocNo = 1;
+ sal_Int32 nDocCount = 0;
+ if( !IsMergeSilent() && lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) )
+ aMonitorDlg.SetTotalCount( nDocCount );
+
+ do
+ {
+ nStartRow = pImpl->pMergeData->xResultSet->getRow();
+ if (!IsMergeSilent())
+ {
+ aMonitorDlg.SetCurrentPosition( nDocNo );
+ aMonitorDlg.Invalidate();
+ aMonitorDlg.Update();
+ // the print monitor needs some time to act
+ for( USHORT i = 0; i < 25; i++)
+ Application::Reschedule();
+ }
+
+ // copy the source document
+ SfxObjectShellRef xWorkDocSh;
+ if(nDocNo == 1 )
+ {
+ uno::Reference< util::XCloneable > xClone( rSourceView.GetDocShell()->GetModel(), uno::UNO_QUERY);
+ uno::Reference< lang::XUnoTunnel > xWorkDocShell( xClone->createClone(), uno::UNO_QUERY);
+ SwXTextDocument* pWorkModel = reinterpret_cast<SwXTextDocument*>(xWorkDocShell->getSomething(SwXTextDocument::getUnoTunnelId()));
+ xWorkDocSh = pWorkModel->GetDocShell();
+ }
+ else
+ {
+ SwDoc* pNewDoc = rSourceView.GetDocShell()->GetDoc()->CreateCopy();
+ xWorkDocSh = new SwDocShell( pNewDoc, SFX_CREATE_MODE_STANDARD );
+ xWorkDocSh->DoInitNew();
+ }
+ //create a ViewFrame
+ SwView* pWorkView = static_cast< SwView* >( SfxViewFrame::CreateViewFrame( *xWorkDocSh, 0, sal_True )->GetViewShell() );
+ SwWrtShell& rWorkShell = pWorkView->GetWrtShell();
+ pWorkView->AttrChangedNotify( &rWorkShell );//Damit SelectShell gerufen wird.
+
+ // merge the data
+ SwDoc* pWorkDoc = rWorkShell.GetDoc();
+ SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
+ pWorkDoc->SetNewDBMgr( this );
+ pWorkDoc->EmbedAllLinks();
+ if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds())
+ rWorkShell.Undo();
+ // #i69485# lock fields to prevent access to the result set while calculating layout
+ rWorkShell.LockExpFlds();
+ // create a layout
+ rWorkShell.CalcLayout();
+ rWorkShell.UnlockExpFlds();
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
+ rWorkShell.ViewShell::UpdateFlds();
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
+
+ // strip invisible content and convert fields to text
+ rWorkShell.RemoveInvisibleContent();
+ rWorkShell.ConvertFieldsToText();
+ rWorkShell.SetNumberingRestart();
+
+
+ // insert the document into the target document
+ rWorkShell.SttEndDoc(FALSE);
+ rWorkShell.SttEndDoc(TRUE);
+ rWorkShell.SelAll();
+ pTargetShell->SttEndDoc(FALSE);
+
+ //#i63806# put the styles to the target document
+ //if the source uses headers or footers each new copy need to copy a new page styles
+ if(bPageStylesWithHeaderFooter)
+ {
+ //create a new pagestyle
+ //copy the pagedesc from the current document to the new document and change the name of the to-be-applied style
+
+ SwDoc* pTargetDoc = pTargetShell->GetDoc();
+ String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
+ pTargetShell->GetDoc()->MakePageDesc( sNewPageDescName );
+ SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
+ const SwPageDesc* pWorkPageDesc = rWorkShell.FindPageDescByName( sStartingPageDesc );
+
+ if(pWorkPageDesc && pTargetPageDesc)
+ {
+ pTargetDoc->CopyPageDesc( *pWorkPageDesc, *pTargetPageDesc, sal_False );
+ sModifiedStartingPageDesc = sNewPageDescName;
+ lcl_CopyFollowPageDesc( *pTargetShell, *pWorkPageDesc, *pTargetPageDesc, nDocNo );
+ }
+ }
+ if(nDocNo == 1 || bPageStylesWithHeaderFooter)
+ {
+ pTargetView->GetDocShell()->_LoadStyles( *pWorkView->GetDocShell(), sal_True );
+ }
+ if(nDocNo > 1)
+ {
+ pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
+ }
+ else
+ {
+ pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
+ }
+ USHORT nPageCountBefore = pTargetShell->GetPageCnt();
+ DBG_ASSERT(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
+ //#i51359# add a second paragraph in case there's only one
+ {
+ SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
+ SwPosition aTestPos( aIdx );
+ SwCursor aTestCrsr(aTestPos,0,false);
+ if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
+ {
+ //append a paragraph
+ pWorkDoc->AppendTxtNode( aTestPos );
+ }
+ }
+ pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
+ //convert fields in page styles (header/footer - has to be done after the first document has been pasted
+ if(1 == nDocNo)
+ {
+ pTargetShell->CalcLayout();
+ pTargetShell->ConvertFieldsToText();
+ }
+ //add the document info to the config item
+ SwDocMergeInfo aMergeInfo;
+ aMergeInfo.nStartPageInTarget = nPageCountBefore;
+ //#i72820# calculate layout to be able to find the correct page index
+ pTargetShell->CalcLayout();
+ aMergeInfo.nEndPageInTarget = pTargetShell->GetPageCnt();
+ aMergeInfo.nDBRow = nStartRow;
+ rMMConfig.AddMergedDocument( aMergeInfo );
+ ++nRet;
+
+ // the print monitor needs some time to act
+ for( USHORT i = 0; i < 25; i++)
+ Application::Reschedule();
+
+ //restore the ole DBMgr
+ pWorkDoc->SetNewDBMgr( pWorkDBMgr );
+ //now the temporary document should be closed
+ SfxObjectShellRef xDocSh(pWorkView->GetDocShell());
+ xDocSh->DoClose();
+ nEndRow = pImpl->pMergeData->xResultSet->getRow();
+ ++nDocNo;
+ } while( !bCancel &&
+ (bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
+
+ //deselect all, go out of the frame and go to the beginning of the document
+ Point aPt(LONG_MIN, LONG_MIN);
+ pTargetShell->SelectObj(aPt, SW_LEAVE_FRAME);
+ if (pTargetShell->IsSelFrmMode())
+ {
+ pTargetShell->UnSelectFrm();
+ pTargetShell->LeaveSelFrmMode();
+ }
+ pTargetShell->EnterStdMode();
+ pTargetShell->SttDoc();
+ //
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("exception caught in SwNewDBMgr::MergeDocuments");
+ }
+ DELETEZ(pImpl->pMergeData);
+ bInMerge = FALSE;
+ return nRet;
+}
+/* -----------------09.12.2002 12:38-----------------
+ *
+ * --------------------------------------------------*/
+SwConnectionDisposedListener_Impl::SwConnectionDisposedListener_Impl(SwNewDBMgr& rMgr) :
+ rDBMgr(rMgr)
+{};
+/* -----------------09.12.2002 12:39-----------------
+ *
+ * --------------------------------------------------*/
+SwConnectionDisposedListener_Impl::~SwConnectionDisposedListener_Impl()
+{};
+/* -----------------09.12.2002 12:39-----------------
+ *
+ * --------------------------------------------------*/
+void SwConnectionDisposedListener_Impl::disposing( const EventObject& rSource )
+ throw (RuntimeException)
+{
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ uno::Reference<XConnection> xSource(rSource.Source, UNO_QUERY);
+ for(USHORT nPos = rDBMgr.aDataSourceParams.Count(); nPos; nPos--)
+ {
+ SwDSParam* pParam = rDBMgr.aDataSourceParams[nPos - 1];
+ if(pParam->xConnection.is() &&
+ (xSource == pParam->xConnection))
+ {
+ rDBMgr.aDataSourceParams.DeleteAndDestroy(nPos - 1);
+ }
+ }
+}
diff --git a/sw/source/ui/dbui/dbtablepreviewdialog.cxx b/sw/source/ui/dbui/dbtablepreviewdialog.cxx
new file mode 100644
index 000000000000..f539f8e8b8d6
--- /dev/null
+++ b/sw/source/ui/dbui/dbtablepreviewdialog.cxx
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbtablepreviewdialog.cxx,v $
+ * $Revision: 1.10 $
+ *
+ * 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 <swtypes.hxx>
+#include <dbtablepreviewdialog.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/unohlp.hxx>
+#endif
+
+#include <dbui.hrc>
+#include <dbtablepreviewdialog.hrc>
+#include <unomid.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::rtl;
+
+/*-- 08.04.2004 15:12:24---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwDBTablePreviewDialog::SwDBTablePreviewDialog(Window* pParent, uno::Sequence< beans::PropertyValue>& rValues ) :
+ SfxModalDialog(pParent, SW_RES(DLG_MM_DBTABLEPREVIEWDIALOG)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aDescriptionFI( this, SW_RES( FI_DESCRIPTION)),
+ m_pBeamerWIN( new Window(this, SW_RES( WIN_BEAMER ))),
+ m_aOK( this, SW_RES( PB_OK ))
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+{
+ FreeResource();
+ const beans::PropertyValue* pValues = rValues.getConstArray();
+ for(sal_Int32 nValue = 0; nValue < rValues.getLength(); ++nValue )
+ {
+ if(pValues[nValue].Name.equalsAscii("Command"))
+ {
+ String sDescription = m_aDescriptionFI.GetText();
+ OUString sTemp;
+ pValues[nValue].Value >>= sTemp;
+ sDescription.SearchAndReplaceAscii("%1", sTemp);
+ m_aDescriptionFI.SetText(sDescription);
+ break;
+ }
+ }
+
+ try
+ {
+ // create a frame wrapper for myself
+ uno::Reference< lang::XMultiServiceFactory >
+ xMgr = comphelper::getProcessServiceFactory();
+ m_xFrame = uno::Reference< frame::XFrame >(xMgr->createInstance(C2U("com.sun.star.frame.Frame")), uno::UNO_QUERY);
+ if(m_xFrame.is())
+ {
+ m_xFrame->initialize( VCLUnoHelper::GetInterface ( m_pBeamerWIN ) );
+ }
+ }
+ catch (uno::Exception const &)
+ {
+ m_xFrame.clear();
+ }
+ if(m_xFrame.is())
+ {
+ uno::Reference<frame::XDispatchProvider> xDP(m_xFrame, uno::UNO_QUERY);
+ util::URL aURL;
+ aURL.Complete = C2U(".component:DB/DataSourceBrowser");
+ uno::Reference<frame::XDispatch> xD = xDP->queryDispatch(aURL,
+ C2U(""),
+ 0x0C);
+ if(xD.is())
+ {
+ xD->dispatch(aURL, rValues);
+ m_pBeamerWIN->Show();
+ }
+/* uno::Reference<???::XController> xController = m_xFrame->getController();
+ pImpl->xFController = uno::Reference<???::XFormController>(xController, uno::UNO_QUERY);
+ if(pImpl->xFController.is())
+ {
+ uno::Reference< awt::XControl > xCtrl = pImpl->xFController->getCurrentControl( );
+ pImpl->xSelSupp = uno::Reference<???::XSelectionSupplier>(xCtrl, uno::UNO_QUERY);
+ if(pImpl->xSelSupp.is())
+ {
+ pImpl->xChgLstnr = new SwXSelChgLstnr_Impl(*this);
+ pImpl->xSelSupp->addSelectionChangeListener( pImpl->xChgLstnr );
+ }
+ }
+*/ }
+
+
+}
+/*-- 08.04.2004 15:12:24---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwDBTablePreviewDialog::~SwDBTablePreviewDialog()
+{
+ if(m_xFrame.is())
+ {
+ m_xFrame->setComponent(NULL, NULL);
+ m_xFrame->dispose();
+ }
+ else
+ delete m_pBeamerWIN;
+}
diff --git a/sw/source/ui/dbui/dbtablepreviewdialog.hrc b/sw/source/ui/dbui/dbtablepreviewdialog.hrc
new file mode 100644
index 000000000000..86719db70191
--- /dev/null
+++ b/sw/source/ui/dbui/dbtablepreviewdialog.hrc
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbtablepreviewdialog.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBTABLEPREVIEWDIALOG_HRC
+#define _DBTABLEPREVIEWDIALOG_HRC
+
+#define FI_DESCRIPTION 1
+#define WIN_BEAMER 2
+#define PB_OK 3
+
+#endif
+
diff --git a/sw/source/ui/dbui/dbtablepreviewdialog.hxx b/sw/source/ui/dbui/dbtablepreviewdialog.hxx
new file mode 100644
index 000000000000..8ded61d4aa74
--- /dev/null
+++ b/sw/source/ui/dbui/dbtablepreviewdialog.hxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbtablepreviewdialog.hxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBTABLEPREVIEWDIALOG_HXX
+#define _DBTABLEPREVIEWDIALOG_HXX
+
+#include <sfx2/basedlgs.hxx>
+#include <svtools/stdctrl.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <com/sun/star/uno/Sequence.h>
+
+namespace com{ namespace sun{ namespace star{
+ namespace beans{ struct PropertyValue; }
+ namespace frame{ class XFrame; }
+ }}}
+
+
+/*-- 08.04.2004 14:04:29---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwDBTablePreviewDialog : public SfxModalDialog
+{
+ FixedInfo m_aDescriptionFI;
+ Window* m_pBeamerWIN;
+ OKButton m_aOK;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
+public:
+ SwDBTablePreviewDialog(Window* pParent,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rValues );
+ ~SwDBTablePreviewDialog();
+
+};
+#endif
+
diff --git a/sw/source/ui/dbui/dbtablepreviewdialog.src b/sw/source/ui/dbui/dbtablepreviewdialog.src
new file mode 100644
index 000000000000..41df437a15cb
--- /dev/null
+++ b/sw/source/ui/dbui/dbtablepreviewdialog.src
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbtablepreviewdialog.src,v $
+ * $Revision: 1.6 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <dbtablepreviewdialog.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+ModalDialog DLG_MM_DBTABLEPREVIEWDIALOG
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_DBTABLEPREVIEWDIALOG;
+ Size = MAP_APPFONT ( 350 , 200 ) ;
+ Moveable = TRUE ;
+
+ Text [ en-US ] = "Mail Merge Recipients";
+
+ FixedText FI_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 338 , 8 ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "The list below shows the contents of: %1";
+ };
+ Window WIN_BEAMER
+ {
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 338 , 150 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 150 , 180 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ Text [ en-US ] = "~Close";
+ };
+};
+
diff --git a/sw/source/ui/dbui/dbtree.cxx b/sw/source/ui/dbui/dbtree.cxx
new file mode 100644
index 000000000000..e284096f8f8a
--- /dev/null
+++ b/sw/source/ui/dbui/dbtree.cxx
@@ -0,0 +1,625 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbtree.cxx,v $
+ * $Revision: 1.26 $
+ *
+ * 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"
+
+// INCLUDE ---------------------------------------------------------------
+
+
+#include <sot/formats.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/XDatabaseAccess.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <svx/dbaexchange.hxx>
+
+#ifndef _DBMGR_HXX
+#include <dbmgr.hxx>
+#endif
+#include <swmodule.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <wrtsh.hxx>
+#include <dbtree.hxx>
+#include <vos/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+#ifndef _HELPID_H
+#include <helpid.h>
+#endif
+#ifndef _UTLUI_HRC
+#include <utlui.hrc>
+#endif
+
+#include <unomid.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::beans;
+
+/* -----------------------------17.07.01 13:10--------------------------------
+
+ ---------------------------------------------------------------------------*/
+struct SwConnectionData
+{
+ ::rtl::OUString sSourceName;
+ Reference<XConnection> xConnection;
+};
+
+typedef SwConnectionData* SwConnectionDataPtr;
+SV_DECL_PTRARR_DEL( SwConnectionArr, SwConnectionDataPtr, 32, 32 )
+SV_IMPL_PTRARR( SwConnectionArr, SwConnectionDataPtr )
+/* -----------------------------17.07.01 13:24--------------------------------
+
+ ---------------------------------------------------------------------------*/
+class SwDBTreeList_Impl : public cppu::WeakImplHelper1 < XContainerListener >
+{
+ Reference< XNameAccess > xDBContext;
+ SwConnectionArr aConnections;
+ SwWrtShell* pWrtSh;
+
+ public:
+ SwDBTreeList_Impl(SwWrtShell* pShell) :
+ pWrtSh(pShell) {}
+ ~SwDBTreeList_Impl();
+
+ virtual void SAL_CALL elementInserted( const ContainerEvent& Event ) throw (RuntimeException);
+ virtual void SAL_CALL elementRemoved( const ContainerEvent& Event ) throw (RuntimeException);
+ virtual void SAL_CALL elementReplaced( const ContainerEvent& Event ) throw (RuntimeException);
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
+
+ BOOL HasContext();
+ SwWrtShell* GetWrtShell() { return pWrtSh;}
+ void SetWrtShell(SwWrtShell& rSh) { pWrtSh = &rSh;}
+ Reference< XNameAccess > GetContext() {return xDBContext;}
+ Reference<XConnection> GetConnection(const rtl::OUString& rSourceName);
+};
+/* -----------------------------17.07.01 13:24--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwDBTreeList_Impl::~SwDBTreeList_Impl()
+{
+ Reference<XContainer> xContainer(xDBContext, UNO_QUERY);
+ if(xContainer.is())
+ {
+ m_refCount++;
+ //block necessary due to solaris' compiler behaviour to
+ //remove temporaries at the block's end
+ {
+ xContainer->removeContainerListener( this );
+ }
+ m_refCount--;
+ }
+}
+/* -----------------------------17.07.01 13:24--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwDBTreeList_Impl::elementInserted( const ContainerEvent& ) throw (RuntimeException)
+{
+ // information not needed
+}
+/* -----------------------------17.07.01 13:24--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwDBTreeList_Impl::elementRemoved( const ContainerEvent& rEvent ) throw (RuntimeException)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+ ::rtl::OUString sSource;
+ rEvent.Accessor >>= sSource;
+ for(USHORT i = 0; i < aConnections.Count(); i++)
+ {
+ SwConnectionDataPtr pPtr = aConnections[i];
+ if(pPtr->sSourceName == sSource)
+ {
+// SwConnectionDataPtr pPtr = aConnections[i];
+// Reference<XComponent> xComp(pPtr->xConnection, UNO_QUERY);
+// if(xComp.is())
+// xComp->dispose();
+ aConnections.DeleteAndDestroy(i);
+ break;
+ }
+ }
+}
+/* -----------------------------17.07.01 13:24--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwDBTreeList_Impl::disposing( const EventObject& ) throw (RuntimeException)
+{
+ xDBContext = 0;
+}
+/* -----------------------------17.07.01 13:24--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwDBTreeList_Impl::elementReplaced( const ContainerEvent& rEvent ) throw (RuntimeException)
+{
+ elementRemoved(rEvent);
+}
+/* -----------------------------17.07.01 13:24--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL SwDBTreeList_Impl::HasContext()
+{
+ if(!xDBContext.is())
+ {
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ if( xMgr.is() )
+ {
+ Reference<XInterface> xInstance = xMgr->createInstance(
+ C2U( "com.sun.star.sdb.DatabaseContext" ));
+ xDBContext = Reference<XNameAccess>(xInstance, UNO_QUERY) ;
+ Reference<XContainer> xContainer(xDBContext, UNO_QUERY);
+ if(xContainer.is())
+ xContainer->addContainerListener( this );
+ }
+ DBG_ASSERT(xDBContext.is(), "com.sun.star.sdb.DataBaseContext: service not available");
+ }
+ return xDBContext.is();
+}
+/* -----------------------------17.07.01 13:24--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Reference<XConnection> SwDBTreeList_Impl::GetConnection(const rtl::OUString& rSourceName)
+{
+ Reference<XConnection> xRet;
+ for(USHORT i = 0; i < aConnections.Count(); i++)
+ {
+ SwConnectionDataPtr pPtr = aConnections[i];
+ if(pPtr->sSourceName == rSourceName)
+ {
+ xRet = pPtr->xConnection;
+ break;
+ }
+ }
+ if(!xRet.is() && xDBContext.is() && pWrtSh)
+ {
+ SwConnectionDataPtr pPtr = new SwConnectionData();
+ pPtr->sSourceName = rSourceName;
+ xRet = pWrtSh->GetNewDBMgr()->RegisterConnection(pPtr->sSourceName);
+ aConnections.Insert(pPtr, aConnections.Count());
+ }
+ return xRet;
+}
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+SwDBTreeList::SwDBTreeList(Window *pParent, const ResId& rResId,
+ SwWrtShell* pSh,
+ const String& rDefDBName, const BOOL bShowCol):
+
+ SvTreeListBox (pParent, rResId),
+ aImageList (SW_RES(ILIST_DB_DLG )),
+ aImageListHC (SW_RES(ILIST_DB_DLG_HC )),
+ sDefDBName (rDefDBName),
+ bInitialized (FALSE),
+ bShowColumns (bShowCol),
+ pImpl(new SwDBTreeList_Impl(pSh))
+{
+ SetHelpId(HID_DB_SELECTION_TLB);
+
+ if (IsVisible())
+ InitTreeList();
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+SwDBTreeList::~SwDBTreeList()
+{
+ delete pImpl;
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+
+
+void SwDBTreeList::InitTreeList()
+{
+ if(!pImpl->HasContext() && pImpl->GetWrtShell())
+ return;
+ SetSelectionMode(SINGLE_SELECTION);
+ SetWindowBits(WB_HASLINES|WB_CLIPCHILDREN|WB_SORT|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
+ // Font nicht setzen, damit der Font des Controls uebernommen wird!
+ SetSpaceBetweenEntries(0);
+ SetNodeBitmaps( aImageList.GetImage(IMG_COLLAPSE),
+ aImageList.GetImage(IMG_EXPAND ), BMP_COLOR_NORMAL );
+ SetNodeBitmaps( aImageListHC.GetImage(IMG_COLLAPSE),
+ aImageListHC.GetImage(IMG_EXPAND ), BMP_COLOR_HIGHCONTRAST );
+
+ SetDragDropMode(SV_DRAGDROP_APP_COPY);
+
+ GetModel()->SetCompareHdl(LINK(this, SwDBTreeList, DBCompare));
+
+ Sequence< ::rtl::OUString > aDBNames = pImpl->GetContext()->getElementNames();
+ const ::rtl::OUString* pDBNames = aDBNames.getConstArray();
+ long nCount = aDBNames.getLength();
+
+ Image aImg = aImageList.GetImage(IMG_DB);
+ Image aHCImg = aImageListHC.GetImage(IMG_DB);
+ for(long i = 0; i < nCount; i++)
+ {
+ String sDBName(pDBNames[i]);
+ SvLBoxEntry* pEntry = InsertEntry(sDBName, aImg, aImg, NULL, TRUE);
+ SetExpandedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
+ SetCollapsedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
+ }
+ String sDBName(sDefDBName.GetToken(0, DB_DELIM));
+ String sTableName(sDefDBName.GetToken(1, DB_DELIM));
+ String sColumnName(sDefDBName.GetToken(2, DB_DELIM));
+ Select(sDBName, sTableName, sColumnName);
+
+
+ bInitialized = TRUE;
+}
+/*-- 27.05.2004 09:19:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwDBTreeList::AddDataSource(const String& rSource)
+{
+ Image aImg = aImageList.GetImage(IMG_DB);
+ Image aHCImg = aImageListHC.GetImage(IMG_DB);
+ SvLBoxEntry* pEntry = InsertEntry(rSource, aImg, aImg, NULL, TRUE);
+ SetExpandedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
+ SetCollapsedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
+ SvTreeListBox::Select(pEntry);
+}
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+
+void SwDBTreeList::ShowColumns(BOOL bShowCol)
+{
+ if (bShowCol != bShowColumns)
+ {
+ bShowColumns = bShowCol;
+ String sTableName, sColumnName;
+ String sDBName(GetDBName(sTableName, sColumnName));
+
+ SetUpdateMode(FALSE);
+
+ SvLBoxEntry* pEntry = First();
+
+ while (pEntry)
+ {
+ pEntry = (SvLBoxEntry*)GetRootLevelParent( pEntry );
+ Collapse(pEntry); // zuklappen
+
+ SvLBoxEntry* pChild;
+ while ((pChild = FirstChild(pEntry)) != 0L)
+ GetModel()->Remove(pChild);
+
+ pEntry = Next(pEntry);
+ }
+
+ if (sDBName.Len())
+ {
+ Select(sDBName, sTableName, sColumnName); // force RequestingChilds
+ }
+ SetUpdateMode(TRUE);
+ }
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+
+void SwDBTreeList::RequestingChilds(SvLBoxEntry* pParent)
+{
+ if (!pParent->HasChilds())
+ {
+ if (GetParent(pParent)) // column names
+ {
+ try
+ {
+
+ String sSourceName = GetEntryText(GetParent(pParent));
+ String sTableName = GetEntryText(pParent);
+
+ if(!pImpl->GetContext()->hasByName(sSourceName))
+ return;
+ Reference<XConnection> xConnection = pImpl->GetConnection(sSourceName);
+ BOOL bTable = pParent->GetUserData() == 0;
+ Reference<XColumnsSupplier> xColsSupplier;
+ if(bTable)
+ {
+ Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ Reference<XNameAccess> xTbls = xTSupplier->getTables();
+ DBG_ASSERT(xTbls->hasByName(sTableName), "table not available anymore?");
+ try
+ {
+ Any aTable = xTbls->getByName(sTableName);
+ Reference<XPropertySet> xPropSet;
+ aTable >>= xPropSet;
+ xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
+ }
+ catch(Exception&)
+ {}
+ }
+ }
+ else
+ {
+ Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
+ if(xQSupplier.is())
+ {
+ Reference<XNameAccess> xQueries = xQSupplier->getQueries();
+ DBG_ASSERT(xQueries->hasByName(sTableName), "table not available anymore?");
+ try
+ {
+ Any aQuery = xQueries->getByName(sTableName);
+ Reference<XPropertySet> xPropSet;
+ aQuery >>= xPropSet;
+ xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
+ }
+ catch(Exception&)
+ {}
+ }
+ }
+
+ if(xColsSupplier.is())
+ {
+ Reference <XNameAccess> xCols = xColsSupplier->getColumns();
+ Sequence< ::rtl::OUString> aColNames = xCols->getElementNames();
+ const ::rtl::OUString* pColNames = aColNames.getConstArray();
+ long nCount = aColNames.getLength();
+ for (long i = 0; i < nCount; i++)
+ {
+ String sName = pColNames[i];
+ if(bTable)
+ InsertEntry(sName, pParent);
+ else
+ InsertEntry(sName, pParent);
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ else // Tabellennamen
+ {
+ try
+ {
+ String sSourceName = GetEntryText(pParent);
+ if(!pImpl->GetContext()->hasByName(sSourceName))
+ return;
+ Reference<XConnection> xConnection = pImpl->GetConnection(sSourceName);
+ if (xConnection.is())
+ {
+ Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ Reference<XNameAccess> xTbls = xTSupplier->getTables();
+ Sequence< ::rtl::OUString> aTblNames = xTbls->getElementNames();
+ String sTableName;
+ long nCount = aTblNames.getLength();
+ const ::rtl::OUString* pTblNames = aTblNames.getConstArray();
+ Image aImg = aImageList.GetImage(IMG_DBTABLE);
+ Image aHCImg = aImageListHC.GetImage(IMG_DBTABLE);
+ for (long i = 0; i < nCount; i++)
+ {
+ sTableName = pTblNames[i];
+ SvLBoxEntry* pTableEntry = InsertEntry(sTableName, aImg, aImg, pParent, bShowColumns);
+ //to discriminate between queries and tables the user data of table entries is set
+ pTableEntry->SetUserData((void*)0);
+ SetExpandedEntryBmp(pTableEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
+ SetCollapsedEntryBmp(pTableEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
+ }
+ }
+
+ Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
+ if(xQSupplier.is())
+ {
+ Reference<XNameAccess> xQueries = xQSupplier->getQueries();
+ Sequence< ::rtl::OUString> aQueryNames = xQueries->getElementNames();
+ String sQueryName;
+ long nCount = aQueryNames.getLength();
+ const ::rtl::OUString* pQueryNames = aQueryNames.getConstArray();
+ Image aImg = aImageList.GetImage(IMG_DBQUERY);
+ Image aHCImg = aImageListHC.GetImage(IMG_DBQUERY);
+ for (long i = 0; i < nCount; i++)
+ {
+ sQueryName = pQueryNames[i];
+ SvLBoxEntry* pQueryEntry = InsertEntry(sQueryName, aImg, aImg, pParent, bShowColumns);
+ pQueryEntry->SetUserData((void*)1);
+ SetExpandedEntryBmp(pQueryEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
+ SetCollapsedEntryBmp( pQueryEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
+ }
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ }
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+
+IMPL_LINK( SwDBTreeList, DBCompare, SvSortData*, pData )
+{
+ SvLBoxEntry* pRight = (SvLBoxEntry*)(pData->pRight );
+
+ if (GetParent(pRight) && GetParent(GetParent(pRight)))
+ return COMPARE_GREATER; // Spaltennamen nicht sortieren
+
+ return DefaultCompare(pData); // Sonst Basisklasse rufen
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+
+String SwDBTreeList::GetDBName(String& rTableName, String& rColumnName, BOOL* pbIsTable)
+{
+ String sDBName;
+ SvLBoxEntry* pEntry = FirstSelected();
+
+ if (pEntry && GetParent(pEntry))
+ {
+ if (GetParent(GetParent(pEntry)))
+ {
+ rColumnName = GetEntryText(pEntry);
+ pEntry = GetParent(pEntry); // Spaltenname war selektiert
+ }
+ sDBName = GetEntryText(GetParent(pEntry));
+ if(pbIsTable)
+ {
+ *pbIsTable = pEntry->GetUserData() == 0;
+ }
+ rTableName = GetEntryText(pEntry);
+ }
+ return sDBName;
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung: Format: Datenbank.Tabelle
+------------------------------------------------------------------------*/
+
+
+void SwDBTreeList::Select(const String& rDBName, const String& rTableName, const String& rColumnName)
+{
+ SvLBoxEntry* pParent;
+ SvLBoxEntry* pChild;
+ USHORT nParent = 0;
+ USHORT nChild = 0;
+
+ while ((pParent = GetEntry(nParent++)) != NULL)
+ {
+ if (rDBName == GetEntryText(pParent))
+ {
+ if (!pParent->HasChilds())
+ RequestingChilds(pParent);
+ while ((pChild = GetEntry(pParent, nChild++)) != NULL)
+ {
+ if (rTableName == GetEntryText(pChild))
+ {
+ pParent = pChild;
+
+ if (bShowColumns && rColumnName.Len())
+ {
+ nChild = 0;
+
+ if (!pParent->HasChilds())
+ RequestingChilds(pParent);
+
+ while ((pChild = GetEntry(pParent, nChild++)) != NULL)
+ if (rColumnName == GetEntryText(pChild))
+ break;
+ }
+ if (!pChild)
+ pChild = pParent;
+
+ MakeVisible(pChild);
+ SvTreeListBox::Select(pChild);
+ return;
+ }
+ }
+ }
+ }
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+
+void SwDBTreeList::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
+{
+ String sTableName, sColumnName;
+ String sDBName( GetDBName( sTableName, sColumnName ));
+ if( sDBName.Len() )
+ {
+ TransferDataContainer* pContainer = new TransferDataContainer;
+ STAR_REFERENCE( datatransfer::XTransferable ) xRef( pContainer );
+ if( sColumnName.Len() )
+ {
+ // Datenbankfeld draggen
+ svx::OColumnTransferable aColTransfer(
+ sDBName
+ ,::rtl::OUString()
+ , sdb::CommandType::TABLE
+ ,sTableName
+ , sColumnName
+ ,(CTF_FIELD_DESCRIPTOR |CTF_COLUMN_DESCRIPTOR ));
+ aColTransfer.addDataToContainer( pContainer );
+ }
+
+ sDBName += '.';
+ sDBName += sTableName;
+ if( sColumnName.Len() )
+ {
+ sDBName += '.';
+ sDBName += sColumnName;
+ }
+
+ pContainer->CopyString( FORMAT_STRING, sDBName );
+ pContainer->StartDrag( this, DND_ACTION_COPY | DND_ACTION_LINK,
+ Link() );
+ }
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+sal_Int8 SwDBTreeList::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
+{
+ return DND_ACTION_NONE;
+}
+/*-- 07.10.2003 13:28:22---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwDBTreeList::SetWrtShell(SwWrtShell& rSh)
+{
+ pImpl->SetWrtShell(rSh);
+ if (IsVisible() && !bInitialized)
+ InitTreeList();
+}
diff --git a/sw/source/ui/dbui/dbui.cxx b/sw/source/ui/dbui/dbui.cxx
new file mode 100644
index 000000000000..5590a46c1674
--- /dev/null
+++ b/sw/source/ui/dbui/dbui.cxx
@@ -0,0 +1,154 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbui.cxx,v $
+ * $Revision: 1.7.136.1 $
+ *
+ * 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"
+
+// INCLUDE ---------------------------------------------------------------
+
+
+#include <tools/list.hxx>
+#include "wrtsh.hxx"
+
+
+#include "dbui.hrc"
+#include "dbui.hxx"
+
+/*---------------------------------------------------------------------
+ Beschreibung:
+---------------------------------------------------------------------*/
+
+PrintMonitor::PrintMonitor( Window *pParent, PrintMonitorType eType )
+: ModelessDialog( pParent, SW_RES(DLG_PRINTMONITOR) ),
+ aDocName (this, SW_RES( FT_DOCNAME )),
+ aPrinting (this, SW_RES(
+ eType == MONITOR_TYPE_MAIL ?
+ FT_SENDING : eType == MONITOR_TYPE_SAVE ? FT_SAVING : FT_PRINTING )),
+ aPrinter (this, SW_RES( FT_PRINTER )),
+ aPrintInfo (this, SW_RES( FT_PRINTINFO )),
+ aCancel (this, SW_RES( PB_CANCELPRNMON ))
+{
+ switch (eType)
+ {
+ case MONITOR_TYPE_SAVE: SetText(SW_RES(STR_SAVEMON)); break;
+ case MONITOR_TYPE_MAIL: SetText(SW_RES(STR_EMAILMON)); break;
+ case MONITOR_TYPE_PRINT: break;
+ }
+ FreeResource();
+}
+/*---------------------------------------------------------------------
+
+---------------------------------------------------------------------*/
+void lcl_ResizeControl( Window* pWin, long nDiff )
+{
+ Size aSize( pWin->GetSizePixel() );
+ aSize.Width() += nDiff;
+ pWin->SetSizePixel( aSize );
+}
+void lcl_RePosControl( Window* pWin, long nDiff )
+{
+ Point aPos( pWin->GetPosPixel() );
+ aPos.X() += nDiff;
+ pWin->SetPosPixel( aPos );
+}
+
+void PrintMonitor::ResizeControls()
+{
+ Size aDlgSize( GetSizePixel() );
+ Size aPrinterSize( aPrinter.GetSizePixel() );
+ long nPrinterTextWidth = aPrinter.GetTextWidth( aPrinter.GetText() );
+ if( nPrinterTextWidth > aPrinterSize.Width() )
+ {
+ //increase control and dialog width if printer text is too long
+ //do not increase dialog width more than three times
+ long nDiff = nPrinterTextWidth - aPrinterSize.Width();
+ if( nDiff > 2 * aDlgSize.Width() )
+ {
+ aPrinter.SetStyle( WB_RIGHT | aPrinter.GetStyle() );
+ nDiff = 2 * aDlgSize.Width();
+ }
+ aDlgSize.Width() += nDiff;
+ SetSizePixel(aDlgSize);
+ lcl_ResizeControl( &aPrinter, nDiff );
+
+ nDiff /= 2;
+ lcl_RePosControl( &aDocName, nDiff );
+ lcl_RePosControl( &aPrinting, nDiff );
+ lcl_RePosControl( &aPrintInfo, nDiff );
+ lcl_RePosControl( &aCancel, nDiff );
+ }
+}
+/*---------------------------------------------------------------------
+ Progress Indicator for Creation of personalized Mail Merge documents:
+---------------------------------------------------------------------*/
+
+CreateMonitor::CreateMonitor( Window *pParent )
+: ModelessDialog( pParent, SW_RES(DLG_MM_CREATIONMONITOR) ),
+ m_aStatus (this, SW_RES( FT_STATUS )),
+ m_aProgress (this, SW_RES( FT_PROGRESS )),
+ m_aCreateDocuments (this, SW_RES( FT_CREATEDOCUMENTS )),
+ m_aCounting (this, SW_RES( FT_COUNTING )),
+ m_aCancelButton (this, SW_RES( PB_CANCELPRNMON )),
+ m_sCountingPattern(),
+ m_sVariable_Total( String::CreateFromAscii("%Y") ),
+ m_sVariable_Position( String::CreateFromAscii("%X") ),
+ m_nTotalCount(0),
+ m_nCurrentPosition(0)
+{
+ FreeResource();
+
+ m_sCountingPattern = m_aCounting.GetText();
+ m_aCounting.SetText(String::CreateFromAscii("..."));
+}
+
+void CreateMonitor::UpdateCountingText()
+{
+ String sText(m_sCountingPattern);
+ sText.SearchAndReplaceAll( m_sVariable_Total, String::CreateFromInt32( m_nTotalCount ) );
+ sText.SearchAndReplaceAll( m_sVariable_Position, String::CreateFromInt32( m_nCurrentPosition ) );
+ m_aCounting.SetText(sText);
+}
+
+void CreateMonitor::SetTotalCount( sal_Int32 nTotal )
+{
+ m_nTotalCount = nTotal;
+ UpdateCountingText();
+}
+
+void CreateMonitor::SetCurrentPosition( sal_Int32 nCurrent )
+{
+ m_nCurrentPosition = nCurrent;
+ UpdateCountingText();
+}
+
+void CreateMonitor::SetCancelHdl( const Link& rLink )
+{
+ m_aCancelButton.SetClickHdl( rLink );
+}
diff --git a/sw/source/ui/dbui/dbui.src b/sw/source/ui/dbui/dbui.src
new file mode 100644
index 000000000000..cf6929437b3f
--- /dev/null
+++ b/sw/source/ui/dbui/dbui.src
@@ -0,0 +1,286 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbui.src,v $
+ * $Revision: 1.34.66.2 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // #pragma ******************************************************************
+
+ // #include *****************************************************************
+#include "dbui.hrc"
+#include "helpid.h"
+ModalDialog DLG_DBSELECTION
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 168 , 132 ) ;
+ Moveable = TRUE ;
+ Control TLB_DBLIST
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 100 , 120 ) ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 112 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Disable = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 112 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 112 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Database Selection" ;
+};
+ // DLG_PRINTMONITOR ------------------------------------------------------
+ModelessDialog DLG_PRINTMONITOR
+{
+ HelpID = HID_MERGE_PRINTMONITOR ;
+ SVLOOK = TRUE ;
+ HIDE = TRUE ;
+ OUTPUTSIZE = TRUE ;
+ Size = MAP_APPFONT ( 118, 72 ) ;
+ MOVEABLE = TRUE ;
+ APP = FALSE ;
+ FixedText FT_DOCNAME
+ {
+ Pos = MAP_APPFONT ( 6,6 ) ;
+ Size = MAP_APPFONT ( 100, 8 ) ;
+ CENTER = TRUE ;
+ };
+ FixedText FT_PRINTING
+ {
+ Pos = MAP_APPFONT ( 6, 17 ) ;
+ Size = MAP_APPFONT ( 100, 8 ) ;
+ CENTER = TRUE ;
+ Text [ en-US ] = "is being printed on" ;
+ };
+ FixedText FT_SENDING
+ {
+ Pos = MAP_APPFONT ( 6, 17 ) ;
+ Size = MAP_APPFONT ( 100, 8 ) ;
+ CENTER = TRUE ;
+ Text [ en-US ] = "is being sent to";
+ };
+ FixedText FT_SAVING
+ {
+ Pos = MAP_APPFONT ( 6, 17 ) ;
+ Size = MAP_APPFONT ( 100, 8 ) ;
+ CENTER = TRUE ;
+ Text [ en-US ] = "is being saved to" ;
+ };
+ FixedText FT_PRINTER
+ {
+ Pos = MAP_APPFONT ( 6, 28 ) ;
+ Size = MAP_APPFONT ( 100, 8 ) ;
+ CENTER = TRUE ;
+ };
+ FixedText FT_PRINTINFO
+ {
+ Pos = MAP_APPFONT ( 6, 39 ) ;
+ Size = MAP_APPFONT ( 100, 8 ) ;
+ CENTER = TRUE ;
+ };
+ CancelButton PB_CANCELPRNMON
+ {
+ Pos = MAP_APPFONT ( 31, 52 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ TABSTOP = TRUE ;
+ };
+ String STR_EMAILMON
+ {
+ Text [ en-US ] = "Send-Monitor";
+ };
+ String STR_SAVEMON
+ {
+ Text [ en-US ] = "Save-Monitor";
+ };
+ Text [ en-US ] = "Print monitor" ;
+};
+
+String STR_DB_EMAIL
+{
+ Text [ en-US ] = "E-mail" ;
+};
+
+StringArray SA_ADDRESS_HEADER
+{
+ ItemList [en-US]=
+ {
+ < "Title" ; MM_PART_TITLE ;> ;
+ < "First Name" ; MM_PART_FIRSTNAME ;> ;
+ < "Last Name" ; MM_PART_LASTNAME ;> ;
+ < "Company Name" ; MM_PART_COMPANY ;> ;
+ < "Address Line 1" ; MM_PART_ADDRESS_1 ;> ;
+ < "Address Line 2" ; MM_PART_ADDRESS_2 ;> ;
+ < "City" ; MM_PART_CITY ;> ;
+ < "State" ; MM_PART_REGION ;> ;
+ < "ZIP" ; MM_PART_ZIP ;> ;
+ < "Country" ; MM_PART_COUNTRY ;> ;
+ < "Telephone private" ; MM_PART_PHONE_PRIVATE ;> ;
+ < "Telephone business" ; MM_PART_PHONE_BUSINESS ;> ;
+ < "E-mail Address" ; MM_PART_E_MAIL ;> ;
+ < "Gender"; MM_PART_GENDER ;> ;
+ };
+};
+String STR_NOTASSIGNED
+{
+ Text[ en-US ] = " not yet matched ";
+};
+String STR_FILTER_ALL
+{
+ Text [ en-US ] = "All files (*.*)" ;
+};
+String STR_FILTER_ALL_DATA
+{
+ Text [ en-US ] = "Address lists(*.*)" ;
+};
+String STR_FILTER_SXB
+{
+ Text [ en-US ] = "%PRODUCTNAME Base (*.odb)" ;
+};
+String STR_FILTER_SXC
+{
+ Text [ en-US ] = "%PRODUCTNAME Calc (*.ods;*.sxc)" ;
+};
+String STR_FILTER_DBF
+{
+ Text [ en-US ] = "dBase (*.dbf)" ;
+};
+String STR_FILTER_XLS
+{
+ Text [ en-US ] = "Microsoft Excel (*.xls)" ;
+};
+String STR_FILTER_TXT
+{
+ Text [ en-US ] = "Plain text (*.txt)" ;
+};
+String STR_FILTER_CSV
+{
+ Text [ en-US ] = "Text Comma Separated (*.csv)" ;
+};
+String STR_FILTER_MDB
+{
+ Text [ en-US ] = "Microsoft Access (*.mdb)" ;
+};
+String STR_FILTER_ACCDB
+{
+ Text [ en-US ] = "Microsoft Access 2007 (*.accdb)" ;
+};
+
+ // DLG_MM_CREATIONMONITOR ------------------------------------------------------
+ModelessDialog DLG_MM_CREATIONMONITOR
+{
+ HelpID = HID_MERGE_PRINTMONITOR ;
+ SVLOOK = TRUE ;
+ HIDE = TRUE ;
+ OUTPUTSIZE = TRUE ;
+ _WHMAPMODE = MAP_APPFONT ;
+ _WIDTH = 140 ;
+ _HEIGHT = 52 ;
+ MOVEABLE = TRUE ;
+ APP = FALSE ;
+
+ Text [ en-US ] = "Mail Merge" ;
+
+ FixedText FT_STATUS
+ {
+ HIDE = FALSE ;
+ _XYMAPMODE = MAP_APPFONT ;
+ _X = 6 ;
+ _Y = 6 ;
+ _WHMAPMODE = MAP_APPFONT ;
+ _WIDTH = 35 ;
+ _HEIGHT = 8 ;
+ Text [ en-US ] = "Status:" ;
+ LEFT = FALSE ;
+ CENTER = FALSE ;
+ RIGHT = TRUE ;
+ };
+ FixedText FT_PROGRESS
+ {
+ HIDE = FALSE ;
+ _XYMAPMODE = MAP_APPFONT ;
+ _X = 6 ;
+ _Y = 17 ;
+ _WHMAPMODE = MAP_APPFONT ;
+ _WIDTH = 35 ;
+ _HEIGHT = 8 ;
+ Text [ en-US ] = "Progress:" ;
+ LEFT = FALSE ;
+ CENTER = FALSE ;
+ RIGHT = TRUE ;
+ };
+ FixedText FT_CREATEDOCUMENTS
+ {
+ HIDE = FALSE ;
+ _XYMAPMODE = MAP_APPFONT ;
+ _X = 45 ;
+ _Y = 6 ;
+ _WHMAPMODE = MAP_APPFONT ;
+ _WIDTH = 91 ;
+ _HEIGHT = 8 ;
+ Text [ en-US ] = "Creating documents...";
+ LEFT = TRUE ;
+ CENTER = FALSE ;
+ RIGHT = FALSE ;
+ };
+ FixedText FT_COUNTING
+ {
+ HIDE = FALSE ;
+ _XYMAPMODE = MAP_APPFONT ;
+ _X = 45 ;
+ _Y = 17 ;
+ _WHMAPMODE = MAP_APPFONT ;
+ _WIDTH = 91 ;
+ _HEIGHT = 8 ;
+ Text [ en-US ] = "%X of %Y";
+ LEFT = TRUE ;
+ CENTER = FALSE ;
+ RIGHT = FALSE ;
+ };
+ CancelButton PB_CANCELPRNMON
+ {
+ HIDE = FALSE ;
+ _XYMAPMODE = MAP_APPFONT ;
+ _X = 74 ;
+ _Y = 32 ;
+ _WHMAPMODE = MAP_APPFONT ;
+ _WIDTH = 50 ;
+ _HEIGHT = 14 ;
+ TABSTOP = TRUE ;
+ };
+};
diff --git a/sw/source/ui/dbui/maildispatcher.cxx b/sw/source/ui/dbui/maildispatcher.cxx
new file mode 100644
index 000000000000..e49c5c68fccb
--- /dev/null
+++ b/sw/source/ui/dbui/maildispatcher.cxx
@@ -0,0 +1,308 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: maildispatcher.cxx,v $
+ * $Revision: 1.6 $
+ *
+ * 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"
+#include "maildispatcher.hxx"
+#include "imaildsplistener.hxx"
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using ::rtl::OUString;
+
+typedef std::list< uno::Reference<mail::XMailMessage> > MailMessageContainer_t;
+typedef std::list< ::rtl::Reference<IMailDispatcherListener> > MailDispatcherListenerContainer_t;
+
+namespace /* private */
+{
+ /* Generic event notifier for started,
+ stopped, and idle events which are
+ very similary */
+ class GenericEventNotifier
+ {
+ public:
+ // pointer to virtual function typedef
+ typedef void (IMailDispatcherListener::*GenericNotificationFunc_t)(::rtl::Reference<MailDispatcher>);
+
+ GenericEventNotifier(
+ GenericNotificationFunc_t notification_function,
+ ::rtl::Reference<MailDispatcher> mail_dispatcher) :
+ notification_function_(notification_function),
+ mail_dispatcher_(mail_dispatcher)
+ {}
+
+ void operator() (::rtl::Reference<IMailDispatcherListener> listener) const
+ { (listener.get()->*notification_function_)(mail_dispatcher_); }
+
+ private:
+ GenericNotificationFunc_t notification_function_;
+ ::rtl::Reference<MailDispatcher> mail_dispatcher_;
+ };
+
+ class MailDeliveryNotifier
+ {
+ public:
+ MailDeliveryNotifier(::rtl::Reference<MailDispatcher> xMailDispatcher, uno::Reference<mail::XMailMessage> message) :
+ mail_dispatcher_(xMailDispatcher),
+ message_(message)
+ {}
+
+ void operator() (::rtl::Reference<IMailDispatcherListener> listener) const
+ { listener->mailDelivered(mail_dispatcher_, message_); }
+
+ private:
+ ::rtl::Reference<MailDispatcher> mail_dispatcher_;
+ uno::Reference<mail::XMailMessage> message_;
+ };
+
+ class MailDeliveryErrorNotifier
+ {
+ public:
+ MailDeliveryErrorNotifier(
+ ::rtl::Reference<MailDispatcher> xMailDispatcher,
+ uno::Reference<mail::XMailMessage> message,
+ const ::rtl::OUString& error_message) :
+ mail_dispatcher_(xMailDispatcher),
+ message_(message),
+ error_message_(error_message)
+ {}
+
+ void operator() (::rtl::Reference<IMailDispatcherListener> listener) const
+ { listener->mailDeliveryError(mail_dispatcher_, message_, error_message_); }
+
+ private:
+ ::rtl::Reference<MailDispatcher> mail_dispatcher_;
+ uno::Reference<mail::XMailMessage> message_;
+ ::rtl::OUString error_message_;
+ };
+
+} // namespace private
+
+
+MailDispatcher::MailDispatcher(uno::Reference<mail::XSmtpService> mailserver) :
+ mailserver_ (mailserver),
+ run_(false),
+ shutdown_requested_(false),
+ bIsInRun(false)
+{
+ wakening_call_.reset();
+ mail_dispatcher_active_.reset();
+
+ if (!create())
+ throw uno::RuntimeException();
+
+ // wait until the mail dispatcher thread is really alive
+ // and has aquired a reference to this instance of the
+ // class
+ mail_dispatcher_active_.wait();
+}
+
+MailDispatcher::~MailDispatcher()
+{
+}
+
+void MailDispatcher::enqueueMailMessage(uno::Reference<mail::XMailMessage> message)
+{
+ ::osl::MutexGuard thread_status_guard(thread_status_mutex_);
+ ::osl::MutexGuard message_container_guard(message_container_mutex_);
+
+ OSL_PRECOND(!shutdown_requested_, "MailDispatcher thread is shuting down already");
+
+ messages_.push_back(message);
+ if (run_)
+ wakening_call_.set();
+}
+
+uno::Reference<mail::XMailMessage> MailDispatcher::dequeueMailMessage()
+{
+ ::osl::MutexGuard guard(message_container_mutex_);
+ uno::Reference<mail::XMailMessage> message;
+ if(!messages_.empty())
+ {
+ message = messages_.front();
+ messages_.pop_front();
+ }
+ return message;
+}
+
+void MailDispatcher::start()
+{
+ OSL_PRECOND(!isStarted(), "MailDispatcher is already started!");
+
+ ::osl::ClearableMutexGuard thread_status_guard(thread_status_mutex_);
+
+ OSL_PRECOND(!shutdown_requested_, "MailDispatcher thread is shuting down already");
+
+ if (!shutdown_requested_)
+ {
+ run_ = true;
+ wakening_call_.set();
+ thread_status_guard.clear();
+
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), GenericEventNotifier(&IMailDispatcherListener::started, this));
+ }
+}
+
+void MailDispatcher::stop()
+{
+ OSL_PRECOND(isStarted(), "MailDispatcher not started!");
+
+ ::osl::ClearableMutexGuard thread_status_guard(thread_status_mutex_);
+
+ OSL_PRECOND(!shutdown_requested_, "MailDispatcher thread is shuting down already");
+
+ if (!shutdown_requested_)
+ {
+ run_ = false;
+ wakening_call_.reset();
+ thread_status_guard.clear();
+
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), GenericEventNotifier(&IMailDispatcherListener::stopped, this));
+ }
+}
+
+void MailDispatcher::shutdown()
+{
+ ::osl::MutexGuard thread_status_guard(thread_status_mutex_);
+
+ OSL_PRECOND(!shutdown_requested_, "MailDispatcher thread is shuting down already");
+
+ shutdown_requested_ = true;
+ wakening_call_.set();
+}
+
+bool MailDispatcher::isStarted() const
+{
+ return run_;
+}
+
+bool MailDispatcher::isRunning() const
+{
+ return bIsInRun;
+}
+
+
+void MailDispatcher::addListener(::rtl::Reference<IMailDispatcherListener> listener)
+{
+ OSL_PRECOND(!shutdown_requested_, "MailDispatcher thread is shuting down already");
+
+ ::osl::MutexGuard guard(listener_container_mutex_);
+ listeners_.push_back(listener);
+}
+
+void MailDispatcher::removeListener(::rtl::Reference<IMailDispatcherListener> listener)
+{
+ OSL_PRECOND(!shutdown_requested_, "MailDispatcher thread is shuting down already");
+
+ ::osl::MutexGuard guard(listener_container_mutex_);
+ listeners_.remove(listener);
+}
+
+std::list< ::rtl::Reference<IMailDispatcherListener> > MailDispatcher::cloneListener()
+{
+ ::osl::MutexGuard guard(listener_container_mutex_);
+ return listeners_;
+}
+
+void MailDispatcher::sendMailMessageNotifyListener(uno::Reference<mail::XMailMessage> message)
+{
+ try
+ {
+ mailserver_->sendMailMessage(message);
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), MailDeliveryNotifier(this, message));
+ }
+ catch (mail::MailException& ex)
+ {
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), MailDeliveryErrorNotifier(this, message, ex.Message));
+ }
+ catch (uno::RuntimeException& ex)
+ {
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), MailDeliveryErrorNotifier(this, message, ex.Message));
+ }
+}
+
+void MailDispatcher::run()
+{
+ // aquire a self reference in order to avoid race
+ // conditions. The last client of this class must
+ // call shutdown before releasing his last reference
+ // to this class in order to shutdown this thread
+ // which will release his (the very last reference
+ // to the class and so force their destruction
+ m_xSelfReference = this;
+
+ // signal that the mail dispatcher thread is now alive
+ mail_dispatcher_active_.set();
+
+ bIsInRun = true;
+ for(;;)
+ {
+ wakening_call_.wait();
+
+ ::osl::ClearableMutexGuard thread_status_guard(thread_status_mutex_);
+ if (shutdown_requested_)
+ break;
+
+ ::osl::ClearableMutexGuard message_container_guard(message_container_mutex_);
+
+ if (messages_.size())
+ {
+ thread_status_guard.clear();
+ uno::Reference<mail::XMailMessage> message = messages_.front();
+ messages_.pop_front();
+ message_container_guard.clear();
+ sendMailMessageNotifyListener(message);
+ }
+ else // idle - put ourself to sleep
+ {
+ wakening_call_.reset();
+ message_container_guard.clear();
+ thread_status_guard.clear();
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), GenericEventNotifier(&IMailDispatcherListener::idle, this));
+ }
+ } // end for SSH ALI
+ bIsInRun = false;
+}
+/*-- 27.08.2004 12:04:46---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void MailDispatcher::onTerminated()
+{
+ //keep the reference until the end of onTerminated() because of the call order in the
+ //_threadFunc() from osl/thread.hxx
+ m_xSelfReference = 0;
+}
diff --git a/sw/source/ui/dbui/mailmergechildwindow.cxx b/sw/source/ui/dbui/mailmergechildwindow.cxx
new file mode 100644
index 000000000000..d70dea638297
--- /dev/null
+++ b/sw/source/ui/dbui/mailmergechildwindow.cxx
@@ -0,0 +1,799 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mailmergechildwindow.cxx,v $
+ * $Revision: 1.14 $
+ *
+ * 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"
+
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <cmdid.h>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <edtwin.hxx>
+#include <vcl/svapp.hxx>
+#include <mailmergechildwindow.hxx>
+#include <mmoutputpage.hxx>
+#include <mmconfigitem.hxx>
+#include <comphelper/processfactory.hxx>
+#include "com/sun/star/mail/XSmtpService.hpp"
+#include "com/sun/star/mail/MailServiceType.hpp"
+#include <rtl/ref.hxx>
+#include <maildispatcher.hxx>
+#include <imaildsplistener.hxx>
+#include <swunohelper.hxx>
+#include <svtools/svmedit.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/image.hxx>
+#include <mailmergechildwindow.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+using namespace ::com::sun::star;
+
+SFX_IMPL_FLOATINGWINDOW( SwMailMergeChildWindow, FN_MAILMERGE_CHILDWINDOW )
+//SFX_IMPL_FLOATINGWINDOW( SwSendMailChildWindow, FN_MAILMERGE_SENDMAIL_CHILDWINDOW )
+
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+
+SwMailMergeChildWindow::SwMailMergeChildWindow( Window* _pParent,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( _pParent, nId )
+{
+ pWindow = new SwMailMergeChildWin( pBindings, this, _pParent);
+
+ if (!pInfo->aSize.Width() || !pInfo->aSize.Height())
+ {
+ SwView* pActiveView = ::GetActiveView();
+ if(pActiveView)
+ {
+ const SwEditWin &rEditWin = pActiveView->GetEditWin();
+ pWindow->SetPosPixel(rEditWin.OutputToScreenPixel(Point(0, 0)));
+ }
+ else
+ pWindow->SetPosPixel(_pParent->OutputToScreenPixel(Point(0, 0)));
+ pInfo->aPos = pWindow->GetPosPixel();
+ pInfo->aSize = pWindow->GetSizePixel();
+ }
+
+ ((SwMailMergeChildWin *)pWindow)->Initialize(pInfo);
+ pWindow->Show();
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+
+SwMailMergeChildWin::SwMailMergeChildWin( SfxBindings* _pBindings,
+ SfxChildWindow* pChild,
+ Window *pParent) :
+ SfxFloatingWindow(_pBindings, pChild, pParent, SW_RES(DLG_MAILMERGECHILD)),
+ m_aBackTB(this, SW_RES( TB_BACK ))
+{
+ m_aBackTB.SetSelectHdl(LINK(this, SwMailMergeChildWin, BackHdl));
+ sal_uInt16 nIResId = GetSettings().GetStyleSettings().GetHighContrastMode() ?
+ ILIST_TBX_HC : ILIST_TBX;
+ ResId aResId( nIResId, *pSwResMgr );
+ ImageList aIList(aResId);
+ FreeResource();
+
+ m_aBackTB.SetItemImage( 1, aIList.GetImage(FN_SHOW_ROOT) );
+ m_aBackTB.SetButtonType( BUTTON_SYMBOLTEXT );
+ Size aSz = m_aBackTB.CalcWindowSizePixel(1);
+ m_aBackTB.SetPosSizePixel( Point(), aSz );
+ SetOutputSizePixel(aSz);
+ m_aBackTB.Show();
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung:
+------------------------------------------------------------------------*/
+
+SwMailMergeChildWin::~SwMailMergeChildWin()
+{
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SwMailMergeChildWin, BackHdl, ToolBox *, EMPTYARG )
+{
+ GetBindings().GetDispatcher()->Execute(FN_MAILMERGE_WIZARD, SFX_CALLMODE_ASYNCHRON);
+ return 0;
+}
+
+/*-- 26.05.2004 10:12:44---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeChildWin::FillInfo(SfxChildWinInfo& rInfo) const
+{
+ SfxFloatingWindow::FillInfo(rInfo);
+ rInfo.aWinState.Erase();
+ rInfo.bVisible = sal_False;
+}
+/*-- 21.05.2004 14:07:37---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+struct SwSendMailDialog_Impl
+{
+ friend class SwSendMailDialog;
+ ::osl::Mutex aDescriptorMutex;
+
+ ::std::vector< SwMailDescriptor > aDescriptors;
+ sal_uInt32 nCurrentDescriptor;
+ sal_uInt32 nDocumentCount;
+ ::rtl::Reference< MailDispatcher > xMailDispatcher;
+ ::rtl::Reference< IMailDispatcherListener> xMailListener;
+ uno::Reference< mail::XMailService > xConnectedMailService;
+ uno::Reference< mail::XMailService > xConnectedInMailService;
+ Timer aRemoveTimer;
+
+
+ SwSendMailDialog_Impl() :
+ nCurrentDescriptor(0),
+ nDocumentCount(0)
+ {
+ aRemoveTimer.SetTimeout(500);
+ }
+
+ ~SwSendMailDialog_Impl()
+ {
+ // Shutdown must be called when the last reference to the
+ // mail dispatcher will be released in order to force a
+ // shutdown of the mail dispatcher thread.
+ // 'join' with the mail dispatcher thread leads to a
+ // deadlock (SolarMutex).
+ if( xMailDispatcher.is() && !xMailDispatcher->isShutdownRequested() )
+ xMailDispatcher->shutdown();
+ }
+ const SwMailDescriptor* GetNextDescriptor();
+};
+
+const SwMailDescriptor* SwSendMailDialog_Impl::GetNextDescriptor()
+{
+ ::osl::MutexGuard aGuard(aDescriptorMutex);
+ if(nCurrentDescriptor < aDescriptors.size())
+ {
+ ++nCurrentDescriptor;
+ return &aDescriptors[nCurrentDescriptor - 1];
+ }
+ return 0;
+}
+
+/*-- 23.06.2004 10:19:55---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwMailDispatcherListener_Impl : public IMailDispatcherListener
+{
+ SwSendMailDialog* m_pSendMailDialog;
+
+public:
+ SwMailDispatcherListener_Impl(SwSendMailDialog& rParentDlg);
+ ~SwMailDispatcherListener_Impl();
+
+ virtual void started(::rtl::Reference<MailDispatcher> xMailDispatcher);
+ virtual void stopped(::rtl::Reference<MailDispatcher> xMailDispatcher);
+ virtual void idle(::rtl::Reference<MailDispatcher> xMailDispatcher);
+ virtual void mailDelivered(::rtl::Reference<MailDispatcher> xMailDispatcher,
+ uno::Reference< mail::XMailMessage> xMailMessage);
+ virtual void mailDeliveryError(::rtl::Reference<MailDispatcher> xMailDispatcher,
+ uno::Reference< mail::XMailMessage> xMailMessage, const rtl::OUString& sErrorMessage);
+
+ static void DeleteAttachments( uno::Reference< mail::XMailMessage >& xMessage );
+};
+
+/*-- 23.06.2004 10:04:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailDispatcherListener_Impl::SwMailDispatcherListener_Impl(SwSendMailDialog& rParentDlg) :
+ m_pSendMailDialog(&rParentDlg)
+{
+}
+/*-- 23.06.2004 10:04:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailDispatcherListener_Impl::~SwMailDispatcherListener_Impl()
+{
+}
+/*-- 23.06.2004 10:04:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailDispatcherListener_Impl::started(::rtl::Reference<MailDispatcher> /*xMailDispatcher*/)
+{
+}
+/*-- 23.06.2004 10:04:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailDispatcherListener_Impl::stopped(
+ ::rtl::Reference<MailDispatcher> /*xMailDispatcher*/)
+{
+}
+/*-- 23.06.2004 10:04:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailDispatcherListener_Impl::idle(::rtl::Reference<MailDispatcher> /*xMailDispatcher*/)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+ m_pSendMailDialog->AllMailsSent();
+}
+/*-- 23.06.2004 10:04:50---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailDispatcherListener_Impl::mailDelivered(
+ ::rtl::Reference<MailDispatcher> /*xMailDispatcher*/,
+ uno::Reference< mail::XMailMessage> xMailMessage)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+ m_pSendMailDialog->DocumentSent( xMailMessage, true, 0 );
+ DeleteAttachments( xMailMessage );
+}
+/*-- 23.06.2004 10:04:51---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailDispatcherListener_Impl::mailDeliveryError(
+ ::rtl::Reference<MailDispatcher> /*xMailDispatcher*/,
+ uno::Reference< mail::XMailMessage> xMailMessage,
+ const rtl::OUString& sErrorMessage)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+ m_pSendMailDialog->DocumentSent( xMailMessage, false, &sErrorMessage );
+ DeleteAttachments( xMailMessage );
+}
+/*-- 23.06.2004 12:30:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailDispatcherListener_Impl::DeleteAttachments( uno::Reference< mail::XMailMessage >& xMessage )
+{
+ uno::Sequence< mail::MailAttachment > aAttachments = xMessage->getAttachments();
+
+ for(sal_Int32 nFile = 0; nFile < aAttachments.getLength(); ++nFile)
+ {
+ try
+ {
+ uno::Reference< beans::XPropertySet > xTransferableProperties( aAttachments[nFile].Data, uno::UNO_QUERY_THROW);
+ if( xTransferableProperties.is() )
+ {
+ ::rtl::OUString sURL;
+ xTransferableProperties->getPropertyValue( ::rtl::OUString::createFromAscii("URL") ) >>= sURL;
+ if(sURL.getLength())
+ SWUnoHelper::UCB_DeleteFile( sURL );
+ }
+ }
+ catch( const uno::Exception& rEx )
+ {
+ (void)rEx;
+ }
+ }
+}
+/*-- 07.07.2004 13:45:51---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwSendWarningBox_Impl : public ModalDialog
+{
+ FixedImage aWarningImageIM;
+ FixedInfo aWarningFI;
+ FixedText aDetailFT;
+ MultiLineEdit aDetailED;
+ FixedLine aSeparatorFL;
+ OKButton aOKPB;
+
+public:
+ SwSendWarningBox_Impl(Window* pParent, const String& rDetails);
+ ~SwSendWarningBox_Impl();
+};
+/*-- 07.07.2004 13:52:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwSendWarningBox_Impl::SwSendWarningBox_Impl(Window* pParent, const String& rDetails) :
+ ModalDialog(pParent, SW_RES( DLG_MM_SENDWARNING )),
+ aWarningImageIM(this, SW_RES( IM_WARNING )),
+ aWarningFI( this, SW_RES( FI_WARNING )),
+ aDetailFT( this, SW_RES( FT_DETAILS )),
+ aDetailED( this, SW_RES( ED_DETAILS )),
+ aSeparatorFL( this, SW_RES( FL_SEPARATOR )),
+ aOKPB( this, SW_RES(PB_OK))
+{
+ FreeResource();
+ aWarningImageIM.SetImage(WarningBox::GetStandardImage());
+ aDetailED.SetText(rDetails);
+}
+/*-- 07.07.2004 13:52:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwSendWarningBox_Impl::~SwSendWarningBox_Impl()
+{
+}
+
+/*-- 21.05.2004 14:10:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+#define ITEMID_TASK 1
+#define ITEMID_STATUS 2
+
+SwSendMailDialog::SwSendMailDialog(Window *pParent, SwMailMergeConfigItem& rConfigItem) :
+ ModelessDialog /*SfxModalDialog*/(pParent, SW_RES(DLG_MM_SENDMAILS)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aStatusFL( this, SW_RES( FL_STATUS )),
+ m_aStatusFT( this, SW_RES( FT_STATUS1 )),
+ m_aTransferStatusFL( this, SW_RES( FL_TRANSFERSTATUS )),
+ m_aTransferStatusFT( this, SW_RES( FT_TRANSFERSTATUS )),
+ m_PausedFI(this, SW_RES( FI_PAUSED )),
+ m_aProgressBar( this, SW_RES( PB_PROGRESS )),
+ m_aErrorStatusFT( this, SW_RES( FT_ERRORSTATUS )),
+ m_aDetailsPB( this, SW_RES( PB_DETAILS )),
+ m_aStatusHB( this, WB_BUTTONSTYLE | WB_BOTTOMBORDER ),
+ m_aStatusLB( this, SW_RES( LB_STATUS )),
+ m_aSeparatorFL( this, SW_RES( FL_SEPARATOR )),
+ m_aStopPB( this, SW_RES( PB_STOP )),
+ m_aClosePB( this, SW_RES( PB_CLOSE )),
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+ m_sMore(m_aDetailsPB.GetText()),
+ m_sLess(SW_RES(ST_LESS)),
+ m_sContinue(SW_RES( ST_CONTINUE )),
+ m_sStop(m_aStopPB.GetText()),
+ m_sSend(SW_RES(ST_SEND)),
+ m_sTransferStatus(m_aTransferStatusFT.GetText()),
+ m_sErrorStatus( m_aErrorStatusFT.GetText()),
+ m_sSendingTo( SW_RES(ST_SENDINGTO )),
+ m_sCompleted( SW_RES(ST_COMPLETED )),
+ m_sFailed( SW_RES(ST_FAILED )),
+ m_sTerminateQuery( SW_RES( ST_TERMINATEQUERY )),
+ m_bCancel(false),
+ m_bDesctructionEnabled(false),
+ m_aImageList( SW_RES( ILIST ) ),
+ m_aImageListHC( SW_RES( ILIST_HC ) ),
+ m_pImpl(new SwSendMailDialog_Impl),
+ m_pConfigItem(&rConfigItem),
+ m_nSendCount(0),
+ m_nErrorCount(0)
+{
+ m_nStatusHeight = m_aSeparatorFL.GetPosPixel().Y() - m_aStatusLB.GetPosPixel().Y();
+ String sTask(SW_RES(ST_TASK));
+ String sStatus(SW_RES(ST_STATUS));
+ m_aStatusLB.SetHelpId(HID_MM_SENDMAILS_STATUSLB);
+
+ FreeResource();
+
+ m_aDetailsPB.SetClickHdl(LINK( this, SwSendMailDialog, DetailsHdl_Impl));
+ m_aStopPB.SetClickHdl(LINK( this, SwSendMailDialog, StopHdl_Impl));
+ m_aClosePB.SetClickHdl(LINK( this, SwSendMailDialog, CloseHdl_Impl));
+
+
+ Size aLBSize(m_aStatusLB.GetSizePixel());
+ m_aStatusHB.SetSizePixel(aLBSize);
+ Size aHeadSize(m_aStatusHB.CalcWindowSizePixel());
+ aHeadSize.Width() = aLBSize.Width();
+ m_aStatusHB.SetSizePixel(aHeadSize);
+ Point aLBPos(m_aStatusLB.GetPosPixel());
+ m_aStatusHB.SetPosPixel(aLBPos);
+ aLBPos.Y() += aHeadSize.Height();
+ aLBSize.Height() -= aHeadSize.Height();
+ m_aStatusLB.SetPosSizePixel(aLBPos, aLBSize);
+
+ Size aSz(m_aStatusHB.GetOutputSizePixel());
+ long nPos1 = aSz.Width()/3 * 2;
+ long nPos2 = aSz.Width()/3;
+ m_aStatusHB.InsertItem( ITEMID_TASK, sTask,
+ nPos1,
+ HIB_LEFT | HIB_VCENTER );
+ m_aStatusHB.InsertItem( ITEMID_STATUS, sStatus,
+ nPos2,
+ HIB_LEFT | HIB_VCENTER );
+ m_aStatusHB.SetHelpId(HID_MM_ADDRESSLIST_HB );
+ m_aStatusHB.Show();
+
+ m_aStatusLB.SetHelpId(HID_MM_MAILSTATUS_TLB);
+ static long nTabs[] = {3, 0, nPos1, aSz.Width() };
+ m_aStatusLB.SetWindowBits( WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP );
+ m_aStatusLB.SetSelectionMode( SINGLE_SELECTION );
+ m_aStatusLB.SetTabs(&nTabs[0], MAP_PIXEL);
+ m_aStatusLB.SetSpaceBetweenEntries(3);
+
+ DetailsHdl_Impl( &m_aDetailsPB );
+ UpdateTransferStatus();
+}
+/*-- 21.05.2004 14:10:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwSendMailDialog::~SwSendMailDialog()
+{
+ if(m_pImpl->xMailDispatcher.is())
+ {
+ try
+ {
+ if(m_pImpl->xMailDispatcher->isStarted())
+ m_pImpl->xMailDispatcher->stop();
+ if(m_pImpl->xConnectedMailService.is() && m_pImpl->xConnectedMailService->isConnected())
+ m_pImpl->xConnectedMailService->disconnect();
+ if(m_pImpl->xConnectedInMailService.is() && m_pImpl->xConnectedInMailService->isConnected())
+ m_pImpl->xConnectedInMailService->disconnect();
+
+ uno::Reference<mail::XMailMessage> xMessage =
+ m_pImpl->xMailDispatcher->dequeueMailMessage();
+ while(xMessage.is())
+ {
+ SwMailDispatcherListener_Impl::DeleteAttachments( xMessage );
+ xMessage = m_pImpl->xMailDispatcher->dequeueMailMessage();
+ }
+ }
+ catch(const uno::Exception&)
+ {
+ }
+ }
+ delete m_pImpl;
+}
+/*-- 21.05.2004 14:10:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwSendMailDialog::AddDocument( SwMailDescriptor& rDesc )
+{
+ ::osl::MutexGuard aGuard(m_pImpl->aDescriptorMutex);
+ m_pImpl->aDescriptors.push_back(rDesc);
+ // if the dialog is already running then continue sending of documents
+ if(m_pImpl->xMailDispatcher.is())
+ {
+ IterateMails();
+ }
+
+}
+/*-- 31.01.2005 08:59:35---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwSendMailDialog::SetDocumentCount( sal_Int32 nAllDocuments )
+{
+ m_pImpl->nDocumentCount = nAllDocuments;
+ UpdateTransferStatus();
+}
+/*-- 21.05.2004 14:10:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void lcl_Move(Control& rCtrl, long nYOffset)
+{
+ Point aPos(rCtrl.GetPosPixel());
+ aPos.Y() += nYOffset;
+ rCtrl.SetPosPixel(aPos);
+}
+/*-- 21.05.2004 14:10:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( SwSendMailDialog, DetailsHdl_Impl, PushButton*, EMPTYARG )
+{
+ long nMove = 0;
+ if(m_aStatusLB.IsVisible())
+ {
+ m_aStatusLB.Hide();
+ m_aStatusHB.Hide();
+ nMove = - m_nStatusHeight;
+ m_aDetailsPB.SetText(m_sMore);
+ }
+ else
+ {
+ m_aStatusLB.Show();
+ m_aStatusHB.Show();
+ nMove = m_nStatusHeight;
+ m_aDetailsPB.SetText(m_sLess);
+ }
+ lcl_Move(m_aSeparatorFL, nMove);
+ lcl_Move(m_aStopPB, nMove);
+ lcl_Move(m_aClosePB, nMove);
+ Size aDlgSize = GetSizePixel(); aDlgSize.Height() += nMove; SetSizePixel(aDlgSize);
+
+ return 0;
+}
+/*-- 21.05.2004 14:10:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( SwSendMailDialog, StopHdl_Impl, PushButton*, pButton )
+{
+ m_bCancel = true;
+ if(m_pImpl->xMailDispatcher.is())
+ {
+ if(m_pImpl->xMailDispatcher->isStarted())
+ {
+ m_pImpl->xMailDispatcher->stop();
+ pButton->SetText(m_sContinue);
+ m_PausedFI.Show();
+ }
+ else
+ {
+ m_pImpl->xMailDispatcher->start();
+ pButton->SetText(m_sStop);
+ m_PausedFI.Show(sal_False);
+ }
+ }
+ return 0;
+}
+/*-- 21.05.2004 14:10:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( SwSendMailDialog, CloseHdl_Impl, PushButton*, EMPTYARG )
+{
+ ModelessDialog::Show( sal_False );
+ return 0;
+}
+/*-- 14.06.2004 09:48:30---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_STATIC_LINK_NOINSTANCE( SwSendMailDialog, StartSendMails, SwSendMailDialog*, pDialog )
+{
+ pDialog->SendMails();
+ return 0;
+}
+/*-- 14.06.2004 09:48:30---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_STATIC_LINK( SwSendMailDialog, RemoveThis, Timer*, pTimer )
+{
+ if( pThis->m_pImpl->xMailDispatcher.is() )
+ {
+ if(pThis->m_pImpl->xMailDispatcher->isStarted())
+ pThis->m_pImpl->xMailDispatcher->stop();
+ if(!pThis->m_pImpl->xMailDispatcher->isShutdownRequested())
+ pThis->m_pImpl->xMailDispatcher->shutdown();
+ }
+
+ if( pThis->m_bDesctructionEnabled &&
+ (!pThis->m_pImpl->xMailDispatcher.is() ||
+ !pThis->m_pImpl->xMailDispatcher->isRunning()))
+ {
+ delete pThis;
+ }
+ else
+ {
+ pTimer->Start();
+ }
+ return 0;
+}
+/*-- 07.07.2004 14:34:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_STATIC_LINK_NOINSTANCE( SwSendMailDialog, StopSendMails, SwSendMailDialog*, pDialog )
+{
+ if(pDialog->m_pImpl->xMailDispatcher.is() &&
+ pDialog->m_pImpl->xMailDispatcher->isStarted())
+ {
+ pDialog->m_pImpl->xMailDispatcher->stop();
+ pDialog->m_aStopPB.SetText(pDialog->m_sContinue);
+ pDialog->m_PausedFI.Show();
+ }
+ return 0;
+}
+/*-- 14.06.2004 10:38:04---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwSendMailDialog::SendMails()
+{
+ if(!m_pConfigItem)
+ {
+ DBG_ERROR("config item not set");
+ return;
+ }
+ String sErrorMessage;
+ bool bIsLoggedIn = false;
+ EnterWait();
+ //get a mail server connection
+ uno::Reference< mail::XSmtpService > xSmtpServer =
+ SwMailMergeHelper::ConnectToSmtpServer( *m_pConfigItem,
+ m_pImpl->xConnectedInMailService,
+ aEmptyStr, aEmptyStr, this );
+ bIsLoggedIn = xSmtpServer.is() && xSmtpServer->isConnected();
+ LeaveWait();
+ if(!bIsLoggedIn)
+ {
+ DBG_ERROR("create error message");
+ return;
+ }
+ m_pImpl->xMailDispatcher.set( new MailDispatcher(xSmtpServer));
+ IterateMails();
+ m_pImpl->xMailListener = new SwMailDispatcherListener_Impl(*this);
+ m_pImpl->xMailDispatcher->addListener(m_pImpl->xMailListener);
+ if(!m_bCancel)
+ {
+ m_pImpl->xMailDispatcher->start();
+ }
+}
+/* -----------------28.01.2005 10:17-----------------
+
+ --------------------------------------------------*/
+void SwSendMailDialog::IterateMails()
+{
+ const SwMailDescriptor* pCurrentMailDescriptor = m_pImpl->GetNextDescriptor();
+ while( pCurrentMailDescriptor )
+ {
+ if(!SwMailMergeHelper::CheckMailAddress( pCurrentMailDescriptor->sEMail ))
+ {
+ ImageList& rImgLst = GetSettings().GetStyleSettings().GetHighContrastMode() ?
+ m_aImageListHC : m_aImageList;
+ Image aInsertImg = rImgLst.GetImage( FN_FORMULA_CANCEL );
+
+ String sMessage = m_sSendingTo;
+ String sTmp(pCurrentMailDescriptor->sEMail);
+ sTmp += '\t';
+ sTmp += m_sFailed;
+ sMessage.SearchAndReplaceAscii("%1", sTmp);
+ m_aStatusLB.InsertEntry( sMessage, aInsertImg, aInsertImg);
+ ++m_nSendCount;
+ ++m_nErrorCount;
+ UpdateTransferStatus( );
+ pCurrentMailDescriptor = m_pImpl->GetNextDescriptor();
+ continue;
+ }
+ SwMailMessage* pMessage = 0;
+ uno::Reference< mail::XMailMessage > xMessage = pMessage = new SwMailMessage;
+ if(m_pConfigItem->IsMailReplyTo())
+ pMessage->setReplyToAddress(m_pConfigItem->GetMailReplyTo());
+ pMessage->addRecipient( pCurrentMailDescriptor->sEMail );
+ pMessage->SetSenderName( m_pConfigItem->GetMailDisplayName() );
+ pMessage->SetSenderAddress( m_pConfigItem->GetMailAddress() );
+ if(pCurrentMailDescriptor->sAttachmentURL.getLength())
+ {
+ mail::MailAttachment aAttach;
+ aAttach.Data =
+ new SwMailTransferable(
+ pCurrentMailDescriptor->sAttachmentURL,
+ pCurrentMailDescriptor->sAttachmentName,
+ pCurrentMailDescriptor->sMimeType );
+ aAttach.ReadableName = pCurrentMailDescriptor->sAttachmentName;
+ pMessage->addAttachment( aAttach );
+ }
+ pMessage->setSubject( pCurrentMailDescriptor->sSubject );
+ uno::Reference< datatransfer::XTransferable> xBody =
+ new SwMailTransferable(
+ pCurrentMailDescriptor->sBodyContent,
+ pCurrentMailDescriptor->sBodyMimeType);
+ pMessage->setBody( xBody );
+
+ //CC and BCC are tokenized by ';'
+ if(pCurrentMailDescriptor->sCC.getLength())
+ {
+ String sTokens( pCurrentMailDescriptor->sCC );
+ sal_uInt16 nTokens = sTokens.GetTokenCount( ';' );
+ xub_StrLen nPos = 0;
+ for( sal_uInt16 nToken = 0; nToken < nTokens; ++nToken)
+ {
+ String sTmp = sTokens.GetToken( 0, ';', nPos);
+ if( sTmp.Len() )
+ pMessage->addCcRecipient( sTmp );
+ }
+ }
+ if(pCurrentMailDescriptor->sBCC.getLength())
+ {
+ String sTokens( pCurrentMailDescriptor->sBCC );
+ sal_uInt16 nTokens = sTokens.GetTokenCount( ';' );
+ xub_StrLen nPos = 0;
+ for( sal_uInt16 nToken = 0; nToken < nTokens; ++nToken)
+ {
+ String sTmp = sTokens.GetToken( 0, ';', nPos);
+ if( sTmp.Len() )
+ pMessage->addBccRecipient( sTmp );
+ }
+ }
+ m_pImpl->xMailDispatcher->enqueueMailMessage( xMessage );
+ pCurrentMailDescriptor = m_pImpl->GetNextDescriptor();
+ }
+ UpdateTransferStatus();
+}
+/*-- 27.08.2004 10:50:17---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwSendMailDialog::ShowDialog()
+{
+ Application::PostUserEvent( STATIC_LINK( this, SwSendMailDialog,
+ StartSendMails ), this );
+ ModelessDialog::Show();
+}
+/*-- 27.08.2004 10:50:17---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwSendMailDialog::StateChanged( StateChangedType nStateChange )
+{
+ ModelessDialog::StateChanged( nStateChange );
+ if(STATE_CHANGE_VISIBLE == nStateChange && !IsVisible())
+ {
+ m_pImpl->aRemoveTimer.SetTimeoutHdl( STATIC_LINK( this, SwSendMailDialog,
+ RemoveThis ) );
+ m_pImpl->aRemoveTimer.Start();
+ }
+}
+
+/*-- 23.06.2004 10:14:22---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwSendMailDialog::DocumentSent( uno::Reference< mail::XMailMessage> xMessage,
+ bool bResult,
+ const ::rtl::OUString* pError )
+{
+ //sending should stop on send errors
+ if(pError &&
+ m_pImpl->xMailDispatcher.is() && m_pImpl->xMailDispatcher->isStarted())
+ {
+ Application::PostUserEvent( STATIC_LINK( this, SwSendMailDialog,
+ StopSendMails ), this );
+ }
+ ImageList& rImgLst = GetSettings().GetStyleSettings().GetHighContrastMode() ?
+ m_aImageListHC : m_aImageList;
+ Image aInsertImg = rImgLst.GetImage( bResult ? FN_FORMULA_APPLY : FN_FORMULA_CANCEL );
+
+ String sMessage = m_sSendingTo;
+ String sTmp(xMessage->getRecipients()[0]);
+ sTmp += '\t';
+ sTmp += bResult ? m_sCompleted : m_sFailed;
+ sMessage.SearchAndReplaceAscii("%1", sTmp);
+ m_aStatusLB.InsertEntry( sMessage, aInsertImg, aInsertImg);
+ ++m_nSendCount;
+ if(!bResult)
+ ++m_nErrorCount;
+
+ UpdateTransferStatus( );
+ if(pError)
+ {
+ SwSendWarningBox_Impl* pDlg = new SwSendWarningBox_Impl(0, *pError);
+ pDlg->Execute();
+ delete pDlg;
+ }
+}
+/*-- 23.06.2004 11:25:31---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwSendMailDialog::UpdateTransferStatus()
+{
+ String sStatus( m_sTransferStatus );
+ sStatus.SearchAndReplaceAscii("%1", String::CreateFromInt32(m_nSendCount) );
+ sStatus.SearchAndReplaceAscii("%2", String::CreateFromInt32(m_pImpl->nDocumentCount));
+ m_aTransferStatusFT.SetText(sStatus);
+
+ sStatus = m_sErrorStatus;
+ sStatus.SearchAndReplaceAscii("%1", String::CreateFromInt32(m_nErrorCount) );
+ m_aErrorStatusFT.SetText(sStatus);
+
+ if(m_pImpl->aDescriptors.size())
+ m_aProgressBar.SetValue((USHORT)(m_nSendCount * 100 / m_pImpl->aDescriptors.size()));
+ else
+ m_aProgressBar.SetValue(0);
+}
+/*-- 23.06.2004 11:18:50---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwSendMailDialog::AllMailsSent()
+{
+ m_aStopPB.Enable(sal_False);
+}
+
+
diff --git a/sw/source/ui/dbui/mailmergechildwindow.hrc b/sw/source/ui/dbui/mailmergechildwindow.hrc
new file mode 100644
index 000000000000..ae83766c83ef
--- /dev/null
+++ b/sw/source/ui/dbui/mailmergechildwindow.hrc
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mailmergechildwindow.hrc,v $
+ * $Revision: 1.5 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#define TB_BACK 1
+#define ILIST_TBX 90
+#define ILIST_TBX_HC 91
+
+#define FL_SEPARATOR 7
+
+#define FL_STATUS 60
+#define FT_STATUS1 61
+#define FL_TRANSFERSTATUS 62
+#define FT_TRANSFERSTATUS 63
+#define PB_PROGRESS 64
+#define FT_ERRORSTATUS 65
+#define PB_DETAILS 66
+#define LB_STATUS 67
+#define FI_PAUSED 68
+#define PB_STOP 69
+#define PB_CLOSE 70
+#define ST_CONTINUE 71
+#define ST_LESS 72
+#define ST_TASK 73
+#define ST_STATUS 74
+#define ILIST 75
+#define ILIST_HC 76
+#define ST_SEND 77
+#define ST_SENDINGTO 78
+#define ST_COMPLETED 79
+#define ST_FAILED 80
+#define ST_TERMINATEQUERY 81
+
+#define IM_WARNING 10
+#define FI_WARNING 11
+#define FT_DETAILS 12
+#define ED_DETAILS 13
+#define PB_OK 14
diff --git a/sw/source/ui/dbui/mailmergechildwindow.src b/sw/source/ui/dbui/mailmergechildwindow.src
new file mode 100644
index 000000000000..6d9f0bc49272
--- /dev/null
+++ b/sw/source/ui/dbui/mailmergechildwindow.src
@@ -0,0 +1,281 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mailmergechildwindow.src,v $
+ * $Revision: 1.11.240.1 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include "mailmergechildwindow.hrc"
+#include "dbui.hrc"
+#include "helpid.h"
+#include <cmdid.h>
+
+#define WIDTH 100
+#define HEIGHT 16
+
+#define WORKAROUND \
+ Text [ en-US ] = "Return to Mail Merge Wizard" ; \
+
+
+FloatingWindow DLG_MAILMERGECHILD\
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WIDTH , HEIGHT ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Sizeable = FALSE ;
+ Zoomable = TRUE ;
+ HelpID = HID_MAILMERGECHILD ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Mail Merge Wizard";\
+ ToolBox TB_BACK\
+ {
+ MenuStrings = TRUE ;
+ SVLook = TRUE ;
+ ItemList =
+ {
+ ToolBoxItem\
+ {
+ Identifier = 1;
+ HelpID = HID_RETURN_TO_MAILMERGE ;
+ Left = TRUE;
+ WORKAROUND
+ };
+ };
+ };
+ #define IMGLIST1_IDS\
+ IdList = \
+ { \
+ FN_SHOW_ROOT; \
+ }; \
+ IdCount = 1
+
+ ImageList ILIST_TBX
+ {
+ Prefix = "sc";
+ MaskColor = IMAGE_MASK_COLOR;
+ IMGLIST1_IDS;
+ };
+
+ ImageList ILIST_TBX_HC
+ {
+ Prefix = "sch";
+ MaskColor = IMAGE_MASK_COLOR ;
+ IMGLIST1_IDS;
+ };
+};
+
+//FloatingWindow DLG_MM_SENDMAILS
+ModelessDialog /*ModalDialog*/ DLG_MM_SENDMAILS
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_SENDMAILS;
+ Size = MAP_APPFONT ( 250 , 221 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE;
+
+ Text [ en-US ] = "Sending E-mail messages";
+
+ FixedLine FL_STATUS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 238 , 8 ) ;
+ Text[ en-US ] = "Connection status";
+ };
+ FixedText FT_STATUS1
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 226 , 8 ) ;
+ Text[ en-US ] = "The connection to the outgoing mail server has been established";
+ };
+ String ST_SEND
+ {
+ Text[ en-US ] = "Sending e-mails...";
+ };
+ FixedLine FL_TRANSFERSTATUS
+ {
+ Pos = MAP_APPFONT ( 6 , 28 ) ;
+ Size = MAP_APPFONT ( 238 , 8 ) ;
+ Text[ en-US ] = "Transfer status";
+ };
+ FixedText FT_TRANSFERSTATUS
+ {
+ Pos = MAP_APPFONT ( 12, 39 ) ;
+ Size = MAP_APPFONT ( 110 , 8 ) ;
+ Text[ en-US ] = "%1 of %2 e-mails sent";
+ };
+ FixedText FI_PAUSED
+ {
+ Pos = MAP_APPFONT ( 125, 39 ) ;
+ Size = MAP_APPFONT ( 100 , 8 ) ;
+ Hide = TRUE;
+ Text[ en-US ] = "Sending paused";
+ };
+ Window PB_PROGRESS
+ {
+ Pos = MAP_APPFONT ( 12 , 50 ) ;
+ Size = MAP_APPFONT ( 226 , 14 ) ;
+ Border = TRUE;
+ };
+ FixedText FT_ERRORSTATUS
+ {
+ Pos = MAP_APPFONT ( 12 , 67 ) ;
+ Size = MAP_APPFONT ( 226 , 8 ) ;
+ Text[ en-US ] = "E-mails not sent: %1";
+ };
+ PushButton PB_DETAILS
+ {
+ Pos = MAP_APPFONT ( 188 , 81 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "More >>";
+ };
+ String ST_LESS
+ {
+ Text[ en-US ] = "<< Less";
+ };
+
+ Control LB_STATUS
+ {
+ Pos = MAP_APPFONT ( 12 , 101 ) ;
+ Size = MAP_APPFONT ( 226 , 80 ) ;
+ Border = TRUE;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 187 ) ;
+ Size = MAP_APPFONT ( 250 , 8 ) ;
+ };
+ PushButton PB_STOP
+ {
+ Pos = MAP_APPFONT ( 141 , 201 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "~Stop";
+ };
+ PushButton PB_CLOSE
+ {
+ Pos = MAP_APPFONT ( 194 , 201 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "C~lose";
+ };
+ String ST_CONTINUE
+ {
+ Text[ en-US ] = "~Continue";
+ };
+ #define IMGLIST2_IDS\
+ IdList = \
+ { \
+ FN_FORMULA_CANCEL ;\
+ FN_FORMULA_APPLY ;\
+ }; \
+ IdCount = 2
+
+ ImageList ILIST
+ {
+ Prefix = "sc";
+ MaskColor = IMAGE_MASK_COLOR;
+ IMGLIST2_IDS;
+ };
+
+ ImageList ILIST_HC
+ {
+ Prefix = "sch";
+ MaskColor = IMAGE_MASK_COLOR ;
+ IMGLIST2_IDS;
+ };
+ String ST_TASK
+ {
+ Text[ en-US ] = "Task";
+ };
+ String ST_STATUS
+ {
+ Text[ en-US ] = "Status";
+ };
+ String ST_SENDINGTO
+ {
+ Text[ en-US ] = "Sending to: %1";
+ };
+ String ST_COMPLETED
+ {
+ Text[ en-US ] = "Successfully sent";
+ };
+ String ST_FAILED
+ {
+ Text[ en-US ] = "Sending failed (invalid address)";
+ };
+ String ST_TERMINATEQUERY
+ {
+ Text[ en-US ] = "There are still e-mail messages in your %PRODUCTNAME Outbox.\nWould you like to exit anyway?";
+ };
+};
+
+ModalDialog DLG_MM_SENDWARNING
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_SENDWARNING;
+ Size = MAP_APPFONT ( 240 , 137 ) ;
+ Moveable = TRUE ;
+
+ Text[en-US] = "E-Mails could not be sent";
+ FixedImage IM_WARNING
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 30 , 30 ) ;
+ };
+ FixedText FI_WARNING
+ {
+ Pos = MAP_APPFONT ( 40 , 6 ) ;
+ Size = MAP_APPFONT ( 170 , 30 ) ;
+ WordBreak = TRUE;
+ Text[ en-US ] = "The following error occurred:";
+ };
+ FixedText FT_DETAILS
+ {
+ Pos = MAP_APPFONT ( 40, 39 ) ;
+ Size = MAP_APPFONT ( 174, 8 ) ;
+ Text[ en-US ] = "Detailed information";
+ };
+ MultiLineEdit ED_DETAILS
+ {
+ Pos = MAP_APPFONT ( 40 , 50 ) ;
+ Size = MAP_APPFONT ( 194 , 50 ) ;
+ Border = TRUE;
+ Readonly = TRUE;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 106 ) ;
+ Size = MAP_APPFONT ( 240 , 8 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 95 , 117) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE;
+ };
+};
+
diff --git a/sw/source/ui/dbui/mailmergehelper.cxx b/sw/source/ui/dbui/mailmergehelper.cxx
new file mode 100644
index 000000000000..0423137cc3c3
--- /dev/null
+++ b/sw/source/ui/dbui/mailmergehelper.cxx
@@ -0,0 +1,1050 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mailmergehelper.cxx,v $
+ * $Revision: 1.17 $
+ *
+ * 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"
+#include <swtypes.hxx>
+#include <mailmergehelper.hxx>
+#include <svtools/stdctrl.hxx>
+#include <mmconfigitem.hxx>
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include "com/sun/star/mail/MailServiceProvider.hpp"
+#include "com/sun/star/mail/XSmtpService.hpp"
+#include <comphelper/processfactory.hxx>
+#include <vcl/msgbox.hxx>
+#ifndef _PASSWD_HXX
+#include <sfx2/passwd.hxx>
+#endif
+
+#include <dbui.hrc>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+
+using rtl::OUString;
+
+//using ::rtl::OUString;
+
+namespace SwMailMergeHelper
+{
+
+/*-- 14.06.2004 12:29:19---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+String CallSaveAsDialog(String& rFilter)
+{
+ ErrCode nRet;
+ String sFactory(String::CreateFromAscii(SwDocShell::Factory().GetShortName()));
+ ::sfx2::FileDialogHelper aDialog( ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
+ 0,
+ sFactory );
+
+ String sRet;
+ nRet = aDialog.Execute();
+ if(ERRCODE_NONE == nRet)
+ {
+ uno::Reference < ui::dialogs::XFilePicker > xFP = aDialog.GetFilePicker();
+ sRet = xFP->getFiles().getConstArray()[0];
+ rFilter = aDialog.GetRealFilter();
+ }
+ return sRet;
+}
+/*-- 20.08.2004 09:39:18---------------------------------------------------
+ simple address check: check for '@'
+ for at least one '.' after the '@'
+ and for at least to characters before and after the dot
+ -----------------------------------------------------------------------*/
+bool CheckMailAddress( const ::rtl::OUString& rMailAddress )
+{
+ String sAddress(rMailAddress);
+ if(!(sAddress.GetTokenCount('@') == 2))
+ return false;
+ sAddress = sAddress.GetToken(1, '@');
+ if(sAddress.GetTokenCount('.') < 2)
+ return false;
+ if(sAddress.GetToken( 0, '.').Len() < 2 || sAddress.GetToken( 1, '.').Len() < 2)
+ return false;
+ return true;
+}
+
+/*-- 28.12.2004 10:16:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Reference< mail::XSmtpService > ConnectToSmtpServer(
+ SwMailMergeConfigItem& rConfigItem,
+ uno::Reference< mail::XMailService >& rxInMailService,
+ const String& rInMailServerPassword,
+ const String& rOutMailServerPassword,
+ Window* pDialogParentWindow )
+{
+ uno::Reference< mail::XSmtpService > xSmtpServer;
+ uno::Reference< lang::XMultiServiceFactory> rMgr = ::comphelper::getProcessServiceFactory();
+ if (rMgr.is())
+ try
+ {
+ uno::Reference< mail::XMailServiceProvider > xMailServiceProvider =
+ mail::MailServiceProvider::create(getCurrentCmpCtx(rMgr));
+ xSmtpServer = uno::Reference< mail::XSmtpService > (
+ xMailServiceProvider->create(
+ mail::MailServiceType_SMTP
+ ), uno::UNO_QUERY);
+
+ uno::Reference< mail::XConnectionListener> xConnectionListener(new SwConnectionListener());
+
+ if(rConfigItem.IsAuthentication() && rConfigItem.IsSMTPAfterPOP())
+ {
+ uno::Reference< mail::XMailService > xInMailService =
+ xMailServiceProvider->create(
+ rConfigItem.IsInServerPOP() ?
+ mail::MailServiceType_POP3 : mail::MailServiceType_IMAP);
+ //authenticate at the POP or IMAP server first
+ String sPasswd = rConfigItem.GetInServerPassword();
+ if(rInMailServerPassword.Len())
+ sPasswd = rInMailServerPassword;
+ uno::Reference<mail::XAuthenticator> xAuthenticator =
+ new SwAuthenticator(
+ rConfigItem.GetInServerUserName(),
+ sPasswd,
+ pDialogParentWindow);
+
+ xInMailService->addConnectionListener(xConnectionListener);
+ //check connection
+ uno::Reference< uno::XCurrentContext> xConnectionContext =
+ new SwConnectionContext(
+ rConfigItem.GetInServerName(),
+ rConfigItem.GetInServerPort(),
+ ::rtl::OUString::createFromAscii( "Insecure" ));
+ xInMailService->connect(xConnectionContext, xAuthenticator);
+ rxInMailService = xInMailService;
+ }
+ uno::Reference< mail::XAuthenticator> xAuthenticator;
+ if(rConfigItem.IsAuthentication() &&
+ !rConfigItem.IsSMTPAfterPOP() &&
+ rConfigItem.GetMailUserName().getLength())
+ {
+ String sPasswd = rConfigItem.GetMailPassword();
+ if(rOutMailServerPassword.Len())
+ sPasswd = rOutMailServerPassword;
+ xAuthenticator =
+ new SwAuthenticator(rConfigItem.GetMailUserName(),
+ sPasswd,
+ pDialogParentWindow);
+ }
+ else
+ xAuthenticator = new SwAuthenticator();
+ //just to check if the server exists
+ xSmtpServer->getSupportedConnectionTypes();
+ //check connection
+
+ uno::Reference< uno::XCurrentContext> xConnectionContext =
+ new SwConnectionContext(
+ rConfigItem.GetMailServer(),
+ rConfigItem.GetMailPort(),
+ ::rtl::OUString::createFromAscii( rConfigItem.IsSecureConnection() ? "Ssl" : "Insecure"));
+ xSmtpServer->connect(xConnectionContext, xAuthenticator);
+ rxInMailService = uno::Reference< mail::XMailService >( xSmtpServer, uno::UNO_QUERY );
+ }
+ catch(uno::Exception& )
+ {
+ DBG_ERROR("exception caught");
+ }
+ return xSmtpServer;
+}
+
+
+} //namespace
+
+/*-- 06.04.2004 10:31:27---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwBoldFixedInfo::SwBoldFixedInfo(Window* pParent, const ResId& rResId) :
+ FixedInfo(pParent, rResId)
+{
+ Font aFont = GetFont();
+ aFont.SetWeight( WEIGHT_BOLD );
+ SetFont( aFont );
+}
+/*-- 06.04.2004 10:31:27---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwBoldFixedInfo::~SwBoldFixedInfo()
+{
+}
+struct SwAddressPreview_Impl
+{
+ ::std::vector< ::rtl::OUString > aAdresses;
+ sal_uInt16 nRows;
+ sal_uInt16 nColumns;
+ sal_uInt16 nSelectedAddress;
+ bool bEnableScrollBar;
+
+ SwAddressPreview_Impl() :
+ nRows(1),
+ nColumns(1),
+ nSelectedAddress(0),
+ bEnableScrollBar(false)
+ {
+ }
+};
+/*-- 27.04.2004 14:01:22---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAddressPreview::SwAddressPreview(Window* pParent, const ResId rResId) :
+ Window( pParent, rResId ),
+ aVScrollBar(this, WB_VSCROLL),
+ pImpl(new SwAddressPreview_Impl())
+{
+ aVScrollBar.SetScrollHdl(LINK(this, SwAddressPreview, ScrollHdl));
+ Size aSize(GetOutputSizePixel());
+ Size aScrollSize(aVScrollBar.GetSizePixel());
+ aScrollSize.Height() = aSize.Height();
+ aVScrollBar.SetSizePixel(aScrollSize);
+ Point aSrollPos(aSize.Width() - aScrollSize.Width(), 0);
+ aVScrollBar.SetPosPixel(aSrollPos);
+ Show();
+}
+/*-- 27.04.2004 14:01:22---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAddressPreview::~SwAddressPreview()
+{
+}
+/*-- 25.06.2004 11:50:55---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAddressPreview, ScrollHdl, ScrollBar*, EMPTYARG)
+{
+ Invalidate();
+ return 0;
+}
+/*-- 27.04.2004 14:01:22---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::AddAddress(const ::rtl::OUString& rAddress)
+{
+ pImpl->aAdresses.push_back(rAddress);
+ UpdateScrollBar();
+}
+/*-- 27.04.2004 14:01:23---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::SetAddress(const ::rtl::OUString& rAddress)
+{
+ pImpl->aAdresses.clear();
+ pImpl->aAdresses.push_back(rAddress);
+ aVScrollBar.Show(FALSE);
+ Invalidate();
+}
+/*-- 27.04.2004 14:01:23---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_uInt16 SwAddressPreview::GetSelectedAddress()const
+{
+ DBG_ASSERT(pImpl->nSelectedAddress < pImpl->aAdresses.size(), "selection invalid");
+ return pImpl->nSelectedAddress;
+}
+/*-- 25.06.2004 10:32:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::SelectAddress(sal_uInt16 nSelect)
+{
+ DBG_ASSERT(pImpl->nSelectedAddress < pImpl->aAdresses.size(), "selection invalid");
+ pImpl->nSelectedAddress = nSelect;
+ // now make it visible..
+ sal_uInt16 nSelectRow = nSelect / pImpl->nColumns;
+ sal_uInt16 nStartRow = (sal_uInt16)aVScrollBar.GetThumbPos();
+ if( (nSelectRow < nStartRow) || (nSelectRow >= (nStartRow + pImpl->nRows) ))
+ aVScrollBar.SetThumbPos( nSelectRow );
+}
+/*-- 25.06.2004 11:00:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::Clear()
+{
+ pImpl->aAdresses.clear();
+ pImpl->nSelectedAddress = 0;
+ UpdateScrollBar();
+}
+/*-- 28.04.2004 12:05:50---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::ReplaceSelectedAddress(const ::rtl::OUString& rNew)
+{
+ pImpl->aAdresses[pImpl->nSelectedAddress] = rNew;
+ Invalidate();
+}
+/*-- 25.06.2004 11:30:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::RemoveSelectedAddress()
+{
+ pImpl->aAdresses.erase(pImpl->aAdresses.begin() + pImpl->nSelectedAddress);
+ if(pImpl->nSelectedAddress)
+ --pImpl->nSelectedAddress;
+ UpdateScrollBar();
+ Invalidate();
+}
+/*-- 27.04.2004 14:01:23---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::SetLayout(sal_uInt16 nRows, sal_uInt16 nColumns)
+{
+ pImpl->nRows = nRows;
+ pImpl->nColumns = nColumns;
+ UpdateScrollBar();
+}
+/*-- 25.06.2004 13:54:03---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::EnableScrollBar(bool bEnable)
+{
+ pImpl->bEnableScrollBar = bEnable;
+}
+/*-- 25.06.2004 11:55:52---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::UpdateScrollBar()
+{
+ if(pImpl->nColumns)
+ {
+ aVScrollBar.SetVisibleSize(pImpl->nRows);
+ sal_uInt16 nResultingRows = (sal_uInt16)(pImpl->aAdresses.size() + pImpl->nColumns - 1) / pImpl->nColumns;
+ ++nResultingRows;
+ aVScrollBar.Show(pImpl->bEnableScrollBar && nResultingRows > pImpl->nRows);
+ aVScrollBar.SetRange(Range(0, nResultingRows));
+ if(aVScrollBar.GetThumbPos() > nResultingRows)
+ aVScrollBar.SetThumbPos(nResultingRows);
+ }
+}
+/*-- 27.04.2004 14:01:23---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::Paint(const Rectangle&)
+{
+ const StyleSettings& rSettings = GetSettings().GetStyleSettings();
+ SetFillColor(rSettings.GetWindowColor());
+ SetLineColor( Color(COL_TRANSPARENT) );
+ DrawRect( Rectangle(Point(0, 0), GetOutputSizePixel()) );
+ Color aPaintColor(IsEnabled() ? rSettings.GetWindowTextColor() : rSettings.GetDisableColor());
+ SetLineColor(aPaintColor);
+ Font aFont(GetFont());
+ aFont.SetColor(aPaintColor);
+ SetFont(aFont);
+
+ Size aSize = GetOutputSizePixel();
+ sal_uInt16 nStartRow = 0;
+ if(aVScrollBar.IsVisible())
+ {
+ aSize.Width() -= aVScrollBar.GetSizePixel().Width();
+ nStartRow = (sal_uInt16)aVScrollBar.GetThumbPos();
+ }
+ Size aPartSize( aSize.Width()/pImpl->nColumns, aSize.Height()/pImpl->nRows );
+ aPartSize.Width() -= 2;
+ aPartSize.Height() -= 2;
+
+ sal_uInt16 nAddress = nStartRow * pImpl->nColumns;
+ const sal_uInt16 nNumAddresses = static_cast< sal_uInt16 >(pImpl->aAdresses.size());
+ for(sal_uInt16 nRow = 0; nRow < pImpl->nRows ; ++nRow)
+ {
+ for(sal_uInt16 nCol = 0; nCol < pImpl->nColumns; ++nCol)
+ {
+ if(nAddress >= nNumAddresses)
+ break;
+ Point aPos(nCol * aPartSize.Width(), (nRow) * aPartSize.Height());
+ aPos.Move(1,1);
+ bool bIsSelected = nAddress == pImpl->nSelectedAddress;
+ if((pImpl->nColumns * pImpl->nRows) == 1)
+ bIsSelected = false;
+ ::rtl::OUString adr(pImpl->aAdresses[nAddress]);
+ DrawText_Impl(adr,aPos,aPartSize,bIsSelected);
+ ++nAddress;
+ }
+ }
+ SetClipRegion();
+}
+
+/*-- 07.06.2004 15:44:15---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Window::MouseButtonDown(rMEvt);
+ if(rMEvt.IsLeft() && ( pImpl->nRows || pImpl->nColumns))
+ {
+ //determine the selected address
+ const Point& rMousePos = rMEvt.GetPosPixel();
+ Size aSize(GetOutputSizePixel());
+ Size aPartSize( aSize.Width()/pImpl->nColumns, aSize.Height()/pImpl->nRows );
+ sal_uInt32 nRow = rMousePos.Y() / aPartSize.Height() ;
+ if(aVScrollBar.IsVisible())
+ {
+ nRow += (sal_uInt16)aVScrollBar.GetThumbPos();
+ }
+ sal_uInt32 nCol = rMousePos.X() / aPartSize.Width();
+ sal_uInt32 nSelect = nRow * pImpl->nColumns + nCol;
+
+ if( nSelect < pImpl->aAdresses.size() &&
+ pImpl->nSelectedAddress != (sal_uInt16)nSelect)
+ {
+ pImpl->nSelectedAddress = (sal_uInt16)nSelect;
+ m_aSelectHdl.Call(this);
+ }
+ Invalidate();
+ }
+}
+/*-- 01.07.2004 12:33:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::KeyInput( const KeyEvent& rKEvt )
+{
+ USHORT nKey = rKEvt.GetKeyCode().GetCode();
+ if(pImpl->nRows || pImpl->nColumns)
+ {
+ sal_uInt32 nSelectedRow = (pImpl->nSelectedAddress + 1)/ pImpl->nColumns;
+ sal_uInt32 nSelectedColumn = pImpl->nSelectedAddress % nSelectedRow;
+ switch(nKey)
+ {
+ case KEY_UP:
+ if(nSelectedRow)
+ --nSelectedRow;
+ break;
+ case KEY_DOWN:
+ if(pImpl->aAdresses.size() > sal_uInt32(pImpl->nSelectedAddress + pImpl->nColumns))
+ ++nSelectedRow;
+ break;
+ case KEY_LEFT:
+ if(nSelectedColumn)
+ --nSelectedColumn;
+ break;
+ case KEY_RIGHT:
+ if(nSelectedColumn < sal_uInt32(pImpl->nColumns - 1) &&
+ pImpl->aAdresses.size() - 1 > pImpl->nSelectedAddress )
+ ++nSelectedColumn;
+ break;
+ }
+ sal_uInt32 nSelect = nSelectedRow * pImpl->nColumns + nSelectedColumn;
+ if( nSelect < pImpl->aAdresses.size() &&
+ pImpl->nSelectedAddress != (sal_uInt16)nSelect)
+ {
+ pImpl->nSelectedAddress = (sal_uInt16)nSelect;
+ m_aSelectHdl.Call(this);
+ Invalidate();
+ }
+ }
+ else
+ Window::KeyInput(rKEvt);
+}
+/*-- 05.07.2004 12:02:28---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::StateChanged( StateChangedType nStateChange )
+{
+ if(nStateChange == STATE_CHANGE_ENABLE)
+ Invalidate();
+ Window::StateChanged(nStateChange);
+}
+/*-- 27.04.2004 14:01:23---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAddressPreview::DrawText_Impl(
+ const ::rtl::OUString& rAddress, const Point& rTopLeft, const Size& rSize, bool bIsSelected)
+{
+ SetClipRegion( Region( Rectangle(rTopLeft, rSize)) );
+ if(bIsSelected)
+ {
+ //selection rectangle
+ SetFillColor(Color(COL_TRANSPARENT));
+ DrawRect(Rectangle(rTopLeft, rSize));
+ }
+ sal_Int32 nHeight = GetTextHeight();
+ String sAddress(rAddress);
+ sal_uInt16 nTokens = sAddress.GetTokenCount('\n');
+ Point aStart = rTopLeft;
+ //put it away from the border
+ aStart.Move( 2, 2);
+ for(sal_uInt16 nToken = 0; nToken < nTokens; nToken++)
+ {
+ DrawText( aStart, sAddress.GetToken(nToken, '\n') );
+ aStart.Y() += nHeight;
+ }
+}
+/*-- 29.04.2004 11:24:47---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+String SwAddressPreview::FillData(
+ const ::rtl::OUString& rAddress,
+ SwMailMergeConfigItem& rConfigItem,
+ const Sequence< ::rtl::OUString>* pAssignments)
+{
+ //find the column names in the address string (with name assignment!) and
+ //exchange the placeholder (like <Firstname>) with the database content
+ //unassigned columns are expanded to <not assigned>
+ Reference< XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), UNO_QUERY);
+ Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
+ Sequence< ::rtl::OUString> aAssignment = pAssignments ?
+ *pAssignments :
+ rConfigItem.GetColumnAssignment(
+ rConfigItem.GetCurrentDBData() );
+ const ::rtl::OUString* pAssignment = aAssignment.getConstArray();
+ const ResStringArray& rDefHeaders = rConfigItem.GetDefaultAddressHeaders();
+ String sAddress(rAddress);
+ String sNotAssigned(SW_RES(STR_NOTASSIGNED));
+ sNotAssigned.Insert('<', 0);
+ sNotAssigned += '>';
+
+ sal_Bool bIncludeCountry = rConfigItem.IsIncludeCountry();
+ const ::rtl::OUString rExcludeCountry = rConfigItem.GetExcludeCountry();
+ bool bSpecialReplacementForCountry = (!bIncludeCountry || rExcludeCountry.getLength());
+ String sCountryColumn;
+ if( bSpecialReplacementForCountry )
+ {
+ sCountryColumn = rDefHeaders.GetString(MM_PART_COUNTRY);
+ Sequence< ::rtl::OUString> aSpecialAssignment =
+ rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
+ if(aSpecialAssignment.getLength() > MM_PART_COUNTRY && aSpecialAssignment[MM_PART_COUNTRY].getLength())
+ sCountryColumn = aSpecialAssignment[MM_PART_COUNTRY];
+ }
+
+ SwAddressIterator aIter(sAddress);
+ sAddress.Erase();
+ while(aIter.HasMore())
+ {
+ SwMergeAddressItem aItem = aIter.Next();
+ if(aItem.bIsColumn)
+ {
+ //get the default column name
+
+ //find the appropriate assignment
+ String sConvertedColumn = aItem.sText;
+ for(USHORT nColumn = 0;
+ nColumn < rDefHeaders.Count() && nColumn < aAssignment.getLength();
+ ++nColumn)
+ {
+ if(rDefHeaders.GetString(nColumn) == aItem.sText &&
+ pAssignment[nColumn].getLength())
+ {
+ sConvertedColumn = pAssignment[nColumn];
+ break;
+ }
+ }
+ if(sConvertedColumn.Len() &&
+ xColAccess.is() &&
+ xColAccess->hasByName(sConvertedColumn))
+ {
+ //get the content and exchange it in the address string
+ Any aCol = xColAccess->getByName(sConvertedColumn);
+ Reference< XColumn > xColumn;
+ aCol >>= xColumn;
+ if(xColumn.is())
+ {
+ try
+ {
+ ::rtl::OUString sReplace = xColumn->getString();
+
+ if( bSpecialReplacementForCountry && sCountryColumn == sConvertedColumn )
+ {
+ if( rExcludeCountry.getLength() && sReplace != rExcludeCountry )
+ aItem.sText = sReplace;
+ else
+ aItem.sText.Erase();
+ }
+ else
+ {
+ aItem.sText = sReplace;
+ }
+ }
+ catch( sdbc::SQLException& )
+ {
+ DBG_ERROR("SQLException caught");
+ }
+ }
+ }
+ else
+ {
+ aItem.sText = sNotAssigned;
+ }
+
+ }
+ sAddress += aItem.sText;
+ }
+ return sAddress;
+}
+
+/*-- 11.05.2004 15:42:08---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMergeAddressItem SwAddressIterator::Next()
+{
+ //currently the string may either start with a '<' then it's a column
+ //otherwise it's simple text maybe containing a return
+ SwMergeAddressItem aRet;
+ if(sAddress.Len())
+ {
+ if(sAddress.GetChar(0) == '<')
+ {
+ aRet.bIsColumn = true;
+ xub_StrLen nClose = sAddress.Search('>');
+ DBG_ASSERT(nClose != STRING_NOTFOUND, "closing '>' not found");
+ if( nClose != STRING_NOTFOUND )
+ {
+ aRet.sText = sAddress.Copy(1, nClose - 1);
+ sAddress.Erase(0, nClose + 1);
+ }
+ else
+ {
+ aRet.sText = sAddress.Copy(1, 1);
+ sAddress.Erase(0, 1);
+ }
+ }
+ else
+ {
+ xub_StrLen nOpen = sAddress.Search('<');
+ xub_StrLen nReturn = sAddress.Search('\n');
+ if(nReturn == 0)
+ {
+ aRet.bIsReturn = true;
+ aRet.sText = '\n';
+ sAddress.Erase(0, 1);
+ }
+ else if(STRING_NOTFOUND == nOpen && STRING_NOTFOUND == nReturn)
+ {
+ nOpen = sAddress.Len();
+ aRet.sText = sAddress;
+ sAddress.Erase();
+ }
+ else
+ {
+ xub_StrLen nTarget = ::std::min(nOpen, nReturn);
+ aRet.sText = sAddress.Copy(0, nTarget);
+ sAddress.Erase(0, nTarget);
+ }
+ }
+ }
+ return aRet;
+
+}
+/*-- 21.05.2004 10:36:20---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAuthenticator::~SwAuthenticator()
+{
+}
+/*-- 21.05.2004 10:36:20---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+OUString SwAuthenticator::getUserName( ) throw (RuntimeException)
+{
+ return m_aUserName;
+}
+/*-- 21.05.2004 10:36:20---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+OUString SwAuthenticator::getPassword( ) throw (RuntimeException)
+{
+ if(m_aUserName.getLength() && !m_aPassword.getLength() && m_pParentWindow)
+ {
+ SfxPasswordDialog* pPasswdDlg =
+ new SfxPasswordDialog( m_pParentWindow );
+ pPasswdDlg->SetMinLen( 0 );
+ if(RET_OK == pPasswdDlg->Execute())
+ m_aPassword = pPasswdDlg->GetPassword();
+ }
+ return m_aPassword;
+}
+/*-- 25.08.2004 12:53:03---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwConnectionContext::SwConnectionContext(
+ const ::rtl::OUString& rMailServer, sal_Int16 nPort,
+ const ::rtl::OUString& rConnectionType) :
+ m_sMailServer(rMailServer),
+ m_nPort(nPort),
+ m_sConnectionType(rConnectionType)
+{
+}
+/*-- 25.08.2004 12:53:03---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwConnectionContext::~SwConnectionContext()
+{
+}
+/*-- 25.08.2004 12:53:03---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Any SwConnectionContext::getValueByName( const ::rtl::OUString& rName )
+ throw (uno::RuntimeException)
+{
+ uno::Any aRet;
+ if( !rName.compareToAscii( "ServerName" ))
+ aRet <<= m_sMailServer;
+ else if( !rName.compareToAscii( "Port" ))
+ aRet <<= (sal_Int32) m_nPort;
+ else if( !rName.compareToAscii( "ConnectionType" ))
+ aRet <<= m_sConnectionType;
+ return aRet;
+}
+/*-- 21.05.2004 10:45:33---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwConnectionListener::~SwConnectionListener()
+{
+}
+/*-- 21.05.2004 10:45:33---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwConnectionListener::connected(const lang::EventObject& /*aEvent*/)
+ throw (uno::RuntimeException)
+{
+ //OSL_ENSURE(false, "Connection opened");
+}
+/*-- 21.05.2004 10:45:33---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwConnectionListener::disconnected(const lang::EventObject& /*aEvent*/)
+ throw (uno::RuntimeException)
+{
+ //OSL_ENSURE(false, "Connection closed");
+}
+/*-- 21.05.2004 10:45:33---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwConnectionListener::disposing(const lang::EventObject& /*aEvent*/)
+ throw(uno::RuntimeException)
+{
+}
+/*-- 21.05.2004 10:17:22---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Reference< uno::XComponentContext> getCurrentCmpCtx(
+ uno::Reference<lang::XMultiServiceFactory> rSrvMgr)
+{
+ uno::Reference< beans::XPropertySet > xPropSet =
+ uno::Reference< beans::XPropertySet>(rSrvMgr, uno::UNO_QUERY);
+ Any aAny = xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii("DefaultContext"));
+ uno::Reference< uno::XComponentContext> rCmpCtx;
+ aAny >>= rCmpCtx;
+ return rCmpCtx;
+}
+/*-- 13.07.2004 09:07:01---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailTransferable::SwMailTransferable(const rtl::OUString& rBody, const rtl::OUString& rMimeType) :
+ cppu::WeakComponentImplHelper2< datatransfer::XTransferable, beans::XPropertySet >(m_aMutex),
+ m_aMimeType( rMimeType ),
+ m_sBody( rBody ),
+ m_bIsBody( true )
+{
+}
+/*-- 13.07.2004 09:07:01---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailTransferable::SwMailTransferable(const rtl::OUString& rURL,
+ const rtl::OUString& rName, const rtl::OUString& rMimeType) :
+ cppu::WeakComponentImplHelper2< datatransfer::XTransferable, beans::XPropertySet >(m_aMutex),
+ m_aMimeType( rMimeType ),
+ m_aURL(rURL),
+ m_aName( rName ),
+ m_bIsBody( false )
+{
+}
+/*-- 13.07.2004 09:07:08---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailTransferable::~SwMailTransferable()
+{
+}
+/*-- 13.07.2004 09:07:08---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Any SwMailTransferable::getTransferData( const datatransfer::DataFlavor& /*aFlavor*/ )
+ throw (datatransfer::UnsupportedFlavorException,
+ io::IOException, uno::RuntimeException)
+{
+ uno::Any aRet;
+ if( m_bIsBody )
+ aRet <<= ::rtl::OUString(m_sBody);
+ else
+ {
+ Sequence<sal_Int8> aData;
+ SfxMedium aMedium( m_aURL, STREAM_STD_READ, FALSE );
+ SvStream* pStream = aMedium.GetInStream();
+ if ( aMedium.GetErrorCode() == ERRCODE_NONE && pStream)
+ {
+ pStream->Seek(STREAM_SEEK_TO_END);
+ aData.realloc(pStream->Tell());
+ pStream->Seek(0);
+ sal_Int8 * pData = aData.getArray();
+ pStream->Read( pData, aData.getLength() );
+ }
+ aRet <<= aData;
+ }
+ return aRet;
+}
+/*-- 13.07.2004 09:07:08---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Sequence< datatransfer::DataFlavor > SwMailTransferable::getTransferDataFlavors( )
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< datatransfer::DataFlavor > aRet(1);
+ aRet[0].MimeType = m_aMimeType;
+ if( m_bIsBody )
+ {
+ aRet[0].DataType = getCppuType((::rtl::OUString*)0);
+ }
+ else
+ {
+ aRet[0].HumanPresentableName = m_aName;
+ aRet[0].DataType = getCppuType((uno::Sequence<sal_Int8>*)0);
+ }
+ return aRet;
+}
+/*-- 13.07.2004 09:07:08---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailTransferable::isDataFlavorSupported(
+ const datatransfer::DataFlavor& aFlavor )
+ throw (uno::RuntimeException)
+{
+ return (aFlavor.MimeType == ::rtl::OUString(m_aMimeType));
+}
+/*-- 28.04.2004 09:52:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Reference< beans::XPropertySetInfo > SwMailTransferable::getPropertySetInfo( ) throw(uno::RuntimeException)
+{
+ return uno::Reference< beans::XPropertySetInfo >();
+}
+/*-- 28.04.2004 09:52:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailTransferable::setPropertyValue( const ::rtl::OUString& , const uno::Any& )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+}
+/*-- 28.04.2004 09:52:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Any SwMailTransferable::getPropertyValue( const ::rtl::OUString& rPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ uno::Any aRet;
+ if( rPropertyName.equalsAscii( "URL" ) )
+ aRet <<= m_aURL;
+ return aRet;
+}
+/*-- 28.04.2004 09:52:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailTransferable::addPropertyChangeListener(
+ const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+}
+/*-- 28.04.2004 09:52:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailTransferable::removePropertyChangeListener(
+ const ::rtl::OUString&,
+ const uno::Reference< beans::XPropertyChangeListener >& )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+}
+/*-- 28.04.2004 09:52:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailTransferable::addVetoableChangeListener(
+ const ::rtl::OUString&,
+ const uno::Reference< beans::XVetoableChangeListener >& )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+}
+/*-- 28.04.2004 09:52:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailTransferable::removeVetoableChangeListener(
+ const ::rtl::OUString& ,
+ const uno::Reference< beans::XVetoableChangeListener >& )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+}
+
+/*-- 22.06.2004 16:46:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMessage::SwMailMessage() :
+ cppu::WeakComponentImplHelper1< mail::XMailMessage>(m_aMutex)
+{
+}
+/*-- 22.06.2004 16:46:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMessage::~SwMailMessage()
+{
+}
+/*-- 02.07.2007 16:00:07---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMessage::getSenderName() throw (uno::RuntimeException)
+{
+ return m_sSenderName;
+}
+/*-- 22.06.2004 16:46:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMessage::getSenderAddress() throw (uno::RuntimeException)
+{
+ return m_sSenderAddress;
+}
+/*-- 22.06.2004 16:46:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMessage::getReplyToAddress() throw (uno::RuntimeException)
+{
+ return m_sReplyToAddress;
+}
+/*-- 22.06.2004 16:46:07---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMessage::setReplyToAddress( const ::rtl::OUString& _replytoaddress ) throw (uno::RuntimeException)
+{
+ m_sReplyToAddress = _replytoaddress;
+}
+/*-- 22.06.2004 16:46:07---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMessage::getSubject() throw (uno::RuntimeException)
+{
+ return m_sSubject;
+}
+/*-- 22.06.2004 16:46:07---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMessage::setSubject( const ::rtl::OUString& _subject ) throw (uno::RuntimeException)
+{
+ m_sSubject = _subject;
+}
+/*-- 13.07.2004 09:57:18---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Reference< datatransfer::XTransferable > SwMailMessage::getBody() throw (uno::RuntimeException)
+{
+ return m_xBody;
+}
+/*-- 13.07.2004 09:57:18---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMessage::setBody(
+ const uno::Reference< datatransfer::XTransferable >& rBody )
+ throw (uno::RuntimeException)
+{
+ m_xBody = rBody;
+}
+/*-- 22.06.2004 16:46:08---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMessage::addRecipient( const ::rtl::OUString& rRecipientAddress )
+ throw (uno::RuntimeException)
+{
+ m_aRecipients.realloc(m_aRecipients.getLength() + 1);
+ m_aRecipients[m_aRecipients.getLength() - 1] = rRecipientAddress;
+}
+/*-- 22.06.2004 16:46:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMessage::addCcRecipient( const ::rtl::OUString& rRecipientAddress )
+ throw (uno::RuntimeException)
+{
+ m_aCcRecipients.realloc(m_aCcRecipients.getLength() + 1);
+ m_aCcRecipients[m_aCcRecipients.getLength() - 1] = rRecipientAddress;
+
+}
+/*-- 22.06.2004 16:46:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMessage::addBccRecipient( const ::rtl::OUString& rRecipientAddress ) throw (uno::RuntimeException)
+{
+ m_aBccRecipients.realloc(m_aBccRecipients.getLength() + 1);
+ m_aBccRecipients[m_aBccRecipients.getLength() - 1] = rRecipientAddress;
+}
+/*-- 22.06.2004 16:46:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Sequence< ::rtl::OUString > SwMailMessage::getRecipients( ) throw (uno::RuntimeException)
+{
+ return m_aRecipients;
+}
+/*-- 22.06.2004 16:46:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Sequence< ::rtl::OUString > SwMailMessage::getCcRecipients( ) throw (uno::RuntimeException)
+{
+ return m_aCcRecipients;
+}
+/*-- 22.06.2004 16:46:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Sequence< ::rtl::OUString > SwMailMessage::getBccRecipients( ) throw (uno::RuntimeException)
+{
+ return m_aBccRecipients;
+}
+/*-- 13.07.2004 09:59:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMessage::addAttachment( const mail::MailAttachment& rMailAttachment )
+ throw (uno::RuntimeException)
+{
+ m_aAttachments.realloc(m_aAttachments.getLength() + 1);
+ m_aAttachments[m_aAttachments.getLength() - 1] = rMailAttachment;
+}
+/*-- 13.07.2004 09:59:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Sequence< mail::MailAttachment > SwMailMessage::getAttachments( )
+ throw (uno::RuntimeException)
+{
+ return m_aAttachments;
+}
diff --git a/sw/source/ui/dbui/mailmergewizard.cxx b/sw/source/ui/dbui/mailmergewizard.cxx
new file mode 100644
index 000000000000..84dba4d979e6
--- /dev/null
+++ b/sw/source/ui/dbui/mailmergewizard.cxx
@@ -0,0 +1,339 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mailmergewizard.cxx,v $
+ * $Revision: 1.16 $
+ *
+ * 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 <mailmergewizard.hxx>
+#include <mmdocselectpage.hxx>
+#include <mmoutputtypepage.hxx>
+#include <mmaddressblockpage.hxx>
+#include <mmpreparemergepage.hxx>
+#include <mmmergepage.hxx>
+#include <mmgreetingspage.hxx>
+#include <mmoutputpage.hxx>
+#include <mmlayoutpage.hxx>
+#include <mmconfigitem.hxx>
+#include <swabstdlg.hxx>
+#ifndef _DBUI_HRC
+#include <dbui.hrc>
+#endif
+#include <view.hxx>
+#ifndef _DBMGR_HXX
+#include <dbmgr.hxx>
+#endif
+#include <sfx2/viewfrm.hxx>
+#include <wrtsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include "vcl/msgbox.hxx" // RET_CANCEL
+
+#include <helpid.h>
+#include <dbui.hrc>
+#include <mailmergewizard.hrc>
+
+using namespace svt;
+using namespace ::com::sun::star;
+/*-- 01.04.2004 16:52:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeWizard::SwMailMergeWizard(SwView& rView, SwMailMergeConfigItem& rItem) :
+ RoadmapWizard(&rView.GetViewFrame()->GetWindow(),
+ SW_RES(DLG_MAILMERGEWIZARD),
+ WZB_NEXT|WZB_PREVIOUS|WZB_FINISH|WZB_CANCEL|WZB_HELP),
+ m_pSwView(&rView),
+ m_bDocumentLoad( false ),
+ m_rConfigItem(rItem),
+ m_sStarting( SW_RES( ST_STARTING )),
+ m_sDocumentType( SW_RES( ST_DOCUMETNTYPE )),
+ m_sAddressBlock( SW_RES( ST_ADDRESSBLOCK )),
+ m_sAddressList( SW_RES( ST_ADDRESSLIST )),
+ m_sGreetingsLine( SW_RES( ST_GREETINGSLINE )),
+ m_sLayout( SW_RES( ST_LAYOUT )),
+ m_sPrepareMerge( SW_RES( ST_PREPAREMERGE )),
+ m_sMerge( SW_RES( ST_MERGE )),
+ m_sOutput( SW_RES( ST_OUTPUT )),
+ m_sFinish( SW_RES( ST_FINISH )),
+ m_nRestartPage( MM_DOCUMENTSELECTPAGE )
+{
+ FreeResource();
+ ShowButtonFixedLine(sal_True);
+ defaultButton(WZB_NEXT);
+ enableButtons(WZB_FINISH, sal_False);
+
+ m_pFinish->SetText(m_sFinish);
+ m_pNextPage->SetHelpId(HID_MM_NEXT_PAGE);
+ m_pPrevPage->SetHelpId(HID_MM_PREV_PAGE);
+
+ //#i51949# no output type page visible if e-Mail is not supported
+ if(rItem.IsMailAvailable())
+ declarePath(
+ 0,
+ MM_DOCUMENTSELECTPAGE,
+ MM_OUTPUTTYPETPAGE,
+ MM_ADDRESSBLOCKPAGE,
+ MM_GREETINGSPAGE,
+ MM_LAYOUTPAGE,
+ MM_PREPAREMERGEPAGE,
+ MM_MERGEPAGE,
+ MM_OUTPUTPAGE,
+ WZS_INVALID_STATE
+ );
+ else
+ declarePath(
+ 0,
+ MM_DOCUMENTSELECTPAGE,
+ MM_ADDRESSBLOCKPAGE,
+ MM_GREETINGSPAGE,
+ MM_LAYOUTPAGE,
+ MM_PREPAREMERGEPAGE,
+ MM_MERGEPAGE,
+ MM_OUTPUTPAGE,
+ WZS_INVALID_STATE
+ );
+
+ ActivatePage();
+ UpdateRoadmap();
+}
+/*-- 01.04.2004 16:52:53---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeWizard::~SwMailMergeWizard()
+{
+}
+/*-- 01.04.2004 16:52:53---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+OWizardPage* SwMailMergeWizard::createPage(WizardState _nState)
+{
+ OWizardPage* pRet = 0;
+ switch(_nState)
+ {
+ case MM_DOCUMENTSELECTPAGE : pRet = new SwMailMergeDocSelectPage(this); break;
+ case MM_OUTPUTTYPETPAGE : pRet = new SwMailMergeOutputTypePage(this); break;
+ case MM_ADDRESSBLOCKPAGE : pRet = new SwMailMergeAddressBlockPage(this); break;
+ case MM_GREETINGSPAGE : pRet = new SwMailMergeGreetingsPage(this); break;
+ case MM_LAYOUTPAGE : pRet = new SwMailMergeLayoutPage(this); break;
+ case MM_PREPAREMERGEPAGE : pRet = new SwMailMergePrepareMergePage(this); break;
+ case MM_MERGEPAGE : pRet = new SwMailMergeMergePage(this); break;
+ case MM_OUTPUTPAGE : pRet = new SwMailMergeOutputPage(this); break;
+ }
+ DBG_ASSERT(pRet, "no page created in ::createPage");
+ return pRet;
+}
+/*-- 04.06.2004 13:18:47---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeWizard::enterState( WizardState _nState )
+{
+ ::svt::RoadmapWizard::enterState( _nState );
+/*
+ entering a page after the layoutpage requires the insertion
+ of greeting and address block - if not yet done
+ entering the merge or output page requires to create the output document
+*/
+ if(_nState > MM_LAYOUTPAGE && m_rConfigItem.GetSourceView() &&
+ ((m_rConfigItem.IsAddressBlock() && !m_rConfigItem.IsAddressInserted()) ||
+ (m_rConfigItem.IsGreetingLine(sal_False) && !m_rConfigItem.IsGreetingInserted() )))
+ {
+ SwMailMergeLayoutPage::InsertAddressAndGreeting(m_rConfigItem.GetSourceView(),
+ m_rConfigItem, Point(-1, -1), true);
+ }
+ if(_nState >= MM_MERGEPAGE && !m_rConfigItem.GetTargetView())
+ {
+ CreateTargetDocument();
+ m_nRestartPage = _nState;
+ EndDialog(RET_TARGET_CREATED);
+ return;
+ }
+ else if(_nState < MM_MERGEPAGE && m_rConfigItem.GetTargetView())
+ {
+ //close the dialog, remove the target view, show the source view
+ m_nRestartPage = _nState;
+ //set ResultSet back to start
+ m_rConfigItem.MoveResultSet(1);
+ EndDialog(RET_REMOVE_TARGET);
+ return;
+ }
+ bool bEnablePrev = true;
+ bool bEnableNext = true;
+ switch(_nState)
+ {
+ case MM_DOCUMENTSELECTPAGE :
+ bEnablePrev = false;
+ break;
+ case MM_ADDRESSBLOCKPAGE :
+ bEnableNext = m_rConfigItem.GetResultSet().is();
+ break;
+ case MM_OUTPUTPAGE :
+ bEnableNext = false;
+ break;
+ }
+ enableButtons( WZB_PREVIOUS, bEnablePrev);
+ enableButtons( WZB_NEXT, bEnableNext);
+
+ UpdateRoadmap();
+}
+/*-- 04.06.2004 12:54:13---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+String SwMailMergeWizard::getStateDisplayName( WizardState _nState ) const
+{
+ String sRet;
+ switch(_nState)
+ {
+ case MM_DOCUMENTSELECTPAGE :sRet = m_sStarting; break;
+ case MM_OUTPUTTYPETPAGE : sRet = m_sDocumentType; break;
+ case MM_ADDRESSBLOCKPAGE :
+ sRet = m_rConfigItem.IsOutputToLetter() ?
+ m_sAddressBlock : m_sAddressList;
+
+ break;
+ case MM_GREETINGSPAGE : sRet = m_sGreetingsLine; break;
+ case MM_LAYOUTPAGE : sRet = m_sLayout; break;
+ case MM_PREPAREMERGEPAGE : sRet = m_sPrepareMerge; break;
+ case MM_MERGEPAGE : sRet = m_sMerge; break;
+ case MM_OUTPUTPAGE : sRet = m_sOutput; break;
+ }
+ return sRet;
+}
+/*-- 24.06.2004 09:24:45---------------------------------------------------
+ enables/disables pages in the roadmap depending on the current
+ page and state
+ -----------------------------------------------------------------------*/
+void SwMailMergeWizard::UpdateRoadmap()
+{
+/*
+ MM_DOCUMENTSELECTPAGE > inactive after the layoutpage
+ MM_OUTPUTTYPETPAGE : > inactive after the layoutpage
+ MM_ADDRESSBLOCKPAGE > inactive after the layoutpage
+ MM_GREETINGSPAGE > inactive after the layoutpage
+ MM_LAYOUTPAGE > inactive after the layoutpage
+ inactive if address block and greeting are switched off
+ or are already inserted into the source document
+ MM_PREPAREMERGEPAGE > only active if address data has been selected
+ inactive after preparemerge page
+ MM_MERGEPAGE > only active if address data has been selected
+
+ MM_OUTPUTPAGE > only active if address data has been selected
+*/
+
+ // enableState( <page id>, false );
+ const sal_uInt16 nCurPage = GetCurLevel();
+ TabPage* pCurPage = GetPage( nCurPage );
+ if(!pCurPage)
+ return;
+ bool bEnable = false;
+ bool bAddressFieldsConfigured = !m_rConfigItem.IsOutputToLetter() ||
+ !m_rConfigItem.IsAddressBlock() ||
+ m_rConfigItem.IsAddressFieldsAssigned();
+ bool bGreetingFieldsConfigured = !m_rConfigItem.IsGreetingLine(sal_False) ||
+ !m_rConfigItem.IsIndividualGreeting(sal_False)||
+ m_rConfigItem.IsGreetingFieldsAssigned();
+ //#i97436# if a document has to be loaded then enable output type page only
+ m_bDocumentLoad = false;
+ bool bEnableOutputTypePage = (nCurPage != MM_DOCUMENTSELECTPAGE) ||
+ static_cast<svt::OWizardPage*>(pCurPage)->commitPage( eValidate );
+
+ for(sal_uInt16 nPage = MM_DOCUMENTSELECTPAGE; nPage <= MM_OUTPUTPAGE; ++nPage)
+ {
+ switch(nPage)
+ {
+ case MM_DOCUMENTSELECTPAGE :
+ bEnable = sal_True;
+ break;
+ case MM_OUTPUTTYPETPAGE :
+ bEnable = bEnableOutputTypePage;
+ break;
+ case MM_ADDRESSBLOCKPAGE :
+ bEnable = !m_bDocumentLoad && bEnableOutputTypePage;
+ break;
+ case MM_GREETINGSPAGE :
+ bEnable = !m_bDocumentLoad && bEnableOutputTypePage &&
+ m_rConfigItem.GetResultSet().is() &&
+ bAddressFieldsConfigured;
+ break;
+ case MM_PREPAREMERGEPAGE :
+ case MM_MERGEPAGE :
+ case MM_OUTPUTPAGE :
+ case MM_LAYOUTPAGE :
+ bEnable = !m_bDocumentLoad && bEnableOutputTypePage &&
+ m_rConfigItem.GetResultSet().is() &&
+ bAddressFieldsConfigured &&
+ bGreetingFieldsConfigured;
+ if(MM_LAYOUTPAGE == nPage)
+ bEnable &=
+ ((m_rConfigItem.IsAddressBlock() && !m_rConfigItem.IsAddressInserted()) ||
+ (m_rConfigItem.IsGreetingLine(sal_False) && !m_rConfigItem.IsGreetingInserted() ));
+ break;
+ }
+ enableState( nPage, bEnable );
+ }
+}
+/*-- 24.06.2004 09:24:45---------------------------------------------------
+ enables/disables pages in the roadmap depending on the current
+ page and state
+ -----------------------------------------------------------------------*/
+void SwMailMergeWizard::CreateTargetDocument()
+{
+ GetSwView()->GetWrtShell().GetNewDBMgr()->
+ MergeDocuments( m_rConfigItem, *GetSwView() );
+ m_rConfigItem.SetMergeDone();
+ if( m_rConfigItem.GetTargetView() )
+ m_rConfigItem.GetTargetView()->GetViewFrame()->GetFrame()->Appear();
+}
+/*-- 23.08.2004 08:51:36---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeWizard::updateRoadmapItemLabel( WizardState _nState )
+{
+ svt::RoadmapWizard::updateRoadmapItemLabel( _nState );
+}
+
+// ------------------------------------------------------------------------
+
+short SwMailMergeWizard::Execute()
+{
+ DBG_ERROR( "SwMailMergeWizard cannot be executed via Dialog::Execute!\n"
+ "It creates a thread (MailDispatcher instance) that will call"
+ "back to VCL apartment => deadlock!\n"
+ "Use Dialog::StartExecuteModal to execute the dialog!" );
+ return RET_CANCEL;
+}
+
+// ------------------------------------------------------------------------
+
+void SwMailMergeWizard::StartExecuteModal( const Link& rEndDialogHdl )
+{
+ ::svt::RoadmapWizard::StartExecuteModal( rEndDialogHdl );
+}
diff --git a/sw/source/ui/dbui/mailmergewizard.hrc b/sw/source/ui/dbui/mailmergewizard.hrc
new file mode 100644
index 000000000000..14106184ef13
--- /dev/null
+++ b/sw/source/ui/dbui/mailmergewizard.hrc
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mailmergewizard.hrc,v $
+ * $Revision: 1.5 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#define ST_STARTING 1
+#define ST_DOCUMETNTYPE 2
+#define ST_ADDRESSBLOCK 3
+#define ST_GREETINGSLINE 4
+#define ST_LAYOUT 5
+#define ST_PREPAREMERGE 6
+#define ST_MERGE 7
+#define ST_OUTPUT 8
+#define ST_FINISH 9
+#define ST_ADDRESSLIST 10
diff --git a/sw/source/ui/dbui/mailmergewizard.src b/sw/source/ui/dbui/mailmergewizard.src
new file mode 100644
index 000000000000..220c31f029da
--- /dev/null
+++ b/sw/source/ui/dbui/mailmergewizard.src
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mailmergewizard.src,v $
+ * $Revision: 1.7 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <mailmergewizard.hrc>
+#include <dbui.hrc>
+
+ModalDialog DLG_MAILMERGEWIZARD
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Text [ en-US ] = "Mail Merge Wizard" ;
+ Moveable = TRUE ;
+
+ String ST_STARTING
+ {
+ Text [ en-US ] = "Select starting document";
+ };
+ String ST_DOCUMETNTYPE
+ {
+ Text [ en-US ] = "Select document type";
+ };
+ String ST_ADDRESSBLOCK
+ {
+ Text [ en-US ] = "Insert address block";
+ };
+ String ST_ADDRESSLIST
+ {
+ Text [ en-US ] = "Select address list";
+ };
+ String ST_GREETINGSLINE
+ {
+ Text [ en-US ] = "Create salutation";
+ };
+ String ST_LAYOUT
+ {
+ Text [ en-US ] = "Adjust layout";
+ };
+ String ST_PREPAREMERGE
+ {
+ Text [ en-US ] = "Edit document";
+ };
+ String ST_MERGE
+ {
+ Text [ en-US ] = "Personalize document";
+ };
+ String ST_OUTPUT
+ {
+ Text [ en-US ] = "Save, print or send";
+ };
+ String ST_FINISH
+ {
+ Text [ en-US ] = "~Finish";
+ };
+
+};
diff --git a/sw/source/ui/dbui/makefile.mk b/sw/source/ui/dbui/makefile.mk
new file mode 100644
index 000000000000..40d6807c2ead
--- /dev/null
+++ b/sw/source/ui/dbui/makefile.mk
@@ -0,0 +1,126 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.14 $
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=dbui
+LIBTARGET=no
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+# --- Files --------------------------------------------------------
+IMGLST_SRS=$(SRS)$/dbui.srs
+BMP_IN=$(PRJ)$/win/imglst
+
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ addresslistdialog.src \
+ createaddresslistdialog.src \
+ customizeaddresslistdialog.src \
+ dbinsdlg.src \
+ dbui.src \
+ dbtablepreviewdialog.src \
+ mailmergechildwindow.src \
+ mailmergewizard.src \
+ mmdocselectpage.src \
+ mmlayoutpage.src \
+ mmoutputpage.src \
+ mmoutputtypepage.src \
+ mmaddressblockpage.src \
+ mmgreetingspage.src \
+ mmmergepage.src \
+ mmpreparemergepage.src \
+ selectdbtabledialog.src \
+
+EXCEPTIONSFILES= \
+ $(SLO)$/addresslistdialog.obj \
+ $(SLO)$/createaddresslistdialog.obj \
+ $(SLO)$/customizeaddresslistdialog.obj \
+ $(SLO)$/dbinsdlg.obj \
+ $(SLO)$/dbmgr.obj \
+ $(SLO)$/dbtablepreviewdialog.obj \
+ $(SLO)$/dbtree.obj \
+ $(SLO)$/maildispatcher.obj \
+ $(SLO)$/mailmergechildwindow.obj \
+ $(SLO)$/mailmergehelper.obj \
+ $(SLO)$/mmaddressblockpage.obj \
+ $(SLO)$/mmconfigitem.obj \
+ $(SLO)$/mmlayoutpage.obj \
+ $(SLO)$/mmgreetingspage.obj \
+ $(SLO)$/mmoutputpage.obj
+
+SLOFILES = \
+ $(SLO)$/addresslistdialog.obj \
+ $(SLO)$/createaddresslistdialog.obj \
+ $(SLO)$/customizeaddresslistdialog.obj \
+ $(SLO)$/dbinsdlg.obj \
+ $(SLO)$/dbmgr.obj \
+ $(SLO)$/dbtree.obj \
+ $(SLO)$/dbtablepreviewdialog.obj \
+ $(SLO)$/maildispatcher.obj \
+ $(SLO)$/mailmergehelper.obj \
+ $(SLO)$/mailmergewizard.obj \
+ $(SLO)$/mailmergechildwindow.obj \
+ $(SLO)$/mmconfigitem.obj \
+ $(SLO)$/mmdocselectpage.obj \
+ $(SLO)$/mmlayoutpage.obj \
+ $(SLO)$/mmoutputpage.obj \
+ $(SLO)$/mmoutputtypepage.obj \
+ $(SLO)$/mmaddressblockpage.obj \
+ $(SLO)$/mmgreetingspage.obj \
+ $(SLO)$/mmmergepage.obj \
+ $(SLO)$/mmpreparemergepage.obj \
+ $(SLO)$/dbui.obj \
+ $(SLO)$/selectdbtabledialog.obj \
+ $(SLO)$/swdbtoolsclient.obj
+
+
+LIB1TARGET = $(SLB)$/$(TARGET).lib
+
+LIB1OBJFILES = \
+ $(SLO)$/dbmgr.obj \
+ $(SLO)$/dbtree.obj \
+ $(SLO)$/dbui.obj \
+ $(SLO)$/maildispatcher.obj \
+ $(SLO)$/mailmergehelper.obj \
+ $(SLO)$/mailmergechildwindow.obj \
+ $(SLO)$/mmconfigitem.obj \
+ $(SLO)$/swdbtoolsclient.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
new file mode 100644
index 000000000000..a15460737de5
--- /dev/null
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -0,0 +1,1830 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmaddressblockpage.cxx,v $
+ * $Revision: 1.25 $
+ *
+ * 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 <mmaddressblockpage.hxx>
+#include <mailmergewizard.hxx>
+#include <swtypes.hxx>
+#include <addresslistdialog.hxx>
+#include <svtools/xtextedt.hxx>
+#include <svtools/txtattr.hxx>
+#include <vcl/msgbox.hxx>
+#include <mmconfigitem.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+
+#include <vector>
+#include <mmaddressblockpage.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+using namespace svt;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+
+//-------------------------------------------------------------------------
+void lcl_Move(Control* pCtrl, long nYOffset)
+{
+ Point aPos(pCtrl->GetPosPixel());
+ aPos.Y() += nYOffset;
+ pCtrl->SetPosPixel(aPos);
+}
+/*-- 02.04.2004 12:46:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeAddressBlockPage::SwMailMergeAddressBlockPage( SwMailMergeWizard* _pParent) :
+ svt::OWizardPage(_pParent, SW_RES(DLG_MM_ADDRESSBLOCK_PAGE)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aHeaderFI( this, SW_RES( FI_HEADER ) ),
+ m_aFirstFI( this, SW_RES( FI_FIRST ) ),
+ m_aAddressListFI( this, SW_RES( FI_ADDRESSLIST ) ),
+ m_aAddressListPB( this, SW_RES( PB_ADDRESSLIST ) ),
+ m_aCurrentAddressFI( this, SW_RES( FI_CURRENTADDRESS ) ),
+ m_aFirstFL( this, SW_RES( FL_FIRST ) ),
+ m_aSecondFI( this, SW_RES( FI_SECOND )),
+ m_aSettingsFI( this, SW_RES( FI_SECOND ) ),
+ m_aAddressCB( this, SW_RES( CB_ADDRESS ) ),
+ m_aSettingsWIN( this, SW_RES( WIN_SETTINGS ) ),
+ m_aSettingsPB( this, SW_RES( PB_SETTINGS ) ),
+ m_aHideEmptyParagraphsCB( this, SW_RES( CB_HIDE_EMPTY_PARA ) ),
+ m_aSecondFL( this, SW_RES( FL_SECOND )),
+ m_aThirdFI( this, SW_RES( FI_THIRD ) ),
+ m_aMatchFieldsFI( this, SW_RES( FI_MATCH_FIELDS ) ),
+ m_aAssignPB( this, SW_RES( PB_ASSIGN ) ),
+ m_aThirdFL( this, SW_RES( FL_THIRD ) ),
+ m_aFourthFI( this, SW_RES( FI_FOURTH ) ),
+ m_aPreviewFI( this, SW_RES( FI_PREVIEW ) ),
+ m_aPreviewWIN( this, SW_RES( WIN_PREVIEW ) ),
+ m_aDocumentIndexFI( this, SW_RES( FI_DOCINDEX ) ),
+ m_aPrevSetIB( this, SW_RES( IB_PREVSET ) ),
+ m_aNextSetIB( this, SW_RES( IB_NEXTSET ) ),
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+ m_sDocument( SW_RES( STR_DOCUMENT ) ),
+ m_sChangeAddress( SW_RES( STR_CHANGEADDRESS )),
+ m_pWizard(_pParent)
+{
+ FreeResource();
+ m_sCurrentAddress = m_aCurrentAddressFI.GetText();
+ m_aAddressListPB.SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, AddressListHdl_Impl));
+ m_aSettingsPB.SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, SettingsHdl_Impl));
+ m_aAssignPB.SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, AssignHdl_Impl ));
+ m_aAddressCB.SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, AddressBlockHdl_Impl));
+ m_aSettingsWIN.SetSelectHdl(LINK(this, SwMailMergeAddressBlockPage, AddressBlockSelectHdl_Impl));
+ m_aHideEmptyParagraphsCB.SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, HideParagraphsHdl_Impl));
+
+ Link aLink = LINK(this, SwMailMergeAddressBlockPage, InsertDataHdl_Impl);
+ m_aPrevSetIB.SetClickHdl(aLink);
+ m_aNextSetIB.SetClickHdl(aLink);
+}
+/*-- 02.04.2004 12:46:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeAddressBlockPage::~SwMailMergeAddressBlockPage()
+{
+}
+/*-- 05.07.2004 13:55:15---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool SwMailMergeAddressBlockPage::canAdvance() const
+{
+ return m_pWizard->GetConfigItem().GetResultSet().is();
+}
+/*-- 16.06.2004 12:34:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeAddressBlockPage::ActivatePage()
+{
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ bool bIsLetter = rConfigItem.IsOutputToLetter();
+
+ //no address block is created for e-Mail
+ m_aSettingsFI.Show( bIsLetter );
+ m_aAddressCB.Show( bIsLetter );
+ m_aSettingsWIN.Show( bIsLetter );
+ m_aSettingsPB.Show( bIsLetter );
+ m_aPreviewFI.Show( bIsLetter );
+ m_aPreviewWIN.Show( bIsLetter );
+ m_aAssignPB.Show( bIsLetter );
+ m_aDocumentIndexFI.Show( bIsLetter );
+ m_aPrevSetIB.Show( bIsLetter );
+ m_aNextSetIB.Show( bIsLetter );
+ m_aHideEmptyParagraphsCB.Show( bIsLetter );
+ m_aSecondFL.Show( bIsLetter );
+ m_aSecondFI.Show( bIsLetter );
+ m_aSettingsFI.Show( bIsLetter );
+ m_aMatchFieldsFI.Show( bIsLetter );
+ m_aThirdFI.Show( bIsLetter );
+ m_aThirdFL.Show( bIsLetter );
+ m_aFourthFI.Show( bIsLetter );
+
+ if(bIsLetter)
+ {
+ m_aHideEmptyParagraphsCB.Check( rConfigItem.IsHideEmptyParagraphs() );
+ String sTemp(m_sDocument);
+ sTemp.SearchAndReplaceAscii("%1", String::CreateFromInt32(1));
+ m_aDocumentIndexFI.SetText(sTemp);
+
+ m_aSettingsWIN.Clear();
+ const uno::Sequence< ::rtl::OUString> aBlocks =
+ m_pWizard->GetConfigItem().GetAddressBlocks();
+ for(sal_Int32 nAddress = 0; nAddress < aBlocks.getLength(); ++nAddress)
+ m_aSettingsWIN.AddAddress(aBlocks[nAddress]);
+ m_aSettingsWIN.SelectAddress((sal_uInt16)rConfigItem.GetCurrentAddressBlockIndex());
+ m_aAddressCB.Check(rConfigItem.IsAddressBlock());
+ AddressBlockHdl_Impl(&m_aAddressCB);
+ m_aSettingsWIN.SetLayout(1, 2);
+ InsertDataHdl_Impl(0);
+ }
+}
+/*-- 27.05.2004 13:59:15---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeAddressBlockPage::commitPage( CommitPageReason _eReason )
+{
+ if ( eTravelForward == _eReason && !m_pWizard->GetConfigItem().GetResultSet().is() )
+ return sal_False;
+ return sal_True;
+}
+/*-- 07.04.2004 16:19:30---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeAddressBlockPage, AddressListHdl_Impl, PushButton*, EMPTYARG)
+{
+ SwAddressListDialog* pAddrDialog = new SwAddressListDialog(this);
+ if(RET_OK == pAddrDialog->Execute())
+ {
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ rConfigItem.SetCurrentConnection(
+ pAddrDialog->GetSource(),
+ pAddrDialog->GetConnection(),
+ pAddrDialog->GetColumnsSupplier(),
+ pAddrDialog->GetDBData());
+ ::rtl::OUString sFilter = pAddrDialog->GetFilter();
+ rConfigItem.SetFilter( sFilter );
+ InsertDataHdl_Impl(0);
+ GetWizard()->UpdateRoadmap();
+ GetWizard()->enableButtons(WZB_NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
+ }
+ delete pAddrDialog;
+ return 0;
+}
+/*-- 07.04.2004 16:19:30---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeAddressBlockPage, SettingsHdl_Impl, PushButton*, pButton)
+{
+ SwSelectAddressBlockDialog* pDlg =
+ new SwSelectAddressBlockDialog(pButton, m_pWizard->GetConfigItem());
+ SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
+ pDlg->SetAddressBlocks(rConfig.GetAddressBlocks(), m_aSettingsWIN.GetSelectedAddress());
+ pDlg->SetSettings(rConfig.IsIncludeCountry(), rConfig.GetExcludeCountry());
+ if(RET_OK == pDlg->Execute())
+ {
+ //the dialog provides the selected address at the first position!
+ const uno::Sequence< ::rtl::OUString> aBlocks =
+ pDlg->GetAddressBlocks();
+ rConfig.SetAddressBlocks(aBlocks);
+ m_aSettingsWIN.Clear();
+ for(sal_Int32 nAddress = 0; nAddress < aBlocks.getLength(); ++nAddress)
+ m_aSettingsWIN.AddAddress(aBlocks[nAddress]);
+ m_aSettingsWIN.SelectAddress(0);
+ m_aSettingsWIN.Invalidate(); // #i40408
+ rConfig.SetCountrySettings(pDlg->IsIncludeCountry(), pDlg->GetCountry());
+ InsertDataHdl_Impl(0);
+ }
+ delete pDlg;
+ GetWizard()->UpdateRoadmap();
+ GetWizard()->enableButtons(WZB_NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
+ return 0;
+}
+/*-- 07.04.2004 16:19:31---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeAddressBlockPage, AssignHdl_Impl, PushButton*, pButton)
+{
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ sal_uInt16 nSel = m_aSettingsWIN.GetSelectedAddress();
+ const uno::Sequence< ::rtl::OUString> aBlocks = rConfigItem.GetAddressBlocks();
+ SwAssignFieldsDialog* pDlg =
+ new SwAssignFieldsDialog(pButton, m_pWizard->GetConfigItem(), aBlocks[nSel], true);
+ if(RET_OK == pDlg->Execute())
+ {
+ //preview update
+ InsertDataHdl_Impl(0);
+ GetWizard()->UpdateRoadmap();
+ GetWizard()->enableButtons(WZB_NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
+ }
+ delete pDlg;
+ return 0;
+}
+/*-- 11.06.2004 13:37:22---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeAddressBlockPage::EnableAddressBlock(sal_Bool bAll, sal_Bool bSelective)
+{
+ m_aSettingsFI.Enable(bAll);
+ m_aAddressCB.Enable(bAll);
+ bSelective &= bAll;
+ m_aHideEmptyParagraphsCB.Enable(bSelective);
+ m_aSettingsWIN.Enable(bSelective);
+ m_aSettingsPB.Enable(bSelective);
+ m_aPreviewFI.Enable(bSelective);
+ m_aPreviewWIN.Enable(bSelective);
+ m_aThirdFI.Enable(bSelective);
+ m_aMatchFieldsFI.Enable(bSelective);
+ m_aAssignPB.Enable(bSelective);
+ m_aDocumentIndexFI.Enable(bSelective);
+ m_aPrevSetIB.Enable(bSelective);
+ m_aNextSetIB.Enable(bSelective);
+}
+/*-- 28.04.2004 12:45:58---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeAddressBlockPage, AddressBlockHdl_Impl, CheckBox*, pBox)
+{
+ EnableAddressBlock(pBox->IsEnabled(), pBox->IsChecked());
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ rConfigItem.SetAddressBlock(m_aAddressCB.IsChecked());
+ m_pWizard->UpdateRoadmap();
+ return 0;
+}
+/*-- 08.06.2004 13:00:29---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeAddressBlockPage, AddressBlockSelectHdl_Impl, SwAddressPreview*, EMPTYARG)
+{
+ sal_uInt16 nSel = m_aSettingsWIN.GetSelectedAddress();
+ const uno::Sequence< ::rtl::OUString> aBlocks =
+ m_pWizard->GetConfigItem().GetAddressBlocks();
+ String sPreview = SwAddressPreview::FillData(aBlocks[nSel], m_pWizard->GetConfigItem());
+ m_aPreviewWIN.SetAddress(sPreview);
+ m_pWizard->GetConfigItem().SetCurrentAddressBlockIndex( nSel );
+ GetWizard()->UpdateRoadmap();
+ GetWizard()->enableButtons(WZB_NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
+ return 0;
+}
+/*-- 31.08.2005 15:34:55---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeAddressBlockPage, HideParagraphsHdl_Impl, CheckBox*, pBox)
+{
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ rConfigItem.SetHideEmptyParagraphs( pBox->IsChecked() );
+ return 0;
+}
+
+// ------------------------------------------------------------------------------
+IMPL_LINK(SwMailMergeAddressBlockPage, InsertDataHdl_Impl, ImageButton*, pButton)
+{
+ //if no pButton is given, the first set has to be pre-set
+ SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
+ m_pWizard->EnterWait();
+ if(!pButton)
+ {
+ rConfig.GetResultSet();
+ }
+ else
+ {
+ BOOL bNext = pButton == &m_aNextSetIB;
+ sal_Int32 nPos = rConfig.GetResultSetPosition();
+ rConfig.MoveResultSet( bNext ? ++nPos : --nPos);
+ }
+ m_pWizard->LeaveWait();
+ sal_Int32 nPos = rConfig.GetResultSetPosition();
+ BOOL bEnable = TRUE;
+ if(nPos < 1)
+ {
+ bEnable = FALSE;
+ nPos = 1;
+ }
+ else
+ {
+ //if output type is letter
+ if(m_aSettingsWIN.IsVisible())
+ {
+ //Fill data into preview
+ sal_uInt16 nSel = m_aSettingsWIN.GetSelectedAddress();
+ const uno::Sequence< ::rtl::OUString> aBlocks =
+ m_pWizard->GetConfigItem().GetAddressBlocks();
+ String sPreview = SwAddressPreview::FillData(aBlocks[nSel], rConfig);
+ m_aPreviewWIN.SetAddress(sPreview);
+ }
+ }
+ 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);
+
+ GetWizard()->enableButtons(WZB_NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
+ sal_Bool bHasResultSet = rConfig.GetResultSet().is();
+ m_aCurrentAddressFI.Show(bHasResultSet);
+ if(bHasResultSet)
+ {
+ String sTmp = m_sCurrentAddress;
+ sTmp.SearchAndReplaceAscii("%1", rConfig.GetCurrentDBData().sDataSource );
+ m_aCurrentAddressFI.SetText(sTmp);
+ m_aAddressListPB.SetText(m_sChangeAddress);
+ }
+ EnableAddressBlock(bHasResultSet, m_aAddressCB.IsChecked());
+ return 0;
+}
+/*-- 13.04.2004 16:01:26---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwSelectAddressBlockDialog::SwSelectAddressBlockDialog(
+ Window* pParent, SwMailMergeConfigItem& rConfig) :
+ SfxModalDialog(pParent, SW_RES(DLG_MM_SELECTADDRESSBLOCK)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aSelectFT( this, SW_RES( FT_SELECT)),
+ m_aPreview( this, SW_RES( WIN_PREVIEW)),
+ m_aNewPB( this, SW_RES( PB_NEW)),
+ m_aCustomizePB( this, SW_RES( PB_CUSTOMIZE)),
+ m_aDeletePB( this, SW_RES( PB_DELETE)),
+ m_aSettingsFI( this, SW_RES( FI_SETTINGS)),
+ m_aNeverRB( this, SW_RES( RB_NEVER)),
+ m_aAlwaysRB( this, SW_RES( RB_ALWAYS)),
+ m_aDependentRB( this, SW_RES( RB_DEPENDENT)),
+ m_aCountryED( this, SW_RES( ED_COUNTRY)),
+ 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_rConfig(rConfig)
+{
+ FreeResource();
+
+ Link aCustomizeHdl = LINK(this, SwSelectAddressBlockDialog, NewCustomizeHdl_Impl);
+ m_aNewPB.SetClickHdl(aCustomizeHdl);
+ m_aCustomizePB.SetClickHdl(aCustomizeHdl);
+
+ m_aDeletePB.SetClickHdl(LINK(this, SwSelectAddressBlockDialog, DeleteHdl_Impl));
+
+ Link aLk = LINK(this, SwSelectAddressBlockDialog, IncludeHdl_Impl);
+ m_aNeverRB.SetClickHdl(aLk);
+ m_aAlwaysRB.SetClickHdl(aLk);
+ m_aDependentRB.SetClickHdl(aLk);
+ m_aPreview.SetLayout(2, 2);
+ m_aPreview.EnableScrollBar();
+}
+/*-- 13.04.2004 16:01:27---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwSelectAddressBlockDialog::~SwSelectAddressBlockDialog()
+{
+}
+/*-- 28.04.2004 11:48:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwSelectAddressBlockDialog::SetAddressBlocks(const uno::Sequence< ::rtl::OUString>& rBlocks,
+ sal_uInt16 nSelectedAddress)
+{
+ m_aAddressBlocks = rBlocks;
+ for(sal_Int32 nAddress = 0; nAddress < m_aAddressBlocks.getLength(); ++nAddress)
+ m_aPreview.AddAddress(m_aAddressBlocks[nAddress]);
+ m_aPreview.SelectAddress(nSelectedAddress);
+}
+/*-- 25.06.2004 10:51:36---------------------------------------------------
+ return the address blocks and put the selected one to the first position
+ -----------------------------------------------------------------------*/
+const uno::Sequence< ::rtl::OUString >& SwSelectAddressBlockDialog::GetAddressBlocks()
+{
+ //put the selected block to the first position
+ sal_uInt16 nSelect = m_aPreview.GetSelectedAddress();
+ if(nSelect)
+ {
+ uno::Sequence< ::rtl::OUString >aTemp = m_aAddressBlocks;
+ ::rtl::OUString* pTemp = aTemp.getArray();
+ pTemp[0] = m_aAddressBlocks[nSelect];
+ sal_uInt32 nIndex = 0;
+ const sal_uInt32 nNumBlocks = m_aAddressBlocks.getLength();
+ for(sal_uInt32 nAddress = 1; nAddress < nNumBlocks; ++nAddress)
+ {
+ if(nIndex == nSelect)
+ ++nIndex;
+ pTemp[nAddress] = m_aAddressBlocks[nIndex];
+ nIndex++;
+ }
+ m_aAddressBlocks = aTemp;
+ }
+ return m_aAddressBlocks;
+}
+/*-- 28.04.2004 11:48:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwSelectAddressBlockDialog::SetSettings(
+ sal_Bool bIsCountry, ::rtl::OUString rCountry)
+{
+ if(bIsCountry)
+ {
+ rCountry.getLength() ? m_aDependentRB.Check() : m_aAlwaysRB.Check();
+ m_aCountryED.SetText(rCountry);
+ }
+ else
+ m_aNeverRB.Check();
+ m_aDeletePB.Enable(m_aAddressBlocks.getLength() > 1);
+}
+/*-- 10.05.2004 11:17:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwSelectAddressBlockDialog::GetCountry() const
+{
+ ::rtl::OUString sRet;
+ if(m_aDependentRB.IsChecked())
+ sRet = m_aCountryED.GetText();
+ return sRet;
+}
+
+/*-- 13.04.2004 16:02:32---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwSelectAddressBlockDialog, DeleteHdl_Impl, PushButton*, pButton)
+{
+ if(m_aAddressBlocks.getLength())
+ {
+ sal_uInt16 nSelected = m_aPreview.GetSelectedAddress();
+ ::rtl::OUString* pAddressBlocks = m_aAddressBlocks.getArray();
+ sal_Int32 nSource = 0;
+ for(sal_Int32 nTarget = 0; nTarget < m_aAddressBlocks.getLength() - 1; nTarget++)
+ {
+ if(nSource == nSelected)
+ ++nSource;
+ pAddressBlocks[nTarget] = pAddressBlocks[nSource++];
+ }
+ m_aAddressBlocks.realloc(m_aAddressBlocks.getLength() - 1);
+ if(m_aAddressBlocks.getLength() <= 1)
+ pButton->Enable(sal_False);
+ m_aPreview.RemoveSelectedAddress();
+ }
+ return 0;
+}
+/*-- 13.04.2004 16:02:32---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwSelectAddressBlockDialog, NewCustomizeHdl_Impl, PushButton*, pButton)
+{
+ bool bCustomize = pButton == &m_aCustomizePB;
+ SwCustomizeAddressBlockDialog::DialogType nType = bCustomize ?
+ SwCustomizeAddressBlockDialog::ADDRESSBLOCK_EDIT :
+ SwCustomizeAddressBlockDialog::ADDRESSBLOCK_NEW;
+ SwCustomizeAddressBlockDialog *pDlg =
+ new SwCustomizeAddressBlockDialog(pButton,m_rConfig,nType);
+ if(bCustomize)
+ {
+ pDlg->SetAddress(m_aAddressBlocks[m_aPreview.GetSelectedAddress()]);
+ }
+ if(RET_OK == pDlg->Execute())
+ {
+ if(bCustomize)
+ {
+ ::rtl::OUString sNew = pDlg->GetAddress();
+ m_aPreview.ReplaceSelectedAddress(sNew);
+ m_aAddressBlocks[m_aPreview.GetSelectedAddress()] = sNew;
+ }
+ else
+ {
+ ::rtl::OUString sNew = pDlg->GetAddress();
+ m_aPreview.AddAddress(sNew);
+ m_aAddressBlocks.realloc(m_aAddressBlocks.getLength() + 1);
+ sal_uInt16 nSelect = (sal_uInt16)m_aAddressBlocks.getLength() - 1;
+ m_aAddressBlocks[nSelect] = sNew;
+ m_aPreview.SelectAddress(nSelect);
+ }
+ m_aDeletePB.Enable( m_aAddressBlocks.getLength() > 1);
+ }
+ delete pDlg;
+ return 0;
+}
+/*-- 13.04.2004 16:02:33---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwSelectAddressBlockDialog, IncludeHdl_Impl, RadioButton*, pButton)
+{
+ m_aCountryED.Enable(&m_aDependentRB == pButton);
+ return 0;
+}
+
+/* -----------------------------28.02.05 09:00--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwRestrictedComboBox::~SwRestrictedComboBox()
+{
+}
+/* -----------------------------28.02.05 09:00--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwRestrictedComboBox::KeyInput(const KeyEvent& rEvt)
+{
+ BOOL bCallParent = TRUE;
+ if(rEvt.GetCharCode())
+ {
+ String sKey = rEvt.GetCharCode();
+ if( STRING_NOTFOUND != sForbiddenChars.Search(sKey))
+ bCallParent = FALSE;
+ }
+ if(bCallParent)
+ ComboBox::KeyInput(rEvt);
+}
+/* -----------------------------28.02.05 09:00--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwRestrictedComboBox::Modify()
+{
+ Selection aSel = GetSelection();
+ String sTemp = GetText();
+ for(USHORT i = 0; i < sForbiddenChars.Len(); i++)
+ {
+ sTemp.EraseAllChars( sForbiddenChars.GetChar(i) );
+ }
+ USHORT nDiff = GetText().Len() - sTemp.Len();
+ if(nDiff)
+ {
+ aSel.setMin(aSel.getMin() - nDiff);
+ aSel.setMax(aSel.getMin());
+ SetText(sTemp);
+ SetSelection(aSel);
+ }
+ if(GetModifyHdl().IsSet())
+ GetModifyHdl().Call(this);
+}
+
+/*-- 13.04.2004 16:01:08---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+#define USER_DATA_SALUTATION -1
+#define USER_DATA_PUNCTUATION -2
+#define USER_DATA_TEXT -3
+#define USER_DATA_NONE -4
+
+SwCustomizeAddressBlockDialog::SwCustomizeAddressBlockDialog(
+ Window* pParent, SwMailMergeConfigItem& rConfig, DialogType eType) :
+ SfxModalDialog(pParent, SW_RES(DLG_MM_CUSTOMIZEADDRESSBLOCK)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aAddressElementsFT( this, SW_RES( FT_ADDRESSELEMENTS )),
+ m_aAddressElementsLB( this, SW_RES( LB_ADDRESSELEMENTS )),
+ m_aInsertFieldIB( this, SW_RES( IB_INSERTFIELD )),
+ m_aRemoveFieldIB( this, SW_RES( IB_REMOVEFIELD )),
+ m_aDragFT( this, SW_RES( FT_DRAG )),
+ m_aDragED( this, SW_RES( ED_DRAG )),
+ m_aUpIB( this, SW_RES( IB_UP )),
+ m_aLeftIB( this, SW_RES( IB_LEFT )),
+ m_aRightIB( this, SW_RES( IB_RIGHT )),
+ m_aDownIB( this, SW_RES( IB_DOWN )),
+ m_aFieldFT( this, SW_RES( FT_FIELD )),
+ m_aFieldCB( this, SW_RES( CB_FIELD )),
+ m_aPreviewFI( this, SW_RES( FI_PREVIEW )),
+ m_aPreviewWIN( this, SW_RES( WIN_PREVIEW )),
+ 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_rConfigItem(rConfig),
+ m_eType(eType)
+{
+ m_aFieldCB.SetForbiddenChars( String::CreateFromAscii("<>"));
+ m_aDragED.SetStyle(m_aDragED.GetStyle() |WB_NOHIDESELECTION);
+ if( eType >= GREETING_FEMALE )
+ {
+ m_aFieldFT.Show();
+ m_aFieldCB.Show();
+ SvLBoxEntry* pEntry = m_aAddressElementsLB.InsertEntry(String(SW_RES(ST_SALUTATION )));
+ pEntry->SetUserData((void*)(sal_Int32)USER_DATA_SALUTATION );
+ pEntry = m_aAddressElementsLB.InsertEntry(String(SW_RES(ST_PUNCTUATION)));
+ pEntry->SetUserData((void*)(sal_Int32)USER_DATA_PUNCTUATION );
+ pEntry = m_aAddressElementsLB.InsertEntry(String(SW_RES(ST_TEXT )));
+ pEntry->SetUserData((void*)(sal_Int32)USER_DATA_TEXT );
+ ResStringArray aSalutArr(SW_RES(
+ eType == GREETING_MALE ? RA_SALUTATION_MALE : RA_SALUTATION_FEMALE));
+ sal_uInt16 i;
+ for(i = 0; i < aSalutArr.Count(); ++i)
+ m_aSalutations.push_back(aSalutArr.GetString(i));
+ ResStringArray aPunctArr(SW_RES(RA_PUNCTUATION));
+ for(i = 0; i < aPunctArr.Count(); ++i)
+ m_aPunctuations.push_back(aPunctArr.GetString(i));
+ m_aDragED.SetText(String::CreateFromAscii(" "));
+ SetText( String( SW_RES( eType == GREETING_MALE ? ST_TITLE_MALE : ST_TITLE_FEMALE)));
+ m_aAddressElementsFT.SetText(String(SW_RES(ST_SALUTATIONELEMENTS)));
+ m_aInsertFieldIB.SetQuickHelpText(String(SW_RES(ST_INSERTSALUTATIONFIELD)));
+ m_aRemoveFieldIB.SetQuickHelpText(String(SW_RES(ST_REMOVESALUTATIONFIELD)));
+ m_aDragFT.SetText(String(SW_RES(ST_DRAGSALUTATION)));
+ }
+ else
+ {
+ if(eType == ADDRESSBLOCK_EDIT)
+ SetText(String(SW_RES(ST_TITLE_EDIT)));
+
+ //resize the preview
+ Point aFieldPos(m_aFieldFT.GetPosPixel());
+ long nDiff = m_aPreviewFI.GetPosPixel().Y() - aFieldPos.Y();
+ m_aPreviewFI.SetPosPixel(aFieldPos);
+ Size aPreviewSize = m_aPreviewWIN.GetSizePixel();
+ aPreviewSize.Height() += nDiff;
+ m_aPreviewWIN.SetSizePixel(aPreviewSize);
+ m_aPreviewWIN.SetPosPixel(m_aFieldCB.GetPosPixel());
+ m_aDragED.SetText(String::CreateFromAscii("\n\n\n\n\n"));
+ }
+ FreeResource();
+ const ResStringArray& rHeaders = m_rConfigItem.GetDefaultAddressHeaders();
+ for(USHORT i = 0; i < rHeaders.Count(); ++i)
+ {
+ const XubString& rHeader = rHeaders.GetString( i );
+ SvLBoxEntry* pEntry = m_aAddressElementsLB.InsertEntry(rHeader);
+ pEntry->SetUserData((void*)(sal_Int32)i);
+ }
+ m_aOK.SetClickHdl(LINK(this, SwCustomizeAddressBlockDialog, OKHdl_Impl));
+ m_aAddressElementsLB.SetSelectHdl(LINK(this, SwCustomizeAddressBlockDialog, ListBoxSelectHdl_Impl ));
+ m_aDragED.SetModifyHdl(LINK(this, SwCustomizeAddressBlockDialog, EditModifyHdl_Impl));
+ m_aDragED.SetSelectionChangedHdl( LINK( this, SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl));
+ Link aFieldsLink = LINK(this, SwCustomizeAddressBlockDialog, FieldChangeHdl_Impl);
+ m_aFieldCB.SetModifyHdl(aFieldsLink);
+ m_aFieldCB.SetSelectHdl(aFieldsLink);
+ Link aImgButtonHdl = LINK(this, SwCustomizeAddressBlockDialog, ImageButtonHdl_Impl);
+ m_aInsertFieldIB.SetClickHdl(aImgButtonHdl);
+ m_aRemoveFieldIB.SetClickHdl(aImgButtonHdl);
+ m_aUpIB.SetClickHdl(aImgButtonHdl);
+ m_aLeftIB.SetClickHdl(aImgButtonHdl);
+ m_aRightIB.SetClickHdl(aImgButtonHdl);
+ m_aDownIB.SetClickHdl(aImgButtonHdl);
+ UpdateImageButtons_Impl();
+}
+/*-- 13.04.2004 16:01:08---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwCustomizeAddressBlockDialog::~SwCustomizeAddressBlockDialog()
+{
+}
+/*-- 07.06.2004 13:51:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCustomizeAddressBlockDialog, OKHdl_Impl, OKButton*, EMPTYARG)
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+/*-- 24.06.2004 11:36:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCustomizeAddressBlockDialog, ListBoxSelectHdl_Impl, DDListBox*, pBox)
+{
+ sal_Int32 nUserData = (sal_Int32)(sal_IntPtr)pBox->FirstSelected()->GetUserData();
+ // Check if the selected entry is already in the address and then forbid inserting
+ m_aInsertFieldIB.Enable(nUserData >= 0 || !HasItem_Impl(nUserData));
+ return 0;
+}
+/*-- 25.06.2004 11:21:24---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCustomizeAddressBlockDialog, EditModifyHdl_Impl, AddressMultiLineEdit*, EMPTYARG)
+{
+ String sAddress = SwAddressPreview::FillData(
+ GetAddress(),
+ m_rConfigItem);
+ m_aPreviewWIN.SetAddress(sAddress);
+ UpdateImageButtons_Impl();
+ return 0;
+}
+/*-- 25.06.2004 12:14:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCustomizeAddressBlockDialog, ImageButtonHdl_Impl, ImageButton*, pButton)
+{
+ if(&m_aInsertFieldIB == pButton)
+ {
+ SvLBoxEntry* pEntry = m_aAddressElementsLB.GetCurEntry();
+ if(pEntry)
+ {
+ String sEntry = m_aAddressElementsLB.GetEntryText(pEntry);
+ sEntry.Insert('<', 0);
+ sEntry += '>';
+ m_aDragED.InsertNewEntry(sEntry);
+ }
+ }
+ else if(&m_aRemoveFieldIB == pButton)
+ {
+ m_aDragED.RemoveCurrentEntry();
+ }
+ else
+ {
+ sal_uInt16 nMove = MOVE_ITEM_DOWN;
+ if(&m_aUpIB == pButton)
+ nMove = MOVE_ITEM_UP;
+ else if(&m_aLeftIB == pButton)
+ nMove = MOVE_ITEM_LEFT;
+ else if(&m_aRightIB == pButton)
+ nMove = MOVE_ITEM_RIGHT;
+ m_aDragED.MoveCurrentItem(nMove);
+ }
+ UpdateImageButtons_Impl();
+ return 0;
+}
+/*-- 01.07.2004 09:27:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Int32 SwCustomizeAddressBlockDialog::GetSelectedItem_Impl()
+{
+ sal_Int32 nRet = USER_DATA_NONE;
+ String sSelected = m_aDragED.GetCurrentItem();
+ if(sSelected.Len())
+ for(ULONG i = 0; i < m_aAddressElementsLB.GetEntryCount(); ++i)
+ {
+ SvLBoxEntry* pEntry = m_aAddressElementsLB.GetEntry(i);
+ String sEntry = m_aAddressElementsLB.GetEntryText(pEntry);
+ if( sSelected.Equals( sEntry, 1, sSelected.Len() - 2 ) )
+ {
+ nRet = (sal_Int32)(sal_IntPtr)pEntry->GetUserData();
+ break;
+ }
+ }
+ return nRet;
+}
+/*-- 01.07.2004 10:01:19---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool SwCustomizeAddressBlockDialog::HasItem_Impl(sal_Int32 nUserData)
+{
+ //get the entry from the ListBox
+ String sEntry;
+ for(ULONG i = 0; i < m_aAddressElementsLB.GetEntryCount(); ++i)
+ {
+ SvLBoxEntry* pEntry = m_aAddressElementsLB.GetEntry(i);
+ if((sal_Int32)(sal_IntPtr)pEntry->GetUserData() == nUserData)
+ {
+ sEntry = m_aAddressElementsLB.GetEntryText(pEntry);
+ break;
+ }
+ }
+ //put it into '<>'
+ sEntry += '>';
+ sEntry.Insert( '<', 0);
+ //search for this entry in the content
+ String sText = m_aDragED.GetText();
+ bool bRet = sText.Search(sEntry) != STRING_NOTFOUND;
+ return bRet;
+}
+/*-- 25.06.2004 13:10:16---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl, AddressMultiLineEdit*, pEdit)
+{
+ // called in case the selection of the edit field changes.
+ // determine selection - if it's one of the editable fields then
+ // enable the related ComboBox and fill it
+ static bool bOnEntry = false;
+ if(bOnEntry)
+ return 0;
+
+ bOnEntry = true;
+ sal_Int32 nSelected = GetSelectedItem_Impl();
+ if(USER_DATA_NONE != nSelected)
+ pEdit->SelectCurrentItem();
+
+ if(m_aFieldCB.IsVisible() && (USER_DATA_NONE != nSelected) && (nSelected < 0))
+ {
+ //search in ListBox if it's one of the first entries
+ String sSelect;
+ ::std::vector<String>* pVector = 0;
+ switch(nSelected) {
+ case USER_DATA_SALUTATION:
+ sSelect = m_sCurrentSalutation;
+ pVector = &m_aSalutations;
+ break;
+ case USER_DATA_PUNCTUATION:
+ sSelect = m_sCurrentPunctuation;
+ pVector = &m_aPunctuations;
+ break;
+ case USER_DATA_TEXT:
+ sSelect = m_sCurrentText;
+ break;
+ }
+ m_aFieldCB.Clear();
+ if(pVector) {
+ ::std::vector<String>::iterator aIterator;
+ for( aIterator = pVector->begin(); aIterator != pVector->end(); ++aIterator)
+ m_aFieldCB.InsertEntry(*aIterator);
+ }
+ m_aFieldCB.SetText(sSelect);
+ m_aFieldCB.Enable(sal_True);
+ m_aFieldFT.Enable(sal_True);
+ }
+ else
+ {
+ m_aFieldCB.Enable(sal_False);
+ m_aFieldFT.Enable(sal_False);
+ }
+
+ UpdateImageButtons_Impl();
+ bOnEntry = false;
+ return 0;
+}
+/*-- 25.06.2004 13:36:29---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwCustomizeAddressBlockDialog, FieldChangeHdl_Impl, ComboBox*, EMPTYARG)
+{
+ //changing the field content changes the related members, too
+ sal_Int32 nSelected = GetSelectedItem_Impl();
+ String sContent = m_aFieldCB.GetText();
+ switch(nSelected) {
+ case USER_DATA_SALUTATION:
+ m_sCurrentSalutation = sContent;
+ break;
+ case USER_DATA_PUNCTUATION:
+ m_sCurrentPunctuation = sContent;
+ break;
+ case USER_DATA_TEXT:
+ m_sCurrentText = sContent;
+ break;
+ }
+ UpdateImageButtons_Impl();
+ m_aPreviewWIN.SetAddress(GetAddress());
+ m_aDragED.Modify();
+ return 0;
+}
+
+/*-- 25.06.2004 12:35:51---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwCustomizeAddressBlockDialog::UpdateImageButtons_Impl()
+{
+ sal_uInt16 nMove = m_aDragED.IsCurrentItemMoveable();
+ m_aUpIB.Enable(nMove & MOVE_ITEM_UP );
+ m_aLeftIB.Enable(nMove & MOVE_ITEM_LEFT );
+ m_aRightIB.Enable(nMove & MOVE_ITEM_RIGHT );
+ m_aDownIB.Enable(nMove & MOVE_ITEM_DOWN);
+ m_aRemoveFieldIB.Enable(m_aDragED.HasCurrentItem() ? sal_True : sal_False);
+ SvLBoxEntry* pEntry = m_aAddressElementsLB.GetCurEntry();
+ m_aInsertFieldIB.Enable( pEntry &&
+ (0 < (sal_Int32)(sal_IntPtr)pEntry->GetUserData() || m_aFieldCB.GetText().Len()));
+}
+/*-- 28.04.2004 12:04:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwCustomizeAddressBlockDialog::SetAddress(const ::rtl::OUString& rAddress)
+{
+ m_aDragED.SetText( rAddress );
+ UpdateImageButtons_Impl();
+ m_aDragED.Modify();
+}
+/*-- 28.04.2004 12:04:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwCustomizeAddressBlockDialog::GetAddress()
+{
+ String sAddress(m_aDragED.GetAddress());
+ //remove placeholders by the actual content
+ if(m_aFieldFT.IsVisible())
+ {
+ for(ULONG i = 0; i < m_aAddressElementsLB.GetEntryCount(); ++i)
+ {
+ SvLBoxEntry* pEntry = m_aAddressElementsLB.GetEntry(i);
+ String sEntry = m_aAddressElementsLB.GetEntryText(pEntry);
+ sEntry += '>';
+ sEntry.Insert('<', 0);
+ sal_Int32 nUserData = (sal_Int32)(sal_IntPtr)pEntry->GetUserData();
+ switch(nUserData)
+ {
+ case USER_DATA_SALUTATION : sAddress.SearchAndReplace(sEntry, m_sCurrentSalutation); break;
+ case USER_DATA_PUNCTUATION: sAddress.SearchAndReplace(sEntry, m_sCurrentPunctuation); break;
+ case USER_DATA_TEXT : sAddress.SearchAndReplace(sEntry, m_sCurrentText); break;
+ }
+ }
+ }
+ return sAddress;
+}
+/*-- 28.02.2005 11:03:35---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwCustomizeAddressBlockDialog::MoveFocus( Window* pMember, bool bNext )
+{
+ ::std::vector< Window* > aControls;
+
+ aControls.push_back(&m_aAddressElementsLB);
+ aControls.push_back(&m_aInsertFieldIB);
+ aControls.push_back(&m_aRemoveFieldIB);
+ aControls.push_back(&m_aDragED);
+ aControls.push_back(&m_aUpIB);
+ aControls.push_back(&m_aLeftIB);
+ aControls.push_back(&m_aRightIB);
+ aControls.push_back(&m_aDownIB);
+ aControls.push_back(&m_aFieldCB);
+ aControls.push_back(&m_aOK);
+ aControls.push_back(&m_aCancel);
+ aControls.push_back(&m_aHelp);
+
+ ::std::vector< Window* >::iterator aMemberIter = aControls.begin();
+ for( ; aMemberIter != aControls.end(); ++aMemberIter)
+ {
+ if(*aMemberIter == pMember)
+ break;
+ }
+ if( aMemberIter == aControls.end() )
+ {
+ DBG_ERROR( "Window not found?" );
+ return;
+ }
+
+ if( bNext )
+ {
+ ::std::vector< Window* >::iterator aSearch = aMemberIter;
+ ++aSearch;
+ while( true )
+ {
+ if( aSearch == aControls.end())
+ aSearch = aControls.begin();
+ else if( (*aSearch)->IsEnabled() )
+ {
+ (*aSearch)->GrabFocus();
+ break;
+ }
+ else
+ ++aSearch;
+ }
+ }
+ else
+ {
+ ::std::vector< Window* >::iterator aSearch = aMemberIter;
+ if(aSearch == aControls.begin())
+ aSearch = aControls.end();
+ while( true )
+ {
+ if(aSearch == aControls.begin())
+ aSearch = aControls.end();
+ else
+ --aSearch;
+ if( (*aSearch)->IsEnabled() )
+ {
+ (*aSearch)->GrabFocus();
+ break;
+ }
+ }
+ }
+
+}
+/*-- 13.04.2004 17:49:45---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwAssignFieldsControl : public Control
+{
+ friend class SwAssignFieldsDialog;
+ ScrollBar m_aVScroll;
+ HeaderBar m_aHeaderHB;
+ Window m_aWindow;
+
+ ::std::vector<FixedInfo*> m_aFieldNames;
+ ::std::vector<ListBox*> m_aMatches;
+ ::std::vector<FixedInfo*> m_aPreviews;
+
+ SwMailMergeConfigItem& m_rConfigItem;
+
+ Link m_aModifyHdl;
+
+ long m_nLBStartTopPos;
+ long m_nYOffset;
+ long m_nFirstYPos;
+
+ DECL_LINK(ScrollHdl_Impl, ScrollBar*);
+ DECL_LINK(MatchHdl_Impl, ListBox*);
+ DECL_LINK(GotFocusHdl_Impl, ListBox*);
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+
+ void MakeVisible( sal_Int32 nIndex );
+public:
+ SwAssignFieldsControl(Window* pParent, const ResId& rResId,
+ SwMailMergeConfigItem& rConfigItem);
+ ~SwAssignFieldsControl();
+
+ void SetModifyHdl(const Link& rModifyHdl)
+ {
+ m_aModifyHdl = rModifyHdl;
+ m_aModifyHdl.Call(this);
+ }
+};
+/*-- 13.04.2004 17:51:27---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+//-------------------------------------------------------------------------
+SwAssignFieldsControl::SwAssignFieldsControl(
+ Window* pParent, const ResId& rResId, SwMailMergeConfigItem& rConfigItem) :
+ Control(pParent, rResId),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aVScroll(this, ResId(SCR_1, *rResId.GetResMgr() )),
+ m_aHeaderHB(this, WB_BUTTONSTYLE | WB_BOTTOMBORDER),
+ m_aWindow(this, ResId(WIN_DATA, *rResId.GetResMgr())),
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+ m_rConfigItem(rConfigItem),
+ m_nLBStartTopPos(0),
+ m_nYOffset(0),
+ m_nFirstYPos(0)
+{
+ SetStyle(GetStyle()|WB_TABSTOP|WB_DIALOGCONTROL);
+ SetHelpId(HID_MM_ASSIGN_FIELDS);
+ long nHBHeight = m_aHeaderHB.CalcWindowSizePixel().Height();
+ Size aOutputSize(GetOutputSize());
+ m_aHeaderHB.SetSizePixel(
+ Size(aOutputSize.Width(), nHBHeight));
+ m_aHeaderHB.Show();
+ m_aWindow.SetPosPixel(Point( 0, nHBHeight) );
+ m_aWindow.SetSizePixel(Size(aOutputSize.Width() - m_aVScroll.GetSizePixel().Width(), aOutputSize.Height() - nHBHeight));
+ m_aWindow.Show();
+
+ //get the name of the default headers
+ const ResStringArray& rHeaders = rConfigItem.GetDefaultAddressHeaders();
+ //get the actual data
+ uno::Reference< XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), uno::UNO_QUERY);
+ //get the name of the actual columns
+ uno::Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
+ uno::Sequence< ::rtl::OUString > aFields;
+ if(xColAccess.is())
+ aFields = xColAccess->getElementNames();
+ const ::rtl::OUString* pFields = aFields.getConstArray();
+
+ //get the current assignment list
+ //each position in this sequence matches the position in the header array rHeaders
+ //if no assignment is available an empty sequence will be returned
+ uno::Sequence< ::rtl::OUString> aAssignments = rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
+ Link aMatchHdl = LINK(this, SwAssignFieldsControl, MatchHdl_Impl);
+ Link aFocusHdl = LINK(this, SwAssignFieldsControl, GotFocusHdl_Impl);
+ //fill the controls
+ for(USHORT i = 0; i < rHeaders.Count(); ++i)
+ {
+ const XubString& rHeader = rHeaders.GetString( i );
+ FixedInfo* pNewText = new FixedInfo(&m_aWindow, ResId( FT_FIELDS, *rResId.GetResMgr()));
+ String sLabel(String::CreateFromAscii("<>"));
+ sLabel.Insert(rHeader, 1);
+ pNewText->SetText(sLabel);
+ ListBox* pNewLB = new ListBox(&m_aWindow, ResId(LB_FIELDS, *rResId.GetResMgr()));
+ pNewLB->SetHelpId( HID_MM_HEADER_0 + i );
+ pNewLB->SelectEntryPos(0);
+ for(sal_Int32 nField = 0; nField < aFields.getLength(); ++nField)
+ pNewLB->InsertEntry(pFields[nField]);
+ FixedInfo* pNewPreview = new FixedInfo(&m_aWindow, ResId( FT_PREVIEW, *rResId.GetResMgr() ));
+ //select the ListBox
+ //if there is an assignment
+ if(aAssignments.getLength() > i && aAssignments[i].getLength())
+ pNewLB->SelectEntry(aAssignments[i]);
+ else //otherwise the current column name may match one of the db columns
+ pNewLB->SelectEntry(rHeader);
+ //then the preview can be filled accordingly
+ if(xColAccess.is() && pNewLB->GetSelectEntryPos() > 0 &&
+ xColAccess->hasByName(pNewLB->GetSelectEntry()))
+ {
+ uno::Any aCol = xColAccess->getByName(pNewLB->GetSelectEntry());
+ uno::Reference< XColumn > xColumn;
+ aCol >>= xColumn;
+ if(xColumn.is())
+ try
+ {
+ pNewPreview->SetText(xColumn->getString());
+ }
+ catch(SQLException& )
+ {
+ }
+ }
+ if(!i)
+ {
+ //determine the vertical offset, use the bottom position of the ListBox
+ m_nFirstYPos = m_nYOffset = pNewLB->GetPosPixel().Y();
+ m_nLBStartTopPos = m_nYOffset;
+ m_nYOffset += pNewLB->GetSizePixel().Height();
+ }
+
+ long nMove = m_nYOffset * i;
+ lcl_Move(pNewText, nMove);
+ lcl_Move(pNewLB, nMove);
+ lcl_Move(pNewPreview, nMove);
+ //set the select handler
+ pNewLB->SetSelectHdl(aMatchHdl);
+ pNewLB->SetGetFocusHdl(aFocusHdl);
+
+ m_aFieldNames.push_back(pNewText);
+ m_aMatches.push_back(pNewLB);
+ m_aPreviews.push_back(pNewPreview);
+ }
+ ListBox* pBottomBox = m_aMatches[rHeaders.Count() -1];
+ long nYBottom = pBottomBox->GetPosPixel().Y();
+ nYBottom += pBottomBox->GetDropDownPosSizePixel().GetHeight();
+ m_aVScroll.SetRange(Range(0, rHeaders.Count()));
+ m_aVScroll.SetPageSize((aOutputSize.Height() - nHBHeight - m_nLBStartTopPos)/ m_nYOffset);
+ m_aVScroll.EnableDrag();
+ m_aVScroll.SetVisibleSize(m_aVScroll.GetPageSize());
+ m_aVScroll.SetScrollHdl(LINK(this, SwAssignFieldsControl, ScrollHdl_Impl));
+
+ FreeResource();
+ m_aVScroll.SetPosPixel(Point(aOutputSize.Width() - m_aVScroll.GetSizePixel().Width(), nHBHeight));
+ m_aVScroll.SetSizePixel(Size(m_aVScroll.GetSizePixel().Width(), aOutputSize.Height() - nHBHeight));
+
+}
+/*-- 13.04.2004 17:51:28---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAssignFieldsControl::~SwAssignFieldsControl()
+{
+ ::std::vector<FixedInfo*>::iterator aFIIter;
+ for(aFIIter = m_aFieldNames.begin(); aFIIter != m_aFieldNames.end(); ++aFIIter)
+ delete *aFIIter;
+ ::std::vector<ListBox*>::iterator aLBIter;
+ for(aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter)
+ delete *aLBIter;
+ for(aFIIter = m_aPreviews.begin(); aFIIter != m_aPreviews.end(); ++aFIIter)
+ delete *aFIIter;
+}
+
+/*-- 07.05.2004 13:11:26---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAssignFieldsControl::Command( const CommandEvent& rCEvt )
+{
+ switch ( rCEvt.GetCommand() )
+ {
+ case COMMAND_WHEEL:
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ {
+ const CommandWheelData* pWheelData = rCEvt.GetWheelData();
+ if(pWheelData && !pWheelData->IsHorz() && COMMAND_WHEEL_ZOOM != pWheelData->GetMode())
+ {
+ HandleScrollCommand( rCEvt, 0, &m_aVScroll );
+ }
+ }
+ break;
+ default:
+ Control::Command(rCEvt);
+ }
+}
+/*-- 07.05.2004 13:11:21---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+long SwAssignFieldsControl::PreNotify( NotifyEvent& rNEvt )
+{
+ if(rNEvt.GetType() == EVENT_COMMAND)
+ {
+ const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
+ USHORT nCmd = pCEvt->GetCommand();
+ if( COMMAND_WHEEL == nCmd )
+ {
+ Command(*pCEvt);
+ return 1;
+ }
+ }
+ return Control::PreNotify(rNEvt);
+}
+/*-- 03.09.2004 13:19:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwAssignFieldsControl::MakeVisible( sal_Int32 nIndex )
+{
+ long nThumb = m_aVScroll.GetThumbPos();
+ long nPage = m_aVScroll.GetPageSize();
+ if(nThumb > nIndex)
+ m_aVScroll.SetThumbPos( nIndex );
+ else if( (nThumb + nPage) < nIndex)
+ m_aVScroll.SetThumbPos( nIndex - nPage );
+ else
+ return;
+ ScrollHdl_Impl( &m_aVScroll );
+}
+/*-- 30.04.2004 16:10:58---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAssignFieldsControl, ScrollHdl_Impl, ScrollBar*, pScroll)
+{
+ long nThumb = pScroll->GetThumbPos();
+ // the scrollbar moves on a per line basis
+ // the height of a line is stored in m_nYOffset
+ // nThumb determines which line has to be set at the top (m_nYOffset)
+ // The first line has to be -(nThumb * m_nYOffset) in the negative
+ long nMove = m_nFirstYPos - (*m_aMatches.begin())->GetPosPixel().Y() - (nThumb * m_nYOffset);
+
+ SetUpdateMode(FALSE);
+ long nIndex;
+ ::std::vector<FixedInfo*>::iterator aFIIter;
+ for(nIndex = 0, aFIIter = m_aFieldNames.begin(); aFIIter != m_aFieldNames.end(); ++aFIIter, ++nIndex)
+ lcl_Move(*aFIIter, nMove);
+ ::std::vector<ListBox*>::iterator aLBIter;
+ for(nIndex = 0, aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter, ++nIndex)
+ lcl_Move(*aLBIter, nMove);
+ for(nIndex = 0, aFIIter = m_aPreviews.begin(); aFIIter != m_aPreviews.end(); ++aFIIter, ++nIndex)
+ lcl_Move(*aFIIter, nMove);
+ SetUpdateMode(TRUE);
+
+ return 0;
+}
+
+/*-- 03.05.2004 15:37:52---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAssignFieldsControl, MatchHdl_Impl, ListBox*, pBox)
+{
+ String sColumn = pBox->GetSelectEntry();
+ uno::Reference< XColumnsSupplier > xColsSupp( m_rConfigItem.GetResultSet(), uno::UNO_QUERY);
+ uno::Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
+ ::rtl::OUString sPreview;
+ if(xColAccess.is() && xColAccess->hasByName(sColumn))
+ {
+ uno::Any aCol = xColAccess->getByName(sColumn);
+ uno::Reference< XColumn > xColumn;
+ aCol >>= xColumn;
+ if(xColumn.is())
+ {
+ try
+ {
+ sPreview = xColumn->getString();
+ }
+ catch( sdbc::SQLException& )
+ {
+ }
+ }
+ }
+ ::std::vector<ListBox*>::iterator aLBIter;
+ sal_Int32 nIndex = 0;
+ for(aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter, ++nIndex)
+ {
+ if(*aLBIter == pBox)
+ {
+ m_aPreviews[nIndex]->SetText(sPreview);
+ break;
+ }
+ }
+ m_aModifyHdl.Call(0);
+ return 0;
+}
+/*-- 03.09.2004 13:16:04---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAssignFieldsControl, GotFocusHdl_Impl, ListBox*, pBox)
+{
+ if(0 != (GETFOCUS_TAB & pBox->GetGetFocusFlags()))
+ {
+ sal_Int32 nIndex = 0;
+ ::std::vector<ListBox*>::iterator aLBIter;
+ for(aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter, ++nIndex)
+ {
+ if(*aLBIter == pBox)
+ {
+ MakeVisible(nIndex);
+ break;
+ }
+ }
+ }
+ return 0;
+}
+/*-- 13.04.2004 17:44:01---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAssignFieldsDialog::SwAssignFieldsDialog(
+ Window* pParent, SwMailMergeConfigItem& rConfigItem,
+ const ::rtl::OUString& rPreview,
+ bool bIsAddressBlock) :
+ SfxModalDialog(pParent, SW_RES(DLG_MM_ASSIGNFIELDS)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aMatchingFI( this, SW_RES( FI_MATCHING)),
+ m_pFieldsControl( new SwAssignFieldsControl(this, SW_RES( CT_FIELDS ), rConfigItem)),
+ m_aPreviewFI( this, SW_RES( FI_PREVIEW )),
+ m_aPreviewWIN( this, SW_RES( WIN_PREVIEW )),
+ 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_sNone(SW_RES(ST_NONE)),
+ m_rPreviewString(rPreview),
+ m_rConfigItem(rConfigItem)
+{
+ //resize the HeaderBar
+ String sAddressElement( SW_RES(ST_ADDRESSELEMENT ));
+ String sMatchesTo( SW_RES(ST_MATCHESTO ));
+ String sPreview( SW_RES(ST_PREVIEW ));
+ if(!bIsAddressBlock)
+ {
+ m_aPreviewFI.SetText(String(SW_RES(ST_SALUTATIONPREVIEW)));
+ m_aMatchingFI.SetText(String(SW_RES(ST_SALUTATIONMATCHING)));
+ sAddressElement = String(SW_RES(ST_SALUTATIONELEMENT));
+ }
+ FreeResource();
+ Size aOutputSize(m_pFieldsControl->m_aHeaderHB.GetSizePixel());
+ sal_Int32 nFirstWidth;
+ sal_Int32 nSecondWidth = nFirstWidth = aOutputSize.Width() / 3;
+ const WinBits nHeadBits = HIB_VCENTER | HIB_FIXED| HIB_FIXEDPOS;
+ m_pFieldsControl->m_aHeaderHB.InsertItem( 1, sAddressElement, nFirstWidth, nHeadBits|HIB_LEFT);
+ m_pFieldsControl->m_aHeaderHB.InsertItem( 2, sMatchesTo, nSecondWidth, nHeadBits|HIB_LEFT);
+ m_pFieldsControl->m_aHeaderHB.InsertItem( 3, sPreview,
+ aOutputSize.Width() - nFirstWidth - nSecondWidth, nHeadBits|HIB_LEFT);
+
+ m_pFieldsControl->SetModifyHdl(LINK(this, SwAssignFieldsDialog, AssignmentModifyHdl_Impl ));
+
+ String sMatching = m_aMatchingFI.GetText();
+ sMatching.SearchAndReplaceAscii("%1", sMatchesTo);
+ m_aMatchingFI.SetText(sMatching);
+
+ m_aOK.SetClickHdl(LINK(this, SwAssignFieldsDialog, OkHdl_Impl));
+}
+/*-- 13.04.2004 17:44:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwAssignFieldsDialog::~SwAssignFieldsDialog()
+{
+ delete m_pFieldsControl;
+}
+/*-- 05.05.2004 14:39:13---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+uno::Sequence< ::rtl::OUString > SwAssignFieldsDialog::CreateAssignments()
+{
+ uno::Sequence< ::rtl::OUString > aAssignments(
+ m_rConfigItem.GetDefaultAddressHeaders().Count());
+ ::rtl::OUString* pAssignments = aAssignments.getArray();
+ ::std::vector<ListBox*>::iterator aLBIter;
+ sal_Int32 nIndex = 0;
+ for(aLBIter = m_pFieldsControl->m_aMatches.begin();
+ aLBIter != m_pFieldsControl->m_aMatches.end();
+ ++aLBIter, ++nIndex)
+ {
+ String sSelect = (*aLBIter)->GetSelectEntry();
+ if(m_sNone != sSelect)
+ pAssignments[nIndex] = sSelect;
+ else
+ pAssignments[nIndex] = ::rtl::OUString();
+ }
+ return aAssignments;
+}
+/*-- 03.05.2004 18:04:00---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAssignFieldsDialog, OkHdl_Impl, PushButton*, EMPTYARG)
+{
+ m_rConfigItem.SetColumnAssignment(
+ m_rConfigItem.GetCurrentDBData(),
+ CreateAssignments() );
+ EndDialog(RET_OK);
+ return 0;
+}
+/*-- 05.05.2004 14:37:19---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwAssignFieldsDialog, AssignmentModifyHdl_Impl, void*, EMPTYARG)
+{
+ uno::Sequence< ::rtl::OUString > aAssignments = CreateAssignments();
+ String sPreview = SwAddressPreview::FillData(
+ m_rPreviewString, m_rConfigItem, &aAssignments);
+ m_aPreviewWIN.SetAddress(sPreview);
+ return 0;
+}
+
+/*-- 26.05.2004 11:20:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+DDListBox::DDListBox(SwCustomizeAddressBlockDialog* pParent, const ResId rResId) :
+ SvTreeListBox(pParent, rResId),
+ m_pParentDialog(pParent)
+{
+ SetWindowBits( /*WB_HASBUTTONS|WB_HASBUTTONSATROOT|*/
+ WB_CLIPCHILDREN );
+// SetSpaceBetweenEntries(3);
+ SetSelectionMode( SINGLE_SELECTION );
+ SetDragDropMode( SV_DRAGDROP_CTRL_COPY );
+ EnableAsyncDrag(TRUE);
+ SetHelpId(HID_MM_CUSTOMFIELDS);
+ // expand selection to the complete width of the ListBox
+ SetHighlightRange();
+ Show();
+
+}
+/*-- 26.05.2004 11:20:15---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+DDListBox::~DDListBox()
+{
+}
+/*-- 26.05.2004 11:20:16---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void DDListBox::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
+{
+ SvLBoxEntry* pEntry = GetCurEntry();
+ if(pEntry)
+ {
+ ReleaseMouse();
+
+ TransferDataContainer* pContainer = new TransferDataContainer;
+ uno::Reference<
+ datatransfer::XTransferable > xRef( pContainer );
+
+ sal_Int32 nUserData = (sal_Int32)(sal_IntPtr)pEntry->GetUserData();
+ //special entries can only be once in the address / greeting
+ if(nUserData >= 0 || !m_pParentDialog->HasItem_Impl(nUserData))
+ {
+ String sEntry;
+ sEntry = GetEntryText(pEntry);
+ sEntry.Insert('<', 0);
+ sEntry += '>';
+ if(sEntry.Len())
+ {
+ pContainer->CopyString( sEntry );
+ pContainer->StartDrag( this, DND_ACTION_COPY, GetDragFinishedHdl() );
+ }
+ }
+ }
+}
+/*-- 26.05.2004 13:14:53---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+AddressMultiLineEdit::AddressMultiLineEdit(SwCustomizeAddressBlockDialog* pParent, const ResId& rResId) :
+ MultiLineEdit(pParent, rResId),
+ m_pParentDialog(pParent)
+
+{
+ GetTextView()->SupportProtectAttribute(sal_True);
+ StartListening(*GetTextEngine());
+ //DisableSelectionOnFocus();
+ EnableFocusSelectionHide(FALSE);
+}
+/*-- 26.05.2004 13:14:53---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+AddressMultiLineEdit::~AddressMultiLineEdit()
+{
+ EndListening(*GetTextEngine());
+}
+/*-- 25.06.2004 13:02:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void AddressMultiLineEdit::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+{
+ if(rHint.ISA(TextHint) &&
+ static_cast<const TextHint&>(rHint).GetId() == TEXT_HINT_VIEWSELECTIONCHANGED &&
+ m_aSelectionLink.IsSet())
+ {
+ m_aSelectionLink.Call(this);
+ }
+}
+/*-- 26.05.2004 13:45:46---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+long AddressMultiLineEdit::PreNotify( NotifyEvent& rNEvt )
+{
+ long nHandled = 0;
+ if( EVENT_KEYINPUT == rNEvt.GetType() &&
+ rNEvt.GetKeyEvent()->GetCharCode())
+ {
+ const KeyEvent* pKEvent = rNEvt.GetKeyEvent();
+ if('\t' == pKEvent->GetCharCode() &&
+ 0 == (pKEvent->GetKeyCode().GetModifier() & (KEY_MOD1|KEY_MOD2)))
+ {
+ m_pParentDialog->MoveFocus(this, !pKEvent->GetKeyCode().IsShift());
+ }
+ nHandled = 1;
+ }
+ else if(EVENT_MOUSEBUTTONDOWN == rNEvt.GetType()) {
+ const MouseEvent *pMEvt = rNEvt.GetMouseEvent();
+ if(pMEvt->GetClicks() >= 2)
+ nHandled = 1;
+ }
+ if(!nHandled)
+ nHandled = MultiLineEdit::PreNotify( rNEvt );
+ return nHandled;
+
+}
+/*-- 25.06.2004 08:20:54---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void AddressMultiLineEdit::SetText( const String& rStr )
+{
+ MultiLineEdit::SetText(rStr);
+ //set attributes to all address tokens
+
+ ExtTextEngine* pTextEngine = GetTextEngine();
+ TextAttribProtect aProtectAttr;
+ ULONG nParaCount = pTextEngine->GetParagraphCount();
+ for(ULONG nPara = 0; nPara < nParaCount; ++nPara)
+ {
+ xub_StrLen nIndex = 0;
+ String sPara = pTextEngine->GetText( nPara );
+ if(sPara.Len() && sPara.GetChar(sPara.Len() - 1) != ' ')
+ {
+ TextPaM aPaM(nPara, sPara.Len());
+ pTextEngine->ReplaceText(TextSelection( aPaM ), String(' '));
+ }
+ while(true)
+ {
+ USHORT nStart = sPara.Search( '<', nIndex );
+ USHORT nEnd = sPara.Search( '>', nStart );
+ nIndex = nEnd;
+ if(nStart != STRING_NOTFOUND && nEnd != STRING_NOTFOUND)
+ pTextEngine->SetAttrib( aProtectAttr, nPara, nStart, nEnd + 1, FALSE );
+ else
+ break;
+ }
+
+ }
+ // add two empty paragraphs at the end
+ if(m_pParentDialog->m_eType == SwCustomizeAddressBlockDialog::ADDRESSBLOCK_NEW ||
+ m_pParentDialog->m_eType == SwCustomizeAddressBlockDialog::ADDRESSBLOCK_EDIT)
+ {
+ xub_StrLen nLastLen = pTextEngine->GetText(nParaCount - 1).Len();
+ if(nLastLen)
+ {
+ TextPaM aPaM(nParaCount ? nParaCount - 1 : 0, nLastLen);
+ pTextEngine->ReplaceText( TextSelection( aPaM ), String::CreateFromAscii("\n \n "));
+ }
+ }
+}
+
+/*-- 25.06.2004 12:32:41---------------------------------------------------
+ Insert the new entry in front of the entry at the beginning of the selection
+
+ -----------------------------------------------------------------------*/
+void AddressMultiLineEdit::InsertNewEntry( const String& rStr )
+{
+ // insert new entry after current selected one.
+ ExtTextView* pTextView = GetTextView();
+ const TextSelection& rSelection = pTextView->GetSelection();
+ ULONG nPara = rSelection.GetStart().GetPara();
+ USHORT nIndex = rSelection.GetEnd().GetIndex();
+ ExtTextEngine *pTextEngine = GetTextEngine();
+ const TextCharAttrib *pAttrib;
+ if(0 != (pAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED )))
+ nIndex = pAttrib->GetEnd();
+ InsertNewEntryAtPosition( rStr, nPara, nIndex );
+
+ // select the new entry
+ pAttrib = pTextEngine->FindCharAttrib(TextPaM(nPara, nIndex),TEXTATTR_PROTECTED);
+ TextSelection aEntrySel(TextPaM(nPara, nIndex), TextPaM(nPara, pAttrib->GetEnd()));
+ pTextView->SetSelection(aEntrySel);
+ Invalidate();
+ Modify();
+}
+
+void AddressMultiLineEdit::InsertNewEntryAtPosition( const String& rStr, ULONG nPara, USHORT nIndex )
+{
+ ExtTextEngine* pTextEngine = GetTextEngine();
+ TextPaM aInsertPos( nPara, nIndex );
+
+ pTextEngine->ReplaceText( aInsertPos, rStr );
+
+ //restore the attributes
+ SetText( GetAddress() );
+ //select the newly inserted/moved element
+ TextSelection aEntrySel(aInsertPos);
+ ExtTextView* pTextView = GetTextView();
+ pTextView->SetSelection(aEntrySel);
+ m_aSelectionLink.Call(this);
+}
+/*-- 25.06.2004 12:32:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void AddressMultiLineEdit::RemoveCurrentEntry()
+{
+ ExtTextEngine* pTextEngine = GetTextEngine();
+ ExtTextView* pTextView = GetTextView();
+ const TextSelection& rSelection = pTextView->GetSelection();
+ const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
+// const TextCharAttrib* pEndAttrib = pTextEngine->FindCharAttrib( rSelection.GetEnd(), TEXTATTR_PROTECTED );
+ if(pBeginAttrib &&
+ (pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex()
+ && pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()))
+ {
+ ULONG nPara = rSelection.GetStart().GetPara();
+ TextSelection aEntrySel(TextPaM( nPara, pBeginAttrib->GetStart()), TextPaM(nPara, pBeginAttrib->GetEnd()));
+ pTextEngine->ReplaceText(aEntrySel, String());
+ //restore the attributes
+ SetText( GetAddress() );
+ Modify();
+ }
+}
+/*-- 25.06.2004 12:32:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void AddressMultiLineEdit::MoveCurrentItem(sal_uInt16 nMove)
+{
+ ExtTextEngine* pTextEngine = GetTextEngine();
+ ExtTextView* pTextView = GetTextView();
+ const TextSelection& rSelection = pTextView->GetSelection();
+ const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
+ if(pBeginAttrib &&
+ (pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex()
+ && pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()))
+ {
+ //current item has been found
+ ULONG nPara = rSelection.GetStart().GetPara();
+ USHORT nIndex = pBeginAttrib->GetStart();
+ TextSelection aEntrySel(TextPaM( nPara, pBeginAttrib->GetStart()), TextPaM(nPara, pBeginAttrib->GetEnd()));
+ String sCurrentItem = pTextEngine->GetText(aEntrySel);
+ pTextEngine->RemoveAttrib( nPara, *pBeginAttrib );
+ pTextEngine->ReplaceText(aEntrySel, String());
+ switch(nMove)
+ {
+ case MOVE_ITEM_LEFT :
+ if(nIndex)
+ {
+ //go left to find a predecessor or simple text
+ --nIndex;
+ String sPara = pTextEngine->GetText( nPara );
+ xub_StrLen nSearchIndex = sPara.SearchBackward( '>', nIndex+1 );
+ if( nSearchIndex != STRING_NOTFOUND && nSearchIndex == nIndex )
+ {
+ nSearchIndex = sPara.SearchBackward( '<', nIndex );
+ if( nSearchIndex != STRING_NOTFOUND )
+ nIndex = nSearchIndex;
+ }
+ }
+ break;
+ case MOVE_ITEM_RIGHT:
+ {
+ //go right to find a successor or simple text
+ ++nIndex;
+ const TextCharAttrib* pEndAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
+ if(pEndAttrib && pEndAttrib->GetEnd() >= nIndex)
+ {
+ nIndex = pEndAttrib->GetEnd();
+ }
+ }
+ break;
+ case MOVE_ITEM_UP :
+ --nPara;
+ nIndex = 0;
+ break;
+ case MOVE_ITEM_DOWN :
+ ++nPara;
+ nIndex = 0;
+ break;
+ }
+ //add a new paragraph if there is none yet
+ if(nPara >= pTextEngine->GetParagraphCount())
+ {
+
+ TextPaM aTemp(nPara - 1, pTextEngine->GetTextLen( nPara - 1 ));
+ pTextEngine->ReplaceText( aTemp, String('\n'));
+ }
+ InsertNewEntryAtPosition( sCurrentItem, nPara, nIndex );
+
+ // select the new entry [#i40817]
+ const TextCharAttrib *pAttrib;
+ pAttrib = pTextEngine->FindCharAttrib(TextPaM(nPara, nIndex),TEXTATTR_PROTECTED);
+ aEntrySel = TextSelection(TextPaM(nPara, nIndex), TextPaM(nPara, pAttrib->GetEnd()));
+ pTextView->SetSelection(aEntrySel);
+ Invalidate();
+ Modify();
+ }
+}
+/*-- 25.06.2004 12:32:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_uInt16 AddressMultiLineEdit::IsCurrentItemMoveable()
+{
+ sal_uInt16 nRet = 0;
+ ExtTextEngine* pTextEngine = GetTextEngine();
+ ExtTextView* pTextView = GetTextView();
+ const TextSelection& rSelection = pTextView->GetSelection();
+ const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
+// const TextCharAttrib* pEndAttrib = pTextEngine->FindCharAttrib( rSelection.GetEnd(), TEXTATTR_PROTECTED );
+ if(pBeginAttrib &&
+ (pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex()
+ && pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()))
+ {
+ if(pBeginAttrib->GetStart())
+ nRet |= MOVE_ITEM_LEFT;
+ //if there is an entry it can always be move to the right and down
+ nRet |= MOVE_ITEM_RIGHT|MOVE_ITEM_DOWN;
+ if(rSelection.GetStart().GetPara() > 0)
+ nRet |= MOVE_ITEM_UP;
+ }
+ return nRet;
+}
+/*-- 25.06.2004 12:32:42---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool AddressMultiLineEdit::HasCurrentItem()
+{
+ ExtTextEngine* pTextEngine = GetTextEngine();
+ ExtTextView* pTextView = GetTextView();
+ const TextSelection& rSelection = pTextView->GetSelection();
+ const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
+ return (pBeginAttrib &&
+ (pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex()
+ && pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()));
+}
+/*-- 01.07.2004 09:07:44---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+String AddressMultiLineEdit::GetCurrentItem()
+{
+ String sRet;
+ ExtTextEngine* pTextEngine = GetTextEngine();
+ ExtTextView* pTextView = GetTextView();
+ const TextSelection& rSelection = pTextView->GetSelection();
+ const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
+ if(pBeginAttrib &&
+ (pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex()
+ && pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()))
+ {
+ ULONG nPara = rSelection.GetStart().GetPara();
+ TextSelection aEntrySel(TextPaM( nPara, pBeginAttrib->GetStart()), TextPaM(nPara, pBeginAttrib->GetEnd()));
+ sRet = pTextEngine->GetText( aEntrySel );
+ }
+ return sRet;
+}
+/*-- 05.07.2004 14:29:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void AddressMultiLineEdit::SelectCurrentItem()
+{
+ ExtTextEngine* pTextEngine = GetTextEngine();
+ ExtTextView* pTextView = GetTextView();
+ const TextSelection& rSelection = pTextView->GetSelection();
+ const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
+ if(pBeginAttrib &&
+ (pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex()
+ && pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()))
+ {
+ ULONG nPara = rSelection.GetStart().GetPara();
+ TextSelection aEntrySel(TextPaM( nPara, pBeginAttrib->GetStart()), TextPaM(nPara, pBeginAttrib->GetEnd()));
+ pTextView->SetSelection(aEntrySel);
+ Invalidate();
+ }
+}
+/*-- 25.06.2004 09:10:43---------------------------------------------------
+ returns the address
+ remove trailing spaces
+ and trailing empty paragraphs
+ -----------------------------------------------------------------------*/
+String AddressMultiLineEdit::GetAddress()
+{
+ String sRet;
+ ExtTextEngine* pTextEngine = GetTextEngine();
+ ULONG nParaCount = pTextEngine->GetParagraphCount();
+ for(ULONG nPara = nParaCount; nPara; --nPara)
+ {
+ String sPara = pTextEngine->GetText( nPara - 1);
+ sPara.EraseTrailingChars(' ');
+ //don't add empty trailing paragraphs
+ if(sRet.Len() || sPara.Len())
+ {
+ sRet.Insert(sPara, 0);
+ //insert the para break
+ if(nPara > 1)
+ sRet.Insert( '\n', 0);
+ }
+ }
+ return sRet;
+}
+
diff --git a/sw/source/ui/dbui/mmaddressblockpage.hrc b/sw/source/ui/dbui/mmaddressblockpage.hrc
new file mode 100644
index 000000000000..1b46cfd95f10
--- /dev/null
+++ b/sw/source/ui/dbui/mmaddressblockpage.hrc
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmaddressblockpage.hrc,v $
+ * $Revision: 1.6 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEADDRESSBLOCKPAGE_HRC
+#define _MAILMERGEADDRESSBLOCKPAGE_HRC
+
+#define FI_ADDRESSLIST 1
+#define PB_ADDRESSLIST 2
+#define FI_SETTINGS 3
+#define WIN_SETTINGS 4
+#define PB_SETTINGS 5
+#define CB_ADDRESS 6
+#define FI_PREVIEW 7
+#define WIN_PREVIEW 8
+#define PB_ASSIGN 9
+#define FI_DOCINDEX 10
+#define IB_PREVSET 11
+#define IB_NEXTSET 12
+#define STR_DOCUMENT 13
+#define FI_HEADER 14
+#define FI_CURRENTADDRESS 15
+#define STR_CHANGEADDRESS 16
+#define FI_SECOND 17
+#define FI_THIRD 18
+#define FI_MATCH_FIELDS 19
+
+#define FT_SELECT 20
+#define PB_NEW 21
+#define PB_DELETE 22
+#define PB_CUSTOMIZE 23
+
+#define RB_NEVER 25
+#define RB_ALWAYS 26
+#define RB_DEPENDENT 27
+#define ED_COUNTRY 28
+#define FL_SEPARATOR 29
+#define PB_OK 30
+#define PB_CANCEL 31
+#define PB_HELP 32
+
+#define FT_ADDRESSELEMENTS 40
+#define LB_ADDRESSELEMENTS 41
+#define IB_INSERTFIELD 42
+#define IB_REMOVEFIELD 43
+#define FT_DRAG 48
+#define ED_DRAG 49
+#define IB_UP 50
+#define IB_LEFT 51
+#define IB_RIGHT 52
+#define IB_DOWN 53
+#define FT_FIELD 54
+#define CB_FIELD 55
+#define ST_SALUTATION 56
+#define ST_PUNCTUATION 57
+#define ST_TEXT 58
+#define RA_SALUTATION_MALE 59
+#define RA_SALUTATION_FEMALE 60
+#define RA_PUNCTUATION 61
+#define ST_TITLE_MALE 62
+#define ST_TITLE_FEMALE 63
+#define ST_SALUTATIONELEMENTS 64
+#define ST_INSERTSALUTATIONFIELD 65
+#define ST_REMOVESALUTATIONFIELD 66
+#define ST_DRAGSALUTATION 67
+#define ST_TITLE_EDIT 68
+
+
+#define FI_MATCHING 70
+#define CT_FIELDS 71
+#define ST_SALUTATIONPREVIEW 72
+#define ST_SALUTATIONMATCHING 73
+#define ST_SALUTATIONELEMENT 74
+#define CB_HIDE_EMPTY_PARA 75
+#define FI_FIRST 76
+#define FL_FIRST 77
+#define FL_SECOND 78
+#define FL_THIRD 79
+#define FI_FOURTH 80
+
+#define SCR_1 1
+#define ST_ADDRESSELEMENT 2
+#define ST_MATCHESTO 3
+#define ST_PREVIEW 4
+#define FT_FIELDS 5
+#define LB_FIELDS 6
+#define FT_PREVIEW 7
+#define ST_NONE 8
+#define WIN_DATA 9
+
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmaddressblockpage.hxx b/sw/source/ui/dbui/mmaddressblockpage.hxx
new file mode 100644
index 000000000000..7d6c3ae81718
--- /dev/null
+++ b/sw/source/ui/dbui/mmaddressblockpage.hxx
@@ -0,0 +1,335 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmaddressblockpage.hxx,v $
+ * $Revision: 1.11 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEADDRESSBLOCKPAGE_HXX
+#define _MAILMERGEADDRESSBLOCKPAGE_HXX
+
+#include <svtools/wizardmachine.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <svtools/stdctrl.hxx>
+#include <mailmergehelper.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/lstbox.hxx>
+#include <svtools/svmedit.hxx>
+#include <svtools/headbar.hxx>
+#include <svtools/svtreebx.hxx>
+#include <vcl/combobox.hxx>
+#include <svtools/lstner.hxx>
+class SwMailMergeWizard;
+class SwMailMergeConfigItem;
+/*-- 13.04.2004 15:50:37---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwMailMergeAddressBlockPage : public svt::OWizardPage
+{
+ SwBoldFixedInfo m_aHeaderFI;
+ FixedInfo m_aFirstFI;
+ FixedInfo m_aAddressListFI;
+ PushButton m_aAddressListPB;
+ FixedInfo m_aCurrentAddressFI;
+
+ FixedLine m_aFirstFL;
+
+ FixedInfo m_aSecondFI;
+ FixedInfo m_aSettingsFI;
+ CheckBox m_aAddressCB;
+ SwAddressPreview m_aSettingsWIN;
+ PushButton m_aSettingsPB;
+
+ CheckBox m_aHideEmptyParagraphsCB;
+
+ FixedLine m_aSecondFL;
+
+ FixedInfo m_aThirdFI;
+ FixedInfo m_aMatchFieldsFI;
+
+ PushButton m_aAssignPB;
+
+ FixedLine m_aThirdFL;
+
+ FixedInfo m_aFourthFI;
+ FixedInfo m_aPreviewFI;
+
+ SwAddressPreview m_aPreviewWIN;
+ FixedInfo m_aDocumentIndexFI;
+ ImageButton m_aPrevSetIB;
+ ImageButton m_aNextSetIB;
+
+ String m_sDocument;
+ String m_sCurrentAddress;
+ String m_sChangeAddress;
+
+ SwMailMergeWizard* m_pWizard;
+
+ DECL_LINK(AddressListHdl_Impl, PushButton*);
+ DECL_LINK(SettingsHdl_Impl, PushButton*);
+ DECL_LINK(AssignHdl_Impl, PushButton*);
+ DECL_LINK(AddressBlockHdl_Impl, CheckBox*);
+ DECL_LINK(InsertDataHdl_Impl, ImageButton*);
+ DECL_LINK(AddressBlockSelectHdl_Impl, SwAddressPreview*);
+ DECL_LINK(HideParagraphsHdl_Impl, CheckBox*);
+
+ void EnableAddressBlock(sal_Bool bAll, sal_Bool bSelective);
+
+ virtual void ActivatePage();
+ virtual sal_Bool commitPage( CommitPageReason _eReason );
+ virtual bool canAdvance() const;
+
+public:
+ SwMailMergeAddressBlockPage( SwMailMergeWizard* _pParent);
+ ~SwMailMergeAddressBlockPage();
+
+ SwMailMergeWizard* GetWizard() { return m_pWizard;}
+};
+/*-- 13.04.2004 15:45:31---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwSelectAddressBlockDialog : public SfxModalDialog
+{
+ FixedText m_aSelectFT;
+ SwAddressPreview m_aPreview;
+ PushButton m_aNewPB;
+ PushButton m_aCustomizePB;
+ PushButton m_aDeletePB;
+
+ FixedInfo m_aSettingsFI;
+ RadioButton m_aNeverRB;
+ RadioButton m_aAlwaysRB;
+ RadioButton m_aDependentRB;
+ Edit m_aCountryED;
+
+ FixedLine m_aSeparatorFL;
+
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ com::sun::star::uno::Sequence< ::rtl::OUString> m_aAddressBlocks;
+ SwMailMergeConfigItem& m_rConfig;
+
+ DECL_LINK(NewCustomizeHdl_Impl, PushButton*);
+ DECL_LINK(DeleteHdl_Impl, PushButton*);
+ DECL_LINK(IncludeHdl_Impl, RadioButton*);
+
+ using Window::SetSettings;
+
+public:
+ SwSelectAddressBlockDialog(Window* pParent, SwMailMergeConfigItem& rConfig);
+ ~SwSelectAddressBlockDialog();
+
+ void SetAddressBlocks(const com::sun::star::uno::Sequence< ::rtl::OUString>& rBlocks,
+ sal_uInt16 nSelected);
+ const com::sun::star::uno::Sequence< ::rtl::OUString>& GetAddressBlocks();
+
+ void SetSettings(sal_Bool bIsCountry, ::rtl::OUString sCountry);
+ sal_Bool IsIncludeCountry() const {return !m_aNeverRB.IsChecked();}
+ ::rtl::OUString GetCountry() const;
+};
+
+
+/*-- 26.05.2004 11:16:25---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwCustomizeAddressBlockDialog;
+class DDListBox : public SvTreeListBox
+{
+ SwCustomizeAddressBlockDialog* m_pParentDialog;
+public:
+ DDListBox(SwCustomizeAddressBlockDialog* pParent, const ResId rResId);
+ ~DDListBox();
+
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+};
+/*-- 26.05.2004 11:16:25---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+#define MOVE_ITEM_LEFT 1
+#define MOVE_ITEM_RIGHT 2
+#define MOVE_ITEM_UP 4
+#define MOVE_ITEM_DOWN 8
+
+class AddressMultiLineEdit : public MultiLineEdit, public SfxListener
+{
+ Link m_aSelectionLink;
+ SwCustomizeAddressBlockDialog* m_pParentDialog;
+
+ using Window::Notify;
+
+ using MultiLineEdit::SetText;
+
+protected:
+ long PreNotify( NotifyEvent& rNEvt );
+public:
+ AddressMultiLineEdit(SwCustomizeAddressBlockDialog* pParent, const ResId& rResId);
+ ~AddressMultiLineEdit();
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ void SetSelectionChangedHdl( const Link& rLink ) {m_aSelectionLink = rLink;}
+
+ void SetText( const String& rStr );
+ String GetAddress();
+
+ void InsertNewEntry( const String& rStr );
+ void InsertNewEntryAtPosition( const String& rStr, ULONG nPara, USHORT nIndex );
+ void RemoveCurrentEntry();
+
+ void MoveCurrentItem(sal_uInt16 nMove);
+ sal_uInt16 IsCurrentItemMoveable();
+ bool HasCurrentItem();
+ String GetCurrentItem();
+ void SelectCurrentItem();
+};
+/*-- 13.04.2004 15:45:31---------------------------------------------------
+ Dialog is used to create custom address blocks as well as
+ custom greeting lines
+ -----------------------------------------------------------------------*/
+class SwRestrictedComboBox : public ComboBox
+{
+ String sForbiddenChars;
+
+protected:
+ virtual void KeyInput( const KeyEvent& );
+ virtual void Modify();
+public:
+ SwRestrictedComboBox(Window* pParent, const ResId& rResId):
+ ComboBox( pParent, rResId ){}
+
+ ~SwRestrictedComboBox();
+
+ void SetForbiddenChars(const String& rSet){sForbiddenChars = rSet;}
+
+};
+class SwCustomizeAddressBlockDialog : public SfxModalDialog
+{
+ friend class DDListBox;
+ friend class AddressMultiLineEdit;
+public:
+ enum DialogType
+ {
+ ADDRESSBLOCK_NEW,
+ ADDRESSBLOCK_EDIT,
+ GREETING_FEMALE,
+ GREETING_MALE
+ };
+private:
+ FixedText m_aAddressElementsFT;
+ DDListBox m_aAddressElementsLB;
+
+ ImageButton m_aInsertFieldIB;
+ ImageButton m_aRemoveFieldIB;
+
+ FixedText m_aDragFT;
+ AddressMultiLineEdit m_aDragED;
+ ImageButton m_aUpIB;
+ ImageButton m_aLeftIB;
+ ImageButton m_aRightIB;
+ ImageButton m_aDownIB;
+
+ FixedText m_aFieldFT;
+ SwRestrictedComboBox m_aFieldCB;
+
+ FixedInfo m_aPreviewFI;
+ SwAddressPreview m_aPreviewWIN;
+
+ FixedLine m_aSeparatorFL;
+
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ ::std::vector<String> m_aSalutations;
+ ::std::vector<String> m_aPunctuations;
+
+ String m_sCurrentSalutation;
+ String m_sCurrentPunctuation;
+ String m_sCurrentText;
+
+ SwMailMergeConfigItem& m_rConfigItem;
+ DialogType m_eType;
+
+ DECL_LINK(OKHdl_Impl, OKButton*);
+ DECL_LINK(ListBoxSelectHdl_Impl, DDListBox*);
+ DECL_LINK(EditModifyHdl_Impl, AddressMultiLineEdit*);
+ DECL_LINK(ImageButtonHdl_Impl, ImageButton*);
+ DECL_LINK(SelectionChangedHdl_Impl, AddressMultiLineEdit*);
+ DECL_LINK(FieldChangeHdl_Impl, ComboBox*);
+
+ bool HasItem_Impl(sal_Int32 nUserData);
+ sal_Int32 GetSelectedItem_Impl();
+ void UpdateImageButtons_Impl();
+ void MoveFocus( Window* pMember, bool bNext );
+
+public:
+ SwCustomizeAddressBlockDialog(Window* pParent, SwMailMergeConfigItem& rConfig, DialogType);
+ ~SwCustomizeAddressBlockDialog();
+
+ void SetAddress(const ::rtl::OUString& rAddress);
+ ::rtl::OUString GetAddress();
+};
+/*-- 13.04.2004 17:41:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwAssignFieldsControl;
+class SwAssignFieldsDialog : public SfxModalDialog
+{
+ FixedInfo m_aMatchingFI;
+ SwAssignFieldsControl* m_pFieldsControl;
+
+ FixedInfo m_aPreviewFI;
+ SwAddressPreview m_aPreviewWIN;
+
+ FixedLine m_aSeparatorFL;
+
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ String m_sNone;
+ ::rtl::OUString m_rPreviewString;
+
+ SwMailMergeConfigItem& m_rConfigItem;
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > CreateAssignments();
+ DECL_LINK(OkHdl_Impl, PushButton*);
+ DECL_LINK(AssignmentModifyHdl_Impl, void*);
+
+public:
+ SwAssignFieldsDialog(Window* pParent,
+ SwMailMergeConfigItem& rConfigItem,
+ const ::rtl::OUString& rPreview,
+ bool bIsAddressBlock);
+ ~SwAssignFieldsDialog();
+};
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmaddressblockpage.src b/sw/source/ui/dbui/mmaddressblockpage.src
new file mode 100644
index 000000000000..28acb9d48429
--- /dev/null
+++ b/sw/source/ui/dbui/mmaddressblockpage.src
@@ -0,0 +1,635 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmaddressblockpage.src,v $
+ * $Revision: 1.13 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <mmaddressblockpage.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+#define _ST_NONE_LIST \
+ StringList [en-US]= \
+ { \
+ < "< none >" ; > ; \
+ };
+
+
+TabPage DLG_MM_ADDRESSBLOCK_PAGE
+{
+ HelpID = HID_MM_ADDRESSBLOCKPAGE;
+ Size = MAP_APPFONT ( 260 , 250 ) ;
+ Hide = TRUE ;
+
+ FixedText FI_HEADER
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Insert address block";
+ };
+
+ FixedText FI_FIRST
+ {
+ Pos = MAP_APPFONT ( 6 , 27 ) ;
+ Size = MAP_APPFONT ( 10 , 8 ) ;
+ Text[ en-US ] = "1.";
+ };
+ FixedText FI_ADDRESSLIST
+ {
+ Pos = MAP_APPFONT ( 16 , 27 ) ;
+ Size = MAP_APPFONT ( 135 , 25 ) ;
+ WordBreak = TRUE;
+ Text[ en-US ] = "Select the address list containing the address data you want to use. This data is needed to create the address block.";
+ };
+ PushButton PB_ADDRESSLIST
+ {
+ Pos = MAP_APPFONT ( 154 , 27 ) ;
+ Size = MAP_APPFONT ( 100 , 14 ) ;
+ Text[ en-US ] = "Select A~ddress List...";
+ };
+ String STR_CHANGEADDRESS
+ {
+ Text[ en-US ] = "Select Different A~ddress List...";
+ };
+ FixedText FI_CURRENTADDRESS
+ {
+ Pos = MAP_APPFONT ( 154 , 44 ) ;
+ Size = MAP_APPFONT ( 100 , 8 ) ;
+ Hide = TRUE;
+ Text[ en-US ] = "Current address list: %1";
+ };
+ FixedLine FL_FIRST
+ {
+ Pos = MAP_APPFONT ( 6 , 55 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ };
+ FixedText FI_SECOND
+ {
+ Pos = MAP_APPFONT ( 6 , 66 ) ;
+ Size = MAP_APPFONT ( 10 , 8 ) ;
+ Text[ en-US ] = "2.";
+ };
+ CheckBox CB_ADDRESS
+ {
+ Pos = MAP_APPFONT ( 16 , 66 ) ;
+ Size = MAP_APPFONT ( 242 , 10 ) ;
+ Text[ en-US ] = "~This document shall contain an address block";
+ };
+ Window WIN_SETTINGS
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT ( 24 , 79 ) ;
+ Size = MAP_APPFONT ( 164 , 45 ) ;
+ };
+ PushButton PB_SETTINGS
+ {
+ Pos = MAP_APPFONT ( 194 , 110 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Group = FALSE;
+ Text[ en-US ] = "~More...";
+ };
+ CheckBox CB_HIDE_EMPTY_PARA
+ {
+ Pos = MAP_APPFONT ( 24 , 127 ) ;
+ Size = MAP_APPFONT ( 230 , 10 ) ;
+ Text[ en-US ] = "~Suppress lines with just empty fields";
+ };
+ FixedLine FL_SECOND
+ {
+ Pos = MAP_APPFONT ( 6 , 140 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ };
+ FixedText FI_THIRD
+ {
+ Pos = MAP_APPFONT ( 6 , 151 ) ;
+ Size = MAP_APPFONT ( 10 , 8 ) ;
+ Text[ en-US ] = "3.";
+ };
+ FixedText FI_MATCH_FIELDS
+ {
+ Pos = MAP_APPFONT ( 16 , 151 ) ;
+ Size = MAP_APPFONT ( 175 , 16 ) ;
+ WordBreak = TRUE;
+ Text[ en-US ] = "Match the field name used in the mail merge to the column headers in your data source.";
+ };
+ PushButton PB_ASSIGN
+ {
+ Pos = MAP_APPFONT ( 194 , 151 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text[ en-US ] = "Match ~Fields...";
+ };
+ FixedLine FL_THIRD
+ {
+ Pos = MAP_APPFONT ( 6 , 169 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ };
+ FixedText FI_FOURTH
+ {
+ Pos = MAP_APPFONT ( 6 , 180 ) ;
+ Size = MAP_APPFONT ( 10 , 8 ) ;
+ Text[ en-US ] = "4.";
+ };
+ FixedText FI_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 16 , 180 ) ;
+ Size = MAP_APPFONT ( 228 , 8 ) ;
+ Text[ en-US ] = "Check if the address data matches correctly.";
+ };
+ Window WIN_PREVIEW
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT ( 12 , 191 ) ;
+ Size = MAP_APPFONT ( 176 , 46 ) ;
+ };
+ FixedText FI_DOCINDEX
+ {
+ Pos = MAP_APPFONT ( 111 , 239 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Right = TRUE;
+ };
+ ImageButton IB_PREVSET
+ {
+ Pos = MAP_APPFONT ( 167 , 238 ) ;
+ Size = MAP_APPFONT ( 10 , 10 ) ;
+ SYMBOL = IMAGEBUTTON_PREV;
+ QuickHelpText[ en-US ] = "Preview Previous Address Block";
+ };
+ ImageButton IB_NEXTSET
+ {
+ Pos = MAP_APPFONT ( 178 , 238 ) ;
+ Size = MAP_APPFONT ( 10 , 10 ) ;
+ SYMBOL = IMAGEBUTTON_NEXT ;
+ QuickHelpText[ en-US ] = "Preview Next Address Block";
+ };
+ String STR_DOCUMENT
+ {
+ Text[ en-US ] = "Document: %1";
+ };
+};
+
+/*-- 13.04.2004 16:07:28---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+ModalDialog DLG_MM_SELECTADDRESSBLOCK
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_SELECTADDRESSBLOCK;
+ Size = MAP_APPFONT ( 260 , 219 ) ;
+ Moveable = TRUE ;
+
+ Text [ en-US ] = "Select Address Block";
+
+ FixedText FT_SELECT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 150 , 8 ) ;
+ Text[ en-US ] = "~Select your preferred address block";
+ };
+ Window WIN_PREVIEW
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 192 , 100 ) ;
+ DialogControl = TRUE;
+ };
+ PushButton PB_NEW
+ {
+ Pos = MAP_APPFONT ( 204 , 14 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "~New...";
+ };
+ PushButton PB_CUSTOMIZE
+ {
+ Pos = MAP_APPFONT ( 204 , 31 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "~Edit...";
+ };
+ PushButton PB_DELETE
+ {
+ Pos = MAP_APPFONT ( 204 , 48 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Group = FALSE;
+ Text[ en-US ] = "~Delete";
+ };
+
+ FixedText FI_SETTINGS
+ {
+ Pos = MAP_APPFONT ( 6 , 120 ) ;
+ Size = MAP_APPFONT ( 150 , 8 ) ;
+ Text[ en-US ] = "Address block settings";
+ };
+ RadioButton RB_NEVER
+ {
+ Pos = MAP_APPFONT ( 12 , 131 ) ;
+ Size = MAP_APPFONT ( 150 , 10 ) ;
+ Text[ en-US ] = "N~ever include the country/region";
+ };
+ RadioButton RB_ALWAYS
+ {
+ Pos = MAP_APPFONT ( 12 , 145 ) ;
+ Size = MAP_APPFONT ( 150 , 10 ) ;
+ Text[ en-US ] = "~Always include the country/region";
+ };
+ RadioButton RB_DEPENDENT
+ {
+ Pos = MAP_APPFONT ( 12 , 159 ) ;
+ Size = MAP_APPFONT ( 150 , 10 ) ;
+ Text[ en-US ] = "Only ~include the country/region if it is not:";
+ };
+ Edit ED_COUNTRY
+ {
+ Pos = MAP_APPFONT ( 18 , 172 ) ;
+ Size = MAP_APPFONT ( 180 , 12 ) ;
+ Border = TRUE;
+ };
+
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 188 ) ;
+ Size = MAP_APPFONT ( 260 , 8 ) ;
+ };
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 95 , 199 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 148 , 199 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 204 , 199 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
+/*-- 13.04.2004 16:07:28---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+
+#define WORKAROUND\
+ Text [ en-US ] = "New Address Block";
+
+
+ModalDialog DLG_MM_CUSTOMIZEADDRESSBLOCK
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_CUSTOMIZEADDRESSBLOCK;
+ Size = MAP_APPFONT ( 320 , 176 ) ;
+ Moveable = TRUE ;
+
+ WORKAROUND
+
+ String ST_TITLE_EDIT
+ {
+ Text [ en-US ] = "Edit Address Block";
+ };
+
+ String ST_TITLE_MALE
+ {
+ Text [ en-US ] = "Custom Salutation (Male Recipients)";
+ };
+ String ST_TITLE_FEMALE
+ {
+ Text [ en-US ] = "Custom Salutation (Female Recipients)";
+ };
+ FixedText FT_ADDRESSELEMENTS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text[ en-US ] = "Address ~elements" ;
+ };
+ String ST_SALUTATIONELEMENTS
+ {
+ Text[ en-US ] = "Salutation e~lements" ;
+ };
+ Control LB_ADDRESSELEMENTS
+ {
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 68 , 121 ) ;
+ TabStop = TRUE;
+ Border = TRUE;
+ };
+ ImageButton IB_INSERTFIELD
+ {
+ Pos = MAP_APPFONT ( 80 , 29 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Symbol = IMAGEBUTTON_ARROW_RIGHT;
+ QuickHelpText[ en-US ] = "Add to address";
+ };
+ String ST_INSERTSALUTATIONFIELD
+ {
+ Text[ en-US ] = "Add to salutation";
+ };
+ ImageButton IB_REMOVEFIELD
+ {
+ Pos = MAP_APPFONT ( 80 , 46 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Symbol = IMAGEBUTTON_ARROW_LEFT;
+ QuickHelpText[ en-US ] = "Remove from address";
+ };
+ String ST_REMOVESALUTATIONFIELD
+ {
+ Text[ en-US ] = "Remove from salutation";
+ };
+ FixedText FT_DRAG
+ {
+ Pos = MAP_APPFONT ( 100 , 3 ) ;
+ Size = MAP_APPFONT ( 210 , 8 ) ;
+ Text[ en-US ] = "1. Drag address elements here" ;
+ };
+ String ST_DRAGSALUTATION
+ {
+ Text[ en-US ] = "1. ~Drag salutation elements into the box below" ;
+ };
+ MultiLineEdit ED_DRAG
+ {
+ Pos = MAP_APPFONT ( 106 , 14 ) ;
+ Size = MAP_APPFONT ( 160 , 60 ) ;
+ Border = TRUE;
+ };
+ ImageButton IB_UP
+ {
+ Pos = MAP_APPFONT ( 285 , 14 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Symbol = IMAGEBUTTON_ARROW_UP;
+ QuickHelpText[ en-US ] = "Move up";
+ };
+ ImageButton IB_LEFT
+ {
+ Pos = MAP_APPFONT ( 270 , 29 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Symbol = IMAGEBUTTON_ARROW_LEFT;
+ QuickHelpText[ en-US ] = "Move left";
+ };
+ ImageButton IB_RIGHT
+ {
+ Pos = MAP_APPFONT ( 300 , 29 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Symbol = IMAGEBUTTON_ARROW_RIGHT;
+ QuickHelpText[ en-US ] = "Move right";
+ };
+ ImageButton IB_DOWN
+ {
+ Pos = MAP_APPFONT ( 285 , 48 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Symbol = IMAGEBUTTON_ARROW_DOWN;
+ QuickHelpText[ en-US ] = "Move down";
+ };
+ FixedText FT_FIELD
+ {
+ Pos = MAP_APPFONT ( 100 , 78 ) ;
+ Size = MAP_APPFONT ( 160 , 8 ) ;
+ Hide = TRUE;
+ Text[ en-US ] = "2. Customi~ze salutation";
+ };
+ ComboBox CB_FIELD
+ {
+ Pos = MAP_APPFONT ( 106 , 89 ) ;
+ Size = MAP_APPFONT ( 160 , 50 ) ;
+ Border = TRUE;
+ DropDown = TRUE;
+ Hide = TRUE;
+ };
+ FixedText FI_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 106 , 105 ) ;
+ Size = MAP_APPFONT ( 160 , 8 ) ;
+ Text[ en-US ] = "Preview";
+ };
+ Window WIN_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 106 , 116 ) ;
+ Size = MAP_APPFONT ( 160 , 19 ) ;
+ Border = TRUE;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 145 ) ;
+ Size = MAP_APPFONT ( 320 , 8 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 155 , 156 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 208 , 156 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 264 , 156 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String ST_SALUTATION
+ {
+ Text[ en-US ] = "Salutation";
+ };
+ String ST_PUNCTUATION
+ {
+ Text[ en-US ] = "Punctuation Mark";
+ };
+ String ST_TEXT
+ {
+ Text[ en-US ] = "Text";
+ };
+ StringArray RA_SALUTATION_MALE
+ {
+ ItemList =
+ {
+ < "Sehr geehrter Herr <2>," ; > ;
+ < "Lieber Herr <2>," ; > ;
+ < "Hallo Herr <2>," ; > ;
+ < "Hallo <1>," ; > ;
+ };
+ ItemList [en-US]=
+ {
+ < "Dear Mr. <2>," ; > ;
+ < "Mr. <2>," ; > ;
+ < "Dear <1>," ; > ;
+ < "Hello <1>," ; > ;
+ };
+ };
+ StringArray RA_SALUTATION_FEMALE
+ {
+ ItemList =
+ {
+ < "Sehr geehrte Frau <2>," ; > ;
+ < "Liebe Frau <2>," ; > ;
+ < "Hallo Frau <2>," ; > ;
+ < "Hallo <1>," ; > ;
+ };
+ ItemList [en-US]=
+ {
+ < "Dear Mrs. <2>," ; > ;
+ < "Ms. <2>," ; > ;
+ < "Dear <1>," ; > ;
+ < "Hello <1>," ; > ;
+ };
+ };
+ StringArray RA_PUNCTUATION
+ {
+ ItemList =
+ {
+ < "," ; > ;
+ < ":" ; > ;
+ < "!" ; > ;
+ < "(kein)" ; > ;
+ };
+ ItemList [en-US]=
+ {
+ < "," ; > ;
+ < ":" ; > ;
+ < "!" ; > ;
+ < "(none)" ; > ;
+ };
+ };
+};
+/*-- 13.04.2004 17:45:24---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+ModalDialog DLG_MM_ASSIGNFIELDS
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_ASSIGNFIELDS;
+ Size = MAP_APPFONT ( 260 , 245 ) ;
+ Moveable = TRUE ;
+
+ Text [ en-US ] = "Match Fields";
+
+ FixedText FI_MATCHING
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 240 , 20 ) ;
+ WordBreak = TRUE;
+ Text[ en-US ] = "Assign the fields from your data source to match the address elements." ;
+ };
+ String ST_SALUTATIONMATCHING
+ {
+ Text[ en-US ] = "Assign the fields from your data source to match the salutation elements." ;
+ };
+ Control CT_FIELDS
+ {
+ Pos = MAP_APPFONT ( 6 , 26 ) ;
+ Size = MAP_APPFONT ( 248 , 120 ) ;
+ Border = TRUE;
+ DialogControl = TRUE;
+ ScrollBar SCR_1
+ {
+ Pos = MAP_APPFONT ( 238 , 10 ) ;
+ Size = MAP_APPFONT ( 10 , 110 ) ;
+ };
+ FixedText FT_FIELDS
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 70 , 8 ) ;
+ };
+ Window WIN_DATA
+ {
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 248 , 120 ) ;
+ DialogControl = TRUE;
+ };
+ ListBox LB_FIELDS
+ {
+ Pos = MAP_APPFONT ( 83 , 4 ) ;
+ Size = MAP_APPFONT ( 74 , 50 ) ;
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ _ST_NONE_LIST
+ };
+ FixedText FT_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 165 , 6 ) ;
+ Size = MAP_APPFONT ( 70 , 8 ) ;
+ };
+ };
+ FixedText FI_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 6 , 152 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text[ en-US ] = "Address block preview";
+ };
+ String ST_SALUTATIONPREVIEW
+ {
+ Text[ en-US ] = "Salutation preview";
+ };
+ Window WIN_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 6 , 163 ) ;
+ Size = MAP_APPFONT ( 248 , 45 ) ;
+ Border = TRUE;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 214 ) ;
+ Size = MAP_APPFONT ( 260 , 8 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 95 , 225 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 148 , 225 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 204 , 225 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String ST_ADDRESSELEMENT
+ {
+ Text[ en-US ] = "Address elements" ;
+ };
+ String ST_SALUTATIONELEMENT
+ {
+ Text[ en-US ] = "Salutation elements" ;
+ };
+ String ST_MATCHESTO
+ {
+ Text[ en-US ] = "Matches to field:" ;
+ };
+ String ST_PREVIEW
+ {
+ Text[ en-US ] = "Preview" ;
+ };
+ String ST_NONE
+ {
+ Text [en-US] = "< none >";
+ };
+};
diff --git a/sw/source/ui/dbui/mmconfigitem.cxx b/sw/source/ui/dbui/mmconfigitem.cxx
new file mode 100644
index 000000000000..7438988a88fd
--- /dev/null
+++ b/sw/source/ui/dbui/mmconfigitem.cxx
@@ -0,0 +1,1987 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmconfigitem.cxx,v $
+ * $Revision: 1.18 $
+ *
+ * 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"
+#include <mmconfigitem.hxx>
+#include <swtypes.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include "com/sun/star/mail/MailServiceType.hpp"
+#include "com/sun/star/mail/XMailService.hpp"
+#include "com/sun/star/mail/MailServiceProvider.hpp"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <unotools/configitem.hxx>
+#include <mailmergehelper.hxx>
+#include <swunohelper.hxx>
+#ifndef _DBMGR_HXX
+#include <dbmgr.hxx>
+#endif
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <wrtsh.hxx>
+#include <dbui.hrc>
+#include <vector>
+
+#include <unomid.h>
+
+#define _SVSTDARR_STRINGSDTOR
+#include <svtools/svstdarr.hxx>
+
+using namespace utl;
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+
+const char* cAddressDataAssignments = "AddressDataAssignments";
+const char* cDBColumnAssignments = "DBColumnAssignments";
+const char* cDataSourceName = "DataSource/DataSourceName";
+const char* cDataTableName = "DataSource/DataTableName" ;
+const char* cDataCommandType = "DataSource/DataCommandType";
+
+#define SECURE_PORT 465
+#define DEFAULT_PORT 25
+#define POP_PORT 110
+
+/*-- 16.04.2004 09:41:36---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+struct DBAddressDataAssignment
+{
+ SwDBData aDBData;
+ Sequence< ::rtl::OUString> aDBColumnAssignments;
+ //if loaded the name of the node has to be saved
+ ::rtl::OUString sConfigNodeName;
+ //all created or changed assignments need to be stored
+ bool bColumnAssignmentsChanged;
+
+ DBAddressDataAssignment() :
+ bColumnAssignmentsChanged(false)
+ {}
+};
+
+/*-- 16.04.2004 09:43:29---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwMailMergeConfigItem_Impl : public utl::ConfigItem
+{
+ friend class SwMailMergeConfigItem;
+ Reference< XDataSource> xSource;
+ SharedConnection xConnection;
+ Reference< XColumnsSupplier> xColumnsSupplier;
+ Reference< XStatement> xStatement;
+ Reference< XResultSet> xResultSet;
+ SwDBData aDBData;
+ ::rtl::OUString sFilter;
+ sal_Int32 nResultSetCursorPos;
+
+ ::std::vector<DBAddressDataAssignment> aAddressDataAssignments;
+ ::std::vector< ::rtl::OUString> aAddressBlocks;
+ sal_Int32 nCurrentAddressBlock;
+ sal_Bool bIsAddressBlock;
+ sal_Bool bIsHideEmptyParagraphs;
+
+ sal_Bool bIsOutputToLetter;
+ sal_Bool bIncludeCountry;
+ ::rtl::OUString sExcludeCountry;
+
+ sal_Bool bIsGreetingLine;
+ sal_Bool bIsIndividualGreetingLine;
+ ::std::vector< ::rtl::OUString> aFemaleGreetingLines;
+ sal_Int32 nCurrentFemaleGreeting;
+ ::std::vector< ::rtl::OUString> aMaleGreetingLines;
+ sal_Int32 nCurrentMaleGreeting;
+ ::std::vector< ::rtl::OUString> aNeutralGreetingLines;
+ sal_Int32 nCurrentNeutralGreeting;
+ ::rtl::OUString sFemaleGenderValue;
+ uno::Sequence< ::rtl::OUString> aSavedDocuments;
+
+ sal_Bool bIsGreetingLineInMail;
+ sal_Bool bIsIndividualGreetingLineInMail;
+
+ //mail settings
+ ::rtl::OUString sMailDisplayName;
+ ::rtl::OUString sMailAddress;
+ ::rtl::OUString sMailReplyTo;
+ ::rtl::OUString sMailServer;
+ ::rtl::OUString sMailUserName;
+ ::rtl::OUString sMailPassword;
+
+ sal_Bool bIsSMPTAfterPOP;
+ ::rtl::OUString sInServerName;
+ sal_Int16 nInServerPort;
+ sal_Bool bInServerPOP;
+ ::rtl::OUString sInServerUserName;
+ ::rtl::OUString sInServerPassword;
+
+ sal_Int16 nMailPort;
+ sal_Bool bIsMailReplyTo;
+ sal_Bool bIsDefaultPort;
+ sal_Bool bIsSecureConnection;
+ sal_Bool bIsAuthentication;
+
+ sal_Bool bIsEMailSupported;
+
+ ResStringArray m_AddressHeaderSA;
+
+ //these addresses are not stored in the configuration
+ ::std::vector< SwDocMergeInfo > aMergeInfos;
+
+ //we do overwrite the usersettings in a special case
+ //than we do remind the usersettings here
+ sal_Bool bUserSettingWereOverwritten;
+ sal_Bool bIsAddressBlock_LastUserSetting;
+ sal_Bool bIsGreetingLineInMail_LastUserSetting;
+ sal_Bool bIsGreetingLine_LastUserSetting;
+
+
+ const Sequence< ::rtl::OUString>& GetPropertyNames();
+
+public:
+ SwMailMergeConfigItem_Impl();
+ ~SwMailMergeConfigItem_Impl();
+
+ virtual void Commit();
+
+ const Sequence< ::rtl::OUString>
+ GetAddressBlocks(sal_Bool bConvertToConfig = sal_False) const;
+ void SetAddressBlocks(
+ const Sequence< ::rtl::OUString>& rBlocks,
+ sal_Bool bConvertFromConfig = sal_False);
+ const uno::Sequence< ::rtl::OUString>
+ GetGreetings(SwMailMergeConfigItem::Gender eType,
+ sal_Bool bConvertToConfig = sal_False) const;
+ void SetGreetings(SwMailMergeConfigItem::Gender eType,
+ const uno::Sequence< ::rtl::OUString>& rBlocks,
+ sal_Bool bConvertFromConfig = sal_False);
+
+ void SetCurrentAddressBlockIndex( sal_Int32 nSet );
+ sal_Int32 GetCurrentAddressBlockIndex() const
+ { return nCurrentAddressBlock; }
+ sal_Int32 GetCurrentGreeting(SwMailMergeConfigItem::Gender eType) const;
+ void SetCurrentGreeting(SwMailMergeConfigItem::Gender eType, sal_Int32 nIndex);
+
+};
+
+/*-- 06.05.2004 12:51:54---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() :
+ ConfigItem(C2U("Office.Writer/MailMergeWizard"), 0),
+ nResultSetCursorPos(-1),
+ nCurrentAddressBlock(0),
+ bIsAddressBlock(sal_True),
+ bIsHideEmptyParagraphs(sal_False),
+ bIsOutputToLetter(sal_True),
+ bIncludeCountry(sal_False),
+ bIsGreetingLine(sal_True),
+ nCurrentFemaleGreeting(0),
+ nCurrentMaleGreeting(0),
+ nCurrentNeutralGreeting(0),
+
+ bIsSMPTAfterPOP(sal_False),
+ nInServerPort( POP_PORT ),
+ bInServerPOP( sal_True ),
+ nMailPort(0),
+ bIsMailReplyTo(sal_False),
+ bIsDefaultPort(sal_False),
+ bIsSecureConnection(sal_False),
+ bIsAuthentication(sal_False),
+
+ bIsEMailSupported(sal_False),
+ m_AddressHeaderSA( SW_RES( SA_ADDRESS_HEADER )),
+ bUserSettingWereOverwritten(sal_False),
+ bIsAddressBlock_LastUserSetting(sal_False),
+ bIsGreetingLineInMail_LastUserSetting(sal_False),
+ bIsGreetingLine_LastUserSetting(sal_False)
+{
+ const Sequence<OUString>& rNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(rNames);
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == rNames.getLength())
+ {
+ for(int nProp = 0; nProp < rNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] >>= bIsOutputToLetter; break;
+ case 1: pValues[nProp] >>= bIncludeCountry; break;
+ case 2: pValues[nProp] >>= sExcludeCountry; break;
+ case 3:
+ {
+ Sequence< ::rtl::OUString> aBlocks;
+ pValues[nProp] >>= aBlocks;
+ SetAddressBlocks(aBlocks, sal_True);
+ }
+ break;
+ case 4: pValues[nProp] >>= bIsAddressBlock; break;
+ case 5: pValues[nProp] >>= bIsGreetingLine; break;
+ case 6: pValues[nProp] >>= bIsIndividualGreetingLine; break;
+ case 7 :
+ case 8 :
+ case 9 :
+ {
+ Sequence< ::rtl::OUString> aGreetings;
+ pValues[nProp] >>= aGreetings;
+ SetGreetings(SwMailMergeConfigItem::Gender(
+ SwMailMergeConfigItem::FEMALE + nProp - 7), aGreetings, sal_True);
+ }
+ break;
+
+ case 10: pValues[nProp] >>= nCurrentFemaleGreeting; break;
+ case 11: pValues[nProp] >>= nCurrentMaleGreeting; break;
+ case 12: pValues[nProp] >>= nCurrentNeutralGreeting; break;
+ case 13: pValues[nProp] >>= sFemaleGenderValue; break;
+ case 14: pValues[nProp] >>= sMailDisplayName; break;
+ case 15: pValues[nProp] >>= sMailAddress; break;
+ case 16: pValues[nProp] >>= bIsMailReplyTo; break;
+ case 17: pValues[nProp] >>= sMailReplyTo; break;
+ case 18: pValues[nProp] >>= sMailServer; break;
+ case 19:
+ bIsDefaultPort =
+ (pValues[nProp] >>= nMailPort) ?
+ sal_False : sal_True;
+ break;
+ case 20: pValues[nProp] >>= bIsSecureConnection; break;
+ case 21: pValues[nProp] >>= bIsAuthentication; break;
+ case 22: pValues[nProp] >>= sMailUserName; break;
+ case 23: pValues[nProp] >>= sMailPassword; break;
+ case 24 :pValues[nProp] >>= aDBData.sDataSource; break;
+ case 25 :pValues[nProp] >>= aDBData.sCommand; break;
+ case 26 :
+ {
+ short nTemp = 0;
+ if(pValues[nProp] >>= nTemp)
+ aDBData.nCommandType = nTemp;
+ }
+ break;
+ case 27: pValues[nProp] >>= sFilter; break;
+ case 28: pValues[nProp] >>= aSavedDocuments; break;
+ case 29:
+ pValues[nProp] >>= bIsEMailSupported;
+ break;
+ case 30: pValues[nProp] >>= bIsGreetingLineInMail; break;
+ case 31: pValues[nProp] >>= bIsIndividualGreetingLineInMail; break;
+ case 32: pValues[nProp] >>= bIsSMPTAfterPOP; break;
+ case 33: pValues[nProp] >>= sInServerName; break;
+ case 34: pValues[nProp] >>= nInServerPort; break;
+ case 35: pValues[nProp] >>= bInServerPOP; break;
+ case 36: pValues[nProp] >>= sInServerUserName; break;
+ case 37: pValues[nProp] >>= sInServerPassword; break;
+ case 38: pValues[nProp] >>= bIsHideEmptyParagraphs; break;
+ case 39: pValues[nProp] >>= nCurrentAddressBlock; break;
+ }
+ }
+ }
+ //read the list of data base assignments
+ Sequence<OUString> aAssignments = GetNodeNames(C2U(cAddressDataAssignments));
+ if(aAssignments.getLength())
+ {
+ //create a list of property names to load the URLs of all data bases
+ const OUString* pAssignments = aAssignments.getConstArray();
+ Sequence< ::rtl::OUString > aAssignProperties(4 * aAssignments.getLength());
+ ::rtl::OUString* pAssignProperties = aAssignProperties.getArray();
+ sal_Int32 nAssign;
+ OUString sSlash = C2U("/");
+ for(nAssign = 0; nAssign < aAssignProperties.getLength(); nAssign += 4)
+ {
+ String sAssignPath = C2U(cAddressDataAssignments);
+ sAssignPath += '/';
+ sAssignPath += String(pAssignments[nAssign / 4]);
+ sAssignPath += '/';
+ pAssignProperties[nAssign] = sAssignPath;
+ pAssignProperties[nAssign] += C2U(cDataSourceName);
+ pAssignProperties[nAssign + 1] = sAssignPath;
+ pAssignProperties[nAssign + 1] += C2U(cDataTableName);
+ pAssignProperties[nAssign + 2] = sAssignPath;
+ pAssignProperties[nAssign + 2] += C2U(cDataCommandType);
+ pAssignProperties[nAssign + 3] = sAssignPath;
+ pAssignProperties[nAssign + 3] += C2U(cDBColumnAssignments);
+ }
+ Sequence<Any> aAssignValues = GetProperties(aAssignProperties);
+ const Any* pAssignValues = aAssignValues.getConstArray();
+ for(nAssign = 0; nAssign < aAssignValues.getLength(); nAssign += 4 )
+ {
+ DBAddressDataAssignment aAssignment;
+ pAssignValues[nAssign] >>= aAssignment.aDBData.sDataSource;
+ pAssignValues[nAssign + 1] >>= aAssignment.aDBData.sCommand;
+ pAssignValues[nAssign + 2] >>= aAssignment.aDBData.nCommandType;
+ pAssignValues[nAssign + 3] >>= aAssignment.aDBColumnAssignments;
+ aAssignment.sConfigNodeName = pAssignments[nAssign / 4];
+ aAddressDataAssignments.push_back(aAssignment);
+ }
+ }
+ //check if the saved documents still exist
+ if(aSavedDocuments.getLength())
+ {
+ uno::Sequence< ::rtl::OUString > aTempDocuments(aSavedDocuments.getLength());
+ ::rtl::OUString* pTempDocuments = aTempDocuments.getArray();
+ sal_Int32 nIndex = 0;
+ for(sal_Int32 i = 0; i < aSavedDocuments.getLength(); ++i)
+ {
+ if(SWUnoHelper::UCB_IsFile( aSavedDocuments[i] ))
+ {
+ pTempDocuments[nIndex++] = aSavedDocuments[i];
+ }
+ }
+ if(nIndex < aSavedDocuments.getLength())
+ {
+ aSavedDocuments = aTempDocuments;
+ aSavedDocuments.realloc(nIndex);
+ }
+ }
+
+}
+/*-- 06.05.2004 12:51:54---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeConfigItem_Impl::~SwMailMergeConfigItem_Impl()
+{
+}
+/*-- 13.03.2006 12:12:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem_Impl::SetCurrentAddressBlockIndex( sal_Int32 nSet )
+{
+ if(aAddressBlocks.size() >= sal::static_int_cast<sal_uInt32, sal_Int32>(nSet))
+ {
+ nCurrentAddressBlock = nSet;
+ SetModified();
+ }
+}
+/*-- 16.04.2004 13:06:07---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+OUString lcl_CreateNodeName(Sequence<OUString>& rAssignments )
+{
+ const OUString* pNames = rAssignments.getConstArray();
+ sal_Int32 nStart = rAssignments.getLength();
+ OUString sNewName;
+ bool bFound;
+ do
+ {
+ bFound = false;
+ sNewName = C2U("_");
+ sNewName += OUString::valueOf(nStart);
+ //search if the name exists
+ for(sal_Int32 nAssign = 0; nAssign < rAssignments.getLength(); ++nAssign)
+ {
+ if(pNames[nAssign] == sNewName)
+ {
+ bFound = true;
+ ++nStart;
+ break;
+ }
+ }
+ }
+ while(bFound);
+ // add the new name to the array of existing names
+ rAssignments.realloc(rAssignments.getLength() + 1);
+ rAssignments.getArray()[rAssignments.getLength() - 1] = sNewName;
+ return sNewName;
+}
+// --------------------------------------------------------------------------------
+void lcl_ConvertToNumbers(OUString& rBlock, const ResStringArray& rHeaders )
+{
+ //convert the strings used for UI to numbers used for the configuration
+ String sBlock(rBlock);
+ sBlock.SearchAndReplaceAllAscii("\n", String::CreateFromAscii("\\n"));
+ for(USHORT i = 0; i < rHeaders.Count(); ++i)
+ {
+ String sHeader = rHeaders.GetString( i );
+ sHeader.Insert('<', 0);
+ sHeader += '>';
+ String sReplace(C2U("<>"));
+ sReplace.Insert('0' + i, 1);
+ sBlock.SearchAndReplaceAll(sHeader, sReplace);
+ }
+ rBlock = sBlock;
+}
+// --------------------------------------------------------------------------------
+void lcl_ConvertFromNumbers(OUString& rBlock, const ResStringArray& rHeaders)
+{
+ //convert the numbers used for the configuration to strings used for UI to numbers
+ //doesn't use ReplaceAll to prevent expansion of numbers inside of the headers
+ String sBlock(rBlock);
+ sBlock.SearchAndReplaceAllAscii("\\n", '\n');
+ SwAddressIterator aGreetingIter(sBlock);
+ sBlock.Erase();
+ while(aGreetingIter.HasMore())
+ {
+ SwMergeAddressItem aNext = aGreetingIter.Next();
+ if(aNext.bIsColumn)
+ {
+ //the text should be 1 characters long
+ sal_Unicode cChar = aNext.sText.GetChar(0);
+ if(cChar >= '0' && cChar <= 'c')
+ {
+ sBlock += '<';
+ sal_uInt16 nHeader = cChar - '0';
+ if(nHeader < rHeaders.Count())
+ sBlock += rHeaders.GetString( nHeader );
+ sBlock += '>';
+ }
+ else
+ {
+ DBG_ERROR("parse error in address block or greeting line");
+ }
+ }
+ else
+ sBlock += aNext.sText;
+ }
+ rBlock = sBlock;
+}
+
+/*--------------------------------------------------------------------
+
+ --------------------------------------------------------------------*/
+const Sequence<OUString>& SwMailMergeConfigItem_Impl::GetPropertyNames()
+{
+ static Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ static const char* aPropNames[] =
+ {
+ "OutputToLetter", // 0
+ "IncludeCountry", // 1
+ "ExcludeCountry", // 2
+ "AddressBlockSettings", // 3
+ "IsAddressBlock", // 4
+ "IsGreetingLine", // 5
+ "IsIndividualGreetingLine", // 6
+ "FemaleGreetingLines", // 7
+ "MaleGreetingLines", // 8
+ "NeutralGreetingLines", // 9
+ "CurrentFemaleGreeting", // 10
+ "CurrentMaleGreeting", // 11
+ "CurrentNeutralGreeting", // 12
+ "FemaleGenderValue", // 13
+ "MailDisplayName", // 14
+ "MailAddress", // 15
+ "IsMailReplyTo", // 16
+ "MailReplyTo", // 17
+ "MailServer", // 18
+ "MailPort", // 19
+ "IsSecureConnection", // 20
+ "IsAuthentication", // 21
+ "MailUserName", // 22
+ "MailPassword", // 23
+ "DataSource/DataSourceName",// 24
+ "DataSource/DataTableName", // 25
+ "DataSource/DataCommandType",// 26
+ "Filter", // 27
+ "SavedDocuments", // 28
+ "EMailSupported", // 29
+ "IsEMailGreetingLine", //30
+ "IsEMailIndividualGreetingLine", //31
+ "IsSMPTAfterPOP", //32
+ "InServerName", //33
+ "InServerPort", //34
+ "InServerIsPOP", //35
+ "InServerUserName", //36
+ "InServerPassword", //37
+ "IsHideEmptyParagraphs", //38
+ "CurrentAddressBlock" //39
+
+ };
+ const int nCount = sizeof(aPropNames)/sizeof(const char*);
+ aNames.realloc(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+/*-- 15.04.2004 08:48:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem_Impl::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] <<= bIsOutputToLetter; break;//
+ case 1: pValues[nProp] <<= bIncludeCountry; break;
+ case 2: pValues[nProp] <<= sExcludeCountry; break;
+ case 3: pValues[nProp] <<= GetAddressBlocks(sal_True); break;
+ case 4:
+ {
+ if( bUserSettingWereOverwritten == sal_True )
+ pValues[nProp] <<= bIsAddressBlock_LastUserSetting;
+ else
+ pValues[nProp] <<= bIsAddressBlock;
+ break;
+ }
+ case 5:
+ {
+ if( bUserSettingWereOverwritten == sal_True )
+ pValues[nProp] <<= bIsGreetingLine_LastUserSetting;
+ else
+ pValues[nProp] <<= bIsGreetingLine;
+ break;
+ }
+ case 6: pValues[nProp] <<= bIsIndividualGreetingLine; break;
+ case 7:
+ case 8:
+ case 9:
+ pValues[nProp] <<= GetGreetings(
+ SwMailMergeConfigItem::Gender(
+ SwMailMergeConfigItem::FEMALE + nProp - 7), sal_True);
+ break;
+ case 10: pValues[nProp] <<= nCurrentFemaleGreeting; break;
+ case 11: pValues[nProp] <<= nCurrentMaleGreeting; break;
+ case 12: pValues[nProp] <<= nCurrentNeutralGreeting; break;
+ case 13: pValues[nProp] <<= sFemaleGenderValue; break;
+ case 14: pValues[nProp] <<= sMailDisplayName; break;
+ case 15: pValues[nProp] <<= sMailAddress; break;
+ case 16: pValues[nProp] <<= bIsMailReplyTo; break;
+ case 17: pValues[nProp] <<= sMailReplyTo; break;
+ case 18: pValues[nProp] <<= sMailServer; break;
+ case 19: if(!bIsDefaultPort)
+ pValues[nProp] <<= nMailPort;
+ break;
+ case 20: pValues[nProp] <<= bIsSecureConnection; break;
+ case 21: pValues[nProp] <<= bIsAuthentication; break;
+ case 22: pValues[nProp] <<= sMailUserName; break;
+ case 23: pValues[nProp] <<= sMailPassword; break;
+ case 24 :pValues[nProp] <<= aDBData.sDataSource; break;
+ case 25 :pValues[nProp] <<= aDBData.sCommand; break;
+ case 26 :pValues[nProp] <<= (short)aDBData.nCommandType; break;
+ case 27 :pValues[nProp] <<= sFilter; break;
+ case 28 :pValues[nProp] <<= aSavedDocuments; break;
+ case 29: pValues[nProp] <<= bIsEMailSupported; break;
+ case 30:
+ {
+ if( bUserSettingWereOverwritten == sal_True )
+ pValues[nProp] <<= bIsGreetingLineInMail_LastUserSetting;
+ else
+ pValues[nProp] <<= bIsGreetingLineInMail;
+ break;
+ }
+ case 31: pValues[nProp] <<= bIsIndividualGreetingLineInMail; break;
+ case 32: pValues[nProp] <<= bIsSMPTAfterPOP; break;
+ case 33: pValues[nProp] <<= sInServerName; break;
+ case 34: pValues[nProp] <<= nInServerPort; break;
+ case 35: pValues[nProp] <<= bInServerPOP; break;
+ case 36: pValues[nProp] <<= sInServerUserName; break;
+ case 37: pValues[nProp] <<= sInServerPassword; break;
+ case 38: pValues[nProp] <<= bIsHideEmptyParagraphs; break;
+ case 39: pValues[nProp] <<= nCurrentAddressBlock; break;
+ }
+ }
+ PutProperties(aNames, aValues);
+ //store the changed / new assignments
+
+ //load the existing node names to find new names
+ Sequence<OUString> aAssignments = GetNodeNames(C2U(cAddressDataAssignments));
+
+ ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
+ for(aAssignIter = aAddressDataAssignments.begin();
+ aAssignIter != aAddressDataAssignments.end(); aAssignIter++)
+ {
+ if(aAssignIter->bColumnAssignmentsChanged)
+ {
+ //create a new node name
+ OUString sNewNode = aAssignIter->sConfigNodeName.getLength() ?
+ aAssignIter->sConfigNodeName :
+ lcl_CreateNodeName(aAssignments);
+ OUString sSlash = C2U("/");
+ OUString sNodePath = C2U(cAddressDataAssignments);
+ sNodePath += sSlash;
+ sNodePath += sNewNode;
+ sNodePath += sSlash;
+ //only one new entry is written
+ Sequence< PropertyValue > aNewValues(4);
+ PropertyValue* pNewValues = aNewValues.getArray();
+ pNewValues[0].Name = sNodePath;
+ pNewValues[0].Name += C2U(cDataSourceName);
+ pNewValues[0].Value <<= aAssignIter->aDBData.sDataSource;
+ pNewValues[1].Name = sNodePath;
+ pNewValues[1].Name += C2U(cDataTableName);
+ pNewValues[1].Value <<= aAssignIter->aDBData.sCommand;
+ pNewValues[2].Name = sNodePath;
+ pNewValues[2].Name += C2U(cDataCommandType);
+ pNewValues[2].Value <<= aAssignIter->aDBData.nCommandType;
+ pNewValues[3].Name = sNodePath;
+ pNewValues[3].Name += C2U(cDBColumnAssignments);
+ pNewValues[3].Value <<= aAssignIter->aDBColumnAssignments;
+
+ SetSetProperties(C2U(cAddressDataAssignments), aNewValues);
+ }
+ }
+
+ bUserSettingWereOverwritten = sal_False;
+}
+/*-- 06.05.2004 13:04:36---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+const Sequence< ::rtl::OUString> SwMailMergeConfigItem_Impl::GetAddressBlocks(
+ sal_Bool bConvertToConfig) const
+{
+ Sequence< ::rtl::OUString> aRet(aAddressBlocks.size());
+ ::rtl::OUString* pRet = aRet.getArray();
+ for(sal_uInt32 nBlock = 0; nBlock < aAddressBlocks.size(); nBlock++)
+ {
+ pRet[nBlock] = aAddressBlocks[nBlock];
+ if(bConvertToConfig)
+ lcl_ConvertToNumbers(pRet[nBlock], m_AddressHeaderSA);
+ }
+ return aRet;
+}
+/*-- 06.05.2004 13:04:36---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem_Impl::SetAddressBlocks(
+ const Sequence< ::rtl::OUString>& rBlocks,
+ sal_Bool bConvertFromConfig)
+{
+ aAddressBlocks.clear();
+ for(sal_Int32 nBlock = 0; nBlock < rBlocks.getLength(); nBlock++)
+ {
+ OUString sBlock = rBlocks[nBlock];
+ if(bConvertFromConfig)
+ lcl_ConvertFromNumbers(sBlock, m_AddressHeaderSA);
+ aAddressBlocks.push_back(sBlock);
+ }
+ nCurrentAddressBlock = 0;
+ SetModified();
+}
+/*-- 30.04.2004 11:04:52---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+const Sequence< ::rtl::OUString> SwMailMergeConfigItem_Impl::GetGreetings(
+ SwMailMergeConfigItem::Gender eType, sal_Bool bConvertToConfig) const
+{
+ const ::std::vector< ::rtl::OUString>& rGreetings =
+ eType == SwMailMergeConfigItem::FEMALE ? aFemaleGreetingLines :
+ eType == SwMailMergeConfigItem::MALE ? aMaleGreetingLines :
+ aNeutralGreetingLines;
+ Sequence< ::rtl::OUString> aRet(rGreetings.size());
+ ::rtl::OUString* pRet = aRet.getArray();
+ for(sal_uInt32 nGreeting = 0; nGreeting < rGreetings.size(); nGreeting++)
+ {
+ pRet[nGreeting] = rGreetings[nGreeting];
+ if(bConvertToConfig)
+ lcl_ConvertToNumbers(pRet[nGreeting], m_AddressHeaderSA);
+ }
+ return aRet;
+}
+/*-- 30.04.2004 11:04:52---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem_Impl::SetGreetings(
+ SwMailMergeConfigItem::Gender eType,
+ const Sequence< ::rtl::OUString>& rSetGreetings,
+ sal_Bool bConvertFromConfig)
+{
+ ::std::vector< ::rtl::OUString>& rGreetings =
+ eType == SwMailMergeConfigItem::FEMALE ? aFemaleGreetingLines :
+ eType == SwMailMergeConfigItem::MALE ? aMaleGreetingLines :
+ aNeutralGreetingLines;
+
+ rGreetings.clear();
+ for(sal_Int32 nGreeting = 0; nGreeting < rSetGreetings.getLength(); nGreeting++)
+ {
+ OUString sGreeting = rSetGreetings[nGreeting];
+ if(bConvertFromConfig)
+ lcl_ConvertFromNumbers(sGreeting, m_AddressHeaderSA);
+ rGreetings.push_back(sGreeting);
+ }
+ SetModified();
+}
+/*-- 11.05.2004 13:13:54---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Int32 SwMailMergeConfigItem_Impl::GetCurrentGreeting(
+ SwMailMergeConfigItem::Gender eType) const
+{
+ sal_Int32 nRet;
+ switch(eType)
+ {
+ case SwMailMergeConfigItem::FEMALE: nRet = nCurrentFemaleGreeting ; break;
+ case SwMailMergeConfigItem::MALE: nRet = nCurrentMaleGreeting ; break;
+ default: nRet = nCurrentNeutralGreeting; break;
+ }
+ return nRet;
+}
+/*-- 11.05.2004 13:13:54---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem_Impl::SetCurrentGreeting(
+ SwMailMergeConfigItem::Gender eType, sal_Int32 nIndex)
+{
+ bool bChanged = false;
+ switch(eType)
+ {
+ case SwMailMergeConfigItem::FEMALE:
+ bChanged = nCurrentFemaleGreeting != nIndex;
+ nCurrentFemaleGreeting = nIndex;
+ break;
+ case SwMailMergeConfigItem::MALE:
+ bChanged = nCurrentMaleGreeting != nIndex;
+ nCurrentMaleGreeting = nIndex;
+ break;
+ default:
+ bChanged = nCurrentNeutralGreeting != nIndex;
+ nCurrentNeutralGreeting = nIndex;
+ }
+ if(bChanged)
+ SetModified();
+}
+
+static SwMailMergeConfigItem_Impl* pOptions = NULL;
+static sal_Int32 nRefCount = 0;
+static ::osl::Mutex aMutex;
+/*-- 15.04.2004 08:42:43---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeConfigItem::SwMailMergeConfigItem() :
+ m_bAddressInserted(false),
+ m_bMergeDone(false),
+ m_bGreetingInserted(false),
+ m_nGreetingMoves(0),
+ m_nStartPrint(0),
+ m_nEndPrint(0),
+ m_pSourceView(0),
+ m_pTargetView(0)
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( aMutex );
+ if ( !pOptions )
+ pOptions = new SwMailMergeConfigItem_Impl;
+ ++nRefCount;
+ m_pImpl = pOptions;
+}
+/*-- 15.04.2004 08:43:36---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeConfigItem::~SwMailMergeConfigItem()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( aMutex );
+ if ( !--nRefCount )
+ {
+ DELETEZ( pOptions );
+ }
+}
+/*-- 06.05.2004 14:18:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::Commit()
+{
+ if(m_pImpl->IsModified())
+ m_pImpl->Commit();
+}
+/*-- 06.05.2004 12:59:50---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+const ResStringArray& SwMailMergeConfigItem::GetDefaultAddressHeaders() const
+{
+ return m_pImpl->m_AddressHeaderSA;
+}
+/*-- 27.04.2004 14:34:16---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetAddressBlocks(
+ const Sequence< ::rtl::OUString>& rBlocks)
+{
+ m_pImpl->SetAddressBlocks(rBlocks);
+}
+/*-- 27.04.2004 14:34:16---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+const Sequence< ::rtl::OUString> SwMailMergeConfigItem::GetAddressBlocks() const
+{
+ return m_pImpl->GetAddressBlocks();
+}
+/*-- 11.05.2004 17:08:45---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeConfigItem::IsAddressBlock()const
+{
+ return m_pImpl->bIsAddressBlock && IsOutputToLetter();
+}
+/*-- 11.05.2004 17:08:46---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetAddressBlock(sal_Bool bSet)
+{
+ m_pImpl->bUserSettingWereOverwritten = sal_False;
+ if(m_pImpl->bIsAddressBlock != bSet)
+ {
+ m_pImpl->bIsAddressBlock = bSet;
+ m_pImpl->SetModified();
+ }
+}
+
+/*-- 30.08.2005 15:09:46---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeConfigItem::IsHideEmptyParagraphs() const
+{
+ return m_pImpl->bIsHideEmptyParagraphs;
+}
+/*-- 30.08.2005 15:09:47---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetHideEmptyParagraphs(sal_Bool bSet)
+{
+ if(m_pImpl->bIsHideEmptyParagraphs != bSet)
+ {
+ m_pImpl->bIsHideEmptyParagraphs = bSet;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 28.04.2004 13:00:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeConfigItem::IsIncludeCountry() const
+{
+ return m_pImpl->bIncludeCountry;
+}
+/*-- 28.04.2004 13:00:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+rtl::OUString& SwMailMergeConfigItem::GetExcludeCountry() const
+{
+ return m_pImpl->sExcludeCountry;
+}
+/*-- 28.04.2004 13:00:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetCountrySettings(sal_Bool bSet, const rtl::OUString& rCountry)
+{
+ if(m_pImpl->sExcludeCountry != rCountry ||
+ m_pImpl->bIncludeCountry != bSet)
+ {
+ m_pImpl->bIncludeCountry = bSet;
+ m_pImpl->sExcludeCountry = bSet ? rCountry : OUString();
+ m_pImpl->SetModified();
+ }
+}
+
+/*-- 28.04.2004 15:35:16---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetCurrentConnection(
+ Reference< XDataSource> xSource,
+ SharedConnection xConnection,
+ Reference< XColumnsSupplier> xColumnsSupplier,
+ const SwDBData& rDBData)
+{
+ m_pImpl->xSource = xSource ;
+ m_pImpl->xConnection = xConnection ;
+ m_pImpl->xColumnsSupplier = xColumnsSupplier;
+ m_pImpl->aDBData = rDBData;
+ m_pImpl->xResultSet = 0;
+ m_pImpl->nResultSetCursorPos = 0;
+ m_pImpl->SetModified();
+}
+/*-- 28.04.2004 15:38:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+Reference< XDataSource> SwMailMergeConfigItem::GetSource()
+{
+ return m_pImpl->xSource;
+}
+/*-- 28.04.2004 15:38:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SharedConnection SwMailMergeConfigItem::GetConnection()
+{
+ return m_pImpl->xConnection;
+}
+/*-- 28.04.2004 15:38:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+Reference< XColumnsSupplier> SwMailMergeConfigItem::GetColumnsSupplier()
+{
+ if(!m_pImpl->xColumnsSupplier.is() && m_pImpl->xConnection.is())
+ {
+ m_pImpl->xColumnsSupplier = SwNewDBMgr::GetColumnSupplier(m_pImpl->xConnection,
+ m_pImpl->aDBData.sCommand,
+ m_pImpl->aDBData.nCommandType == CommandType::TABLE ?
+ SW_DB_SELECT_TABLE : SW_DB_SELECT_QUERY );
+ }
+ return m_pImpl->xColumnsSupplier;
+}
+/*-- 30.04.2004 14:30:55---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+const SwDBData& SwMailMergeConfigItem::GetCurrentDBData() const
+{
+ return m_pImpl->aDBData;
+}
+
+/*-- 17.06.2004 13:18:47---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetCurrentDBData( const SwDBData& rDBData)
+{
+ if(m_pImpl->aDBData != rDBData)
+ {
+ m_pImpl->aDBData = rDBData;
+ m_pImpl->xConnection.clear();
+ m_pImpl->xSource = 0;
+ m_pImpl->xColumnsSupplier = 0;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 29.04.2004 11:34:36---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+Reference< XResultSet> SwMailMergeConfigItem::GetResultSet() const
+{
+ if(!m_pImpl->xConnection.is() && m_pImpl->aDBData.sDataSource.getLength())
+ {
+ m_pImpl->xConnection.reset(
+ SwNewDBMgr::GetConnection( m_pImpl->aDBData.sDataSource, m_pImpl->xSource ),
+ SharedConnection::TakeOwnership
+ );
+ }
+ if(!m_pImpl->xResultSet.is() && m_pImpl->xConnection.is())
+ {
+ try
+ {
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ if( xMgr.is() )
+ {
+ Reference<XRowSet> xRowSet(
+ xMgr->createInstance(C2U("com.sun.star.sdb.RowSet")), UNO_QUERY);
+ Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY);
+ xRowProperties->setPropertyValue(C2U("DataSourceName"), makeAny(m_pImpl->aDBData.sDataSource));
+ xRowProperties->setPropertyValue(C2U("Command"), makeAny(m_pImpl->aDBData.sCommand));
+ xRowProperties->setPropertyValue(C2U("CommandType"), makeAny(m_pImpl->aDBData.nCommandType));
+ xRowProperties->setPropertyValue(C2U("FetchSize"), makeAny((sal_Int32)10));
+ xRowProperties->setPropertyValue(C2U("ActiveConnection"), makeAny(m_pImpl->xConnection.getTyped()));
+ try
+ {
+ xRowProperties->setPropertyValue(C2U("ApplyFilter"), makeAny(m_pImpl->sFilter.getLength()>0));
+ xRowProperties->setPropertyValue(C2U("Filter"), makeAny(m_pImpl->sFilter));
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("exception caught in xResultSet->SetFilter()");
+ }
+ xRowSet->execute();
+ m_pImpl->xResultSet = xRowSet.get();
+ m_pImpl->xResultSet->first();
+ m_pImpl->nResultSetCursorPos = 1;
+ }
+ }
+ catch(Exception& )
+ {
+ DBG_ERROR("exception caught in: SwMailMergeConfigItem::GetResultSet() ");
+ }
+ }
+ return m_pImpl->xResultSet;
+}
+/*-- 13.08.2004 11:49:46---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::DisposeResultSet()
+{
+ m_pImpl->xConnection.clear();
+ if(m_pImpl->xResultSet.is())
+ {
+ ::comphelper::disposeComponent( m_pImpl->xResultSet );
+ }
+}
+/*-- 14.05.2004 15:07:55---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString& SwMailMergeConfigItem::GetFilter() const
+{
+ return m_pImpl->sFilter;
+}
+/*-- 14.05.2004 15:07:55---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetFilter(::rtl::OUString& rFilter)
+{
+ if(m_pImpl->sFilter != rFilter)
+ {
+ m_pImpl->sFilter = rFilter;
+ m_pImpl->SetModified();
+ Reference<XPropertySet> xRowProperties(m_pImpl->xResultSet, UNO_QUERY);
+ if(xRowProperties.is())
+ {
+ try
+ {
+ xRowProperties->setPropertyValue(C2U("ApplyFilter"), makeAny(m_pImpl->sFilter.getLength()>0));
+ xRowProperties->setPropertyValue(C2U("Filter"), makeAny(m_pImpl->sFilter));
+ uno::Reference<XRowSet> xRowSet( m_pImpl->xResultSet, UNO_QUERY_THROW );
+ xRowSet->execute();
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("exception caught in SwMailMergeConfigItem::SetFilter()");
+ }
+ }
+ }
+}
+/*-- 29.04.2004 11:55:38---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Int32 SwMailMergeConfigItem::MoveResultSet(sal_Int32 nTarget)
+{
+ if(!m_pImpl->xResultSet.is())
+ GetResultSet();
+ if(m_pImpl->xResultSet.is())
+ {
+ try
+ {
+ //no action if the resultset is already at the right position
+ if(m_pImpl->xResultSet->getRow() != nTarget)
+ {
+ if(nTarget > 0)
+ {
+ BOOL bMoved = m_pImpl->xResultSet->absolute(nTarget);
+ if(!bMoved)
+ {
+ if(nTarget > 1)
+ m_pImpl->xResultSet->last();
+ else if(nTarget == 1)
+ m_pImpl->xResultSet->first();
+ }
+ }
+ else if(nTarget == -1)
+ m_pImpl->xResultSet->last();
+ m_pImpl->nResultSetCursorPos = m_pImpl->xResultSet->getRow();
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ return m_pImpl->nResultSetCursorPos;
+}
+
+/*-- 27.05.2004 13:56:18---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool SwMailMergeConfigItem::IsResultSetFirstLast(bool& bIsFirst, bool& bIsLast)
+{
+ bool bRet = false;
+ if(!m_pImpl->xResultSet.is())
+ GetResultSet();
+ if(m_pImpl->xResultSet.is())
+ {
+ try
+ {
+ bIsFirst = m_pImpl->xResultSet->isFirst();
+ bIsLast = m_pImpl->xResultSet->isLast();
+ bRet = true;
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ return bRet;
+}
+/*-- 29.04.2004 11:55:38---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Int32 SwMailMergeConfigItem::GetResultSetPosition() const
+{
+ return m_pImpl->nResultSetCursorPos;
+}
+/*-- 27.05.2004 14:49:53---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool SwMailMergeConfigItem::IsRecordExcluded(sal_Int32 nRecord)
+{
+ bool bRet = false;
+ if(nRecord > 0 && nRecord < m_aSelection.getLength())
+ {
+ sal_Int32 nTemp = 0;
+ m_aSelection[nRecord - 1] >>= nTemp;
+ bRet = nTemp < 1;
+ }
+ return bRet;
+}
+/*-- 27.05.2004 14:49:53---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::ExcludeRecord(sal_Int32 nRecord, bool bExclude)
+{
+ //nRecord is based on 1
+ //the selection array contains Anys for all records
+ //excluded records contain a '-1'
+ if(!m_aSelection.getLength() || nRecord > m_aSelection.getLength())
+ {
+ if(bExclude)
+ {
+ //if no selection array is available we need to create one containing the
+ //entries for all available records
+ if(!m_pImpl->xResultSet.is())
+ GetResultSet();
+ if(m_pImpl->xResultSet.is())
+ {
+ m_pImpl->xResultSet->last();
+ sal_Int32 nEnd = m_pImpl->xResultSet->getRow();
+ sal_Int32 nStart = m_aSelection.getLength();
+ m_aSelection.realloc(nEnd);
+ Any* pSelection = m_aSelection.getArray();
+ for(sal_Int32 nIndex = nStart; nIndex < nEnd; ++nIndex)
+ {
+ if((nRecord - 1) != nIndex)
+ pSelection[nIndex] <<= nIndex + 1;
+ else
+ pSelection[nIndex] <<= (sal_Int32) -1;
+ }
+ }
+ }
+ }
+ else
+ {
+ if(nRecord > 0 && m_aSelection.getLength() > nRecord)
+ {
+ m_aSelection[nRecord - 1] <<= bExclude ? -1 : nRecord;
+ }
+ }
+}
+/*-- 27.05.2004 15:08:35---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+Sequence< Any > SwMailMergeConfigItem::GetSelection() const
+{
+ Sequence< Any > aRet(m_aSelection.getLength());
+ sal_Int32 nRetIndex = 0;
+ sal_Int32 nRet;
+ for(sal_Int32 nIndex = 0; nIndex < m_aSelection.getLength(); ++nIndex)
+ {
+ m_aSelection[nIndex] >>= nRet;
+ if(nRet > 0)
+ {
+ aRet[nRetIndex] <<= nRet;
+ ++nRetIndex;
+ }
+ }
+ aRet.realloc(nRetIndex);
+ return aRet;
+}
+/*-- 16.06.2004 15:15:56---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+const uno::Sequence< ::rtl::OUString>&
+ SwMailMergeConfigItem::GetSavedDocuments() const
+{
+ return m_pImpl->aSavedDocuments;
+}
+/*-- 16.06.2004 15:15:56---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::AddSavedDocument(::rtl::OUString rName)
+{
+ const ::rtl::OUString* pDocs = m_pImpl->aSavedDocuments.getConstArray();
+ bool bFound = false;
+ for(sal_Int32 nDoc = 0; nDoc < m_pImpl->aSavedDocuments.getLength(); ++nDoc)
+ {
+ if(pDocs[nDoc] == rName)
+ {
+ bFound = true;
+ break;
+ }
+ }
+ if(!bFound)
+ {
+ m_pImpl->aSavedDocuments.realloc(m_pImpl->aSavedDocuments.getLength() + 1);
+ m_pImpl->aSavedDocuments[m_pImpl->aSavedDocuments.getLength() - 1] = rName;
+ }
+}
+/*-- 28.04.2004 16:15:16---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeConfigItem::IsOutputToLetter()const
+{
+ return m_pImpl->bIsOutputToLetter || !IsMailAvailable();
+}
+/*-- 28.04.2004 16:15:16---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetOutputToLetter(sal_Bool bSet)
+{
+ if(m_pImpl->bIsOutputToLetter != bSet)
+ {
+ m_pImpl->bIsOutputToLetter = bSet;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 30.04.2004 10:51:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeConfigItem::IsIndividualGreeting(sal_Bool bInEMail) const
+{
+ return bInEMail ?
+ m_pImpl->bIsIndividualGreetingLineInMail :
+ m_pImpl->bIsIndividualGreetingLine;
+}
+/*-- 30.04.2004 10:51:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetIndividualGreeting(
+ sal_Bool bSet, sal_Bool bInEMail)
+{
+ if(bInEMail)
+ {
+ if(m_pImpl->bIsIndividualGreetingLineInMail != bSet)
+ {
+ m_pImpl->bIsIndividualGreetingLineInMail = bSet;
+ m_pImpl->SetModified();
+ }
+ }
+ else
+ {
+ if(m_pImpl->bIsIndividualGreetingLine != bSet)
+ {
+ m_pImpl->bIsIndividualGreetingLine = bSet;
+ m_pImpl->SetModified();
+ }
+ }
+}
+/*-- 30.04.2004 10:51:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeConfigItem::IsGreetingLine(sal_Bool bInEMail) const
+{
+ return bInEMail ? m_pImpl->bIsGreetingLineInMail : m_pImpl->bIsGreetingLine;
+}
+/*-- 30.04.2004 10:51:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetGreetingLine(sal_Bool bSet, sal_Bool bInEMail)
+{
+ m_pImpl->bUserSettingWereOverwritten = sal_False;
+ if(bInEMail)
+ {
+ if(m_pImpl->bIsGreetingLineInMail != bSet)
+ {
+ m_pImpl->bIsGreetingLineInMail = bSet;
+ m_pImpl->SetModified();
+ }
+ }
+ else
+ {
+ if(m_pImpl->bIsGreetingLine != bSet)
+ {
+ m_pImpl->bIsGreetingLine = bSet;
+ m_pImpl->SetModified();
+ }
+ }
+}
+/*-- 30.04.2004 11:04:52---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+const Sequence< ::rtl::OUString> SwMailMergeConfigItem::GetGreetings(
+ Gender eType ) const
+{
+ return m_pImpl->GetGreetings(eType);
+}
+/*-- 30.04.2004 11:04:52---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetGreetings(
+ Gender eType, const Sequence< ::rtl::OUString>& rSetGreetings)
+{
+ m_pImpl->SetGreetings( eType, rSetGreetings);
+}
+
+/*-- 11.05.2004 13:10:54---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Int32 SwMailMergeConfigItem::GetCurrentGreeting(
+ SwMailMergeConfigItem::Gender eType) const
+{
+ return m_pImpl->GetCurrentGreeting(eType);
+}
+/*-- 11.05.2004 13:10:55---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetCurrentGreeting(Gender eType, sal_Int32 nIndex)
+{
+ m_pImpl->SetCurrentGreeting(eType, nIndex);
+}
+/*-- 12.05.2004 12:29:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+const ::rtl::OUString& SwMailMergeConfigItem::GetFemaleGenderValue() const
+{
+ return m_pImpl->sFemaleGenderValue;
+}
+/*-- 12.05.2004 12:29:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetFemaleGenderValue(const ::rtl::OUString rValue)
+{
+ if( m_pImpl->sFemaleGenderValue != rValue )
+ {
+ m_pImpl->sFemaleGenderValue = rValue;
+ m_pImpl->SetModified();
+ }
+}
+
+/*-- 30.04.2004 13:25:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+Sequence< ::rtl::OUString> SwMailMergeConfigItem::GetColumnAssignment(
+ const SwDBData& rDBData ) const
+{
+ Sequence< ::rtl::OUString> aRet;
+ ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
+ for(aAssignIter = m_pImpl->aAddressDataAssignments.begin();
+ aAssignIter != m_pImpl->aAddressDataAssignments.end(); aAssignIter++)
+ {
+ if(aAssignIter->aDBData == rDBData)
+ {
+ aRet = aAssignIter->aDBColumnAssignments;
+ break;
+ }
+ }
+ return aRet;
+}
+/*-- 21.05.2004 12:31:31---------------------------------------------------
+ returns the name that is assigned as e-mail column of the current data base
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMergeConfigItem::GetAssignedColumn(sal_uInt32 nColumn) const
+{
+ ::rtl::OUString sRet;
+ Sequence< ::rtl::OUString> aAssignment = GetColumnAssignment( m_pImpl->aDBData );
+ if(aAssignment.getLength() > sal::static_int_cast< sal_Int32, sal_uInt32>(nColumn) && aAssignment[nColumn].getLength())
+ sRet = aAssignment[nColumn];
+ else if(nColumn < m_pImpl->m_AddressHeaderSA.Count())
+ sRet = m_pImpl->m_AddressHeaderSA.GetString(nColumn);
+ return sRet;
+}
+/*-- 30.04.2004 13:25:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetColumnAssignment( const SwDBData& rDBData,
+ const Sequence< ::rtl::OUString>& rList)
+{
+ ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
+ sal_Bool bFound = sal_False;
+ for(aAssignIter = m_pImpl->aAddressDataAssignments.begin();
+ aAssignIter != m_pImpl->aAddressDataAssignments.end(); aAssignIter++)
+ {
+ if(aAssignIter->aDBData == rDBData)
+ {
+ if(aAssignIter->aDBColumnAssignments != rList)
+ {
+ aAssignIter->aDBColumnAssignments = rList;
+ aAssignIter->bColumnAssignmentsChanged = true;
+ }
+ bFound = sal_True;
+ break;
+ }
+ }
+ if(!bFound)
+ {
+ DBAddressDataAssignment aAssignment;
+ aAssignment.aDBData = rDBData;
+ aAssignment.aDBColumnAssignments = rList;
+ aAssignment.bColumnAssignmentsChanged = true;
+ m_pImpl->aAddressDataAssignments.push_back(aAssignment);
+ }
+ m_pImpl->SetModified();
+}
+
+/*-- 07.09.2005 11:50:27---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool SwMailMergeConfigItem::IsAddressFieldsAssigned() const
+{
+ bool bResult = true;
+ Reference< XResultSet> xResultSet = GetResultSet();
+ uno::Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
+ if(!xColsSupp.is())
+ return false;
+ uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
+
+ const ResStringArray& rHeaders = GetDefaultAddressHeaders();
+ Sequence< ::rtl::OUString> aAssignment =
+ GetColumnAssignment( GetCurrentDBData() );
+ const ::rtl::OUString* pAssignment = aAssignment.getConstArray();
+ const Sequence< ::rtl::OUString> aBlocks = GetAddressBlocks();
+
+ if(aBlocks.getLength() <= m_pImpl->GetCurrentAddressBlockIndex())
+ return false;
+ SwAddressIterator aIter(aBlocks[m_pImpl->GetCurrentAddressBlockIndex()]);
+ while(aIter.HasMore())
+ {
+ SwMergeAddressItem aItem = aIter.Next();
+ if(aItem.bIsColumn)
+ {
+ String sConvertedColumn = aItem.sText;
+ for(USHORT nColumn = 0;
+ nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
+ ++nColumn)
+ {
+ if(rHeaders.GetString(nColumn) == aItem.sText &&
+ pAssignment[nColumn].getLength())
+ {
+ sConvertedColumn = pAssignment[nColumn];
+ break;
+ }
+ }
+ //find out if the column exists in the data base
+ if(!xCols->hasByName(sConvertedColumn))
+ {
+ bResult = false;
+ break;
+ }
+ }
+ }
+ return bResult;
+}
+/*-- 07.09.2005 11:50:27---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool SwMailMergeConfigItem::IsGreetingFieldsAssigned() const
+{
+ bool bResult = true;
+
+ if(!IsIndividualGreeting(sal_False))
+ return true;
+
+ Reference< XResultSet> xResultSet = GetResultSet();
+ uno::Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
+ if(!xColsSupp.is())
+ return false;
+ const ResStringArray& rHeaders = GetDefaultAddressHeaders();
+ uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
+
+ Sequence< ::rtl::OUString> aAssignment =
+ GetColumnAssignment( GetCurrentDBData() );
+ const ::rtl::OUString* pAssignment = aAssignment.getConstArray();
+
+ const Sequence< ::rtl::OUString> rFemaleEntries = GetGreetings(SwMailMergeConfigItem::FEMALE);
+ sal_Int32 nCurrentFemale = GetCurrentGreeting(SwMailMergeConfigItem::FEMALE);
+ const Sequence< ::rtl::OUString> rMaleEntries = GetGreetings(SwMailMergeConfigItem::MALE);
+ sal_Int32 nCurrentMale = GetCurrentGreeting(SwMailMergeConfigItem::MALE);
+ ::rtl::OUString sMale, sFemale;
+ if(rFemaleEntries.getLength() > nCurrentFemale)
+ sFemale = rFemaleEntries[nCurrentFemale];
+ if(rMaleEntries.getLength() > nCurrentMale)
+ sMale = rMaleEntries[nCurrentMale];
+
+ ::rtl::OUString sAddress( sFemale );
+ sAddress += sMale;
+ SwAddressIterator aIter(sAddress);
+ while(aIter.HasMore())
+ {
+ SwMergeAddressItem aItem = aIter.Next();
+ if(aItem.bIsColumn)
+ {
+ String sConvertedColumn = aItem.sText;
+ for(USHORT nColumn = 0;
+ nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
+ ++nColumn)
+ {
+ if(rHeaders.GetString(nColumn) == aItem.sText &&
+ pAssignment[nColumn].getLength())
+ {
+ sConvertedColumn = pAssignment[nColumn];
+ break;
+ }
+ }
+ //find out if the column exists in the data base
+ if(!xCols->hasByName(sConvertedColumn))
+ {
+ bResult = false;
+ break;
+ }
+ }
+ }
+ return bResult;
+}
+/*-- 05.05.2004 16:10:07---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMergeConfigItem::GetMailDisplayName() const
+{
+ return m_pImpl->sMailDisplayName;
+}
+/*-- 05.05.2004 16:10:08---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetMailDisplayName(const ::rtl::OUString& rName)
+{
+ if(m_pImpl->sMailDisplayName != rName)
+ {
+ m_pImpl->sMailDisplayName = rName;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 05.05.2004 16:10:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMergeConfigItem::GetMailAddress() const
+{
+ return m_pImpl->sMailAddress;
+}
+/*-- 05.05.2004 16:10:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetMailAddress(const ::rtl::OUString& rAddress)
+{
+ if(m_pImpl->sMailAddress != rAddress )
+ {
+ m_pImpl->sMailAddress = rAddress;
+ m_pImpl->SetModified();
+ }
+}
+
+/*-- 07.05.2004 12:40:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeConfigItem::IsMailReplyTo() const
+{
+ return m_pImpl->bIsMailReplyTo;
+}
+/*-- 07.05.2004 12:40:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetMailReplyTo(sal_Bool bSet)
+{
+ if(m_pImpl->bIsMailReplyTo != bSet)
+ {
+ m_pImpl->bIsMailReplyTo = bSet;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 05.05.2004 16:10:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMergeConfigItem::GetMailReplyTo() const
+{
+ return m_pImpl->sMailReplyTo;
+}
+/*-- 05.05.2004 16:10:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetMailReplyTo(const ::rtl::OUString& rReplyTo)
+{
+ if(m_pImpl->sMailReplyTo != rReplyTo)
+ {
+ m_pImpl->sMailReplyTo = rReplyTo;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 05.05.2004 16:10:09---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMergeConfigItem::GetMailServer() const
+{
+ return m_pImpl->sMailServer;
+}
+/*-- 05.05.2004 16:10:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetMailServer(const ::rtl::OUString& rAddress)
+{
+ if(m_pImpl->sMailServer != rAddress)
+ {
+ m_pImpl->sMailServer = rAddress;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 05.05.2004 16:10:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Int16 SwMailMergeConfigItem::GetMailPort() const
+{
+ return m_pImpl->bIsDefaultPort ?
+ (m_pImpl->bIsSecureConnection ? SECURE_PORT : DEFAULT_PORT) :
+ m_pImpl->nMailPort;
+}
+/*-- 05.05.2004 16:10:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetMailPort(sal_Int16 nSet)
+{
+ if(m_pImpl->nMailPort != nSet || m_pImpl->bIsDefaultPort)
+ {
+ m_pImpl->nMailPort = nSet;
+ m_pImpl->bIsDefaultPort = sal_False;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 05.05.2004 16:10:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeConfigItem::IsSecureConnection() const
+{
+ return m_pImpl->bIsSecureConnection;
+}
+/*-- 05.05.2004 16:10:12---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetSecureConnection(sal_Bool bSet)
+{
+ if(m_pImpl->bIsSecureConnection != bSet)
+ {
+ m_pImpl->bIsSecureConnection = bSet;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 05.05.2004 16:10:12---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeConfigItem::IsAuthentication() const
+{
+ return m_pImpl->bIsAuthentication;
+}
+/*-- 05.05.2004 16:10:13---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetAuthentication(sal_Bool bSet)
+{
+ if(m_pImpl->bIsAuthentication != bSet)
+ {
+ m_pImpl->bIsAuthentication = bSet;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 05.05.2004 16:10:13---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMergeConfigItem::GetMailUserName() const
+{
+ return m_pImpl->sMailUserName;
+}
+/*-- 05.05.2004 16:10:13---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetMailUserName(const ::rtl::OUString& rName)
+{
+ if(m_pImpl->sMailUserName != rName)
+ {
+ m_pImpl->sMailUserName = rName;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 05.05.2004 16:10:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMergeConfigItem::GetMailPassword() const
+{
+ return m_pImpl->sMailPassword;
+}
+/*-- 05.05.2004 16:10:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetMailPassword(const ::rtl::OUString& rPassword)
+{
+ if(m_pImpl->sMailPassword != rPassword)
+ {
+ m_pImpl->sMailPassword = rPassword;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 19.08.2004 14:44:57---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeConfigItem::IsSMTPAfterPOP() const
+{
+ return m_pImpl->bIsSMPTAfterPOP;
+}
+/*-- 19.08.2004 14:44:57---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetSMTPAfterPOP(sal_Bool bSet)
+{
+ if( m_pImpl->bIsSMPTAfterPOP != bSet)
+ {
+ m_pImpl->bIsSMPTAfterPOP = bSet;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 19.08.2004 14:44:57---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMergeConfigItem::GetInServerName() const
+{
+ return m_pImpl->sInServerName;
+}
+/*-- 19.08.2004 14:44:57---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetInServerName(const ::rtl::OUString& rServer)
+{
+ if(m_pImpl->sInServerName != rServer)
+ {
+ m_pImpl->sInServerName = rServer;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 19.08.2004 14:44:58---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Int16 SwMailMergeConfigItem::GetInServerPort() const
+{
+ return m_pImpl->nInServerPort;
+}
+/*-- 19.08.2004 14:44:58---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetInServerPort(sal_Int16 nSet)
+{
+ if( m_pImpl->nInServerPort != nSet)
+ {
+ m_pImpl->nInServerPort = nSet;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 20.08.2004 08:52:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeConfigItem::IsInServerPOP() const
+{
+ return m_pImpl->bInServerPOP;
+}
+/*-- 20.08.2004 08:52:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetInServerPOP(sal_Bool bSet)
+{
+ if( m_pImpl->bInServerPOP != bSet)
+ {
+ m_pImpl->bInServerPOP = bSet;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 19.08.2004 14:44:58---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMergeConfigItem::GetInServerUserName() const
+{
+ return m_pImpl->sInServerUserName;
+}
+/*-- 19.08.2004 14:44:58---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetInServerUserName(const ::rtl::OUString& rName)
+{
+ if( m_pImpl->sInServerUserName != rName)
+ {
+ m_pImpl->sInServerUserName = rName;
+ m_pImpl->SetModified();
+ }
+}
+/*-- 19.08.2004 14:44:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString SwMailMergeConfigItem::GetInServerPassword() const
+{
+ return m_pImpl->sInServerPassword;
+}
+/*-- 19.08.2004 14:45:00---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetInServerPassword(const ::rtl::OUString& rPassword)
+{
+ if(m_pImpl->sInServerPassword != rPassword)
+ {
+ m_pImpl->sInServerPassword = rPassword;
+ m_pImpl->SetModified();
+ }
+}
+
+/*-- 02.09.2004 14:43:27---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::DocumentReloaded()
+{
+ m_bMergeDone = false;
+ m_bGreetingInserted = false;
+ m_bAddressInserted = false;
+ m_rAddressBlockFrame = ::rtl::OUString();
+}
+/*-- 16.06.2004 12:24:18---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool SwMailMergeConfigItem::IsMailAvailable() const
+{
+ return m_pImpl->bIsEMailSupported;
+}
+/*-- 21.05.2004 12:20:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::AddMergedDocument(SwDocMergeInfo& rInfo)
+{
+ m_pImpl->aMergeInfos.push_back(rInfo);
+}
+/*-- 21.05.2004 12:20:05---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwDocMergeInfo& SwMailMergeConfigItem::GetDocumentMergeInfo(sal_uInt32 nDocument)
+{
+ DBG_ASSERT(m_pImpl->aMergeInfos.size() > nDocument,"invalid document index");
+ return m_pImpl->aMergeInfos[nDocument];
+}
+/*-- 14.06.2004 11:46:26---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_uInt32 SwMailMergeConfigItem::GetMergedDocumentCount() const
+{
+ return m_pImpl->aMergeInfos.size();
+}
+/*-- 11.06.2004 10:38:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwView* lcl_ExistsView(SwView* pView)
+{
+ const TypeId aType(TYPE(SwView));
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst( &aType, FALSE );
+ while(pViewShell)
+ {
+ if(pViewShell == pView)
+ return pView;
+
+ pViewShell = SfxViewShell::GetNext( *pViewShell, &aType, FALSE );
+ }
+ return 0;
+}
+/*-- 16.06.2004 15:02:35---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwView* SwMailMergeConfigItem::GetTargetView()
+{
+ //make sure that the pointer is really valid - the document may have been closed manually
+ if(m_pTargetView)
+ {
+ m_pTargetView = lcl_ExistsView(m_pTargetView);
+ }
+ return m_pTargetView;
+}
+/*-- 02.09.2004 17:04:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetTargetView(SwView* pView)
+{
+ m_pTargetView = pView;
+ //reset the document merge counter
+ if(!m_pTargetView)
+ {
+ m_pImpl->aMergeInfos.clear();
+ }
+}
+/*-- 16.06.2004 15:02:35---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwView* SwMailMergeConfigItem::GetSourceView()
+{
+ m_pSourceView = lcl_ExistsView(m_pSourceView);
+ return m_pSourceView;
+}
+
+/*-- 04.11.2004 19:53 ---------------------------------------------------
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetSourceView(SwView* pView)
+{
+ m_pSourceView = pView;
+
+ if(pView)
+ {
+ SvStringsDtor aDBNameList(5, 1);
+ SvStringsDtor aAllDBNames(5, 5);
+ pView->GetWrtShell().GetAllUsedDB( aDBNameList, &aAllDBNames );
+ if(aDBNameList.Count())
+ {
+ // if fields are available there is usually no need of an addressblock and greeting
+ if(!m_pImpl->bUserSettingWereOverwritten)
+ {
+ if( m_pImpl->bIsAddressBlock == sal_True
+ || m_pImpl->bIsGreetingLineInMail == sal_True
+ || m_pImpl->bIsGreetingLine == sal_True )
+ {
+ //store user settings
+ m_pImpl->bUserSettingWereOverwritten = sal_True;
+ m_pImpl->bIsAddressBlock_LastUserSetting = m_pImpl->bIsAddressBlock;
+ m_pImpl->bIsGreetingLineInMail_LastUserSetting = m_pImpl->bIsGreetingLineInMail;
+ m_pImpl->bIsGreetingLine_LastUserSetting = m_pImpl->bIsGreetingLine;
+
+ //set all to false
+ m_pImpl->bIsAddressBlock = sal_False;
+ m_pImpl->bIsGreetingLineInMail = sal_False;
+ m_pImpl->bIsGreetingLine = sal_False;
+
+ m_pImpl->SetModified();
+ }
+ }
+ }
+ else if( m_pImpl->bUserSettingWereOverwritten )
+ {
+ //restore last user settings:
+ m_pImpl->bIsAddressBlock = m_pImpl->bIsAddressBlock_LastUserSetting;
+ m_pImpl->bIsGreetingLineInMail = m_pImpl->bIsGreetingLineInMail_LastUserSetting;
+ m_pImpl->bIsGreetingLine = m_pImpl->bIsGreetingLine_LastUserSetting;
+
+ m_pImpl->bUserSettingWereOverwritten = sal_False;
+ }
+ }
+}
+
+/*-- 13.03.2006 12:15:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeConfigItem::SetCurrentAddressBlockIndex( sal_Int32 nSet )
+{
+ m_pImpl->SetCurrentAddressBlockIndex( nSet );
+}
+/*-- 13.03.2006 12:15:07---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Int32 SwMailMergeConfigItem::GetCurrentAddressBlockIndex() const
+{
+ return m_pImpl->GetCurrentAddressBlockIndex();
+}
diff --git a/sw/source/ui/dbui/mmdocselectpage.cxx b/sw/source/ui/dbui/mmdocselectpage.cxx
new file mode 100644
index 000000000000..7bef5c752be6
--- /dev/null
+++ b/sw/source/ui/dbui/mmdocselectpage.cxx
@@ -0,0 +1,227 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmdocselectpage.cxx,v $
+ * $Revision: 1.15 $
+ *
+ * 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 <svtools/pathoptions.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/new.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/docfac.hxx>
+#include <vcl/msgbox.hxx>
+#include <view.hxx>
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#include <mmdocselectpage.hxx>
+#include <mailmergewizard.hxx>
+#include <shellio.hxx>
+#include <swabstdlg.hxx>
+#include <mmconfigitem.hxx>
+
+#include <dbui.hrc>
+#include <mmdocselectpage.hrc>
+
+#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace svt;
+
+/*-- 02.04.2004 09:40:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeDocSelectPage::SwMailMergeDocSelectPage( SwMailMergeWizard* _pParent ) :
+ svt::OWizardPage(_pParent, SW_RES(DLG_MM_DOCSELECT_PAGE)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aHeaderFI(this, SW_RES( FI_HEADER ) ),
+ m_aHowToFT (this, SW_RES( FT_HOWTO )),
+ m_aCurrentDocRB (this, SW_RES( RB_CURRENTDOC )),
+ m_aNewDocRB (this, SW_RES( RB_NEWDOC )),
+ m_aLoadDocRB (this, SW_RES( RB_LOADDOC )),
+ m_aLoadTemplateRB (this, SW_RES( RB_LOADTEMPLATE )),
+ m_aRecentDocRB (this, SW_RES( RB_RECENTDOC )),
+ m_aBrowseDocPB (this, SW_RES( PB_LOADDOC )),
+ m_aBrowseTemplatePB (this, SW_RES( PB_BROWSETEMPLATE )),
+ m_aRecentDocLB (this, SW_RES( LB_RECENTDOC )),
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+ m_pWizard(_pParent)
+{
+ FreeResource();
+
+ m_aCurrentDocRB.Check();
+ DocSelectHdl(&m_aNewDocRB);
+
+ Link aDocSelectLink = LINK(this, SwMailMergeDocSelectPage, DocSelectHdl);
+ m_aCurrentDocRB.SetClickHdl(aDocSelectLink);
+ m_aNewDocRB.SetClickHdl(aDocSelectLink);
+ m_aLoadDocRB.SetClickHdl(aDocSelectLink);
+ m_aLoadTemplateRB.SetClickHdl(aDocSelectLink);
+ m_aRecentDocRB.SetClickHdl(aDocSelectLink);
+
+ Link aFileSelectHdl = LINK(this, SwMailMergeDocSelectPage, FileSelectHdl);
+ m_aBrowseDocPB.SetClickHdl(aFileSelectHdl);
+ m_aBrowseTemplatePB.SetClickHdl(aFileSelectHdl);
+
+ const uno::Sequence< ::rtl::OUString >& rDocs =
+ m_pWizard->GetConfigItem().GetSavedDocuments();
+ for(sal_Int32 nDoc = 0; nDoc < rDocs.getLength(); ++nDoc)
+ {
+ //insert in reverse order
+ m_aRecentDocLB.InsertEntry(rDocs[nDoc], 0);
+ }
+ m_aRecentDocLB.SelectEntryPos(0);
+ if(!rDocs.getLength())
+ {
+ m_aRecentDocRB.Enable(sal_False);
+ }
+}
+
+/*-- 02.04.2004 09:40:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeDocSelectPage::~SwMailMergeDocSelectPage()
+{
+}
+
+/*-- 05.04.2004 14:21:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeDocSelectPage, DocSelectHdl, RadioButton*, pButton)
+{
+ m_aRecentDocLB.Enable(&m_aRecentDocRB == pButton);
+
+ m_pWizard->UpdateRoadmap();
+ m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE));
+
+ return 0;
+}
+/*-- 05.04.2004 14:25:12---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, PushButton*, pButton)
+{
+ bool bTemplate = &m_aBrowseTemplatePB == pButton;
+
+ if(bTemplate)
+ {
+ m_aLoadTemplateRB.Check();
+ SfxNewFileDialog* pNewFileDlg = new SfxNewFileDialog(this, 0);
+ //pNewFileDlg->SetTemplateFlags(nFlags);
+ USHORT nRet = pNewFileDlg->Execute();
+ if(RET_TEMPLATE_LOAD == nRet)
+ bTemplate = false;
+ else if(RET_CANCEL != nRet)
+ m_sLoadTemplateName = pNewFileDlg->GetTemplateFileName();
+ delete pNewFileDlg;
+ }
+ else
+ m_aLoadDocRB.Check();
+
+ if(!bTemplate)
+ {
+ sfx2::FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
+ Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
+
+ xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
+
+ SfxObjectFactory &rFact = m_pWizard->GetSwView()->GetDocShell()->GetFactory();
+ SfxFilterMatcher aMatcher( String::CreateFromAscii(rFact.GetShortName()) );
+ SfxFilterMatcherIter aIter( &aMatcher );
+ Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
+ const SfxFilter* pFlt = aIter.First();
+ while( pFlt )
+ {
+ if( pFlt && pFlt->IsAllowedAsTemplate() )
+ {
+ const String sWild = ((WildCard&)pFlt->GetWildcard()).GetWildCard();
+ xFltMgr->appendFilter( pFlt->GetUIName(), sWild );
+
+ // #i40125
+ if(pFlt->GetFilterFlags() & SFX_FILTER_DEFAULT)
+ xFltMgr->setCurrentFilter( pFlt->GetUIName() ) ;
+ }
+
+
+ pFlt = aIter.Next();
+ }
+
+ if( ERRCODE_NONE == aDlgHelper.Execute() )
+ {
+ m_sLoadFileName = xFP->getFiles().getConstArray()[0];
+ }
+ }
+ m_pWizard->UpdateRoadmap();
+ m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE));
+
+ return 0;
+}
+
+/*-- 06.04.2004 12:52:24---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeDocSelectPage::commitPage( CommitPageReason _eReason )
+{
+ sal_Bool bReturn = sal_False;
+ bool bNext = _eReason == eTravelForward;
+ if(bNext || _eReason == eValidate )
+ {
+ ::rtl::OUString sReloadDocument;
+ bReturn = m_aCurrentDocRB.IsChecked() ||
+ m_aNewDocRB.IsChecked() ||
+ ((sReloadDocument = m_sLoadFileName).getLength() && m_aLoadDocRB.IsChecked() )||
+ ((sReloadDocument = m_sLoadTemplateName).getLength() && m_aLoadTemplateRB.IsChecked())||
+ (m_aRecentDocRB.IsChecked() && (sReloadDocument = m_aRecentDocLB.GetSelectEntry()).getLength());
+ if( _eReason == eValidate )
+ m_pWizard->SetDocumentLoad(!m_aCurrentDocRB.IsChecked());
+
+ if(bNext && !m_aCurrentDocRB.IsChecked())
+ {
+ if(sReloadDocument.getLength())
+ m_pWizard->SetReloadDocument( sReloadDocument );
+ m_pWizard->SetRestartPage(MM_OUTPUTTYPETPAGE);
+ m_pWizard->EndDialog(RET_LOAD_DOC);
+ }
+ }
+ return bReturn;
+}
diff --git a/sw/source/ui/dbui/mmdocselectpage.hrc b/sw/source/ui/dbui/mmdocselectpage.hrc
new file mode 100644
index 000000000000..a81f78d61c63
--- /dev/null
+++ b/sw/source/ui/dbui/mmdocselectpage.hrc
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmdocselectpage.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#define FT_HOWTO 1
+#define RB_CURRENTDOC 2
+#define RB_NEWDOC 3
+#define RB_LOADDOC 4
+#define PB_LOADDOC 5
+#define RB_LOADTEMPLATE 6
+#define PB_BROWSETEMPLATE 7
+#define RB_RECENTDOC 8
+#define LB_RECENTDOC 9
+#define FI_HEADER 10
diff --git a/sw/source/ui/dbui/mmdocselectpage.hxx b/sw/source/ui/dbui/mmdocselectpage.hxx
new file mode 100644
index 000000000000..e459a8b36546
--- /dev/null
+++ b/sw/source/ui/dbui/mmdocselectpage.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmdocselectpage.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEDOCSELECTPAGE_HXX
+#define _MAILMERGEDOCSELECTPAGE_HXX
+
+#include <svtools/wizardmachine.hxx>
+#include <mailmergehelper.hxx>
+#include <vcl/lstbox.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <svtools/stdctrl.hxx>
+class SwMailMergeWizard;
+/*-- 02.04.2004 09:21:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwMailMergeDocSelectPage : public svt::OWizardPage
+{
+ SwBoldFixedInfo m_aHeaderFI;
+ FixedInfo m_aHowToFT;
+ RadioButton m_aCurrentDocRB;
+ RadioButton m_aNewDocRB;
+ RadioButton m_aLoadDocRB;
+ RadioButton m_aLoadTemplateRB;
+ RadioButton m_aRecentDocRB;
+
+ PushButton m_aBrowseDocPB;
+ PushButton m_aBrowseTemplatePB;
+
+ ListBox m_aRecentDocLB;
+
+ String m_sLoadFileName;
+ String m_sLoadTemplateName;
+
+ SwMailMergeWizard* m_pWizard;
+
+ DECL_LINK(DocSelectHdl, RadioButton*);
+ DECL_LINK(FileSelectHdl, PushButton*);
+
+ virtual sal_Bool commitPage( CommitPageReason _eReason );
+
+public:
+ SwMailMergeDocSelectPage( SwMailMergeWizard* _pParent);
+ ~SwMailMergeDocSelectPage();
+
+};
+
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmdocselectpage.src b/sw/source/ui/dbui/mmdocselectpage.src
new file mode 100644
index 000000000000..91e3f445fc43
--- /dev/null
+++ b/sw/source/ui/dbui/mmdocselectpage.src
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmdocselectpage.src,v $
+ * $Revision: 1.8 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <mmdocselectpage.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+TabPage DLG_MM_DOCSELECT_PAGE
+{
+ HelpID = HID_MM_DOCSELECTPAGE ;
+ Size = MAP_APPFONT ( 260 , 250 ) ;
+ Hide = TRUE ;
+
+ FixedText FI_HEADER
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Select starting document for the mail merge";
+ };
+ FixedText FT_HOWTO
+ {
+ Pos = MAP_APPFONT ( 6 , 27 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Select the document upon which to base the mail merge document";
+ };
+ RadioButton RB_CURRENTDOC
+ {
+ Pos = MAP_APPFONT ( 12 , 48 ) ;
+ Size = MAP_APPFONT ( 190 , 10 ) ;
+ Text[ en-US ] = "Use the current ~document";
+ };
+ RadioButton RB_NEWDOC
+ {
+ Pos = MAP_APPFONT ( 12 , 66 ) ;
+ Size = MAP_APPFONT ( 190 , 10 ) ;
+ Text[ en-US ] = "Create a ne~w document";
+ };
+ RadioButton RB_LOADDOC
+ {
+ Pos = MAP_APPFONT ( 12 , 84) ;
+ Size = MAP_APPFONT ( 190 , 10 ) ;
+ Text[ en-US ] = "Start from ~existing document";
+ };
+ PushButton PB_LOADDOC
+ {
+ Pos = MAP_APPFONT ( 204 , 80) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "B~rowse...";
+ };
+ RadioButton RB_LOADTEMPLATE
+ {
+ Pos = MAP_APPFONT ( 12 , 103 ) ;
+ Size = MAP_APPFONT ( 190 , 10 ) ;
+ Text[ en-US ] = "Start from a t~emplate";
+ };
+ PushButton PB_BROWSETEMPLATE
+ {
+ Pos = MAP_APPFONT ( 204 , 99 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "B~rowse...";
+ };
+ RadioButton RB_RECENTDOC
+ {
+ Pos = MAP_APPFONT ( 12 , 120) ;
+ Size = MAP_APPFONT ( 190 , 10 ) ;
+ Text[ en-US ] = "Start fro~m a recently saved starting document";
+ };
+ ListBox LB_RECENTDOC
+ {
+ Pos = MAP_APPFONT ( 20 , 134 ) ;
+ Size = MAP_APPFONT ( 180 , 50 ) ;
+ DropDown = TRUE;
+ Border = TRUE;
+ };
+};
+
+
+
diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx b/sw/source/ui/dbui/mmgreetingspage.cxx
new file mode 100644
index 000000000000..03bd61021306
--- /dev/null
+++ b/sw/source/ui/dbui/mmgreetingspage.cxx
@@ -0,0 +1,622 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmgreetingspage.cxx,v $
+ * $Revision: 1.15 $
+ *
+ * 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>
+#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));
+ }
+ 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));
+ }
+ 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()
+{
+ //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);
+ 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( 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);
+ 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;
+}
+
diff --git a/sw/source/ui/dbui/mmgreetingspage.hrc b/sw/source/ui/dbui/mmgreetingspage.hrc
new file mode 100644
index 000000000000..bf7ea71f83ef
--- /dev/null
+++ b/sw/source/ui/dbui/mmgreetingspage.hrc
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmgreetingspage.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEGREETINGSPAGE_HRC
+#define _MAILMERGEGREETINGSPAGE_HRC
+
+
+#define CB_PERSONALIZED 2
+#define LB_FEMALE 3
+#define PB_FEMALE 4
+#define LB_MALE 5
+#define PB_MALE 6
+#define FI_FEMALE 7
+#define FT_FEMALECOLUMN 8
+#define LB_FEMALECOLUMN 9
+#define FT_FEMALEFIELD 10
+#define CB_FEMALEFIELD 11
+#define FT_NEUTRAL 12
+
+#define CB_NEUTRAL 14
+#define CB_GREETINGLINE 15
+#define FI_PREVIEW 16
+#define WIN_PREVIEW 17
+#define PB_ASSIGN 18
+#define FI_DOCINDEX 19
+#define IB_PREVSET 20
+#define IB_NEXTSET 21
+#define STR_DOCUMENT 22
+#define FI_HEADER 23
+#define FT_FEMALE 24
+#define FT_MALE 25
+
+#define FT_BODY 30
+#define MLE_BODY 31
+#define FL_SEPARATOR 32
+#define PB_OK 33
+#define PB_CANCEL 34
+#define PB_HELP 35
+
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmgreetingspage.hxx b/sw/source/ui/dbui/mmgreetingspage.hxx
new file mode 100644
index 000000000000..cc71c09ee771
--- /dev/null
+++ b/sw/source/ui/dbui/mmgreetingspage.hxx
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmgreetingspage.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEGREETINGSPAGE_HXX
+#define _MAILMERGEGREETINGSPAGE_HXX
+
+#include <svtools/wizardmachine.hxx>
+#include <sfx2/basedlgs.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <vcl/lstbox.hxx>
+#include <vcl/combobox.hxx>
+#include <svtools/stdctrl.hxx>
+#include <mailmergehelper.hxx>
+#include <svtools/svmedit.hxx>
+
+class SwMailMergeWizard;
+/*-- 17.05.2004 14:51:45---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwGreetingsHandler
+{
+ friend class SwMailBodyDialog;
+ friend class SwMailMergeGreetingsPage;
+ CheckBox* m_pGreetingLineCB;
+
+ CheckBox* m_pPersonalizedCB;
+
+ FixedText* m_pFemaleFT;
+ ListBox* m_pFemaleLB;
+ PushButton* m_pFemalePB;
+
+ FixedText* m_pMaleFT;
+ ListBox* m_pMaleLB;
+ PushButton* m_pMalePB;
+
+ FixedInfo* m_pFemaleFI;
+ FixedText* m_pFemaleColumnFT;
+ ListBox* m_pFemaleColumnLB;
+ FixedText* m_pFemaleFieldFT;
+ ComboBox* m_pFemaleFieldCB;
+
+ FixedText* m_pNeutralFT;
+ ComboBox* m_pNeutralCB;
+
+ bool m_bIsTabPage;
+
+ SwMailMergeWizard* m_pWizard;
+
+ DECL_LINK(IndividualHdl_Impl, CheckBox*);
+ DECL_LINK(GreetingHdl_Impl, PushButton*);
+
+ void Contains(sal_Bool bContainsGreeting);
+ virtual void UpdatePreview();
+};
+/*-- 02.04.2004 09:21:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwMailMergeGreetingsPage : public svt::OWizardPage,
+ public SwGreetingsHandler
+{
+ SwBoldFixedInfo m_aHeaderFI;
+
+ CheckBox m_aGreetingLineCB;
+
+ CheckBox m_aPersonalizedCB;
+
+ FixedText m_aFemaleFT;
+ ListBox m_aFemaleLB;
+ PushButton m_aFemalePB;
+
+ FixedText m_aMaleFT;
+ ListBox m_aMaleLB;
+ PushButton m_aMalePB;
+
+ FixedInfo m_aFemaleFI;
+ FixedText m_aFemaleColumnFT;
+ ListBox m_aFemaleColumnLB;
+ FixedText m_aFemaleFieldFT;
+ ComboBox m_aFemaleFieldCB;
+
+ FixedText m_aNeutralFT;
+ ComboBox m_aNeutralCB;
+
+ FixedInfo m_aPreviewFI;
+ SwAddressPreview m_aPreviewWIN;
+ PushButton m_aAssignPB;
+ FixedInfo m_aDocumentIndexFI;
+ ImageButton m_aPrevSetIB;
+ ImageButton m_aNextSetIB;
+
+ String m_sDocument;
+
+ DECL_LINK(ContainsHdl_Impl, CheckBox*);
+ DECL_LINK(InsertDataHdl_Impl, ImageButton*);
+ DECL_LINK(GreetingSelectHdl_Impl, ListBox*);
+ DECL_LINK(AssignHdl_Impl, PushButton*);
+
+ virtual void UpdatePreview();
+ virtual void ActivatePage();
+ virtual sal_Bool commitPage( CommitPageReason _eReason );
+public:
+ SwMailMergeGreetingsPage( SwMailMergeWizard* _pParent);
+ ~SwMailMergeGreetingsPage();
+
+};
+/*-- 17.05.2004 14:45:43---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwMailBodyDialog : public SfxModalDialog, public SwGreetingsHandler
+{
+ CheckBox m_aGreetingLineCB;
+
+ CheckBox m_aPersonalizedCB;
+
+ FixedText m_aFemaleFT;
+ ListBox m_aFemaleLB;
+ PushButton m_aFemalePB;
+
+ FixedText m_aMaleFT;
+ ListBox m_aMaleLB;
+ PushButton m_aMalePB;
+
+ FixedInfo m_aFemaleFI;
+ FixedText m_aFemaleColumnFT;
+ ListBox m_aFemaleColumnLB;
+ FixedText m_aFemaleFieldFT;
+ ComboBox m_aFemaleFieldCB;
+
+ FixedText m_aNeutralFT;
+ ComboBox m_aNeutralCB;
+
+ FixedText m_aBodyFT;
+ MultiLineEdit m_aBodyMLE;
+ FixedLine m_aSeparatorFL;
+
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ DECL_LINK(ContainsHdl_Impl, CheckBox*);
+ DECL_LINK(OKHdl, PushButton*);
+public:
+ SwMailBodyDialog(Window* pParent, SwMailMergeWizard* pWizard);
+ ~SwMailBodyDialog();
+
+ void SetBody(const String& rBody ) {m_aBodyMLE.SetText(rBody);}
+ String GetBody() const {return m_aBodyMLE.GetText();}
+};
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmgreetingspage.src b/sw/source/ui/dbui/mmgreetingspage.src
new file mode 100644
index 000000000000..4db1887f1958
--- /dev/null
+++ b/sw/source/ui/dbui/mmgreetingspage.src
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmgreetingspage.src,v $
+ * $Revision: 1.11 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <mmgreetingspage.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+#define _LB_FEMALECOLUMN \
+ StringList [en-US]= \
+ { \
+ < "< not available >" ; > ; \
+ };
+
+
+#define GREETINGS_BODY \
+ CheckBox CB_PERSONALIZED \
+ { \
+ Pos = MAP_APPFONT ( 12 + LEFT_OFFSET , 17 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 226 , 10 ) ; \
+ Text[ en-US ] = "Insert personalized salutation"; \
+ }; \
+ FixedText FT_FEMALE \
+ { \
+ Pos = MAP_APPFONT ( 18 + LEFT_OFFSET , 32 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 50 , 8 ) ; \
+ Text[ en-US ] = "~Female"; \
+ }; \
+ ListBox LB_FEMALE \
+ { \
+ Pos = MAP_APPFONT ( 71 + LEFT_OFFSET , 30 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 121 , 50 ) ; \
+ DropDown = TRUE; \
+ Border = TRUE; \
+ }; \
+ PushButton PB_FEMALE \
+ { \
+ Pos = MAP_APPFONT ( 198 + LEFT_OFFSET , 29 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 50 , 14 ) ; \
+ Text[ en-US ] = "~New..."; \
+ }; \
+ FixedText FT_MALE \
+ { \
+ Pos = MAP_APPFONT ( 18 + LEFT_OFFSET , 49 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 50 , 8 ) ; \
+ Text[ en-US ] = "~Male"; \
+ }; \
+ ListBox LB_MALE \
+ { \
+ Pos = MAP_APPFONT ( 71 + LEFT_OFFSET , 47 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 121 , 50 ) ; \
+ DropDown = TRUE; \
+ Border = TRUE; \
+ }; \
+ PushButton PB_MALE \
+ { \
+ Pos = MAP_APPFONT ( 198 + LEFT_OFFSET , 48 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 50 , 14 ) ; \
+ Text[ en-US ] = "N~ew..."; \
+ }; \
+ FixedText FI_FEMALE \
+ { \
+ Pos = MAP_APPFONT ( 18 + LEFT_OFFSET , 67 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 225 , 8 ) ; \
+ Text[ en-US ] = "Address list field indicating a female recipient"; \
+ }; \
+ FixedText FT_FEMALECOLUMN \
+ { \
+ Pos = MAP_APPFONT ( 18 + LEFT_OFFSET , 80 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 50 , 8 ) ; \
+ Text[ en-US ] = "Field name"; \
+ }; \
+ ListBox LB_FEMALECOLUMN \
+ { \
+ Pos = MAP_APPFONT ( 71 + LEFT_OFFSET , 78 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 121 , 50 ) ; \
+ DropDown = TRUE; \
+ Border = TRUE; \
+ _LB_FEMALECOLUMN \
+ }; \
+ FixedText FT_FEMALEFIELD \
+ { \
+ Pos = MAP_APPFONT ( 18 + LEFT_OFFSET , 95 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 50 , 8 ) ; \
+ Text[ en-US ] = "Field value"; \
+ }; \
+ ComboBox CB_FEMALEFIELD \
+ { \
+ Pos = MAP_APPFONT ( 71 + LEFT_OFFSET , 93 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 121 , 50 ) ; \
+ DropDown = TRUE; \
+ Border = TRUE; \
+ }; \
+ FixedText FT_NEUTRAL \
+ { \
+ Pos = MAP_APPFONT ( 12 + LEFT_OFFSET , 113 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 180 , 8 ) ; \
+ Text[ en-US ] = "General salutation"; \
+ }; \
+ ComboBox CB_NEUTRAL \
+ { \
+ Pos = MAP_APPFONT ( 12 + LEFT_OFFSET , 124 + TOP_OFFSET ) ; \
+ Size = MAP_APPFONT ( 180 , 50 ) ; \
+ DropDown = TRUE; \
+ Border = TRUE; \
+ };
+
+#define TOP_OFFSET 24
+#define LEFT_OFFSET 6
+
+TabPage DLG_MM_GREETINGS_PAGE
+{
+ HelpID = HID_MM_GREETINGSPAGE ;
+ Size = MAP_APPFONT ( 260 , 250 ) ;
+ Hide = TRUE ;
+
+ FixedText FI_HEADER
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Create a salutation";
+ };
+ CheckBox CB_GREETINGLINE
+ {
+ Pos = MAP_APPFONT ( 12 , 27 );
+ Size = MAP_APPFONT ( 242 , 10 );
+ Text[ en-US ] = "This document should contain a salutation";
+ };
+ GREETINGS_BODY
+ FixedText FI_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 12 , 168 ) ;
+ Size = MAP_APPFONT ( 242 , 8 ) ;
+ Text[ en-US ] = "Preview";
+ };
+ Window WIN_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 12 , 179 );
+ Size = MAP_APPFONT ( 186 , 21 ) ;
+ Border = TRUE;
+ };
+ PushButton PB_ASSIGN
+ {
+ Pos = MAP_APPFONT ( 204 , 179 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "~Match fields...";
+ };
+ FixedText FI_DOCINDEX
+ {
+ Pos = MAP_APPFONT ( 121 , 206 ) ;
+ Size = MAP_APPFONT ( 50, 8 ) ;
+ Right = TRUE;
+ };
+ ImageButton IB_PREVSET
+ {
+ Pos = MAP_APPFONT ( 177 , 204 ) ;
+ Size = MAP_APPFONT ( 10 , 10 ) ;
+ SYMBOL = IMAGEBUTTON_PREV;
+ QuickHelpText[ en-US ] = "Preview Previous Salutation";
+ };
+ ImageButton IB_NEXTSET
+ {
+ Pos = MAP_APPFONT ( 188 , 204 ) ;
+ Size = MAP_APPFONT ( 10 , 10 ) ;
+ SYMBOL = IMAGEBUTTON_NEXT ;
+ QuickHelpText[ en-US ] = "Preview Next Salutation";
+ };
+ String STR_DOCUMENT
+ {
+ Text[ en-US ] = "Document: %1";
+ };
+};
+
+#undef TOP_OFFSET
+#undef LEFT_OFFSET
+
+#define TOP_OFFSET 0
+#define LEFT_OFFSET 0
+ModalDialog DLG_MM_MAILBODY
+{
+ HelpID = HID_MM_MAILBODY;
+ Size = MAP_APPFONT ( 254 , 238 ) ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Text [ en-US ] = "E-Mail Message";
+ CheckBox CB_GREETINGLINE
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 242 , 10 ) ;
+ Text[ en-US ] = "This e-mail should contain a salutation";
+ };
+ GREETINGS_BODY
+ FixedText FT_BODY
+ {
+ Pos = MAP_APPFONT ( 12 , 140 ) ;
+ Size = MAP_APPFONT ( 174 , 8 ) ;
+ Text[ en-US ] = "Write your message here";
+ };
+ MultiLineEdit MLE_BODY
+ {
+ Pos = MAP_APPFONT ( 12, 151 ) ;
+ Size = MAP_APPFONT ( 180 , 50 ) ;
+ Border = TRUE;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ VScroll = TRUE ;
+ HScroll = TRUE ;
+ IgnoreTab = TRUE;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 207 ) ;
+ Size = MAP_APPFONT ( 254 , 8 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 89, 218 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 142 , 218 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 198 , 218 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
+
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
new file mode 100644
index 000000000000..ddb37e3c8eeb
--- /dev/null
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -0,0 +1,823 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmlayoutpage.cxx,v $
+ * $Revision: 1.21 $
+ *
+ * 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 <swtypes.hxx>
+#include <mmlayoutpage.hxx>
+#include <mailmergewizard.hxx>
+#include <mmconfigitem.hxx>
+#include <mailmergehelper.hxx>
+#include <unotools.hxx>
+#include <unotools/tempfile.hxx>
+#include <uitool.hxx>
+#include <svx/dlgutil.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <swundo.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svtools/stritem.hxx>
+#include <sfx2/docfilt.hxx>
+#include <com/sun/star/text/XParagraphCursor.hpp>
+#include <com/sun/star/view/XViewSettingsSupplier.hpp>
+#include <com/sun/star/view/DocumentZoomType.hpp>
+#include <fldmgr.hxx>
+#include <fldbas.hxx>
+#include <poolfmt.hxx>
+#include <unotxdoc.hxx>
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#include <doc.hxx>
+#include <wrtsh.hxx>
+#include <fmtsrnd.hxx>
+#include <pagedesc.hxx>
+#include <fmtanchr.hxx>
+#include <fmtornt.hxx>
+#include <fmtfsize.hxx>
+#include <svx/boxitem.hxx>
+#include <svtools/urihelper.hxx>
+#include <shellio.hxx>
+#include <osl/file.hxx>
+#include <unoprnms.hxx>
+
+#include <mmlayoutpage.hrc>
+#include <dbui.hrc>
+#include <unomid.h>
+
+using namespace osl;
+using namespace svt;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::view;
+
+#define DEFAULT_LEFT_DISTANCE (MM50*5) // 2,5 cm
+#define DEFAULT_TOP_DISTANCE (MM50*11) // 5,5 cm
+#define GREETING_TOP_DISTANCE (MM50*25) //12,5 cm
+#define DEFAULT_ADDRESS_WIDTH (MM50*15)// 7,5 cm
+#define DEFAULT_ADDRESS_HEIGHT (MM50*7) // 3,5cm
+
+/*-- 15.04.2004 08:16:35---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeLayoutPage::SwMailMergeLayoutPage( SwMailMergeWizard* _pParent) :
+ svt::OWizardPage( _pParent, SW_RES(DLG_MM_LAYOUT_PAGE)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aHeaderFI( this, SW_RES( FI_HEADER )),
+ m_aPositionFL( this, SW_RES( FL_POSITION )),
+ m_aAlignToBodyCB( this, SW_RES( CB_ALIGN )),
+ m_aLeftFT( this, SW_RES( FT_LEFT )),
+ m_aLeftMF( this, SW_RES( MF_LEFT )),
+ m_aTopFT( this, SW_RES( FT_TOP )),
+ m_aTopMF( this, SW_RES( MF_TOP )),
+ m_aGreetingLineFL( this, SW_RES( FL_GREETINGLINE )),
+ m_aUpFT( this, SW_RES( FT_UP )),
+ m_aUpPB( this, SW_RES( MF_UP )),
+ m_aDownFT( this, SW_RES( FT_DOWN )),
+ m_aDownPB( this, SW_RES( PB_DOWN )),
+ m_aExampleContainerWIN( this, SW_RES( WIN_EXAMPLECONTAINER )),
+ m_aExampleWIN( this, 0 ),
+ m_aZoomFT( this, SW_RES( FT_ZOOM )),
+ m_aZoomLB( this, SW_RES( LB_ZOOM )),
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+ m_pExampleFrame(0),
+ m_pExampleWrtShell(0),
+ m_pAddressBlockFormat(0),
+ m_bIsGreetingInserted(false),
+ m_pWizard(_pParent)
+{
+ FreeResource();
+ m_aExampleWIN.SetPosSizePixel(m_aExampleContainerWIN.GetPosPixel(),
+ m_aExampleContainerWIN.GetSizePixel());
+
+
+ const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
+ String::CreateFromAscii( FILTER_XML ),
+ SwDocShell::Factory().GetFilterContainer() );
+ //save the current document into a temporary file
+ {
+ //temp file needs it's own block
+ //creating with extension is not supported by a static method :-(
+ String sLeading;
+ String sExt(pSfxFlt->GetDefaultExtension());
+ sExt.EraseLeadingChars('*');
+ utl::TempFile aTempFile( sLeading, &sExt );
+ m_sExampleURL = aTempFile.GetURL();
+ aTempFile.EnableKillingFile();
+ }
+ SwView* pView = m_pWizard->GetSwView();
+ uno::Sequence< beans::PropertyValue > aValues(1);
+ beans::PropertyValue* pValues = aValues.getArray();
+ pValues[0].Name = C2U("FilterName");
+ pValues[0].Value <<= ::rtl::OUString(pSfxFlt->GetFilterName());
+
+ uno::Reference< frame::XStorable > xStore( pView->GetDocShell()->GetModel(), uno::UNO_QUERY);
+ xStore->storeToURL( m_sExampleURL, aValues );
+
+ Link aLink(LINK(this, SwMailMergeLayoutPage, PreviewLoadedHdl_Impl));
+ m_pExampleFrame = new SwOneExampleFrame( m_aExampleWIN,
+ EX_SHOW_DEFAULT_PAGE, &aLink, &m_sExampleURL );
+
+ m_aExampleWIN.Show( FALSE );
+ m_aExampleContainerWIN.Show(TRUE);
+
+ m_aLeftMF.SetValue(m_aLeftMF.Normalize(DEFAULT_LEFT_DISTANCE), FUNIT_TWIP);
+ m_aTopMF.SetValue(m_aTopMF.Normalize(DEFAULT_TOP_DISTANCE), FUNIT_TWIP);
+
+ m_aZoomLB.InsertEntry(String::CreateFromAscii("50 %"), 1);
+ m_aZoomLB.InsertEntry(String::CreateFromAscii("75 %"), 2);
+ m_aZoomLB.InsertEntry(String::CreateFromAscii("100 %"), 3);
+ m_aZoomLB.SelectEntryPos(0); //page size
+ m_aZoomLB.SetSelectHdl(LINK(this, SwMailMergeLayoutPage, ZoomHdl_Impl));
+
+ Link aFrameHdl = LINK(this, SwMailMergeLayoutPage, ChangeAddressHdl_Impl);
+ m_aLeftMF.SetUpHdl(aFrameHdl);
+ m_aLeftMF.SetDownHdl(aFrameHdl);
+ m_aLeftMF.SetLoseFocusHdl(aFrameHdl);
+ m_aTopMF.SetUpHdl(aFrameHdl);
+ m_aTopMF.SetDownHdl(aFrameHdl);
+ m_aTopMF.SetLoseFocusHdl(aFrameHdl);
+
+ FieldUnit eFieldUnit = ::GetDfltMetric(sal_False);
+ ::SetFieldUnit( m_aLeftMF, eFieldUnit );
+ ::SetFieldUnit( m_aTopMF, eFieldUnit );
+
+ Link aUpDownHdl = LINK(this, SwMailMergeLayoutPage, GreetingsHdl_Impl );
+ m_aUpPB.SetClickHdl(aUpDownHdl);
+ m_aDownPB.SetClickHdl(aUpDownHdl);
+ m_aAlignToBodyCB.SetClickHdl(LINK(this, SwMailMergeLayoutPage, AlignToTextHdl_Impl));
+ m_aAlignToBodyCB.Check();
+}
+/*-- 15.04.2004 08:17:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeLayoutPage::~SwMailMergeLayoutPage()
+{
+ delete m_pExampleFrame;
+ File::remove( m_sExampleURL );
+
+}
+/*-- 27.05.2004 13:41:04---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeLayoutPage::ActivatePage()
+{
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ sal_Bool bGreetingLine = rConfigItem.IsGreetingLine(sal_False) && !rConfigItem.IsGreetingInserted();
+ sal_Bool bAddressBlock = rConfigItem.IsAddressBlock() && !rConfigItem.IsAddressInserted();
+
+ m_aPositionFL.Enable(bAddressBlock);
+ m_aLeftFT.Enable(bAddressBlock);
+ m_aTopFT.Enable(bAddressBlock);
+ m_aLeftMF.Enable(bAddressBlock);
+ m_aTopMF.Enable(bAddressBlock);
+ AlignToTextHdl_Impl( &m_aAlignToBodyCB );
+
+ m_aGreetingLineFL.Enable(bGreetingLine);
+ m_aUpPB.Enable(bGreetingLine);
+ m_aDownPB.Enable(bGreetingLine);
+ m_aUpFT.Enable(bGreetingLine);
+ m_aDownFT.Enable(bGreetingLine);
+
+ //check if greeting and/or address frame have to be inserted/removed
+ if(m_pExampleWrtShell) // initially there's nothing to check
+ {
+ if(!rConfigItem.IsGreetingInserted() &&
+ m_bIsGreetingInserted != (0 != bGreetingLine) )
+ {
+ if( m_bIsGreetingInserted )
+ {
+ m_pExampleWrtShell->DelFullPara();
+ m_bIsGreetingInserted = false;
+ }
+ else
+ {
+ InsertGreeting(*m_pExampleWrtShell, m_pWizard->GetConfigItem(), true);
+ m_bIsGreetingInserted = true;
+ }
+ }
+ if(!rConfigItem.IsAddressInserted() &&
+ rConfigItem.IsAddressBlock() != ( 0 != m_pAddressBlockFormat ))
+ {
+ if( m_pAddressBlockFormat )
+ {
+ m_pExampleWrtShell->Push();
+ m_pExampleWrtShell->GotoFly( m_pAddressBlockFormat->GetName() );
+ m_pExampleWrtShell->DelRight();
+ m_pAddressBlockFormat = 0;
+ m_pExampleWrtShell->Pop(FALSE);
+ }
+ else
+ {
+ long nLeft = static_cast< long >(m_aLeftMF.Denormalize(m_aLeftMF.GetValue(FUNIT_TWIP)));
+ long nTop = static_cast< long >(m_aTopMF.Denormalize(m_aTopMF.GetValue(FUNIT_TWIP)));
+ m_pAddressBlockFormat = InsertAddressFrame(
+ *m_pExampleWrtShell, m_pWizard->GetConfigItem(),
+ Point(nLeft, nTop),
+ m_aAlignToBodyCB.IsChecked(), true);
+ }
+ }
+
+ }
+}
+/*-- 11.05.2004 10:41:26---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergeLayoutPage::commitPage( CommitPageReason _eReason )
+{
+ //now insert the frame and the greeting
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ if(eTravelForward == _eReason)
+ {
+ long nLeft = static_cast< long >(m_aLeftMF.Denormalize(m_aLeftMF.GetValue(FUNIT_TWIP)));
+ long nTop = static_cast< long >(m_aTopMF.Denormalize(m_aTopMF.GetValue(FUNIT_TWIP)));
+ InsertAddressAndGreeting(
+ m_pWizard->GetSwView(),
+ rConfigItem,
+ Point(nLeft, nTop),
+ m_aAlignToBodyCB.IsChecked());
+ }
+ return sal_True;
+}
+/*-- 24.06.2004 09:50:26---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwFrmFmt* SwMailMergeLayoutPage::InsertAddressAndGreeting(SwView* pView,
+ SwMailMergeConfigItem& rConfigItem,
+ const Point& rAddressPosition,
+ bool bAlignToBody)
+{
+ SwFrmFmt* pAddressBlockFormat = 0;
+ pView->GetWrtShell().StartUndo(UNDO_INSERT);
+ if(rConfigItem.IsAddressBlock() && !rConfigItem.IsAddressInserted())
+ {
+ //insert the frame
+ Point aAddressPosition(DEFAULT_LEFT_DISTANCE, DEFAULT_TOP_DISTANCE);
+ if(rAddressPosition.X() > 0 && rAddressPosition.Y() > 0)
+ aAddressPosition = rAddressPosition;
+ pAddressBlockFormat = InsertAddressFrame( pView->GetWrtShell(),
+ rConfigItem,
+ aAddressPosition, bAlignToBody, false);
+ rConfigItem.SetAddressInserted(pAddressBlockFormat->GetName());
+ }
+ //now the greeting
+ if(rConfigItem.IsGreetingLine(sal_False) && !rConfigItem.IsGreetingInserted())
+ {
+ InsertGreeting( pView->GetWrtShell(), rConfigItem, false);
+ rConfigItem.SetGreetingInserted();
+ }
+ pView->GetWrtShell().EndUndo(UNDO_INSERT);
+ return pAddressBlockFormat;
+}
+/*-- 11.05.2004 12:49:04---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwFrmFmt* SwMailMergeLayoutPage::InsertAddressFrame(
+ SwWrtShell& rShell,
+ SwMailMergeConfigItem& rConfigItem,
+ const Point& rDestination,
+ bool bAlignLeft,
+ bool bExample)
+{
+ // insert the address block and the greeting line
+ SfxItemSet aSet(rShell.GetAttrPool(), RES_ANCHOR, RES_ANCHOR,
+ RES_VERT_ORIENT, RES_VERT_ORIENT,
+ RES_HORI_ORIENT, RES_HORI_ORIENT,
+ RES_BOX, RES_BOX,
+ RES_FRM_SIZE, RES_FRM_SIZE,
+ RES_SURROUND, RES_SURROUND,
+ 0 );
+ aSet.Put(SwFmtAnchor(FLY_PAGE, 1));
+ if(bAlignLeft)
+ aSet.Put(SwFmtHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::PAGE_PRINT_AREA ));
+ else
+ aSet.Put(SwFmtHoriOrient( rDestination.X(), text::HoriOrientation::NONE, text::RelOrientation::PAGE_FRAME ));
+ aSet.Put(SwFmtVertOrient( rDestination.Y(), text::VertOrientation::NONE, text::RelOrientation::PAGE_FRAME ));
+ aSet.Put(SwFmtFrmSize( ATT_MIN_SIZE, DEFAULT_ADDRESS_WIDTH, DEFAULT_ADDRESS_HEIGHT ));
+ // the example gets a border around the frame, the real document doesn't get one
+ if(!bExample)
+ aSet.Put(SvxBoxItem( RES_BOX ));
+ aSet.Put(SwFmtSurround( SURROUND_NONE ));
+
+ rShell.NewFlyFrm(aSet, sal_True );
+ SwFrmFmt* pRet = rShell.GetFlyFrmFmt();
+ ASSERT( pRet, "Fly not inserted" );
+
+ rShell.UnSelectFrm();
+ const Sequence< ::rtl::OUString> aBlocks = rConfigItem.GetAddressBlocks();
+ if(bExample)
+ {
+ rShell.Insert(aBlocks[0]);
+ }
+ else
+ {
+ //the placeholders should be replaced by the appropriate fields
+ SwFldMgr aFldMgr(&rShell);
+ //create a database string source.command.commandtype.column
+ const SwDBData& rData = rConfigItem.GetCurrentDBData();
+ String sDBName(rData.sDataSource);
+ sDBName += DB_DELIM;
+ sDBName += String(rData.sCommand);
+ sDBName += DB_DELIM;
+ String sDatabaseConditionPrefix(sDBName);
+ sDatabaseConditionPrefix.SearchAndReplaceAll(DB_DELIM, '.');
+ sDBName += String::CreateFromInt32(rData.nCommandType);
+ sDBName += DB_DELIM;
+
+ // if only the country is in an address line the
+ // paragraph has to be hidden depending on the
+ // IsIncludeCountry()/GetExcludeCountry() settings
+
+ sal_Bool bIncludeCountry = rConfigItem.IsIncludeCountry();
+ sal_Bool bHideEmptyParagraphs = rConfigItem.IsHideEmptyParagraphs();
+ const ::rtl::OUString rExcludeCountry = rConfigItem.GetExcludeCountry();
+ bool bSpecialReplacementForCountry = (!bIncludeCountry || rExcludeCountry.getLength());
+
+ const ResStringArray& rHeaders = rConfigItem.GetDefaultAddressHeaders();
+ String sCountryColumn = rHeaders.GetString(MM_PART_COUNTRY);
+ Sequence< ::rtl::OUString> aAssignment =
+ rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
+ const ::rtl::OUString* pAssignment = aAssignment.getConstArray();
+ if(aAssignment.getLength() > MM_PART_COUNTRY && aAssignment[MM_PART_COUNTRY].getLength())
+ sCountryColumn = aAssignment[MM_PART_COUNTRY];
+ //
+ String sHideParagraphsExpression;
+ SwAddressIterator aIter(aBlocks[0]);
+ while(aIter.HasMore())
+ {
+ SwMergeAddressItem aItem = aIter.Next();
+ if(aItem.bIsColumn)
+ {
+ String sConvertedColumn = aItem.sText;
+ for(USHORT nColumn = 0;
+ nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
+ ++nColumn)
+ {
+ if(rHeaders.GetString(nColumn) == aItem.sText &&
+ pAssignment[nColumn].getLength())
+ {
+ sConvertedColumn = pAssignment[nColumn];
+ break;
+ }
+ }
+ String sDB(sDBName);
+ sDB += sConvertedColumn;
+
+ if(sHideParagraphsExpression.Len())
+ sHideParagraphsExpression.AppendAscii(" AND ");
+ sHideParagraphsExpression += '!';
+ sHideParagraphsExpression += '[';
+ sHideParagraphsExpression += sDatabaseConditionPrefix;
+ sHideParagraphsExpression += sConvertedColumn;
+ sHideParagraphsExpression += ']';
+
+ if( bSpecialReplacementForCountry && sCountryColumn == sConvertedColumn )
+ {
+ // now insert a hidden paragraph field
+ String sExpression;
+ if( rExcludeCountry.getLength() )
+ {
+ sExpression = sDatabaseConditionPrefix;
+ sExpression.Insert('[', 0);
+ sExpression += sCountryColumn;
+ sExpression.AppendAscii("]");
+
+ String sCondition(sExpression);
+ sCondition.AppendAscii(" != \"");
+ sCondition += String(rExcludeCountry);
+ sCondition += '\"';
+
+ SwInsertFld_Data aData(TYP_CONDTXTFLD, 0, sCondition, sExpression, 0, &rShell );
+ aFldMgr.InsertFld( aData );
+ }
+ else
+ {
+ SwInsertFld_Data aData(TYP_HIDDENPARAFLD, 0, sExpression, aEmptyStr, 0, &rShell );
+ aFldMgr.InsertFld( aData );
+ }
+ }
+ else
+ {
+ SwInsertFld_Data aData(TYP_DBFLD, 0, sDB, aEmptyStr, 0, &rShell );
+ aFldMgr.InsertFld( aData );
+ }
+ }
+ else if(!aItem.bIsReturn)
+ {
+ rShell.Insert(aItem.sText);
+ }
+ else
+ {
+ if(bHideEmptyParagraphs)
+ {
+ SwInsertFld_Data aData(TYP_HIDDENPARAFLD, 0, sHideParagraphsExpression, aEmptyStr, 0, &rShell );
+ aFldMgr.InsertFld( aData );
+ }
+ sHideParagraphsExpression.Erase();
+ //now add a new paragraph
+ rShell.SplitNode();
+ }
+ }
+ if(bHideEmptyParagraphs && sHideParagraphsExpression.Len())
+ {
+ SwInsertFld_Data aData(TYP_HIDDENPARAFLD, 0, sHideParagraphsExpression, aEmptyStr, 0, &rShell );
+ aFldMgr.InsertFld( aData );
+ }
+ }
+ return pRet;
+}
+
+/*-- 12.05.2004 12:20:19---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfigItem& rConfigItem, bool bExample)
+{
+ //set the cursor to the desired position - if no text content is here then
+ //new paragraphs are inserted
+ const SwRect& rPageRect = rShell.GetAnyCurRect(RECT_PAGE);
+ const Point aGreetingPos( DEFAULT_LEFT_DISTANCE + rPageRect.Left(), GREETING_TOP_DISTANCE );
+
+ const sal_Bool bRet = rShell.SetShadowCrsrPos( aGreetingPos, FILL_SPACE );
+
+ if(!bRet)
+ {
+ //there's already text at the desired position
+ //go to start of the doc, directly!
+ rShell.SttEndDoc(TRUE);
+ //and go by paragraph until the position is reached
+ long nYPos = rShell.GetCharRect().Top();
+ while(nYPos < GREETING_TOP_DISTANCE)
+ {
+ if(!rShell.FwdPara())
+ break;
+ nYPos = rShell.GetCharRect().Top();
+ }
+ //text needs to be appended
+ while(nYPos < GREETING_TOP_DISTANCE)
+ {
+ if(!rShell.AppendTxtNode())
+ break;
+ nYPos = rShell.GetCharRect().Top();
+ }
+ }
+ else
+ {
+ //we may end up inside of a paragraph if the left margin is not at DEFAULT_LEFT_DISTANCE
+ rShell.MovePara(GetfnParaCurr(), GetfnParaStart());
+ }
+ bool bSplitNode = rShell.GetText().Len() > 0;
+// rShell.SetTxtFmtColl( rShell.GetTxtCollFromPool( RES_POOLCOLL_GREETING ) );
+ sal_Int32 nMoves = rConfigItem.GetGreetingMoves();
+ if( !bExample && 0 != nMoves )
+ {
+ if(nMoves < 0)
+ {
+ rShell.MoveParagraph( nMoves );
+ }
+ else
+ while(nMoves)
+ {
+ sal_Bool bMoved = rShell.MoveParagraph( 1 );
+ if(!bMoved)
+ {
+ //insert a new paragraph before the greeting line
+ rShell.SplitNode();
+ }
+ --nMoves;
+ }
+ }
+ //now insert the greeting text - if we have any?
+ const sal_Bool bIndividual = rConfigItem.IsIndividualGreeting(sal_False);
+ String sGreeting;
+ if(bIndividual)
+ {
+ //lock expression fields - prevents hiding of the paragraph to insert into
+ rShell.LockExpFlds();
+ if(bExample)
+ {
+ for(sal_Int8 eGender = SwMailMergeConfigItem::FEMALE;
+ eGender <= SwMailMergeConfigItem::NEUTRAL; ++eGender)
+ {
+ Sequence< ::rtl::OUString > aEntries =
+ rConfigItem.GetGreetings((SwMailMergeConfigItem::Gender)eGender);
+ sal_Int32 nCurrent = rConfigItem.GetCurrentGreeting((SwMailMergeConfigItem::Gender)eGender);
+ if( nCurrent >= 0 && nCurrent < aEntries.getLength())
+ {
+ sGreeting = aEntries[nCurrent];
+ rShell.Insert(sGreeting);
+ break;
+ }
+ }
+ }
+ else
+ {
+ SwFldMgr aFldMgr(&rShell);
+ //three paragraphs, each with an appropriate hidden paragraph field
+ //are to be inserted
+
+ //name of the gender column
+ String sGenderColumn = rConfigItem.GetAssignedColumn(MM_PART_GENDER);
+ String sNameColumn = rConfigItem.GetAssignedColumn(MM_PART_LASTNAME);
+
+ const ::rtl::OUString& rFemaleGenderValue = rConfigItem.GetFemaleGenderValue();
+ sal_Bool bHideEmptyParagraphs = rConfigItem.IsHideEmptyParagraphs();
+ const SwDBData& rData = rConfigItem.GetCurrentDBData();
+ String sConditionBase(rData.sDataSource);
+ sConditionBase += '.';
+ sConditionBase += String(rData.sCommand);
+ sConditionBase += '.';
+ //split the name column from here
+ String sNameColumnBase(sConditionBase);
+
+ sConditionBase += String(sGenderColumn);
+ sConditionBase += ']';
+ sConditionBase.Insert('[', 0);
+
+ sNameColumnBase += String(sNameColumn);
+ sNameColumnBase += ']';
+ sNameColumnBase.Insert('[', 0);
+
+ String sDBName(rData.sDataSource);
+ sDBName += DB_DELIM;
+ sDBName += String(rData.sCommand);
+ sDBName += DB_DELIM;
+ sDBName += String::CreateFromInt32(rData.nCommandType);
+ sDBName += DB_DELIM;
+
+// Female: [database.sGenderColumn] != "rFemaleGenderValue" && [database.NameColumn]
+// Male: [database.sGenderColumn] == "rFemaleGenderValue" && [database.rGenderColumn]
+// Neutral: [database.sNameColumn]
+ DBG_ASSERT(sGenderColumn.Len() && rFemaleGenderValue.getLength(),
+ "gender settings not available - how to form the condition?");
+ //column used as lastname
+ for(sal_Int8 eGender = SwMailMergeConfigItem::FEMALE;
+ eGender <= SwMailMergeConfigItem::NEUTRAL; ++eGender)
+ {
+ Sequence< ::rtl::OUString> aEntries = rConfigItem.GetGreetings((SwMailMergeConfigItem::Gender)eGender);
+ sal_Int32 nCurrent = rConfigItem.GetCurrentGreeting((SwMailMergeConfigItem::Gender)eGender);
+ if( nCurrent >= 0 && nCurrent < aEntries.getLength())
+ {
+ sGreeting = aEntries[nCurrent];
+ String sCondition(sConditionBase);
+ String sHideParagraphsExpression;
+ switch(eGender)
+ {
+ case SwMailMergeConfigItem::FEMALE:
+ sCondition.AppendAscii(" != \"");
+ sCondition += String(rFemaleGenderValue);
+ sCondition.AppendAscii("\" OR NOT ");
+ sCondition += String(sNameColumnBase);
+
+ sHideParagraphsExpression += '!';
+ sHideParagraphsExpression += sNameColumnBase;
+ break;
+ case SwMailMergeConfigItem::MALE:
+ sCondition.AppendAscii(" == \"");
+ sCondition += String(rFemaleGenderValue);
+ sCondition.AppendAscii("\" OR NOT ");
+ sCondition += String(sNameColumnBase);
+ break;
+ case SwMailMergeConfigItem::NEUTRAL:
+ sCondition = sNameColumnBase;
+ break;
+ }
+
+ if(bHideEmptyParagraphs && sHideParagraphsExpression.Len())
+ {
+ String sComplete( sCondition );
+ sComplete.Insert('(', 0);
+ sComplete.AppendAscii( ") OR (");
+ sComplete += sHideParagraphsExpression;
+ sComplete += ')';
+ SwInsertFld_Data aData(TYP_HIDDENPARAFLD, 0, sComplete, aEmptyStr, 0, &rShell );
+ aFldMgr.InsertFld( aData );
+ }
+ else
+ {
+ SwInsertFld_Data aData(TYP_HIDDENPARAFLD, 0, sCondition, aEmptyStr, 0, &rShell );
+ aFldMgr.InsertFld( aData );
+ }
+ //now the text has to be inserted
+ const ResStringArray& rHeaders = rConfigItem.GetDefaultAddressHeaders();
+ Sequence< ::rtl::OUString> aAssignment =
+ rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
+ const ::rtl::OUString* pAssignment = aAssignment.getConstArray();
+ SwAddressIterator aIter(sGreeting);
+ while(aIter.HasMore())
+ {
+ SwMergeAddressItem aItem = aIter.Next();
+ if(aItem.bIsColumn)
+ {
+ String sDB(sDBName);
+ String sConvertedColumn = aItem.sText;
+ for(USHORT nColumn = 0;
+ nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
+ ++nColumn)
+ {
+ if(rHeaders.GetString(nColumn) == aItem.sText &&
+ pAssignment[nColumn].getLength())
+ {
+ sConvertedColumn = pAssignment[nColumn];
+ break;
+ }
+ }
+ sDB += sConvertedColumn;
+ SwInsertFld_Data aData(TYP_DBFLD, 0, sDB, aEmptyStr, 0, &rShell );
+ aFldMgr.InsertFld( aData );
+ }
+ else
+ {
+ rShell.Insert(aItem.sText);
+ }
+ }
+ //now add a new paragraph
+ rShell.SplitNode();
+ }
+ }
+
+ }
+ rShell.UnlockExpFlds();
+ }
+ else
+ {
+ Sequence< ::rtl::OUString> aEntries = rConfigItem.GetGreetings(SwMailMergeConfigItem::NEUTRAL);
+ sal_Int32 nCurrent = rConfigItem.GetCurrentGreeting(SwMailMergeConfigItem::NEUTRAL);
+ if( nCurrent >= 0 && nCurrent < aEntries.getLength())
+ sGreeting = aEntries[nCurrent];
+ rShell.Insert(sGreeting);
+ }
+ // now insert a new paragraph here if necessary
+ if(bSplitNode)
+ {
+ rShell.Push();
+ rShell.SplitNode();
+ rShell.Pop(FALSE);
+ }
+ //put the cursor to the start of the paragraph
+ rShell.SttPara();
+
+ DBG_ASSERT(0 == rShell.GetTableFmt(), "What to do with a table here?");
+}
+/*-- 10.05.2004 09:34:25---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeLayoutPage, PreviewLoadedHdl_Impl, void*, EMPTYARG)
+{
+ m_aExampleWIN.Show( TRUE );
+ m_aExampleContainerWIN.Show(FALSE);
+
+ Reference< XModel > & xModel = m_pExampleFrame->GetModel();
+ //now the ViewOptions should be set properly
+ Reference< XViewSettingsSupplier > xSettings(xModel->getCurrentController(), UNO_QUERY);
+ m_xViewProperties = xSettings->getViewSettings();
+ Reference< XUnoTunnel > xDocTunnel(xModel, UNO_QUERY);
+ SwXTextDocument* pXDoc = reinterpret_cast<SwXTextDocument*>(xDocTunnel->getSomething(SwXTextDocument::getUnoTunnelId()));
+ SwDocShell* pDocShell = pXDoc->GetDocShell();
+ m_pExampleWrtShell = pDocShell->GetWrtShell();
+ DBG_ASSERT(m_pExampleWrtShell, "No SwWrtShell found!");
+ if(!m_pExampleWrtShell)
+ return 0;
+
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ if(rConfigItem.IsAddressBlock())
+ {
+ m_pAddressBlockFormat = InsertAddressFrame(
+ *m_pExampleWrtShell, rConfigItem,
+ Point(DEFAULT_LEFT_DISTANCE, DEFAULT_TOP_DISTANCE),
+ m_aAlignToBodyCB.IsChecked(), true);
+ }
+ if(rConfigItem.IsGreetingLine(sal_False))
+ {
+ InsertGreeting(*m_pExampleWrtShell, rConfigItem, true);
+ m_bIsGreetingInserted = true;
+ }
+
+ Any aZoom;
+ aZoom <<= (sal_Int16)DocumentZoomType::ENTIRE_PAGE;
+ m_xViewProperties->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom);
+
+
+// m_pExampleWrtShell->SetTxtFmtColl( rSh.GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
+ const SwFmtFrmSize& rPageSize = m_pExampleWrtShell->GetPageDesc(
+ m_pExampleWrtShell->GetCurPageDesc()).GetMaster().GetFrmSize();
+ m_aLeftMF.SetMax(rPageSize.GetWidth() - DEFAULT_LEFT_DISTANCE);
+ m_aTopMF.SetMax(rPageSize.GetHeight() - DEFAULT_TOP_DISTANCE);
+ return 0;
+}
+/*-- 10.05.2004 14:05:24---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeLayoutPage, ZoomHdl_Impl, ListBox*, pBox)
+{
+ if(m_pExampleWrtShell)
+ {
+ sal_Int16 eType = DocumentZoomType::BY_VALUE;
+ short nZoom = 50;
+ switch(pBox->GetSelectEntryPos())
+ {
+ case 0 : eType = DocumentZoomType::ENTIRE_PAGE; break;
+ case 1 : nZoom = 50; break;
+ case 2 : nZoom = 75; break;
+ case 3 : nZoom = 100; break;
+ }
+ Any aZoom;
+ aZoom <<= eType;
+ m_xViewProperties->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom);
+ aZoom <<= nZoom;
+ m_xViewProperties->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE)), aZoom);
+
+ }
+ return 0;
+}
+
+
+/*-- 10.05.2004 15:56:51---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeLayoutPage, ChangeAddressHdl_Impl, MetricField*, EMPTYARG)
+{
+ if(m_pExampleWrtShell && m_pAddressBlockFormat)
+ {
+ long nLeft = static_cast< long >(m_aLeftMF.Denormalize(m_aLeftMF.GetValue(FUNIT_TWIP)));
+ long nTop = static_cast< long >(m_aTopMF.Denormalize(m_aTopMF.GetValue(FUNIT_TWIP)));
+
+ SfxItemSet aSet(m_pExampleWrtShell->GetAttrPool(), RES_ANCHOR, RES_ANCHOR,
+ RES_VERT_ORIENT, RES_VERT_ORIENT,
+ RES_HORI_ORIENT, RES_HORI_ORIENT,
+ 0 );
+ if(m_aAlignToBodyCB.IsChecked())
+ aSet.Put(SwFmtHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::PAGE_PRINT_AREA ));
+ else
+ aSet.Put(SwFmtHoriOrient( nLeft, text::HoriOrientation::NONE, text::RelOrientation::PAGE_FRAME ));
+ aSet.Put(SwFmtVertOrient( nTop, text::VertOrientation::NONE, text::RelOrientation::PAGE_FRAME ));
+ m_pExampleWrtShell->GetDoc()->SetFlyFrmAttr( *m_pAddressBlockFormat, aSet );
+ }
+ return 0;
+}
+
+/*-- 10.05.2004 16:13:36---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeLayoutPage, GreetingsHdl_Impl, PushButton*, pButton)
+{
+ bool bDown = pButton == &m_aDownPB;
+ BOOL bMoved = m_pExampleWrtShell->MoveParagraph( bDown ? 1 : -1 );
+ if (bMoved || bDown)
+ m_pWizard->GetConfigItem().MoveGreeting(bDown ? 1 : -1 );
+ if(!bMoved && bDown)
+ {
+ //insert a new paragraph before the greeting line
+ m_pExampleWrtShell->SplitNode();
+ }
+
+ return 0;
+}
+/*-- 15.07.2004 16:05:30---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeLayoutPage, AlignToTextHdl_Impl, CheckBox*, pBox)
+{
+ sal_Bool bCheck = pBox->IsChecked() && pBox->IsEnabled();
+ m_aLeftFT.Enable(!bCheck);
+ m_aLeftMF.Enable(!bCheck);
+ ChangeAddressHdl_Impl( 0 );
+ return 0;
+}
diff --git a/sw/source/ui/dbui/mmlayoutpage.hrc b/sw/source/ui/dbui/mmlayoutpage.hrc
new file mode 100644
index 000000000000..bf0100b32de6
--- /dev/null
+++ b/sw/source/ui/dbui/mmlayoutpage.hrc
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmlayoutpage.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGELAYOUTPAGE_HRC
+#define _MAILMERGELAYOUTPAGE_HRC
+
+#define FI_HEADER 1
+#define FL_POSITION 2
+#define FT_LEFT 3
+#define MF_LEFT 4
+#define FT_TOP 5
+#define MF_TOP 6
+#define FL_GREETINGLINE 7
+#define FT_UP 8
+#define MF_UP 9
+#define FT_DOWN 10
+#define PB_DOWN 11
+#define CB_ALIGN 12
+
+#define WIN_EXAMPLECONTAINER 13
+#define FT_ZOOM 14
+#define LB_ZOOM 15
+
+#endif
+
diff --git a/sw/source/ui/dbui/mmlayoutpage.hxx b/sw/source/ui/dbui/mmlayoutpage.hxx
new file mode 100644
index 000000000000..bb1e012c857b
--- /dev/null
+++ b/sw/source/ui/dbui/mmlayoutpage.hxx
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmlayoutpage.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGELAYOUTPAGE_HXX
+#define _MAILMERGELAYOUTPAGE_HXX
+
+#include <svtools/wizardmachine.hxx>
+#include <mailmergehelper.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <svtools/stdctrl.hxx>
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+#include <com/sun/star/uno/Reference.h>
+
+class SwMailMergeWizard;
+class SwFrmFmt;
+class SwOneExampleFrame;
+class SwWrtShell;
+class SwView;
+
+namespace com{ namespace sun{ namespace star{ namespace beans{ class XPropertySet;}}}}
+/*-- 02.04.2004 09:21:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwMailMergeLayoutPage : public svt::OWizardPage
+{
+ SwBoldFixedInfo m_aHeaderFI;
+
+ FixedLine m_aPositionFL;
+
+ CheckBox m_aAlignToBodyCB;
+ FixedText m_aLeftFT;
+ MetricField m_aLeftMF;
+ FixedText m_aTopFT;
+ MetricField m_aTopMF;
+
+ FixedLine m_aGreetingLineFL;
+ FixedText m_aUpFT;
+ PushButton m_aUpPB;
+ FixedText m_aDownFT;
+ PushButton m_aDownPB;
+
+ Window m_aExampleContainerWIN;
+ Window m_aExampleWIN;
+
+ FixedText m_aZoomFT;
+ ListBox m_aZoomLB;
+
+ SwOneExampleFrame* m_pExampleFrame;
+ SwWrtShell* m_pExampleWrtShell;
+
+ String m_sExampleURL;
+ SwFrmFmt* m_pAddressBlockFormat;
+
+ bool m_bIsGreetingInserted;
+
+ SwMailMergeWizard* m_pWizard;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xViewProperties;
+
+ DECL_LINK(PreviewLoadedHdl_Impl, void*);
+ DECL_LINK(ZoomHdl_Impl, ListBox*);
+ DECL_LINK(ChangeAddressHdl_Impl, MetricField*);
+ DECL_LINK(GreetingsHdl_Impl, PushButton*);
+ DECL_LINK(AlignToTextHdl_Impl, CheckBox*);
+
+ static SwFrmFmt* InsertAddressFrame(
+ SwWrtShell& rShell,
+ SwMailMergeConfigItem& rConfigItem,
+ const Point& rDestination,
+ bool bAlignToBody,
+ bool bExample);
+ static void InsertGreeting(SwWrtShell& rShell, SwMailMergeConfigItem& rConfigItem, bool bExample);
+
+ virtual void ActivatePage();
+ virtual sal_Bool commitPage(CommitPageReason _eReason);
+public:
+ SwMailMergeLayoutPage( SwMailMergeWizard* _pParent);
+ ~SwMailMergeLayoutPage();
+
+ static SwFrmFmt* InsertAddressAndGreeting(SwView* pView,
+ SwMailMergeConfigItem& rConfigItem,
+ const Point& rAddressPos,
+ bool bAlignToBody);
+};
+
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmlayoutpage.src b/sw/source/ui/dbui/mmlayoutpage.src
new file mode 100644
index 000000000000..4c30916ef908
--- /dev/null
+++ b/sw/source/ui/dbui/mmlayoutpage.src
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmlayoutpage.src,v $
+ * $Revision: 1.9 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <mmlayoutpage.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+TabPage DLG_MM_LAYOUT_PAGE
+{
+ HelpID = HID_MM_LAYOUT_PAGE;
+ Size = MAP_APPFONT ( 260 , 250 ) ;
+ Hide = TRUE ;
+
+ FixedText FI_HEADER
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text[ en-US ] = "Adjust layout of address block and salutation";
+ };
+ FixedLine FL_POSITION
+ {
+ Pos = MAP_APPFONT ( 6 , 27 ) ;
+ Size = MAP_APPFONT ( 118 , 8 ) ;
+ Text[ en-US ] = "Address block position";
+ };
+ CheckBox CB_ALIGN
+ {
+ Pos = MAP_APPFONT ( 6 , 40 ) ;
+ Size = MAP_APPFONT ( 118 , 10 ) ;
+ Text[ en-US ] = "Align to text body";
+ };
+ FixedText FT_LEFT
+ {
+ Pos = MAP_APPFONT ( 15 , 54 ) ;
+ Size = MAP_APPFONT ( 63 , 8 ) ;
+ Text[ en-US ] = "From ~left";
+ };
+ MetricField MF_LEFT
+ {
+ Pos = MAP_APPFONT ( 78 , 52 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Border = TRUE ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ Maximum = 99999 ;
+ DecimalDigits = 2 ;
+ Value = 200 ;
+ Unit = FUNIT_CM ;
+ First = 10 ;
+ Last = 99999 ;
+ SpinSize = 10 ;
+ };
+ FixedText FT_TOP
+ {
+ Pos = MAP_APPFONT ( 15 , 69 ) ;
+ Size = MAP_APPFONT ( 62 , 8 ) ;
+ Text[ en-US ] = "~From top";
+ };
+ MetricField MF_TOP
+ {
+ Pos = MAP_APPFONT ( 78 , 67 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Border = TRUE ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ Maximum = 99999 ;
+ DecimalDigits = 2 ;
+ Value = 200 ;
+ Unit = FUNIT_CM ;
+ First = 10 ;
+ Last = 99999 ;
+ SpinSize = 10 ;
+ };
+ FixedLine FL_GREETINGLINE
+ {
+ Pos = MAP_APPFONT ( 6 , 85 ) ;
+ Size = MAP_APPFONT ( 118 , 8 ) ;
+ Text[ en-US ] = "Salutation position";
+ };
+ FixedText FT_UP
+ {
+ Pos = MAP_APPFONT ( 15 , 98 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ Text[ en-US ] = "Move";
+ };
+ PushButton MF_UP
+ {
+ Pos = MAP_APPFONT ( 68 , 96 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "~Up";
+ };
+ FixedText FT_DOWN
+ {
+ Pos = MAP_APPFONT ( 15 , 115 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ Text[ en-US ] = "Move";
+ };
+ PushButton PB_DOWN
+ {
+ Pos = MAP_APPFONT ( 68 , 113 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "~Down";
+ };
+ Window WIN_EXAMPLECONTAINER
+ {
+ Pos = MAP_APPFONT ( 130 , 20 ) ;
+ Size = MAP_APPFONT ( 124 , 159 ) ;
+ Border = TRUE;
+ };
+ FixedText FT_ZOOM
+ {
+ Pos = MAP_APPFONT ( 161 , 185 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Right = TRUE;
+ Text[ en-US ] = "~Zoom";
+ };
+ ListBox LB_ZOOM
+ {
+ Pos = MAP_APPFONT ( 204 , 182 ) ;
+ Size = MAP_APPFONT ( 50 , 50 ) ;
+ Border = TRUE;
+ DropDown = TRUE;
+ StringList [en-US]= \
+ { \
+ < "Entire page" ; > ; \
+ };
+ };
+
+};
+
+
+
diff --git a/sw/source/ui/dbui/mmmergepage.cxx b/sw/source/ui/dbui/mmmergepage.cxx
new file mode 100644
index 000000000000..d6083d1fc712
--- /dev/null
+++ b/sw/source/ui/dbui/mmmergepage.cxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmmergepage.cxx,v $
+ * $Revision: 1.12 $
+ *
+ * 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 <mmmergepage.hxx>
+#include <mailmergewizard.hxx>
+#include <mmconfigitem.hxx>
+#include <swtypes.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <dbui.hrc>
+#include <mmmergepage.hrc>
+#include <svx/srchitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svtools/eitem.hxx>
+#include <swabstdlg.hxx>
+
+/*-- 02.04.2004 16:38:45---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeMergePage::SwMailMergeMergePage( SwMailMergeWizard* _pParent) :
+ svt::OWizardPage(_pParent, SW_RES(DLG_MM_MERGE_PAGE)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aHeaderFI(this, SW_RES( FI_HEADER ) ),
+ m_aEditFI(this, SW_RES( FI_EDIT )),
+ m_aEditPB(this, SW_RES( PB_EDIT )),
+ m_aFindFL(this, SW_RES( FL_FIND )),
+ m_aFineFT(this, SW_RES( FT_FIND )),
+ m_aFindED(this, SW_RES( ED_FIND )),
+ m_aFindPB(this, SW_RES( PB_FIND )),
+ m_aWholeWordsCB(this, SW_RES( CB_WHOLEWORDS)),
+ m_aBackwardsCB(this, SW_RES( CB_BACKWARDS )),
+ m_aMatchCaseCB(this, SW_RES( CB_MATCHCASE )),
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+ m_pWizard(_pParent)
+{
+ FreeResource();
+ String sTemp(m_aEditFI.GetText());
+ sTemp.SearchAndReplace(String::CreateFromAscii("%1"), m_aEditPB.GetText());
+ m_aEditFI.SetText(sTemp);
+ m_aEditPB.SetClickHdl( LINK( this, SwMailMergeMergePage, EditDocumentHdl_Impl));
+ m_aFindPB.SetClickHdl( LINK( this, SwMailMergeMergePage, FindHdl_Impl ));
+
+ m_aFindED.SetReturnActionLink( LINK(this, SwMailMergeMergePage, EnteredFindStringHdl_Impl ));
+
+}
+/*-- 02.04.2004 16:38:45---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeMergePage::~SwMailMergeMergePage()
+{
+}
+/*-- 25.05.2004 16:14:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( SwMailMergeMergePage, EditDocumentHdl_Impl, PushButton*, EMPTYARG)
+{
+ m_pWizard->SetRestartPage(MM_MERGEPAGE);
+ m_pWizard->EndDialog(RET_EDIT_RESULT_DOC);
+ return 0;
+}
+/*-- 25.05.2004 16:14:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( SwMailMergeMergePage, FindHdl_Impl, PushButton*, EMPTYARG)
+{
+ SvxSearchItem aSearchItem( SID_SEARCH_ITEM );
+
+ SfxBoolItem aQuiet( SID_SEARCH_QUIET, sal_False );
+ aSearchItem.SetSearchString(m_aFindED.GetText());
+
+ aSearchItem.SetWordOnly(m_aWholeWordsCB.IsChecked());
+ aSearchItem.SetExact(m_aMatchCaseCB.IsChecked());
+ aSearchItem.SetBackward(m_aBackwardsCB.IsChecked());
+
+ SwView* pTargetView = m_pWizard->GetConfigItem().GetTargetView();
+ DBG_ASSERT(pTargetView, "no target view exists");
+ if(pTargetView)
+ {
+ pTargetView->GetViewFrame()->GetDispatcher()->Execute(
+ FID_SEARCH_NOW, SFX_CALLMODE_SYNCHRON, &aSearchItem, &aQuiet, 0L );
+ }
+
+ return 0;
+}
+IMPL_LINK( SwMailMergeMergePage, EnteredFindStringHdl_Impl, void*, EMPTYARG )
+{
+ m_aFindPB.GetClickHdl().Call( &m_aFindPB );
+ return 0;
+}
diff --git a/sw/source/ui/dbui/mmmergepage.hrc b/sw/source/ui/dbui/mmmergepage.hrc
new file mode 100644
index 000000000000..e01c4ab46b85
--- /dev/null
+++ b/sw/source/ui/dbui/mmmergepage.hrc
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmmergepage.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEMERGEPAGE_HRC
+#define _MAILMERGEMERGEPAGE_HRC
+
+#define FI_HEADER 1
+#define FI_EDIT 2
+#define PB_EDIT 3
+#define FL_FIND 4
+#define FT_FIND 5
+#define ED_FIND 6
+#define PB_FIND 7
+#define CB_WHOLEWORDS 8
+#define CB_BACKWARDS 9
+#define CB_MATCHCASE 10
+
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmmergepage.hxx b/sw/source/ui/dbui/mmmergepage.hxx
new file mode 100644
index 000000000000..da6f008b5b6d
--- /dev/null
+++ b/sw/source/ui/dbui/mmmergepage.hxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmmergepage.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEMERGEPAGE_HXX
+#define _MAILMERGEMERGEPAGE_HXX
+
+#include <svtools/wizardmachine.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <vcl/edit.hxx>
+#include <svtools/stdctrl.hxx>
+#include <mailmergehelper.hxx>
+#include <actctrl.hxx>
+class SwMailMergeWizard;
+/*-- 02.04.2004 09:21:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwMailMergeMergePage : public svt::OWizardPage
+{
+ SwBoldFixedInfo m_aHeaderFI;
+
+ FixedInfo m_aEditFI;
+ PushButton m_aEditPB;
+
+ FixedLine m_aFindFL;
+ FixedText m_aFineFT;
+ ReturnActionEdit m_aFindED;
+ PushButton m_aFindPB;
+
+ CheckBox m_aWholeWordsCB;
+ CheckBox m_aBackwardsCB;
+ CheckBox m_aMatchCaseCB;
+
+ SwMailMergeWizard* m_pWizard;
+
+ DECL_LINK(EditDocumentHdl_Impl, PushButton*);
+ DECL_LINK(FindHdl_Impl, PushButton*);
+ DECL_LINK(EnteredFindStringHdl_Impl, void*);
+
+public:
+ SwMailMergeMergePage( SwMailMergeWizard* _pParent);
+ ~SwMailMergeMergePage();
+
+};
+
+
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmmergepage.src b/sw/source/ui/dbui/mmmergepage.src
new file mode 100644
index 000000000000..068a51f57a04
--- /dev/null
+++ b/sw/source/ui/dbui/mmmergepage.src
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmmergepage.src,v $
+ * $Revision: 1.9 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <mmmergepage.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+TabPage DLG_MM_MERGE_PAGE
+{
+ HelpID = HID_MM_MERGEPAGE ;
+ Size = MAP_APPFONT ( 260 , 250 ) ;
+ Hide = TRUE ;
+
+ FixedText FI_HEADER
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Personalize the mail merge documents";
+ };
+ FixedText FI_EDIT
+ {
+ Pos = MAP_APPFONT ( 6 , 27 ) ;
+ Size = MAP_APPFONT ( 248 , 38 ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "You can personalize particular documents. Clicking '%1' will temporarily reduce the wizard to a small window so you can edit your document. After editing the document, return to the wizard by clicking 'Return to Mail Merge Wizard' in the small window.";
+ };
+ PushButton PB_EDIT
+ {
+ Pos = MAP_APPFONT ( 70 , 67 ) ;
+ Size = MAP_APPFONT ( 120 , 14 ) ;
+ Text [ en-US ] = "~Edit individual document...";
+ };
+ FixedLine FL_FIND
+ {
+ Pos = MAP_APPFONT ( 6 , 102 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "~Find";
+ };
+ FixedText FT_FIND
+ {
+ Pos = MAP_APPFONT ( 16 ,116 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ Text [ en-US ] = "~Search for:";
+ };
+ Edit ED_FIND
+ {
+ Pos = MAP_APPFONT ( 55 ,114 ) ;
+ Size = MAP_APPFONT ( 140 , 12 ) ;
+ Border = TRUE;
+ };
+ PushButton PB_FIND
+ {
+ Pos = MAP_APPFONT ( 198 ,113 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Find...";
+ };
+ CheckBox CB_WHOLEWORDS
+ {
+ Pos = MAP_APPFONT ( 55 , 131 ) ;
+ Size = MAP_APPFONT ( 180 , 10 ) ;
+ Text [ en-US ] = "Whole wor~ds only";
+ };
+ CheckBox CB_BACKWARDS
+ {
+ Pos = MAP_APPFONT ( 55 , 144 ) ;
+ Size = MAP_APPFONT ( 180 , 10 ) ;
+ Text [ en-US ] = "Back~wards";
+ };
+ CheckBox CB_MATCHCASE
+ {
+ Pos = MAP_APPFONT ( 55 , 157 ) ;
+ Size = MAP_APPFONT ( 180 , 10 ) ;
+ Text [ en-US ] = "Ma~tch case";
+ };
+};
+
+
+
diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx
new file mode 100644
index 000000000000..eb1f75d57979
--- /dev/null
+++ b/sw/source/ui/dbui/mmoutputpage.cxx
@@ -0,0 +1,1409 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmoutputpage.cxx,v $
+ * $Revision: 1.23.136.2 $
+ *
+ * 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 <mmoutputpage.hxx>
+#include <mailmergewizard.hxx>
+#include <mmconfigitem.hxx>
+#include <mailmergechildwindow.hxx>
+#include <mailconfigpage.hxx>
+#include <cmdid.h>
+#include <swtypes.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <wrtsh.hxx>
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#ifndef IDOCUMENTDEVICEACCESS_HXX_INCLUDED
+#include <IDocumentDeviceAccess.hxx>
+#endif
+#include <hintids.hxx>
+#include <svx/scripttypeitem.hxx>
+#include <svx/langitem.hxx>
+#include <svtools/itemset.hxx>
+#include <svtools/stritem.hxx>
+#include <svtools/ehdl.hxx>
+#include <svtools/sfxecode.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/dinfdlg.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+//#ifndef _SFX_DOCFILT_HACK_HXX
+//#include <sfx2/docfilt.hxx>
+//#endif
+#include <tools/urlobj.hxx>
+#include <svtools/urihelper.hxx>
+#ifndef _VCL_PRINT_HXX
+#include <vcl/print.hxx>
+#endif
+#include <unotools/tempfile.hxx>
+#include <osl/file.hxx>
+#include <mmgreetingspage.hxx>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+//#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+//#include <com/sun/star/beans/PropertyValue.hpp>
+//#endif
+//#ifndef _BASEDLGS_HXX
+//#include <sfx2/basedlgs.hxx>
+//#endif
+#ifndef _DBMGR_HXX
+#include <dbmgr.hxx>
+#endif
+#include <swunohelper.hxx>
+#include <vos/mutex.hxx>
+#include <shellio.hxx>
+#include <svx/htmlcfg.hxx>
+#include <sfx2/event.hxx>
+#include <swevent.hxx>
+#include <mmoutputpage.hrc>
+#include <dbui.hxx>
+#include <dbui.hrc>
+#include <helpid.h>
+#include <sfx2/app.hxx>
+#include <statstr.hrc>
+#include <unomid.h>
+
+using namespace svt;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+/*-- 01.07.2004 16:47:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+String lcl_GetExtensionForDocType(ULONG nDocType)
+{
+ String sExtension;
+ switch( nDocType )
+ {
+ case MM_DOCTYPE_OOO : sExtension = String::CreateFromAscii( "odt" ); break;
+ case MM_DOCTYPE_PDF : sExtension = String::CreateFromAscii( "pdf" ); break;
+ case MM_DOCTYPE_WORD: sExtension = String::CreateFromAscii( "doc" ); break;
+ case MM_DOCTYPE_HTML: sExtension = String::CreateFromAscii( "html" ); break;
+ case MM_DOCTYPE_TEXT: sExtension = String::CreateFromAscii( "txt" ); break;
+ }
+ return sExtension;
+}
+/*-- 28.06.2004 11:49:21---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+::rtl::OUString lcl_GetColumnValueOf(const ::rtl::OUString& rColumn, Reference < container::XNameAccess>& rxColAccess )
+{
+ ::rtl::OUString sRet;
+ if(rxColAccess->hasByName(rColumn))
+ {
+ Any aCol = rxColAccess->getByName(rColumn);
+ Reference< sdb::XColumn > xColumn;
+ aCol >>= xColumn;
+ if(xColumn.is())
+ sRet = xColumn->getString();
+ }
+ return sRet;
+}
+/*-- 21.06.2004 14:01:13---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwSaveWarningBox_Impl : public ModalDialog
+{
+ FixedImage aWarningImageIM;
+ FixedInfo aWarningFI;
+
+ FixedText aFileNameFT;
+ Edit aFileNameED;
+
+ FixedLine aSeparatorFL;
+ OKButton aOKPB;
+ CancelButton aCancelPB;
+
+ DECL_LINK( ModifyHdl, Edit*);
+public:
+ SwSaveWarningBox_Impl(Window* pParent, const String& rFileName);
+ ~SwSaveWarningBox_Impl();
+
+ String GetFileName() const {return aFileNameED.GetText();}
+};
+/*-- 02.07.2004 08:54:42---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwSendQueryBox_Impl : public ModalDialog
+{
+ FixedImage aQueryImageIM;
+ FixedInfo aQueryFI;
+
+ Edit aTextED;
+
+ FixedLine aSeparatorFL;
+ OKButton aOKPB;
+ CancelButton aCancelPB;
+
+ bool bIsEmptyAllowed;
+ DECL_LINK( ModifyHdl, Edit*);
+public:
+ SwSendQueryBox_Impl(Window* pParent, const String& rQueryText);
+ ~SwSendQueryBox_Impl();
+
+ void SetValue(const String& rSet)
+ {
+ aTextED.SetText(rSet);
+ ModifyHdl( &aTextED );
+ }
+ String GetValue() const {return aTextED.GetText();}
+
+ void SetIsEmptyTextAllowed(bool bSet)
+ {
+ bIsEmptyAllowed = bSet;
+ ModifyHdl( &aTextED );
+ }
+};
+
+/*-- 21.06.2004 14:11:58---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwSaveWarningBox_Impl::SwSaveWarningBox_Impl(Window* pParent, const String& rFileName) :
+ ModalDialog(pParent, SW_RES( DLG_MM_SAVEWARNING )),
+ aWarningImageIM(this, SW_RES( IM_WARNING )),
+ aWarningFI(this, SW_RES( FI_WARNING )),
+ aFileNameFT(this, SW_RES( FT_FILENAME )),
+ aFileNameED(this, SW_RES( ED_FILENAME )),
+ aSeparatorFL(this, SW_RES( FL_SEPARATOR )),
+ aOKPB(this, SW_RES( PB_OK )),
+ aCancelPB(this, SW_RES( PB_CANCEL ))
+{
+ FreeResource();
+ aWarningImageIM.SetImage(WarningBox::GetStandardImage());
+ aFileNameED.SetText(rFileName);
+ aFileNameED.SetModifyHdl(LINK(this, SwSaveWarningBox_Impl, ModifyHdl));
+ ModifyHdl( &aFileNameED );
+}
+/*-- 21.06.2004 14:11:58---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwSaveWarningBox_Impl::~SwSaveWarningBox_Impl()
+{
+}
+/*-- 21.06.2004 14:11:58---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( SwSaveWarningBox_Impl, ModifyHdl, Edit*, pEdit)
+{
+ aOKPB.Enable(pEdit->GetText().Len() > 0);
+ return 0;
+}
+/*-- 02.07.2004 09:02:53---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwSendQueryBox_Impl::SwSendQueryBox_Impl(Window* pParent, const String& rText) :
+ ModalDialog(pParent, SW_RES( DLG_MM_QUERY )),
+ aQueryImageIM( this, SW_RES( IM_QUERY )),
+ aQueryFI( this, SW_RES( FI_QUERY )),
+ aTextED( this, SW_RES( ED_TEXT )),
+ aSeparatorFL(this, SW_RES( FL_SEPARATOR )),
+ aOKPB(this, SW_RES( PB_OK )),
+ aCancelPB(this, SW_RES( PB_CANCEL )),
+ bIsEmptyAllowed(true)
+{
+ FreeResource();
+ aQueryFI.SetText(rText);
+ aQueryImageIM.SetImage(QueryBox::GetStandardImage());
+ aTextED.SetModifyHdl(LINK(this, SwSendQueryBox_Impl, ModifyHdl));
+ ModifyHdl( &aTextED );
+}
+/*-- 02.07.2004 08:58:45---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwSendQueryBox_Impl::~SwSendQueryBox_Impl()
+{
+}
+/*-- 02.07.2004 08:58:25---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( SwSendQueryBox_Impl, ModifyHdl, Edit*, pEdit)
+{
+ aOKPB.Enable(bIsEmptyAllowed || (pEdit->GetText().Len() > 0));
+ return 0;
+}
+
+/*-- 16.04.2004 16:34:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwCopyToDialog : public SfxModalDialog
+{
+ FixedInfo m_aDescriptionFI;
+ FixedText m_aCCFT;
+ Edit m_aCCED;
+ FixedText m_aBCCFT;
+ Edit m_aBCCED;
+
+ FixedInfo m_aNoteFI;
+ FixedLine m_aSeparatorFL;
+
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+public:
+ SwCopyToDialog(Window* pParent);
+ ~SwCopyToDialog();
+
+ String GetCC() {return m_aCCED.GetText();}
+ void SetCC(const String& rSet) {m_aCCED.SetText(rSet);}
+
+ String GetBCC() {return m_aBCCED.GetText();}
+ void SetBCC(const String& rSet) {m_aBCCED.SetText(rSet);}
+};
+
+/*-- 16.04.2004 16:43:18---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwCopyToDialog::SwCopyToDialog(Window* pParent) :
+ SfxModalDialog(pParent, SW_RES(DLG_MM_COPYTO)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aDescriptionFI( this, SW_RES( FI_DESCRIPTION )),
+ m_aCCFT( this, SW_RES( FT_CC )),
+ m_aCCED( this, SW_RES( ED_CC )),
+ m_aBCCFT( this, SW_RES( FT_BCC )),
+ m_aBCCED( this, SW_RES( ED_BCC )),
+ m_aNoteFI( this, SW_RES( FI_NOTE )),
+ 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
+{
+ FreeResource();
+}
+/*-- 16.04.2004 16:43:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwCopyToDialog::~SwCopyToDialog()
+{
+}
+
+/*-- 02.04.2004 13:15:54---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeOutputPage::SwMailMergeOutputPage( SwMailMergeWizard* _pParent) :
+ svt::OWizardPage( _pParent, SW_RES(DLG_MM_OUTPUT_PAGE)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aHeaderFI(this, SW_RES( FI_HEADER ) ),
+ m_aOptionsFI(this, SW_RES( FI_OPTIONS ) ),
+ m_aSaveStartDocRB(this, SW_RES( RB_SAVESTARTDOC ) ),
+ m_aSaveMergedDocRB(this, SW_RES( RB_SAVEMERGEDDOC ) ),
+ m_aPrintRB(this, SW_RES( RB_PRINT ) ),
+ m_aSendMailRB(this, SW_RES( RB_SENDMAIL ) ),
+
+ m_aSeparatorFL(this, SW_RES( FL_SEPARATOR ) ),
+
+ m_aSaveStartDocPB(this, SW_RES( PB_SAVESTARTDOC ) ),
+
+ m_aSaveAsOneRB(this, SW_RES( RB_SAVEASONE ) ),
+ m_aSaveIndividualRB(this, SW_RES( RB_SAVEINDIVIDUAL ) ),
+ m_aPrintAllRB(this, SW_RES( RB_PRINTALL ) ),
+ m_aSendAllRB( this, SW_RES( RB_SENDALL ) ),
+
+ m_aFromRB(this, SW_RES( RB_FROM ) ),
+ m_aFromNF(this, SW_RES( NF_FROM ) ),
+ m_aToFT(this, SW_RES( FT_TO ) ),
+ m_aToNF(this, SW_RES( NF_TO ) ),
+ m_aSaveNowPB(this, SW_RES( PB_SAVENOW ) ),
+
+ m_aPrinterFT(this, SW_RES( FT_PRINT ) ),
+ m_aPrinterLB(this, SW_RES( LB_PRINT ) ),
+ m_aPrinterSettingsPB(this, SW_RES( PB_PRINTERSETTINGS ) ),
+ m_aPrintNowPB(this, SW_RES( PB_PRINTNOW ) ),
+
+ m_aMailToFT( this, SW_RES( FT_MAILTO ) ),
+ m_aMailToLB( this, SW_RES( LB_MAILTO ) ),
+ m_aCopyToPB( this, SW_RES( PB_COPYTO ) ),
+ m_aSubjectFT( this, SW_RES( FT_SUBJECT ) ),
+ m_aSubjectED( this, SW_RES( ED_SUBJECT ) ),
+ m_aSendAsFT( this, SW_RES( FT_SENDAS ) ),
+ m_aSendAsLB( this, SW_RES( LB_SENDAS ) ),
+ m_aAttachmentFT( this, SW_RES( FT_ATTACHMENT ) ),
+ m_aAttachmentED( this, SW_RES( ED_ATTACHMENT ) ),
+ m_aSendAsPB( this, SW_RES( PB_SENDAS ) ),
+ m_aSendDocumentsPB( this, SW_RES( PB_SENDDOCUMENTS ) ),
+
+ m_sSaveStartST(SW_RES( ST_SAVESTART ) ),
+ m_sSaveMergedST(SW_RES( ST_SAVEMERGED ) ),
+ m_sPrintST(SW_RES( ST_PRINT ) ),
+ m_sSendMailST(SW_RES( ST_SENDMAIL ) ),
+
+ m_sDefaultAttachmentST(SW_RES( ST_DEFAULTATTACHMENT )),
+ m_sNoSubjectQueryST(SW_RES( ST_SUBJECTQUERY )),
+ m_sNoSubjectST(SW_RES( ST_NOSUBJECT )),
+ m_sNoAttachmentNameST(SW_RES( ST_NOATTACHMENTNAME )),
+ m_sConfigureMail(SW_RES( ST_CONFIGUREMAIL)),
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+ m_bCancelSaving( false ),
+ m_pWizard(_pParent),
+ m_pTempPrinter( 0 ),
+ m_pDocumentPrinterCopy(0)
+{
+ FreeResource();
+
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ // #i51949# hide e-Mail option if e-Mail is not supported
+ if(!rConfigItem.IsMailAvailable())
+ m_aSendMailRB.Hide();
+
+ Link aLink = LINK(this, SwMailMergeOutputPage, OutputTypeHdl_Impl);
+ m_aSaveStartDocRB.SetClickHdl(aLink);
+ m_aSaveMergedDocRB.SetClickHdl(aLink);
+ m_aPrintRB.SetClickHdl(aLink);
+ m_aSendMailRB.SetClickHdl(aLink);
+ m_aSaveStartDocRB.Check();
+ m_aPrintAllRB.Check();
+ m_aSaveAsOneRB.Check();
+ m_aSendAllRB.Check();
+
+ m_aSaveStartDocPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, SaveStartHdl_Impl));
+ m_aSaveNowPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, SaveOutputHdl_Impl));
+ m_aPrinterLB.SetSelectHdl(LINK(this, SwMailMergeOutputPage, PrinterChangeHdl_Impl));
+ m_aPrintNowPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, PrintHdl_Impl));
+ m_aPrinterSettingsPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, PrinterSetupHdl_Impl));
+
+ m_aSendAsPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, SendAsHdl_Impl)),
+ m_aSendDocumentsPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, SendDocumentsHdl_Impl)),
+ m_aSendAsLB.SetSelectHdl(LINK(this, SwMailMergeOutputPage, SendTypeHdl_Impl));
+
+ m_nFromToRBPos = m_aFromRB.GetPosPixel().Y();
+ m_nFromToFTPos = m_aToFT.GetPosPixel().Y();
+ m_nFromToNFPos = m_aFromNF.GetPosPixel().Y();
+
+ m_nRBOffset = m_nFromToRBPos - m_aSaveIndividualRB.GetPosPixel().Y();
+
+ OutputTypeHdl_Impl(&m_aSaveStartDocRB);
+
+ m_aCopyToPB.SetClickHdl(LINK(this, SwMailMergeOutputPage, CopyToHdl_Impl));
+
+ m_aSaveAsOneRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl));
+ m_aSaveIndividualRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl));
+ m_aPrintAllRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl));
+ m_aSendAllRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl));
+
+ m_aFromRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl));
+ //#i63267# printing might be disabled
+ m_aPrintRB.Enable(!Application::GetSettings().GetMiscSettings().GetDisablePrinting());
+}
+
+/*-- 02.04.2004 13:15:44---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeOutputPage::~SwMailMergeOutputPage()
+{
+ delete m_pTempPrinter;
+ delete m_pDocumentPrinterCopy;
+}
+/*-- 31.01.2005 08:38:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergeOutputPage::ActivatePage()
+{
+ //fill printer ListBox
+ const std::vector<rtl::OUString>& rPrinters = Printer::GetPrinterQueues();
+ unsigned int nCount = rPrinters.size();
+ if ( nCount )
+ {
+ for( unsigned int i = 0; i < nCount; i++ )
+ {
+ m_aPrinterLB.InsertEntry( rPrinters[i] );
+ }
+
+ }
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+
+ SwView* pTargetView = rConfigItem.GetTargetView();
+ DBG_ASSERT(pTargetView, "no target view exists");
+ if(pTargetView)
+ {
+ SfxPrinter* pPrinter = pTargetView->GetWrtShell().getIDocumentDeviceAccess()->getPrinter( true );
+ m_aPrinterLB.SelectEntry( pPrinter->GetName() );
+ m_aToNF.SetValue( rConfigItem.GetMergedDocumentCount() );
+ m_aToNF.SetMax( rConfigItem.GetMergedDocumentCount() );
+ m_pDocumentPrinterCopy = pTargetView->GetWrtShell().getIDocumentDeviceAccess()->getPrinter( true )->Clone();
+ }
+ m_aPrinterLB.SelectEntry( rConfigItem.GetSelectedPrinter() );
+
+ SwView* pSourceView = rConfigItem.GetSourceView();
+ DBG_ASSERT(pSourceView, "no source view exists");
+ if(pSourceView)
+ {
+ SwDocShell* pDocShell = pSourceView->GetDocShell();
+ if ( pDocShell->HasName() )
+ {
+ INetURLObject aTmp( pDocShell->GetMedium()->GetName() );
+ m_aAttachmentED.SetText(aTmp.getName(
+ INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ));
+ }
+ }
+}
+/*-- 05.07.2004 13:54:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool SwMailMergeOutputPage::canAdvance() const
+{
+ return false;
+}
+/*-- 02.04.2004 13:15:44---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, OutputTypeHdl_Impl, RadioButton*, pButton)
+{
+ Control* aControls[] =
+ {
+ &m_aSaveStartDocPB,
+ &m_aSaveAsOneRB, &m_aSaveIndividualRB,
+ &m_aFromRB, &m_aFromNF, &m_aToFT, &m_aToNF,
+ &m_aSaveNowPB,
+ &m_aPrinterFT, &m_aPrinterLB, &m_aPrinterSettingsPB, &m_aPrintAllRB,
+ &m_aPrintNowPB,
+ &m_aMailToFT, &m_aMailToLB, &m_aCopyToPB,
+ &m_aSubjectFT, &m_aSubjectED,
+ &m_aSendAsFT, &m_aSendAsLB, &m_aSendAsPB,
+ &m_aAttachmentFT, &m_aAttachmentED,
+ &m_aSendAllRB, &m_aSendDocumentsPB,
+ 0
+ };
+ SetUpdateMode(TRUE);
+ Control** pControl = aControls;
+ do
+ {
+ (*pControl)->Show(sal_False);
+
+ } while(*(++pControl));
+
+ if(&m_aSaveStartDocRB == pButton)
+ {
+ m_aSaveStartDocPB.Show();
+ m_aSeparatorFL.SetText(m_sSaveStartST);
+
+ }
+ else if(&m_aSaveMergedDocRB == pButton)
+ {
+ Control* aSaveMergedControls[] =
+ {
+ &m_aSaveAsOneRB, &m_aSaveIndividualRB,
+ &m_aFromRB, &m_aFromNF, &m_aToFT, &m_aToNF,
+ &m_aSaveNowPB,
+ 0
+ };
+ Control** pSaveMergeControl = aSaveMergedControls;
+ do
+ {
+ (*pSaveMergeControl)->Show(sal_True);
+
+ } while(*(++pSaveMergeControl));
+ if(!m_aFromRB.IsChecked() && !m_aSaveAsOneRB.IsChecked())
+ {
+ m_aSaveIndividualRB.Check();
+ }
+ m_aSeparatorFL.SetText(m_sSaveMergedST);
+ //reposition the from/to line
+ if(m_aFromRB.GetPosPixel().Y() != m_nFromToRBPos)
+ {
+ Point aPos(m_aFromRB.GetPosPixel()); aPos.Y() = m_nFromToRBPos; m_aFromRB.SetPosPixel(aPos);
+ aPos = m_aToFT.GetPosPixel(); aPos.Y() = m_nFromToFTPos; m_aToFT.SetPosPixel(aPos);
+ aPos = m_aFromNF.GetPosPixel(); aPos.Y() = m_nFromToNFPos; m_aFromNF.SetPosPixel(aPos);
+ aPos = m_aToNF.GetPosPixel(); aPos.Y() = m_nFromToNFPos; m_aToNF.SetPosPixel(aPos);
+ }
+ }
+ else if(&m_aPrintRB == pButton)
+ {
+ Control* aPrintControls[] =
+ {
+ &m_aFromRB, &m_aFromNF, &m_aToFT, &m_aToNF,
+ &m_aPrinterFT, &m_aPrinterLB, &m_aPrinterSettingsPB, &m_aPrintAllRB,
+ &m_aPrintNowPB,
+ 0
+ };
+ Control** pPrinterControl = aPrintControls;
+ do
+ {
+ (*pPrinterControl)->Show(sal_True);
+
+ } while(*(++pPrinterControl));
+ if(!m_aFromRB.IsChecked())
+ m_aPrintAllRB.Check();
+
+ m_aSeparatorFL.SetText(m_sPrintST);
+ //reposition the from/to line
+ long nRB_FT_Offset = m_nFromToRBPos - m_nFromToFTPos;
+ long nNewRBXPos = m_aPrintAllRB.GetPosPixel().Y() + m_nRBOffset;
+
+ Point aPos(m_aFromRB.GetPosPixel());aPos.Y() = nNewRBXPos; m_aFromRB.SetPosPixel(aPos);
+ aPos = m_aToFT.GetPosPixel(); aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aToFT.SetPosPixel(aPos);
+ aPos = m_aFromNF.GetPosPixel(); aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aFromNF.SetPosPixel(aPos);
+ aPos = m_aToNF.GetPosPixel(); aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aToNF.SetPosPixel(aPos);
+ }
+ else /*if(&m_aSendMailRB == pButton)*/
+ {
+ Control* aMailControls[] =
+ {
+ &m_aFromRB, &m_aFromNF, &m_aToFT, &m_aToNF,
+ &m_aMailToFT, &m_aMailToLB, &m_aCopyToPB,
+ &m_aSubjectFT, &m_aSubjectED,
+ &m_aSendAsFT, &m_aSendAsLB, &m_aSendAsPB,
+ &m_aAttachmentFT, &m_aAttachmentED,
+ &m_aSendAllRB, &m_aSendDocumentsPB, 0
+ };
+ Control** pMailControl = aMailControls;
+ do
+ {
+ (*pMailControl)->Show(sal_True);
+
+ } while(*(++pMailControl));
+
+ if(!m_aFromRB.IsChecked())
+ m_aSendAllRB.Check();
+ if(!m_aAttachmentED.GetText().Len())
+ {
+ String sAttach( m_sDefaultAttachmentST );
+ sAttach += '.';
+ sAttach += lcl_GetExtensionForDocType(
+ (ULONG)m_aSendAsLB.GetEntryData(m_aSendAsLB.GetSelectEntryPos()));
+ m_aAttachmentED.SetText( sAttach );
+
+ }
+ m_aSeparatorFL.SetText(m_sSendMailST);
+ //fill mail address ListBox
+ if(!m_aMailToLB.GetEntryCount())
+ {
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ //select first column
+ uno::Reference< sdbcx::XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), uno::UNO_QUERY);
+ //get the name of the actual columns
+ uno::Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
+ uno::Sequence< ::rtl::OUString > aFields;
+ if(xColAccess.is())
+ aFields = xColAccess->getElementNames();
+ const ::rtl::OUString* pFields = aFields.getConstArray();
+ for(sal_Int32 nField = 0; nField < aFields.getLength(); ++nField)
+ m_aMailToLB.InsertEntry(pFields[nField]);
+
+ m_aMailToLB.SelectEntryPos(0);
+ // then select the right one - may not be available
+ const ResStringArray& rHeaders = rConfigItem.GetDefaultAddressHeaders();
+ String sEMailColumn = rHeaders.GetString( MM_PART_E_MAIL );
+ Sequence< ::rtl::OUString> aAssignment =
+ rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
+ if(aAssignment.getLength() > MM_PART_E_MAIL && aAssignment[MM_PART_E_MAIL].getLength())
+ sEMailColumn = aAssignment[MM_PART_E_MAIL];
+ m_aMailToLB.SelectEntry(sEMailColumn);
+ // HTML format pre-selected
+ m_aSendAsLB.SelectEntryPos(3);
+ SendTypeHdl_Impl(&m_aSendAsLB);
+ }
+ if(m_aSendAllRB.GetPosPixel().Y() + m_nRBOffset != m_aFromRB.GetPosPixel().Y())
+ {
+ long nRB_FT_Offset = m_nFromToRBPos - m_nFromToFTPos;
+ long nNewRBXPos = m_aSendAllRB.GetPosPixel().Y() + m_nRBOffset;
+
+ Point aPos(m_aFromRB.GetPosPixel());aPos.Y() = nNewRBXPos; m_aFromRB.SetPosPixel(aPos);
+ aPos = m_aToFT.GetPosPixel(); aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aToFT.SetPosPixel(aPos);
+ aPos = m_aFromNF.GetPosPixel(); aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aFromNF.SetPosPixel(aPos);
+ aPos = m_aToNF.GetPosPixel(); aPos.Y() = nNewRBXPos + nRB_FT_Offset; m_aToNF.SetPosPixel(aPos);
+ }
+ }
+ m_aFromRB.GetClickHdl().Call(m_aFromRB.IsChecked() ? &m_aFromRB : 0);
+
+ SetUpdateMode(FALSE);
+ return 0;
+}
+/*-- 22.08.2005 12:15:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, DocumentSelectionHdl_Impl, RadioButton*, pButton)
+{
+ sal_Bool bEnableFromTo = pButton == &m_aFromRB;
+ m_aFromNF.Enable(bEnableFromTo);
+ m_aToFT.Enable(bEnableFromTo);
+ m_aToNF.Enable(bEnableFromTo);
+ return 0;
+}
+
+/*-- 16.04.2004 16:45:10---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, CopyToHdl_Impl, PushButton*, pButton)
+{
+ SwCopyToDialog* pDlg = new SwCopyToDialog(pButton);
+ pDlg->SetCC(m_sCC );
+ pDlg->SetBCC(m_sBCC);
+ if(RET_OK == pDlg->Execute())
+ {
+ m_sCC = pDlg->GetCC() ;
+ m_sBCC = pDlg->GetBCC();
+ }
+ delete pDlg;
+ return 0;
+}
+/*-- 17.05.2004 13:51:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, SaveStartHdl_Impl, PushButton*, pButton)
+{
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ SwView* pSourceView = rConfigItem.GetSourceView();
+ DBG_ASSERT( pSourceView, "source view missing");
+ if(pSourceView)
+ {
+ SfxViewFrame* pSourceViewFrm = pSourceView->GetViewFrame();
+ uno::Reference< frame::XFrame > xFrame =
+ pSourceViewFrm->GetFrame()->GetFrameInterface();
+ xFrame->getContainerWindow()->setVisible(sal_True);
+ pSourceViewFrm->GetDispatcher()->Execute(SID_SAVEDOC, SFX_CALLMODE_SYNCHRON);
+ xFrame->getContainerWindow()->setVisible(sal_False);
+ SwDocShell* pDocShell = pSourceView->GetDocShell();
+ //if the document has been saved it's URL has to be stored for
+ // later use and it can be closed now
+ if(pDocShell->HasName() && !pDocShell->IsModified())
+ {
+ INetURLObject aURL = pDocShell->GetMedium()->GetURLObject();
+ //update the attachment name
+ if(!m_aAttachmentED.GetText().Len())
+ {
+ if ( pDocShell->HasName() )
+ {
+ m_aAttachmentED.SetText(aURL.getName(
+ INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ));
+ }
+ }
+
+ rConfigItem.AddSavedDocument(
+ aURL.GetMainURL(INetURLObject::DECODE_TO_IURI));
+ pButton->Enable(FALSE);
+ m_pWizard->enableButtons(WZB_FINISH, sal_True);
+ pButton->Enable(FALSE);
+
+ }
+ }
+ return 0;
+}
+/*-- 17.07.2008 08:09:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, SaveCancelHdl_Impl, Button*, EMPTYARG )
+{
+ m_bCancelSaving = true;
+ return 0;
+}
+/*-- 17.05.2004 13:51:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, SaveOutputHdl_Impl, PushButton*, pButton)
+{
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ SwView* pTargetView = rConfigItem.GetTargetView();
+ DBG_ASSERT(pTargetView, "no target view exists");
+ if(!pTargetView)
+ return 0;
+
+ if(m_aSaveAsOneRB.IsChecked())
+ {
+ String sFilter;
+ String sPath = SwMailMergeHelper::CallSaveAsDialog(sFilter);
+ if(!sPath.Len())
+ return 0;
+ uno::Sequence< beans::PropertyValue > aValues(1);
+ beans::PropertyValue* pValues = aValues.getArray();
+ pValues[0].Name = C2U("FilterName");
+ pValues[0].Value <<= ::rtl::OUString(sFilter);
+
+ uno::Reference< frame::XStorable > xStore( pTargetView->GetDocShell()->GetModel(), uno::UNO_QUERY);
+ sal_uInt32 nErrorCode = ERRCODE_NONE;
+ try
+ {
+ xStore->storeToURL( sPath, aValues );
+ }
+ catch( task::ErrorCodeIOException& aErrorEx )
+ {
+ nErrorCode = (sal_uInt32)aErrorEx.ErrCode;
+ }
+ catch( Exception& )
+ {
+ nErrorCode = ERRCODE_IO_GENERAL;
+ }
+ if( nErrorCode != ERRCODE_NONE )
+ {
+ SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC, pTargetView->GetDocShell()->GetTitle());
+ ErrorHandler::HandleError( nErrorCode );
+ }
+ }
+ else
+ {
+ sal_uInt32 nBegin = 0;
+ sal_uInt32 nEnd = 0;
+ if(m_aSaveIndividualRB.IsChecked())
+ {
+ nBegin = 0;
+ nEnd = rConfigItem.GetMergedDocumentCount();
+ }
+ else
+ {
+ nBegin = static_cast< sal_Int32 >(m_aFromNF.GetValue() - 1);
+ nEnd = static_cast< sal_Int32 >(m_aToNF.GetValue());
+ if(nEnd > rConfigItem.GetMergedDocumentCount())
+ nEnd = rConfigItem.GetMergedDocumentCount();
+ }
+ String sFilter;
+ String sPath = SwMailMergeHelper::CallSaveAsDialog(sFilter);
+ if(!sPath.Len())
+ return 0;
+ String sTargetTempURL = URIHelper::SmartRel2Abs(
+ INetURLObject(), utl::TempFile::CreateTempName(),
+ URIHelper::GetMaybeFileHdl());
+ const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
+ String::CreateFromAscii( FILTER_XML ),
+ SwDocShell::Factory().GetFilterContainer() );
+
+ uno::Sequence< beans::PropertyValue > aValues(1);
+ beans::PropertyValue* pValues = aValues.getArray();
+ pValues[0].Name = C2U("FilterName");
+ pValues[0].Value <<= ::rtl::OUString(pSfxFlt->GetFilterName());
+
+ uno::Reference< frame::XStorable > xStore( pTargetView->GetDocShell()->GetModel(), uno::UNO_QUERY);
+ sal_uInt32 nErrorCode = ERRCODE_NONE;
+ try
+ {
+ xStore->storeToURL( sTargetTempURL, aValues );
+ }
+ catch( task::ErrorCodeIOException& aErrorEx )
+ {
+ nErrorCode = (sal_uInt32)aErrorEx.ErrCode;
+ }
+ catch( Exception& )
+ {
+ nErrorCode = ERRCODE_IO_GENERAL;
+ }
+ if( nErrorCode != ERRCODE_NONE )
+ {
+ SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC, pTargetView->GetDocShell()->GetTitle());
+ ErrorHandler::HandleError( nErrorCode );
+ }
+
+ SwView* pSourceView = rConfigItem.GetSourceView();
+ PrintMonitor aSaveMonitor(this, PrintMonitor::MONITOR_TYPE_SAVE);
+ aSaveMonitor.aDocName.SetText(pSourceView->GetDocShell()->GetTitle(22));
+ aSaveMonitor.aCancel.SetClickHdl(LINK(this, SwMailMergeOutputPage, SaveCancelHdl_Impl));
+ aSaveMonitor.aPrinter.SetText( INetURLObject( sPath ).getFSysPath( INetURLObject::FSYS_DETECT ) );
+ aSaveMonitor.ResizeControls();
+
+ m_bCancelSaving = false;
+ aSaveMonitor.Show();
+ m_pWizard->enableButtons(WZB_CANCEL, sal_False);
+
+ for(sal_uInt32 nDoc = nBegin; nDoc < nEnd && !m_bCancelSaving; ++nDoc)
+ {
+ SwDocMergeInfo& rInfo = rConfigItem.GetDocumentMergeInfo(nDoc);
+ INetURLObject aURL(sPath);
+ String sFile = aURL.GetBase();
+ String sExtension = aURL.getExtension();
+ if(!sExtension.Len())
+ {
+ sExtension = pSfxFlt->GetWildcard()().GetToken(1, '.');
+ sPath += '.';
+ sPath += sExtension;
+ }
+ String sStat(SW_RES(STR_STATSTR_LETTER));
+ sStat += ' ';
+ sStat += String::CreateFromInt32( nDoc );
+ aSaveMonitor.aPrintInfo.SetText(sStat);
+
+ //now extract a document from the target document
+ SfxObjectShellRef xTempDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
+ xTempDocShell->DoInitNew( 0 );
+ SfxViewFrame* pTempFrame = SfxViewFrame::CreateViewFrame( *xTempDocShell, 0, TRUE );
+// pTempFrame->GetFrame()->Appear();
+ SwView* pTempView = static_cast<SwView*>( pTempFrame->GetViewShell() );
+ pTargetView->GetWrtShell().StartAction();
+ SwgReaderOption aOpt;
+ aOpt.SetTxtFmts( sal_True );
+ aOpt.SetFrmFmts( sal_True );
+ aOpt.SetPageDescs( sal_True );
+ aOpt.SetNumRules( sal_True );
+ aOpt.SetMerge( sal_False );
+ pTempView->GetDocShell()->LoadStylesFromFile(
+ sTargetTempURL, aOpt, sal_True );
+
+ pTargetView->GetWrtShell().PastePages(pTempView->GetWrtShell(),
+ (USHORT)rInfo.nStartPageInTarget, (USHORT)rInfo.nEndPageInTarget );
+ pTargetView->GetWrtShell().EndAction();
+ //then save it
+ String sOutPath = aURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
+ String sCounter('_');
+ sCounter += String::CreateFromInt32(nDoc);
+ sOutPath.Insert(sCounter, sOutPath.Len() - sExtension.Len() - 1);
+ //SfxStringItem aName(SID_FILE_NAME, sOutPath);
+ //SfxStringItem aFilter(SID_FILTER_NAME, sFilter);
+
+ while(true)
+ {
+ //time for other slots is needed
+ for(sal_Int16 r = 0; r < 10; ++r)
+ Application::Reschedule();
+ bool bFailed = false;
+ try
+ {
+ pValues[0].Value <<= ::rtl::OUString(sFilter);
+ uno::Reference< frame::XStorable > xTempStore( xTempDocShell->GetModel(), uno::UNO_QUERY);
+ xTempStore->storeToURL( sOutPath, aValues );
+ }
+ catch( const uno::Exception& )
+ {
+ bFailed = true;
+ }
+
+ if(bFailed)
+ {
+ SwSaveWarningBox_Impl aWarning( pButton, sOutPath );
+ if(RET_OK == aWarning.Execute())
+ sOutPath = aWarning.GetFileName();
+ else
+ {
+ xTempDocShell->DoClose();
+ return 0;
+ }
+ }
+ else
+ {
+ xTempDocShell->DoClose();
+ break;
+ }
+ }
+ }
+ ::osl::File::remove( sTargetTempURL );
+ }
+ m_pWizard->enableButtons(WZB_CANCEL, sal_True);
+ m_pWizard->enableButtons(WZB_FINISH, sal_True);
+ return 0;
+}
+/*-- 22.06.2004 11:51:30---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, PrinterChangeHdl_Impl, ListBox*, pBox)
+{
+ if( m_pDocumentPrinterCopy && pBox->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
+ {
+ const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->GetSelectEntry(), false );
+
+ if( pInfo )
+ {
+ if ( !m_pTempPrinter )
+ {
+ if( (m_pDocumentPrinterCopy->GetName() == pInfo->GetPrinterName()) &&
+ (m_pDocumentPrinterCopy->GetDriverName() == pInfo->GetDriver()) )
+ m_pTempPrinter = new Printer( m_pDocumentPrinterCopy->GetJobSetup() );
+ else
+ m_pTempPrinter = new Printer( *pInfo );
+ }
+ else
+ {
+ if( (m_pTempPrinter->GetName() != pInfo->GetPrinterName()) ||
+ (m_pTempPrinter->GetDriverName() != pInfo->GetDriver()) )
+ {
+ delete m_pTempPrinter;
+ m_pTempPrinter = new Printer( *pInfo );
+ }
+ }
+ }
+ else if( ! m_pTempPrinter )
+ m_pTempPrinter = new Printer();
+
+ m_aPrinterSettingsPB.Enable( m_pTempPrinter->HasSupport( SUPPORT_SETUPDIALOG ) );
+ }
+ else
+ m_aPrinterSettingsPB.Disable();
+ m_pWizard->GetConfigItem().SetSelectedPrinter( pBox->GetSelectEntry() );
+
+// return m_pTempPrinter;
+ return 0;
+}
+
+/*-- 17.05.2004 13:51:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, PrintHdl_Impl, PushButton*, EMPTYARG)
+{
+ SwView* pTargetView = m_pWizard->GetConfigItem().GetTargetView();
+ DBG_ASSERT(pTargetView, "no target view exists");
+ if(!pTargetView)
+ return 0;
+
+ sal_uInt32 nBegin = 0;
+ sal_uInt32 nEnd = 0;
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ if(m_aPrintAllRB.IsChecked())
+ {
+ nBegin = 0;
+ nEnd = rConfigItem.GetMergedDocumentCount();
+ }
+ else
+ {
+ nBegin = static_cast< sal_Int32 >(m_aFromNF.GetValue() - 1);
+ nEnd = static_cast< sal_Int32 >(m_aToNF.GetValue());
+ if(nEnd > rConfigItem.GetMergedDocumentCount())
+ nEnd = rConfigItem.GetMergedDocumentCount();
+ }
+ rConfigItem.SetPrintRange( (USHORT)nBegin, (USHORT)nEnd );
+ SwWrtShell& rSh = pTargetView->GetWrtShell();
+ pTargetView->SetMailMergeConfigItem(&rConfigItem, 0, sal_False);
+ if(m_pTempPrinter)
+ {
+ m_pDocumentPrinterCopy->SetPrinterProps(m_pTempPrinter);
+ pTargetView->SetPrinter(m_pDocumentPrinterCopy->Clone());
+ }
+
+ SfxObjectShell* pObjSh = pTargetView->GetViewFrame()->GetObjectShell();
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), pObjSh));
+ rSh.GetNewDBMgr()->SetMergeType( DBMGR_MERGE_DOCUMENTS );
+ SfxDispatcher *pDis = pTargetView->GetViewFrame()->GetDispatcher();
+ SfxBoolItem aMergeSilent(SID_SILENT, sal_False);
+ m_pWizard->enableButtons(WZB_CANCEL, sal_False);
+ pDis->Execute(SID_PRINTDOCDIRECT,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aMergeSilent, 0L);
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), pObjSh));
+
+ pTargetView->SetMailMergeConfigItem(0, 0, sal_False);
+ m_pWizard->enableButtons(WZB_CANCEL, sal_True);
+ m_pWizard->enableButtons(WZB_FINISH, sal_True);
+ return 0;
+}
+/*-- 17.05.2004 13:51:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, PrinterSetupHdl_Impl, PushButton*, pButton)
+{
+ if( !m_pTempPrinter )
+ PrinterChangeHdl_Impl(&m_aPrinterLB);
+ if(m_pTempPrinter)
+ m_pTempPrinter->Setup(pButton);
+ return 0;
+}
+/*-- 14.06.2004 09:34:01---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, SendTypeHdl_Impl, ListBox*, pBox)
+{
+ ULONG nDocType = (ULONG)pBox->GetEntryData(pBox->GetSelectEntryPos());
+ sal_Bool bEnable = MM_DOCTYPE_HTML != nDocType && MM_DOCTYPE_TEXT != nDocType;
+ m_aSendAsPB.Enable( bEnable );
+ m_aAttachmentFT.Enable( bEnable );
+ m_aAttachmentED.Enable( bEnable );
+ if(bEnable)
+ {
+ //add the correct extension
+ String sAttach(m_aAttachmentED.GetText());
+ //do nothing if the user has removed the name - the warning will come early enough
+ if(sAttach.Len())
+ {
+ xub_StrLen nTokenCount = sAttach.GetTokenCount( '.' );
+ if( 2 > nTokenCount)
+ {
+ sAttach += '.';
+ ++nTokenCount;
+ }
+ sAttach.SetToken( nTokenCount - 1, '.', lcl_GetExtensionForDocType( nDocType ));
+ m_aAttachmentED.SetText(sAttach);
+ }
+ }
+ return 0;
+}
+/*-- 17.05.2004 13:51:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, SendAsHdl_Impl, PushButton*, pButton)
+{
+ SwMailBodyDialog* pDlg = new SwMailBodyDialog(pButton, m_pWizard);
+ pDlg->SetBody(m_sBody);
+ if(RET_OK == pDlg->Execute())
+ {
+ m_sBody = pDlg->GetBody();
+ }
+ return 0;
+}
+/*-- 21.05.2004 12:03:25---------------------------------------------------
+ Send documents as e-mail
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton)
+{
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+
+ //get the composed document
+ SwView* pTargetView = rConfigItem.GetTargetView();
+ DBG_ASSERT(pTargetView, "no target view exists");
+ if(!pTargetView)
+ return 0;
+
+ if(!rConfigItem.GetMailServer().getLength() ||
+ !SwMailMergeHelper::CheckMailAddress(rConfigItem.GetMailAddress()) )
+ {
+ QueryBox aQuery(pButton, WB_YES_NO_CANCEL, m_sConfigureMail);
+ USHORT nRet = aQuery.Execute();
+ if(RET_YES == nRet )
+ {
+ SfxAllItemSet aSet(pTargetView->GetPool());
+ SwMailConfigDlg* pDlg = new SwMailConfigDlg(pButton, aSet);
+ nRet = pDlg->Execute();
+ delete pDlg;
+ }
+
+ if(nRet != RET_OK && nRet != RET_YES)
+ return 0;
+ }
+ //create the send dialog
+ SwSendMailDialog* pDlg = new SwSendMailDialog( pButton, rConfigItem );
+ //add the documents
+ sal_uInt32 nBegin = 0;
+ sal_uInt32 nEnd = 0;
+ if(m_aSendAllRB.IsChecked())
+ {
+ nBegin = 0;
+ nEnd = rConfigItem.GetMergedDocumentCount();
+ }
+ else
+ {
+ nBegin = static_cast< sal_Int32 >(m_aFromNF.GetValue() - 1);
+ nEnd = static_cast< sal_Int32 >(m_aToNF.GetValue());
+ if(nEnd > rConfigItem.GetMergedDocumentCount())
+ nEnd = rConfigItem.GetMergedDocumentCount();
+ }
+ bool bAsBody = false;
+ bool bIsPDF = false;
+ rtl_TextEncoding eEncoding = ::gsl_getSystemTextEncoding();
+ SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
+ const SfxFilter *pSfxFlt = 0;
+ ULONG nDocType = (ULONG)m_aSendAsLB.GetEntryData(m_aSendAsLB.GetSelectEntryPos());
+ String sExtension = lcl_GetExtensionForDocType(nDocType);
+ switch( nDocType )
+ {
+ case MM_DOCTYPE_OOO : break;
+ case MM_DOCTYPE_PDF : bIsPDF = true; break;
+ case MM_DOCTYPE_WORD:
+ {
+ //the method SwIOSystemGetFilterOfFormat( ) returns the template filter
+ //because it uses the same user data :-(
+ SfxFilterMatcher aMatcher( pFilterContainer->GetName() );
+ SfxFilterMatcherIter aIter( &aMatcher );
+ const SfxFilter* pFilter = aIter.First();
+ String sFilterUserData( String::CreateFromAscii( FILTER_WW8 ));
+ while ( pFilter )
+ {
+ if( pFilter->GetUserData() == sFilterUserData && pFilter->CanExport() )
+ {
+ pSfxFlt = pFilter;
+ break;
+ }
+ pFilter = aIter.Next();
+ }
+
+ }
+ break;
+ case MM_DOCTYPE_HTML:
+ {
+ bAsBody = true;
+ SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get();
+ eEncoding = pHtmlOptions->GetTextEncoding();
+ }
+ break;
+ case MM_DOCTYPE_TEXT:
+ bAsBody = true;
+ break;
+ }
+ if(!pSfxFlt)
+ pSfxFlt = pFilterContainer->GetFilter4Extension(sExtension, SFX_FILTER_EXPORT);
+
+ if(!pSfxFlt)
+ return 0;
+ String sMimeType = pSfxFlt->GetMimeType();
+
+ if(!m_aSubjectED.GetText().Len())
+ {
+ SwSendQueryBox_Impl aQuery(pButton, m_sNoSubjectQueryST);
+ aQuery.SetIsEmptyTextAllowed(true);
+ aQuery.SetValue(m_sNoSubjectST);
+ if(RET_OK == aQuery.Execute())
+ {
+ if(aQuery.GetValue() != m_sNoSubjectST)
+ m_aSubjectED.SetText(aQuery.GetValue());
+ }
+ else
+ return 0;
+ }
+ if(!bAsBody && !m_aAttachmentED.GetText().Len())
+ {
+ SwSendQueryBox_Impl aQuery(pButton, m_sNoAttachmentNameST);
+ aQuery.SetIsEmptyTextAllowed(false);
+ if(RET_OK == aQuery.Execute())
+ {
+ String sAttach(aQuery.GetValue());
+ xub_StrLen nTokenCount = sAttach.GetTokenCount( '.' );
+ if( 2 > nTokenCount)
+ {
+ sAttach += '.';
+ ++nTokenCount;
+ }
+ sAttach.SetToken( nTokenCount - 1, '.', lcl_GetExtensionForDocType(
+ (ULONG)m_aSendAsLB.GetEntryData(m_aSendAsLB.GetSelectEntryPos())));
+ m_aAttachmentED.SetText(sAttach);
+ }
+ else
+ return 0;
+ }
+ SfxStringItem aFilterName( SID_FILTER_NAME, pSfxFlt->GetFilterName() );
+ String sEMailColumn = m_aMailToLB.GetSelectEntry();
+ DBG_ASSERT( sEMailColumn.Len(), "No email column selected");
+ Reference< sdbcx::XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), UNO_QUERY);
+ Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
+ if(!sEMailColumn.Len() || !xColAccess.is() || !xColAccess->hasByName(sEMailColumn))
+ return 0;
+
+ String sFilterOptions;
+ if(MM_DOCTYPE_TEXT == nDocType)
+ {
+ SwAsciiOptions aOpt;
+ USHORT nAppScriptType = GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() );
+ USHORT nWhich = GetWhichOfScript( RES_CHRATR_LANGUAGE, nAppScriptType);
+ aOpt.SetLanguage( ((SvxLanguageItem&)pTargetView->GetWrtShell().
+ GetDefault( nWhich )).GetLanguage());
+ aOpt.SetParaFlags( LINEEND_CR );
+ aOpt.WriteUserData( sFilterOptions );
+ }
+ String sTargetTempURL = URIHelper::SmartRel2Abs(
+ INetURLObject(), utl::TempFile::CreateTempName(),
+ URIHelper::GetMaybeFileHdl());
+ const SfxFilter *pTargetSfxFlt = SwIoSystem::GetFilterOfFormat(
+ String::CreateFromAscii( FILTER_XML ),
+ SwDocShell::Factory().GetFilterContainer() );
+
+ uno::Sequence< beans::PropertyValue > aValues(1);
+ beans::PropertyValue* pValues = aValues.getArray();
+ pValues[0].Name = C2U("FilterName");
+ pValues[0].Value <<= ::rtl::OUString(pTargetSfxFlt->GetFilterName());
+
+ uno::Reference< frame::XStorable > xStore( pTargetView->GetDocShell()->GetModel(), uno::UNO_QUERY);
+ xStore->storeToURL( sTargetTempURL, aValues );
+
+ pDlg->SetDocumentCount( nEnd );
+ pDlg->ShowDialog();
+ //help to force painting the dialog
+ //TODO/CLEANUP
+ //Sollbruchstelle
+ for ( sal_Int16 i = 0; i < 25; i++)
+ Application::Reschedule();
+ for(sal_uInt32 nDoc = nBegin; nDoc < nEnd; ++nDoc)
+ {
+ m_pWizard->EnterWait();
+ SwDocMergeInfo& rInfo = rConfigItem.GetDocumentMergeInfo(nDoc);
+
+ //now extract a document from the target document
+ SfxObjectShellRef xTempDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
+ xTempDocShell->DoInitNew( 0 );
+ SfxViewFrame* pTempFrame = SfxViewFrame::CreateViewFrame( *xTempDocShell, 0, TRUE );
+// pTempFrame->GetFrame()->Appear();
+ SwView* pTempView = static_cast<SwView*>( pTempFrame->GetViewShell() );
+ pTargetView->GetWrtShell().StartAction();
+ SwgReaderOption aOpt;
+ aOpt.SetTxtFmts( sal_True );
+ aOpt.SetFrmFmts( sal_True );
+ aOpt.SetPageDescs( sal_True );
+ aOpt.SetNumRules( sal_True );
+ aOpt.SetMerge( sal_False );
+ pTempView->GetDocShell()->LoadStylesFromFile(
+ sTargetTempURL, aOpt, sal_True );
+ pTargetView->GetWrtShell().PastePages(pTempView->GetWrtShell(),
+ (USHORT)rInfo.nStartPageInTarget, (USHORT)rInfo.nEndPageInTarget );
+ pTargetView->GetWrtShell().EndAction();
+
+ //then save it
+ SfxStringItem aName(SID_FILE_NAME,
+ URIHelper::SmartRel2Abs(
+ INetURLObject(), utl::TempFile::CreateTempName(0),
+ URIHelper::GetMaybeFileHdl()) );
+
+/* if(bIsPDF)
+ {
+ SfxDispatcher* pSfxDispatcher = pTempView->GetViewFrame()->GetDispatcher();
+ pSfxDispatcher->Execute(
+ SID_DIRECTEXPORTDOCASPDF,
+ SFX_CALLMODE_SYNCHRON, &aName, &aFilterName, 0L );
+ }
+ else*/
+ {
+ uno::Sequence< beans::PropertyValue > aFilterValues(MM_DOCTYPE_TEXT == nDocType ? 2 : 1);
+ beans::PropertyValue* pFilterValues = aFilterValues.getArray();
+ pFilterValues[0].Name = C2U("FilterName");
+ pFilterValues[0].Value <<= ::rtl::OUString(pSfxFlt->GetFilterName());
+ if(MM_DOCTYPE_TEXT == nDocType)
+ {
+ pFilterValues[1].Name = C2U("FilterOptions");
+ pFilterValues[1].Value <<= ::rtl::OUString(sFilterOptions);
+ }
+
+ uno::Reference< frame::XStorable > xTempStore( pTempView->GetDocShell()->GetModel(), uno::UNO_QUERY);
+ xTempStore->storeToURL( aName.GetValue(), aFilterValues );
+ }
+ xTempDocShell->DoClose();
+
+#ifdef DBG_UTIL
+ sal_Int32 nTarget =
+#endif
+ rConfigItem.MoveResultSet(rInfo.nDBRow);
+ DBG_ASSERT( nTarget == rInfo.nDBRow, "row of current document could not be selected");
+ DBG_ASSERT( sEMailColumn.Len(), "No email column selected");
+ ::rtl::OUString sEMail = lcl_GetColumnValueOf(sEMailColumn, xColAccess);
+ SwMailDescriptor aDesc;
+ aDesc.sEMail = sEMail;
+ rtl::OUString sBody;
+ if(bAsBody)
+ {
+ {
+ //read in the temporary file and use it as mail body
+ SfxMedium aMedium( aName.GetValue(), STREAM_READ, TRUE);
+ SvStream* pInStream = aMedium.GetInStream();
+ if(pInStream)
+ pInStream->SetStreamCharSet( eEncoding );
+ else
+ {
+ DBG_ERROR("no output file created?");
+ continue;
+ }
+ ByteString sLine;
+ sal_Bool bDone = pInStream->ReadLine( sLine );
+ while ( bDone )
+ {
+ sBody += rtl::OUString(String(sLine, eEncoding));
+ sBody += rtl::OUString('\n');
+ bDone = pInStream->ReadLine( sLine );
+ }
+ }
+ //remove the temporary file
+ SWUnoHelper::UCB_DeleteFile( aName.GetValue() );
+ }
+ else
+ {
+ sBody = m_sBody;
+ aDesc.sAttachmentURL = aName.GetValue();
+ String sAttachment(m_aAttachmentED.GetText());
+ xub_StrLen nTokenCount = sAttachment.GetTokenCount( '.' );
+ if( 2 > nTokenCount)
+ {
+ sAttachment += '.';
+ sAttachment.SetToken( nTokenCount, '.', sExtension);
+ }
+ else if(sAttachment.GetToken( nTokenCount - 1, '.') != sExtension)
+ sAttachment += sExtension;
+ aDesc.sAttachmentName = sAttachment;
+ aDesc.sMimeType = sMimeType;
+
+ if(rConfigItem.IsGreetingLine(sal_True))
+ {
+ ::rtl::OUString sNameColumn = rConfigItem.GetAssignedColumn(MM_PART_LASTNAME);
+ ::rtl::OUString sName = lcl_GetColumnValueOf(sNameColumn, xColAccess);
+ String sGreeting;
+ if(sName.getLength() && rConfigItem.IsIndividualGreeting(sal_True))
+ {
+ ::rtl::OUString sGenderColumn = rConfigItem.GetAssignedColumn(MM_PART_GENDER);
+ const ::rtl::OUString& sFemaleValue = rConfigItem.GetFemaleGenderValue();
+ ::rtl::OUString sGenderValue = lcl_GetColumnValueOf(sGenderColumn, xColAccess);
+ SwMailMergeConfigItem::Gender eGenderType = sGenderValue == sFemaleValue ?
+ SwMailMergeConfigItem::FEMALE :
+ SwMailMergeConfigItem::MALE;
+
+ sGreeting = SwAddressPreview::FillData(
+ rConfigItem.GetGreetings(eGenderType)
+ [rConfigItem.GetCurrentGreeting(eGenderType)],
+ rConfigItem);
+ }
+ else
+ {
+ sGreeting =
+ rConfigItem.GetGreetings(SwMailMergeConfigItem::NEUTRAL)
+ [rConfigItem.GetCurrentGreeting(SwMailMergeConfigItem::NEUTRAL)];
+
+ }
+ sGreeting += '\n';
+ ::rtl::OUString sTemp( sGreeting );
+ sTemp += sBody;
+ sBody = sTemp;
+ }
+ }
+ aDesc.sBodyContent = sBody;
+ if(MM_DOCTYPE_HTML == nDocType)
+ {
+ aDesc.sBodyMimeType = ::rtl::OUString::createFromAscii("text/html; charset=");
+ aDesc.sBodyMimeType += ::rtl::OUString::createFromAscii(
+ rtl_getBestMimeCharsetFromTextEncoding( eEncoding ));
+ }
+ else
+ aDesc.sBodyMimeType =
+ ::rtl::OUString::createFromAscii("text/plain; charset=UTF-8; format=flowed");
+
+ aDesc.sSubject = m_aSubjectED.GetText();
+ aDesc.sCC = m_sCC;
+ aDesc.sBCC = m_sBCC;
+ pDlg->AddDocument( aDesc );
+ //help to force painting the dialog
+ for ( sal_Int16 i = 0; i < 25; i++)
+ Application::Reschedule();
+ //stop creating of data when dialog has been closed
+ if(!pDlg->IsVisible())
+ {
+ m_pWizard->LeaveWait();
+ break;
+ }
+ m_pWizard->LeaveWait();
+ }
+ pDlg->EnableDesctruction();
+ ::osl::File::remove( sTargetTempURL );
+
+ m_pWizard->enableButtons(WZB_FINISH, sal_True);
+ //the dialog deletes itself
+ //delete pDlg;
+ return 0;
+}
diff --git a/sw/source/ui/dbui/mmoutputpage.hrc b/sw/source/ui/dbui/mmoutputpage.hrc
new file mode 100644
index 000000000000..d4130b17adb8
--- /dev/null
+++ b/sw/source/ui/dbui/mmoutputpage.hrc
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmoutputpage.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEOUTPUTTYPEPAGE_HRC
+#define _MAILMERGEOUTPUTTYPEPAGE_HRC
+
+#define FI_HEADER 1
+#define FI_OPTIONS 2
+#define RB_SAVESTARTDOC 3
+#define RB_SAVEMERGEDDOC 4
+#define RB_PRINT 5
+#define RB_SENDMAIL 6
+#define FL_SEPARATOR 7
+#define PB_SAVESTARTDOC 8
+#define RB_SAVEASONE 12
+#define RB_SAVEINDIVIDUAL 13
+
+#define RB_FROM 15
+#define NF_FROM 16
+#define FT_TO 17
+#define NF_TO 18
+#define PB_SAVENOW 19
+
+#define FT_PRINT 21
+#define LB_PRINT 22
+#define PB_PRINTERSETTINGS 23
+#define RB_PRINTALL 24
+#define RB_PRINTCURRENT 25
+#define PB_PRINTNOW 26
+#define ST_SAVESTART 27
+#define ST_SAVEMERGED 28
+#define ST_PRINT 29
+#define ST_SENDMAIL 30
+
+#define FT_MAILTO 31
+#define LB_MAILTO 32
+#define PB_COPYTO 33
+#define FT_SUBJECT 34
+#define ED_SUBJECT 35
+#define FT_SENDAS 36
+#define LB_SENDAS 37
+#define PB_SENDAS 38
+#define RB_SENDALL 39
+#define PB_SENDDOCUMENTS 40
+
+#define FI_DESCRIPTION 41
+#define FT_CC 42
+#define ED_CC 43
+#define FT_BCC 44
+#define ED_BCC 45
+#define PB_OK 47
+#define PB_CANCEL 48
+#define PB_HELP 49
+#define FI_NOTE 50
+#define FT_ATTACHMENT 51
+#define ED_ATTACHMENT 52
+#define ST_DEFAULTATTACHMENT 53
+#define ST_SUBJECTQUERY 54
+#define ST_NOSUBJECT 55
+#define ST_NOATTACHMENTNAME 56
+#define ST_CONFIGUREMAIL 57
+
+#define IM_QUERY 58
+#define FI_QUERY 59
+#define ED_TEXT 60
+
+#define MM_DOCTYPE_OOO 1
+#define MM_DOCTYPE_PDF 2
+#define MM_DOCTYPE_WORD 3
+#define MM_DOCTYPE_HTML 4
+#define MM_DOCTYPE_TEXT 5
+
+
+#define IM_WARNING 1
+#define FI_WARNING 2
+#define FT_FILENAME 3
+#define ED_FILENAME 4
+
+#endif
+
diff --git a/sw/source/ui/dbui/mmoutputpage.hxx b/sw/source/ui/dbui/mmoutputpage.hxx
new file mode 100644
index 000000000000..6a02a8482416
--- /dev/null
+++ b/sw/source/ui/dbui/mmoutputpage.hxx
@@ -0,0 +1,245 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmoutputpage.hxx,v $
+ * $Revision: 1.10.136.1 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEOUTPUTPAGE_HXX
+#define _MAILMERGEOUTPUTPAGE_HXX
+#include <svtools/wizardmachine.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <svtools/stdctrl.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <svtools/svtabbx.hxx>
+#include <svtools/headbar.hxx>
+#include <svtools/prgsbar.hxx>
+#include "swdllapi.h"
+#include "mailmergehelper.hxx"
+
+class SwMailMergeWizard;
+class SfxPrinter;
+class SwSendMailDialog;
+
+namespace com{ namespace sun{ namespace star{
+ namespace mail{
+ class XMailMessage;
+ }
+}}}
+/*-- 02.04.2004 09:21:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwMailMergeOutputPage : public svt::OWizardPage
+{
+ SwBoldFixedInfo m_aHeaderFI;
+ FixedInfo m_aOptionsFI;
+ RadioButton m_aSaveStartDocRB;
+ RadioButton m_aSaveMergedDocRB;
+ RadioButton m_aPrintRB;
+ RadioButton m_aSendMailRB;
+
+ FixedLine m_aSeparatorFL;
+
+ PushButton m_aSaveStartDocPB;
+
+ RadioButton m_aSaveAsOneRB;
+ RadioButton m_aSaveIndividualRB;
+ RadioButton m_aPrintAllRB; //has to be here for tab control reasons
+ RadioButton m_aSendAllRB; //has to be here for tab control reasons
+ //this group is used in save and print
+ RadioButton m_aFromRB;
+ NumericField m_aFromNF;
+ FixedText m_aToFT;
+ NumericField m_aToNF;
+ PushButton m_aSaveNowPB;
+
+ FixedText m_aPrinterFT;
+ ListBox m_aPrinterLB;
+ PushButton m_aPrinterSettingsPB;
+ PushButton m_aPrintNowPB;
+
+ FixedText m_aMailToFT;
+ ListBox m_aMailToLB;
+ PushButton m_aCopyToPB;
+ FixedText m_aSubjectFT;
+ Edit m_aSubjectED;
+ FixedText m_aSendAsFT;
+ ListBox m_aSendAsLB;
+ FixedText m_aAttachmentFT;
+ Edit m_aAttachmentED;
+ PushButton m_aSendAsPB;
+ PushButton m_aSendDocumentsPB;
+
+ //some FixedLine labels
+ String m_sSaveStartST;
+ String m_sSaveMergedST;
+ String m_sPrintST;
+ String m_sSendMailST;
+
+ //misc strings
+ String m_sDefaultAttachmentST;
+ String m_sNoSubjectQueryST;
+ String m_sNoSubjectST;
+ String m_sNoAttachmentNameST;
+ String m_sConfigureMail;
+
+ String m_sBody;
+
+ long m_nFromToRBPos;
+ long m_nFromToFTPos;
+ long m_nFromToNFPos;
+ long m_nRBOffset;
+
+ bool m_bCancelSaving;
+
+ SwMailMergeWizard* m_pWizard;
+
+ //some dialog data
+ Printer* m_pTempPrinter;
+ SfxPrinter* m_pDocumentPrinterCopy;
+ String m_sCC;
+ String m_sBCC;
+
+
+ DECL_LINK(OutputTypeHdl_Impl, RadioButton*);
+ DECL_LINK(CopyToHdl_Impl, PushButton*);
+ DECL_LINK(SaveStartHdl_Impl, PushButton* );
+ DECL_LINK(SaveOutputHdl_Impl, PushButton* );
+ DECL_LINK(PrinterChangeHdl_Impl, ListBox* );
+ DECL_LINK(PrintHdl_Impl, PushButton* );
+ DECL_LINK(PrinterSetupHdl_Impl, PushButton* );
+ DECL_LINK(SendTypeHdl_Impl, ListBox*);
+ DECL_LINK(SendAsHdl_Impl, PushButton*);
+ DECL_LINK(SendDocumentsHdl_Impl, PushButton*);
+ DECL_LINK(DocumentSelectionHdl_Impl, RadioButton*);
+ DECL_LINK(SaveCancelHdl_Impl, Button*);
+protected:
+ virtual bool canAdvance() const;
+ virtual void ActivatePage();
+public:
+ SwMailMergeOutputPage( SwMailMergeWizard* _pParent);
+ ~SwMailMergeOutputPage();
+
+};
+/*-- 21.05.2004 12:48:50---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+struct SwMailDescriptor
+{
+ ::rtl::OUString sEMail;
+ ::rtl::OUString sAttachmentURL;
+ ::rtl::OUString sAttachmentName;
+ ::rtl::OUString sMimeType;
+ ::rtl::OUString sSubject;
+ ::rtl::OUString sBodyMimeType;
+ ::rtl::OUString sBodyContent;
+
+
+ ::rtl::OUString sCC;
+ ::rtl::OUString sBCC;
+};
+struct SwSendMailDialog_Impl;
+class SwMailMergeConfigItem;
+class SW_DLLPUBLIC SwSendMailDialog : public ModelessDialog //SfxModalDialog
+{
+ FixedLine m_aStatusFL;
+ FixedText m_aStatusFT;
+
+ FixedLine m_aTransferStatusFL;
+ FixedText m_aTransferStatusFT;
+ FixedInfo m_PausedFI;
+ ProgressBar m_aProgressBar;
+ FixedText m_aErrorStatusFT;
+
+ PushButton m_aDetailsPB;
+ HeaderBar m_aStatusHB;
+ SvTabListBox m_aStatusLB;
+
+ FixedLine m_aSeparatorFL;
+
+ PushButton m_aStopPB;
+ PushButton m_aClosePB;
+
+ String m_sMore;
+ String m_sLess;
+ String m_sContinue;
+ String m_sStop;
+ String m_sSend;
+ String m_sTransferStatus;
+ String m_sErrorStatus;
+ String m_sSendingTo;
+ String m_sCompleted;
+ String m_sFailed;
+ String m_sTerminateQuery;
+
+ bool m_bCancel;
+ bool m_bDesctructionEnabled;
+
+ ImageList m_aImageList;
+ ImageList m_aImageListHC;
+
+ SwSendMailDialog_Impl* m_pImpl;
+ SwMailMergeConfigItem* m_pConfigItem;
+ sal_Int32 m_nStatusHeight;
+ sal_Int32 m_nSendCount;
+ sal_Int32 m_nErrorCount;
+
+ SW_DLLPRIVATE DECL_LINK( DetailsHdl_Impl, PushButton* );
+ SW_DLLPRIVATE DECL_LINK( StopHdl_Impl, PushButton* );
+ SW_DLLPRIVATE DECL_LINK( CloseHdl_Impl, PushButton* );
+ SW_DLLPRIVATE DECL_STATIC_LINK( SwSendMailDialog, StartSendMails, SwSendMailDialog* );
+ SW_DLLPRIVATE DECL_STATIC_LINK( SwSendMailDialog, StopSendMails, SwSendMailDialog* );
+ SW_DLLPRIVATE DECL_STATIC_LINK( SwSendMailDialog, RemoveThis, Timer* );
+
+ SW_DLLPRIVATE void IterateMails();
+ SW_DLLPRIVATE void SendMails();
+ SW_DLLPRIVATE void UpdateTransferStatus();
+
+ virtual void StateChanged( StateChangedType nStateChange );
+
+public:
+ SwSendMailDialog( Window* pParent, SwMailMergeConfigItem& );
+ ~SwSendMailDialog();
+
+ void AddDocument( SwMailDescriptor& rDesc );
+ void SetDocumentCount( sal_Int32 nAllDocuments );
+ void EnableDesctruction() {m_bDesctructionEnabled = true;}
+ void ShowDialog();
+
+ void DocumentSent( ::com::sun::star::uno::Reference< ::com::sun::star::mail::XMailMessage>,
+ bool bResult,
+ const ::rtl::OUString* pError );
+ void AllMailsSent();
+
+};
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmoutputpage.src b/sw/source/ui/dbui/mmoutputpage.src
new file mode 100644
index 000000000000..d044767785bc
--- /dev/null
+++ b/sw/source/ui/dbui/mmoutputpage.src
@@ -0,0 +1,466 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmoutputpage.src,v $
+ * $Revision: 1.13 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <mmoutputpage.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+TabPage DLG_MM_OUTPUT_PAGE
+{
+ HelpID = HID_MM_OUTPUTPAGE ;
+ Size = MAP_APPFONT ( 260 , 250 ) ;
+ Hide = TRUE ;
+
+ FixedText FI_HEADER
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text[ en-US ] = "Save, print or send the document";
+ };
+ FixedText FI_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 27 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text[ en-US ] = "Select one of the options below:";
+ };
+ RadioButton RB_SAVESTARTDOC
+ {
+ Pos = MAP_APPFONT ( 45 , 40 ) ;
+ Size = MAP_APPFONT ( 209 , 10 ) ;
+ Text[ en-US ] = "~Save starting document";
+ };
+ RadioButton RB_SAVEMERGEDDOC
+ {
+ Pos = MAP_APPFONT ( 45 , 53 ) ;
+ Size = MAP_APPFONT ( 209 , 10 ) ;
+ Text[ en-US ] = "Save ~merged document" ;
+ };
+ RadioButton RB_PRINT
+ {
+ Pos = MAP_APPFONT ( 45 , 66 ) ;
+ Size = MAP_APPFONT ( 209 , 10 ) ;
+ Text[ en-US ] = "~Print merged document";
+ };
+ RadioButton RB_SENDMAIL
+ {
+ Pos = MAP_APPFONT ( 45 , 79 ) ;
+ Size = MAP_APPFONT ( 209 , 10 ) ;
+ Text[ en-US ] = "Send merged document as ~E-Mail";
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 6 , 95 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ };
+ PushButton PB_SAVESTARTDOC
+ {
+ Pos = MAP_APPFONT ( 55 , 108 ) ;
+ Size = MAP_APPFONT ( 100 , 14 ) ;
+ Text[ en-US ] = "Save starting ~document";
+ };
+ RadioButton RB_SAVEASONE
+ {
+ Pos = MAP_APPFONT ( 45 , 109 ) ;
+ Size = MAP_APPFONT ( 150 , 10 ) ;
+ Text[ en-US ] = "S~ave as single document";
+ };
+ RadioButton RB_SAVEINDIVIDUAL
+ {
+ Pos = MAP_APPFONT ( 45, 123 ) ;
+ Size = MAP_APPFONT ( 150 , 10 ) ;
+ Text[ en-US ] = "Sa~ve as individual documents";
+ };
+ RadioButton RB_FROM
+ {
+ Pos = MAP_APPFONT ( 45 , 137 ) ;
+ Size = MAP_APPFONT ( 30 , 10 ) ;
+ Text[ en-US ] = "~From";
+ };
+ NumericField NF_FROM
+ {
+ Pos = MAP_APPFONT ( 78 , 136 ) ;
+ Size = MAP_APPFONT ( 20 , 10 ) ;
+ Border = TRUE;
+ Left = TRUE ;
+ First = 1 ;
+ Minimum = 1 ;
+ Repeat = TRUE ;
+ Spin = FALSE ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_TO
+ {
+ Pos = MAP_APPFONT ( 101 , 138 ) ;
+ Size = MAP_APPFONT ( 20 , 8 ) ;
+ Right = TRUE;
+ Text[ en-US ] = "~To";
+ };
+ NumericField NF_TO
+ {
+ Pos = MAP_APPFONT ( 124 , 136 ) ;
+ Size = MAP_APPFONT ( 20 , 10 ) ;
+ Border = TRUE;
+ Left = TRUE ;
+ First = 1 ;
+ Minimum = 1 ;
+ Repeat = TRUE ;
+ Spin = FALSE ;
+ TabStop = TRUE ;
+ };
+ PushButton PB_SAVENOW
+ {
+ Pos = MAP_APPFONT ( 45 , 150 ) ;
+ Size = MAP_APPFONT ( 80 , 14 ) ;
+ Text[ en-US ] = "Save Do~cuments";
+ };
+ FixedText FT_PRINT
+ {
+ Pos = MAP_APPFONT ( 12 , 111 ) ;
+ Size = MAP_APPFONT ( 30 , 8 ) ;
+ Text[ en-US ] = "~Printer";
+ };
+ ListBox LB_PRINT
+ {
+ Pos = MAP_APPFONT ( 45 , 109 ) ;
+ Size = MAP_APPFONT ( 147 , 50 ) ;
+ Border = TRUE;
+ DropDown = TRUE;
+ Sort = TRUE;
+ };
+ PushButton PB_PRINTERSETTINGS
+ {
+ Pos = MAP_APPFONT ( 198 , 108 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "P~roperties...";
+ };
+ RadioButton RB_PRINTALL
+ {
+ Pos = MAP_APPFONT ( 45 , 126 ) ;
+ Size = MAP_APPFONT ( 150 , 10 ) ;
+ Text[ en-US ] = "Print ~all documents";
+ };
+ PushButton PB_PRINTNOW
+ {
+ Pos = MAP_APPFONT ( 45 , 155 ) ;
+ Size = MAP_APPFONT ( 80 , 14 ) ;
+ Text[ en-US ] = "Prin~t Documents";
+ };
+
+ FixedText FT_MAILTO
+ {
+ Pos = MAP_APPFONT ( 12 , 111 ) ;
+ Size = MAP_APPFONT ( 30 , 8 ) ;
+ Text[ en-US ] = "T~o";
+ };
+ ListBox LB_MAILTO
+ {
+ Pos = MAP_APPFONT ( 45 , 109 ) ;
+ Size = MAP_APPFONT ( 147 , 50 ) ;
+ DropDown = TRUE;
+ Border = TRUE;
+ };
+ PushButton PB_COPYTO
+ {
+ Pos = MAP_APPFONT ( 198 , 108 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "~Copy to...";
+ };
+ FixedText FT_SUBJECT
+ {
+ Pos = MAP_APPFONT ( 12 , 127 ) ;
+ Size = MAP_APPFONT ( 30 , 8 ) ;
+ Text[ en-US ] = "S~ubject";
+ };
+ Edit ED_SUBJECT
+ {
+ Pos = MAP_APPFONT ( 45 , 125 ) ;
+ Size = MAP_APPFONT ( 147 , 12 ) ;
+ Border = TRUE;
+ };
+ FixedText FT_SENDAS
+ {
+ Pos = MAP_APPFONT ( 12 , 143 ) ;
+ Size = MAP_APPFONT ( 30 , 8 ) ;
+ Text[ en-US ] = "Sen~d as";
+ };
+ ListBox LB_SENDAS
+ {
+ Pos = MAP_APPFONT ( 45 , 141 ) ;
+ Size = MAP_APPFONT (147 , 70 ) ;
+ DropDown = TRUE;
+ Border = TRUE;
+ StringList =
+ {
+ < "OpenDocument Text" ; MM_DOCTYPE_OOO ;> ;
+ < "Adobe PDF-Dokument" ; MM_DOCTYPE_PDF ;> ;
+ < "Microsoft Word Dokument" ; MM_DOCTYPE_WORD;> ;
+ < "HTML-Nachricht" ; MM_DOCTYPE_HTML;> ;
+ < "Nur Text" ; MM_DOCTYPE_TEXT;> ;
+ };
+ StringList [en-US]=
+ {
+ < "OpenDocument Text" ; MM_DOCTYPE_OOO ;> ;
+ < "Adobe PDF-Document" ; MM_DOCTYPE_PDF ;> ;
+ < "Microsoft Word Document" ; MM_DOCTYPE_WORD;> ;
+ < "HTML Message" ; MM_DOCTYPE_HTML;> ;
+ < "Plain Text" ; MM_DOCTYPE_TEXT;> ;
+ };
+ };
+ PushButton PB_SENDAS
+ {
+ Pos = MAP_APPFONT ( 198 , 140 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "Pr~operties...";
+ };
+ FixedText FT_ATTACHMENT
+ {
+ Pos = MAP_APPFONT ( 45 , 157 ) ;
+ Size = MAP_APPFONT ( 147 , 8 ) ;
+ Text[ en-US ] = "Name of the a~ttachment";
+ };
+ Edit ED_ATTACHMENT
+ {
+ Pos = MAP_APPFONT ( 45 , 168 ) ;
+ Size = MAP_APPFONT ( 147 , 12 ) ;
+ Border = TRUE;
+ };
+ RadioButton RB_SENDALL
+ {
+ Pos = MAP_APPFONT ( 45 , 184 ) ;
+ Size = MAP_APPFONT ( 153 , 10 ) ;
+ Text[ en-US ] = "S~end all documents";
+ };
+ PushButton PB_SENDDOCUMENTS
+ {
+ Pos = MAP_APPFONT ( 45 , 212 ) ;
+ Size = MAP_APPFONT ( 80 , 14 ) ;
+ Text[ en-US ] = "Se~nd documents";
+ };
+ String ST_SAVESTART
+ {
+ Text[ en-US ] = "Save ~starting document";
+ };
+ String ST_SAVEMERGED
+ {
+ Text[ en-US ] = "Save merged document";
+ };
+ String ST_PRINT
+ {
+ Text[ en-US ] = "Print settings";
+ };
+ String ST_SENDMAIL
+ {
+ Text[ en-US ] = "E-Mail settings";
+ };
+ String ST_DEFAULTATTACHMENT
+ {
+ Text[ en-US ] = "Untitled";
+ };
+ String ST_SUBJECTQUERY
+ {
+ Text[ en-US ] = "You did not specify a subject for this message. If you would like to provide one, please type it now.";
+ };
+ String ST_NOSUBJECT
+ {
+ Text[ en-US ] = "No subject";
+ };
+ String ST_NOATTACHMENTNAME
+ {
+ Text[ en-US ] = "You did not specify a new name for the attachment. If you would like to provide one, please type it now.";
+ };
+ String ST_CONFIGUREMAIL
+ {
+ Text[ en-US ] = "In order to be able to send mail merge documents by e-mail, %PRODUCTNAME requires information about the e-mail account to be used.\n\n Do you want to enter e-mail account information now?";
+ };
+};
+
+ModalDialog DLG_MM_COPYTO
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_COPYTO;
+ Size = MAP_APPFONT ( 250 , 100 ) ;
+ Moveable = TRUE ;
+
+ Text [ en-US ] = "Copy To";
+
+ FixedText FI_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 238 , 8 ) ;
+ Text[ en-US ] = "Send a copy of this mail to:";
+ };
+ FixedText FT_CC
+ {
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( 30 , 8 ) ;
+ Text[ en-US ] = "~Cc";
+ };
+ Edit ED_CC
+ {
+ Pos = MAP_APPFONT ( 40 , 15 ) ;
+ Size = MAP_APPFONT ( 204 , 12 ) ;
+ Border = TRUE;
+ };
+ FixedText FT_BCC
+ {
+ Pos = MAP_APPFONT ( 6 , 33 ) ;
+ Size = MAP_APPFONT ( 30 , 8 ) ;
+ Text[ en-US ] = "~Bcc";
+ };
+ Edit ED_BCC
+ {
+ Pos = MAP_APPFONT ( 40 , 31 ) ;
+ Size = MAP_APPFONT ( 204 , 12 ) ;
+ Border = TRUE;
+ };
+ FixedText FI_NOTE
+ {
+ Pos = MAP_APPFONT ( 6 , 47 ) ;
+ Size = MAP_APPFONT ( 204 , 20 ) ;
+ WordBreak = TRUE;
+ Text[ en-US ] = "Note:\nSeparate e-mail addresses with a semicolon (;).";
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 66 ) ;
+ Size = MAP_APPFONT ( 250 , 8 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 85 , 80 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 138 , 80 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 194 , 80 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
+ModalDialog DLG_MM_SAVEWARNING
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_SAVEWARNING;
+ Size = MAP_APPFONT ( 200 , 99 ) ;
+ Moveable = TRUE ;
+
+ Text = "%PRODUCTNAME";
+ FixedImage IM_WARNING
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 30 , 30 ) ;
+ };
+ FixedText FI_WARNING
+ {
+ Pos = MAP_APPFONT ( 40 , 3 ) ;
+ Size = MAP_APPFONT ( 150 , 30 ) ;
+ WordBreak = TRUE;
+ Text[ en-US ] = "A document with the name '%1' already exists. Please save this document under a different name.";
+ };
+ FixedText FT_FILENAME
+ {
+ Pos = MAP_APPFONT ( 40, 39 ) ;
+ Size = MAP_APPFONT ( 154, 8 ) ;
+ Text[ en-US ] = "New document name";
+ };
+ Edit ED_FILENAME
+ {
+ Pos = MAP_APPFONT ( 40 , 50 ) ;
+ Size = MAP_APPFONT ( 154 , 12 ) ;
+ Border = TRUE;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 68 ) ;
+ Size = MAP_APPFONT ( 200 , 8 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 40 , 79) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 93 , 79 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+ModalDialog DLG_MM_QUERY
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_QUERY;
+ Size = MAP_APPFONT ( 240 , 88 ) ;
+ Moveable = TRUE ;
+
+ Text = "%PRODUCTNAME";
+ FixedImage IM_QUERY
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 30 , 30 ) ;
+ };
+ FixedText FI_QUERY
+ {
+ Pos = MAP_APPFONT ( 40 , 6 ) ;
+ Size = MAP_APPFONT ( 190 , 30 ) ;
+ WordBreak = TRUE;
+ };
+ Edit ED_TEXT
+ {
+ Pos = MAP_APPFONT ( 40 , 39 ) ;
+ Size = MAP_APPFONT ( 194 , 12 ) ;
+ Border = TRUE;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 57 ) ;
+ Size = MAP_APPFONT ( 240 , 8 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 69 , 68) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 122 , 68 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx b/sw/source/ui/dbui/mmoutputtypepage.cxx
new file mode 100644
index 000000000000..88aa3ba496ff
--- /dev/null
+++ b/sw/source/ui/dbui/mmoutputtypepage.cxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmoutputtypepage.cxx,v $
+ * $Revision: 1.10 $
+ *
+ * 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 <mmoutputtypepage.hxx>
+#include <mailmergewizard.hxx>
+#include <mmconfigitem.hxx>
+#include <vcl/msgbox.hxx>
+#ifndef _DBUI_HRC
+#include <dbui.hrc>
+#endif
+#include <swtypes.hxx>
+#include <mmoutputtypepage.hrc>
+#include <dbui.hrc>
+
+/*-- 02.04.2004 11:06:55---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeOutputTypePage::SwMailMergeOutputTypePage( SwMailMergeWizard* _pParent) :
+ svt::OWizardPage( _pParent, SW_RES(DLG_MM_OUTPUTTYPE_PAGE)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aHeaderFI( this, SW_RES( FI_HEADER )),
+ m_aTypeFT( this, SW_RES( FT_TYPE )),
+ m_aLetterRB( this, SW_RES( RB_LETTER )),
+ m_aMailRB( this, SW_RES( RB_MAIL )),
+ m_aHintHeaderFI(this, SW_RES( FI_HINTHEADER)),
+ m_aHintFI( this, SW_RES( FI_HINT)),
+ m_aNoMailHintFI(this, SW_RES( FT_NOMAILHINT)),
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+ m_sLetterHintHeader( SW_RES( ST_LETTERHINTHEADER)),
+ m_sMailHintHeader( SW_RES( ST_MAILHINTHEADER)),
+ m_sLetterHint( SW_RES( ST_LETTERHINT)),
+ m_sMailHint( SW_RES( ST_MAILHINT)),
+ m_pWizard(_pParent)
+{
+ FreeResource();
+ Link aLink = LINK(this, SwMailMergeOutputTypePage, TypeHdl_Impl);
+ m_aLetterRB.SetClickHdl(aLink);
+ m_aMailRB.SetClickHdl(aLink);
+
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ m_pWizard->EnterWait();
+ bool bMailAvailable = rConfigItem.IsMailAvailable();
+ m_pWizard->LeaveWait();
+ if(rConfigItem.IsOutputToLetter())
+ m_aLetterRB.Check();
+ else
+ m_aMailRB.Check();
+ if(!bMailAvailable)
+ {
+ m_aNoMailHintFI.Show();
+ m_aMailRB.Enable(sal_False);
+ m_aLetterRB.Check();
+ }
+ TypeHdl_Impl(&m_aLetterRB);
+
+}
+/*-- 02.04.2004 11:06:55---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeOutputTypePage::~SwMailMergeOutputTypePage()
+{
+}
+/*-- 14.04.2004 14:44:07---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( SwMailMergeOutputTypePage, TypeHdl_Impl, RadioButton*, EMPTYARG )
+{
+ bool bLetter = m_aLetterRB.IsChecked();
+ m_aHintHeaderFI.SetText(bLetter ? m_sLetterHintHeader : m_sMailHintHeader);
+ m_aHintFI.SetText(bLetter ? m_sLetterHint : m_sMailHint);
+ m_pWizard->GetConfigItem().SetOutputToLetter(bLetter);
+ m_pWizard->updateRoadmapItemLabel( MM_ADDRESSBLOCKPAGE );
+ m_pWizard->UpdateRoadmap();
+ return 0;
+}
+
+
diff --git a/sw/source/ui/dbui/mmoutputtypepage.hrc b/sw/source/ui/dbui/mmoutputtypepage.hrc
new file mode 100644
index 000000000000..b57344e7caaf
--- /dev/null
+++ b/sw/source/ui/dbui/mmoutputtypepage.hrc
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmoutputtypepage.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEOUTPUTTYPEPAGE_HRC
+#define _MAILMERGEOUTPUTTYPEPAGE_HRC
+
+#define FT_TYPE 1
+#define RB_LETTER 2
+#define RB_MAIL 3
+#define FI_HEADER 4
+#define FI_HINTHEADER 5
+#define FI_HINT 6
+#define ST_LETTERHINTHEADER 7
+#define ST_MAILHINTHEADER 8
+#define ST_LETTERHINT 9
+#define ST_MAILHINT 10
+#define FT_NOMAILHINT 11
+
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmoutputtypepage.hxx b/sw/source/ui/dbui/mmoutputtypepage.hxx
new file mode 100644
index 000000000000..b268f152f790
--- /dev/null
+++ b/sw/source/ui/dbui/mmoutputtypepage.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmoutputtypepage.hxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEOUTPUTTYPEPAGE_HXX
+#define _MAILMERGEOUTPUTTYPEPAGE_HXX
+
+#include <svtools/wizardmachine.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <svtools/stdctrl.hxx>
+#include <mailmergehelper.hxx>
+class SwMailMergeWizard;
+/*-- 02.04.2004 09:21:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwMailMergeOutputTypePage : public svt::OWizardPage
+{
+ SwBoldFixedInfo m_aHeaderFI;
+ FixedInfo m_aTypeFT;
+ RadioButton m_aLetterRB;
+ RadioButton m_aMailRB;
+
+ SwBoldFixedInfo m_aHintHeaderFI;
+ FixedInfo m_aHintFI;
+ FixedInfo m_aNoMailHintFI;
+
+ String m_sLetterHintHeader;
+ String m_sMailHintHeader;
+ String m_sLetterHint;
+ String m_sMailHint;
+
+ SwMailMergeWizard* m_pWizard;
+
+ DECL_LINK(TypeHdl_Impl, RadioButton*);
+
+public:
+ SwMailMergeOutputTypePage( SwMailMergeWizard* _pParent);
+ ~SwMailMergeOutputTypePage();
+
+};
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmoutputtypepage.src b/sw/source/ui/dbui/mmoutputtypepage.src
new file mode 100644
index 000000000000..e1a8167a22d1
--- /dev/null
+++ b/sw/source/ui/dbui/mmoutputtypepage.src
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmoutputtypepage.src,v $
+ * $Revision: 1.9 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <mmoutputtypepage.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+TabPage DLG_MM_OUTPUTTYPE_PAGE
+{
+ HelpID = HID_MM_OUTPUTTYPEPAGE ;
+ Size = MAP_APPFONT ( 260 , 250 ) ;
+ Hide = TRUE ;
+
+ FixedText FI_HEADER
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text[ en-US ] = "Select a document type";
+ };
+ FixedText FT_TYPE
+ {
+ Pos = MAP_APPFONT ( 6 , 27 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text[ en-US ] = "What type of document do you want to create?";
+ };
+ RadioButton RB_LETTER
+ {
+ Pos = MAP_APPFONT ( 12 , 43 ) ;
+ Size = MAP_APPFONT ( 240 , 10 ) ;
+ Text[ en-US ] = "~Letter";
+ };
+ RadioButton RB_MAIL
+ {
+ Pos = MAP_APPFONT ( 12 , 57 ) ;
+ Size = MAP_APPFONT ( 240 , 10 ) ;
+ Text[ en-US ] = "~E-mail message";
+ };
+ FixedText FI_HINTHEADER
+ {
+ Pos = MAP_APPFONT ( 12 , 72) ;
+ Size = MAP_APPFONT ( 242 , 8 ) ;
+ };
+ FixedText FI_HINT
+ {
+ Pos = MAP_APPFONT ( 12 , 83 ) ;
+ Size = MAP_APPFONT ( 242 , 26 ) ;
+ WordBreak = TRUE;
+ };
+ String ST_LETTERHINTHEADER
+ {
+ Text[ en-US ] = "Letter:";
+ };
+ String ST_MAILHINTHEADER
+ {
+ Text[ en-US ] = "E-Mail Message:";
+ };
+ String ST_LETTERHINT
+ {
+ Text[ en-US ] = "Send letters to a group of recipients. The letters can contain an address block and a salutation. The letters can be personalized for each recipient.";
+ };
+ String ST_MAILHINT
+ {
+ Text[ en-US ] = "Send e-mail messages to a group of recipients. The e-mail messages can contain a salutation. The e-mail messages can be personalized for each recipient.";
+ };
+ FixedText FT_NOMAILHINT
+ {
+ Pos = MAP_APPFONT ( 12 , 113 ) ;
+ Size = MAP_APPFONT ( 242 , 42 ) ;
+ WordBreak = TRUE;
+ Hide = TRUE;
+ Text[ en-US ] = "%PRODUCTNAME was unable to find a Java Mail connection. In order to send e-mail with %PRODUCTNAME, you need to install the latest version of Java Mail. You can find further information about Java Mail on the internet at 'http://java.sun.com/products/javamail/'.";
+ };
+};
+
+
+
diff --git a/sw/source/ui/dbui/mmpreparemergepage.cxx b/sw/source/ui/dbui/mmpreparemergepage.cxx
new file mode 100644
index 000000000000..c8c7de0aeca5
--- /dev/null
+++ b/sw/source/ui/dbui/mmpreparemergepage.cxx
@@ -0,0 +1,207 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmpreparemergepage.cxx,v $
+ * $Revision: 1.13 $
+ *
+ * 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 <mmpreparemergepage.hxx>
+#include <mailmergewizard.hxx>
+#include <mmconfigitem.hxx>
+#ifndef _DBUI_HRC
+#include <dbui.hrc>
+#endif
+#include <swtypes.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#ifndef _DBMGR_HXX
+#include <dbmgr.hxx>
+#endif
+#include <wrtsh.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <swabstdlg.hxx>
+
+
+#include <mmpreparemergepage.hrc>
+#include <dbui.hrc>
+
+#include <unomid.h>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using ::rtl::OUString;
+
+/*-- 02.04.2004 16:42:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergePrepareMergePage::SwMailMergePrepareMergePage( SwMailMergeWizard* _pParent) :
+ svt::OWizardPage( _pParent, SW_RES(DLG_MM_PREPAREMERGE_PAGE)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aHeaderFI(this, SW_RES( FI_HEADER ) ),
+ m_aPreviewFI(this, SW_RES( FI_PREVIEW ) ),
+ m_aRecipientFT(this, SW_RES( FT_RECIPIENT ) ),
+ m_aFirstPB(this, SW_RES( PB_FIRST ) ),
+ m_aPrevPB(this, SW_RES( PB_PREV ) ),
+ m_aRecordED(this, SW_RES( ED_RECORD ) ),
+ m_aNextPB(this, SW_RES( PB_NEXT ) ),
+ m_aLastPB(this, SW_RES( PB_LAST ) ),
+ m_ExcludeCB(this, SW_RES( CB_EXCLUDE ) ),
+ m_aNoteHeaderFL(this, SW_RES( FL_NOTEHEADER ) ),
+ m_aEditFI(this, SW_RES( FI_EDIT ) ),
+ m_aEditPB(this, SW_RES( PB_EDIT ) ),
+#ifdef MSC
+#pragma warning (default : 4355)
+#endif
+ m_pWizard(_pParent)
+{
+ FreeResource();
+ m_aEditPB.SetClickHdl( LINK( this, SwMailMergePrepareMergePage, EditDocumentHdl_Impl));
+ Link aMoveLink(LINK( this, SwMailMergePrepareMergePage, MoveHdl_Impl));
+ m_aFirstPB.SetClickHdl( aMoveLink );
+ m_aPrevPB.SetClickHdl( aMoveLink );
+ m_aNextPB.SetClickHdl( aMoveLink );
+ m_aLastPB.SetClickHdl( aMoveLink );
+ m_aRecordED.SetActionHdl( aMoveLink );
+ m_ExcludeCB.SetClickHdl(LINK(this, SwMailMergePrepareMergePage, ExcludeHdl_Impl));
+ aMoveLink.Call(&m_aRecordED);
+}
+/*-- 02.04.2004 16:42:49---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergePrepareMergePage::~SwMailMergePrepareMergePage()
+{
+}
+/*-- 13.05.2004 15:36:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( SwMailMergePrepareMergePage, EditDocumentHdl_Impl, PushButton*, EMPTYARG)
+{
+ m_pWizard->SetRestartPage(MM_PREPAREMERGEPAGE);
+ m_pWizard->EndDialog(RET_EDIT_DOC);
+ return 0;
+}
+/*-- 27.05.2004 14:16:37---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( SwMailMergePrepareMergePage, MoveHdl_Impl, void*, pCtrl)
+{
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ sal_Int32 nPos = rConfigItem.GetResultSetPosition();
+ if(pCtrl == &m_aFirstPB)
+ {
+ rConfigItem.MoveResultSet(1);
+ }
+ else if(pCtrl == &m_aPrevPB)
+ {
+ rConfigItem.MoveResultSet(nPos - 1);
+ }
+ else if(pCtrl == &m_aRecordED)
+ {
+ rConfigItem.MoveResultSet( static_cast< sal_Int32 >(m_aRecordED.GetValue()) );
+ }
+ else if(pCtrl == &m_aNextPB)
+ rConfigItem.MoveResultSet(nPos + 1);
+ else if(pCtrl == &m_aLastPB)
+ rConfigItem.MoveResultSet(-1);
+
+ nPos = rConfigItem.GetResultSetPosition();
+ m_aRecordED.SetValue(nPos);
+ bool bIsFirst;
+ bool bIsLast;
+ bool bValid = rConfigItem.IsResultSetFirstLast(bIsFirst, bIsLast);
+ m_aFirstPB.Enable(bValid && !bIsFirst);
+ m_aPrevPB.Enable(bValid && !bIsFirst);
+ m_aNextPB.Enable(bValid && !bIsLast);
+ m_aLastPB.Enable(bValid && !bIsLast);
+ m_ExcludeCB.Check(rConfigItem.IsRecordExcluded( rConfigItem.GetResultSetPosition() ));
+ //now the record has to be merged into the source document
+ const SwDBData& rDBData = rConfigItem.GetCurrentDBData();
+
+ Sequence< PropertyValue > aArgs(7);
+ Sequence<Any> aSelection(1);
+ aSelection[0] <<= rConfigItem.GetResultSetPosition();
+ aArgs[0].Name = C2U("Selection");
+ aArgs[0].Value <<= aSelection;
+ aArgs[1].Name = C2U("DataSourceName");
+ aArgs[1].Value <<= rDBData.sDataSource;
+ aArgs[2].Name = C2U("Command");
+ aArgs[2].Value <<= rDBData.sCommand;
+ aArgs[3].Name = C2U("CommandType");
+ aArgs[3].Value <<= rDBData.nCommandType;
+ aArgs[4].Name = C2U("ActiveConnection");
+ aArgs[4].Value <<= rConfigItem.GetConnection().getTyped();
+ aArgs[5].Name = C2U("Filter");
+ aArgs[5].Value <<= rConfigItem.GetFilter();
+ aArgs[6].Name = C2U("Cursor");
+ aArgs[6].Value <<= rConfigItem.GetResultSet();
+
+ ::svx::ODataAccessDescriptor aDescriptor(aArgs);
+ SwWrtShell& rSh = m_pWizard->GetSwView()->GetWrtShell();
+ SwMergeDescriptor aMergeDesc( DBMGR_MERGE, rSh, aDescriptor );
+ rSh.GetNewDBMgr()->MergeNew(aMergeDesc);
+ return 0;
+}
+/*-- 27.05.2004 14:46:28---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( SwMailMergePrepareMergePage, ExcludeHdl_Impl, CheckBox*, pBox)
+{
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ rConfigItem.ExcludeRecord( rConfigItem.GetResultSetPosition(), pBox->IsChecked());
+ return 0;
+};
+/*-- 18.08.2004 10:36:25---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwMailMergePrepareMergePage::ActivatePage()
+{
+ MoveHdl_Impl(&m_aRecordED);
+}
+/*-- 13.05.2004 15:38:32---------------------------------------------------
+ merge the data into a new file
+ -----------------------------------------------------------------------*/
+sal_Bool SwMailMergePrepareMergePage::commitPage( CommitPageReason _eReason )
+{
+ SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
+ if(eTravelForward == _eReason && !rConfigItem.IsMergeDone())
+ {
+ m_pWizard->CreateTargetDocument();
+ m_pWizard->SetRestartPage(MM_MERGEPAGE);
+ m_pWizard->EndDialog(RET_TARGET_CREATED);
+ }
+ return sal_True;
+}
diff --git a/sw/source/ui/dbui/mmpreparemergepage.hrc b/sw/source/ui/dbui/mmpreparemergepage.hrc
new file mode 100644
index 000000000000..d2958128f4c2
--- /dev/null
+++ b/sw/source/ui/dbui/mmpreparemergepage.hrc
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmpreparemergepage.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEPREPAREMERGEPAGE_HRC
+#define _MAILMERGEPREPAREMERGEPAGE_HRC
+
+#define FI_HEADER 1
+#define FI_PREVIEW 2
+#define PB_FIRST 3
+#define PB_PREV 4
+#define ED_RECORD 5
+#define PB_NEXT 6
+#define PB_LAST 7
+#define CB_EXCLUDE 8
+#define FI_EDIT 9
+#define PB_EDIT 10
+#define FL_NOTEHEADER 11
+
+#define FT_RECIPIENT 13
+
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmpreparemergepage.hxx b/sw/source/ui/dbui/mmpreparemergepage.hxx
new file mode 100644
index 000000000000..56765ff13c71
--- /dev/null
+++ b/sw/source/ui/dbui/mmpreparemergepage.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmpreparemergepage.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _MAILMERGEPREPAREMERGEPAGE_HXX
+#define _MAILMERGEPREPAREMERGEPAGE_HXX
+
+#include <svtools/wizardmachine.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <vcl/field.hxx>
+#include <svtools/stdctrl.hxx>
+#include <mailmergehelper.hxx>
+#include "actctrl.hxx"
+
+class SwMailMergeWizard;
+/*-- 02.04.2004 09:21:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwMailMergePrepareMergePage : public svt::OWizardPage
+{
+ SwBoldFixedInfo m_aHeaderFI;
+ FixedInfo m_aPreviewFI;
+ FixedText m_aRecipientFT;
+ PushButton m_aFirstPB;
+ PushButton m_aPrevPB;
+ NumEditAction m_aRecordED;
+ PushButton m_aNextPB;
+ PushButton m_aLastPB;
+ CheckBox m_ExcludeCB;
+
+ FixedLine m_aNoteHeaderFL;
+ FixedInfo m_aEditFI;
+ PushButton m_aEditPB;
+
+
+ SwMailMergeWizard* m_pWizard;
+
+ DECL_LINK(EditDocumentHdl_Impl, PushButton*);
+ DECL_LINK(ExcludeHdl_Impl, CheckBox*);
+ DECL_LINK(MoveHdl_Impl, void*);
+
+ virtual void ActivatePage();
+ virtual sal_Bool commitPage( CommitPageReason _eReason );
+
+public:
+ SwMailMergePrepareMergePage( SwMailMergeWizard* _pParent);
+ ~SwMailMergePrepareMergePage();
+
+};
+
+#endif
+
+
diff --git a/sw/source/ui/dbui/mmpreparemergepage.src b/sw/source/ui/dbui/mmpreparemergepage.src
new file mode 100644
index 000000000000..984c72550727
--- /dev/null
+++ b/sw/source/ui/dbui/mmpreparemergepage.src
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mmpreparemergepage.src,v $
+ * $Revision: 1.9 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <mmpreparemergepage.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+TabPage DLG_MM_PREPAREMERGE_PAGE
+{
+ HelpID = HID_MM_PREPAREMERGEPAGE ;
+ Size = MAP_APPFONT ( 260 , 250 ) ;
+ Hide = TRUE ;
+
+ FixedText FI_HEADER
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text[ en-US ] = "Preview and edit the document";
+ };
+
+ FixedText FI_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 6 , 27 ) ;
+ Size = MAP_APPFONT ( 248 , 26 ) ;
+ WordBreak = TRUE;
+ Text[ en-US ] = "The preview of a merged document is visible now. To see the preview of another document click one of the arrows.";
+ };
+ FixedText FT_RECIPIENT
+ {
+ Pos = MAP_APPFONT ( 12 , 58 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text[ en-US ] = "~Recipient";
+ };
+
+ PushButton PB_FIRST
+ {
+ Pos = MAP_APPFONT ( 75 , 55 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ Text = "|<" ;
+ QuickHelpText [en-US] = "First";
+ };
+ PushButton PB_PREV
+ {
+ Pos = MAP_APPFONT ( 98 , 55 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ Text = "<" ;
+ QuickHelpText [en-US] = "Previous";
+ };
+ NumericField ED_RECORD
+ {
+ Pos = MAP_APPFONT ( 121 , 56 ) ;
+ Size = MAP_APPFONT ( 20 , 12 ) ;
+ Border = TRUE ;
+ Left = TRUE ;
+ First = 1 ;
+ Minimum = 1 ;
+ Repeat = TRUE ;
+ Spin = FALSE ;
+ TabStop = TRUE ;
+ };
+ PushButton PB_NEXT
+ {
+ Pos = MAP_APPFONT ( 144 , 55 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ Text = ">" ;
+ QuickHelpText [en-US] = "Next";
+ };
+ PushButton PB_LAST
+ {
+ Pos = MAP_APPFONT ( 167 , 55 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ Text = ">|" ;
+ QuickHelpText [en-US] = "Last";
+ };
+ CheckBox CB_EXCLUDE
+ {
+ Pos = MAP_APPFONT ( 75, 77 ) ;
+ Size = MAP_APPFONT ( 179 , 10 ) ;
+ Text[ en-US ] = "E~xclude this recipient";
+ };
+ FixedLine FL_NOTEHEADER
+ {
+ Pos = MAP_APPFONT ( 6 , 100 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text[ en-US ] = "Edit Document";
+ };
+ FixedText FI_EDIT
+ {
+ Pos = MAP_APPFONT ( 12 , 122 ) ;
+ Size = MAP_APPFONT ( 242 , 60 ) ;
+ WordBreak = TRUE;
+ Text[ en-US ] = "Write or edit your document now if you have not already done so. The changes will effect all merged documents.\n\nClicking 'Edit Document...' will temporarily reduce the wizard to a small window so you can edit the mail merge document. After editing the document, return to the wizard by clicking 'Return to Mail Merge Wizard' in the small window." ;
+ };
+ PushButton PB_EDIT
+ {
+ Pos = MAP_APPFONT ( 90 , 185 ) ;
+ Size = MAP_APPFONT ( 80 , 14 ) ;
+ Text[ en-US ] = "~Edit Document...";
+ };
+};
+
+
diff --git a/sw/source/ui/dbui/selectdbtabledialog.cxx b/sw/source/ui/dbui/selectdbtabledialog.cxx
new file mode 100644
index 000000000000..96b87c93779e
--- /dev/null
+++ b/sw/source/ui/dbui/selectdbtabledialog.cxx
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: selectdbtabledialog.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * 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 <swtypes.hxx>
+#include <selectdbtabledialog.hxx>
+#include <dbtablepreviewdialog.hxx>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+
+#include <unomid.h>
+
+#include <selectdbtabledialog.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+
+/*-- 08.04.2004 14:33:56---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwSelectDBTableDialog::SwSelectDBTableDialog(Window* pParent,
+ const uno::Reference< sdbc::XConnection>& rConnection) :
+ SfxModalDialog(pParent, SW_RES(DLG_MM_SELECTDBTABLEDDIALOG)),
+#ifdef MSC
+#pragma warning (disable : 4355)
+#endif
+ m_aSelectFI( this, SW_RES( FI_SELECT )),
+ m_aTableHB( this, WB_BUTTONSTYLE | WB_BOTTOMBORDER),
+ m_aTableLB( this, SW_RES( LB_TABLE )),
+ m_aPreviewPB( this, SW_RES( PB_PREVIEW )),
+ 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_sName( SW_RES( ST_NAME )),
+ m_sType( SW_RES( ST_TYPE )),
+ m_sTable( SW_RES( ST_TABLE )),
+ m_sQuery( SW_RES( ST_QUERY )),
+ m_xConnection(rConnection)
+{
+ FreeResource();
+
+ Size aLBSize(m_aTableLB.GetSizePixel());
+ m_aTableHB.SetSizePixel(aLBSize);
+ Size aHeadSize(m_aTableHB.CalcWindowSizePixel());
+ aHeadSize.Width() = aLBSize.Width();
+ m_aTableHB.SetSizePixel(aHeadSize);
+ Point aLBPos(m_aTableLB.GetPosPixel());
+ m_aTableHB.SetPosPixel(aLBPos);
+ aLBPos.Y() += aHeadSize.Height();
+ aLBSize.Height() -= aHeadSize.Height();
+ m_aTableLB.SetPosSizePixel(aLBPos, aLBSize);
+
+ Size aSz(m_aTableHB.GetOutputSizePixel());
+ m_aTableHB.InsertItem( 1, m_sName,
+ aSz.Width()/2,
+ HIB_LEFT | HIB_VCENTER /*| HIB_CLICKABLE | HIB_UPARROW */);
+ m_aTableHB.InsertItem( 2, m_sType,
+ aSz.Width()/2,
+ HIB_LEFT | HIB_VCENTER /*| HIB_CLICKABLE | HIB_UPARROW */);
+ m_aTableHB.SetHelpId(HID_MM_ADDRESSLIST_HB );
+ m_aTableHB.Show();
+
+ static long nTabs[] = {3, 0, aSz.Width()/2, aSz.Width() };
+ m_aTableLB.SetTabs(&nTabs[0], MAP_PIXEL);
+ m_aTableLB.SetHelpId(HID_MM_SELECTDBTABLEDDIALOG_LISTBOX);
+ m_aTableLB.SetWindowBits( WB_CLIPCHILDREN );
+ m_aTableLB.SetSpaceBetweenEntries(3);
+ m_aTableLB.SetSelectionMode( SINGLE_SELECTION );
+ m_aTableLB.SetDragDropMode( 0 );
+ m_aTableLB.EnableAsyncDrag(FALSE);
+
+ m_aPreviewPB.SetClickHdl(LINK(this, SwSelectDBTableDialog, PreviewHdl));
+
+ Reference<XTablesSupplier> xTSupplier(m_xConnection, UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ Reference<XNameAccess> xTbls = xTSupplier->getTables();
+ Sequence<rtl::OUString> aTbls = xTbls->getElementNames();
+ const rtl::OUString* pTbls = aTbls.getConstArray();
+ for(long i = 0; i < aTbls.getLength(); i++)
+ {
+ String sEntry = pTbls[i];
+ sEntry += '\t';
+ sEntry += m_sTable;
+ SvLBoxEntry* pEntry = m_aTableLB.InsertEntry(sEntry);
+ pEntry->SetUserData((void*)0);
+ }
+ }
+ Reference<XQueriesSupplier> xQSupplier(m_xConnection, UNO_QUERY);
+ if(xQSupplier.is())
+ {
+ Reference<XNameAccess> xQueries = xQSupplier->getQueries();
+ Sequence<rtl::OUString> aQueries = xQueries->getElementNames();
+ const rtl::OUString* pQueries = aQueries.getConstArray();
+ for(long i = 0; i < aQueries.getLength(); i++)
+ {
+ String sEntry = pQueries[i];
+ sEntry += '\t';
+ sEntry += m_sQuery;
+ SvLBoxEntry* pEntry = m_aTableLB.InsertEntry(sEntry);
+ pEntry->SetUserData((void*)1);
+ }
+ }
+}
+/*-- 08.04.2004 14:33:57---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwSelectDBTableDialog::~SwSelectDBTableDialog()
+{
+}
+/*-- 08.04.2004 14:33:57---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK(SwSelectDBTableDialog, PreviewHdl, PushButton*, pButton)
+{
+ SvLBoxEntry* pEntry = m_aTableLB.FirstSelected();
+ if(pEntry)
+ {
+ ::rtl::OUString sTableOrQuery = m_aTableLB.GetEntryText(pEntry, 0);
+ sal_Int32 nCommandType = 0 == pEntry->GetUserData() ? 0 : 1;
+
+ ::rtl::OUString sDataSourceName;
+ Reference<XChild> xChild(m_xConnection, UNO_QUERY);
+ if(xChild.is())
+ {
+ Reference<XDataSource> xSource(xChild->getParent(), UNO_QUERY);
+ Reference<XPropertySet> xPrSet(xSource, UNO_QUERY);
+ xPrSet->getPropertyValue(C2U("Name")) >>= sDataSourceName;
+ }
+ DBG_ASSERT(sDataSourceName.getLength(), "no data source found");
+ Sequence<PropertyValue> aProperties(5);
+ PropertyValue* pProperties = aProperties.getArray();
+ pProperties[0].Name = C2U("DataSourceName");
+ pProperties[0].Value <<= sDataSourceName;
+ pProperties[1].Name = C2U("Command");
+ pProperties[1].Value <<= sTableOrQuery;
+ pProperties[2].Name = C2U("CommandType");
+ pProperties[2].Value <<= nCommandType;
+ pProperties[3].Name = C2U("ShowTreeView");
+ sal_Bool bFalse = sal_False;
+ pProperties[3].Value <<= bFalse;
+ pProperties[4].Name = C2U("ShowTreeViewButton");
+ pProperties[4].Value <<= bFalse;
+
+ SwDBTablePreviewDialog* pDlg = new SwDBTablePreviewDialog(pButton, aProperties);
+ pDlg->Execute();
+ delete pDlg;
+ }
+
+ return 0;
+}
+/*-- 19.04.2004 10:03:26---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+String SwSelectDBTableDialog::GetSelectedTable(bool& bIsTable)
+{
+ SvLBoxEntry* pEntry = m_aTableLB.FirstSelected();
+ bIsTable = pEntry->GetUserData() ? false : true;
+ return pEntry ? m_aTableLB.GetEntryText(pEntry, 0) : String();
+}
+/*-- 13.05.2004 12:58:26---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwSelectDBTableDialog::SetSelectedTable(const String& rTable, bool bIsTable)
+{
+ SvLBoxEntry* pEntry = m_aTableLB.First();
+ while(pEntry)
+ {
+ if((m_aTableLB.GetEntryText(pEntry, 0) == rTable) &&
+ ((pEntry->GetUserData() == 0 ) == bIsTable))
+ {
+ m_aTableLB.Select(pEntry);
+ break;
+ }
+ pEntry = m_aTableLB.Next( pEntry );
+ }
+}
diff --git a/sw/source/ui/dbui/selectdbtabledialog.hrc b/sw/source/ui/dbui/selectdbtabledialog.hrc
new file mode 100644
index 000000000000..3fcb2d1ee491
--- /dev/null
+++ b/sw/source/ui/dbui/selectdbtabledialog.hrc
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: selectdbtabledialog.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _SELECTDBTABLEDIALOG_HRC
+#define _SELECTDBTABLEDIALOG_HRC
+
+#define FI_SELECT 1
+#define LB_TABLE 2
+#define PB_PREVIEW 3
+#define PB_OK 4
+#define PB_CANCEL 5
+#define PB_HELP 6
+#define FL_SEPARATOR 7
+#define ST_TYPE 8
+#define ST_NAME 9
+#define ST_TABLE 10
+#define ST_QUERY 11
+
+#endif
+
diff --git a/sw/source/ui/dbui/selectdbtabledialog.hxx b/sw/source/ui/dbui/selectdbtabledialog.hxx
new file mode 100644
index 000000000000..868668b08d6c
--- /dev/null
+++ b/sw/source/ui/dbui/selectdbtabledialog.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: selectdbtabledialog.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _SELECTDBTABLEDIALOG_HXX
+#define _SELECTDBTABLEDIALOG_HXX
+
+#include <sfx2/basedlgs.hxx>
+
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <vcl/fixed.hxx>
+#include <svtools/svtabbx.hxx>
+#include <svtools/headbar.hxx>
+namespace com{namespace sun{namespace star{
+ namespace sdbc{
+ class XConnection;
+ }
+}}}
+
+/*-- 08.04.2004 14:04:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+class SwSelectDBTableDialog : public SfxModalDialog
+{
+ FixedText m_aSelectFI;
+ HeaderBar m_aTableHB;
+ SvTabListBox m_aTableLB;
+ PushButton m_aPreviewPB;
+
+ FixedLine m_aSeparatorFL;
+
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ String m_sName;
+ String m_sType;
+ String m_sTable;
+ String m_sQuery;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+
+ DECL_LINK(PreviewHdl, PushButton*);
+public:
+
+ SwSelectDBTableDialog(Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& xConnection
+ );
+ ~SwSelectDBTableDialog();
+
+ String GetSelectedTable(bool& bIsTable);
+ void SetSelectedTable(const String& rTable, bool bIsTable);
+};
+#endif
+
diff --git a/sw/source/ui/dbui/selectdbtabledialog.src b/sw/source/ui/dbui/selectdbtabledialog.src
new file mode 100644
index 000000000000..8a08c4c16e8b
--- /dev/null
+++ b/sw/source/ui/dbui/selectdbtabledialog.src
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: selectdbtabledialog.src,v $
+ * $Revision: 1.6 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <selectdbtabledialog.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+ModalDialog DLG_MM_SELECTDBTABLEDDIALOG
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_SELECTDBTABLEDDIALOG;
+ Size = MAP_APPFONT ( 250 , 135 ) ;
+ Moveable = TRUE ;
+
+ Text [ en-US ] = "Select Table";
+
+ FixedText FI_SELECT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 238 , 24 ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "The file you have selected contains more than one table. Please select the table containing the address list you want to use.";
+ };
+ Control LB_TABLE
+ {
+ Pos = MAP_APPFONT ( 6 , 30 ) ;
+ Size = MAP_APPFONT ( 238 , 50 ) ;
+ Border = TRUE;
+ };
+ PushButton PB_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 6 , 84 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Preview";
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 6 , 104 ) ;
+ Size = MAP_APPFONT ( 238 , 8 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 85 , 115 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 138 , 115 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 194 , 115 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String ST_NAME
+ {
+ Text [ en-US ] = "Name";
+ };
+ String ST_TYPE
+ {
+ Text [ en-US ] = "Type";
+ };
+ String ST_TABLE
+ {
+ Text [ en-US ] = "Table";
+ };
+ String ST_QUERY
+ {
+ Text [ en-US ] = "Query";
+ };
+
+};
diff --git a/sw/source/ui/dbui/swdbtoolsclient.cxx b/sw/source/ui/dbui/swdbtoolsclient.cxx
new file mode 100644
index 000000000000..354495884c1e
--- /dev/null
+++ b/sw/source/ui/dbui/swdbtoolsclient.cxx
@@ -0,0 +1,251 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: swdbtoolsclient.cxx,v $
+ * $Revision: 1.9 $
+ *
+ * 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"
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <swdbtoolsclient.hxx>
+#include <osl/diagnose.h>
+#include <tools/solar.h>
+
+//........................................................................
+
+using namespace ::connectivity::simple;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdb;
+
+//====================================================================
+//= SwDbtoolsClient
+//====================================================================
+namespace
+{
+ // -----------------------------------------------------------------------------
+ // this namespace contains access to all static members of the class SwDbtoolsClient
+ // to make the initialize of the dll a little bit faster
+ // -----------------------------------------------------------------------------
+ ::osl::Mutex& getDbtoolsClientMutex()
+ {
+ static ::osl::Mutex aMutex;
+ return aMutex;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Int32& getDbToolsClientClients()
+ {
+ static sal_Int32 nClients = 0;
+ return nClients;
+ }
+ // -----------------------------------------------------------------------------
+ oslModule& getDbToolsClientModule()
+ {
+ static oslModule hDbtoolsModule = NULL;
+ return hDbtoolsModule;
+ }
+ // -----------------------------------------------------------------------------
+ createDataAccessToolsFactoryFunction& getDbToolsClientFactoryFunction()
+ {
+ static createDataAccessToolsFactoryFunction pFactoryCreationFunc = NULL;
+ return pFactoryCreationFunc;
+ }
+ // -----------------------------------------------------------------------------
+}
+// -----------------------------------------------------------------------------
+SwDbtoolsClient::SwDbtoolsClient()
+{
+}
+
+//--------------------------------------------------------------------
+SwDbtoolsClient::~SwDbtoolsClient()
+{
+ if(m_xDataAccessFactory.is())
+ {
+ // clear the factory _before_ revoking the client
+ // (the revocation may unload the DBT lib)
+ m_xDataAccessFactory = NULL;
+ // revoke the client
+ revokeClient();
+ }
+}
+
+//--------------------------------------------------------------------
+extern "C" { static void SAL_CALL thisModule() {} }
+
+void SwDbtoolsClient::registerClient()
+{
+ ::osl::MutexGuard aGuard(getDbtoolsClientMutex());
+ if (1 == ++getDbToolsClientClients())
+ {
+ OSL_ENSURE(NULL == getDbToolsClientModule(), "SwDbtoolsClient::registerClient: inconsistence: already have a module!");
+ OSL_ENSURE(NULL == getDbToolsClientFactoryFunction(), "SwDbtoolsClient::registerClient: inconsistence: already have a factory function!");
+
+ const ::rtl::OUString sModuleName = ::rtl::OUString::createFromAscii(
+ SVLIBRARY( "dbtools" )
+ );
+
+ // load the dbtools library
+ getDbToolsClientModule() = osl_loadModuleRelative(
+ &thisModule, sModuleName.pData, 0);
+ OSL_ENSURE(NULL != getDbToolsClientModule(), "SwDbtoolsClient::registerClient: could not load the dbtools library!");
+ if (NULL != getDbToolsClientModule())
+ {
+ // get the symbol for the method creating the factory
+ const ::rtl::OUString sFactoryCreationFunc = ::rtl::OUString::createFromAscii("createDataAccessToolsFactory");
+ // reinterpret_cast<createDataAccessToolsFactoryFunction> removed for gcc permissive
+ getDbToolsClientFactoryFunction() = reinterpret_cast< createDataAccessToolsFactoryFunction >(
+ osl_getFunctionSymbol(getDbToolsClientModule(), sFactoryCreationFunc.pData));
+
+ if (NULL == getDbToolsClientFactoryFunction())
+ { // did not find the symbol
+ OSL_ENSURE(sal_False, "SwDbtoolsClient::registerClient: could not find the symbol for creating the factory!");
+ osl_unloadModule(getDbToolsClientModule());
+ getDbToolsClientModule() = NULL;
+ }
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+void SwDbtoolsClient::revokeClient()
+{
+ ::osl::MutexGuard aGuard(getDbtoolsClientMutex());
+ if (0 == --getDbToolsClientClients())
+ {
+ getDbToolsClientFactoryFunction() = NULL;
+ if (getDbToolsClientModule())
+ osl_unloadModule(getDbToolsClientModule());
+ getDbToolsClientModule() = NULL;
+ }
+}
+/* -----------------------------30.08.2001 14:58------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwDbtoolsClient::getFactory()
+{
+ if(!m_xDataAccessFactory.is())
+ {
+ registerClient();
+ if(getDbToolsClientFactoryFunction())
+ { // loading the lib succeeded
+ void* pUntypedFactory = (*getDbToolsClientFactoryFunction())();
+ IDataAccessToolsFactory* pDBTFactory = static_cast<IDataAccessToolsFactory*>(pUntypedFactory);
+ OSL_ENSURE(pDBTFactory, "SwDbtoolsClient::SwDbtoolsClient: no factory returned!");
+ if (pDBTFactory)
+ {
+ m_xDataAccessFactory = pDBTFactory;
+ // by definition, the factory was aquired once
+ m_xDataAccessFactory->release();
+ }
+ }
+ }
+}
+/* -----------------------------30.08.2001 11:32------------------------------
+
+ ---------------------------------------------------------------------------*/
+::rtl::Reference< ::connectivity::simple::IDataAccessTools >
+ SwDbtoolsClient::getDataAccessTools()
+{
+ if(!m_xDataAccessTools.is())
+ {
+ getFactory();
+ if(m_xDataAccessFactory.is())
+ m_xDataAccessTools = m_xDataAccessFactory->getDataAccessTools();
+ }
+ return m_xDataAccessTools;
+}
+/* -----------------------------30.08.2001 12:40------------------------------
+
+ ---------------------------------------------------------------------------*/
+::rtl::Reference< ::connectivity::simple::IDataAccessTypeConversion >
+ SwDbtoolsClient::getAccessTypeConversion()
+{
+ if(!m_xAccessTypeConversion.is())
+ {
+ getFactory();
+ if(m_xDataAccessFactory.is())
+ m_xAccessTypeConversion = m_xDataAccessFactory->getTypeConversionHelper();
+ }
+ return m_xAccessTypeConversion;
+}
+
+/* -----------------------------30.08.2001 11:37------------------------------
+
+ ---------------------------------------------------------------------------*/
+Reference< XDataSource > SwDbtoolsClient::getDataSource(
+ const ::rtl::OUString& rRegisteredName,
+ const Reference< XMultiServiceFactory>& xFactory
+ )
+{
+ Reference< XDataSource > xRet;
+ ::rtl::Reference< ::connectivity::simple::IDataAccessTools > xAccess = getDataAccessTools();
+ if(xAccess.is())
+ xRet = xAccess->getDataSource(rRegisteredName, xFactory);
+ return xRet;
+}
+/* -----------------------------30.08.2001 12:06------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Int32 SwDbtoolsClient::getDefaultNumberFormat(
+ const Reference< XPropertySet >& rxColumn,
+ const Reference< XNumberFormatTypes >& rxTypes,
+ const Locale& rLocale
+ )
+{
+ sal_Int32 nRet = -1;
+ ::rtl::Reference< ::connectivity::simple::IDataAccessTools > xAccess = getDataAccessTools();
+ if(xAccess.is())
+ nRet = xAccess->getDefaultNumberFormat( rxColumn, rxTypes, rLocale);
+ return nRet;
+}
+/* -----------------------------30.08.2001 12:38------------------------------
+
+ ---------------------------------------------------------------------------*/
+::rtl::OUString SwDbtoolsClient::getValue(
+ const uno::Reference< beans::XPropertySet>& _rxColumn,
+ const uno::Reference< util::XNumberFormatter>& _rxFormatter,
+ const lang::Locale& _rLocale,
+ const util::Date& _rNullDate
+ )
+
+{
+ ::rtl::Reference< ::connectivity::simple::IDataAccessTypeConversion > xConversion =
+ getAccessTypeConversion();
+ rtl::OUString sRet;
+ if(xConversion.is())
+ sRet = xConversion->getValue(_rxColumn, _rxFormatter, _rLocale, _rNullDate);
+ return sRet;
+}
+