2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 17:23:11 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:23:11 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:23:11 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:23:11 +00:00
|
|
|
* $RCSfile: dbmgr.cxx,v $
|
2008-06-06 09:06:54 +00:00
|
|
|
* $Revision: 1.131 $
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:23:11 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:23:11 +00:00
|
|
|
* 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.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:23:11 +00:00
|
|
|
* 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).
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:23:11 +00:00
|
|
|
* 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.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-16 21:43:40 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
2000-09-18 16:15:01 +00:00
|
|
|
#if STLPORT_VERSION>=321
|
|
|
|
#include <cstdarg>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2003-06-10 08:15:14 +00:00
|
|
|
#include <com/sun/star/text/NotePrintMode.hpp>
|
2006-05-02 14:20:53 +00:00
|
|
|
#include <sfx2/app.hxx>
|
2000-11-13 07:32:00 +00:00
|
|
|
#include <com/sun/star/sdb/CommandType.hpp>
|
2005-03-30 09:55:07 +00:00
|
|
|
#include <com/sun/star/sdb/XDocumentDataSource.hpp>
|
2000-10-27 10:26:20 +00:00
|
|
|
#include <com/sun/star/frame/XComponentLoader.hpp>
|
2005-10-19 07:25:32 +00:00
|
|
|
#include <com/sun/star/lang/DisposedException.hpp>
|
2004-08-02 13:20:28 +00:00
|
|
|
#include <com/sun/star/lang/XEventListener.hpp>
|
2000-11-08 08:46:34 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UTIL_iXNUMBERFORMATTER_HPP_
|
|
|
|
#include <com/sun/star/util/XNumberFormatter.hpp>
|
|
|
|
#endif
|
2000-12-01 10:45:55 +00:00
|
|
|
#include <com/sun/star/sdb/XCompletedConnection.hpp>
|
2002-08-21 11:23:43 +00:00
|
|
|
#include <com/sun/star/sdb/XCompletedExecution.hpp>
|
2001-06-08 12:47:33 +00:00
|
|
|
#include <com/sun/star/container/XChild.hpp>
|
2003-03-27 14:45:43 +00:00
|
|
|
#ifndef _COM_SUN_STAR_TEXT_MAILMERGEEVENT_
|
|
|
|
#include <com/sun/star/text/MailMergeEvent.hpp>
|
|
|
|
#endif
|
2004-08-02 13:20:28 +00:00
|
|
|
#include <com/sun/star/frame/XStorable.hpp>
|
2006-10-12 10:07:57 +00:00
|
|
|
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
|
2004-08-02 13:20:28 +00:00
|
|
|
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
|
|
|
|
#include <com/sun/star/uno/XNamingService.hpp>
|
2007-11-06 15:25:40 +00:00
|
|
|
#include <com/sun/star/util/XCloseable.hpp>
|
2008-03-07 10:16:55 +00:00
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
2005-01-28 14:47:46 +00:00
|
|
|
#include <sfx2/fcontnr.hxx>
|
2004-08-02 13:20:28 +00:00
|
|
|
#include <sfx2/filedlghelper.hxx>
|
2000-10-27 10:26:20 +00:00
|
|
|
#include <sfx2/viewfrm.hxx>
|
2001-02-21 11:27:37 +00:00
|
|
|
#include <dbconfig.hxx>
|
2001-08-30 12:56:46 +00:00
|
|
|
#include <swdbtoolsclient.hxx>
|
2004-09-20 12:11:33 +00:00
|
|
|
#include <pagedesc.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#ifndef _LSTBOX_HXX //autogen
|
|
|
|
#include <vcl/lstbox.hxx>
|
|
|
|
#endif
|
2000-11-06 08:30:33 +00:00
|
|
|
#include <unotools/tempfile.hxx>
|
2004-08-02 13:20:28 +00:00
|
|
|
#include <svtools/pathoptions.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#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>
|
2002-11-29 11:14:12 +00:00
|
|
|
#include <cmdid.h>
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <swmodule.hxx>
|
|
|
|
#ifndef _VIEW_HXX
|
|
|
|
#include <view.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DOCSH_HXX
|
|
|
|
#include <docsh.hxx>
|
|
|
|
#endif
|
|
|
|
#include <edtwin.hxx>
|
|
|
|
#include <wrtsh.hxx>
|
|
|
|
#include <fldbas.hxx>
|
|
|
|
#include <initui.hxx>
|
|
|
|
#include <swundo.hxx>
|
|
|
|
#include <flddat.hxx>
|
|
|
|
#ifndef _MODCFG_HXX
|
|
|
|
#include <modcfg.hxx>
|
|
|
|
#endif
|
|
|
|
#include <swprtopt.hxx>
|
|
|
|
#include <shellio.hxx>
|
|
|
|
#include <dbui.hxx>
|
|
|
|
#ifndef _DBMGR_HXX
|
|
|
|
#include <dbmgr.hxx>
|
|
|
|
#endif
|
|
|
|
#include <doc.hxx>
|
|
|
|
#include <swwait.hxx>
|
2001-10-19 14:33:53 +00:00
|
|
|
#include <swunohelper.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#ifndef _DBUI_HRC
|
|
|
|
#include <dbui.hrc>
|
|
|
|
#endif
|
|
|
|
#ifndef _GLOBALS_HRC
|
|
|
|
#include <globals.hrc>
|
|
|
|
#endif
|
|
|
|
#ifndef _STATSTR_HRC
|
|
|
|
#include <statstr.hrc>
|
|
|
|
#endif
|
2004-09-20 12:11:33 +00:00
|
|
|
#include <mmconfigitem.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <sfx2/request.hxx>
|
|
|
|
#include <hintids.hxx>
|
2008-03-07 10:16:55 +00:00
|
|
|
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
|
2002-08-21 11:23:43 +00:00
|
|
|
#include <com/sun/star/sdbc/XRowSet.hpp>
|
2000-09-18 16:15:01 +00:00
|
|
|
#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>
|
2005-01-28 14:47:46 +00:00
|
|
|
#include <com/sun/star/mail/MailAttachment.hpp>
|
2000-10-20 13:18:07 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2004-11-09 11:56:07 +00:00
|
|
|
#include <comphelper/types.hxx>
|
2008-03-07 10:16:55 +00:00
|
|
|
#include <comphelper/property.hxx>
|
2005-01-28 14:47:46 +00:00
|
|
|
#include <mailmergehelper.hxx>
|
|
|
|
#include <maildispatcher.hxx>
|
|
|
|
#include <svx/htmlcfg.hxx>
|
2006-04-07 14:17:54 +00:00
|
|
|
#include <i18npool/mslangid.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <com/sun/star/util/XNumberFormatTypes.hpp>
|
|
|
|
#include <svx/langitem.hxx>
|
|
|
|
#include <svtools/numuno.hxx>
|
2000-11-13 07:32:00 +00:00
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
#include <unomailmerge.hxx>
|
2000-11-13 07:32:00 +00:00
|
|
|
#include <sfx2/event.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
2002-08-21 11:23:43 +00:00
|
|
|
#include <svx/dataaccessdescriptor.hxx>
|
2002-12-09 12:58:30 +00:00
|
|
|
#include <vos/mutex.hxx>
|
2004-09-20 12:11:33 +00:00
|
|
|
#include <rtl/textenc.h>
|
2005-10-19 07:25:32 +00:00
|
|
|
#include <ndindex.hxx>
|
|
|
|
#include <pam.hxx>
|
|
|
|
#include <swcrsr.hxx>
|
2005-03-11 09:48:02 +00:00
|
|
|
#include <swevent.hxx>
|
2004-09-20 12:11:33 +00:00
|
|
|
#include <osl/file.hxx>
|
2007-09-27 10:31:02 +00:00
|
|
|
#include <swabstdlg.hxx>
|
2006-08-14 16:30:22 +00:00
|
|
|
#include <fmthdft.hxx>
|
2007-09-27 10:31:02 +00:00
|
|
|
#include <dbui.hrc>
|
|
|
|
#include <envelp.hrc>
|
2005-01-28 14:47:46 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
2007-09-27 10:31:02 +00:00
|
|
|
#include <unomid.h>
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-09-20 12:11:33 +00:00
|
|
|
using namespace ::osl;
|
|
|
|
using namespace ::svx;
|
2000-10-27 10:26:20 +00:00
|
|
|
using namespace ::com::sun::star;
|
2007-09-27 10:31:02 +00:00
|
|
|
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;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
#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);
|
2001-06-06 05:20:21 +00:00
|
|
|
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";
|
2001-06-08 12:47:33 +00:00
|
|
|
const sal_Char cActiveConnection[] = "ActiveConnection";
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2002-08-21 11:23:43 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Use nameless namespace to avoid to rubbish the global namespace
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2004-11-16 15:57:21 +00:00
|
|
|
bool lcl_getCountFromResultSet( sal_Int32& rCount, const uno::Reference<XResultSet>& xResultSet )
|
|
|
|
{
|
|
|
|
uno::Reference<XPropertySet> xPrSet(xResultSet, UNO_QUERY);
|
|
|
|
if(xPrSet.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2007-11-12 15:30:55 +00:00
|
|
|
sal_Bool bFinal = sal_False;
|
2004-11-16 15:57:21 +00:00
|
|
|
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;
|
|
|
|
}
|
2005-10-18 12:49:13 +00:00
|
|
|
// #122799# copy compatibility options
|
|
|
|
void lcl_CopyCompatibilityOptions( SwWrtShell& rSourceShell, SwWrtShell& rTargetShell)
|
|
|
|
{
|
2006-08-14 16:30:22 +00:00
|
|
|
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));
|
2005-10-18 12:49:13 +00:00
|
|
|
}
|
2002-08-21 11:23:43 +00:00
|
|
|
}
|
2002-12-09 12:58:30 +00:00
|
|
|
/* -----------------09.12.2002 12:35-----------------
|
|
|
|
*
|
|
|
|
* --------------------------------------------------*/
|
|
|
|
|
|
|
|
class SwConnectionDisposedListener_Impl : public cppu::WeakImplHelper1
|
2007-09-27 10:31:02 +00:00
|
|
|
< lang::XEventListener >
|
2002-12-09 12:58:30 +00:00
|
|
|
{
|
|
|
|
SwNewDBMgr& rDBMgr;
|
|
|
|
|
|
|
|
virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
|
|
|
|
public:
|
|
|
|
SwConnectionDisposedListener_Impl(SwNewDBMgr& rMgr);
|
|
|
|
~SwConnectionDisposedListener_Impl();
|
2002-08-21 11:23:43 +00:00
|
|
|
|
2002-12-09 12:58:30 +00:00
|
|
|
};
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
struct SwNewDBMgr_Impl
|
|
|
|
{
|
|
|
|
SwDSParam* pMergeData;
|
2004-05-10 15:20:29 +00:00
|
|
|
AbstractMailMergeDlg* pMergeDialog;
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<lang::XEventListener> xDisposeListener;
|
2002-12-09 12:58:30 +00:00
|
|
|
|
|
|
|
SwNewDBMgr_Impl(SwNewDBMgr& rDBMgr)
|
|
|
|
:pMergeData(0)
|
|
|
|
,pMergeDialog(0)
|
|
|
|
,xDisposeListener(new SwConnectionDisposedListener_Impl(rDBMgr))
|
|
|
|
{}
|
|
|
|
};
|
2003-11-25 09:48:37 +00:00
|
|
|
/*-- 24.10.2003 15:54:18---------------------------------------------------
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------*/
|
2004-09-20 12:11:33 +00:00
|
|
|
void lcl_InitNumberFormatter(SwDSParam& rParam, uno::Reference<XDataSource> xSource)
|
2003-11-25 09:48:37 +00:00
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XMultiServiceFactory> xMgr = ::comphelper::getProcessServiceFactory();
|
2003-11-25 09:48:37 +00:00
|
|
|
if( xMgr.is() )
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.util.NumberFormatter" ));
|
|
|
|
rParam.xFormatter = uno::Reference<util::XNumberFormatter>(xInstance, UNO_QUERY) ;
|
2003-11-25 09:48:37 +00:00
|
|
|
}
|
|
|
|
if(!xSource.is())
|
|
|
|
xSource = SwNewDBMgr::getDataSourceAsParent(rParam.xConnection, rParam.sDataSource);
|
|
|
|
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
|
2003-11-25 09:48:37 +00:00
|
|
|
if(xSourceProps.is())
|
|
|
|
{
|
|
|
|
Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
|
|
|
|
if(aFormats.hasValue())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XNumberFormatsSupplier> xSuppl;
|
2003-11-25 09:48:37 +00:00
|
|
|
aFormats >>= xSuppl;
|
|
|
|
if(xSuppl.is())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
|
2003-11-25 09:48:37 +00:00
|
|
|
Any aNull = xSettings->getPropertyValue(C2U("NullDate"));
|
|
|
|
aNull >>= rParam.aNullDate;
|
|
|
|
if(rParam.xFormatter.is())
|
|
|
|
rParam.xFormatter->attachNumberFormatsSupplier(xSuppl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
/* -----------------------------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
|
|
|
|
{
|
2001-03-30 11:05:13 +00:00
|
|
|
DBG_ERROR("no absolute positioning available")
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception aExcept)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
/* -----------------------------17.07.00 17:23--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
BOOL lcl_GetColumnCnt(SwDSParam* pParam,
|
|
|
|
const String& rColumnName, long nLanguage, String& rResult, double* pNumber)
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XColumnsSupplier > xColsSupp( pParam->xResultSet, UNO_QUERY );
|
2005-10-19 07:25:32 +00:00
|
|
|
uno::Reference<XNameAccess> xCols;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xCols = xColsSupp->getColumns();
|
|
|
|
}
|
2007-09-27 10:31:02 +00:00
|
|
|
catch( lang::DisposedException& )
|
2005-10-19 07:25:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
if(!xCols.is() || !xCols->hasByName(rColumnName))
|
2000-09-18 16:15:01 +00:00
|
|
|
return FALSE;
|
|
|
|
Any aCol = xCols->getByName(rColumnName);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XPropertySet > xColumnProps;
|
2001-09-06 12:36:15 +00:00
|
|
|
aCol >>= xColumnProps;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
SwDBFormatData aFormatData;
|
2003-11-25 09:48:37 +00:00
|
|
|
if(!pParam->xFormatter.is())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(
|
2003-11-25 09:48:37 +00:00
|
|
|
pParam->xConnection,pParam->sDataSource);
|
|
|
|
lcl_InitNumberFormatter(*pParam, xSource );
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
aFormatData.aNullDate = pParam->aNullDate;
|
|
|
|
aFormatData.xFormatter = pParam->xFormatter;
|
|
|
|
|
2006-04-07 14:17:54 +00:00
|
|
|
MsLangId::convertLanguageToLocale( (LanguageType)nLanguage, aFormatData.aLocale );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
rResult = SwNewDBMgr::GetDBField( xColumnProps, aFormatData, pNumber);
|
|
|
|
return TRUE;
|
|
|
|
};
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Daten importieren
|
|
|
|
--------------------------------------------------------------------*/
|
2005-01-28 14:47:46 +00:00
|
|
|
BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc )
|
2000-11-13 07:32:00 +00:00
|
|
|
{
|
2005-01-28 14:47:46 +00:00
|
|
|
SetMergeType( rMergeDesc.nMergeType );
|
2000-11-13 07:32:00 +00:00
|
|
|
|
2001-08-30 12:56:46 +00:00
|
|
|
DBG_ASSERT(!bInMerge && !pImpl->pMergeData, "merge already activated!")
|
2000-11-13 07:32:00 +00:00
|
|
|
|
2001-03-30 11:05:13 +00:00
|
|
|
SwDBData aData;
|
|
|
|
aData.nCommandType = CommandType::TABLE;
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XResultSet> xResSet;
|
2001-06-26 13:35:16 +00:00
|
|
|
Sequence<Any> aSelection;
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XConnection> xConnection;
|
2002-08-21 11:23:43 +00:00
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
aData.sDataSource = rMergeDesc.rDescriptor.getDataSource();
|
|
|
|
rMergeDesc.rDescriptor[daCommand] >>= aData.sCommand;
|
|
|
|
rMergeDesc.rDescriptor[daCommandType] >>= aData.nCommandType;
|
2002-08-21 11:23:43 +00:00
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
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;
|
2002-08-21 11:23:43 +00:00
|
|
|
|
2001-03-30 11:05:13 +00:00
|
|
|
if(!aData.sDataSource.getLength() || !aData.sCommand.getLength() || !xResSet.is())
|
2000-11-13 07:32:00 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-08-21 11:23:43 +00:00
|
|
|
|
|
|
|
pImpl->pMergeData = new SwDSParam(aData, xResSet, aSelection);
|
2001-03-30 11:05:13 +00:00
|
|
|
SwDSParam* pTemp = FindDSData(aData, FALSE);
|
|
|
|
if(pTemp)
|
2001-08-30 12:56:46 +00:00
|
|
|
*pTemp = *pImpl->pMergeData;
|
2001-03-30 11:05:13 +00:00
|
|
|
else
|
2001-11-26 14:07:28 +00:00
|
|
|
{
|
|
|
|
//#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;
|
2001-11-30 12:09:09 +00:00
|
|
|
pTemp = FindDSData(aData, FALSE);
|
2001-11-26 14:07:28 +00:00
|
|
|
if(pTemp)
|
|
|
|
*pTemp = *pImpl->pMergeData;
|
|
|
|
else
|
2002-12-09 12:58:30 +00:00
|
|
|
{
|
|
|
|
SwDSParam* pInsert = new SwDSParam(*pImpl->pMergeData);
|
|
|
|
aDataSourceParams.Insert(pInsert, aDataSourceParams.Count());
|
|
|
|
try
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XComponent> xComponent(pInsert->xConnection, UNO_QUERY);
|
2002-12-09 12:58:30 +00:00
|
|
|
if(xComponent.is())
|
|
|
|
xComponent->addEventListener(pImpl->xDisposeListener);
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2001-11-26 14:07:28 +00:00
|
|
|
}
|
2001-08-30 12:56:46 +00:00
|
|
|
if(!pImpl->pMergeData->xConnection.is())
|
|
|
|
pImpl->pMergeData->xConnection = xConnection;
|
2002-12-09 12:58:30 +00:00
|
|
|
// add an XEventListener
|
2001-01-26 14:51:55 +00:00
|
|
|
|
|
|
|
try{
|
|
|
|
//set to start position
|
2001-08-30 12:56:46 +00:00
|
|
|
if(pImpl->pMergeData->aSelection.getLength())
|
2001-01-26 14:51:55 +00:00
|
|
|
{
|
2002-08-21 11:23:43 +00:00
|
|
|
sal_Int32 nPos = 0;
|
|
|
|
pImpl->pMergeData->aSelection.getConstArray()[ pImpl->pMergeData->nSelectionIndex++ ] >>= nPos;
|
|
|
|
pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->absolute( nPos );
|
2001-08-30 12:56:46 +00:00
|
|
|
pImpl->pMergeData->CheckEndOfDB();
|
|
|
|
if(pImpl->pMergeData->nSelectionIndex >= pImpl->pMergeData->aSelection.getLength())
|
|
|
|
pImpl->pMergeData->bEndOfDB = TRUE;
|
2001-01-26 14:51:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->first();
|
|
|
|
pImpl->pMergeData->CheckEndOfDB();
|
2001-01-26 14:51:55 +00:00
|
|
|
}
|
|
|
|
}
|
2001-03-30 11:05:13 +00:00
|
|
|
catch(Exception&)
|
2001-01-26 14:51:55 +00:00
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
pImpl->pMergeData->bEndOfDB = TRUE;
|
|
|
|
pImpl->pMergeData->CheckEndOfDB();
|
2001-01-26 14:51:55 +00:00
|
|
|
DBG_ERROR("exception in MergeNew()")
|
|
|
|
}
|
|
|
|
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,aData.sDataSource);
|
2002-08-21 11:23:43 +00:00
|
|
|
|
2003-11-25 09:48:37 +00:00
|
|
|
lcl_InitNumberFormatter(*pImpl->pMergeData, xSource);
|
2000-11-13 07:32:00 +00:00
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
rMergeDesc.rSh.ChgDBData(aData);
|
2000-11-13 07:32:00 +00:00
|
|
|
bInMerge = TRUE;
|
|
|
|
|
|
|
|
if (IsInitDBFields())
|
|
|
|
{
|
|
|
|
// Bei Datenbankfeldern ohne DB-Name DB-Name von Dok einsetzen
|
|
|
|
SvStringsDtor aDBNames(1, 1);
|
|
|
|
aDBNames.Insert( new String(), 0);
|
2007-09-27 10:31:02 +00:00
|
|
|
SwDBData aInsertData = rMergeDesc.rSh.GetDBData();
|
|
|
|
String sDBName = aInsertData.sDataSource;
|
2001-02-21 11:27:37 +00:00
|
|
|
sDBName += DB_DELIM;
|
2007-09-27 10:31:02 +00:00
|
|
|
sDBName += (String)aInsertData.sCommand;
|
2001-02-21 11:27:37 +00:00
|
|
|
sDBName += DB_DELIM;
|
2007-09-27 10:31:02 +00:00
|
|
|
sDBName += String::CreateFromInt32(aInsertData.nCommandType);
|
2005-01-28 14:47:46 +00:00
|
|
|
rMergeDesc.rSh.ChangeDBFields( aDBNames, sDBName);
|
2000-11-13 07:32:00 +00:00
|
|
|
SetInitDBFields(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL bRet = TRUE;
|
2005-01-28 14:47:46 +00:00
|
|
|
switch(rMergeDesc.nMergeType)
|
2000-11-13 07:32:00 +00:00
|
|
|
{
|
|
|
|
case DBMGR_MERGE:
|
2005-01-28 14:47:46 +00:00
|
|
|
bRet = Merge(&rMergeDesc.rSh); // Mischen
|
2000-11-13 07:32:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DBMGR_MERGE_MAILMERGE: // Serienbrief
|
2002-11-29 11:14:12 +00:00
|
|
|
{
|
2005-01-28 14:47:46 +00:00
|
|
|
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) );
|
2003-03-27 14:45:43 +00:00
|
|
|
|
|
|
|
// !! 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.
|
2005-01-28 14:47:46 +00:00
|
|
|
if(IsMergeSilent())
|
2006-04-27 08:46:29 +00:00
|
|
|
{
|
2005-01-28 14:47:46 +00:00
|
|
|
aPrintArgs.Put( SfxBoolItem(SID_SILENT, TRUE) );
|
2006-04-27 08:46:29 +00:00
|
|
|
// #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 ));
|
|
|
|
}
|
2005-01-28 14:47:46 +00:00
|
|
|
// 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" ))
|
|
|
|
{
|
2007-11-12 15:30:55 +00:00
|
|
|
sal_Int16 nCopies = 0;
|
2005-01-28 14:47:46 +00:00
|
|
|
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" ))
|
|
|
|
{
|
2007-11-12 15:30:55 +00:00
|
|
|
sal_Bool bCollate = sal_False;
|
2005-01-28 14:47:46 +00:00
|
|
|
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" ))
|
|
|
|
{
|
2007-11-12 15:30:55 +00:00
|
|
|
sal_Bool bWait = sal_False;
|
2005-01-28 14:47:46 +00:00
|
|
|
if( pPrintOptions[nOption].Value >>= bWait )
|
|
|
|
aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, !bWait ));
|
|
|
|
}
|
2003-03-27 14:45:43 +00:00
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
}
|
|
|
|
pDis->Execute( SID_PRINTDOC,
|
|
|
|
SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
|
|
|
|
aPrintArgs );
|
2002-11-29 11:14:12 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-11-13 07:32:00 +00:00
|
|
|
|
|
|
|
case DBMGR_MERGE_MAILING:
|
|
|
|
case DBMGR_MERGE_MAILFILES:
|
2007-07-05 06:38:34 +00:00
|
|
|
case DBMGR_MERGE_SINGLE_FILE:
|
2005-01-28 14:47:46 +00:00
|
|
|
// save files and send them as e-Mail if required
|
|
|
|
bRet = MergeMailFiles(&rMergeDesc.rSh,
|
|
|
|
rMergeDesc);
|
2000-11-13 07:32:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: // Einfuegen der selektierten Eintraege
|
|
|
|
// (war: InsertRecord)
|
2005-01-28 14:47:46 +00:00
|
|
|
ImportFromConnection(&rMergeDesc.rSh);
|
2000-11-13 07:32:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
EndMerge();
|
|
|
|
return bRet;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
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 )
|
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
if(pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
pSh->StartAllAction();
|
2007-09-27 10:31:02 +00:00
|
|
|
pSh->StartUndo(UNDO_EMPTY);
|
2000-09-18 16:15:01 +00:00
|
|
|
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);
|
2007-09-27 10:31:02 +00:00
|
|
|
pSh->EndUndo(UNDO_EMPTY);
|
2000-09-18 16:15:01 +00:00
|
|
|
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)
|
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
if(pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
|
|
|
|
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
|
2007-09-27 10:31:02 +00:00
|
|
|
String sFormatStr;
|
2000-09-18 16:15:01 +00:00
|
|
|
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);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XPropertySet > xColumnProp;
|
2001-09-06 12:36:15 +00:00
|
|
|
aCol >>= xColumnProp;
|
2000-09-18 16:15:01 +00:00
|
|
|
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;
|
2001-09-04 11:40:59 +00:00
|
|
|
Sequence<rtl::OUString> aColNames = xCols->getElementNames();
|
|
|
|
const rtl::OUString* pColNames = aColNames.getConstArray();
|
2000-09-18 16:15:01 +00:00
|
|
|
long nLength = aColNames.getLength();
|
|
|
|
for(long i = 0; i < nLength; i++)
|
|
|
|
{
|
|
|
|
Any aCol = xCols->getByName(pColNames[i]);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XPropertySet > xColumnProp;
|
2001-09-06 12:36:15 +00:00
|
|
|
aCol >>= xColumnProp;
|
2000-09-18 16:15:01 +00:00
|
|
|
SwDBFormatData aDBFormat;
|
|
|
|
sStr += GetDBField( xColumnProp, aDBFormat);
|
|
|
|
if (i < nLength - 1)
|
|
|
|
sStr += '\t';
|
|
|
|
}
|
|
|
|
pSh->SwEditShell::Insert(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();
|
2001-08-15 07:20:44 +00:00
|
|
|
SwDSParam* pParam = FindDSConnection(rDBName, FALSE);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XConnection> xConnection;
|
2001-08-15 07:20:44 +00:00
|
|
|
if(pParam && pParam->xConnection.is())
|
|
|
|
xConnection = pParam->xConnection;
|
|
|
|
else
|
2002-10-24 12:48:08 +00:00
|
|
|
{
|
|
|
|
rtl::OUString sDBName(rDBName);
|
|
|
|
xConnection = RegisterConnection( sDBName );
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
if(xConnection.is())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XTablesSupplier> xTSupplier = uno::Reference<XTablesSupplier>(xConnection, UNO_QUERY);
|
2000-09-18 16:15:01 +00:00
|
|
|
if(xTSupplier.is())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XNameAccess> xTbls = xTSupplier->getTables();
|
2001-09-04 11:40:59 +00:00
|
|
|
Sequence<rtl::OUString> aTbls = xTbls->getElementNames();
|
|
|
|
const rtl::OUString* pTbls = aTbls.getConstArray();
|
2000-09-18 16:15:01 +00:00
|
|
|
for(long i = 0; i < aTbls.getLength(); i++)
|
2001-07-20 11:49:57 +00:00
|
|
|
{
|
|
|
|
USHORT nEntry = pListBox->InsertEntry(pTbls[i]);
|
|
|
|
pListBox->SetEntryData(nEntry, (void*)0);
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XQueriesSupplier> xQSupplier = uno::Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
|
2000-09-18 16:15:01 +00:00
|
|
|
if(xQSupplier.is())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XNameAccess> xQueries = xQSupplier->getQueries();
|
2001-09-04 11:40:59 +00:00
|
|
|
Sequence<rtl::OUString> aQueries = xQueries->getElementNames();
|
|
|
|
const rtl::OUString* pQueries = aQueries.getConstArray();
|
2000-09-18 16:15:01 +00:00
|
|
|
for(long i = 0; i < aQueries.getLength(); i++)
|
2001-07-20 11:49:57 +00:00
|
|
|
{
|
2001-07-20 12:00:50 +00:00
|
|
|
USHORT nEntry = pListBox->InsertEntry(pQueries[i]);
|
2001-07-20 11:49:57 +00:00
|
|
|
pListBox->SetEntryData(nEntry, (void*)1);
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
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();
|
2007-07-12 09:49:57 +00:00
|
|
|
SwDBData aData;
|
|
|
|
aData.sDataSource = rDBName;
|
|
|
|
aData.sCommand = rTableName;
|
|
|
|
aData.nCommandType = -1;
|
|
|
|
SwDSParam* pParam = FindDSData(aData, FALSE);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XConnection> xConnection;
|
2001-08-15 07:20:44 +00:00
|
|
|
if(pParam && pParam->xConnection.is())
|
|
|
|
xConnection = pParam->xConnection;
|
|
|
|
else
|
2002-10-24 12:48:08 +00:00
|
|
|
{
|
|
|
|
rtl::OUString sDBName(rDBName);
|
|
|
|
xConnection = RegisterConnection( sDBName );
|
|
|
|
}
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
|
2000-09-18 16:15:01 +00:00
|
|
|
if(xColsSupp.is())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
|
2001-09-04 11:40:59 +00:00
|
|
|
const Sequence<rtl::OUString> aColNames = xCols->getElementNames();
|
|
|
|
const rtl::OUString* pColNames = aColNames.getConstArray();
|
2000-09-18 16:15:01 +00:00
|
|
|
for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
|
|
|
|
{
|
|
|
|
pListBox->InsertEntry(pColNames[nCol]);
|
|
|
|
}
|
2004-11-09 11:56:07 +00:00
|
|
|
::comphelper::disposeComponent( xColsSupp );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
return(TRUE);
|
|
|
|
}
|
2001-06-08 12:47:33 +00:00
|
|
|
/* -----------------------------08.06.01 15:11--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
BOOL SwNewDBMgr::GetColumnNames(ListBox* pListBox,
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XConnection> xConnection,
|
2001-06-08 12:47:33 +00:00
|
|
|
const String& rTableName, BOOL bAppend)
|
|
|
|
{
|
|
|
|
if (!bAppend)
|
|
|
|
pListBox->Clear();
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
|
2001-06-08 12:47:33 +00:00
|
|
|
if(xColsSupp.is())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
|
2001-09-04 11:40:59 +00:00
|
|
|
const Sequence<rtl::OUString> aColNames = xCols->getElementNames();
|
|
|
|
const rtl::OUString* pColNames = aColNames.getConstArray();
|
2001-06-08 12:47:33 +00:00
|
|
|
for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
|
|
|
|
{
|
|
|
|
pListBox->InsertEntry(pColNames[nCol]);
|
|
|
|
}
|
2004-11-09 11:56:07 +00:00
|
|
|
::comphelper::disposeComponent( xColsSupp );
|
2001-06-08 12:47:33 +00:00
|
|
|
}
|
|
|
|
return(TRUE);
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: CTOR
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
SwNewDBMgr::SwNewDBMgr() :
|
2007-09-27 10:31:02 +00:00
|
|
|
nMergeType(DBMGR_INSERT),
|
|
|
|
bInitDBFields(FALSE),
|
2000-09-18 16:15:01 +00:00
|
|
|
bInMerge(FALSE),
|
2003-03-27 14:45:43 +00:00
|
|
|
bMergeSilent(FALSE),
|
2007-09-27 10:31:02 +00:00
|
|
|
bMergeLock(FALSE),
|
|
|
|
pImpl(new SwNewDBMgr_Impl(*this)),
|
|
|
|
pMergeEvtSrc(NULL)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
/* -----------------------------18.07.00 08:56--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
SwNewDBMgr::~SwNewDBMgr()
|
|
|
|
{
|
2001-08-15 07:20:44 +00:00
|
|
|
for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++)
|
|
|
|
{
|
|
|
|
SwDSParam* pParam = aDataSourceParams[nPos];
|
|
|
|
if(pParam->xConnection.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XComponent> xComp(pParam->xConnection, UNO_QUERY);
|
2001-08-15 07:20:44 +00:00
|
|
|
if(xComp.is())
|
|
|
|
xComp->dispose();
|
|
|
|
}
|
2002-08-21 11:23:43 +00:00
|
|
|
catch(const RuntimeException& )
|
2001-08-15 07:20:44 +00:00
|
|
|
{
|
|
|
|
//may be disposed already since multiple entries may have used the same connection
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-30 12:56:46 +00:00
|
|
|
delete pImpl;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Serienbrief drucken
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
BOOL SwNewDBMgr::MergePrint( SwView& rView,
|
2007-01-25 10:44:43 +00:00
|
|
|
SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
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
|
2003-04-17 15:19:08 +00:00
|
|
|
rOpt.nMergeCnt = 0;
|
2006-04-27 08:46:29 +00:00
|
|
|
//#i56195# no field update while printing mail merge documents
|
|
|
|
rOpt.bUpdateFieldsInPrinting = sal_False;
|
2003-04-17 15:19:08 +00:00
|
|
|
if(pImpl->pMergeData)
|
|
|
|
{
|
|
|
|
if(pImpl->pMergeData->aSelection.getLength())
|
|
|
|
rOpt.nMergeCnt = pImpl->pMergeData->aSelection.getLength();
|
|
|
|
else if(pImpl->pMergeData->xResultSet.is())
|
|
|
|
{
|
2004-11-16 15:57:21 +00:00
|
|
|
sal_Int32 nCount;
|
|
|
|
if( lcl_getCountFromResultSet( nCount, pImpl->pMergeData->xResultSet ) )
|
|
|
|
rOpt.nMergeCnt = (ULONG)nCount;
|
2003-04-17 15:19:08 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-03-30 11:05:13 +00:00
|
|
|
SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
|
2002-05-29 13:34:14 +00:00
|
|
|
pModOpt->SetSinglePrintJob(rOpt.IsPrintSingleJobs());
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2006-08-14 16:30:22 +00:00
|
|
|
SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false );
|
2000-09-18 16:15:01 +00:00
|
|
|
Link aSfxSaveLnk = pPrt->GetEndPrintHdl();
|
2002-05-29 13:34:14 +00:00
|
|
|
if( rOpt.IsPrintSingleJobs() )
|
2000-09-18 16:15:01 +00:00
|
|
|
pPrt->SetEndPrintHdl( Link() );
|
|
|
|
|
2007-09-27 10:31:02 +00:00
|
|
|
BOOL bUserBreak = FALSE,
|
2000-09-18 16:15:01 +00:00
|
|
|
bRet = FALSE;
|
2003-04-04 17:15:06 +00:00
|
|
|
long nStartRow, nEndRow;
|
2003-04-17 15:19:08 +00:00
|
|
|
//calculate number of data sets to be printed
|
2003-06-10 08:15:14 +00:00
|
|
|
|
2005-12-21 14:12:34 +00:00
|
|
|
Sequence<PropertyValue> aViewProperties(16);
|
2003-04-17 15:19:08 +00:00
|
|
|
PropertyValue* pViewProperties = aViewProperties.getArray();
|
|
|
|
pViewProperties[0].Name = C2U("MailMergeCount");
|
|
|
|
pViewProperties[0].Value <<= (sal_Int32)rOpt.nMergeCnt;
|
2003-06-10 08:15:14 +00:00
|
|
|
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");
|
2007-09-27 10:31:02 +00:00
|
|
|
pViewProperties[10].Value <<= (text::NotePrintMode) rOpt.GetPrintPostIts();
|
2003-06-10 08:15:14 +00:00
|
|
|
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();
|
2005-12-21 14:12:34 +00:00
|
|
|
pViewProperties[15].Name = C2U("PrintEmptyPages");
|
|
|
|
pViewProperties[15].Value <<= (sal_Bool)rOpt.IsPrintEmptyPages();
|
2003-06-10 08:15:14 +00:00
|
|
|
|
2003-04-17 15:19:08 +00:00
|
|
|
rView.SetAdditionalPrintOptions(aViewProperties);
|
2000-09-18 16:15:01 +00:00
|
|
|
do {
|
2003-04-04 17:15:06 +00:00
|
|
|
nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2005-03-11 09:48:02 +00:00
|
|
|
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, pSh->GetView().GetViewFrame()->GetObjectShell()));
|
2000-09-18 16:15:01 +00:00
|
|
|
pSh->ViewShell::UpdateFlds();
|
2005-03-11 09:48:02 +00:00
|
|
|
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, pSh->GetView().GetViewFrame()->GetObjectShell()));
|
2000-09-18 16:15:01 +00:00
|
|
|
++rOpt.nMergeAct;
|
2003-03-27 14:45:43 +00:00
|
|
|
|
|
|
|
// launch MailMergeEvent if required
|
|
|
|
const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc();
|
|
|
|
if (pEvtSrc)
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc );
|
2003-03-27 14:45:43 +00:00
|
|
|
text::MailMergeEvent aEvt( xRef, rView.GetDocShell()->GetModel() );
|
|
|
|
pEvtSrc->LaunchMailMergeEvent( aEvt );
|
|
|
|
}
|
|
|
|
|
2007-01-25 10:44:43 +00:00
|
|
|
rView.SfxViewShell::Print( rProgress, bIsAPI ); // ggf Basic-Macro ausfuehren
|
2002-05-29 13:34:14 +00:00
|
|
|
if( rOpt.IsPrintSingleJobs() && bRet )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
//rOpt.bJobStartet = FALSE;
|
|
|
|
bRet = FALSE;
|
|
|
|
}
|
|
|
|
|
2003-04-04 17:15:06 +00:00
|
|
|
bMergeLock = TRUE;
|
2002-04-11 10:40:43 +00:00
|
|
|
if(rOpt.IsPrintProspect())
|
|
|
|
{
|
2007-12-12 14:00:19 +00:00
|
|
|
if( ! pPrt->IsJobActive() )
|
|
|
|
{
|
|
|
|
pPrt->SetJobValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ),
|
|
|
|
String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) );
|
|
|
|
pPrt->StartJob( rOpt.GetJobName() );
|
|
|
|
}
|
|
|
|
if( pPrt->IsJobActive() )
|
2002-04-11 10:40:43 +00:00
|
|
|
{
|
2007-04-03 12:48:15 +00:00
|
|
|
pSh->PrintProspect( rOpt, rProgress, rOpt.IsPrintProspect_RTL() );
|
2002-04-11 10:40:43 +00:00
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2005-03-23 11:00:00 +00:00
|
|
|
else if( pSh->Prt( rOpt, &rProgress ) )
|
2000-09-18 16:15:01 +00:00
|
|
|
bRet = TRUE;
|
2003-04-04 17:15:06 +00:00
|
|
|
bMergeLock = FALSE;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if( !pPrt->IsJobActive() )
|
|
|
|
{
|
|
|
|
bUserBreak = TRUE;
|
|
|
|
bRet = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2002-05-29 13:34:14 +00:00
|
|
|
if( !rOpt.IsPrintSingleJobs() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
String& rJNm = (String&)rOpt.GetJobName();
|
|
|
|
rJNm.Erase();
|
|
|
|
}
|
|
|
|
}
|
2003-04-04 17:15:06 +00:00
|
|
|
nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
|
|
|
|
} while( bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord());
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2002-05-29 13:34:14 +00:00
|
|
|
if( rOpt.IsPrintSingleJobs() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2006-08-14 16:30:22 +00:00
|
|
|
SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true );
|
|
|
|
pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk );
|
|
|
|
if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet?
|
|
|
|
aSfxSaveLnk.Call( pTmpPrinter );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2004-09-20 12:11:33 +00:00
|
|
|
/*-- 21.06.2004 09:08:16---------------------------------------------------
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------*/
|
|
|
|
BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView,
|
2007-01-25 10:44:43 +00:00
|
|
|
SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI )
|
2004-09-20 12:11:33 +00:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
|
2006-08-14 16:30:22 +00:00
|
|
|
SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false );
|
2004-09-20 12:11:33 +00:00
|
|
|
Link aSfxSaveLnk = pPrt->GetEndPrintHdl();
|
|
|
|
if( rOpt.IsPrintSingleJobs() )
|
|
|
|
pPrt->SetEndPrintHdl( Link() );
|
|
|
|
|
2007-09-27 10:31:02 +00:00
|
|
|
BOOL bUserBreak = FALSE,
|
2004-09-20 12:11:33 +00:00
|
|
|
bRet = FALSE;
|
|
|
|
//calculate number of data sets to be printed
|
|
|
|
|
2005-12-21 14:12:34 +00:00
|
|
|
Sequence<PropertyValue> aViewProperties(16);
|
2004-09-20 12:11:33 +00:00
|
|
|
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");
|
2007-09-27 10:31:02 +00:00
|
|
|
pViewProperties[10].Value <<= (text::NotePrintMode) rOpt.GetPrintPostIts();
|
2004-09-20 12:11:33 +00:00
|
|
|
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();
|
2005-12-21 14:12:34 +00:00
|
|
|
pViewProperties[15].Name = C2U("PrintEmptyPages");
|
|
|
|
pViewProperties[15].Value <<= (sal_Bool)rOpt.IsPrintEmptyPages();
|
2004-09-20 12:11:33 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2005-04-27 08:22:51 +00:00
|
|
|
String aTmp;
|
|
|
|
aTmp += String::CreateFromInt32( rDocInfo.nStartPageInTarget );
|
|
|
|
aTmp += '-';
|
|
|
|
aTmp += String::CreateFromInt32( rDocInfo.nEndPageInTarget );
|
|
|
|
|
2007-09-27 10:31:02 +00:00
|
|
|
Sequence<PropertyValue> aAddViewProperties(1);
|
|
|
|
PropertyValue* pAddViewProperties = aAddViewProperties.getArray();
|
|
|
|
pAddViewProperties[0].Name = C2U("Pages");
|
|
|
|
pAddViewProperties[0].Value <<= ::rtl::OUString( aTmp );
|
|
|
|
rView.SetAdditionalPrintOptions(aAddViewProperties);
|
2005-04-27 08:22:51 +00:00
|
|
|
|
2007-01-25 10:44:43 +00:00
|
|
|
rView.SfxViewShell::Print( rProgress, bIsAPI ); // ggf Basic-Macro ausfuehren
|
2004-09-20 12:11:33 +00:00
|
|
|
if( rOpt.IsPrintSingleJobs() && bRet )
|
|
|
|
{
|
|
|
|
//rOpt.bJobStartet = FALSE;
|
|
|
|
bRet = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bMergeLock = TRUE;
|
|
|
|
if(rOpt.IsPrintProspect())
|
|
|
|
{
|
|
|
|
if( pPrt->IsJobActive() || pPrt->StartJob( rOpt.GetJobName() ))
|
|
|
|
{
|
2007-04-03 12:48:15 +00:00
|
|
|
pSh->PrintProspect( rOpt, rProgress, rOpt.IsPrintProspect_RTL() );
|
2004-09-20 12:11:33 +00:00
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2005-03-23 11:00:00 +00:00
|
|
|
else if( pSh->Prt( rOpt, &rProgress ) )
|
2004-09-20 12:11:33 +00:00
|
|
|
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() )
|
|
|
|
{
|
2006-08-14 16:30:22 +00:00
|
|
|
SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true );
|
|
|
|
pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk );
|
|
|
|
if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet?
|
|
|
|
aSfxSaveLnk.Call( pTmpPrinter );
|
2004-09-20 12:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
/*--------------------------------------------------------------------
|
2005-01-28 14:47:46 +00:00
|
|
|
Beschreibung: Serienbriefe als einzelne Dokumente speichern
|
2000-09-18 16:15:01 +00:00
|
|
|
--------------------------------------------------------------------*/
|
2007-04-04 14:17:58 +00:00
|
|
|
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,
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
|
|
|
|
const SwMergeDescriptor& rMergeDescriptor)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
//check if the doc is synchronized and contains at least one linked section
|
2005-01-28 14:47:46 +00:00
|
|
|
BOOL bSynchronizedDoc = pSourceShell->IsLabelDoc() && pSourceShell->GetSectionFmtCount() > 1;
|
2000-09-18 16:15:01 +00:00
|
|
|
BOOL bLoop = TRUE;
|
2005-01-28 14:47:46 +00:00
|
|
|
BOOL bEMail = rMergeDescriptor.nMergeType == DBMGR_MERGE_MAILING;
|
2007-07-05 06:38:34 +00:00
|
|
|
const bool bAsSingleFile = rMergeDescriptor.nMergeType == DBMGR_MERGE_SINGLE_FILE;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
::rtl::Reference< MailDispatcher > xMailDispatcher;
|
|
|
|
::rtl::OUString sBodyMimeType;
|
|
|
|
rtl_TextEncoding eEncoding = ::gsl_getSystemTextEncoding();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
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();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2005-01-28 14:47:46 +00:00
|
|
|
else
|
|
|
|
sBodyMimeType =
|
|
|
|
::rtl::OUString::createFromAscii("text/plain; charset=UTF-8; format=flowed");
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XPropertySet > xColumnProp;
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
BOOL bColumnName = sEMailAddrFld.Len() > 0;
|
|
|
|
|
|
|
|
if (bColumnName)
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
|
|
|
|
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
|
2000-09-18 16:15:01 +00:00
|
|
|
if(!xCols->hasByName(sEMailAddrFld))
|
|
|
|
return FALSE;
|
|
|
|
Any aCol = xCols->getByName(sEMailAddrFld);
|
2001-09-06 12:36:15 +00:00
|
|
|
aCol >>= xColumnProp;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
SfxDispatcher* pSfxDispatcher = pSourceShell->GetView().GetViewFrame()->GetDispatcher();
|
2007-09-27 10:31:02 +00:00
|
|
|
SwDocShell* pSourrceDocSh = pSourceShell->GetView().GetDocShell();
|
|
|
|
pSfxDispatcher->Execute( pSourrceDocSh->HasName() ? SID_SAVEDOC : SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD);
|
2005-01-28 14:47:46 +00:00
|
|
|
// has document been saved successfully?
|
2007-09-27 10:31:02 +00:00
|
|
|
if( !pSourrceDocSh->IsModified() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2005-01-28 14:47:46 +00:00
|
|
|
SfxMedium* pOrig = pSourceShell->GetView().GetDocShell()->GetMedium();
|
|
|
|
String sSourceDocumentURL(pOrig->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ));
|
2000-09-18 16:15:01 +00:00
|
|
|
const SfxFilter* pSfxFlt = SwIoSystem::GetFileFilter(
|
2005-01-28 14:47:46 +00:00
|
|
|
sSourceDocumentURL, ::aEmptyStr );
|
|
|
|
const SfxFilter* pStoreToFilter = pSfxFlt;
|
|
|
|
SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
|
2005-03-08 12:55:46 +00:00
|
|
|
const String* pStoreToFilterOptions = 0;
|
2005-01-28 14:47:46 +00:00
|
|
|
// 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)
|
2005-03-08 12:55:46 +00:00
|
|
|
{
|
2005-01-28 14:47:46 +00:00
|
|
|
pStoreToFilter = pFilter;
|
2005-03-08 12:55:46 +00:00
|
|
|
if(rMergeDescriptor.sSaveToFilterOptions.Len())
|
|
|
|
pStoreToFilterOptions = &rMergeDescriptor.sSaveToFilterOptions;
|
|
|
|
}
|
2005-01-28 14:47:46 +00:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
String sAddress;
|
|
|
|
bCancel = FALSE;
|
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
// 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;
|
2007-04-04 14:17:58 +00:00
|
|
|
String sModifiedStartingPageDesc;
|
2005-01-28 14:47:46 +00:00
|
|
|
String sStartingPageDesc;
|
|
|
|
USHORT nStartingPageNo = 0;
|
2007-04-04 14:17:58 +00:00
|
|
|
bool bPageStylesWithHeaderFooter = false;
|
2007-07-05 06:38:34 +00:00
|
|
|
if(bAsSingleFile || rMergeDescriptor.bCreateSingleFile)
|
2005-01-28 14:47:46 +00:00
|
|
|
{
|
|
|
|
// create a target docshell to put the merged document into
|
|
|
|
xTargetDocShell = new SwDocShell( SFX_CREATE_MODE_STANDARD );
|
|
|
|
xTargetDocShell->DoInitNew( 0 );
|
2006-05-02 14:20:53 +00:00
|
|
|
SfxViewFrame* pTargetFrame = SfxViewFrame::CreateViewFrame( *xTargetDocShell, 0, TRUE );
|
2005-01-28 14:47:46 +00:00
|
|
|
|
|
|
|
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
|
2007-09-27 10:31:02 +00:00
|
|
|
pSourceShell->SttEndDoc(TRUE);
|
2005-01-28 14:47:46 +00:00
|
|
|
nStartingPageNo = pSourceShell->GetVirtPageNum();
|
2007-04-04 14:17:58 +00:00
|
|
|
sStartingPageDesc = sModifiedStartingPageDesc = pSourceShell->GetPageDesc(
|
2005-01-28 14:47:46 +00:00
|
|
|
pSourceShell->GetCurPageDesc()).GetName();
|
2005-10-18 12:49:13 +00:00
|
|
|
// #122799# copy compatibility options
|
|
|
|
lcl_CopyCompatibilityOptions( *pSourceShell, *pTargetShell);
|
2007-04-04 14:17:58 +00:00
|
|
|
// #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();
|
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PrintMonitor aPrtMonDlg(&pSourceShell->GetView().GetEditWin());
|
|
|
|
aPrtMonDlg.aDocName.SetText(pSourceShell->GetView().GetDocShell()->GetTitle(22));
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
aPrtMonDlg.aCancel.SetClickHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
|
2003-03-27 14:45:43 +00:00
|
|
|
if (!IsMergeSilent())
|
|
|
|
aPrtMonDlg.Show();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
// Progress, um KeyInputs zu unterbinden
|
2007-09-27 10:31:02 +00:00
|
|
|
SfxProgress aProgress(pSourrceDocSh, ::aEmptyStr, 1);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
// Alle Dispatcher sperren
|
2007-09-27 10:31:02 +00:00
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst(pSourrceDocSh);
|
2000-09-18 16:15:01 +00:00
|
|
|
while (pViewFrm)
|
|
|
|
{
|
|
|
|
pViewFrm->GetDispatcher()->Lock(TRUE);
|
2007-09-27 10:31:02 +00:00
|
|
|
pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourrceDocSh);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
ULONG nDocNo = 1;
|
|
|
|
ULONG nCounter = 0;
|
|
|
|
|
2003-04-04 17:15:06 +00:00
|
|
|
long nStartRow, nEndRow;
|
2005-01-28 14:47:46 +00:00
|
|
|
// collect temporary files
|
|
|
|
::std::vector< String> aFilesToRemove;
|
2003-04-04 17:15:06 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
String sPath(sSubject);
|
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
if( !bEMail && bColumnName )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
SwDBFormatData aDBFormat;
|
2003-11-25 09:48:37 +00:00
|
|
|
aDBFormat.xFormatter = pImpl->pMergeData->xFormatter;
|
|
|
|
aDBFormat.aNullDate = pImpl->pMergeData->aNullDate;
|
2000-09-18 16:15:01 +00:00
|
|
|
sAddress = GetDBField( xColumnProp, aDBFormat);
|
|
|
|
if (!sAddress.Len())
|
|
|
|
sAddress = '_';
|
|
|
|
sPath += sAddress;
|
|
|
|
nCounter = 0;
|
|
|
|
}
|
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
// create a new temporary file name - only done once in case of bCreateSingleFile
|
2007-07-05 06:38:34 +00:00
|
|
|
if( 1 == nDocNo || (!rMergeDescriptor.bCreateSingleFile && !bAsSingleFile) )
|
2005-01-28 14:47:46 +00:00
|
|
|
{
|
|
|
|
INetURLObject aEntry(sPath);
|
|
|
|
String 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 ));
|
2007-07-05 06:38:34 +00:00
|
|
|
if( bAsSingleFile )
|
|
|
|
aTempFile->EnableKillingFile();
|
2005-01-28 14:47:46 +00:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
if( !aTempFile->IsValid() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
ErrorHandler::HandleError( ERRCODE_IO_NOTSUPPORTED );
|
|
|
|
bLoop = FALSE;
|
|
|
|
bCancel = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-28 14:47:46 +00:00
|
|
|
INetURLObject aTempFileURL(aTempFile->GetURL());
|
|
|
|
aPrtMonDlg.aPrinter.SetText( aTempFileURL.GetBase() );
|
2000-09-18 16:15:01 +00:00
|
|
|
String sStat(SW_RES(STR_STATSTR_LETTER)); // Brief
|
|
|
|
sStat += ' ';
|
2005-01-28 14:47:46 +00:00
|
|
|
sStat += String::CreateFromInt32( nDocNo );
|
2000-09-18 16:15:01 +00:00
|
|
|
aPrtMonDlg.aPrintInfo.SetText(sStat);
|
|
|
|
|
|
|
|
// Rechenzeit fuer Save-Monitor:
|
|
|
|
for (USHORT i = 0; i < 10; i++)
|
|
|
|
Application::Reschedule();
|
|
|
|
|
|
|
|
// Neues Dokument erzeugen und speichern
|
2005-01-28 14:47:46 +00:00
|
|
|
SfxObjectShellRef xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL ));
|
|
|
|
SfxMedium* pWorkMed = new SfxMedium( sSourceDocumentURL, STREAM_STD_READ, TRUE );
|
|
|
|
pWorkMed->SetFilter( pSfxFlt );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
if (xWorkDocSh->DoLoad(pWorkMed))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2003-04-04 17:15:06 +00:00
|
|
|
//create a view frame for the document
|
2006-05-02 14:20:53 +00:00
|
|
|
SfxViewFrame* pWorkFrame = SfxViewFrame::CreateViewFrame( *xWorkDocSh, 0, TRUE );
|
2003-04-04 17:15:06 +00:00
|
|
|
//request the layout calculation
|
2005-01-28 14:47:46 +00:00
|
|
|
SwWrtShell& rWorkShell =
|
|
|
|
static_cast< SwView* >(pWorkFrame->GetViewShell())->GetWrtShell();
|
|
|
|
rWorkShell.CalcLayout();
|
|
|
|
SwDoc* pWorkDoc = ((SwDocShell*)(&xWorkDocSh))->GetDoc();
|
|
|
|
SwNewDBMgr* pOldDBMgr = pWorkDoc->GetNewDBMgr();
|
|
|
|
pWorkDoc->SetNewDBMgr( this );
|
2005-03-11 09:48:02 +00:00
|
|
|
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, xWorkDocSh));
|
2006-08-14 16:30:22 +00:00
|
|
|
pWorkDoc->UpdateFlds(NULL, false);
|
2005-03-11 09:48:02 +00:00
|
|
|
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, xWorkDocSh));
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
// alle versteckten Felder/Bereiche entfernen
|
2005-01-28 14:47:46 +00:00
|
|
|
pWorkDoc->RemoveInvisibleContent();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
// launch MailMergeEvent if required
|
|
|
|
const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc();
|
2005-01-28 14:47:46 +00:00
|
|
|
if(pEvtSrc)
|
2003-03-27 14:45:43 +00:00
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc );
|
2005-01-28 14:47:46 +00:00
|
|
|
text::MailMergeEvent aEvt( xRef, xWorkDocSh->GetModel() );
|
2003-03-27 14:45:43 +00:00
|
|
|
pEvtSrc->LaunchMailMergeEvent( aEvt );
|
|
|
|
}
|
|
|
|
|
2007-07-05 06:38:34 +00:00
|
|
|
if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile )
|
2005-01-28 14:47:46 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( pTargetShell, "no target shell available!" )
|
|
|
|
// copy created file into the target document
|
|
|
|
rWorkShell.ConvertFieldsToText();
|
2005-11-04 15:01:40 +00:00
|
|
|
rWorkShell.SetNumberingRestart();
|
2005-01-28 14:47:46 +00:00
|
|
|
|
|
|
|
// insert the document into the target document
|
2007-09-27 10:31:02 +00:00
|
|
|
rWorkShell.SttEndDoc(FALSE);
|
|
|
|
rWorkShell.SttEndDoc(TRUE);
|
2005-01-28 14:47:46 +00:00
|
|
|
rWorkShell.SelAll();
|
2007-09-27 10:31:02 +00:00
|
|
|
pTargetShell->SwCrsrShell::SttEndDoc( FALSE );
|
2007-04-04 14:17:58 +00:00
|
|
|
//#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;
|
2007-09-27 10:31:02 +00:00
|
|
|
lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo );
|
2007-04-04 14:17:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
if(nDocNo > 1)
|
2007-04-04 14:17:58 +00:00
|
|
|
pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
|
2005-01-28 14:47:46 +00:00
|
|
|
else
|
2007-04-04 14:17:58 +00:00
|
|
|
pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
|
2005-01-28 14:47:46 +00:00
|
|
|
DBG_ASSERT(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended")
|
2005-10-19 07:25:32 +00:00
|
|
|
//#i51359# add a second paragraph in case there's only one
|
|
|
|
{
|
|
|
|
SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
|
2007-04-04 14:17:58 +00:00
|
|
|
SwPosition aTestPos( aIdx );
|
2007-11-22 14:39:40 +00:00
|
|
|
SwCursor aTestCrsr(aTestPos,0,false);
|
2005-10-19 07:25:32 +00:00
|
|
|
if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
|
|
|
|
{
|
|
|
|
//append a paragraph
|
|
|
|
pWorkDoc->AppendTxtNode( aTestPos );
|
|
|
|
}
|
|
|
|
}
|
2005-01-28 14:47:46 +00:00
|
|
|
pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
|
2007-04-04 14:17:58 +00:00
|
|
|
|
2005-11-10 14:57:22 +00:00
|
|
|
//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();
|
|
|
|
}
|
2005-01-28 14:47:46 +00:00
|
|
|
}
|
|
|
|
else
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2005-01-28 14:47:46 +00:00
|
|
|
String sFileURL = aTempFileURL.GetMainURL( INetURLObject::NO_DECODE );
|
|
|
|
SfxMedium* pDstMed = new SfxMedium(
|
|
|
|
sFileURL,
|
|
|
|
STREAM_STD_READWRITE, TRUE );
|
|
|
|
pDstMed->SetFilter( pStoreToFilter );
|
2005-03-08 12:55:46 +00:00
|
|
|
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)));
|
|
|
|
}
|
2005-01-28 14:47:46 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2005-01-28 14:47:46 +00:00
|
|
|
pWorkDoc->SetNewDBMgr( pOldDBMgr );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2005-01-28 14:47:46 +00:00
|
|
|
xWorkDocSh->DoClose();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-28 14:47:46 +00:00
|
|
|
nDocNo++;
|
2003-04-04 17:15:06 +00:00
|
|
|
nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
|
|
|
|
} while( !bCancel &&
|
|
|
|
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
|
2005-01-28 14:47:46 +00:00
|
|
|
// save the single output document
|
2007-07-05 06:38:34 +00:00
|
|
|
if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile)
|
2005-01-28 14:47:46 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( aTempFile.get(), "Temporary file not available" )
|
2007-07-05 06:38:34 +00:00
|
|
|
INetURLObject aTempFileURL(bAsSingleFile ? sSubject : aTempFile->GetURL());
|
2005-01-28 14:47:46 +00:00
|
|
|
SfxMedium* pDstMed = new SfxMedium(
|
|
|
|
aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ),
|
|
|
|
STREAM_STD_READWRITE, TRUE );
|
|
|
|
pDstMed->SetFilter( pStoreToFilter );
|
2005-03-08 12:55:46 +00:00
|
|
|
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)));
|
|
|
|
}
|
2005-01-28 14:47:46 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
// Alle Dispatcher freigeben
|
2007-09-27 10:31:02 +00:00
|
|
|
pViewFrm = SfxViewFrame::GetFirst(pSourrceDocSh);
|
2000-09-18 16:15:01 +00:00
|
|
|
while (pViewFrm)
|
|
|
|
{
|
|
|
|
pViewFrm->GetDispatcher()->Lock(FALSE);
|
2007-09-27 10:31:02 +00:00
|
|
|
pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourrceDocSh);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
SW_MOD()->SetView(&pSourceShell->GetView());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nMergeType = DBMGR_INSERT;
|
|
|
|
}
|
|
|
|
|
2005-01-28 14:47:46 +00:00
|
|
|
if(bEMail)
|
|
|
|
{
|
|
|
|
xMailDispatcher->stop();
|
|
|
|
xMailDispatcher->shutdown();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
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)
|
2001-06-08 12:47:33 +00:00
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XDataSource> xSource;
|
|
|
|
uno::Reference< XConnection> xConnection;
|
2001-06-08 12:47:33 +00:00
|
|
|
sal_Bool bUseMergeData = sal_False;
|
2005-10-19 07:25:32 +00:00
|
|
|
uno::Reference< XColumnsSupplier> xColsSupp;
|
2001-08-30 12:56:46 +00:00
|
|
|
if(pImpl->pMergeData &&
|
|
|
|
pImpl->pMergeData->sDataSource.equals(rDBName) && pImpl->pMergeData->sCommand.equals(rTableName))
|
2001-06-08 12:47:33 +00:00
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
xConnection = pImpl->pMergeData->xConnection;
|
2007-09-27 10:31:02 +00:00
|
|
|
xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,rDBName);
|
2001-06-08 12:47:33 +00:00
|
|
|
bUseMergeData = sal_True;
|
2005-10-19 07:25:32 +00:00
|
|
|
xColsSupp = xColsSupp.query( pImpl->pMergeData->xResultSet );
|
2001-06-08 12:47:33 +00:00
|
|
|
}
|
2005-10-19 07:25:32 +00:00
|
|
|
if(!xConnection.is())
|
2001-06-08 12:47:33 +00:00
|
|
|
{
|
2007-07-12 09:49:57 +00:00
|
|
|
SwDBData aData;
|
|
|
|
aData.sDataSource = rDBName;
|
|
|
|
aData.sCommand = rTableName;
|
|
|
|
aData.nCommandType = -1;
|
|
|
|
SwDSParam* pParam = FindDSData(aData, FALSE);
|
2001-08-15 07:20:44 +00:00
|
|
|
if(pParam && pParam->xConnection.is())
|
2005-10-19 07:25:32 +00:00
|
|
|
{
|
2001-08-15 07:20:44 +00:00
|
|
|
xConnection = pParam->xConnection;
|
2005-10-19 07:25:32 +00:00
|
|
|
xColsSupp = xColsSupp.query( pParam->xResultSet );
|
|
|
|
}
|
2001-08-15 07:20:44 +00:00
|
|
|
else
|
2002-10-24 12:48:08 +00:00
|
|
|
{
|
|
|
|
rtl::OUString sDBName(rDBName);
|
|
|
|
xConnection = RegisterConnection( sDBName );
|
|
|
|
}
|
2001-06-08 12:47:33 +00:00
|
|
|
if(bUseMergeData)
|
2001-08-30 12:56:46 +00:00
|
|
|
pImpl->pMergeData->xConnection = xConnection;
|
2001-06-08 12:47:33 +00:00
|
|
|
}
|
2005-10-19 07:25:32 +00:00
|
|
|
bool bDispose = !xColsSupp.is();
|
|
|
|
if(bDispose)
|
|
|
|
{
|
|
|
|
xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
|
|
|
|
}
|
2001-06-08 12:47:33 +00:00
|
|
|
if(xColsSupp.is())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XNameAccess> xCols;
|
2001-07-18 12:25:54 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
xCols = xColsSupp->getColumns();
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("Exception in getColumns()")
|
|
|
|
}
|
2001-07-20 09:07:05 +00:00
|
|
|
if(!xCols.is() || !xCols->hasByName(rColNm))
|
2001-06-08 12:47:33 +00:00
|
|
|
return nRet;
|
|
|
|
Any aCol = xCols->getByName(rColNm);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XPropertySet > xColumn;
|
2001-06-08 12:47:33 +00:00
|
|
|
aCol >>= xColumn;
|
|
|
|
nRet = GetColumnFmt(xSource, xConnection, xColumn, pNFmtr, nLanguage);
|
2005-10-19 07:25:32 +00:00
|
|
|
if(bDispose)
|
|
|
|
{
|
|
|
|
::comphelper::disposeComponent( xColsSupp );
|
|
|
|
}
|
2001-06-08 12:47:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
nRet = pNFmtr->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM );
|
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
/* -----------------------------07.06.01 15:43--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2004-09-20 12:11:33 +00:00
|
|
|
ULONG SwNewDBMgr::GetColumnFmt( uno::Reference< XDataSource> xSource,
|
|
|
|
uno::Reference< XConnection> xConnection,
|
|
|
|
uno::Reference< XPropertySet> xColumn,
|
2001-06-08 12:47:33 +00:00
|
|
|
SvNumberFormatter* pNFmtr,
|
|
|
|
long nLanguage )
|
|
|
|
{
|
|
|
|
//JP 12.01.99: ggfs. das NumberFormat im Doc setzen
|
|
|
|
ULONG nRet = 0;
|
|
|
|
|
|
|
|
if(!xSource.is())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XChild> xChild(xConnection, UNO_QUERY);
|
|
|
|
xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
|
2001-06-08 12:47:33 +00:00
|
|
|
}
|
|
|
|
if(xSource.is() && xConnection.is() && xColumn.is() && pNFmtr)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj( pNFmtr );
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< util::XNumberFormatsSupplier > xDocNumFmtsSupplier = pNumFmt;
|
|
|
|
uno::Reference< XNumberFormats > xDocNumberFormats = xDocNumFmtsSupplier->getNumberFormats();
|
|
|
|
uno::Reference< XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2006-04-07 14:17:54 +00:00
|
|
|
Locale aLocale( MsLangId::convertLanguageToLocale( (LanguageType)nLanguage ));
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
//get the number formatter of the data source
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
|
|
|
|
uno::Reference< XNumberFormats > xNumberFormats;
|
2000-09-18 16:15:01 +00:00
|
|
|
if(xSourceProps.is())
|
|
|
|
{
|
|
|
|
Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
|
|
|
|
if(aFormats.hasValue())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XNumberFormatsSupplier> xSuppl;
|
2001-09-06 12:36:15 +00:00
|
|
|
aFormats >>= xSuppl;
|
2000-09-18 16:15:01 +00:00
|
|
|
if(xSuppl.is())
|
|
|
|
{
|
|
|
|
xNumberFormats = xSuppl->getNumberFormats();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-07-19 08:39:02 +00:00
|
|
|
bool bUseDefault = true;
|
|
|
|
try
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2007-09-27 10:31:02 +00:00
|
|
|
Any aFormatKey = xColumn->getPropertyValue(C2U("FormatKey"));
|
|
|
|
if(aFormatKey.hasValue())
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2007-11-12 15:30:55 +00:00
|
|
|
sal_Int32 nFmt = 0;
|
2007-09-27 10:31:02 +00:00
|
|
|
aFormatKey >>= nFmt;
|
2006-07-19 08:39:02 +00:00
|
|
|
if(xNumberFormats.is())
|
2001-06-08 12:47:33 +00:00
|
|
|
{
|
2006-07-19 08:39:02 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<XPropertySet> xNumProps = xNumberFormats->getByKey( nFmt );
|
2007-09-27 10:31:02 +00:00
|
|
|
Any aFormatString = xNumProps->getPropertyValue(C2U("FormatString"));
|
|
|
|
Any aLocaleVal = xNumProps->getPropertyValue(C2U("Locale"));
|
2006-07-19 08:39:02 +00:00
|
|
|
rtl::OUString sFormat;
|
2007-09-27 10:31:02 +00:00
|
|
|
aFormatString >>= sFormat;
|
|
|
|
lang::Locale aLoc;
|
|
|
|
aLocaleVal >>= aLoc;
|
2006-07-19 08:39:02 +00:00
|
|
|
nFmt = xDocNumberFormats->queryKey( sFormat, aLoc, sal_False );
|
2007-09-27 10:31:02 +00:00
|
|
|
if(NUMBERFORMAT_ENTRY_NOT_FOUND == sal::static_int_cast< sal_uInt32, sal_Int32>(nFmt))
|
2006-07-19 08:39:02 +00:00
|
|
|
nFmt = xDocNumberFormats->addNew( sFormat, aLoc );
|
|
|
|
nRet = nFmt;
|
|
|
|
bUseDefault = false;
|
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("illegal number format key")
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-07-19 08:39:02 +00:00
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_ERROR("no FormatKey property found")
|
|
|
|
}
|
|
|
|
if(bUseDefault)
|
2002-08-21 11:23:43 +00:00
|
|
|
nRet = SwNewDBMgr::GetDbtoolsClient().getDefaultNumberFormat(xColumn, xDocNumberFormatTypes, aLocale);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
2001-06-08 12:47:33 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
/* -----------------------------17.07.00 09:47--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
sal_Int32 SwNewDBMgr::GetColumnType( const String& rDBName,
|
|
|
|
const String& rTableName,
|
|
|
|
const String& rColNm )
|
|
|
|
{
|
|
|
|
sal_Int32 nRet = DataType::SQLNULL;
|
2007-07-12 09:49:57 +00:00
|
|
|
SwDBData aData;
|
|
|
|
aData.sDataSource = rDBName;
|
|
|
|
aData.sCommand = rTableName;
|
|
|
|
aData.nCommandType = -1;
|
|
|
|
SwDSParam* pParam = FindDSData(aData, FALSE);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XConnection> xConnection;
|
2007-07-12 09:49:57 +00:00
|
|
|
uno::Reference< XColumnsSupplier > xColsSupp;
|
|
|
|
bool bDispose = false;
|
2001-08-15 07:20:44 +00:00
|
|
|
if(pParam && pParam->xConnection.is())
|
2007-07-12 09:49:57 +00:00
|
|
|
{
|
2001-08-15 07:20:44 +00:00
|
|
|
xConnection = pParam->xConnection;
|
2007-07-12 09:49:57 +00:00
|
|
|
xColsSupp = uno::Reference< XColumnsSupplier >( pParam->xResultSet, UNO_QUERY );
|
|
|
|
}
|
2001-08-15 07:20:44 +00:00
|
|
|
else
|
2002-10-24 12:48:08 +00:00
|
|
|
{
|
|
|
|
rtl::OUString sDBName(rDBName);
|
|
|
|
xConnection = RegisterConnection( sDBName );
|
|
|
|
}
|
2007-07-12 09:49:57 +00:00
|
|
|
if( !xColsSupp.is() )
|
|
|
|
{
|
|
|
|
xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
|
|
|
|
bDispose = true;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
if(xColsSupp.is())
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
|
2000-09-18 16:15:01 +00:00
|
|
|
if(xCols->hasByName(rColNm))
|
|
|
|
{
|
|
|
|
Any aCol = xCols->getByName(rColNm);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XPropertySet> xCol;
|
2001-09-06 12:36:15 +00:00
|
|
|
aCol >>= xCol;
|
2000-09-18 16:15:01 +00:00
|
|
|
Any aType = xCol->getPropertyValue(C2S("Type"));
|
|
|
|
aType >>= nRet;
|
|
|
|
}
|
2007-07-12 09:49:57 +00:00
|
|
|
if(bDispose)
|
|
|
|
::comphelper::disposeComponent( xColsSupp );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -----------------------------03.07.00 17:12--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< sdbc::XConnection> SwNewDBMgr::GetConnection(const String& rDataSource,
|
|
|
|
uno::Reference<XDataSource>& rxSource)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
Reference< sdbc::XConnection> xConnection;
|
2000-10-20 13:18:07 +00:00
|
|
|
Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
|
2004-08-02 13:20:28 +00:00
|
|
|
try
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-08-02 13:20:28 +00:00
|
|
|
Reference<XCompletedConnection> xComplConnection(SwNewDBMgr::GetDbtoolsClient().getDataSource(rDataSource, xMgr),UNO_QUERY);
|
|
|
|
if ( xComplConnection.is() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-08-02 13:20:28 +00:00
|
|
|
rxSource.set(xComplConnection,UNO_QUERY);
|
|
|
|
Reference< XInteractionHandler > xHandler(
|
2000-12-01 10:45:55 +00:00
|
|
|
xMgr->createInstance( C2U( "com.sun.star.sdb.InteractionHandler" )), UNO_QUERY);
|
|
|
|
xConnection = xComplConnection->connectWithCompletion( xHandler );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-02 13:20:28 +00:00
|
|
|
catch(Exception&) {}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
return xConnection;
|
|
|
|
}
|
|
|
|
/* -----------------------------03.07.00 17:12--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< sdbcx::XColumnsSupplier> SwNewDBMgr::GetColumnSupplier(uno::Reference<sdbc::XConnection> xConnection,
|
2000-09-18 16:15:01 +00:00
|
|
|
const String& rTableOrQuery,
|
|
|
|
BYTE eTableOrQuery)
|
|
|
|
{
|
2004-11-09 11:56:07 +00:00
|
|
|
Reference< sdbcx::XColumnsSupplier> xRet;
|
|
|
|
try
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-11-09 11:56:07 +00:00
|
|
|
if(eTableOrQuery == SW_DB_SELECT_UNKNOWN)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-11-09 11:56:07 +00:00
|
|
|
//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;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2004-11-09 11:56:07 +00:00
|
|
|
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())
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-11-09 11:56:07 +00:00
|
|
|
xSourceProperties->getPropertyValue(C2U("Name")) >>= sDataSource;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2004-11-09 11:56:07 +00:00
|
|
|
|
|
|
|
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 );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2007-09-27 10:31:02 +00:00
|
|
|
catch( const uno::Exception& )
|
2004-11-09 11:56:07 +00:00
|
|
|
{
|
|
|
|
DBG_ERROR("Exception in SwDBMgr::GetColumnSupplier")
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
return xRet;
|
|
|
|
}
|
|
|
|
/* -----------------------------05.07.00 13:44--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2004-09-20 12:11:33 +00:00
|
|
|
String SwNewDBMgr::GetDBField(uno::Reference<XPropertySet> xColumnProps,
|
2000-09-18 16:15:01 +00:00
|
|
|
const SwDBFormatData& rDBFormatData,
|
|
|
|
double* pNumber)
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XColumn > xColumn(xColumnProps, UNO_QUERY);
|
2000-09-18 16:15:01 +00:00
|
|
|
String sRet;
|
|
|
|
DBG_ASSERT(xColumn.is(), "SwNewDBMgr::::ImportDBField: illegal arguments")
|
|
|
|
if(!xColumn.is())
|
|
|
|
return sRet;
|
|
|
|
|
|
|
|
Any aType = xColumnProps->getPropertyValue(C2U("Type"));
|
2007-11-12 15:30:55 +00:00
|
|
|
sal_Int32 eDataType = 0;
|
2000-09-18 16:15:01 +00:00
|
|
|
aType >>= eDataType;
|
|
|
|
switch(eDataType)
|
|
|
|
{
|
|
|
|
case DataType::CHAR:
|
|
|
|
case DataType::VARCHAR:
|
|
|
|
case DataType::LONGVARCHAR:
|
2006-02-01 12:48:54 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
sRet = xColumn->getString();
|
|
|
|
}
|
2007-09-27 10:31:02 +00:00
|
|
|
catch( SQLException& )
|
2006-02-01 12:48:54 +00:00
|
|
|
{
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
break;
|
|
|
|
case DataType::BIT:
|
2005-02-17 09:37:55 +00:00
|
|
|
case DataType::BOOLEAN:
|
2000-09-18 16:15:01 +00:00
|
|
|
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:
|
|
|
|
{
|
2000-11-08 08:46:34 +00:00
|
|
|
// ::Date aTempDate(rDBFormatData.aNullDate.Day,
|
|
|
|
// rDBFormatData.aNullDate.Month, rDBFormatData.aNullDate.Year);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2002-08-21 11:23:43 +00:00
|
|
|
SwDbtoolsClient& aClient = SwNewDBMgr::GetDbtoolsClient();
|
2001-08-30 12:56:46 +00:00
|
|
|
sRet = aClient.getValue(
|
2000-09-18 16:15:01 +00:00
|
|
|
xColumnProps,
|
|
|
|
rDBFormatData.xFormatter,
|
|
|
|
rDBFormatData.aLocale,
|
2000-11-08 08:46:34 +00:00
|
|
|
rDBFormatData.aNullDate);
|
2000-09-18 16:15:01 +00:00
|
|
|
if (pNumber)
|
2005-03-01 14:25:36 +00:00
|
|
|
{
|
|
|
|
double fVal = xColumn->getDouble();
|
|
|
|
if(!xColumn->wasNull())
|
|
|
|
{
|
|
|
|
*pNumber = fVal;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2001-06-08 12:47:33 +00:00
|
|
|
catch(Exception& )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
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;
|
2001-08-30 12:56:46 +00:00
|
|
|
delete pImpl->pMergeData;
|
|
|
|
pImpl->pMergeData = 0;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
/* -----------------------------06.07.00 14:28--------------------------------
|
|
|
|
checks if a desired data source table or query is open
|
|
|
|
---------------------------------------------------------------------------*/
|
2001-07-10 12:51:01 +00:00
|
|
|
BOOL SwNewDBMgr::IsDataSourceOpen(const String& rDataSource,
|
|
|
|
const String& rTableOrQuery, sal_Bool bMergeOnly)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
if(pImpl->pMergeData)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2003-04-04 17:15:06 +00:00
|
|
|
return !bMergeLock &&
|
2007-07-18 11:59:12 +00:00
|
|
|
((rDataSource == (String)pImpl->pMergeData->sDataSource &&
|
|
|
|
rTableOrQuery == (String)pImpl->pMergeData->sCommand)
|
|
|
|
||(!rDataSource.Len() && !rTableOrQuery.Len()))
|
|
|
|
&&
|
2001-08-30 12:56:46 +00:00
|
|
|
pImpl->pMergeData->xResultSet.is();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2001-07-10 12:51:01 +00:00
|
|
|
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;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
/* -----------------------------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;
|
2001-07-10 12:51:01 +00:00
|
|
|
SwDSParam* pFound = 0;
|
2000-09-18 16:15:01 +00:00
|
|
|
//check if it's the merge data source
|
2001-08-30 12:56:46 +00:00
|
|
|
if(pImpl->pMergeData &&
|
|
|
|
rSourceName == (String)pImpl->pMergeData->sDataSource &&
|
|
|
|
rTableName == (String)pImpl->pMergeData->sCommand)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
pFound = pImpl->pMergeData;
|
2001-07-10 12:51:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SwDBData aData;
|
|
|
|
aData.sDataSource = rSourceName;
|
|
|
|
aData.sCommand = rTableName;
|
|
|
|
aData.nCommandType = -1;
|
|
|
|
pFound = FindDSData(aData, FALSE);
|
|
|
|
}
|
2003-04-04 17:15:06 +00:00
|
|
|
//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++)
|
|
|
|
{
|
2007-11-12 15:30:55 +00:00
|
|
|
sal_Int32 nSelection = 0;
|
2003-04-04 17:15:06 +00:00
|
|
|
pSelection[nPos] >>= nSelection;
|
|
|
|
if(nSelection == static_cast<sal_Int32>(nAbsRecordId))
|
|
|
|
bFound = sal_True;
|
|
|
|
}
|
|
|
|
if(!bFound)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-07-10 12:51:01 +00:00
|
|
|
if(pFound && pFound->xResultSet.is() && !pFound->bAfterSelection)
|
|
|
|
{
|
2001-12-11 10:24:42 +00:00
|
|
|
sal_Int32 nOldRow = 0;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nOldRow = pFound->xResultSet->getRow();
|
|
|
|
}
|
2002-08-21 11:23:43 +00:00
|
|
|
catch(const Exception& )
|
2001-12-11 10:24:42 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
//position to the desired index
|
2001-07-10 12:51:01 +00:00
|
|
|
BOOL bMove = TRUE;
|
2002-08-21 11:23:43 +00:00
|
|
|
if ( nOldRow != static_cast<sal_Int32>(nAbsRecordId) )
|
2001-07-10 12:51:01 +00:00
|
|
|
bMove = lcl_MoveAbsolute(pFound, nAbsRecordId);
|
2000-09-18 16:15:01 +00:00
|
|
|
if(bMove)
|
|
|
|
{
|
2001-07-10 12:51:01 +00:00
|
|
|
bRet = lcl_GetColumnCnt(pFound, rColumnName, nLanguage, rResult, pNumber);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2002-08-21 11:23:43 +00:00
|
|
|
if ( nOldRow != static_cast<sal_Int32>(nAbsRecordId) )
|
2001-07-10 12:51:01 +00:00
|
|
|
bMove = lcl_MoveAbsolute(pFound, nOldRow);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
/* -----------------------------06.07.00 16:47--------------------------------
|
|
|
|
reads the column data at the current position
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
BOOL SwNewDBMgr::GetMergeColumnCnt(const String& rColumnName, USHORT nLanguage,
|
2007-09-27 10:31:02 +00:00
|
|
|
String &rResult, double *pNumber, sal_uInt32 * /*pFormat*/)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is() || pImpl->pMergeData->bAfterSelection )
|
2001-02-26 09:26:48 +00:00
|
|
|
{
|
|
|
|
rResult.Erase();
|
2000-09-18 16:15:01 +00:00
|
|
|
return FALSE;
|
2001-02-26 09:26:48 +00:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-08-30 12:56:46 +00:00
|
|
|
BOOL bRet = lcl_GetColumnCnt(pImpl->pMergeData, rColumnName, nLanguage, rResult, pNumber);
|
2000-09-18 16:15:01 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
/* -----------------------------07.07.00 14:28--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
BOOL SwNewDBMgr::ToNextMergeRecord()
|
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
DBG_ASSERT(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge")
|
|
|
|
return ToNextRecord(pImpl->pMergeData);
|
2001-07-10 12:51:01 +00:00
|
|
|
}
|
|
|
|
/* -----------------------------10.07.01 14:28--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
BOOL SwNewDBMgr::ToNextRecord(
|
2007-09-27 10:31:02 +00:00
|
|
|
const String& rDataSource, const String& rCommand, sal_Int32 /*nCommandType*/)
|
2001-07-10 12:51:01 +00:00
|
|
|
{
|
|
|
|
SwDSParam* pFound = 0;
|
2001-08-30 12:56:46 +00:00
|
|
|
if(pImpl->pMergeData &&
|
|
|
|
rDataSource == (String)pImpl->pMergeData->sDataSource &&
|
|
|
|
rCommand == (String)pImpl->pMergeData->sCommand)
|
|
|
|
pFound = pImpl->pMergeData;
|
2001-07-10 12:51:01 +00:00
|
|
|
else
|
2001-02-26 09:26:48 +00:00
|
|
|
{
|
2001-07-10 12:51:01 +00:00
|
|
|
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;
|
2001-10-16 10:10:55 +00:00
|
|
|
if(!pParam || !pParam->xResultSet.is() || pParam->bEndOfDB ||
|
|
|
|
(pParam->aSelection.getLength() && pParam->aSelection.getLength() <= pParam->nSelectionIndex))
|
2001-07-10 12:51:01 +00:00
|
|
|
{
|
|
|
|
if(pParam)
|
|
|
|
pParam->CheckEndOfDB();
|
2000-09-18 16:15:01 +00:00
|
|
|
return FALSE;
|
2001-02-26 09:26:48 +00:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
try
|
|
|
|
{
|
2001-07-10 12:51:01 +00:00
|
|
|
if(pParam->aSelection.getLength())
|
2000-11-13 07:32:00 +00:00
|
|
|
{
|
2002-08-21 11:23:43 +00:00
|
|
|
sal_Int32 nPos = 0;
|
|
|
|
pParam->aSelection.getConstArray()[ pParam->nSelectionIndex++ ] >>= nPos;
|
|
|
|
pParam->bEndOfDB = !pParam->xResultSet->absolute( nPos );
|
2001-07-10 12:51:01 +00:00
|
|
|
pParam->CheckEndOfDB();
|
|
|
|
bRet = !pParam->bEndOfDB;
|
|
|
|
if(pParam->nSelectionIndex >= pParam->aSelection.getLength())
|
|
|
|
pParam->bEndOfDB = TRUE;
|
2000-11-13 07:32:00 +00:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
else
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
sal_Int32 nBefore = pParam->xResultSet->getRow();
|
2001-07-10 12:51:01 +00:00
|
|
|
pParam->bEndOfDB = !pParam->xResultSet->next();
|
2004-09-20 12:11:33 +00:00
|
|
|
if( !pParam->bEndOfDB && nBefore == pParam->xResultSet->getRow())
|
|
|
|
{
|
|
|
|
//next returned true but it didn't move
|
|
|
|
pParam->bEndOfDB = sal_True;
|
|
|
|
}
|
|
|
|
|
2001-07-10 12:51:01 +00:00
|
|
|
pParam->CheckEndOfDB();
|
|
|
|
bRet = !pParam->bEndOfDB;
|
|
|
|
++pParam->nSelectionIndex;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
2001-06-08 12:47:33 +00:00
|
|
|
catch(Exception&)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
}
|
2001-05-07 09:05:52 +00:00
|
|
|
return bRet;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2001-07-10 12:51:01 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
/* -----------------------------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
|
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
return pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
/* -----------------------------13.07.00 10:41--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
sal_uInt32 SwNewDBMgr::GetSelectedRecordId()
|
|
|
|
{
|
|
|
|
sal_uInt32 nRet = 0;
|
2001-08-30 12:56:46 +00:00
|
|
|
DBG_ASSERT(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge")
|
|
|
|
if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is())
|
2000-09-18 16:15:01 +00:00
|
|
|
return FALSE;
|
|
|
|
try
|
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
nRet = pImpl->pMergeData->xResultSet->getRow();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2001-06-08 12:47:33 +00:00
|
|
|
catch(Exception& )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
/* -----------------------------13.07.00 10:58--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
sal_Bool SwNewDBMgr::ToRecordId(sal_Int32 nSet)
|
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
DBG_ASSERT(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge")
|
|
|
|
if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is()|| nSet < 0)
|
2000-09-18 16:15:01 +00:00
|
|
|
return FALSE;
|
|
|
|
sal_Bool bRet = FALSE;
|
2001-03-30 11:05:13 +00:00
|
|
|
sal_Int32 nAbsPos = nSet;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if(nAbsPos >= 0)
|
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
bRet = lcl_MoveAbsolute(pImpl->pMergeData, nAbsPos);
|
|
|
|
pImpl->pMergeData->bEndOfDB = !bRet;
|
|
|
|
pImpl->pMergeData->CheckEndOfDB();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -----------------------------17.07.00 14:17--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2005-10-19 07:25:32 +00:00
|
|
|
BOOL SwNewDBMgr::OpenDataSource(const String& rDataSource, const String& rTableOrQuery,
|
|
|
|
sal_Int32 nCommandType, bool bCreate)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-03-30 11:05:13 +00:00
|
|
|
SwDBData aData;
|
|
|
|
aData.sDataSource = rDataSource;
|
|
|
|
aData.sCommand = rTableOrQuery;
|
|
|
|
aData.nCommandType = nCommandType;
|
|
|
|
|
|
|
|
SwDSParam* pFound = FindDSData(aData, TRUE);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XDataSource> xSource;
|
2000-09-18 16:15:01 +00:00
|
|
|
if(pFound->xResultSet.is())
|
|
|
|
return TRUE;
|
2001-08-15 07:20:44 +00:00
|
|
|
SwDSParam* pParam = FindDSConnection(rDataSource, FALSE);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XConnection> xConnection;
|
2001-08-15 07:20:44 +00:00
|
|
|
if(pParam && pParam->xConnection.is())
|
|
|
|
pFound->xConnection = pParam->xConnection;
|
2005-10-19 07:25:32 +00:00
|
|
|
else if(bCreate)
|
2002-10-24 12:48:08 +00:00
|
|
|
{
|
|
|
|
rtl::OUString sDataSource(rDataSource);
|
|
|
|
pFound->xConnection = RegisterConnection( sDataSource );
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
if(pFound->xConnection.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< sdbc::XDatabaseMetaData > xMetaData = pFound->xConnection->getMetaData();
|
2002-09-03 05:28:09 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
pFound->bScrollable = xMetaData
|
2000-09-18 16:15:01 +00:00
|
|
|
->supportsResultSetType((sal_Int32)ResultSetType::SCROLL_INSENSITIVE);
|
2002-09-03 05:28:09 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
//#98373# DB driver may not be ODBC 3.0 compliant
|
|
|
|
pFound->bScrollable = TRUE;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
pFound->xStatement = pFound->xConnection->createStatement();
|
2001-09-04 11:40:59 +00:00
|
|
|
rtl::OUString aQuoteChar = xMetaData->getIdentifierQuoteString();
|
|
|
|
rtl::OUString sStatement(C2U("SELECT * FROM "));
|
2001-03-30 11:05:13 +00:00
|
|
|
sStatement = C2U("SELECT * FROM ");
|
|
|
|
sStatement += aQuoteChar;
|
|
|
|
sStatement += rTableOrQuery;
|
|
|
|
sStatement += aQuoteChar;
|
|
|
|
pFound->xResultSet = pFound->xStatement->executeQuery( sStatement );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
//after executeQuery the cursor must be positioned
|
2001-03-30 11:05:13 +00:00
|
|
|
pFound->bEndOfDB = !pFound->xResultSet->next();
|
2001-07-10 12:51:01 +00:00
|
|
|
pFound->bAfterSelection = sal_False;
|
2001-03-30 11:05:13 +00:00
|
|
|
pFound->CheckEndOfDB();
|
|
|
|
++pFound->nSelectionIndex;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2000-12-18 09:12:48 +00:00
|
|
|
catch (Exception&)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
pFound->xResultSet = 0;
|
|
|
|
pFound->xStatement = 0;
|
|
|
|
pFound->xConnection = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pFound->xResultSet.is();
|
|
|
|
}
|
2001-08-15 07:20:44 +00:00
|
|
|
/* -----------------------------14.08.2001 10:26------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XConnection> SwNewDBMgr::RegisterConnection(rtl::OUString& rDataSource)
|
2001-08-15 07:20:44 +00:00
|
|
|
{
|
|
|
|
SwDSParam* pFound = SwNewDBMgr::FindDSConnection(rDataSource, TRUE);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XDataSource> xSource;
|
2001-08-15 07:20:44 +00:00
|
|
|
if(!pFound->xConnection.is())
|
2002-12-09 12:58:30 +00:00
|
|
|
{
|
2001-08-15 07:20:44 +00:00
|
|
|
pFound->xConnection = SwNewDBMgr::GetConnection(rDataSource, xSource );
|
2002-12-09 12:58:30 +00:00
|
|
|
try
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
|
2002-12-09 12:58:30 +00:00
|
|
|
if(xComponent.is())
|
|
|
|
xComponent->addEventListener(pImpl->xDisposeListener);
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2001-08-15 07:20:44 +00:00
|
|
|
return pFound->xConnection;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
/* -----------------------------17.07.00 15:55--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2001-03-30 11:05:13 +00:00
|
|
|
sal_uInt32 SwNewDBMgr::GetSelectedRecordId(
|
|
|
|
const String& rDataSource, const String& rTableOrQuery, sal_Int32 nCommandType)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2007-09-27 10:31:02 +00:00
|
|
|
sal_uInt32 nRet = 0xffffffff;
|
2000-09-18 16:15:01 +00:00
|
|
|
//check for merge data source first
|
2001-08-30 12:56:46 +00:00
|
|
|
if(pImpl->pMergeData && rDataSource == (String)pImpl->pMergeData->sDataSource &&
|
|
|
|
rTableOrQuery == (String)pImpl->pMergeData->sCommand &&
|
|
|
|
(nCommandType == -1 || nCommandType == pImpl->pMergeData->nCommandType) &&
|
|
|
|
pImpl->pMergeData->xResultSet.is())
|
2000-09-18 16:15:01 +00:00
|
|
|
nRet = GetSelectedRecordId();
|
|
|
|
else
|
|
|
|
{
|
2001-03-30 11:05:13 +00:00
|
|
|
SwDBData aData;
|
|
|
|
aData.sDataSource = rDataSource;
|
|
|
|
aData.sCommand = rTableOrQuery;
|
|
|
|
aData.nCommandType = nCommandType;
|
|
|
|
SwDSParam* pFound = FindDSData(aData, FALSE);
|
2000-09-18 16:15:01 +00:00
|
|
|
if(pFound && pFound->xResultSet.is())
|
|
|
|
{
|
|
|
|
try
|
2003-04-04 17:15:06 +00:00
|
|
|
{ //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;
|
2003-07-21 10:22:42 +00:00
|
|
|
if(nSelIndex >= pFound->aSelection.getLength())
|
2003-04-04 17:15:06 +00:00
|
|
|
nSelIndex = pFound->aSelection.getLength() -1;
|
|
|
|
pFound->aSelection.getConstArray()[nSelIndex] >>= nRet;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nRet = pFound->xResultSet->getRow();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2000-12-18 09:12:48 +00:00
|
|
|
catch(Exception&){}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -----------------------------17.07.00 14:18--------------------------------
|
|
|
|
close all data sources - after fields were updated
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
void SwNewDBMgr::CloseAll(BOOL bIncludingMerge)
|
|
|
|
{
|
2003-04-04 17:15:06 +00:00
|
|
|
//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;
|
2003-12-01 08:43:52 +00:00
|
|
|
pParam->bEndOfDB = sal_False;
|
2003-07-21 10:22:42 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if(!bInMerge && pParam->xResultSet.is())
|
|
|
|
pParam->xResultSet->first();
|
|
|
|
}
|
|
|
|
catch(Exception& )
|
|
|
|
{}
|
2003-04-04 17:15:06 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
/* -----------------------------17.07.00 14:54--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2001-03-30 11:05:13 +00:00
|
|
|
SwDSParam* SwNewDBMgr::FindDSData(const SwDBData& rData, BOOL bCreate)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2007-07-12 09:49:57 +00:00
|
|
|
//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;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
SwDSParam* pFound = 0;
|
2002-12-09 12:58:30 +00:00
|
|
|
for(USHORT nPos = aDataSourceParams.Count(); nPos; nPos--)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2002-12-09 12:58:30 +00:00
|
|
|
SwDSParam* pParam = aDataSourceParams[nPos - 1];
|
2001-03-30 11:05:13 +00:00
|
|
|
if(rData.sDataSource == pParam->sDataSource &&
|
|
|
|
rData.sCommand == pParam->sCommand &&
|
2001-11-26 14:07:28 +00:00
|
|
|
(rData.nCommandType == -1 || rData.nCommandType == pParam->nCommandType ||
|
|
|
|
(bCreate && pParam->nCommandType == -1)))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-11-26 14:07:28 +00:00
|
|
|
//#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;
|
2000-09-18 16:15:01 +00:00
|
|
|
pFound = pParam;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(bCreate)
|
|
|
|
{
|
|
|
|
if(!pFound)
|
|
|
|
{
|
2001-03-30 11:05:13 +00:00
|
|
|
pFound = new SwDSParam(rData);
|
2000-09-18 16:15:01 +00:00
|
|
|
aDataSourceParams.Insert(pFound, aDataSourceParams.Count());
|
2002-12-09 12:58:30 +00:00
|
|
|
try
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
|
2002-12-09 12:58:30 +00:00
|
|
|
if(xComponent.is())
|
|
|
|
xComponent->addEventListener(pImpl->xDisposeListener);
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return pFound;
|
|
|
|
}
|
2001-08-15 07:20:44 +00:00
|
|
|
/* -----------------------------14.08.2001 10:27------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2003-11-25 09:48:37 +00:00
|
|
|
|
2001-09-04 11:40:59 +00:00
|
|
|
SwDSParam* SwNewDBMgr::FindDSConnection(const rtl::OUString& rDataSource, BOOL bCreate)
|
2001-08-15 07:20:44 +00:00
|
|
|
{
|
2007-07-12 09:49:57 +00:00
|
|
|
//prefer merge data if available
|
|
|
|
if(pImpl->pMergeData && rDataSource == pImpl->pMergeData->sDataSource )
|
|
|
|
{
|
|
|
|
return pImpl->pMergeData;
|
|
|
|
}
|
2001-08-15 07:20:44 +00:00
|
|
|
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());
|
2002-12-09 12:58:30 +00:00
|
|
|
try
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
|
2002-12-09 12:58:30 +00:00
|
|
|
if(xComponent.is())
|
|
|
|
xComponent->addEventListener(pImpl->xDisposeListener);
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
2001-08-15 07:20:44 +00:00
|
|
|
}
|
|
|
|
return pFound;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
/* -----------------------------17.07.00 14:34--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2001-02-21 11:27:37 +00:00
|
|
|
const SwDBData& SwNewDBMgr::GetAddressDBName()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-02-21 11:27:37 +00:00
|
|
|
return SW_MOD()->GetDBConfig()->GetAddressSource();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
/* -----------------------------18.07.00 13:13--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2001-09-04 11:40:59 +00:00
|
|
|
Sequence<rtl::OUString> SwNewDBMgr::GetExistingDatabaseNames()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XNameAccess> xDBContext;
|
|
|
|
uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
|
2000-09-18 16:15:01 +00:00
|
|
|
if( xMgr.is() )
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
|
|
|
|
xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
if(xDBContext.is())
|
|
|
|
{
|
|
|
|
return xDBContext->getElementNames();
|
|
|
|
}
|
2001-09-04 11:40:59 +00:00
|
|
|
return Sequence<rtl::OUString>();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2004-08-02 13:20:28 +00:00
|
|
|
/*-- 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));
|
2008-06-06 09:06:54 +00:00
|
|
|
#ifdef WNT
|
|
|
|
String sFilterMDB(SW_RES(STR_FILTER_MDB));
|
|
|
|
#endif
|
2004-08-02 13:20:28 +00:00
|
|
|
xFltMgr->appendFilter( sFilterAll, C2U("*") );
|
2005-01-28 14:47:46 +00:00
|
|
|
xFltMgr->appendFilter( sFilterAllData, C2U("*.ods;*.sxc;*.dbf;*.xls;*.txt;*.csv"));
|
2004-08-02 13:20:28 +00:00
|
|
|
|
|
|
|
xFltMgr->appendFilter( sFilterSXB, C2U("*.odb") );
|
2005-02-16 16:10:36 +00:00
|
|
|
xFltMgr->appendFilter( sFilterSXC, C2U("*.ods;*.sxc") );
|
2004-08-02 13:20:28 +00:00
|
|
|
xFltMgr->appendFilter( sFilterDBF, C2U("*.dbf") );
|
|
|
|
xFltMgr->appendFilter( sFilterXLS, C2U("*.xls") );
|
|
|
|
xFltMgr->appendFilter( sFilterTXT, C2U("*.txt") );
|
|
|
|
xFltMgr->appendFilter( sFilterCSV, C2U("*.csv") );
|
2008-06-06 09:06:54 +00:00
|
|
|
#ifdef WNT
|
|
|
|
xFltMgr->appendFilter( sFilterMDB, C2U("*.mdb") );
|
|
|
|
#endif
|
2004-08-02 13:20:28 +00:00
|
|
|
|
|
|
|
xFltMgr->setCurrentFilter( sFilterAll ) ;
|
|
|
|
String sFind;
|
2008-03-07 10:16:55 +00:00
|
|
|
bool bTextConnection = false;
|
2004-08-02 13:20:28 +00:00
|
|
|
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;
|
2008-06-06 09:06:54 +00:00
|
|
|
Any aSuppressVersionsAny;
|
2004-08-02 13:20:28 +00:00
|
|
|
Any aInfoAny;
|
|
|
|
INetURLObject aTempURL(aURL);
|
|
|
|
bool bStore = true;
|
2004-09-20 12:11:33 +00:00
|
|
|
if(sExt.EqualsAscii("odb"))
|
2004-08-02 13:20:28 +00:00
|
|
|
{
|
|
|
|
bStore = false;
|
|
|
|
}
|
2007-07-12 09:49:57 +00:00
|
|
|
else if(sExt.EqualsIgnoreCaseAscii("sxc")
|
|
|
|
|| sExt.EqualsIgnoreCaseAscii("ods")
|
|
|
|
|| sExt.EqualsIgnoreCaseAscii("xls"))
|
2004-08-02 13:20:28 +00:00
|
|
|
{
|
|
|
|
rtl::OUString sDBURL(C2U("sdbc:calc:"));
|
|
|
|
sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
|
|
|
|
aURLAny <<= sDBURL;
|
|
|
|
}
|
2007-07-12 09:49:57 +00:00
|
|
|
else if(sExt.EqualsIgnoreCaseAscii("dbf"))
|
2004-08-02 13:20:28 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2007-07-12 09:49:57 +00:00
|
|
|
else if(sExt.EqualsIgnoreCaseAscii("csv") || sExt.EqualsIgnoreCaseAscii("txt"))
|
2004-08-02 13:20:28 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2008-03-07 10:16:55 +00:00
|
|
|
bTextConnection = true;
|
2004-08-02 13:20:28 +00:00
|
|
|
//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;
|
|
|
|
}
|
2008-06-06 09:06:54 +00:00
|
|
|
#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);
|
|
|
|
}
|
|
|
|
#endif
|
2004-08-02 13:20:28 +00:00
|
|
|
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);
|
|
|
|
|
2005-01-18 13:39:03 +00:00
|
|
|
String sNewName = INetURLObject::decode( aURL.getName(),
|
|
|
|
INET_HEX_ESCAPE,
|
|
|
|
INetURLObject::DECODE_UNAMBIGUOUS,
|
|
|
|
RTL_TEXTENCODING_UTF8 );
|
2007-09-27 10:31:02 +00:00
|
|
|
xub_StrLen nExtLen = static_cast< xub_StrLen >(aURL.GetExtension().getLength());
|
2004-08-02 13:20:28 +00:00
|
|
|
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)
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
//odb-file
|
2004-08-02 13:20:28 +00:00
|
|
|
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);
|
2008-06-06 09:06:54 +00:00
|
|
|
if(aSuppressVersionsAny.hasValue())
|
|
|
|
xDataProperties->setPropertyValue(C2U("SuppressVersionColumns"), aSuppressVersionsAny);
|
2004-08-02 13:20:28 +00:00
|
|
|
if(aInfoAny.hasValue())
|
|
|
|
xDataProperties->setPropertyValue(C2U("Info"), aInfoAny);
|
|
|
|
|
2008-03-07 10:16:55 +00:00
|
|
|
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 )));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-30 09:55:07 +00:00
|
|
|
Reference<XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW);
|
|
|
|
Reference<XStorable> xStore(xDS->getDatabaseDocument(), UNO_QUERY_THROW);
|
2007-09-27 10:31:02 +00:00
|
|
|
String sOutputExt = String::CreateFromAscii(".odb");
|
2004-08-02 13:20:28 +00:00
|
|
|
String sTmpName;
|
|
|
|
{
|
2007-09-27 10:31:02 +00:00
|
|
|
utl::TempFile aTempFile(sNewName , &sOutputExt, &sHomePath);
|
2004-08-02 13:20:28 +00:00
|
|
|
aTempFile.EnableKillingFile(sal_True);
|
|
|
|
sTmpName = aTempFile.GetURL();
|
|
|
|
}
|
|
|
|
xStore->storeAsURL(sTmpName, Sequence< PropertyValue >());
|
|
|
|
}
|
|
|
|
Reference<XNamingService> xNaming(xDBContext, UNO_QUERY);
|
|
|
|
xNaming->registerObject( sFind, xNewInstance );
|
|
|
|
|
|
|
|
}
|
2007-09-27 10:31:02 +00:00
|
|
|
catch(Exception&)
|
2004-08-02 13:20:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sFind;
|
|
|
|
|
|
|
|
}
|
2000-11-13 07:32:00 +00:00
|
|
|
/* -----------------------------10.11.00 17:10--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh,
|
2002-09-18 09:39:28 +00:00
|
|
|
const Sequence<PropertyValue>& rProperties,
|
|
|
|
BOOL bWithDataSourceBrowser)
|
2000-11-13 07:32:00 +00:00
|
|
|
{
|
2001-02-16 13:58:11 +00:00
|
|
|
//prevent second call
|
2001-08-30 12:56:46 +00:00
|
|
|
if(pImpl->pMergeDialog)
|
2001-02-16 13:58:11 +00:00
|
|
|
return ;
|
2001-09-04 11:40:59 +00:00
|
|
|
rtl::OUString sDataSource, sDataTableOrQuery;
|
2001-06-19 06:42:09 +00:00
|
|
|
Sequence<Any> aSelection;
|
2002-08-21 11:23:43 +00:00
|
|
|
|
2000-11-13 07:32:00 +00:00
|
|
|
sal_Int16 nCmdType = CommandType::TABLE;
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XConnection> xConnection;
|
2002-08-21 11:23:43 +00:00
|
|
|
|
|
|
|
ODataAccessDescriptor aDescriptor(rProperties);
|
2004-08-02 13:20:28 +00:00
|
|
|
sDataSource = aDescriptor.getDataSource();
|
2002-08-21 11:23:43 +00:00
|
|
|
aDescriptor[daCommand] >>= sDataTableOrQuery;
|
|
|
|
aDescriptor[daCommandType] >>= nCmdType;
|
|
|
|
|
|
|
|
if ( aDescriptor.has(daSelection) )
|
|
|
|
aDescriptor[daSelection] >>= aSelection;
|
|
|
|
if ( aDescriptor.has(daConnection) )
|
|
|
|
aDescriptor[daConnection] >>= xConnection;
|
|
|
|
|
2001-03-07 12:41:22 +00:00
|
|
|
if(!sDataSource.getLength() || !sDataTableOrQuery.getLength())
|
2000-11-13 07:32:00 +00:00
|
|
|
{
|
|
|
|
DBG_ERROR("PropertyValues missing or unset")
|
|
|
|
return;
|
|
|
|
}
|
2001-06-19 06:42:09 +00:00
|
|
|
|
2005-07-18 11:26:10 +00:00
|
|
|
//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);
|
|
|
|
}
|
2004-05-10 15:20:29 +00:00
|
|
|
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
|
2007-09-27 10:31:02 +00:00
|
|
|
DBG_ASSERT(pFact, "Dialogdiet fail!");
|
2007-04-26 08:02:02 +00:00
|
|
|
pImpl->pMergeDialog = pFact->CreateMailMergeDlg( DLG_MAILMERGE,
|
2004-05-10 15:20:29 +00:00
|
|
|
&rSh.GetView().GetViewFrame()->GetWindow(), rSh,
|
|
|
|
sDataSource,
|
|
|
|
sDataTableOrQuery,
|
|
|
|
nCmdType,
|
|
|
|
xConnection,
|
|
|
|
bWithDataSourceBrowser ? 0 : &aSelection);
|
2007-09-27 10:31:02 +00:00
|
|
|
DBG_ASSERT(pImpl->pMergeDialog, "Dialogdiet fail!");
|
2001-08-30 12:56:46 +00:00
|
|
|
if(pImpl->pMergeDialog->Execute() == RET_OK)
|
2000-11-13 07:32:00 +00:00
|
|
|
{
|
2002-08-21 11:23:43 +00:00
|
|
|
aDescriptor[daSelection] <<= pImpl->pMergeDialog->GetSelection();
|
2001-06-06 05:20:21 +00:00
|
|
|
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XResultSet> xResSet = pImpl->pMergeDialog->GetResultSet();
|
2001-06-06 05:20:21 +00:00
|
|
|
if(xResSet.is())
|
2002-08-21 11:23:43 +00:00
|
|
|
aDescriptor[daCursor] <<= xResSet;
|
|
|
|
|
2007-11-06 15:25:40 +00:00
|
|
|
SfxObjectShellRef xDocShell = rSh.GetView().GetViewFrame()->GetObjectShell();
|
|
|
|
SFX_APP()->NotifyEvent(SfxEventHint(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.
|
2008-03-10 12:48:39 +00:00
|
|
|
//set the current DBMgr
|
|
|
|
SwDoc* pWorkDoc = pView->GetWrtShell().GetDoc();
|
|
|
|
SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
|
|
|
|
pWorkDoc->SetNewDBMgr( this );
|
2007-11-06 15:25:40 +00:00
|
|
|
|
|
|
|
SwMergeDescriptor aMergeDesc( pImpl->pMergeDialog->GetMergeType(), pView->GetWrtShell(), aDescriptor );
|
|
|
|
aMergeDesc.sSaveToFilter = pImpl->pMergeDialog->GetSaveFilter();
|
|
|
|
MergeNew(aMergeDesc);
|
2008-03-10 12:48:39 +00:00
|
|
|
|
|
|
|
pWorkDoc->SetNewDBMgr( pWorkDBMgr );
|
2007-11-06 15:25:40 +00:00
|
|
|
//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 );
|
|
|
|
}
|
2004-02-03 15:37:21 +00:00
|
|
|
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, rSh.GetView().GetViewFrame()->GetObjectShell()));
|
2003-06-27 08:08:38 +00:00
|
|
|
|
2002-08-21 11:23:43 +00:00
|
|
|
// reset the cursor inside
|
|
|
|
xResSet = NULL;
|
|
|
|
aDescriptor[daCursor] <<= xResSet;
|
2000-11-13 07:32:00 +00:00
|
|
|
}
|
2005-07-18 11:26:10 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2001-08-30 12:56:46 +00:00
|
|
|
DELETEZ(pImpl->pMergeDialog);
|
2000-11-13 07:32:00 +00:00
|
|
|
}
|
|
|
|
/* -----------------------------13.11.00 08:20--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
void SwNewDBMgr::InsertText(SwWrtShell& rSh,
|
|
|
|
const Sequence< PropertyValue>& rProperties)
|
|
|
|
{
|
2001-09-04 11:40:59 +00:00
|
|
|
rtl::OUString sDataSource, sDataTableOrQuery;
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XResultSet> xResSet;
|
2001-06-06 11:01:40 +00:00
|
|
|
Sequence<Any> aSelection;
|
2000-11-13 07:32:00 +00:00
|
|
|
BOOL bHasSelectionProperty = FALSE;
|
|
|
|
sal_Int32 nSelectionPos = 0;
|
|
|
|
sal_Int16 nCmdType = CommandType::TABLE;
|
|
|
|
const PropertyValue* pValues = rProperties.getConstArray();
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XConnection> xConnection;
|
2000-11-13 07:32:00 +00:00
|
|
|
for(sal_Int32 nPos = 0; nPos < rProperties.getLength(); nPos++)
|
|
|
|
{
|
2001-06-06 05:20:21 +00:00
|
|
|
if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cDataSourceName)))
|
2000-11-13 07:32:00 +00:00
|
|
|
pValues[nPos].Value >>= sDataSource;
|
2001-06-06 05:20:21 +00:00
|
|
|
else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCommand)))
|
2000-11-13 07:32:00 +00:00
|
|
|
pValues[nPos].Value >>= sDataTableOrQuery;
|
2001-06-06 05:20:21 +00:00
|
|
|
else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCursor)))
|
2000-11-13 07:32:00 +00:00
|
|
|
pValues[nPos].Value >>= xResSet;
|
2001-06-06 05:20:21 +00:00
|
|
|
else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cSelection)))
|
2000-11-13 07:32:00 +00:00
|
|
|
{
|
|
|
|
bHasSelectionProperty = TRUE;
|
|
|
|
nSelectionPos = nPos;
|
|
|
|
pValues[nPos].Value >>= aSelection;
|
|
|
|
}
|
2001-06-06 05:20:21 +00:00
|
|
|
else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCommandType)))
|
2000-11-13 07:32:00 +00:00
|
|
|
pValues[nPos].Value >>= nCmdType;
|
2001-06-08 12:47:33 +00:00
|
|
|
else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cActiveConnection)))
|
|
|
|
pValues[nPos].Value >>= xConnection;
|
2000-11-13 07:32:00 +00:00
|
|
|
}
|
|
|
|
if(!sDataSource.getLength() || !sDataTableOrQuery.getLength() || !xResSet.is())
|
|
|
|
{
|
|
|
|
DBG_ERROR("PropertyValues missing or unset")
|
|
|
|
return;
|
|
|
|
}
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
|
|
|
|
uno::Reference<XDataSource> xSource;
|
|
|
|
uno::Reference<XChild> xChild(xConnection, UNO_QUERY);
|
2001-06-08 12:47:33 +00:00
|
|
|
if(xChild.is())
|
2004-09-20 12:11:33 +00:00
|
|
|
xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
|
2001-06-08 12:47:33 +00:00
|
|
|
if(!xSource.is())
|
2002-08-21 11:23:43 +00:00
|
|
|
xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(sDataSource, xMgr);
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XColumnsSupplier > xColSupp( xResSet, UNO_QUERY );
|
2001-02-21 11:27:37 +00:00
|
|
|
SwDBData aDBData;
|
|
|
|
aDBData.sDataSource = sDataSource;
|
|
|
|
aDBData.sCommand = sDataTableOrQuery;
|
|
|
|
aDBData.nCommandType = nCmdType;
|
2000-11-13 07:32:00 +00:00
|
|
|
|
2007-09-27 10:31:02 +00:00
|
|
|
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
|
|
|
|
DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
|
2004-05-10 15:20:29 +00:00
|
|
|
|
|
|
|
AbstractSwInsertDBColAutoPilot* pDlg = pFact->CreateSwInsertDBColAutoPilot( rSh.GetView(),
|
|
|
|
xSource,
|
|
|
|
xColSupp,
|
|
|
|
aDBData,
|
2007-04-26 08:02:02 +00:00
|
|
|
DLG_AP_INSERT_DB_SEL );
|
2007-09-27 10:31:02 +00:00
|
|
|
DBG_ASSERT(pDlg, "Dialogdiet fail!");
|
2000-11-13 07:32:00 +00:00
|
|
|
if( RET_OK == pDlg->Execute() )
|
|
|
|
{
|
2001-09-04 11:40:59 +00:00
|
|
|
rtl::OUString sDummy;
|
2001-06-08 12:47:33 +00:00
|
|
|
if(!xConnection.is())
|
|
|
|
xConnection = xSource->getConnection(sDummy, sDummy);
|
2001-05-21 12:45:09 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
pDlg->DataToDoc( aSelection , xSource, xConnection, xResSet);
|
|
|
|
}
|
|
|
|
catch(Exception& )
|
|
|
|
{
|
|
|
|
DBG_ERROR("exception caught")
|
|
|
|
}
|
2000-11-13 07:32:00 +00:00
|
|
|
}
|
|
|
|
delete pDlg;
|
|
|
|
|
|
|
|
}
|
2001-08-30 12:56:46 +00:00
|
|
|
/* -----------------------------30.08.2001 12:00------------------------------
|
2000-11-13 07:32:00 +00:00
|
|
|
|
2001-08-30 12:56:46 +00:00
|
|
|
---------------------------------------------------------------------------*/
|
2003-05-26 07:14:51 +00:00
|
|
|
SwDbtoolsClient* SwNewDBMgr::pDbtoolsClient = NULL;
|
|
|
|
|
2001-08-30 12:56:46 +00:00
|
|
|
SwDbtoolsClient& SwNewDBMgr::GetDbtoolsClient()
|
|
|
|
{
|
2002-08-21 11:23:43 +00:00
|
|
|
if ( !pDbtoolsClient )
|
2003-05-26 07:14:51 +00:00
|
|
|
pDbtoolsClient = new SwDbtoolsClient;
|
2002-08-21 11:23:43 +00:00
|
|
|
return *pDbtoolsClient;
|
2001-08-30 12:56:46 +00:00
|
|
|
}
|
2003-05-26 07:14:51 +00:00
|
|
|
/* -----------------13.05.2003 15:34-----------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
void SwNewDBMgr::RemoveDbtoolsClient()
|
|
|
|
{
|
|
|
|
delete pDbtoolsClient;
|
|
|
|
pDbtoolsClient = 0;
|
|
|
|
}
|
2002-08-21 11:23:43 +00:00
|
|
|
/* -----------------------------20.08.2002 12:00------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XDataSource> SwNewDBMgr::getDataSourceAsParent(const uno::Reference< XConnection>& _xConnection,const ::rtl::OUString& _sDataSourceName)
|
2002-08-21 11:23:43 +00:00
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XDataSource> xSource;
|
2003-09-11 08:41:01 +00:00
|
|
|
try
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XChild> xChild(_xConnection, UNO_QUERY);
|
2003-09-11 08:41:01 +00:00
|
|
|
if ( xChild.is() )
|
2004-09-20 12:11:33 +00:00
|
|
|
xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
|
2003-09-11 08:41:01 +00:00
|
|
|
if ( !xSource.is() )
|
|
|
|
xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(_sDataSourceName, ::comphelper::getProcessServiceFactory());
|
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("exception in getDataSourceAsParent caught")
|
|
|
|
}
|
2002-08-21 11:23:43 +00:00
|
|
|
return xSource;
|
|
|
|
}
|
|
|
|
/* -----------------------------20.08.2002 12:00------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XResultSet> SwNewDBMgr::createCursor(const ::rtl::OUString& _sDataSourceName,
|
2002-08-21 11:23:43 +00:00
|
|
|
const ::rtl::OUString& _sCommand,
|
|
|
|
sal_Int32 _nCommandType,
|
2004-09-20 12:11:33 +00:00
|
|
|
const uno::Reference<XConnection>& _xConnection
|
2002-08-21 11:23:43 +00:00
|
|
|
)
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XResultSet> xResultSet;
|
2002-08-21 11:23:43 +00:00
|
|
|
try
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
|
2002-08-21 11:23:43 +00:00
|
|
|
if( xMgr.is() )
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XInterface> xInstance = xMgr->createInstance(
|
2002-08-21 11:23:43 +00:00
|
|
|
C2U( "com.sun.star.sdb.RowSet" ));
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XPropertySet> xRowSetPropSet(xInstance, UNO_QUERY);
|
2002-08-21 11:23:43 +00:00
|
|
|
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));
|
|
|
|
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XCompletedExecution > xRowSet(xInstance, UNO_QUERY);
|
2002-08-21 11:23:43 +00:00
|
|
|
|
|
|
|
if ( xRowSet.is() )
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference< XInteractionHandler > xHandler(xMgr->createInstance(C2U("com.sun.star.sdb.InteractionHandler")), UNO_QUERY);
|
2002-08-21 11:23:43 +00:00
|
|
|
xRowSet->executeWithCompletion(xHandler);
|
|
|
|
}
|
2004-09-20 12:11:33 +00:00
|
|
|
xResultSet = uno::Reference<XResultSet>(xRowSet, UNO_QUERY);
|
2002-08-21 11:23:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
2004-09-20 12:11:33 +00:00
|
|
|
DBG_ASSERT(0,"Caught exception while creating a new RowSet!");
|
2002-08-21 11:23:43 +00:00
|
|
|
}
|
|
|
|
return xResultSet;
|
|
|
|
}
|
2004-09-20 12:11:33 +00:00
|
|
|
/*-- 13.05.2004 16:14:15---------------------------------------------------
|
|
|
|
merge all data into one resulting document and return the number of
|
|
|
|
merged documents
|
|
|
|
-----------------------------------------------------------------------*/
|
2006-07-13 14:55:52 +00:00
|
|
|
|
2004-09-20 12:11:33 +00:00
|
|
|
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;
|
|
|
|
|
2004-11-16 15:57:21 +00:00
|
|
|
CreateMonitor aMonitorDlg(&rSourceView.GetEditWin());
|
|
|
|
aMonitorDlg.SetCancelHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
|
2004-09-20 12:11:33 +00:00
|
|
|
if (!IsMergeSilent())
|
2004-11-16 15:57:21 +00:00
|
|
|
{
|
|
|
|
aMonitorDlg.Show();
|
|
|
|
aMonitorDlg.Invalidate();
|
|
|
|
aMonitorDlg.Update();
|
|
|
|
// the print monitor needs some time to act
|
|
|
|
for( USHORT i = 0; i < 25; i++)
|
|
|
|
Application::Reschedule();
|
|
|
|
}
|
|
|
|
|
2004-09-20 12:11:33 +00:00
|
|
|
SwWrtShell& rSourceShell = rSourceView.GetWrtShell();
|
|
|
|
BOOL bSynchronizedDoc = rSourceShell.IsLabelDoc() && rSourceShell.GetSectionFmtCount() > 1;
|
|
|
|
String sSourceDocURL;
|
|
|
|
//save the settings of the first
|
2007-09-27 10:31:02 +00:00
|
|
|
rSourceShell.SttEndDoc(TRUE);
|
2004-09-20 12:11:33 +00:00
|
|
|
USHORT nStartingPageNo = rSourceShell.GetVirtPageNum();
|
2006-07-13 14:55:52 +00:00
|
|
|
String sModifiedStartingPageDesc;
|
|
|
|
String sStartingPageDesc = sModifiedStartingPageDesc = rSourceShell.GetPageDesc(
|
2004-09-20 12:11:33 +00:00
|
|
|
rSourceShell.GetCurPageDesc()).GetName();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// save the working document into a temporary location
|
2005-01-11 11:39:42 +00:00
|
|
|
sSourceDocURL = URIHelper::SmartRel2Abs(
|
|
|
|
INetURLObject(), utl::TempFile::CreateTempName(),
|
|
|
|
URIHelper::GetMaybeFileHdl());
|
2004-09-20 12:11:33 +00:00
|
|
|
const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
|
|
|
|
String::CreateFromAscii( FILTER_XML ),
|
|
|
|
SwDocShell::Factory().GetFilterContainer() );
|
|
|
|
|
|
|
|
SfxStringItem aFilterName( SID_FILTER_NAME, pSfxFlt->GetFilterName());
|
2005-03-01 14:25:36 +00:00
|
|
|
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( rSourceView.GetDocShell()->GetModel(), uno::UNO_QUERY);
|
|
|
|
xStore->storeToURL( sSourceDocURL, aValues );
|
|
|
|
|
2004-09-20 12:11:33 +00:00
|
|
|
// create a target docshell to put the merged document into
|
|
|
|
SfxObjectShellRef xTargetDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
|
|
|
|
xTargetDocShell->DoInitNew( 0 );
|
2006-05-02 14:20:53 +00:00
|
|
|
SfxViewFrame* pTargetFrame = SfxViewFrame::CreateViewFrame( *xTargetDocShell, 0, TRUE );
|
2004-09-20 12:11:33 +00:00
|
|
|
|
|
|
|
//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();
|
2006-07-13 14:55:52 +00:00
|
|
|
// #i63806#
|
|
|
|
const SwPageDesc* pSourcePageDesc = rSourceShell.FindPageDescByName( sStartingPageDesc );
|
|
|
|
const SwFrmFmt& rMaster = pSourcePageDesc->GetMaster();
|
|
|
|
bool bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive() ||
|
|
|
|
rMaster.GetFooter().IsActive();
|
|
|
|
|
|
|
|
|
2005-10-18 12:49:13 +00:00
|
|
|
// #122799# copy compatibility options
|
|
|
|
lcl_CopyCompatibilityOptions( rSourceShell, *pTargetShell);
|
2007-04-04 14:17:58 +00:00
|
|
|
// #72821# copy dynamic defaults
|
|
|
|
lcl_CopyDynamicDefaults( *rSourceShell.GetDoc(), *pTargetShell->GetDoc() );
|
2004-09-20 12:11:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
long nStartRow, nEndRow;
|
|
|
|
ULONG nDocNo = 1;
|
2004-11-16 15:57:21 +00:00
|
|
|
sal_Int32 nDocCount = 0;
|
|
|
|
if( !IsMergeSilent() && lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) )
|
|
|
|
aMonitorDlg.SetTotalCount( nDocCount );
|
2004-09-20 12:11:33 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
nStartRow = pImpl->pMergeData->xResultSet->getRow();
|
2004-11-16 15:57:21 +00:00
|
|
|
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();
|
|
|
|
}
|
2004-09-20 12:11:33 +00:00
|
|
|
|
|
|
|
// create a new docshell from the temporary document
|
|
|
|
SfxBoolItem aHidden( SID_HIDDEN, TRUE );
|
|
|
|
SfxStringItem aReferer( SID_REFERER, String::CreateFromAscii(URL_PREFIX_PRIV_SOFFICE ));
|
|
|
|
SfxStringItem aTarget( SID_TARGETNAME, String::CreateFromAscii("_blank") );
|
2005-03-01 14:25:36 +00:00
|
|
|
SfxStringItem aURL( SID_FILE_NAME, sSourceDocURL );
|
2004-09-20 12:11:33 +00:00
|
|
|
const SfxPoolItem* pReturnValue =
|
|
|
|
rSourceView.GetViewFrame()->GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON,
|
2007-06-06 10:06:43 +00:00
|
|
|
&aURL, &aFilterName, &aHidden, &aReferer, &aTarget, 0L);
|
2004-09-20 12:11:33 +00:00
|
|
|
if(pReturnValue)
|
|
|
|
{
|
|
|
|
SfxViewFrameItem* pVItem = (SfxViewFrameItem*)pReturnValue;
|
|
|
|
SwView* pWorkView = (SwView*) pVItem->GetFrame()->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();
|
2007-09-27 10:31:02 +00:00
|
|
|
if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds())
|
2004-09-20 12:11:33 +00:00
|
|
|
rWorkShell.Undo();
|
|
|
|
// create a layout
|
|
|
|
rWorkShell.CalcLayout();
|
2005-03-11 09:48:02 +00:00
|
|
|
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
|
2004-09-20 12:11:33 +00:00
|
|
|
rWorkShell.ViewShell::UpdateFlds();
|
2005-03-11 09:48:02 +00:00
|
|
|
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
|
2004-09-20 12:11:33 +00:00
|
|
|
|
|
|
|
// strip invisible content and convert fields to text
|
|
|
|
rWorkShell.RemoveInvisibleContent();
|
|
|
|
rWorkShell.ConvertFieldsToText();
|
2005-11-04 15:01:40 +00:00
|
|
|
rWorkShell.SetNumberingRestart();
|
2004-09-20 12:11:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
// insert the document into the target document
|
2007-09-27 10:31:02 +00:00
|
|
|
rWorkShell.SttEndDoc(FALSE);
|
|
|
|
rWorkShell.SttEndDoc(TRUE);
|
2004-09-20 12:11:33 +00:00
|
|
|
rWorkShell.SelAll();
|
2007-09-27 10:31:02 +00:00
|
|
|
pTargetShell->SttEndDoc(FALSE);
|
2006-07-13 14:55:52 +00:00
|
|
|
|
|
|
|
//#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 );
|
2007-04-04 14:17:58 +00:00
|
|
|
SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
|
|
|
|
if(pSourcePageDesc && pTargetPageDesc)
|
2006-07-13 14:55:52 +00:00
|
|
|
{
|
2007-04-04 14:17:58 +00:00
|
|
|
pTargetDoc->CopyPageDesc( *pSourcePageDesc, *pTargetPageDesc, sal_False );
|
2006-07-13 14:55:52 +00:00
|
|
|
sModifiedStartingPageDesc = sNewPageDescName;
|
2007-09-27 10:31:02 +00:00
|
|
|
lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo );
|
2006-07-13 14:55:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(nDocNo == 1 || bPageStylesWithHeaderFooter)
|
|
|
|
{
|
|
|
|
pTargetView->GetDocShell()->_LoadStyles( *pWorkView->GetDocShell(), sal_True );
|
|
|
|
}
|
2004-09-20 12:11:33 +00:00
|
|
|
if(nDocNo > 1)
|
|
|
|
{
|
2006-07-13 14:55:52 +00:00
|
|
|
pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
|
2004-09-20 12:11:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-13 14:55:52 +00:00
|
|
|
pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
|
2004-09-20 12:11:33 +00:00
|
|
|
}
|
|
|
|
USHORT nPageCountBefore = pTargetShell->GetPageCnt();
|
2005-01-28 14:47:46 +00:00
|
|
|
DBG_ASSERT(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended")
|
2005-10-19 07:25:32 +00:00
|
|
|
//#i51359# add a second paragraph in case there's only one
|
|
|
|
{
|
|
|
|
SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
|
|
|
|
SwPosition aTestPos( aIdx );
|
2007-11-22 14:39:40 +00:00
|
|
|
SwCursor aTestCrsr(aTestPos,0,false);
|
2005-10-19 07:25:32 +00:00
|
|
|
if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
|
|
|
|
{
|
|
|
|
//append a paragraph
|
|
|
|
pWorkDoc->AppendTxtNode( aTestPos );
|
|
|
|
}
|
|
|
|
}
|
2004-09-20 12:11:33 +00:00
|
|
|
pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
|
2005-11-10 14:57:22 +00:00
|
|
|
//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();
|
|
|
|
}
|
2004-09-20 12:11:33 +00:00
|
|
|
//add the document info to the config item
|
|
|
|
SwDocMergeInfo aMergeInfo;
|
|
|
|
aMergeInfo.nStartPageInTarget = nPageCountBefore;
|
2007-07-12 09:49:57 +00:00
|
|
|
//#i72820# calculate layout to be able to find the correct page index
|
|
|
|
pTargetShell->CalcLayout();
|
2004-09-20 12:11:33 +00:00
|
|
|
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
|
2004-10-22 12:57:37 +00:00
|
|
|
SfxObjectShellRef xDocSh(pWorkView->GetDocShell());
|
|
|
|
xDocSh->DoClose();
|
2004-09-20 12:11:33 +00:00
|
|
|
}
|
|
|
|
nEndRow = pImpl->pMergeData->xResultSet->getRow();
|
|
|
|
++nDocNo;
|
|
|
|
} while( !bCancel &&
|
|
|
|
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
|
2004-11-16 15:57:21 +00:00
|
|
|
|
|
|
|
//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();
|
|
|
|
//
|
2004-09-20 12:11:33 +00:00
|
|
|
}
|
2007-09-27 10:31:02 +00:00
|
|
|
catch( Exception& )
|
2004-09-20 12:11:33 +00:00
|
|
|
{
|
|
|
|
DBG_ERROR("exception caught in SwNewDBMgr::MergeDocuments")
|
|
|
|
}
|
|
|
|
if(sSourceDocURL.Len())
|
|
|
|
File::remove( sSourceDocURL );
|
|
|
|
DELETEZ(pImpl->pMergeData);
|
|
|
|
bInMerge = FALSE;
|
|
|
|
return nRet;
|
|
|
|
}
|
2002-12-09 12:58:30 +00:00
|
|
|
/* -----------------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());
|
2004-09-20 12:11:33 +00:00
|
|
|
uno::Reference<XConnection> xSource(rSource.Source, UNO_QUERY);
|
2002-12-09 12:58:30 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-08-21 11:23:43 +00:00
|
|
|
|