2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: dbmgr.cxx,v $
|
|
|
|
*
|
2001-08-31 13:10:43 +00:00
|
|
|
* $Revision: 1.45 $
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2001-08-31 13:10:43 +00:00
|
|
|
* last change: $Author: jp $ $Date: 2001-08-31 14:07:46 $
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library 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 for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef PRECOMPILED
|
|
|
|
#include "ui_pch.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#pragma hdrstop
|
|
|
|
|
|
|
|
#if STLPORT_VERSION>=321
|
|
|
|
#include <cstdarg>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#ifndef _UCBHELPER_CONTENT_HXX
|
|
|
|
#include <ucbhelper/content.hxx>
|
|
|
|
#endif
|
2000-11-13 07:32:00 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
|
|
|
|
#include <com/sun/star/sdb/CommandType.hpp>
|
|
|
|
#endif
|
2000-09-18 16:15:01 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UCB_XCOMMANDENVIRONMENT_HPP_
|
|
|
|
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_TRANSFERINFO_HPP_
|
|
|
|
#include <com/sun/star/ucb/TransferInfo.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_NAMECLASH_HPP_
|
|
|
|
#include <com/sun/star/ucb/NameClash.hpp>
|
|
|
|
#endif
|
2000-10-27 10:26:20 +00:00
|
|
|
#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
|
|
|
|
#include <com/sun/star/frame/XComponentLoader.hpp>
|
|
|
|
#endif
|
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
|
|
|
#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
|
|
|
|
#include <com/sun/star/sdb/XCompletedConnection.hpp>
|
|
|
|
#endif
|
2001-06-08 12:47:33 +00:00
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
|
|
|
|
#include <com/sun/star/container/XChild.hpp>
|
|
|
|
#endif
|
2000-10-27 10:26:20 +00:00
|
|
|
#ifndef _SFXVIEWFRM_HXX
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
#endif
|
2001-02-21 11:27:37 +00:00
|
|
|
#ifndef _DBCONFIG_HXX
|
|
|
|
#include <dbconfig.hxx>
|
|
|
|
#endif
|
2001-08-30 12:56:46 +00:00
|
|
|
#ifndef _SWDBTOOLSCLIENT_HXX
|
|
|
|
#include <swdbtoolsclient.hxx>
|
|
|
|
#endif
|
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
|
|
|
#ifndef _UNOTOOLS_TEMPFILE_HXX
|
|
|
|
#include <unotools/tempfile.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef SVTOOLS_URIHELPER_HXX
|
|
|
|
#include <svtools/urihelper.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVSTDARR_HXX
|
|
|
|
#define _SVSTDARR_STRINGSDTOR
|
|
|
|
#include <svtools/svstdarr.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _ZFORLIST_HXX //autogen
|
|
|
|
#include <svtools/zforlist.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _ZFORMAT_HXX //autogen
|
|
|
|
#include <svtools/zformat.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXSTRITEM_HXX //autogen
|
|
|
|
#include <svtools/stritem.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXENUMITEM_HXX //autogen
|
|
|
|
#include <svtools/eitem.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_PRINTER_HXX //autogen
|
|
|
|
#include <sfx2/printer.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXDOCFILE_HXX //autogen
|
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_PROGRESS_HXX //autogen
|
|
|
|
#include <sfx2/progress.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_DOCFILT_HACK_HXX //autogen
|
|
|
|
#include <sfx2/docfilt.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXDISPATCH_HXX //autogen
|
|
|
|
#include <sfx2/dispatch.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _OFF_APP_HXX //autogen
|
|
|
|
#include <offmgr/app.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _MAILENUM_HXX //autogen
|
|
|
|
#include <goodies/mailenum.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SWTYPES_HXX
|
|
|
|
#include <swtypes.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SWMODULE_HXX
|
|
|
|
#include <swmodule.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _VIEW_HXX
|
|
|
|
#include <view.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DOCSH_HXX
|
|
|
|
#include <docsh.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _EDTWIN_HXX
|
|
|
|
#include <edtwin.hxx>
|
|
|
|
#endif
|
2000-11-13 07:32:00 +00:00
|
|
|
#ifndef _DBINSDLG_HXX
|
|
|
|
#include <dbinsdlg.hxx>
|
|
|
|
#endif
|
2000-09-18 16:15:01 +00:00
|
|
|
#ifndef _WRTSH_HXX
|
|
|
|
#include <wrtsh.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _FLDBAS_HXX
|
|
|
|
#include <fldbas.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _INITUI_HXX
|
|
|
|
#include <initui.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SWUNDO_HXX
|
|
|
|
#include <swundo.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _FLDDAT_HXX
|
|
|
|
#include <flddat.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SWMODULE_HXX
|
|
|
|
#include <swmodule.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _MODCFG_HXX
|
|
|
|
#include <modcfg.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SWPRTOPT_HXX
|
|
|
|
#include <swprtopt.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SHELLIO_HXX
|
|
|
|
#include <shellio.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DBUI_HXX
|
|
|
|
#include <dbui.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DBMGR_HXX
|
|
|
|
#include <dbmgr.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DOC_HXX
|
|
|
|
#include <doc.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SWWAIT_HXX
|
|
|
|
#include <swwait.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _DBUI_HRC
|
|
|
|
#include <dbui.hrc>
|
|
|
|
#endif
|
|
|
|
#ifndef _GLOBALS_HRC
|
|
|
|
#include <globals.hrc>
|
|
|
|
#endif
|
|
|
|
#ifndef _STATSTR_HRC
|
|
|
|
#include <statstr.hrc>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SFXREQUEST_HXX
|
|
|
|
#include <sfx2/request.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _HINTIDS_HXX
|
|
|
|
#include <hintids.hxx>
|
|
|
|
#endif
|
2000-11-08 08:46:34 +00:00
|
|
|
#include <connectivity/dbconversion.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
|
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XDataSource.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_XCOLUMN_HPP_
|
|
|
|
#include <com/sun/star/sdb/XColumn.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
|
|
|
|
#include <com/sun/star/sdbc/DataType.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XStatement.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_
|
|
|
|
#include <com/sun/star/sdbc/ResultSetType.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#endif
|
2000-10-20 13:18:07 +00:00
|
|
|
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
|
|
|
|
#include <comphelper/processfactory.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _ISOLANG_HXX
|
|
|
|
#include <tools/isolang.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
|
|
|
|
#include <com/sun/star/util/XNumberFormatTypes.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVX_LANGITEM_HXX
|
|
|
|
#include <svx/langitem.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVX_UNOMID_HXX
|
|
|
|
#include <svx/unomid.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _NUMUNO_HXX
|
|
|
|
#include <svtools/numuno.hxx>
|
|
|
|
#endif
|
2000-11-13 07:32:00 +00:00
|
|
|
#include "mailmrge.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _SFXEVENT_HXX
|
|
|
|
#include <sfx2/event.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_MSGBOX_HXX
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#endif
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
using namespace rtl;
|
2000-10-27 10:26:20 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace com::sun::star::uno;
|
2000-09-18 16:15:01 +00:00
|
|
|
using namespace com::sun::star::container;
|
2000-10-27 10:26:20 +00:00
|
|
|
using namespace com::sun::star::frame;
|
2000-09-18 16:15:01 +00:00
|
|
|
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::ucb;
|
2000-12-01 10:45:55 +00:00
|
|
|
using namespace com::sun::star::task;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2000-10-27 10:26:20 +00:00
|
|
|
#define C2S(cChar) String::CreateFromAscii(cChar)
|
2000-09-18 16:15:01 +00:00
|
|
|
#define C2U(char) rtl::OUString::createFromAscii(char)
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
/* -----------------------------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)
|
|
|
|
{
|
|
|
|
DBG_ERROR("exception caught")
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
/* -----------------------------17.07.00 17:23--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
BOOL lcl_GetColumnCnt(SwDSParam* pParam,
|
|
|
|
const String& rColumnName, long nLanguage, String& rResult, double* pNumber)
|
|
|
|
{
|
|
|
|
Reference< XColumnsSupplier > xColsSupp( pParam->xResultSet, UNO_QUERY );
|
|
|
|
Reference <XNameAccess> xCols = xColsSupp->getColumns();
|
|
|
|
if(!xCols->hasByName(rColumnName))
|
|
|
|
return FALSE;
|
|
|
|
Any aCol = xCols->getByName(rColumnName);
|
|
|
|
Reference< XPropertySet > xColumnProps;
|
|
|
|
if(aCol.hasValue())
|
|
|
|
xColumnProps = *(Reference< XPropertySet >*)aCol.getValue();
|
|
|
|
|
|
|
|
SwDBFormatData aFormatData;
|
|
|
|
aFormatData.aNullDate = pParam->aNullDate;
|
|
|
|
aFormatData.xFormatter = pParam->xFormatter;
|
|
|
|
|
|
|
|
String sLanguage, sCountry;
|
2001-03-30 11:05:13 +00:00
|
|
|
::ConvertLanguageToIsoNames( (USHORT)nLanguage, sLanguage, sCountry );
|
2000-09-18 16:15:01 +00:00
|
|
|
aFormatData.aLocale.Language = sLanguage;
|
|
|
|
aFormatData.aLocale.Country = sCountry;
|
|
|
|
|
|
|
|
rResult = SwNewDBMgr::GetDBField( xColumnProps, aFormatData, pNumber);
|
|
|
|
return TRUE;
|
|
|
|
};
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Daten importieren
|
|
|
|
--------------------------------------------------------------------*/
|
2000-11-13 07:32:00 +00:00
|
|
|
BOOL SwNewDBMgr::MergeNew(USHORT nOpt, SwWrtShell& rSh,
|
|
|
|
const Sequence<PropertyValue>& rProperties,
|
|
|
|
const String *pPrinter)
|
|
|
|
{
|
|
|
|
|
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;
|
2000-11-13 07:32:00 +00:00
|
|
|
Reference<XResultSet> xResSet;
|
2001-06-26 13:35:16 +00:00
|
|
|
Sequence<Any> aSelection;
|
2001-06-29 07:10:35 +00:00
|
|
|
Sequence<sal_Int32> aDlgSelection;
|
2001-06-08 12:47:33 +00:00
|
|
|
Reference< XConnection> xConnection;
|
2000-11-13 07:32:00 +00:00
|
|
|
const PropertyValue* pValues = rProperties.getConstArray();
|
|
|
|
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)))
|
2001-03-30 11:05:13 +00:00
|
|
|
pValues[nPos].Value >>= aData.sDataSource;
|
2001-06-06 05:20:21 +00:00
|
|
|
else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCommand)))
|
2001-03-30 11:05:13 +00:00
|
|
|
pValues[nPos].Value >>= aData.sCommand;
|
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)))
|
2001-06-29 07:10:35 +00:00
|
|
|
{
|
|
|
|
//both types are possible here
|
2000-11-13 07:32:00 +00:00
|
|
|
pValues[nPos].Value >>= aSelection;
|
2001-06-29 07:10:35 +00:00
|
|
|
pValues[nPos].Value >>= aDlgSelection;
|
|
|
|
}
|
2001-06-06 05:20:21 +00:00
|
|
|
else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCommandType)))
|
2001-03-30 11:05:13 +00:00
|
|
|
pValues[nPos].Value >>= aData.nCommandType;
|
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
|
|
|
}
|
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;
|
|
|
|
}
|
2001-06-26 13:35:16 +00:00
|
|
|
if(aSelection.getLength())
|
|
|
|
{
|
2001-06-29 07:10:35 +00:00
|
|
|
aDlgSelection.realloc(aSelection.getLength());
|
2001-06-26 13:35:16 +00:00
|
|
|
sal_Int32* pDlgSelection = aDlgSelection.getArray();
|
|
|
|
const Any* pGridSelection = aSelection.getConstArray();
|
|
|
|
for(sal_Int32 nSel = 0; nSel < aSelection.getLength(); nSel++)
|
|
|
|
pGridSelection[nSel] >>= pDlgSelection[nSel];
|
|
|
|
}
|
2001-08-30 12:56:46 +00:00
|
|
|
pImpl->pMergeData = new SwDSParam(aData, xResSet, aDlgSelection);
|
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-08-30 12:56:46 +00:00
|
|
|
aDataSourceParams.Insert(new SwDSParam(*pImpl->pMergeData), aDataSourceParams.Count());
|
|
|
|
if(!pImpl->pMergeData->xConnection.is())
|
|
|
|
pImpl->pMergeData->xConnection = xConnection;
|
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
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->absolute(
|
|
|
|
(ULONG)pImpl->pMergeData->aSelection.getConstArray()[ pImpl->pMergeData->nSelectionIndex++ ] );
|
|
|
|
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()")
|
|
|
|
}
|
|
|
|
|
2000-11-13 07:32:00 +00:00
|
|
|
Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
|
2001-08-30 12:56:46 +00:00
|
|
|
Reference<XDataSource> xSource = GetDbtoolsClient().getDataSource(aData.sDataSource, xMgr);
|
2000-11-13 07:32:00 +00:00
|
|
|
if( xMgr.is() )
|
|
|
|
{
|
|
|
|
Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.util.NumberFormatter" ));
|
2001-08-30 12:56:46 +00:00
|
|
|
pImpl->pMergeData->xFormatter = Reference<util::XNumberFormatter>(xInstance, UNO_QUERY) ;
|
2000-11-13 07:32:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
|
|
|
|
if(xSourceProps.is())
|
|
|
|
{
|
|
|
|
Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
|
|
|
|
if(aFormats.hasValue())
|
|
|
|
{
|
|
|
|
Reference<XNumberFormatsSupplier> xSuppl;
|
|
|
|
aFormats >>= xSuppl;
|
|
|
|
if(xSuppl.is())
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
|
|
|
|
Any aNull = xSettings->getPropertyValue(C2U("NullDate"));
|
|
|
|
if(aNull.hasValue())
|
2001-08-30 12:56:46 +00:00
|
|
|
pImpl->pMergeData->aNullDate = *(util::Date*)aNull.getValue();
|
2000-11-13 07:32:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-30 11:05:13 +00:00
|
|
|
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);
|
2001-02-21 11:27:37 +00:00
|
|
|
SwDBData aData = rSh.GetDBData();
|
|
|
|
String sDBName = aData.sDataSource;
|
|
|
|
sDBName += DB_DELIM;
|
|
|
|
sDBName += (String)aData.sCommand;
|
|
|
|
sDBName += DB_DELIM;
|
|
|
|
sDBName += String::CreateFromInt32(aData.nCommandType);
|
|
|
|
rSh.ChangeDBFields( aDBNames, sDBName);
|
2000-11-13 07:32:00 +00:00
|
|
|
SetInitDBFields(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL bRet = TRUE;
|
|
|
|
switch(nOpt)
|
|
|
|
{
|
|
|
|
case DBMGR_MERGE:
|
|
|
|
bRet = Merge(&rSh); // Mischen
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DBMGR_MERGE_MAILMERGE: // Serienbrief
|
|
|
|
{
|
|
|
|
SfxDispatcher *pDis = rSh.GetView().GetViewFrame()->GetDispatcher();
|
|
|
|
if (pPrinter) // Aufruf kommt aus dem Basic
|
|
|
|
{
|
|
|
|
SfxBoolItem aSilent( SID_SILENT, TRUE );
|
|
|
|
if (pPrinter)
|
|
|
|
{
|
|
|
|
SfxStringItem aPrinterName(SID_PRINTER_NAME, *pPrinter);
|
|
|
|
pDis->Execute( SID_PRINTDOC, SFX_CALLMODE_SYNCHRON,
|
|
|
|
&aPrinterName, &aSilent, 0L );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pDis->Execute( SID_PRINTDOC, SFX_CALLMODE_SYNCHRON,
|
|
|
|
&aSilent, 0L );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pDis->Execute(SID_PRINTDOC, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DBMGR_MERGE_MAILING:
|
|
|
|
bRet = MergeMailing(&rSh); // Mailing
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DBMGR_MERGE_MAILFILES:
|
|
|
|
bRet = MergeMailFiles(&rSh); // Serienbriefe als Dateien abspeichern
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: // Einfuegen der selektierten Eintraege
|
|
|
|
// (war: InsertRecord)
|
|
|
|
ImportFromConnection(&rSh);
|
|
|
|
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();
|
|
|
|
pSh->StartUndo(0);
|
|
|
|
BOOL bGroupUndo(pSh->DoesGroupUndo());
|
|
|
|
pSh->DoGroupUndo(FALSE);
|
|
|
|
|
|
|
|
if( pSh->HasSelection() )
|
|
|
|
pSh->DelRight();
|
|
|
|
|
|
|
|
SwWait *pWait = 0;
|
|
|
|
|
|
|
|
{
|
|
|
|
ULONG i = 0;
|
|
|
|
do {
|
|
|
|
|
|
|
|
ImportDBEntry(pSh);
|
|
|
|
if( 10 == ++i )
|
|
|
|
pWait = new SwWait( *pSh->GetView().GetDocShell(), TRUE);
|
|
|
|
|
|
|
|
} while(ToNextMergeRecord());
|
|
|
|
}
|
|
|
|
|
|
|
|
pSh->DoGroupUndo(bGroupUndo);
|
|
|
|
pSh->EndUndo(0);
|
|
|
|
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:
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
2001-03-30 11:05:13 +00:00
|
|
|
inline String lcl_GetDBInsertMode( const SwDBData& rData )
|
2000-10-06 12:41:54 +00:00
|
|
|
{
|
2000-11-13 10:11:47 +00:00
|
|
|
return aEmptyStr;
|
|
|
|
#if 0
|
|
|
|
//JP 13.11.00: must be change to the new configuration
|
2000-10-06 12:41:54 +00:00
|
|
|
return SFX_APP()->GetIniManager()->Get( String::CreateFromAscii(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM( "DataBaseFormatInfo" )),
|
|
|
|
FALSE, FALSE, sDBName );
|
2000-11-13 10:11:47 +00:00
|
|
|
#endif
|
2000-10-06 12:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
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
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
|
2000-09-18 16:15:01 +00:00
|
|
|
Reference <XNameAccess> xCols = xColsSupp->getColumns();
|
2001-08-30 12:56:46 +00:00
|
|
|
String sFormatStr( lcl_GetDBInsertMode( *pImpl->pMergeData ));
|
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);
|
|
|
|
Reference< XPropertySet > xColumnProp = *(Reference< XPropertySet >*)aCol.getValue();;
|
|
|
|
if(xColumnProp.is())
|
|
|
|
{
|
|
|
|
SwDBFormatData aDBFormat;
|
|
|
|
String sInsert = GetDBField( xColumnProp, aDBFormat);
|
|
|
|
if( DB_SEP_SPACE == nSeparator )
|
|
|
|
sInsert += cSpace;
|
|
|
|
else if( DB_SEP_TAB == nSeparator)
|
|
|
|
sInsert += cTab;
|
|
|
|
pSh->Insert(sInsert);
|
|
|
|
if( DB_SEP_RETURN == nSeparator)
|
|
|
|
pSh->SplitNode();
|
|
|
|
else if(DB_SEP_NEWLINE == nSeparator)
|
|
|
|
pSh->InsertLineBreak();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Spalte nicht gefunden -> Fehler anzeigen
|
|
|
|
String sInsert = '?';
|
|
|
|
sInsert += sColumn;
|
|
|
|
sInsert += '?';
|
|
|
|
pSh->Insert(sInsert);
|
|
|
|
}
|
|
|
|
sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator);
|
|
|
|
}
|
|
|
|
pSh->SplitNode();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
String sStr;
|
|
|
|
Sequence<OUString> aColNames = xCols->getElementNames();
|
|
|
|
const OUString* pColNames = aColNames.getConstArray();
|
|
|
|
long nLength = aColNames.getLength();
|
|
|
|
for(long i = 0; i < nLength; i++)
|
|
|
|
{
|
|
|
|
Any aCol = xCols->getByName(pColNames[i]);
|
|
|
|
Reference< XPropertySet > xColumnProp = *(Reference< XPropertySet >*)aCol.getValue();;
|
|
|
|
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();
|
|
|
|
Reference< XDataSource> xSource;
|
2001-08-15 07:20:44 +00:00
|
|
|
SwDSParam* pParam = FindDSConnection(rDBName, FALSE);
|
|
|
|
Reference< XConnection> xConnection;
|
|
|
|
if(pParam && pParam->xConnection.is())
|
|
|
|
xConnection = pParam->xConnection;
|
|
|
|
else
|
|
|
|
xConnection = SwNewDBMgr::GetConnection(rDBName, xSource);
|
2000-09-18 16:15:01 +00:00
|
|
|
if(xConnection.is())
|
|
|
|
{
|
|
|
|
Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
|
|
|
|
if(xTSupplier.is())
|
|
|
|
{
|
|
|
|
Reference<XNameAccess> xTbls = xTSupplier->getTables();
|
|
|
|
Sequence<OUString> aTbls = xTbls->getElementNames();
|
|
|
|
const OUString* pTbls = aTbls.getConstArray();
|
|
|
|
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
|
|
|
}
|
|
|
|
Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
|
|
|
|
if(xQSupplier.is())
|
|
|
|
{
|
|
|
|
Reference<XNameAccess> xQueries = xQSupplier->getQueries();
|
|
|
|
Sequence<OUString> aQueries = xQueries->getElementNames();
|
|
|
|
const OUString* pQueries = aQueries.getConstArray();
|
|
|
|
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();
|
|
|
|
Reference< XDataSource> xSource;
|
2001-08-15 07:20:44 +00:00
|
|
|
SwDSParam* pParam = FindDSConnection(rDBName, FALSE);
|
|
|
|
Reference< XConnection> xConnection;
|
|
|
|
if(pParam && pParam->xConnection.is())
|
|
|
|
xConnection = pParam->xConnection;
|
|
|
|
else
|
|
|
|
xConnection = SwNewDBMgr::GetConnection(rDBName, xSource);
|
2000-09-18 16:15:01 +00:00
|
|
|
Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
|
|
|
|
if(xColsSupp.is())
|
|
|
|
{
|
|
|
|
Reference <XNameAccess> xCols = xColsSupp->getColumns();
|
|
|
|
const Sequence<OUString> aColNames = xCols->getElementNames();
|
|
|
|
const OUString* pColNames = aColNames.getConstArray();
|
|
|
|
for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
|
|
|
|
{
|
|
|
|
pListBox->InsertEntry(pColNames[nCol]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(TRUE);
|
|
|
|
}
|
2001-06-08 12:47:33 +00:00
|
|
|
/* -----------------------------08.06.01 15:11--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
BOOL SwNewDBMgr::GetColumnNames(ListBox* pListBox,
|
|
|
|
Reference< XConnection> xConnection,
|
|
|
|
const String& rTableName, BOOL bAppend)
|
|
|
|
{
|
|
|
|
if (!bAppend)
|
|
|
|
pListBox->Clear();
|
|
|
|
Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
|
|
|
|
if(xColsSupp.is())
|
|
|
|
{
|
|
|
|
Reference <XNameAccess> xCols = xColsSupp->getColumns();
|
|
|
|
const Sequence<OUString> aColNames = xCols->getElementNames();
|
|
|
|
const OUString* pColNames = aColNames.getConstArray();
|
|
|
|
for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
|
|
|
|
{
|
|
|
|
pListBox->InsertEntry(pColNames[nCol]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(TRUE);
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: CTOR
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
SwNewDBMgr::SwNewDBMgr() :
|
2001-08-30 12:56:46 +00:00
|
|
|
pImpl(new SwNewDBMgr_Impl),
|
2000-09-18 16:15:01 +00:00
|
|
|
bInMerge(FALSE),
|
|
|
|
nMergeType(DBMGR_INSERT),
|
|
|
|
bInitDBFields(FALSE)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
/* -----------------------------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
|
|
|
|
{
|
|
|
|
Reference<XComponent> xComp(pParam->xConnection, UNO_QUERY);
|
|
|
|
if(xComp.is())
|
|
|
|
xComp->dispose();
|
|
|
|
}
|
|
|
|
catch(RuntimeException& rEx)
|
|
|
|
{
|
|
|
|
//may be disposed already since multiple entries may have used the same connection
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-30 12:56:46 +00:00
|
|
|
delete pImpl->pDbtoolsClient;
|
|
|
|
delete pImpl;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Serienbrief drucken
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
BOOL SwNewDBMgr::MergePrint( SwView& rView,
|
|
|
|
SwPrtOptions& rOpt, SfxProgress& rProgress )
|
|
|
|
{
|
|
|
|
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
|
2001-08-30 12:56:46 +00:00
|
|
|
rOpt.nMergeCnt = pImpl->pMergeData && pImpl->pMergeData->aSelection.getLength();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-03-30 11:05:13 +00:00
|
|
|
SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
|
|
|
|
rOpt.bSinglePrtJobs = pModOpt->IsSinglePrintJob();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
SfxPrinter *pPrt = pSh->GetPrt();
|
|
|
|
Link aSfxSaveLnk = pPrt->GetEndPrintHdl();
|
|
|
|
if( rOpt.bSinglePrtJobs )
|
|
|
|
pPrt->SetEndPrintHdl( Link() );
|
|
|
|
|
|
|
|
BOOL bNewJob = FALSE,
|
|
|
|
bUserBreak = FALSE,
|
|
|
|
bRet = FALSE;
|
|
|
|
|
|
|
|
do {
|
|
|
|
{
|
|
|
|
pSh->ViewShell::UpdateFlds();
|
|
|
|
++rOpt.nMergeAct;
|
|
|
|
rView.SfxViewShell::Print( rProgress ); // ggf Basic-Macro ausfuehren
|
|
|
|
|
|
|
|
if( rOpt.bSinglePrtJobs && bRet )
|
|
|
|
{
|
|
|
|
//rOpt.bJobStartet = FALSE;
|
|
|
|
bRet = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pSh->Prt( rOpt, rProgress ) )
|
|
|
|
bRet = TRUE;
|
|
|
|
|
|
|
|
if( !pPrt->IsJobActive() )
|
|
|
|
{
|
|
|
|
bUserBreak = TRUE;
|
|
|
|
bRet = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( !rOpt.bSinglePrtJobs )
|
|
|
|
{
|
|
|
|
String& rJNm = (String&)rOpt.GetJobName();
|
|
|
|
rJNm.Erase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while( bSynchronizedDoc ? ExistsNextRecord() : ToNextMergeRecord());
|
|
|
|
|
|
|
|
if( rOpt.bSinglePrtJobs )
|
|
|
|
{
|
|
|
|
pSh->GetPrt()->SetEndPrintHdl( aSfxSaveLnk );
|
|
|
|
if ( !bUserBreak && !pSh->GetPrt()->IsJobActive() ) //Schon zu spaet?
|
|
|
|
aSfxSaveLnk.Call( pSh->GetPrt() );
|
|
|
|
}
|
|
|
|
|
|
|
|
rOpt.nMergeCnt = 0;
|
|
|
|
rOpt.nMergeAct = 0;
|
|
|
|
|
|
|
|
nMergeType = DBMGR_INSERT;
|
|
|
|
|
|
|
|
SwDocShell* pDocSh = rView.GetDocShell();
|
|
|
|
SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(pDocSh);
|
|
|
|
|
|
|
|
while (pTmpFrm) // Alle Views Invalidieren
|
|
|
|
{
|
|
|
|
SwView *pVw = PTR_CAST(SwView, pTmpFrm->GetViewShell());
|
|
|
|
if (pVw)
|
|
|
|
pVw->GetEditWin().Invalidate();
|
|
|
|
pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, pDocSh);
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Serienbrief als Mail versenden
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
BOOL SwNewDBMgr::MergeMailing(SwWrtShell* pSh)
|
|
|
|
{
|
|
|
|
//check if the doc is synchronized and contains at least one linked section
|
|
|
|
BOOL bSynchronizedDoc = pSh->IsLabelDoc() && pSh->GetSectionFmtCount() > 1;
|
|
|
|
BOOL bLoop = TRUE;
|
|
|
|
|
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
|
2000-09-18 16:15:01 +00:00
|
|
|
Reference <XNameAccess> xCols = xColsSupp->getColumns();
|
|
|
|
if(!xCols->hasByName(sEMailAddrFld))
|
|
|
|
return FALSE;
|
|
|
|
Any aCol = xCols->getByName(sEMailAddrFld);
|
|
|
|
Reference< XPropertySet > xColumnProp = *(Reference< XPropertySet >*)aCol.getValue();;
|
|
|
|
|
|
|
|
SfxDispatcher* pSfxDispatcher = pSh->GetView().GetViewFrame()->GetDispatcher();
|
|
|
|
if (!sSubject.Len()) // Kein leeres Subject wegen Automail (PB)
|
|
|
|
sSubject = ' ';
|
|
|
|
SfxStringItem aSubject(SID_MAIL_SUBJECT, sSubject);
|
|
|
|
SfxStringItem aText(SID_MAIL_TEXT, ' '); // Leerer Text ist nicht moeglich
|
|
|
|
SfxStringItem aAttached(SID_MAIL_ATTACH_FILE, sAttached);
|
|
|
|
SfxBoolItem aAttach(SID_MAIL_ATTACH, TRUE);
|
|
|
|
|
|
|
|
SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
|
|
|
|
BYTE nMailFmts = pModOpt->GetMailingFormats() | TXTFORMAT_ASCII; // Immer Ascii
|
|
|
|
SfxByteItem aTextFormats(SID_MAIL_TXTFORMAT, nMailFmts);
|
|
|
|
|
|
|
|
pSfxDispatcher->Execute( SID_SAVEDOC, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD);
|
|
|
|
if( !pSh->IsModified() )
|
|
|
|
{
|
|
|
|
// Beim Speichern wurde kein Abbruch gedrueckt
|
|
|
|
// neue DocShell erzeugen, alle gelinkten Bereiche embedden
|
|
|
|
// und unter temporaerem Namen wieder speichern.
|
|
|
|
String sTmpName;
|
|
|
|
const SfxFilter* pSfxFlt;
|
|
|
|
|
|
|
|
{
|
|
|
|
SfxMedium* pOrig = pSh->GetView().GetDocShell()->GetMedium();
|
2001-08-31 13:10:43 +00:00
|
|
|
String sMainURL( pOrig->GetURLObject().GetMainURL(
|
|
|
|
INetURLObject::NO_DECODE ));
|
|
|
|
pSfxFlt = SwIoSystem::GetFileFilter( sMainURL, ::aEmptyStr );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-08-02 07:30:38 +00:00
|
|
|
sTmpName = utl::TempFile::CreateTempName(0);
|
|
|
|
sTmpName = URIHelper::SmartRelToAbs(sTmpName);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
String sMain(sTmpName);
|
|
|
|
sal_Unicode cSlash = '/';
|
|
|
|
xub_StrLen nSlashPos = sMain.SearchBackward(cSlash);
|
|
|
|
sMain.Erase(nSlashPos);
|
|
|
|
::ucb::Content aNewContent( sMain, Reference< XCommandEnvironment > ());
|
|
|
|
Any aAny;
|
|
|
|
TransferInfo aInfo;
|
2001-08-02 07:30:38 +00:00
|
|
|
aInfo.NameClash = NameClash::ERROR;
|
2000-09-18 16:15:01 +00:00
|
|
|
aInfo.NewTitle = INetURLObject(sTmpName).GetName();
|
2001-08-31 13:10:43 +00:00
|
|
|
aInfo.SourceURL = sMainURL;
|
2000-09-18 16:15:01 +00:00
|
|
|
aInfo.MoveData = FALSE;
|
|
|
|
aAny <<= aInfo;
|
|
|
|
aNewContent.executeCommand( C2U( "transfer" ), aAny);
|
|
|
|
}
|
2001-08-02 07:30:38 +00:00
|
|
|
catch( Exception& rEx)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String sAddress;
|
|
|
|
ULONG nDocNo = 1;
|
|
|
|
bCancel = FALSE;
|
|
|
|
|
|
|
|
PrintMonitor aPrtMonDlg(&pSh->GetView().GetEditWin(), TRUE);
|
|
|
|
aPrtMonDlg.aDocName.SetText(pSh->GetView().GetDocShell()->GetTitle(22));
|
|
|
|
aPrtMonDlg.aCancel.SetClickHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
|
|
|
|
aPrtMonDlg.Show();
|
|
|
|
|
|
|
|
OfficeApplication* pOffApp = OFF_APP();
|
|
|
|
SfxRequest aReq( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, pOffApp->GetPool() );
|
|
|
|
aReq.AppendItem( SfxStringItem( SID_FILE_NAME, sTmpName ));
|
2001-03-01 11:18:58 +00:00
|
|
|
if(pSfxFlt)
|
|
|
|
aReq.AppendItem( SfxStringItem( SID_FILTER_NAME, pSfxFlt->GetName() ));
|
2000-09-18 16:15:01 +00:00
|
|
|
aReq.AppendItem( SfxBoolItem( SID_HIDDEN, TRUE ) );
|
|
|
|
aReq.AppendItem( SfxStringItem( SID_REFERER, String::CreateFromAscii(URL_PREFIX_PRIV_SOFFICE )));
|
|
|
|
|
|
|
|
pOffApp->ExecuteSlot( aReq, pOffApp->SfxApplication::GetInterface());
|
2001-08-02 07:30:38 +00:00
|
|
|
const SfxPoolItem* pReturnValue = aReq.GetReturnValue();
|
|
|
|
if(pReturnValue)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
// DocShell besorgen
|
2001-08-02 07:30:38 +00:00
|
|
|
SfxViewFrameItem* pVItem = (SfxViewFrameItem*)pReturnValue;
|
2000-09-18 16:15:01 +00:00
|
|
|
SwView* pView = (SwView*) pVItem->GetFrame()->GetViewShell();
|
|
|
|
SwWrtShell& rSh = pView->GetWrtShell();
|
|
|
|
pView->AttrChangedNotify( &rSh );//Damit SelectShell gerufen wird.
|
|
|
|
|
|
|
|
SwDoc* pDoc = rSh.GetDoc();
|
|
|
|
SwNewDBMgr* pOldDBMgr = pDoc->GetNewDBMgr();
|
|
|
|
pDoc->SetNewDBMgr( this );
|
|
|
|
pDoc->EmbedAllLinks();
|
|
|
|
String sTempStat(SW_RES(STR_DB_EMAIL));
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2001-06-29 07:10:35 +00:00
|
|
|
if(UIUNDO_DELETE_INVISIBLECNTNT == rSh.GetUndoIds())
|
|
|
|
rSh.Undo();
|
|
|
|
rSh.ViewShell::UpdateFlds();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-06-29 07:10:35 +00:00
|
|
|
// alle versteckten Felder/Bereiche entfernen
|
|
|
|
rSh.RemoveInvisibleContent();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-06-29 07:10:35 +00:00
|
|
|
SfxFrameItem aFrame( SID_DOCFRAME, pVItem->GetFrame() );
|
|
|
|
SwDBFormatData aDBFormat;
|
|
|
|
sAddress = GetDBField( xColumnProp, aDBFormat);
|
|
|
|
if (!sAddress.Len())
|
|
|
|
sAddress = '_';
|
|
|
|
|
|
|
|
String sStat(sTempStat);
|
|
|
|
sStat += ' ';
|
|
|
|
sStat += String::CreateFromInt32( nDocNo++ );
|
|
|
|
aPrtMonDlg.aPrintInfo.SetText(sStat);
|
|
|
|
aPrtMonDlg.aPrinter.SetText( sAddress );
|
|
|
|
|
|
|
|
// Rechenzeit fuer EMail-Monitor:
|
|
|
|
for (USHORT i = 0; i < 25; i++)
|
|
|
|
Application::Reschedule();
|
|
|
|
|
|
|
|
sAddress.Insert(String::CreateFromAscii("mailto:"), 0);
|
|
|
|
SfxStringItem aRecipient( SID_MAIL_RECIPIENT, sAddress );
|
|
|
|
|
|
|
|
const SfxPoolItem* pRet = pSfxDispatcher->Execute(
|
|
|
|
SID_MAIL_SENDDOC,
|
|
|
|
SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
|
|
|
|
&aRecipient, &aSubject, &aAttach, &aAttached,
|
|
|
|
&aText, &aTextFormats, &aFrame,
|
|
|
|
0L );
|
|
|
|
//this must be done here because pRet may be destroyed in Reschedule (DeleteOnIdle)
|
|
|
|
BOOL bBreak = pRet && !( (SfxBoolItem*)pRet )->GetValue();
|
|
|
|
|
|
|
|
// Rechenzeit fuer EMail-Monitor:
|
|
|
|
for (i = 0; i < 25; i++)
|
|
|
|
Application::Reschedule();
|
|
|
|
|
|
|
|
if ( bBreak )
|
|
|
|
break; // das Verschicken wurde unterbrochen
|
|
|
|
} while( !bCancel && (bSynchronizedDoc ? ExistsNextRecord() : ToNextMergeRecord()));
|
2000-09-18 16:15:01 +00:00
|
|
|
pDoc->SetNewDBMgr( pOldDBMgr );
|
|
|
|
pView->GetDocShell()->OwnerLock( FALSE );
|
|
|
|
|
|
|
|
}
|
2001-08-02 07:30:38 +00:00
|
|
|
// remove the temporary file
|
|
|
|
try
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-08-02 07:30:38 +00:00
|
|
|
::ucb::Content aTempContent(
|
|
|
|
sTmpName,
|
|
|
|
Reference< XCommandEnvironment > ());
|
|
|
|
aTempContent.executeCommand( C2U( "delete" ),
|
|
|
|
makeAny( sal_Bool( sal_True ) ) );
|
|
|
|
}
|
|
|
|
catch( Exception& rEx)
|
|
|
|
{
|
|
|
|
DBG_ERRORFILE( "Exception" );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
SW_MOD()->SetView(&pSh->GetView());
|
|
|
|
}
|
|
|
|
|
|
|
|
nMergeType = DBMGR_INSERT;
|
|
|
|
}
|
|
|
|
return bLoop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Serienbriefe als einzelne Dokumente speichern
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSh)
|
|
|
|
{
|
|
|
|
//check if the doc is synchronized and contains at least one linked section
|
|
|
|
BOOL bSynchronizedDoc = pSh->IsLabelDoc() && pSh->GetSectionFmtCount() > 1;
|
|
|
|
BOOL bLoop = TRUE;
|
|
|
|
|
|
|
|
Reference< XPropertySet > xColumnProp;
|
|
|
|
{
|
|
|
|
USHORT nColPos = 0;
|
|
|
|
BOOL bColumnName = sEMailAddrFld.Len() > 0;
|
|
|
|
|
|
|
|
if (bColumnName)
|
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
|
2000-09-18 16:15:01 +00:00
|
|
|
Reference <XNameAccess> xCols = xColsSupp->getColumns();
|
|
|
|
if(!xCols->hasByName(sEMailAddrFld))
|
|
|
|
return FALSE;
|
|
|
|
Any aCol = xCols->getByName(sEMailAddrFld);
|
|
|
|
xColumnProp = *(Reference< XPropertySet >*)aCol.getValue();;
|
|
|
|
}
|
|
|
|
|
|
|
|
SfxDispatcher* pSfxDispatcher = pSh->GetView().GetViewFrame()->GetDispatcher();
|
|
|
|
|
|
|
|
pSfxDispatcher->Execute( SID_SAVEDOC, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD);
|
|
|
|
if( !pSh->IsModified() )
|
|
|
|
{
|
|
|
|
// Beim Speichern wurde kein Abbruch gedrueckt
|
|
|
|
SfxMedium* pOrig = pSh->GetView().GetDocShell()->GetMedium();
|
2001-08-31 13:10:43 +00:00
|
|
|
String sOldName(pOrig->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ));
|
2000-09-18 16:15:01 +00:00
|
|
|
const SfxFilter* pSfxFlt = SwIoSystem::GetFileFilter(
|
|
|
|
sOldName, ::aEmptyStr );
|
|
|
|
String sAddress;
|
|
|
|
bCancel = FALSE;
|
|
|
|
|
|
|
|
PrintMonitor aPrtMonDlg(&pSh->GetView().GetEditWin());
|
|
|
|
aPrtMonDlg.aDocName.SetText(pSh->GetView().GetDocShell()->GetTitle(22));
|
|
|
|
|
|
|
|
aPrtMonDlg.aCancel.SetClickHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
|
|
|
|
aPrtMonDlg.Show();
|
|
|
|
|
|
|
|
SwDocShell *pDocSh = pSh->GetView().GetDocShell();
|
|
|
|
// Progress, um KeyInputs zu unterbinden
|
|
|
|
SfxProgress aProgress(pDocSh, ::aEmptyStr, 1);
|
|
|
|
|
|
|
|
// Alle Dispatcher sperren
|
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst(pDocSh);
|
|
|
|
while (pViewFrm)
|
|
|
|
{
|
|
|
|
pViewFrm->GetDispatcher()->Lock(TRUE);
|
|
|
|
pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pDocSh);
|
|
|
|
}
|
|
|
|
ULONG nDocNo = 1;
|
|
|
|
ULONG nCounter = 0;
|
|
|
|
String sExt( INetURLObject( sOldName ).GetExtension() );
|
2001-06-19 10:18:21 +00:00
|
|
|
sExt.InsertAscii(".", 0);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
{
|
|
|
|
String sPath(sSubject);
|
|
|
|
|
|
|
|
if( bColumnName )
|
|
|
|
{
|
|
|
|
SwDBFormatData aDBFormat;
|
|
|
|
sAddress = GetDBField( xColumnProp, aDBFormat);
|
|
|
|
if (!sAddress.Len())
|
|
|
|
sAddress = '_';
|
|
|
|
sPath += sAddress;
|
|
|
|
nCounter = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
INetURLObject aEntry(sPath);
|
|
|
|
String sLeading(aEntry.GetBase());
|
|
|
|
aEntry.removeSegment();
|
2001-08-31 13:10:43 +00:00
|
|
|
sPath = aEntry.GetMainURL( INetURLObject::NO_DECODE );
|
2000-11-06 08:30:33 +00:00
|
|
|
utl::TempFile aTemp(sLeading,&sExt,&sPath );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if( !aTemp.IsValid() )
|
|
|
|
{
|
|
|
|
ErrorHandler::HandleError( ERRCODE_IO_NOTSUPPORTED );
|
|
|
|
bLoop = FALSE;
|
|
|
|
bCancel = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-09 12:57:43 +00:00
|
|
|
INetURLObject aTempFile(aTemp.GetURL());
|
2000-09-18 16:15:01 +00:00
|
|
|
aPrtMonDlg.aPrinter.SetText( aTempFile.GetBase() );
|
|
|
|
String sStat(SW_RES(STR_STATSTR_LETTER)); // Brief
|
|
|
|
sStat += ' ';
|
|
|
|
sStat += String::CreateFromInt32( nDocNo++ );
|
|
|
|
aPrtMonDlg.aPrintInfo.SetText(sStat);
|
|
|
|
|
|
|
|
// Rechenzeit fuer Save-Monitor:
|
|
|
|
for (USHORT i = 0; i < 10; i++)
|
|
|
|
Application::Reschedule();
|
|
|
|
|
|
|
|
// Neues Dokument erzeugen und speichern
|
|
|
|
SfxObjectShellRef xDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL ));
|
|
|
|
SfxMedium* pMed = new SfxMedium( sOldName, STREAM_STD_READ, TRUE );
|
|
|
|
pMed->SetFilter( pSfxFlt );
|
|
|
|
|
|
|
|
if (xDocSh->DoLoad(pMed))
|
|
|
|
{
|
|
|
|
SwDoc* pDoc = ((SwDocShell*)(&xDocSh))->GetDoc();
|
|
|
|
SwNewDBMgr* pOldDBMgr = pDoc->GetNewDBMgr();
|
|
|
|
pDoc->SetNewDBMgr( this );
|
|
|
|
pDoc->UpdateFlds(0);
|
|
|
|
|
|
|
|
// alle versteckten Felder/Bereiche entfernen
|
|
|
|
pDoc->RemoveInvisibleContent();
|
|
|
|
|
2001-08-31 13:10:43 +00:00
|
|
|
SfxMedium* pDstMed = new SfxMedium(
|
|
|
|
aTempFile.GetMainURL( INetURLObject::NO_DECODE ),
|
|
|
|
STREAM_STD_READWRITE, TRUE );
|
2000-09-18 16:15:01 +00:00
|
|
|
pDstMed->SetFilter( pSfxFlt );
|
|
|
|
|
|
|
|
xDocSh->DoSaveAs(*pDstMed);
|
|
|
|
xDocSh->DoSaveCompleted(pDstMed);
|
|
|
|
if( xDocSh->GetError() )
|
|
|
|
{
|
|
|
|
// error message ??
|
|
|
|
ErrorHandler::HandleError( xDocSh->GetError() );
|
|
|
|
bCancel = TRUE;
|
|
|
|
bLoop = FALSE;
|
|
|
|
}
|
|
|
|
pDoc->SetNewDBMgr( pOldDBMgr );
|
|
|
|
}
|
|
|
|
xDocSh->DoClose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while( !bCancel && bSynchronizedDoc ? ExistsNextRecord() : ToNextMergeRecord());
|
|
|
|
// Alle Dispatcher freigeben
|
|
|
|
pViewFrm = SfxViewFrame::GetFirst(pDocSh);
|
|
|
|
while (pViewFrm)
|
|
|
|
{
|
|
|
|
pViewFrm->GetDispatcher()->Lock(FALSE);
|
|
|
|
pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pDocSh);
|
|
|
|
}
|
|
|
|
|
|
|
|
SW_MOD()->SetView(&pSh->GetView());
|
|
|
|
}
|
|
|
|
|
|
|
|
nMergeType = DBMGR_INSERT;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
Reference< XDataSource> xSource;
|
|
|
|
Reference< XConnection> xConnection;
|
|
|
|
sal_Bool bUseMergeData = sal_False;
|
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;
|
2001-06-08 12:47:33 +00:00
|
|
|
Reference<XChild> xChild(xConnection, UNO_QUERY);
|
|
|
|
if(xChild.is())
|
|
|
|
xSource = Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
|
|
|
|
bUseMergeData = sal_True;
|
|
|
|
}
|
|
|
|
if(!xConnection.is() || !xSource.is())
|
|
|
|
{
|
2001-08-15 07:20:44 +00:00
|
|
|
SwDSParam* pParam = FindDSConnection(rDBName, FALSE);
|
|
|
|
if(pParam && pParam->xConnection.is())
|
|
|
|
xConnection = pParam->xConnection;
|
|
|
|
else
|
|
|
|
xConnection = SwNewDBMgr::GetConnection(rDBName, xSource);
|
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
|
|
|
}
|
|
|
|
Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
|
|
|
|
if(xColsSupp.is())
|
|
|
|
{
|
2001-07-18 12:25:54 +00:00
|
|
|
Reference <XNameAccess> xCols;
|
|
|
|
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);
|
|
|
|
Reference< XPropertySet > xColumn;
|
|
|
|
aCol >>= xColumn;
|
|
|
|
nRet = GetColumnFmt(xSource, xConnection, xColumn, pNFmtr, nLanguage);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nRet = pNFmtr->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM );
|
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
/* -----------------------------07.06.01 15:43--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
ULONG SwNewDBMgr::GetColumnFmt( Reference< XDataSource> xSource,
|
|
|
|
Reference< XConnection> xConnection,
|
|
|
|
Reference< XPropertySet> xColumn,
|
|
|
|
SvNumberFormatter* pNFmtr,
|
|
|
|
long nLanguage )
|
|
|
|
{
|
|
|
|
//JP 12.01.99: ggfs. das NumberFormat im Doc setzen
|
|
|
|
ULONG nRet = 0;
|
|
|
|
|
|
|
|
if(!xSource.is())
|
|
|
|
{
|
|
|
|
Reference<XChild> xChild(xConnection, UNO_QUERY);
|
|
|
|
xSource = Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
|
|
|
|
}
|
|
|
|
if(xSource.is() && xConnection.is() && xColumn.is() && pNFmtr)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj( pNFmtr );
|
|
|
|
Reference< util::XNumberFormatsSupplier > xDocNumFmtsSupplier = pNumFmt;
|
|
|
|
Reference< XNumberFormats > xDocNumberFormats = xDocNumFmtsSupplier->getNumberFormats();
|
|
|
|
Reference< XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY);
|
|
|
|
|
|
|
|
String sLanguage, sCountry;
|
2001-03-30 11:05:13 +00:00
|
|
|
::ConvertLanguageToIsoNames( (USHORT)nLanguage, sLanguage, sCountry );
|
2000-09-18 16:15:01 +00:00
|
|
|
Locale aLocale;
|
|
|
|
aLocale.Language = sLanguage;
|
|
|
|
aLocale.Country = sCountry;
|
|
|
|
|
|
|
|
//get the number formatter of the data source
|
|
|
|
Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
|
|
|
|
Reference< XNumberFormats > xNumberFormats;
|
|
|
|
if(xSourceProps.is())
|
|
|
|
{
|
|
|
|
Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
|
|
|
|
if(aFormats.hasValue())
|
|
|
|
{
|
|
|
|
Reference<XNumberFormatsSupplier> xSuppl = *(Reference<util::XNumberFormatsSupplier>*) aFormats.getValue();
|
|
|
|
if(xSuppl.is())
|
|
|
|
{
|
|
|
|
xNumberFormats = xSuppl->getNumberFormats();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-08 12:47:33 +00:00
|
|
|
Any aFormat = xColumn->getPropertyValue(C2U("FormatKey"));
|
|
|
|
if(aFormat.hasValue())
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-06-08 12:47:33 +00:00
|
|
|
sal_Int32 nFmt;
|
|
|
|
aFormat >>= nFmt;
|
|
|
|
if(xNumberFormats.is())
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-06-08 12:47:33 +00:00
|
|
|
try
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-06-08 12:47:33 +00:00
|
|
|
Reference<XPropertySet> xNumProps = xNumberFormats->getByKey( nFmt );
|
|
|
|
Any aFormat = xNumProps->getPropertyValue(C2U("FormatString"));
|
|
|
|
Any aLocale = xNumProps->getPropertyValue(C2U("Locale"));
|
|
|
|
OUString sFormat;
|
|
|
|
aFormat >>= sFormat;
|
|
|
|
com::sun::star::lang::Locale aLoc;
|
|
|
|
aLocale >>= aLoc;
|
|
|
|
nFmt = xDocNumberFormats->queryKey( sFormat, aLoc, sal_False );
|
|
|
|
if(NUMBERFORMAT_ENTRY_NOT_FOUND == nFmt)
|
2000-09-18 16:15:01 +00:00
|
|
|
nFmt = xDocNumberFormats->addNew( sFormat, aLoc );
|
2001-06-08 12:47:33 +00:00
|
|
|
nRet = nFmt;
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("illegal number format key")
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2001-08-30 12:56:46 +00:00
|
|
|
nRet = 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;
|
|
|
|
Reference< XDataSource> xSource;
|
2001-08-15 07:20:44 +00:00
|
|
|
SwDSParam* pParam = FindDSConnection(rDBName, FALSE);
|
|
|
|
Reference< XConnection> xConnection;
|
|
|
|
if(pParam && pParam->xConnection.is())
|
|
|
|
xConnection = pParam->xConnection;
|
|
|
|
else
|
|
|
|
xConnection = SwNewDBMgr::GetConnection(rDBName, xSource);
|
2000-09-18 16:15:01 +00:00
|
|
|
Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
|
|
|
|
if(xColsSupp.is())
|
|
|
|
{
|
|
|
|
Reference <XNameAccess> xCols = xColsSupp->getColumns();
|
|
|
|
if(xCols->hasByName(rColNm))
|
|
|
|
{
|
|
|
|
Any aCol = xCols->getByName(rColNm);
|
|
|
|
Reference <XPropertySet> xCol = *(Reference <XPropertySet>*)aCol.getValue();
|
|
|
|
Any aType = xCol->getPropertyValue(C2S("Type"));
|
|
|
|
aType >>= nRet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -----------------------------03.07.00 17:12--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
Reference< sdbc::XConnection> SwNewDBMgr::GetConnection(const String& rDataSource,
|
|
|
|
Reference<XDataSource>& rxSource)
|
|
|
|
{
|
|
|
|
Reference< sdbc::XConnection> xConnection;
|
|
|
|
Reference<XNameAccess> xDBContext;
|
2000-10-20 13:18:07 +00:00
|
|
|
Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
|
2000-09-18 16:15:01 +00:00
|
|
|
if( xMgr.is() )
|
|
|
|
{
|
|
|
|
Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
|
|
|
|
xDBContext = Reference<XNameAccess>(xInstance, UNO_QUERY) ;
|
|
|
|
}
|
|
|
|
DBG_ASSERT(xDBContext.is(), "com.sun.star.sdb.DataBaseContext: service not available")
|
|
|
|
if(xDBContext.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if(xDBContext->hasByName(rDataSource))
|
|
|
|
{
|
2000-12-01 10:45:55 +00:00
|
|
|
Reference<XCompletedConnection> xComplConnection;
|
|
|
|
xDBContext->getByName(rDataSource) >>= xComplConnection;
|
|
|
|
rxSource = Reference<XDataSource>(xComplConnection, UNO_QUERY);
|
|
|
|
|
|
|
|
Reference< XInteractionHandler > xHandler(
|
|
|
|
xMgr->createInstance( C2U( "com.sun.star.sdb.InteractionHandler" )), UNO_QUERY);
|
|
|
|
xConnection = xComplConnection->connectWithCompletion( xHandler );
|
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 xConnection;
|
|
|
|
}
|
|
|
|
/* -----------------------------03.07.00 17:12--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
Reference< sdbcx::XColumnsSupplier> SwNewDBMgr::GetColumnSupplier(Reference<sdbc::XConnection> xConnection,
|
|
|
|
const String& rTableOrQuery,
|
|
|
|
BYTE eTableOrQuery)
|
|
|
|
{
|
|
|
|
Reference< sdbcx::XColumnsSupplier> xRet;
|
|
|
|
if(SW_DB_SELECT_QUERY != eTableOrQuery)
|
|
|
|
{
|
|
|
|
Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
|
|
|
|
if(xTSupplier.is())
|
|
|
|
{
|
|
|
|
Reference<XNameAccess> xTbls = xTSupplier->getTables();
|
|
|
|
if(xTbls->hasByName(rTableOrQuery))
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Any aTable = xTbls->getByName(rTableOrQuery);
|
|
|
|
Reference<XPropertySet> xPropSet = *(Reference<XPropertySet>*)aTable.getValue();
|
|
|
|
xRet = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
|
|
|
|
}
|
2000-12-18 09:12:48 +00:00
|
|
|
catch(Exception&){}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!xRet.is() && SW_DB_SELECT_QUERY != SW_DB_SELECT_TABLE)
|
|
|
|
{
|
|
|
|
Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
|
|
|
|
if(xQSupplier.is())
|
|
|
|
{
|
|
|
|
Reference<XNameAccess> xQueries = xQSupplier->getQueries();
|
|
|
|
if(xQueries->hasByName(rTableOrQuery))
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Any aQuery = xQueries->getByName(rTableOrQuery);
|
|
|
|
Reference<XPropertySet> xPropSet = *(Reference<XPropertySet>*)aQuery.getValue();
|
|
|
|
xRet = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
|
|
|
|
}
|
2000-12-18 09:12:48 +00:00
|
|
|
catch(Exception&){}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return xRet;
|
|
|
|
}
|
|
|
|
/* -----------------------------05.07.00 13:44--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
String SwNewDBMgr::GetDBField(Reference<XPropertySet> xColumnProps,
|
|
|
|
const SwDBFormatData& rDBFormatData,
|
|
|
|
double* pNumber)
|
|
|
|
{
|
|
|
|
Reference< XColumn > xColumn(xColumnProps, UNO_QUERY);
|
|
|
|
String sRet;
|
|
|
|
DBG_ASSERT(xColumn.is(), "SwNewDBMgr::::ImportDBField: illegal arguments")
|
|
|
|
if(!xColumn.is())
|
|
|
|
return sRet;
|
|
|
|
|
|
|
|
Any aType = xColumnProps->getPropertyValue(C2U("Type"));
|
|
|
|
sal_Int32 eDataType;
|
|
|
|
aType >>= eDataType;
|
|
|
|
switch(eDataType)
|
|
|
|
{
|
|
|
|
case DataType::CHAR:
|
|
|
|
case DataType::VARCHAR:
|
|
|
|
case DataType::LONGVARCHAR:
|
|
|
|
sRet = xColumn->getString();
|
|
|
|
break;
|
|
|
|
case DataType::BIT:
|
|
|
|
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
|
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
SwDbtoolsClient aClient;
|
|
|
|
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
|
|
|
double fVal = xColumn->getDouble();
|
|
|
|
if (pNumber)
|
|
|
|
*pNumber = fVal;
|
|
|
|
}
|
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
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
return rDataSource == (String)pImpl->pMergeData->sDataSource &&
|
|
|
|
rTableOrQuery == (String)pImpl->pMergeData->sCommand &&
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
if(pFound && pFound->xResultSet.is() && !pFound->bAfterSelection)
|
|
|
|
{
|
|
|
|
sal_Int32 nOldRow = pFound->xResultSet->getRow();
|
2000-09-18 16:15:01 +00:00
|
|
|
//position to the desired index
|
2001-07-10 12:51:01 +00:00
|
|
|
BOOL bMove = TRUE;
|
2000-09-18 16:15:01 +00:00
|
|
|
if(nOldRow != 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
|
|
|
}
|
|
|
|
if(nOldRow != 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,
|
|
|
|
String &rResult, double *pNumber, sal_uInt32 *pFormat)
|
|
|
|
{
|
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(
|
|
|
|
const String& rDataSource, const String& rCommand, sal_Int32 nCommandType)
|
|
|
|
{
|
|
|
|
SwDSParam* pFound = 0;
|
|
|
|
BOOL bRet = TRUE;
|
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;
|
|
|
|
if(!pParam || !pParam->xResultSet.is() || pParam->bEndOfDB)
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2001-07-10 12:51:01 +00:00
|
|
|
pParam->bEndOfDB = !pParam->xResultSet->absolute(
|
|
|
|
(ULONG)pParam->aSelection.getConstArray()[ pParam->nSelectionIndex++ ] );
|
|
|
|
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
|
|
|
|
{
|
2001-07-10 12:51:01 +00:00
|
|
|
pParam->bEndOfDB = !pParam->xResultSet->next();
|
|
|
|
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
|
|
|
{
|
|
|
|
DBG_ERROR("exception caught")
|
|
|
|
}
|
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
|
|
|
{
|
|
|
|
DBG_ERROR("exception caught")
|
|
|
|
}
|
|
|
|
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:50--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
void lcl_ExtractMembers(const String& rDBName, String& sSource, String& sTable, String& sStatement)
|
|
|
|
{
|
|
|
|
sSource = rDBName.GetToken(0, DB_DELIM);
|
|
|
|
sTable = rDBName.GetToken(0).GetToken(1, DB_DELIM);
|
|
|
|
sal_uInt16 nPos;
|
|
|
|
if ((nPos = rDBName.Search(';')) != STRING_NOTFOUND)
|
|
|
|
sStatement = rDBName.Copy(nPos + 1);
|
|
|
|
}
|
|
|
|
/* -----------------------------17.07.00 14:17--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2001-03-30 11:05:13 +00:00
|
|
|
BOOL SwNewDBMgr::OpenDataSource(const String& rDataSource, const String& rTableOrQuery, sal_Int32 nCommandType)
|
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);
|
2000-09-18 16:15:01 +00:00
|
|
|
Reference< XDataSource> xSource;
|
|
|
|
if(pFound->xResultSet.is())
|
|
|
|
return TRUE;
|
2001-08-15 07:20:44 +00:00
|
|
|
SwDSParam* pParam = FindDSConnection(rDataSource, FALSE);
|
|
|
|
Reference< XConnection> xConnection;
|
|
|
|
if(pParam && pParam->xConnection.is())
|
|
|
|
pFound->xConnection = pParam->xConnection;
|
|
|
|
else
|
|
|
|
pFound->xConnection = SwNewDBMgr::GetConnection(rDataSource, xSource );
|
2000-09-18 16:15:01 +00:00
|
|
|
if(pFound->xConnection.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2000-12-21 13:38:05 +00:00
|
|
|
Reference< sdbc::XDatabaseMetaData > xMetaData = pFound->xConnection->getMetaData();
|
|
|
|
pFound->bScrollable = xMetaData
|
2000-09-18 16:15:01 +00:00
|
|
|
->supportsResultSetType((sal_Int32)ResultSetType::SCROLL_INSENSITIVE);
|
|
|
|
pFound->xStatement = pFound->xConnection->createStatement();
|
2001-03-30 11:05:13 +00:00
|
|
|
OUString aQuoteChar = xMetaData->getIdentifierQuoteString();
|
|
|
|
OUString sStatement(C2U("SELECT * FROM "));
|
|
|
|
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------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
Reference< XConnection> SwNewDBMgr::RegisterConnection(OUString& rDataSource)
|
|
|
|
{
|
|
|
|
SwDSParam* pFound = SwNewDBMgr::FindDSConnection(rDataSource, TRUE);
|
|
|
|
Reference< XDataSource> xSource;
|
|
|
|
if(!pFound->xConnection.is())
|
|
|
|
pFound->xConnection = SwNewDBMgr::GetConnection(rDataSource, xSource );
|
|
|
|
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
|
|
|
{
|
|
|
|
sal_uInt32 nRet = -1;
|
|
|
|
//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
|
|
|
|
{
|
|
|
|
nRet = pFound->xResultSet->getRow();
|
|
|
|
}
|
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)
|
|
|
|
{
|
2001-08-15 07:20:44 +00:00
|
|
|
//do nothing - keep all connections until the destructor
|
|
|
|
// for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++)
|
|
|
|
// {
|
|
|
|
// SwDSParam* pParam = aDataSourceParams[nPos];
|
2001-08-30 12:56:46 +00:00
|
|
|
// if(bIncludingMerge || pParam != pImpl->pMergeData)
|
2001-08-15 07:20:44 +00:00
|
|
|
// {
|
|
|
|
// pParam->xResultSet = 0;
|
|
|
|
// pParam->xStatement = 0;
|
|
|
|
// pParam->xConnection = 0;
|
|
|
|
// }
|
|
|
|
// }
|
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
|
|
|
{
|
|
|
|
SwDSParam* pFound = 0;
|
|
|
|
for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++)
|
|
|
|
{
|
|
|
|
SwDSParam* pParam = aDataSourceParams[nPos];
|
2001-03-30 11:05:13 +00:00
|
|
|
if(rData.sDataSource == pParam->sDataSource &&
|
|
|
|
rData.sCommand == pParam->sCommand &&
|
|
|
|
(rData.nCommandType == -1 || rData.nCommandType == pParam->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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pFound;
|
|
|
|
}
|
2001-08-15 07:20:44 +00:00
|
|
|
/* -----------------------------14.08.2001 10:27------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
SwDSParam* SwNewDBMgr::FindDSConnection(const OUString& rDataSource, BOOL bCreate)
|
|
|
|
{
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
return pFound;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
/* -----------------------------17.07.00 14:31--------------------------------
|
|
|
|
rDBName: <Source> + DB_DELIM + <Table>; + <Statement>
|
|
|
|
---------------------------------------------------------------------------*/
|
2001-03-30 11:05:13 +00:00
|
|
|
void SwNewDBMgr::AddDSData(const SwDBData& rData, long nSelStart, long nSelEnd)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-03-30 11:05:13 +00:00
|
|
|
SwDSParam* pFound = FindDSData(rData, TRUE);
|
|
|
|
if(nSelStart > 0)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-03-30 11:05:13 +00:00
|
|
|
if(nSelEnd < nSelStart)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
sal_uInt32 nZw = nSelEnd;
|
|
|
|
nSelEnd = nSelStart;
|
|
|
|
nSelStart = nZw;
|
|
|
|
}
|
|
|
|
|
2001-03-30 11:05:13 +00:00
|
|
|
pFound->aSelection.realloc(nSelEnd - nSelStart + 1);
|
|
|
|
sal_Int32* pSelection = pFound->aSelection.getArray();
|
|
|
|
sal_Int32 nIdx = 0;
|
|
|
|
for (long i = nSelStart; i <= nSelEnd; i++, nIdx++)
|
|
|
|
pSelection[nIdx] = i;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2001-03-30 11:05:13 +00:00
|
|
|
else
|
|
|
|
pFound->aSelection.realloc(0);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
/* -----------------------------17.07.00 14:31--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2001-03-30 11:05:13 +00:00
|
|
|
void SwNewDBMgr::GetDSSelection(const SwDBData& rData, long& rSelStart, long& rSelEnd)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2001-03-30 11:05:13 +00:00
|
|
|
SwDSParam* pFound = FindDSData(rData, FALSE);
|
|
|
|
if(!pFound || !pFound->aSelection.getLength())
|
2000-09-18 16:15:01 +00:00
|
|
|
rSelStart = -1L;
|
|
|
|
else
|
|
|
|
{
|
2001-03-30 11:05:13 +00:00
|
|
|
rSelStart = pFound->aSelection.getConstArray()[0];
|
|
|
|
rSelEnd = pFound->aSelection.getConstArray()[pFound->aSelection.getLength() - 1];
|
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--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
Sequence<OUString> SwNewDBMgr::GetExistingDatabaseNames()
|
|
|
|
{
|
|
|
|
Reference<XNameAccess> xDBContext;
|
2000-10-20 13:18:07 +00:00
|
|
|
Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
|
2000-09-18 16:15:01 +00:00
|
|
|
if( xMgr.is() )
|
|
|
|
{
|
|
|
|
Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
|
|
|
|
xDBContext = Reference<XNameAccess>(xInstance, UNO_QUERY) ;
|
|
|
|
}
|
|
|
|
if(xDBContext.is())
|
|
|
|
{
|
|
|
|
return xDBContext->getElementNames();
|
|
|
|
}
|
|
|
|
return Sequence<OUString>();
|
|
|
|
}
|
2000-11-13 07:32:00 +00:00
|
|
|
/* -----------------------------10.11.00 17:10--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh,
|
|
|
|
const Sequence<PropertyValue>& rProperties)
|
|
|
|
{
|
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 ;
|
2000-11-13 07:32:00 +00:00
|
|
|
OUString sDataSource, sDataTableOrQuery;
|
2001-06-19 06:42:09 +00:00
|
|
|
Sequence<Any> aSelection;
|
2000-11-13 07:32:00 +00:00
|
|
|
BOOL bHasSelectionProperty = FALSE;
|
|
|
|
sal_Int32 nSelectionPos = 0;
|
2001-06-06 05:20:21 +00:00
|
|
|
sal_Int32 nResultSetIdx = -1;
|
2000-11-13 07:32:00 +00:00
|
|
|
sal_Int16 nCmdType = CommandType::TABLE;
|
|
|
|
const PropertyValue* pValues = rProperties.getConstArray();
|
2001-06-08 12:47:33 +00:00
|
|
|
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(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-06 05:20:21 +00:00
|
|
|
else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCursor)))
|
|
|
|
nResultSetIdx = nPos;
|
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
|
|
|
}
|
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
|
|
|
Sequence<sal_Int32> aDlgSelection(aSelection.getLength());
|
|
|
|
if(aSelection.getLength())
|
|
|
|
{
|
|
|
|
sal_Int32* pDlgSelection = aDlgSelection.getArray();
|
|
|
|
const Any* pGridSelection = aSelection.getConstArray();
|
|
|
|
for(sal_Int32 nSel = 0; nSel < aSelection.getLength(); nSel++)
|
|
|
|
pGridSelection[nSel] >>= pDlgSelection[nSel];
|
|
|
|
|
|
|
|
}
|
2001-08-30 12:56:46 +00:00
|
|
|
pImpl->pMergeDialog = new SwMailMergeDlg(
|
2000-11-13 07:32:00 +00:00
|
|
|
&rSh.GetView().GetViewFrame()->GetWindow(), rSh,
|
|
|
|
sDataSource,
|
|
|
|
sDataTableOrQuery,
|
2001-03-07 12:41:22 +00:00
|
|
|
nCmdType,
|
2001-06-08 12:47:33 +00:00
|
|
|
xConnection,
|
2001-06-19 06:42:09 +00:00
|
|
|
bHasSelectionProperty ? &aDlgSelection : 0 );
|
2000-11-13 07:32:00 +00:00
|
|
|
|
2001-08-30 12:56:46 +00:00
|
|
|
if(pImpl->pMergeDialog->Execute() == RET_OK)
|
2000-11-13 07:32:00 +00:00
|
|
|
{
|
2001-08-30 12:56:46 +00:00
|
|
|
SetMergeType( pImpl->pMergeDialog->GetMergeType() );
|
2000-11-13 07:32:00 +00:00
|
|
|
|
|
|
|
Sequence<PropertyValue> aNewProperties = rProperties;
|
|
|
|
if(!bHasSelectionProperty)
|
|
|
|
{
|
|
|
|
nSelectionPos = rProperties.getLength();
|
|
|
|
aNewProperties.realloc(rProperties.getLength() + 1);
|
2001-06-06 05:20:21 +00:00
|
|
|
aNewProperties[nSelectionPos].Name = C2U("Selection");
|
|
|
|
}
|
2001-08-30 12:56:46 +00:00
|
|
|
aNewProperties[nSelectionPos].Value <<= pImpl->pMergeDialog->GetSelection();
|
2001-06-06 05:20:21 +00:00
|
|
|
|
2001-08-30 12:56:46 +00:00
|
|
|
Reference<XResultSet> xResSet = pImpl->pMergeDialog->GetResultSet();
|
2001-06-06 05:20:21 +00:00
|
|
|
if(xResSet.is())
|
|
|
|
{
|
|
|
|
if(nResultSetIdx < 0)
|
|
|
|
{
|
|
|
|
nResultSetIdx = aNewProperties.getLength();
|
|
|
|
aNewProperties.realloc(nResultSetIdx + 1);
|
|
|
|
aNewProperties[nResultSetIdx].Name = C2U("Cursor");
|
|
|
|
}
|
|
|
|
aNewProperties[nResultSetIdx].Value <<= xResSet;
|
2000-11-13 07:32:00 +00:00
|
|
|
}
|
|
|
|
OFF_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, rSh.GetView().GetViewFrame()->GetObjectShell()));
|
|
|
|
MergeNew(GetMergeType(),
|
|
|
|
rSh,
|
|
|
|
aNewProperties);
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
OUString sDataSource, sDataTableOrQuery;
|
|
|
|
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();
|
2001-06-08 12:47:33 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
|
2001-06-08 12:47:33 +00:00
|
|
|
Reference<XDataSource> xSource;
|
|
|
|
Reference<XChild> xChild(xConnection, UNO_QUERY);
|
|
|
|
if(xChild.is())
|
|
|
|
xSource = Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
|
|
|
|
if(!xSource.is())
|
2001-08-30 12:56:46 +00:00
|
|
|
xSource = GetDbtoolsClient().getDataSource(sDataSource, xMgr);
|
2000-11-13 07:32:00 +00:00
|
|
|
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
|
|
|
|
|
|
|
SwInsertDBColAutoPilot *pDlg = new SwInsertDBColAutoPilot(
|
|
|
|
rSh.GetView(),
|
|
|
|
xSource,
|
|
|
|
xColSupp,
|
|
|
|
aDBData );
|
|
|
|
if( RET_OK == pDlg->Execute() )
|
|
|
|
{
|
|
|
|
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
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
SwDbtoolsClient& SwNewDBMgr::GetDbtoolsClient()
|
|
|
|
{
|
|
|
|
if(!pImpl->pDbtoolsClient)
|
|
|
|
pImpl->pDbtoolsClient = new SwDbtoolsClient;
|
|
|
|
return *pImpl->pDbtoolsClient;
|
|
|
|
}
|