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

2991 lines
119 KiB
C++
Raw Normal View History

2000-09-18 16:15:01 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 16:15:01 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:15:01 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 16:15:01 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 16:15:01 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
2000-09-18 16:15:01 +00:00
#if STLPORT_VERSION>=321
#include <cstdarg>
#endif
#include <stdio.h>
#include <unotxdoc.hxx>
#include <com/sun/star/text/NotePrintMode.hpp>
#include <sfx2/app.hxx>
2000-11-13 07:32:00 +00:00
#include <com/sun/star/sdb/CommandType.hpp>
#include <com/sun/star/sdb/XDocumentDataSource.hpp>
2000-10-27 10:26:20 +00:00
#include <com/sun/star/frame/XComponentLoader.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/util/XNumberFormatter.hpp>
2000-12-01 10:45:55 +00:00
#include <com/sun/star/sdb/XCompletedConnection.hpp>
#include <com/sun/star/sdb/XCompletedExecution.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/text/MailMergeEvent.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
#include <com/sun/star/uno/XNamingService.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <sfx2/fcontnr.hxx>
#include <sfx2/filedlghelper.hxx>
2000-10-27 10:26:20 +00:00
#include <sfx2/viewfrm.hxx>
#include <dbconfig.hxx>
#include <swdbtoolsclient.hxx>
#include <pagedesc.hxx>
2000-09-18 16:15:01 +00:00
#include <vcl/lstbox.hxx>
2000-11-06 08:30:33 +00:00
#include <unotools/tempfile.hxx>
#include <unotools/pathoptions.hxx>
#include <svl/urihelper.hxx>
2000-09-18 16:15:01 +00:00
#ifndef _SVSTDARR_HXX
#define _SVSTDARR_STRINGSDTOR
#include <svl/svstdarr.hxx>
2000-09-18 16:15:01 +00:00
#endif
#include <svl/zforlist.hxx>
#include <svl/zformat.hxx>
#include <svl/stritem.hxx>
#include <svl/eitem.hxx>
2009-08-14 13:56:56 +00:00
#include <vcl/oldprintadaptor.hxx>
2000-09-18 16:15:01 +00:00
#include <sfx2/docfile.hxx>
#include <sfx2/progress.hxx>
#include <sfx2/dispatch.hxx>
2009-12-15 21:55:40 +01:00
#include <svl/mailenum.hxx>
2002-11-29 11:14:12 +00:00
#include <cmdid.h>
2000-09-18 16:15:01 +00:00
#include <swmodule.hxx>
#include <view.hxx>
#include <docsh.hxx>
#include <edtwin.hxx>
#include <wrtsh.hxx>
#include <fldbas.hxx>
#include <initui.hxx>
#include <swundo.hxx>
#include <flddat.hxx>
#include <modcfg.hxx>
#include <swprtopt.hxx>
#include <shellio.hxx>
#include <dbui.hxx>
#include <dbmgr.hxx>
#include <doc.hxx>
#include <swwait.hxx>
#include <swunohelper.hxx>
2000-09-18 16:15:01 +00:00
#include <dbui.hrc>
#include <globals.hrc>
#include <statstr.hrc>
#include <mmconfigitem.hxx>
2000-09-18 16:15:01 +00:00
#include <sfx2/request.hxx>
#include <hintids.hxx>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/sdbc/XRowSet.hpp>
2000-09-18 16:15:01 +00:00
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
#include <com/sun/star/sdb/XColumn.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/ResultSetType.hpp>
#include <com/sun/star/mail/MailAttachment.hpp>
2000-10-20 13:18:07 +00:00
#include <comphelper/processfactory.hxx>
#include <comphelper/types.hxx>
#include <comphelper/property.hxx>
#include <mailmergehelper.hxx>
#include <maildispatcher.hxx>
2010-01-13 22:25:07 +01:00
#include <svtools/htmlcfg.hxx>
#include <i18npool/mslangid.hxx>
2000-09-18 16:15:01 +00:00
#include <com/sun/star/util/XNumberFormatTypes.hpp>
#include <editeng/langitem.hxx>
#include <svl/numuno.hxx>
2000-11-13 07:32:00 +00:00
#include <unomailmerge.hxx>
2000-11-13 07:32:00 +00:00
#include <sfx2/event.hxx>
#include <vcl/msgbox.hxx>
#include <svx/dataaccessdescriptor.hxx>
#include <vos/mutex.hxx>
#include <rtl/textenc.h>
#include <ndindex.hxx>
#include <pam.hxx>
#include <swcrsr.hxx>
#include <swevent.hxx>
#include <osl/file.hxx>
#include <swabstdlg.hxx>
#include <fmthdft.hxx>
#include <dbui.hrc>
#include <envelp.hrc>
#include <memory>
#include <vector>
#include <unomid.h>
2000-09-18 16:15:01 +00:00
using namespace ::osl;
using namespace ::svx;
2000-10-27 10:26:20 +00:00
using namespace ::com::sun::star;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::ui::dialogs;
2000-09-18 16:15:01 +00:00
#define DB_SEP_SPACE 0
#define DB_SEP_TAB 1
#define DB_SEP_RETURN 2
#define DB_SEP_NEWLINE 3
SV_IMPL_PTRARR(SwDSParamArr, SwDSParamPtr);
const sal_Char cCursor[] = "Cursor";
const sal_Char cCommand[] = "Command";
const sal_Char cCommandType[] = "CommandType";
const sal_Char cDataSourceName[] = "DataSourceName";
const sal_Char cSelection[] = "Selection";
const sal_Char cActiveConnection[] = "ActiveConnection";
2000-09-18 16:15:01 +00:00
// -----------------------------------------------------------------------------
// Use nameless namespace to avoid to rubbish the global namespace
// -----------------------------------------------------------------------------
namespace
{
bool lcl_getCountFromResultSet( sal_Int32& rCount, const uno::Reference<XResultSet>& xResultSet )
{
uno::Reference<XPropertySet> xPrSet(xResultSet, UNO_QUERY);
if(xPrSet.is())
{
try
{
sal_Bool bFinal = sal_False;
Any aFinal = xPrSet->getPropertyValue(C2U("IsRowCountFinal"));
aFinal >>= bFinal;
if(!bFinal)
{
xResultSet->last();
xResultSet->first();
}
Any aCount = xPrSet->getPropertyValue(C2U("RowCount"));
if( aCount >>= rCount )
return true;
}
catch(Exception&)
{
}
}
return false;
}
// #122799# copy compatibility options
void lcl_CopyCompatibilityOptions( SwWrtShell& rSourceShell, SwWrtShell& rTargetShell)
{
IDocumentSettingAccess* pIDsa = rSourceShell.getIDocumentSettingAccess();
rTargetShell.SetParaSpaceMax( pIDsa->get(IDocumentSettingAccess::PARA_SPACE_MAX));
rTargetShell.SetParaSpaceMaxAtPages(pIDsa->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES));
rTargetShell.SetTabCompat( pIDsa->get(IDocumentSettingAccess::TAB_COMPAT));
rTargetShell.SetAddExtLeading( pIDsa->get(IDocumentSettingAccess::ADD_EXT_LEADING));
rTargetShell.SetUseVirDev( pIDsa->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE));
rTargetShell.SetAddParaSpacingToTableCells( pIDsa->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS));
rTargetShell.SetUseFormerLineSpacing( pIDsa->get(IDocumentSettingAccess::OLD_LINE_SPACING));
rTargetShell.SetUseFormerObjectPositioning( pIDsa->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS));
rTargetShell.SetConsiderWrapOnObjPos( pIDsa->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION));
rTargetShell.SetUseFormerTextWrapping( pIDsa->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING));
}
}
class SwConnectionDisposedListener_Impl : public cppu::WeakImplHelper1
< lang::XEventListener >
{
SwNewDBMgr& rDBMgr;
virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
public:
SwConnectionDisposedListener_Impl(SwNewDBMgr& rMgr);
~SwConnectionDisposedListener_Impl();
};
2010-10-11 17:38:56 -05:00
struct SwNewDBMgr_Impl
{
SwDSParam* pMergeData;
AbstractMailMergeDlg* pMergeDialog;
uno::Reference<lang::XEventListener> xDisposeListener;
SwNewDBMgr_Impl(SwNewDBMgr& rDBMgr)
:pMergeData(0)
,pMergeDialog(0)
,xDisposeListener(new SwConnectionDisposedListener_Impl(rDBMgr))
{}
};
void lcl_InitNumberFormatter(SwDSParam& rParam, uno::Reference<XDataSource> xSource)
{
uno::Reference<XMultiServiceFactory> xMgr = ::comphelper::getProcessServiceFactory();
if( xMgr.is() )
{
uno::Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.util.NumberFormatter" ));
rParam.xFormatter = uno::Reference<util::XNumberFormatter>(xInstance, UNO_QUERY) ;
}
if(!xSource.is())
xSource = SwNewDBMgr::getDataSourceAsParent(rParam.xConnection, rParam.sDataSource);
uno::Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
if(xSourceProps.is())
{
Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
if(aFormats.hasValue())
{
uno::Reference<XNumberFormatsSupplier> xSuppl;
aFormats >>= xSuppl;
if(xSuppl.is())
{
uno::Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
Any aNull = xSettings->getPropertyValue(C2U("NullDate"));
aNull >>= rParam.aNullDate;
if(rParam.xFormatter.is())
rParam.xFormatter->attachNumberFormatsSupplier(xSuppl);
}
}
}
}
2000-09-18 16:15:01 +00:00
BOOL lcl_MoveAbsolute(SwDSParam* pParam, long nAbsPos)
{
BOOL bRet = FALSE;
try
{
if(pParam->bScrollable)
{
bRet = pParam->xResultSet->absolute( nAbsPos );
}
else
{
DBG_ERROR("no absolute positioning available");
2000-09-18 16:15:01 +00:00
}
}
catch(Exception aExcept)
{
}
return bRet;
}
BOOL lcl_GetColumnCnt(SwDSParam* pParam,
const String& rColumnName, long nLanguage, String& rResult, double* pNumber)
{
uno::Reference< XColumnsSupplier > xColsSupp( pParam->xResultSet, UNO_QUERY );
uno::Reference<XNameAccess> xCols;
try
{
xCols = xColsSupp->getColumns();
}
catch( lang::DisposedException& )
{
}
if(!xCols.is() || !xCols->hasByName(rColumnName))
2000-09-18 16:15:01 +00:00
return FALSE;
Any aCol = xCols->getByName(rColumnName);
uno::Reference< XPropertySet > xColumnProps;
aCol >>= xColumnProps;
2000-09-18 16:15:01 +00:00
SwDBFormatData aFormatData;
if(!pParam->xFormatter.is())
{
uno::Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(
pParam->xConnection,pParam->sDataSource);
lcl_InitNumberFormatter(*pParam, xSource );
}
2000-09-18 16:15:01 +00:00
aFormatData.aNullDate = pParam->aNullDate;
aFormatData.xFormatter = pParam->xFormatter;
MsLangId::convertLanguageToLocale( (LanguageType)nLanguage, aFormatData.aLocale );
2000-09-18 16:15:01 +00:00
rResult = SwNewDBMgr::GetDBField( xColumnProps, aFormatData, pNumber);
return TRUE;
};
2010-10-11 17:38:56 -05:00
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Beschreibung: Daten importieren
--------------------------------------------------------------------*/
BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc )
2000-11-13 07:32:00 +00:00
{
SetMergeType( rMergeDesc.nMergeType );
2000-11-13 07:32:00 +00:00
DBG_ASSERT(!bInMerge && !pImpl->pMergeData, "merge already activated!");
2000-11-13 07:32:00 +00:00
SwDBData aData;
aData.nCommandType = CommandType::TABLE;
uno::Reference<XResultSet> xResSet;
2001-06-26 13:35:16 +00:00
Sequence<Any> aSelection;
uno::Reference< XConnection> xConnection;
aData.sDataSource = rMergeDesc.rDescriptor.getDataSource();
rMergeDesc.rDescriptor[daCommand] >>= aData.sCommand;
rMergeDesc.rDescriptor[daCommandType] >>= aData.nCommandType;
if ( rMergeDesc.rDescriptor.has(daCursor) )
rMergeDesc.rDescriptor[daCursor] >>= xResSet;
if ( rMergeDesc.rDescriptor.has(daSelection) )
rMergeDesc.rDescriptor[daSelection] >>= aSelection;
if ( rMergeDesc.rDescriptor.has(daConnection) )
rMergeDesc.rDescriptor[daConnection] >>= xConnection;
if(!aData.sDataSource.getLength() || !aData.sCommand.getLength() || !xResSet.is())
2000-11-13 07:32:00 +00:00
{
return FALSE;
}
pImpl->pMergeData = new SwDSParam(aData, xResSet, aSelection);
SwDSParam* pTemp = FindDSData(aData, FALSE);
if(pTemp)
*pTemp = *pImpl->pMergeData;
else
{
//#94779# calls from the calculator may have added a connection with an invalid commandtype
//"real" data base connections added here have to re-use the already available
//DSData and set the correct CommandType
SwDBData aTempData(aData);
aData.nCommandType = -1;
2001-11-30 12:09:09 +00:00
pTemp = FindDSData(aData, FALSE);
if(pTemp)
*pTemp = *pImpl->pMergeData;
else
{
SwDSParam* pInsert = new SwDSParam(*pImpl->pMergeData);
aDataSourceParams.Insert(pInsert, aDataSourceParams.Count());
try
{
uno::Reference<XComponent> xComponent(pInsert->xConnection, UNO_QUERY);
if(xComponent.is())
xComponent->addEventListener(pImpl->xDisposeListener);
}
catch(Exception&)
{
}
}
}
if(!pImpl->pMergeData->xConnection.is())
pImpl->pMergeData->xConnection = xConnection;
// add an XEventListener
try{
//set to start position
if(pImpl->pMergeData->aSelection.getLength())
{
sal_Int32 nPos = 0;
pImpl->pMergeData->aSelection.getConstArray()[ pImpl->pMergeData->nSelectionIndex++ ] >>= nPos;
pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->absolute( nPos );
pImpl->pMergeData->CheckEndOfDB();
if(pImpl->pMergeData->nSelectionIndex >= pImpl->pMergeData->aSelection.getLength())
pImpl->pMergeData->bEndOfDB = TRUE;
}
else
{
pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->first();
pImpl->pMergeData->CheckEndOfDB();
}
}
catch(Exception&)
{
pImpl->pMergeData->bEndOfDB = TRUE;
pImpl->pMergeData->CheckEndOfDB();
DBG_ERROR("exception in MergeNew()");
}
uno::Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,aData.sDataSource);
lcl_InitNumberFormatter(*pImpl->pMergeData, xSource);
2000-11-13 07:32:00 +00:00
rMergeDesc.rSh.ChgDBData(aData);
2000-11-13 07:32:00 +00:00
bInMerge = TRUE;
if (IsInitDBFields())
{
// Bei Datenbankfeldern ohne DB-Name DB-Name von Dok einsetzen
SvStringsDtor aDBNames(1, 1);
aDBNames.Insert( new String(), 0);
SwDBData aInsertData = rMergeDesc.rSh.GetDBData();
String sDBName = aInsertData.sDataSource;
sDBName += DB_DELIM;
sDBName += (String)aInsertData.sCommand;
sDBName += DB_DELIM;
sDBName += String::CreateFromInt32(aInsertData.nCommandType);
rMergeDesc.rSh.ChangeDBFields( aDBNames, sDBName);
2000-11-13 07:32:00 +00:00
SetInitDBFields(FALSE);
}
BOOL bRet = TRUE;
switch(rMergeDesc.nMergeType)
2000-11-13 07:32:00 +00:00
{
case DBMGR_MERGE:
bRet = Merge(&rMergeDesc.rSh); // Mischen
2000-11-13 07:32:00 +00:00
break;
2009-09-01 08:22:04 +00:00
case DBMGR_MERGE_MAILMERGE: // printing merge from 'old' merge dialog or from UNO-component
2000-11-13 07:32:00 +00:00
case DBMGR_MERGE_MAILING:
case DBMGR_MERGE_MAILFILES:
case DBMGR_MERGE_SINGLE_FILE:
// save files and send them as e-Mail if required
bRet = MergeMailFiles(&rMergeDesc.rSh,
rMergeDesc);
2000-11-13 07:32:00 +00:00
break;
default: // Einfuegen der selektierten Eintraege
// (war: InsertRecord)
ImportFromConnection(&rMergeDesc.rSh);
2000-11-13 07:32:00 +00:00
break;
}
EndMerge();
return bRet;
}
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Beschreibung: Daten importieren
--------------------------------------------------------------------*/
BOOL SwNewDBMgr::Merge(SwWrtShell* pSh)
{
pSh->StartAllAction();
pSh->ViewShell::UpdateFlds(TRUE);
pSh->SetModified();
pSh->EndAllAction();
return TRUE;
}
void SwNewDBMgr::ImportFromConnection( SwWrtShell* pSh )
{
if(pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB)
2000-09-18 16:15:01 +00:00
{
{
pSh->StartAllAction();
pSh->StartUndo(UNDO_EMPTY);
2000-09-18 16:15:01 +00:00
BOOL bGroupUndo(pSh->DoesGroupUndo());
pSh->DoGroupUndo(FALSE);
if( pSh->HasSelection() )
pSh->DelRight();
SwWait *pWait = 0;
{
ULONG i = 0;
do {
ImportDBEntry(pSh);
if( 10 == ++i )
pWait = new SwWait( *pSh->GetView().GetDocShell(), TRUE);
} while(ToNextMergeRecord());
}
pSh->DoGroupUndo(bGroupUndo);
pSh->EndUndo(UNDO_EMPTY);
2000-09-18 16:15:01 +00:00
pSh->EndAllAction();
delete pWait;
}
}
}
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;
}
void SwNewDBMgr::ImportDBEntry(SwWrtShell* pSh)
{
if(pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB)
2000-09-18 16:15:01 +00:00
{
uno::Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
String sFormatStr;
2000-09-18 16:15:01 +00:00
USHORT nFmtLen = sFormatStr.Len();
if( nFmtLen )
{
const char cSpace = ' ';
const char cTab = '\t';
USHORT nUsedPos = 0;
BYTE nSeparator;
String sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator);
while( sColumn.Len() )
{
if(!xCols->hasByName(sColumn))
return;
Any aCol = xCols->getByName(sColumn);
uno::Reference< XPropertySet > xColumnProp;
aCol >>= xColumnProp;
2000-09-18 16:15:01 +00:00
if(xColumnProp.is())
{
SwDBFormatData aDBFormat;
String sInsert = GetDBField( xColumnProp, aDBFormat);
if( DB_SEP_SPACE == nSeparator )
sInsert += cSpace;
else if( DB_SEP_TAB == nSeparator)
sInsert += cTab;
pSh->Insert(sInsert);
if( DB_SEP_RETURN == nSeparator)
pSh->SplitNode();
else if(DB_SEP_NEWLINE == nSeparator)
pSh->InsertLineBreak();
}
else
{
// Spalte nicht gefunden -> Fehler anzeigen
String sInsert = '?';
sInsert += sColumn;
sInsert += '?';
pSh->Insert(sInsert);
}
sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator);
}
pSh->SplitNode();
}
else
{
String sStr;
2001-09-04 11:40:59 +00:00
Sequence<rtl::OUString> aColNames = xCols->getElementNames();
const rtl::OUString* pColNames = aColNames.getConstArray();
2000-09-18 16:15:01 +00:00
long nLength = aColNames.getLength();
for(long i = 0; i < nLength; i++)
{
Any aCol = xCols->getByName(pColNames[i]);
uno::Reference< XPropertySet > xColumnProp;
aCol >>= xColumnProp;
2000-09-18 16:15:01 +00:00
SwDBFormatData aDBFormat;
sStr += GetDBField( xColumnProp, aDBFormat);
if (i < nLength - 1)
sStr += '\t';
}
CWS-TOOLING: integrate CWS odfmetadata3 2009-09-11 Michael Stahl merge DEV300_m58 2009-09-07 Michael Stahl SwFmtFld::Modify(): do nothing on RES_OBJECTDYING 2009-08-27 Michael Stahl #i91565#, #i91566#: TextPortionEnumerationTest.java: add test document 2009-08-27 Michael Stahl #i91565#, #i91566#: add complex test: TextPortionEnumerationTest.java 2009-08-27 Michael Stahl CLiteral::initialize(): zero-length literals probably not an error 2009-08-27 Michael Stahl #i91565#, #i91566#: offapi: new InContentMetadata and MetadataField services adapt TextPortion for InContentMetadata 2009-08-27 Michael Stahl #i91564#: xmloff: load/store xml:id and RDFa for text:bookmark(-start). 2009-08-27 Michael Stahl #i91564#: sw core: add support for xml:id at bookmarks: sw::mark::Bookmark: derive from Metadatable. SwHistoryBookmark, SaveBookmark: store a MetadatableUndo. ndcopy.cxx: lcl_CopyBookmarks(): copy the xml:id. SwXBookmark: derive from MetadatableMixin. 2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: refactor ruby import so nested meta(-field) works: remove XMLRubyHint_Impl. XMLImpRubyContext_Impl::~XMLImpRubyContext_Impl(): insert ruby directly. 2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: fix text:meta(-field) import/export: new XMLTextParagraphExport::exportTextField() overload for XTextField. CreateAndInsertMark(): set xml:id after insertion. fix meta(-field) service names, bugs etc. 2009-08-27 Michael Stahl #i91565#, #i91566#: sw text formatting: paint background of meta(-field) body: SwFont: add member m_nMetaCount. txttypes.hxx: add POR_META. atrstck.cxx: handle RES_TXTATR_META(FIELD). itrform2.cxx: SwTxtFormatter::WhichTxtPor(): create new class SwMetaPortion. 2009-08-27 Michael Stahl #i91566#: sw text formatting: display meta-field prefix and suffix: SwAttrIter::GetAttr(): replace with call to GetTxtAttrForCharAt(). SwTxtFormatter::NewExtraPortion(): handle meta-field prefix. SwTxtFormatter: new member m_nHintEndIndex. SwTxtFormatter::WhichFirstPortion(): call TryNewNoLengthPortion(). SwTxtFormatter::TryNewNoLengthPortion(): new; handle suffix of meta-field. SwTxtFormatter::UnderFlow(): UGLY HACK: decrement m_nHintEndIndex. SwFldPortion: add flag m_bNoLength: portion has zero length (for suffix). 2009-08-27 Michael Stahl #i91565#, #i91566#: extend text:meta(-field) uno wrapper with XText interface: unoobj.hxx: new CursorType CURSOR_META. unoobj2.cxx: refactor SwXText implementation to ensure that when the SwXText belongs to a SwXMeta, content is always inserted inside the meta(-field). unoobj.cxx: new SwXTextCursor::ForceIntoMeta(): cursor stays in meta(-field). unometa.hxx: SwXMeta implements XText, forwarding to a member SwXMetaText. DocInsertStringSplitCR(), SwX*::attachToRange(), SwX*::DeleteAndInsert(): use FORCEHINTEXPAND hack to ensure insert into the meta(-field) at the end. 2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) uno wrapper to sw: fmtmeta.hxx, fmtatr2.cxx: new class sw::MetaField, new sw::MetaFieldManager. doc.hxx, docnew.cxx: new SwDoc::GetMetaFieldManager(). unocoll.hxx,.cxx: new SW_SERVICE_FIELDTYPE_METAFIELD, SW_SERVICE_TYPE_META. unomap.hxx,.cxx: new PROPERTY_MAP_METAFIELD. unoprnms.hxx: new UNO_NAME_META. unoport.hxx: new PORTION_META; add "InContentMetadata" prop to SwXTextPortion. new unometa.hxx: new class SwXMeta and SwXMetaField. unofield.cxx: SwXFieldEnumeration: include meta-fields. unoportenum.cxx: handle RES_TXTATR_META(FIELD) by using a portion list stack. unotext.cxx: SwXText::insertTextContent(): handle meta(-field) as attribute. 2009-08-27 Michael Stahl #i91565#, #i91566#: ndhints.cxx: remove sort number from SwTxtAttrNesting 2009-08-27 Michael Stahl #i91565#, #i91566#: add support for hints with end and CH_TXTATR to sw core: doc.hxx, docedt.cxx: replace SwDoc::Delete(), DeleteAndJoin(), ReplaceRange() with wrappers that split at left-overlapped end+CH_TXTATR hints. txatbase.hxx: new member SwTxtAttr::m_bHasDummyChar. ndtxt.hxx: rename SwTxtNode::GetTxtAttr() to GetTxtAttrForCharAt(). ndtxt.cxx: SwTxtNode::CopyText(): copy end+CH_TXTATR hints iff copy CH_TXTATR. txtatr2.cxx, thints.cxx: SwTxtMeta gets a CH_TXTATR. 2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) to sw core: txatbase.hxx: new member SwTxtAttr::m_bNesting. hintids.hxx: new ids RES_TXTATR_META, RES_TXTATR_METAFIELD. txtatr.hxx: new base class SwTxtAttrNesting. new hint SwTxtMeta. SwTxtRuby derives from SwTxtAttrNesting. txtinet.hxx: SwTxtINetFmt derives from SwTxtAttrNesting. new header fmtmeta.hxx: new pool item SwFmtMeta. new class sw::Meta. ndhints.hxx, thints.cxx: new method SwpHints::TryInsertNesting(). thints.cxx: refactoring: BuildPortions() no longer handles Ruby/Hyperlink, but TryInsertNesting(), which also handles meta(-field). SwTxtNode::InsertItem(): check if the hint is actually inserted. ndhints.cxx: sort nesting hints based on sort number. ndtxt.cxx: lcl_CopyHint(): handle copy of meta/meta-field. 2009-08-27 Michael Stahl enable expanding hints with m_bLockExpandFlag set: add new InsertFlag: INS_FORCEHINTEXPAND. add new SetAttrMode: SETATTR_FORCEHINTEXPAND. rename SwEditShell::Insert() to Insert2() because changed signature fails to compile when SwWrtShell tries to overwrite these non-virtual members... SwWrtShell::Insert() sets FOCEHINTEXPAND if range was selected/deleted. adapt SwUndoInsert to store flags. 2009-08-27 Michael Stahl change formal parameters of item insertion methods to type SetAttrMode 2009-08-27 Michael Stahl fix incorrect resetting of text attributes in SwUndoInsSection, SwUndoInserts 2009-08-27 Michael Stahl clean up SwTxtNode::CutImpl() and lcl_CopyHint() 2009-08-27 Michael Stahl rename SwDoc::Copy() to CopyRange(), and _Copy() to CopyImpl() 2009-08-27 Michael Stahl rename SwNodes::Move() to MoveRange(), and remove unused parameter 2009-08-27 Michael Stahl rename SwDoc::Move() to MoveRange()/MoveNodeRange() 2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertString(), and remove sal_Unicode variant 2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertPoolItem()/InsertItemSet()/InsertSwSection() 2009-08-27 Michael Stahl rename SwDoc::Replace() to ReplaceRange() 2009-08-27 Michael Stahl remove SwDoc::Overwrite() sal_Unicode variant 2009-08-27 Michael Stahl split up SwDoc::DeleteAndJoin(): factor out DeleteAndJoinWithRedline() 2009-08-27 Michael Stahl rename overloaded SwDoc::Delete() to DeleteRange()/DeleteTOXMark() 2009-08-27 Michael Stahl rename SwTxtNode::Copy() to CopyText() 2009-08-27 Michael Stahl rename SwTxtNode::Cut() to CutText(), and _Cut() to CutImpl() 2009-08-27 Michael Stahl rename SwTxtNode::Delete() to DeleteAttribute()/DeleteAttributes() 2009-08-27 Michael Stahl rename SwTxtNode::Replace() to ReplaceText(), and remove the xub_Unicode variant 2009-08-27 Michael Stahl rename SwTxtNode::Erase() to EraseText() 2009-08-27 Michael Stahl rename SwTxtNode::Insert() to InsertText(), and remove the xub_Unicode variant 2009-08-27 Michael Stahl clean up SwTxtNode::Update() 2009-08-27 Michael Stahl remove SwTxtAttr::RemoveFromPool() and make destructor non-public, to be invoked by new method SwTxtAttr::Destroy() 2009-08-27 Michael Stahl ensure that SwDoc::Insert() for item (set) returns success indicator: replace SwRegHistory constructor with method InsertItems(), returning bool. refactor InsAttr() so that it checks if InsertItems() succeeds. 2009-08-27 Michael Stahl move SwXTextPortionEnumeration from unoobj.hxx to unoport.hxx 2009-08-27 Michael Stahl add missing SolarMutex in SwXTextPortion methods 2009-08-27 Michael Stahl SwXTextPortion: new member m_xTextField (so the TextField property need not be returned indirectly via SwUnoCursorHelper). factor out function CreateSwXTextField(). 2009-08-27 Michael Stahl SwXTextPortion: remove PORTION_CONTROL_CHAR and implementation of XTextField 2009-08-27 Michael Stahl remove obsolete hint SwTxtHardBlank and formats SwFmtHardBlank/SwFmtSoftHyph 2009-08-27 Michael Stahl clean up SwTxtAttr and friends: remove many accessor methods for obsolete (due to autofmt) char format items. remove unused flag SwTxtAttr::m_bDontMergeAttr. MakeRedlineTxtAttr() now dedicated function, no longer calls MakeTxtAttr(). 2009-08-27 Michael Stahl remove obsolete attribute SwTxt2Lines 2009-08-27 Michael Stahl SwXTextPortionEnumeration: finish refactoring CreatePortions change ExportHints so it always returns a text portion for hint w/ CH_TXTATR. remove special case for handling end of paragraph. unfortunately had to refactor the fieldmarks export as well (got in the way). 2009-08-27 Michael Stahl SwXTextPortionEnumeration: refactor CreatePortions: frames export extract function ExportFrames() from CreatePortions(). remove (un)dead code that calls evil MovePara(fnParaCurr, fnParaEnd) 2009-08-27 Michael Stahl clean up SwXParaFrameEnumeration 2009-08-27 Michael Stahl CollectFrameAtNode: replace SwDependArr with STL based FrameDependList_t 2009-08-27 Michael Stahl SwXTextPortionEnumeration: tweak refmark/toxmark export so ExportHints returns the portion for point marks 2009-08-27 Michael Stahl clean up SwXTextPortionEnumeration: prefix members, remove casts, replace SvWeirdArray with STL, etc. make CreatePortions() method a function, and remove lots of members. extract fieldmarks function from CreatePortions. 2009-08-27 Michael Stahl remove FOREACHUNOPAM_START/END macros 2009-08-27 Michael Stahl clean up SwXTextPortion: prefix members, remove casts, etc. remove SwXRubyPortion: replace it with another SwXTextPortion constructor 2009-08-27 Michael Stahl #i102541# SwXReferenceMark::InsertRefMark(): use flag SETATTR_DONTEXPAND 2009-08-27 Michael Stahl rename SwTxtNode::Insert to SwTxtNode::InsertHint, and fix constness in SwTxtNode::InsertItem 2009-08-27 Michael Stahl turn SwTxtNode::MakeTxtAttr() methods into global functions in ndhints.hxx 2009-08-27 Michael Stahl remove obsolete sw/inc/bookmrk.hxx 2009-08-27 Michael Stahl pam.cxx: fix ComparePosition functions (returned wrong result in one case) 2009-08-27 Michael Stahl #i103613# only import RDF metadata on normal open of a document 2009-09-11 kz CWS-TOOLING: integrate CWS impress176 2009-09-08 20:18:24 +0200 sj r275957 : fixed warning (shadowed variable) 2009-09-08 18:02:05 +0200 cl r275948 : #i104315# added missing tab pages 2009-09-08 17:35:18 +0200 cl r275947 : #i104866# fixed angle import 2009-09-08 17:32:53 +0200 cl r275946 : #i104841# fixed angle import 2009-09-08 17:01:25 +0200 cl r275943 : #i103935# fixed the SID_EVENTCONFIG mess 2009-09-08 14:32:57 +0200 sj r275928 : #i104685# only comments 2009-09-07 12:37:36 +0200 sj r275886 : #i104683# fixed import of bold/italic attributes for normal text shapes 2009-09-04 15:07:46 +0200 sj r275808 : #104689# fixed bullet color problem 2009-09-03 15:25:07 +0200 sj r275753 : #160200# added vertical alignment of table cells 2009-09-11 kz CWS-TOOLING: integrate CWS dv14 2009-09-10 15:16:32 +0200 sg r276035 : #160513# updated wfs scheme to accept ports 2009-09-10 07:41:47 +0200 dv r276019 : #i104942# Better renaming algorithmen 2009-08-31 13:41:11 +0200 dv r275604 : #160505# Setting APP1PRODUCTNAME must not overwrite APP1PRODUCTDEF 2009-09-11 kz CWS-TOOLING: integrate CWS jl131 2009-09-02 16:42:40 +0200 jl r275720 : #i97896# 2009-08-31 13:01:53 +0200 jl r275599 : CWS-TOOLING: rebase CWS jl131 to trunk@275331 (milestone: DEV300:m56) 2009-07-31 14:35:30 +0200 jl r274531 : CWS-TOOLING: rebase CWS jl131 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 14:20:32 +0200 jl r274272 : #i79839# better error text when trying to modify shared layer without having write permission, eg. unopkg add --shared, unopkg remove --shared, unopkg reinstall --shared 2009-07-22 16:38:02 +0200 jl r274252 : #i97896# localize error message for lock file 2009-07-22 16:37:22 +0200 jl r274251 : #i80462# unprecise wording in updatedialog 2009-07-22 16:36:06 +0200 jl r274250 : #i97896# localize error message for lock file 2009-07-22 16:35:20 +0200 jl r274249 : #i97896# localize error message for lock file 2009-07-22 15:07:30 +0200 jl r274242 : #i98873# minimum java version is 1.5 since OOo 3.0 2009-09-11 kz CWS-TOOLING: integrate CWS changehc 2009-08-31 19:38:50 +0200 pl r275633 : remove dbug printf 2009-08-31 17:41:50 +0200 pl r275623 : CWS-TOOLING: rebase CWS changehc to trunk@275331 (milestone: DEV300:m56) 2009-07-15 19:45:46 +0200 pl r274028 : #i35482# use HC flag to decide high contrast mode 2009-07-15 17:40:52 +0200 pl r274020 : #i35482# use HC flag to decide high contrast mode 2009-07-15 17:39:50 +0200 pl r274019 : #i35482# update autohc correctly in MergeSystemSettings 2009-07-15 17:38:57 +0200 pl r274018 : #i35482# update autohc correctly in MergeSystemSettings 2009-09-11 kz CWS-TOOLING: integrate CWS notes10 2009-08-24 07:25:57 +0200 mod r275287 : 2009-07-26 02:38:32 +0200 mod r274343 : #i#i103645# 2009-07-26 02:01:53 +0200 mod r274342 : #i103645# 2009-07-26 01:52:42 +0200 mod r274341 : #i103490# 2009-07-22 08:31:48 +0200 mod r274215 : #i103373# 2009-07-15 00:55:11 +0200 mod r273987 : #i101419# 2009-07-14 07:07:55 +0200 mod r273956 : #i101419# 2009-07-14 07:07:43 +0200 mod r273955 : #i101419# 2009-07-14 07:02:10 +0200 mod r273954 : changes from notes9 2009-07-14 06:14:25 +0200 mod r273953 : #i103476# 2009-09-11 kz CWS-TOOLING: integrate CWS ab70 2009-09-10 15:12:54 +0200 jsk r276034 : #i85434# - mandatory automatic update test 2009-09-10 15:11:06 +0200 jsk r276033 : #i85434# - mandatory automatic update test 2009-09-02 09:49:24 +0200 ab r275698 : #i85434# Dialog Import 2009-09-11 kz CWS-TOOLING: integrate CWS hb32bugs02 2009-09-02 Henning Brinkmann #i102420# revert changes 2009-08-26 Henning Brinkmann merged DEV300_m56 2009-08-19 Henning Brinkmann merged DEV300_m55 2009-08-14 Henning Brinkmann merged changes from wntmsci12 2009-08-12 Henning Brinkmann Implemented NoSpaceEdit constructor and destructor in .cxx to allow compile with debug on wntmsci12. 2009-08-12 Henning Brinkmann Added some SW_DLLPUBLIC to make compilable on wntmsci12. 2009-08-11 Henning Brinkmann #i102420# dbg_out: surround output for SwNodes with <nodes-array>. 2009-08-10 Henning Brinkmann #i102420# rewritten debug output for SwNodes. 2009-08-07 Henning Brinkmann #i102420# debug _MoveNodes: output the destination, too. Break after two iterations. 2009-08-07 Henning Brinkmann #i102420# _MoveNodes: Additionally check if destination index is inside source => false Check if current range was already handled => loop Debug output current range 2009-08-06 Henning Brinkmann merged DEV300_m54 2009-08-06 Henning Brinkmann added master fix 2009-08-06 Henning Brinkmann debug output for SwNodeRange 2009-08-04 Henning Brinkmann #i102844# robustness: check for NULL pointer to prevent crash 2009-08-03 Henning Brinkmann #i103475# applied patch and verified 2009-08-03 Henning Brinkmann Removed code preventing build of sw with DEBUG. 2009-09-11 convert-repo update tags 2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300 2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree. 2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23 2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite 2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix 2009-09-10 kz CWS-TOOLING: integrate CWS mh232 2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch 2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD 2009-08-26 03:11:20 +0200 mh r275383 : #i39230 2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field 2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name 2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl 2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam 2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613# 2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3 2009-09-10 kz CWS-TOOLING: integrate CWS tkr24 2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT 2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping> 2009-09-11 convert-repo update tags 2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300 2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree. 2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23 2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite 2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix 2009-09-10 kz CWS-TOOLING: integrate CWS mh232 2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch 2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD 2009-08-26 03:11:20 +0200 mh r275383 : #i39230 2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field 2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name 2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl 2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam 2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613# 2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3 2009-09-10 kz CWS-TOOLING: integrate CWS tkr24 2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT 2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping>
2009-09-11 14:29:45 +00:00
pSh->SwEditShell::Insert2(sStr);
2000-09-18 16:15:01 +00:00
pSh->SwFEShell::SplitNode(); // Zeilenvorschub
}
}
}
2010-10-11 17:38:56 -05:00
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Beschreibung: Listbox mit Tabellenliste fuellen
--------------------------------------------------------------------*/
BOOL SwNewDBMgr::GetTableNames(ListBox* pListBox, const String& rDBName)
{
BOOL bRet = FALSE;
String sOldTableName(pListBox->GetSelectEntry());
pListBox->Clear();
SwDSParam* pParam = FindDSConnection(rDBName, FALSE);
uno::Reference< XConnection> xConnection;
if(pParam && pParam->xConnection.is())
xConnection = pParam->xConnection;
else
2002-10-24 12:48:08 +00:00
{
rtl::OUString sDBName(rDBName);
xConnection = RegisterConnection( sDBName );
}
2000-09-18 16:15:01 +00:00
if(xConnection.is())
{
uno::Reference<XTablesSupplier> xTSupplier = uno::Reference<XTablesSupplier>(xConnection, UNO_QUERY);
2000-09-18 16:15:01 +00:00
if(xTSupplier.is())
{
uno::Reference<XNameAccess> xTbls = xTSupplier->getTables();
2001-09-04 11:40:59 +00:00
Sequence<rtl::OUString> aTbls = xTbls->getElementNames();
const rtl::OUString* pTbls = aTbls.getConstArray();
2000-09-18 16:15:01 +00:00
for(long i = 0; i < aTbls.getLength(); i++)
{
USHORT nEntry = pListBox->InsertEntry(pTbls[i]);
pListBox->SetEntryData(nEntry, (void*)0);
}
2000-09-18 16:15:01 +00:00
}
uno::Reference<XQueriesSupplier> xQSupplier = uno::Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
2000-09-18 16:15:01 +00:00
if(xQSupplier.is())
{
uno::Reference<XNameAccess> xQueries = xQSupplier->getQueries();
2001-09-04 11:40:59 +00:00
Sequence<rtl::OUString> aQueries = xQueries->getElementNames();
const rtl::OUString* pQueries = aQueries.getConstArray();
2000-09-18 16:15:01 +00:00
for(long i = 0; i < aQueries.getLength(); i++)
{
USHORT nEntry = pListBox->InsertEntry(pQueries[i]);
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();
SwDBData aData;
aData.sDataSource = rDBName;
aData.sCommand = rTableName;
aData.nCommandType = -1;
SwDSParam* pParam = FindDSData(aData, FALSE);
uno::Reference< XConnection> xConnection;
if(pParam && pParam->xConnection.is())
xConnection = pParam->xConnection;
else
2002-10-24 12:48:08 +00:00
{
rtl::OUString sDBName(rDBName);
xConnection = RegisterConnection( sDBName );
}
uno::Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
2000-09-18 16:15:01 +00:00
if(xColsSupp.is())
{
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
2001-09-04 11:40:59 +00:00
const Sequence<rtl::OUString> aColNames = xCols->getElementNames();
const rtl::OUString* pColNames = aColNames.getConstArray();
2000-09-18 16:15:01 +00:00
for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
{
pListBox->InsertEntry(pColNames[nCol]);
}
::comphelper::disposeComponent( xColsSupp );
2000-09-18 16:15:01 +00:00
}
return(TRUE);
}
BOOL SwNewDBMgr::GetColumnNames(ListBox* pListBox,
uno::Reference< XConnection> xConnection,
const String& rTableName, BOOL bAppend)
{
if (!bAppend)
pListBox->Clear();
uno::Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
if(xColsSupp.is())
{
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
2001-09-04 11:40:59 +00:00
const Sequence<rtl::OUString> aColNames = xCols->getElementNames();
const rtl::OUString* pColNames = aColNames.getConstArray();
for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
{
pListBox->InsertEntry(pColNames[nCol]);
}
::comphelper::disposeComponent( xColsSupp );
}
return(TRUE);
}
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Beschreibung: CTOR
--------------------------------------------------------------------*/
SwNewDBMgr::SwNewDBMgr() :
nMergeType(DBMGR_INSERT),
bInitDBFields(FALSE),
2000-09-18 16:15:01 +00:00
bInMerge(FALSE),
bMergeSilent(FALSE),
bMergeLock(FALSE),
pImpl(new SwNewDBMgr_Impl(*this)),
pMergeEvtSrc(NULL)
2000-09-18 16:15:01 +00:00
{
}
SwNewDBMgr::~SwNewDBMgr()
{
for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++)
{
SwDSParam* pParam = aDataSourceParams[nPos];
if(pParam->xConnection.is())
{
try
{
uno::Reference<XComponent> xComp(pParam->xConnection, UNO_QUERY);
if(xComp.is())
xComp->dispose();
}
catch(const RuntimeException& )
{
//may be disposed already since multiple entries may have used the same connection
}
}
}
delete pImpl;
2000-09-18 16:15:01 +00:00
}
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Beschreibung: Serienbriefe als einzelne Dokumente speichern
2000-09-18 16:15:01 +00:00
--------------------------------------------------------------------*/
String lcl_FindUniqueName(SwWrtShell* pTargetShell, const String& rStartingPageDesc, ULONG nDocNo )
{
do
{
String sTest = rStartingPageDesc;
sTest += String::CreateFromInt32( nDocNo );
if( !pTargetShell->FindPageDescByName( sTest ) )
return sTest;
++nDocNo;
}while(true);
}
2010-10-11 17:38:56 -05:00
void lcl_CopyDynamicDefaults( const SwDoc& rSource, SwDoc& rTarget )
{
USHORT __FAR_DATA aRangeOfDefaults[] = {
RES_FRMATR_BEGIN, RES_FRMATR_END-1,
RES_CHRATR_BEGIN, RES_CHRATR_END-1,
RES_PARATR_BEGIN, RES_PARATR_END-1,
// --> OD 2008-02-25 #refactorlists##
RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
// <--
RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
0
};
SfxItemSet aNewDefaults( rTarget.GetAttrPool(), aRangeOfDefaults );
USHORT nWhich;
USHORT nRange = 0;
while( aRangeOfDefaults[nRange] != 0)
{
for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich )
{
const SfxPoolItem& rSourceAttr = rSource.GetDefault( nWhich );
if( rSourceAttr != rTarget.GetDefault( nWhich ) )
aNewDefaults.Put( rSourceAttr );
}
nRange += 2;
}
if( aNewDefaults.Count() )
rTarget.SetDefault( aNewDefaults );
}
2010-10-11 17:38:56 -05:00
void lcl_CopyFollowPageDesc(
SwWrtShell& rTargetShell,
const SwPageDesc& rSourcePageDesc,
const SwPageDesc& rTargetPageDesc,
const ULONG nDocNo )
{
//now copy the follow page desc, too
const SwPageDesc* pFollowPageDesc = rSourcePageDesc.GetFollow();
String sFollowPageDesc = pFollowPageDesc->GetName();
if( sFollowPageDesc != rSourcePageDesc.GetName() )
{
SwDoc* pTargetDoc = rTargetShell.GetDoc();
String sNewFollowPageDesc = lcl_FindUniqueName(&rTargetShell, sFollowPageDesc, nDocNo );
sal_uInt16 nNewDesc = pTargetDoc->MakePageDesc( sNewFollowPageDesc );
SwPageDesc& rTargetFollowPageDesc = pTargetDoc->_GetPageDesc( nNewDesc );
pTargetDoc->CopyPageDesc( *pFollowPageDesc, rTargetFollowPageDesc, sal_False );
SwPageDesc aDesc( rTargetPageDesc );
aDesc.SetFollow( &rTargetFollowPageDesc );
pTargetDoc->ChgPageDesc( rTargetPageDesc.GetName(), aDesc );
}
}
2000-09-18 16:15:01 +00:00
BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
const SwMergeDescriptor& rMergeDescriptor)
2000-09-18 16:15:01 +00:00
{
//check if the doc is synchronized and contains at least one linked section
BOOL bSynchronizedDoc = pSourceShell->IsLabelDoc() && pSourceShell->GetSectionFmtCount() > 1;
2000-09-18 16:15:01 +00:00
BOOL bLoop = TRUE;
BOOL bEMail = rMergeDescriptor.nMergeType == DBMGR_MERGE_MAILING;
const bool bAsSingleFile = rMergeDescriptor.nMergeType == DBMGR_MERGE_SINGLE_FILE;
2000-09-18 16:15:01 +00:00
::rtl::Reference< MailDispatcher > xMailDispatcher;
::rtl::OUString sBodyMimeType;
rtl_TextEncoding eEncoding = ::gsl_getSystemTextEncoding();
2000-09-18 16:15:01 +00:00
if(bEMail)
{
xMailDispatcher.set( new MailDispatcher(rMergeDescriptor.xSmtpServer));
if(!rMergeDescriptor.bSendAsAttachment && rMergeDescriptor.bSendAsHTML)
{
sBodyMimeType = ::rtl::OUString::createFromAscii("text/html; charset=");
sBodyMimeType += ::rtl::OUString::createFromAscii(
rtl_getBestMimeCharsetFromTextEncoding( eEncoding ));
SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get();
eEncoding = pHtmlOptions->GetTextEncoding();
2000-09-18 16:15:01 +00:00
}
else
sBodyMimeType =
::rtl::OUString::createFromAscii("text/plain; charset=UTF-8; format=flowed");
2000-09-18 16:15:01 +00:00
}
uno::Reference< XPropertySet > xColumnProp;
2000-09-18 16:15:01 +00:00
{
BOOL bColumnName = sEMailAddrFld.Len() > 0;
if (bColumnName)
{
uno::Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
2000-09-18 16:15:01 +00:00
if(!xCols->hasByName(sEMailAddrFld))
return FALSE;
Any aCol = xCols->getByName(sEMailAddrFld);
aCol >>= xColumnProp;
2000-09-18 16:15:01 +00:00
}
SfxDispatcher* pSfxDispatcher = pSourceShell->GetView().GetViewFrame()->GetDispatcher();
SwDocShell* pSourrceDocSh = pSourceShell->GetView().GetDocShell();
pSfxDispatcher->Execute( pSourrceDocSh->HasName() ? SID_SAVEDOC : SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD);
// has document been saved successfully?
if( !pSourrceDocSh->IsModified() )
2000-09-18 16:15:01 +00:00
{
SfxMedium* pOrig = pSourceShell->GetView().GetDocShell()->GetMedium();
String sSourceDocumentURL(pOrig->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ));
2000-09-18 16:15:01 +00:00
const SfxFilter* pSfxFlt = SwIoSystem::GetFileFilter(
sSourceDocumentURL, ::aEmptyStr );
const SfxFilter* pStoreToFilter = pSfxFlt;
SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
const String* pStoreToFilterOptions = 0;
// if a save_to filter is set then use it - otherwise use the default
if( bEMail && !rMergeDescriptor.bSendAsAttachment )
{
String sExtension( String::CreateFromAscii(
rMergeDescriptor.bSendAsHTML ? "html" : "txt" ));
pStoreToFilter = pFilterContainer->GetFilter4Extension(sExtension, SFX_FILTER_EXPORT);
}
else if( rMergeDescriptor.sSaveToFilter.Len())
{
const SfxFilter* pFilter =
pFilterContainer->GetFilter4FilterName( rMergeDescriptor.sSaveToFilter );
if(pFilter)
{
pStoreToFilter = pFilter;
if(rMergeDescriptor.sSaveToFilterOptions.Len())
pStoreToFilterOptions = &rMergeDescriptor.sSaveToFilterOptions;
}
}
2000-09-18 16:15:01 +00:00
bCancel = FALSE;
// in case of creating a single resulting file this has to be created here
SwWrtShell* pTargetShell = 0;
SfxObjectShellRef xTargetDocShell;
2009-09-01 08:22:04 +00:00
SwView* pTargetView = 0;
std::auto_ptr< utl::TempFile > aTempFile;
String sModifiedStartingPageDesc;
String sStartingPageDesc;
USHORT nStartingPageNo = 0;
bool bPageStylesWithHeaderFooter = false;
if(bAsSingleFile || rMergeDescriptor.bCreateSingleFile)
{
// create a target docshell to put the merged document into
xTargetDocShell = new SwDocShell( SFX_CREATE_MODE_STANDARD );
xTargetDocShell->DoInitNew( 0 );
SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
2009-09-01 08:22:04 +00:00
pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() );
//initiate SelectShell() to create sub shells
pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() );
pTargetShell = pTargetView->GetWrtShellPtr();
//copy the styles from the source to the target document
SwgReaderOption aOpt;
aOpt.SetTxtFmts( sal_True );
aOpt.SetFrmFmts( sal_True );
aOpt.SetPageDescs( sal_True );
aOpt.SetNumRules( sal_True );
aOpt.SetMerge( sal_False );
pTargetView->GetDocShell()->LoadStylesFromFile(
sSourceDocumentURL, aOpt, sal_True );
//determine the page style and number used at the start of the source document
pSourceShell->SttEndDoc(TRUE);
nStartingPageNo = pSourceShell->GetVirtPageNum();
sStartingPageDesc = sModifiedStartingPageDesc = pSourceShell->GetPageDesc(
pSourceShell->GetCurPageDesc()).GetName();
// #122799# copy compatibility options
lcl_CopyCompatibilityOptions( *pSourceShell, *pTargetShell);
// #72821# copy dynamic defaults
lcl_CopyDynamicDefaults( *pSourceShell->GetDoc(), *pTargetShell->GetDoc() );
// #i72517#
const SwPageDesc* pSourcePageDesc = pSourceShell->FindPageDescByName( sStartingPageDesc );
const SwFrmFmt& rMaster = pSourcePageDesc->GetMaster();
bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive() ||
rMaster.GetFooter().IsActive();
}
2008-10-01 06:46:01 +00:00
PrintMonitor aPrtMonDlg(&pSourceShell->GetView().GetEditWin(), PrintMonitor::MONITOR_TYPE_PRINT);
aPrtMonDlg.aDocName.SetText(pSourceShell->GetView().GetDocShell()->GetTitle(22));
2000-09-18 16:15:01 +00:00
aPrtMonDlg.aCancel.SetClickHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
if (!IsMergeSilent())
aPrtMonDlg.Show();
2000-09-18 16:15:01 +00:00
// Progress, um KeyInputs zu unterbinden
SfxProgress aProgress(pSourrceDocSh, ::aEmptyStr, 1);
2000-09-18 16:15:01 +00:00
// Alle Dispatcher sperren
SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst(pSourrceDocSh);
2000-09-18 16:15:01 +00:00
while (pViewFrm)
{
pViewFrm->GetDispatcher()->Lock(TRUE);
pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourrceDocSh);
2000-09-18 16:15:01 +00:00
}
ULONG nDocNo = 1;
long nStartRow, nEndRow;
// collect temporary files
::std::vector< String> aFilesToRemove;
do
{
nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
2000-09-18 16:15:01 +00:00
{
String sPath(sSubject);
String sAddress;
if( !bEMail && bColumnName )
2000-09-18 16:15:01 +00:00
{
SwDBFormatData aDBFormat;
aDBFormat.xFormatter = pImpl->pMergeData->xFormatter;
aDBFormat.aNullDate = pImpl->pMergeData->aNullDate;
2000-09-18 16:15:01 +00:00
sAddress = GetDBField( xColumnProp, aDBFormat);
if (!sAddress.Len())
sAddress = '_';
sPath += sAddress;
}
// create a new temporary file name - only done once in case of bCreateSingleFile
if( 1 == nDocNo || (!rMergeDescriptor.bCreateSingleFile && !bAsSingleFile) )
{
INetURLObject aEntry(sPath);
String sLeading;
//#i97667# if the name is from a database field then it will be used _as is_
if( sAddress.Len() )
sLeading = sAddress;
else
sLeading = aEntry.GetBase();
aEntry.removeSegment();
sPath = aEntry.GetMainURL( INetURLObject::NO_DECODE );
String sExt( pStoreToFilter->GetDefaultExtension() );
sExt.EraseLeadingChars('*');
aTempFile = std::auto_ptr< utl::TempFile >(
new utl::TempFile(sLeading,&sExt,&sPath ));
if( bAsSingleFile )
aTempFile->EnableKillingFile();
}
2000-09-18 16:15:01 +00:00
if( !aTempFile->IsValid() )
2000-09-18 16:15:01 +00:00
{
ErrorHandler::HandleError( ERRCODE_IO_NOTSUPPORTED );
bLoop = FALSE;
bCancel = TRUE;
}
else
{
INetURLObject aTempFileURL(aTempFile->GetURL());
aPrtMonDlg.aPrinter.SetText( aTempFileURL.GetBase() );
2000-09-18 16:15:01 +00:00
String sStat(SW_RES(STR_STATSTR_LETTER)); // Brief
sStat += ' ';
sStat += String::CreateFromInt32( nDocNo );
2000-09-18 16:15:01 +00:00
aPrtMonDlg.aPrintInfo.SetText(sStat);
// Rechenzeit fuer Save-Monitor:
for (USHORT i = 0; i < 10; i++)
Application::Reschedule();
// Neues Dokument erzeugen und speichern
SfxObjectShellRef xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL ));
SfxMedium* pWorkMed = new SfxMedium( sSourceDocumentURL, STREAM_STD_READ, TRUE );
pWorkMed->SetFilter( pSfxFlt );
2000-09-18 16:15:01 +00:00
if (xWorkDocSh->DoLoad(pWorkMed))
2000-09-18 16:15:01 +00:00
{
//create a view frame for the document
SfxViewFrame* pWorkFrame = SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 );
//request the layout calculation
SwWrtShell& rWorkShell =
static_cast< SwView* >(pWorkFrame->GetViewShell())->GetWrtShell();
rWorkShell.CalcLayout();
SwDoc* pWorkDoc = ((SwDocShell*)(&xWorkDocSh))->GetDoc();
SwNewDBMgr* pOldDBMgr = pWorkDoc->GetNewDBMgr();
pWorkDoc->SetNewDBMgr( this );
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), xWorkDocSh));
pWorkDoc->UpdateFlds(NULL, false);
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), xWorkDocSh));
2000-09-18 16:15:01 +00:00
// alle versteckten Felder/Bereiche entfernen
pWorkDoc->RemoveInvisibleContent();
2000-09-18 16:15:01 +00:00
// launch MailMergeEvent if required
const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc();
if(pEvtSrc)
{
uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc );
text::MailMergeEvent aEvt( xRef, xWorkDocSh->GetModel() );
pEvtSrc->LaunchMailMergeEvent( aEvt );
}
if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile )
{
DBG_ASSERT( pTargetShell, "no target shell available!" );
// copy created file into the target document
rWorkShell.ConvertFieldsToText();
rWorkShell.SetNumberingRestart();
// insert the document into the target document
rWorkShell.SttEndDoc(FALSE);
rWorkShell.SttEndDoc(TRUE);
rWorkShell.SelAll();
pTargetShell->SwCrsrShell::SttEndDoc( FALSE );
//#i72517# the headers and footers are still those from the source - update in case of fields inside header/footer
if( !nDocNo && bPageStylesWithHeaderFooter )
pTargetShell->GetView().GetDocShell()->_LoadStyles( *rWorkShell.GetView().GetDocShell(), sal_True );
//#i72517# put the styles to the target document
//if the source uses headers or footers each new copy need to copy a new page styles
if(bPageStylesWithHeaderFooter)
{
//create a new pagestyle
//copy the pagedesc from the current document to the new document and change the name of the to-be-applied style
SwDoc* pTargetDoc = pTargetShell->GetDoc();
SwPageDesc* pSourcePageDesc = rWorkShell.FindPageDescByName( sStartingPageDesc );
String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
pTargetDoc->MakePageDesc( sNewPageDescName );
SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
if(pSourcePageDesc && pTargetPageDesc)
{
pTargetDoc->CopyPageDesc( *pSourcePageDesc, *pTargetPageDesc, sal_False );
sModifiedStartingPageDesc = sNewPageDescName;
lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo );
}
}
if(nDocNo > 1)
pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
else
pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
DBG_ASSERT(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
//#i51359# add a second paragraph in case there's only one
{
SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
SwPosition aTestPos( aIdx );
SwCursor aTestCrsr(aTestPos,0,false);
if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
{
//append a paragraph
pWorkDoc->AppendTxtNode( aTestPos );
}
}
pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
//convert fields in page styles (header/footer - has to be done after the first document has been pasted
if(1 == nDocNo)
{
pTargetShell->CalcLayout();
pTargetShell->ConvertFieldsToText();
}
}
else
2000-09-18 16:15:01 +00:00
{
String sFileURL = aTempFileURL.GetMainURL( INetURLObject::NO_DECODE );
SfxMedium* pDstMed = new SfxMedium(
sFileURL,
STREAM_STD_READWRITE, TRUE );
pDstMed->SetFilter( pStoreToFilter );
if(pDstMed->GetItemSet())
{
if(pStoreToFilterOptions )
pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions));
if(rMergeDescriptor.aSaveToFilterData.getLength())
pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData)));
}
CWS-TOOLING: integrate CWS os121 2008-11-28 13:44:51 +0100 os r264551 : Copy Hyperlink Location added 2008-11-28 13:36:20 +0100 os r264547 : Copy Hyperlink Location added 2008-11-25 15:43:53 +0100 os r264311 : label of EditHyperlink fixed 2008-11-25 15:42:42 +0100 os r264310 : use ResetAttr to remove hyperlink 2008-11-25 10:08:02 +0100 os r264276 : edit/remove hyperlink names fixed 2008-11-11 15:47:22 +0100 os r263565 : typo fixed 2008-11-10 18:46:00 +0100 os r263536 : CWS-TOOLING: rebase CWS os121 to trunk@263288 (milestone: DEV300:m35) 2008-11-07 15:34:41 +0100 os r263422 : #i6191# accept/reject changes;#i7311# remove hyperlink 2008-11-07 15:34:05 +0100 os r263421 : #i6191# accept/reject changes;#i7311# remove hyperlink 2008-11-06 17:26:18 +0100 os r263402 : #i43971# words from online help documents must not be added to AutoCompletion 2008-11-06 16:08:27 +0100 os r263397 : #i6191# accept/reject changes added to context menu 2008-11-06 16:07:49 +0100 os r263396 : #i6191# accept/reject changes added to context menu 2008-11-06 16:07:16 +0100 os r263395 : #i6191# accept/reject changes added to context menu 2008-11-06 16:06:18 +0100 os r263394 : #i6191# accept/reject changes added to context menu 2008-10-30 14:31:32 +0100 os r262826 : #i84980# less options changed to fewer options 2008-10-30 11:44:41 +0100 os r262824 : #i95624# don't add paragraph numbering in getString() 2008-10-27 10:46:04 +0100 os r262665 : #i88235# SvCheckListBox::SelectEntryPos() paints a CheckBox to the wrong device if page is not visible, yet - call moved to ::Reset() 2008-10-24 15:49:27 +0200 os r262648 : #i77230# make repeating headers the default 2008-10-23 16:49:42 +0200 os r262625 : #i95350# RTL output of table window fixed 2008-10-23 15:37:40 +0200 os r262623 : #i76723# RTL related patch removed - it is now done by vcl 2008-10-22 14:05:58 +0200 os r262601 : #b6297019#,#i49754# LoadStyles: restore outline settings 2008-10-22 14:05:17 +0200 os r262600 : #b6297019#,#i49754# LoadStyles: restore outline settings 2008-10-20 15:39:18 +0200 os r262323 : #i95059# border attribute: which id of SID_ATTR_BORDER_INNER fixed 2008-10-20 09:30:28 +0200 os r262305 : #i95123# conflict css::util::Color and ::Color solved 2008-10-17 11:44:16 +0200 os r262280 : #i93714# merge to PDF: convert fields to text before export 2008-10-17 10:30:11 +0200 os r262275 : #i94364# 2008-10-17 10:11:56 +0200 os r262274 : +i94536# default font ListBoxes: prevent entry duplication if 'Back' button is pressed
2008-12-09 07:49:49 +00:00
//convert fields to text if we are exporting to PDF
//this prevents a second merge while updating the fields in SwXTextDocument::getRendererCount()
if( pStoreToFilter && pStoreToFilter->GetFilterName().EqualsAscii("writer_pdf_Export"))
rWorkShell.ConvertFieldsToText();
xWorkDocSh->DoSaveAs(*pDstMed);
xWorkDocSh->DoSaveCompleted(pDstMed);
if( xWorkDocSh->GetError() )
{
// error message ??
ErrorHandler::HandleError( xWorkDocSh->GetError() );
bCancel = TRUE;
bLoop = FALSE;
}
if( bEMail )
{
SwDBFormatData aDBFormat;
aDBFormat.xFormatter = pImpl->pMergeData->xFormatter;
aDBFormat.aNullDate = pImpl->pMergeData->aNullDate;
String sMailAddress = GetDBField( xColumnProp, aDBFormat);
if(!SwMailMergeHelper::CheckMailAddress( sMailAddress ))
{
DBG_ERROR("invalid e-Mail address in database column");
}
else
{
SwMailMessage* pMessage = 0;
uno::Reference< mail::XMailMessage > xMessage =
pMessage = new SwMailMessage;
if(rMergeDescriptor.pMailMergeConfigItem->IsMailReplyTo())
pMessage->setReplyToAddress(rMergeDescriptor.pMailMergeConfigItem->GetMailReplyTo());
pMessage->addRecipient( sMailAddress );
pMessage->SetSenderAddress( rMergeDescriptor.pMailMergeConfigItem->GetMailAddress() );
::rtl::OUString sBody;
if(rMergeDescriptor.bSendAsAttachment)
{
sBody = rMergeDescriptor.sMailBody;
mail::MailAttachment aAttach;
aAttach.Data = new SwMailTransferable(
sFileURL,
rMergeDescriptor.sAttachmentName,
pStoreToFilter->GetMimeType());
aAttach.ReadableName = rMergeDescriptor.sAttachmentName;
pMessage->addAttachment( aAttach );
}
else
{
{
//read in the temporary file and use it as mail body
SfxMedium aMedium( sFileURL, STREAM_READ, TRUE);
SvStream* pInStream = aMedium.GetInStream();
DBG_ASSERT(pInStream, "no output file created?");
if(pInStream)
{
pInStream->SetStreamCharSet( eEncoding );
ByteString sLine;
sal_Bool bDone = pInStream->ReadLine( sLine );
while ( bDone )
{
sBody += String(sLine, eEncoding);
sBody += ::rtl::OUString('\n');
bDone = pInStream->ReadLine( sLine );
}
}
}
}
pMessage->setSubject( rMergeDescriptor.sSubject );
uno::Reference< datatransfer::XTransferable> xBody =
new SwMailTransferable(
sBody,
sBodyMimeType);
pMessage->setBody( xBody );
if(rMergeDescriptor.aCopiesTo.getLength())
{
const ::rtl::OUString* pCopies = rMergeDescriptor.aCopiesTo.getConstArray();
for( sal_Int32 nToken = 0; nToken < rMergeDescriptor.aCopiesTo.getLength(); ++nToken)
pMessage->addCcRecipient( pCopies[nToken] );
}
if(rMergeDescriptor.aBlindCopiesTo.getLength())
{
const ::rtl::OUString* pCopies = rMergeDescriptor.aBlindCopiesTo.getConstArray();
for( sal_Int32 nToken = 0; nToken < rMergeDescriptor.aBlindCopiesTo.getLength(); ++nToken)
pMessage->addBccRecipient( pCopies[nToken] );
}
xMailDispatcher->enqueueMailMessage( xMessage );
if(!xMailDispatcher->isStarted())
xMailDispatcher->start();
//schedule for removal
aFilesToRemove.push_back(sFileURL);
}
}
2000-09-18 16:15:01 +00:00
}
pWorkDoc->SetNewDBMgr( pOldDBMgr );
2000-09-18 16:15:01 +00:00
}
xWorkDocSh->DoClose();
2000-09-18 16:15:01 +00:00
}
}
nDocNo++;
nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
} while( !bCancel &&
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
aPrtMonDlg.Show( FALSE );
// save the single output document
if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile)
{
2009-09-01 08:22:04 +00:00
if( rMergeDescriptor.nMergeType != DBMGR_MERGE_MAILMERGE )
{
2009-09-01 08:22:04 +00:00
DBG_ASSERT( aTempFile.get(), "Temporary file not available" );
INetURLObject aTempFileURL(bAsSingleFile ? sSubject : aTempFile->GetURL());
SfxMedium* pDstMed = new SfxMedium(
aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ),
STREAM_STD_READWRITE, TRUE );
pDstMed->SetFilter( pStoreToFilter );
if(pDstMed->GetItemSet())
{
if(pStoreToFilterOptions )
pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions));
if(rMergeDescriptor.aSaveToFilterData.getLength())
pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData)));
}
2009-09-01 08:22:04 +00:00
xTargetDocShell->DoSaveAs(*pDstMed);
xTargetDocShell->DoSaveCompleted(pDstMed);
if( xTargetDocShell->GetError() )
{
// error message ??
ErrorHandler::HandleError( xTargetDocShell->GetError() );
bLoop = FALSE;
}
}
else if( pTargetView ) // must be available!
{
2009-09-01 08:22:04 +00:00
//print the target document
#if OSL_DEBUG_LEVEL > 1
sal_Bool _bVal;
sal_Int16 _nVal;
rtl::OUString _sVal;
const beans::PropertyValue* pDbgPrintOptions = rMergeDescriptor.aPrintOptions.getConstArray();
for( sal_Int32 nOption = 0; nOption < rMergeDescriptor.aPrintOptions.getLength(); ++nOption)
{
rtl::OUString aName( pDbgPrintOptions[nOption].Name );
uno::Any aVal( pDbgPrintOptions[nOption].Value );
aVal >>= _bVal;
aVal >>= _nVal;
aVal >>= _sVal;
}
#endif
// printing should be done synchronously otherwise the document
// might already become invalid during the process
uno::Sequence< beans::PropertyValue > aOptions( rMergeDescriptor.aPrintOptions );
const sal_Int32 nOpts = aOptions.getLength();
aOptions.realloc( nOpts + 1 );
aOptions[ nOpts ].Name = rtl::OUString::createFromAscii( "Wait" );
aOptions[ nOpts ].Value <<= sal_True ;
// aPrintArgs.Put(SfxBoolItem(FN_QRY_MERGE, TRUE) );
// // #i52629# aynchronous printing should only be done in silent mode - otherwise
// // the printer dialog does not come up
// aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, rMergeDescriptor.bPrintAsync ));
// move print options
const beans::PropertyValue* pPrintOptions = rMergeDescriptor.aPrintOptions.getConstArray();
for( sal_Int32 nOption = 0; nOption < rMergeDescriptor.aPrintOptions.getLength(); ++nOption)
{
if( pPrintOptions[nOption].Name.equalsAscii( "CopyCount" )
||( pPrintOptions[nOption].Name.equalsAscii( "FileName" ))
||( pPrintOptions[nOption].Name.equalsAscii( "Collate" ))
||( pPrintOptions[nOption].Name.equalsAscii( "Pages" ))
||( pPrintOptions[nOption].Name.equalsAscii( "Wait" )))
{
aOptions.realloc( nOpts + 1 );
aOptions[ nOpts ].Name = pPrintOptions[nOption].Name;
aOptions[ nOpts ].Value = pPrintOptions[nOption].Value ;
}
}
2009-09-01 16:31:53 +00:00
// const SwModuleOptions * pModOpt = SW_MOD()->GetModuleConfig();
2009-09-01 08:22:04 +00:00
// if (pModOpt->IsSinglePrintJob())
// {
// }
// else
// {
pTargetView->ExecPrint( aOptions, IsMergeSilent(), rMergeDescriptor.bPrintAsync );
// }
}
xTargetDocShell->DoClose();
}
//remove the temporary files
::std::vector<String>::iterator aFileIter;
for(aFileIter = aFilesToRemove.begin();
aFileIter != aFilesToRemove.end(); aFileIter++)
SWUnoHelper::UCB_DeleteFile( *aFileIter );
2000-09-18 16:15:01 +00:00
// Alle Dispatcher freigeben
pViewFrm = SfxViewFrame::GetFirst(pSourrceDocSh);
2000-09-18 16:15:01 +00:00
while (pViewFrm)
{
pViewFrm->GetDispatcher()->Lock(FALSE);
pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourrceDocSh);
2000-09-18 16:15:01 +00:00
}
SW_MOD()->SetView(&pSourceShell->GetView());
2000-09-18 16:15:01 +00:00
}
nMergeType = DBMGR_INSERT;
}
if(bEMail)
{
xMailDispatcher->stop();
xMailDispatcher->shutdown();
}
2000-09-18 16:15:01 +00:00
return bLoop;
}
IMPL_LINK_INLINE_START( SwNewDBMgr, PrtCancelHdl, Button *, pButton )
{
pButton->GetParent()->Hide();
bCancel = TRUE;
return 0;
}
IMPL_LINK_INLINE_END( SwNewDBMgr, PrtCancelHdl, Button *, pButton )
/*--------------------------------------------------------------------
Beschreibung: Numberformat der Spalte ermitteln und ggfs. in
den uebergebenen Formatter uebertragen
--------------------------------------------------------------------*/
ULONG SwNewDBMgr::GetColumnFmt( const String& rDBName,
const String& rTableName,
const String& rColNm,
SvNumberFormatter* pNFmtr,
long nLanguage )
{
ULONG nRet = 0;
if(pNFmtr)
{
uno::Reference< XDataSource> xSource;
uno::Reference< XConnection> xConnection;
sal_Bool bUseMergeData = sal_False;
uno::Reference< XColumnsSupplier> xColsSupp;
CWS-TOOLING: integrate CWS os132 2009-07-21 15:24:18 +0200 os r274201 : #i103696# SwXTextPortion/SwXParagraph excluded 2009-07-15 13:19:17 +0200 os r274007 : #i103564# typo 2009-07-15 13:09:30 +0200 os r274005 : #i103564# SwFrames::hasElements 2009-07-15 13:02:16 +0200 os r274003 : #i103564# SwXBookmark::getPropertySetInfo fixed 2009-06-26 10:11:00 +0200 os r273395 : CWS-TOOLING: rebase CWS os132 to trunk@272827 (milestone: DEV300:m50) 2009-06-23 08:52:24 +0200 os r273256 : #i102764# patch: attribute ListBoxes correctly handled in ::Reset() 2009-06-23 08:51:31 +0200 os r273255 : #i102764# ResetColor() added to remove background color 2009-06-22 14:57:38 +0200 os r273233 : #i102619# prevent access to already destroyed shell 2009-06-18 13:26:51 +0200 os r273112 : #i99508# ::insertTextContent: re-route to ::attach() 2009-06-18 10:59:53 +0200 os r273107 : #i85405# patch to enable 'Print grid' CheckBox correctly 2009-06-18 10:54:02 +0200 os r273106 : #i85133# dispose connection in GetColumnFmt to prevent connection locking 2009-06-18 10:24:31 +0200 os r273104 : #99535# ExportGraphic changed 2009-06-18 10:24:03 +0200 os r273103 : #99535# ExportGraphic changed 2009-06-18 10:23:11 +0200 os r273102 : #i102841# redlining mode switches to insert mode (cmc) 2009-06-17 14:05:42 +0200 os r273070 : #i102111# do not save already saved HTML documents before switching to source veiw 2009-06-17 13:18:20 +0200 os r273063 : #i101825# set rembered start position at the real start not at the initial start 2009-06-17 08:24:10 +0200 os r273048 : #99535# no dierect access to the file picker interface 2009-06-16 15:00:12 +0200 os r273020 : #i99937# notification of user options changes re-introduced 2009-06-15 14:36:03 +0200 os r272987 : #i98032# unreplaced text in protected areas must not be attributed either 2009-06-15 14:20:26 +0200 os r272985 : #i98032# replace list has to be initialised 2009-06-04 13:29:02 +0200 os r272624 : #i97810# set focus into column page 2009-06-04 11:01:14 +0200 os r272617 : #i98164# dialog resize to ease localisation 2009-06-04 10:59:44 +0200 os r272616 : #i98164# dialog resize to ease localisation 2009-05-28 16:05:03 +0200 os r272413 : #i98172# ConvertFieldsToText: take care of tabs with attributes 2009-05-28 11:12:45 +0200 os r272385 : #i59361# dialog controls resized 2009-05-28 11:03:14 +0200 os r272383 : #i59174# dialog controls moved
2009-08-06 12:44:16 +00:00
bool bDisposeConnection = false;
if(pImpl->pMergeData &&
pImpl->pMergeData->sDataSource.equals(rDBName) && pImpl->pMergeData->sCommand.equals(rTableName))
{
xConnection = pImpl->pMergeData->xConnection;
xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,rDBName);
bUseMergeData = sal_True;
xColsSupp = xColsSupp.query( pImpl->pMergeData->xResultSet );
}
if(!xConnection.is())
{
SwDBData aData;
aData.sDataSource = rDBName;
aData.sCommand = rTableName;
aData.nCommandType = -1;
SwDSParam* pParam = FindDSData(aData, FALSE);
if(pParam && pParam->xConnection.is())
{
xConnection = pParam->xConnection;
xColsSupp = xColsSupp.query( pParam->xResultSet );
}
else
2002-10-24 12:48:08 +00:00
{
rtl::OUString sDBName(rDBName);
xConnection = RegisterConnection( sDBName );
CWS-TOOLING: integrate CWS os132 2009-07-21 15:24:18 +0200 os r274201 : #i103696# SwXTextPortion/SwXParagraph excluded 2009-07-15 13:19:17 +0200 os r274007 : #i103564# typo 2009-07-15 13:09:30 +0200 os r274005 : #i103564# SwFrames::hasElements 2009-07-15 13:02:16 +0200 os r274003 : #i103564# SwXBookmark::getPropertySetInfo fixed 2009-06-26 10:11:00 +0200 os r273395 : CWS-TOOLING: rebase CWS os132 to trunk@272827 (milestone: DEV300:m50) 2009-06-23 08:52:24 +0200 os r273256 : #i102764# patch: attribute ListBoxes correctly handled in ::Reset() 2009-06-23 08:51:31 +0200 os r273255 : #i102764# ResetColor() added to remove background color 2009-06-22 14:57:38 +0200 os r273233 : #i102619# prevent access to already destroyed shell 2009-06-18 13:26:51 +0200 os r273112 : #i99508# ::insertTextContent: re-route to ::attach() 2009-06-18 10:59:53 +0200 os r273107 : #i85405# patch to enable 'Print grid' CheckBox correctly 2009-06-18 10:54:02 +0200 os r273106 : #i85133# dispose connection in GetColumnFmt to prevent connection locking 2009-06-18 10:24:31 +0200 os r273104 : #99535# ExportGraphic changed 2009-06-18 10:24:03 +0200 os r273103 : #99535# ExportGraphic changed 2009-06-18 10:23:11 +0200 os r273102 : #i102841# redlining mode switches to insert mode (cmc) 2009-06-17 14:05:42 +0200 os r273070 : #i102111# do not save already saved HTML documents before switching to source veiw 2009-06-17 13:18:20 +0200 os r273063 : #i101825# set rembered start position at the real start not at the initial start 2009-06-17 08:24:10 +0200 os r273048 : #99535# no dierect access to the file picker interface 2009-06-16 15:00:12 +0200 os r273020 : #i99937# notification of user options changes re-introduced 2009-06-15 14:36:03 +0200 os r272987 : #i98032# unreplaced text in protected areas must not be attributed either 2009-06-15 14:20:26 +0200 os r272985 : #i98032# replace list has to be initialised 2009-06-04 13:29:02 +0200 os r272624 : #i97810# set focus into column page 2009-06-04 11:01:14 +0200 os r272617 : #i98164# dialog resize to ease localisation 2009-06-04 10:59:44 +0200 os r272616 : #i98164# dialog resize to ease localisation 2009-05-28 16:05:03 +0200 os r272413 : #i98172# ConvertFieldsToText: take care of tabs with attributes 2009-05-28 11:12:45 +0200 os r272385 : #i59361# dialog controls resized 2009-05-28 11:03:14 +0200 os r272383 : #i59174# dialog controls moved
2009-08-06 12:44:16 +00:00
bDisposeConnection = true;
2002-10-24 12:48:08 +00:00
}
if(bUseMergeData)
pImpl->pMergeData->xConnection = xConnection;
}
bool bDispose = !xColsSupp.is();
if(bDispose)
{
xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
}
if(xColsSupp.is())
{
uno::Reference<XNameAccess> xCols;
try
{
xCols = xColsSupp->getColumns();
}
catch(Exception&)
{
DBG_ERROR("Exception in getColumns()");
}
2001-07-20 09:07:05 +00:00
if(!xCols.is() || !xCols->hasByName(rColNm))
return nRet;
Any aCol = xCols->getByName(rColNm);
uno::Reference< XPropertySet > xColumn;
aCol >>= xColumn;
nRet = GetColumnFmt(xSource, xConnection, xColumn, pNFmtr, nLanguage);
if(bDispose)
{
::comphelper::disposeComponent( xColsSupp );
}
CWS-TOOLING: integrate CWS os132 2009-07-21 15:24:18 +0200 os r274201 : #i103696# SwXTextPortion/SwXParagraph excluded 2009-07-15 13:19:17 +0200 os r274007 : #i103564# typo 2009-07-15 13:09:30 +0200 os r274005 : #i103564# SwFrames::hasElements 2009-07-15 13:02:16 +0200 os r274003 : #i103564# SwXBookmark::getPropertySetInfo fixed 2009-06-26 10:11:00 +0200 os r273395 : CWS-TOOLING: rebase CWS os132 to trunk@272827 (milestone: DEV300:m50) 2009-06-23 08:52:24 +0200 os r273256 : #i102764# patch: attribute ListBoxes correctly handled in ::Reset() 2009-06-23 08:51:31 +0200 os r273255 : #i102764# ResetColor() added to remove background color 2009-06-22 14:57:38 +0200 os r273233 : #i102619# prevent access to already destroyed shell 2009-06-18 13:26:51 +0200 os r273112 : #i99508# ::insertTextContent: re-route to ::attach() 2009-06-18 10:59:53 +0200 os r273107 : #i85405# patch to enable 'Print grid' CheckBox correctly 2009-06-18 10:54:02 +0200 os r273106 : #i85133# dispose connection in GetColumnFmt to prevent connection locking 2009-06-18 10:24:31 +0200 os r273104 : #99535# ExportGraphic changed 2009-06-18 10:24:03 +0200 os r273103 : #99535# ExportGraphic changed 2009-06-18 10:23:11 +0200 os r273102 : #i102841# redlining mode switches to insert mode (cmc) 2009-06-17 14:05:42 +0200 os r273070 : #i102111# do not save already saved HTML documents before switching to source veiw 2009-06-17 13:18:20 +0200 os r273063 : #i101825# set rembered start position at the real start not at the initial start 2009-06-17 08:24:10 +0200 os r273048 : #99535# no dierect access to the file picker interface 2009-06-16 15:00:12 +0200 os r273020 : #i99937# notification of user options changes re-introduced 2009-06-15 14:36:03 +0200 os r272987 : #i98032# unreplaced text in protected areas must not be attributed either 2009-06-15 14:20:26 +0200 os r272985 : #i98032# replace list has to be initialised 2009-06-04 13:29:02 +0200 os r272624 : #i97810# set focus into column page 2009-06-04 11:01:14 +0200 os r272617 : #i98164# dialog resize to ease localisation 2009-06-04 10:59:44 +0200 os r272616 : #i98164# dialog resize to ease localisation 2009-05-28 16:05:03 +0200 os r272413 : #i98172# ConvertFieldsToText: take care of tabs with attributes 2009-05-28 11:12:45 +0200 os r272385 : #i59361# dialog controls resized 2009-05-28 11:03:14 +0200 os r272383 : #i59174# dialog controls moved
2009-08-06 12:44:16 +00:00
if(bDisposeConnection)
{
::comphelper::disposeComponent( xConnection );
}
}
else
nRet = pNFmtr->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM );
}
return nRet;
}
ULONG SwNewDBMgr::GetColumnFmt( uno::Reference< XDataSource> xSource,
uno::Reference< XConnection> xConnection,
uno::Reference< XPropertySet> xColumn,
SvNumberFormatter* pNFmtr,
long nLanguage )
{
//JP 12.01.99: ggfs. das NumberFormat im Doc setzen
ULONG nRet = 0;
if(!xSource.is())
{
uno::Reference<XChild> xChild(xConnection, UNO_QUERY);
xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
}
if(xSource.is() && xConnection.is() && xColumn.is() && pNFmtr)
2000-09-18 16:15:01 +00:00
{
SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj( pNFmtr );
uno::Reference< util::XNumberFormatsSupplier > xDocNumFmtsSupplier = pNumFmt;
uno::Reference< XNumberFormats > xDocNumberFormats = xDocNumFmtsSupplier->getNumberFormats();
uno::Reference< XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY);
2000-09-18 16:15:01 +00:00
Locale aLocale( MsLangId::convertLanguageToLocale( (LanguageType)nLanguage ));
2000-09-18 16:15:01 +00:00
//get the number formatter of the data source
uno::Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
uno::Reference< XNumberFormats > xNumberFormats;
2000-09-18 16:15:01 +00:00
if(xSourceProps.is())
{
Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
if(aFormats.hasValue())
{
uno::Reference<XNumberFormatsSupplier> xSuppl;
aFormats >>= xSuppl;
2000-09-18 16:15:01 +00:00
if(xSuppl.is())
{
xNumberFormats = xSuppl->getNumberFormats();
}
}
}
bool bUseDefault = true;
try
2000-09-18 16:15:01 +00:00
{
Any aFormatKey = xColumn->getPropertyValue(C2U("FormatKey"));
if(aFormatKey.hasValue())
2000-09-18 16:15:01 +00:00
{
sal_Int32 nFmt = 0;
aFormatKey >>= nFmt;
if(xNumberFormats.is())
{
try
{
uno::Reference<XPropertySet> xNumProps = xNumberFormats->getByKey( nFmt );
Any aFormatString = xNumProps->getPropertyValue(C2U("FormatString"));
Any aLocaleVal = xNumProps->getPropertyValue(C2U("Locale"));
rtl::OUString sFormat;
aFormatString >>= sFormat;
lang::Locale aLoc;
aLocaleVal >>= aLoc;
nFmt = xDocNumberFormats->queryKey( sFormat, aLoc, sal_False );
if(NUMBERFORMAT_ENTRY_NOT_FOUND == sal::static_int_cast< sal_uInt32, sal_Int32>(nFmt))
nFmt = xDocNumberFormats->addNew( sFormat, aLoc );
nRet = nFmt;
bUseDefault = false;
}
catch(const Exception&)
{
DBG_ERROR("illegal number format key");
}
2000-09-18 16:15:01 +00:00
}
}
}
catch( const Exception& )
{
DBG_ERROR("no FormatKey property found");
}
if(bUseDefault)
nRet = SwNewDBMgr::GetDbtoolsClient().getDefaultNumberFormat(xColumn, xDocNumberFormatTypes, aLocale);
2000-09-18 16:15:01 +00:00
}
return nRet;
}
2000-09-18 16:15:01 +00:00
sal_Int32 SwNewDBMgr::GetColumnType( const String& rDBName,
const String& rTableName,
const String& rColNm )
{
sal_Int32 nRet = DataType::SQLNULL;
SwDBData aData;
aData.sDataSource = rDBName;
aData.sCommand = rTableName;
aData.nCommandType = -1;
SwDSParam* pParam = FindDSData(aData, FALSE);
uno::Reference< XConnection> xConnection;
uno::Reference< XColumnsSupplier > xColsSupp;
bool bDispose = false;
if(pParam && pParam->xConnection.is())
{
xConnection = pParam->xConnection;
xColsSupp = uno::Reference< XColumnsSupplier >( pParam->xResultSet, UNO_QUERY );
}
else
2002-10-24 12:48:08 +00:00
{
rtl::OUString sDBName(rDBName);
xConnection = RegisterConnection( sDBName );
}
if( !xColsSupp.is() )
{
xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
bDispose = true;
}
2000-09-18 16:15:01 +00:00
if(xColsSupp.is())
{
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
2000-09-18 16:15:01 +00:00
if(xCols->hasByName(rColNm))
{
Any aCol = xCols->getByName(rColNm);
uno::Reference<XPropertySet> xCol;
aCol >>= xCol;
2000-09-18 16:15:01 +00:00
Any aType = xCol->getPropertyValue(C2S("Type"));
aType >>= nRet;
}
if(bDispose)
::comphelper::disposeComponent( xColsSupp );
2000-09-18 16:15:01 +00:00
}
return nRet;
}
uno::Reference< sdbc::XConnection> SwNewDBMgr::GetConnection(const String& rDataSource,
uno::Reference<XDataSource>& rxSource)
2000-09-18 16:15:01 +00:00
{
Reference< sdbc::XConnection> xConnection;
2000-10-20 13:18:07 +00:00
Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
try
2000-09-18 16:15:01 +00:00
{
Reference<XCompletedConnection> xComplConnection(SwNewDBMgr::GetDbtoolsClient().getDataSource(rDataSource, xMgr),UNO_QUERY);
if ( xComplConnection.is() )
2000-09-18 16:15:01 +00:00
{
rxSource.set(xComplConnection,UNO_QUERY);
Reference< XInteractionHandler > xHandler(
autorecovery: more sophisticated configuration data for interaction handlers The generic css.task.InteractionHandler implementation in module uui is now able to instantiate "sub handlers", i.e. components to delegate a request to, based on the type of the request, and some configuration data. The "old" (and now deprecated) configuration scheme at org.openoffice.ucb.InteractionHandler did not contain type information, so any handlers registered there were always called when no default implementation for a given request was available. The "new" configuration scheme at org.openoffice.Interaction contains UNO type information. That is, a given handler implementation can declare itself responsible for an arbitrary set of UNO types, and for each of those types, whether it is also responsible for sub types. The generic interaction handler implementation uses this configuration data, when it encounteres an interaction request it cannot fullfill itself, to instantiate a component to delegate the request to. As with the "old" data, such a component is required to support the css.task.XInteractionHandler2 interface. Also, if it supports css.lang.XInitialization, then it will be initialized with a name-value pair, the name being "Parent", the value being the XWindow interface of the parent window for any message boxes. As an examplary implementation for this feature, the css.sdb.InteractionHandler has been deprecated. Now the css.sdb.DatabaseInteractionHandler is reponsible for database-related interactions, and the new configuration scheme is pre-filled with data assigning this responsibility. Consequently, a lot of places previously creating an css.sdb.InteractionHandler have been modified to create the default css.task.InteractionHandler.
2010-02-01 21:32:33 +01:00
xMgr->createInstance( C2U( "com.sun.star.task.InteractionHandler" )), UNO_QUERY);
2000-12-01 10:45:55 +00:00
xConnection = xComplConnection->connectWithCompletion( xHandler );
2000-09-18 16:15:01 +00:00
}
}
catch(Exception&) {}
2000-09-18 16:15:01 +00:00
return xConnection;
}
uno::Reference< sdbcx::XColumnsSupplier> SwNewDBMgr::GetColumnSupplier(uno::Reference<sdbc::XConnection> xConnection,
2000-09-18 16:15:01 +00:00
const String& rTableOrQuery,
BYTE eTableOrQuery)
{
Reference< sdbcx::XColumnsSupplier> xRet;
try
2000-09-18 16:15:01 +00:00
{
if(eTableOrQuery == SW_DB_SELECT_UNKNOWN)
2000-09-18 16:15:01 +00:00
{
//search for a table with the given command name
Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
if(xTSupplier.is())
{
Reference<XNameAccess> xTbls = xTSupplier->getTables();
eTableOrQuery = xTbls->hasByName(rTableOrQuery) ?
SW_DB_SELECT_TABLE : SW_DB_SELECT_QUERY;
}
2000-09-18 16:15:01 +00:00
}
sal_Int32 nCommandType = SW_DB_SELECT_TABLE == eTableOrQuery ?
CommandType::TABLE : CommandType::QUERY;
Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
Reference<XRowSet> xRowSet(
xMgr->createInstance(C2U("com.sun.star.sdb.RowSet")), UNO_QUERY);
::rtl::OUString sDataSource;
Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(xConnection, sDataSource);
Reference<XPropertySet> xSourceProperties(xSource, UNO_QUERY);
if(xSourceProperties.is())
2000-09-18 16:15:01 +00:00
{
xSourceProperties->getPropertyValue(C2U("Name")) >>= sDataSource;
2000-09-18 16:15:01 +00:00
}
Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY);
xRowProperties->setPropertyValue(C2U("DataSourceName"), makeAny(sDataSource));
xRowProperties->setPropertyValue(C2U("Command"), makeAny(::rtl::OUString(rTableOrQuery)));
xRowProperties->setPropertyValue(C2U("CommandType"), makeAny(nCommandType));
xRowProperties->setPropertyValue(C2U("FetchSize"), makeAny((sal_Int32)10));
xRowProperties->setPropertyValue(C2U("ActiveConnection"), makeAny(xConnection));
xRowSet->execute();
xRet = Reference<XColumnsSupplier>( xRowSet, UNO_QUERY );
2000-09-18 16:15:01 +00:00
}
catch( const uno::Exception& )
{
DBG_ERROR("Exception in SwDBMgr::GetColumnSupplier");
}
2000-09-18 16:15:01 +00:00
return xRet;
}
String SwNewDBMgr::GetDBField(uno::Reference<XPropertySet> xColumnProps,
2000-09-18 16:15:01 +00:00
const SwDBFormatData& rDBFormatData,
double* pNumber)
{
uno::Reference< XColumn > xColumn(xColumnProps, UNO_QUERY);
2000-09-18 16:15:01 +00:00
String sRet;
DBG_ASSERT(xColumn.is(), "SwNewDBMgr::::ImportDBField: illegal arguments");
2000-09-18 16:15:01 +00:00
if(!xColumn.is())
return sRet;
Any aType = xColumnProps->getPropertyValue(C2U("Type"));
sal_Int32 eDataType = 0;
2000-09-18 16:15:01 +00:00
aType >>= eDataType;
switch(eDataType)
{
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
try
{
sRet = xColumn->getString();
}
catch( SQLException& )
{
}
2000-09-18 16:15:01 +00:00
break;
case DataType::BIT:
case DataType::BOOLEAN:
2000-09-18 16:15:01 +00:00
case DataType::TINYINT:
case DataType::SMALLINT:
case DataType::INTEGER:
case DataType::BIGINT:
case DataType::FLOAT:
case DataType::REAL:
case DataType::DOUBLE:
case DataType::NUMERIC:
case DataType::DECIMAL:
case DataType::DATE:
case DataType::TIME:
case DataType::TIMESTAMP:
{
// ::Date aTempDate(rDBFormatData.aNullDate.Day,
// rDBFormatData.aNullDate.Month, rDBFormatData.aNullDate.Year);
2000-09-18 16:15:01 +00:00
try
{
SwDbtoolsClient& aClient = SwNewDBMgr::GetDbtoolsClient();
sRet = aClient.getValue(
2000-09-18 16:15:01 +00:00
xColumnProps,
rDBFormatData.xFormatter,
rDBFormatData.aLocale,
rDBFormatData.aNullDate);
2000-09-18 16:15:01 +00:00
if (pNumber)
{
double fVal = xColumn->getDouble();
if(!xColumn->wasNull())
{
*pNumber = fVal;
}
}
2000-09-18 16:15:01 +00:00
}
catch(Exception& )
2000-09-18 16:15:01 +00:00
{
DBG_ERROR("exception caught");
2000-09-18 16:15:01 +00:00
}
}
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;
}
2010-10-11 17:38:56 -05:00
2000-09-18 16:15:01 +00:00
/* -----------------------------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");
2000-09-18 16:15:01 +00:00
bInMerge = FALSE;
delete pImpl->pMergeData;
pImpl->pMergeData = 0;
2000-09-18 16:15:01 +00:00
}
2010-10-11 17:38:56 -05:00
2000-09-18 16:15:01 +00:00
/* -----------------------------06.07.00 14:28--------------------------------
checks if a desired data source table or query is open
---------------------------------------------------------------------------*/
BOOL SwNewDBMgr::IsDataSourceOpen(const String& rDataSource,
const String& rTableOrQuery, sal_Bool bMergeOnly)
2000-09-18 16:15:01 +00:00
{
if(pImpl->pMergeData)
2000-09-18 16:15:01 +00:00
{
return !bMergeLock &&
((rDataSource == (String)pImpl->pMergeData->sDataSource &&
rTableOrQuery == (String)pImpl->pMergeData->sCommand)
||(!rDataSource.Len() && !rTableOrQuery.Len()))
&&
pImpl->pMergeData->xResultSet.is();
2000-09-18 16:15: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
}
2010-10-11 17:38:56 -05:00
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;
SwDSParam* pFound = 0;
2000-09-18 16:15:01 +00:00
//check if it's the merge data source
if(pImpl->pMergeData &&
rSourceName == (String)pImpl->pMergeData->sDataSource &&
rTableName == (String)pImpl->pMergeData->sCommand)
2000-09-18 16:15:01 +00:00
{
pFound = pImpl->pMergeData;
}
else
{
SwDBData aData;
aData.sDataSource = rSourceName;
aData.sCommand = rTableName;
aData.nCommandType = -1;
pFound = FindDSData(aData, FALSE);
}
//check validity of supplied record Id
if(pFound->aSelection.getLength())
{
//the destination has to be an element of the selection
const Any* pSelection = pFound->aSelection.getConstArray();
sal_Bool bFound = sal_False;
for(sal_Int32 nPos = 0; !bFound && nPos < pFound->aSelection.getLength(); nPos++)
{
sal_Int32 nSelection = 0;
pSelection[nPos] >>= nSelection;
if(nSelection == static_cast<sal_Int32>(nAbsRecordId))
bFound = sal_True;
}
if(!bFound)
return FALSE;
}
if(pFound && pFound->xResultSet.is() && !pFound->bAfterSelection)
{
2001-12-11 10:24:42 +00:00
sal_Int32 nOldRow = 0;
try
{
nOldRow = pFound->xResultSet->getRow();
}
catch(const Exception& )
2001-12-11 10:24:42 +00:00
{
return FALSE;
}
2000-09-18 16:15:01 +00:00
//position to the desired index
BOOL bMove = TRUE;
if ( nOldRow != static_cast<sal_Int32>(nAbsRecordId) )
bMove = lcl_MoveAbsolute(pFound, nAbsRecordId);
2000-09-18 16:15:01 +00:00
if(bMove)
{
bRet = lcl_GetColumnCnt(pFound, rColumnName, nLanguage, rResult, pNumber);
2000-09-18 16:15:01 +00:00
}
if ( nOldRow != static_cast<sal_Int32>(nAbsRecordId) )
bMove = lcl_MoveAbsolute(pFound, nOldRow);
2000-09-18 16:15:01 +00:00
}
return bRet;
}
2010-10-11 17:38:56 -05:00
2000-09-18 16:15:01 +00:00
/* -----------------------------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*/)
2000-09-18 16:15:01 +00:00
{
if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is() || pImpl->pMergeData->bAfterSelection )
{
rResult.Erase();
2000-09-18 16:15:01 +00:00
return FALSE;
}
2000-09-18 16:15:01 +00:00
BOOL bRet = lcl_GetColumnCnt(pImpl->pMergeData, rColumnName, nLanguage, rResult, pNumber);
2000-09-18 16:15:01 +00:00
return bRet;
}
BOOL SwNewDBMgr::ToNextMergeRecord()
{
DBG_ASSERT(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
return ToNextRecord(pImpl->pMergeData);
}
BOOL SwNewDBMgr::ToNextRecord(
const String& rDataSource, const String& rCommand, sal_Int32 /*nCommandType*/)
{
SwDSParam* pFound = 0;
if(pImpl->pMergeData &&
rDataSource == (String)pImpl->pMergeData->sDataSource &&
rCommand == (String)pImpl->pMergeData->sCommand)
pFound = pImpl->pMergeData;
else
{
SwDBData aData;
aData.sDataSource = rDataSource;
aData.sCommand = rCommand;
aData.nCommandType = -1;
pFound = FindDSData(aData, FALSE);
}
return ToNextRecord(pFound);
}
BOOL SwNewDBMgr::ToNextRecord(SwDSParam* pParam)
{
BOOL bRet = TRUE;
2001-10-16 10:10:55 +00:00
if(!pParam || !pParam->xResultSet.is() || pParam->bEndOfDB ||
(pParam->aSelection.getLength() && pParam->aSelection.getLength() <= pParam->nSelectionIndex))
{
if(pParam)
pParam->CheckEndOfDB();
2000-09-18 16:15:01 +00:00
return FALSE;
}
2000-09-18 16:15:01 +00:00
try
{
if(pParam->aSelection.getLength())
2000-11-13 07:32:00 +00:00
{
sal_Int32 nPos = 0;
pParam->aSelection.getConstArray()[ pParam->nSelectionIndex++ ] >>= nPos;
pParam->bEndOfDB = !pParam->xResultSet->absolute( nPos );
pParam->CheckEndOfDB();
bRet = !pParam->bEndOfDB;
if(pParam->nSelectionIndex >= pParam->aSelection.getLength())
pParam->bEndOfDB = TRUE;
2000-11-13 07:32:00 +00:00
}
2000-09-18 16:15:01 +00:00
else
{
sal_Int32 nBefore = pParam->xResultSet->getRow();
pParam->bEndOfDB = !pParam->xResultSet->next();
if( !pParam->bEndOfDB && nBefore == pParam->xResultSet->getRow())
{
//next returned true but it didn't move
pParam->bEndOfDB = sal_True;
}
pParam->CheckEndOfDB();
bRet = !pParam->bEndOfDB;
++pParam->nSelectionIndex;
2000-09-18 16:15:01 +00:00
}
}
catch(Exception&)
2000-09-18 16:15:01 +00:00
{
}
return bRet;
2000-09-18 16:15: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
{
return pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB;
2000-09-18 16:15:01 +00:00
}
sal_uInt32 SwNewDBMgr::GetSelectedRecordId()
{
sal_uInt32 nRet = 0;
DBG_ASSERT(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is())
2000-09-18 16:15:01 +00:00
return FALSE;
try
{
nRet = pImpl->pMergeData->xResultSet->getRow();
2000-09-18 16:15:01 +00:00
}
catch(Exception& )
2000-09-18 16:15:01 +00:00
{
}
return nRet;
}
sal_Bool SwNewDBMgr::ToRecordId(sal_Int32 nSet)
{
DBG_ASSERT(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is()|| nSet < 0)
2000-09-18 16:15:01 +00:00
return FALSE;
sal_Bool bRet = FALSE;
sal_Int32 nAbsPos = nSet;
2000-09-18 16:15:01 +00:00
if(nAbsPos >= 0)
{
bRet = lcl_MoveAbsolute(pImpl->pMergeData, nAbsPos);
pImpl->pMergeData->bEndOfDB = !bRet;
pImpl->pMergeData->CheckEndOfDB();
2000-09-18 16:15:01 +00:00
}
return bRet;
}
BOOL SwNewDBMgr::OpenDataSource(const String& rDataSource, const String& rTableOrQuery,
sal_Int32 nCommandType, bool bCreate)
2000-09-18 16:15:01 +00:00
{
SwDBData aData;
aData.sDataSource = rDataSource;
aData.sCommand = rTableOrQuery;
aData.nCommandType = nCommandType;
SwDSParam* pFound = FindDSData(aData, TRUE);
uno::Reference< XDataSource> xSource;
2000-09-18 16:15:01 +00:00
if(pFound->xResultSet.is())
return TRUE;
SwDSParam* pParam = FindDSConnection(rDataSource, FALSE);
uno::Reference< XConnection> xConnection;
if(pParam && pParam->xConnection.is())
pFound->xConnection = pParam->xConnection;
else if(bCreate)
2002-10-24 12:48:08 +00:00
{
rtl::OUString sDataSource(rDataSource);
pFound->xConnection = RegisterConnection( sDataSource );
}
2000-09-18 16:15:01 +00:00
if(pFound->xConnection.is())
{
try
{
uno::Reference< sdbc::XDatabaseMetaData > xMetaData = pFound->xConnection->getMetaData();
try
{
pFound->bScrollable = xMetaData
2000-09-18 16:15:01 +00:00
->supportsResultSetType((sal_Int32)ResultSetType::SCROLL_INSENSITIVE);
}
catch(Exception&)
{
//#98373# DB driver may not be ODBC 3.0 compliant
pFound->bScrollable = TRUE;
}
2000-09-18 16:15:01 +00:00
pFound->xStatement = pFound->xConnection->createStatement();
2001-09-04 11:40:59 +00:00
rtl::OUString aQuoteChar = xMetaData->getIdentifierQuoteString();
rtl::OUString sStatement(C2U("SELECT * FROM "));
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
pFound->bEndOfDB = !pFound->xResultSet->next();
pFound->bAfterSelection = sal_False;
pFound->CheckEndOfDB();
++pFound->nSelectionIndex;
2000-09-18 16:15:01 +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();
}
uno::Reference< XConnection> SwNewDBMgr::RegisterConnection(rtl::OUString& rDataSource)
{
SwDSParam* pFound = SwNewDBMgr::FindDSConnection(rDataSource, TRUE);
uno::Reference< XDataSource> xSource;
if(!pFound->xConnection.is())
{
pFound->xConnection = SwNewDBMgr::GetConnection(rDataSource, xSource );
try
{
uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
if(xComponent.is())
xComponent->addEventListener(pImpl->xDisposeListener);
}
catch(Exception&)
{
}
}
return pFound->xConnection;
}
2000-09-18 16:15:01 +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 = 0xffffffff;
2000-09-18 16:15:01 +00:00
//check for merge data source first
if(pImpl->pMergeData && rDataSource == (String)pImpl->pMergeData->sDataSource &&
rTableOrQuery == (String)pImpl->pMergeData->sCommand &&
(nCommandType == -1 || nCommandType == pImpl->pMergeData->nCommandType) &&
pImpl->pMergeData->xResultSet.is())
2000-09-18 16:15:01 +00:00
nRet = GetSelectedRecordId();
else
{
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
{ //if a selection array is set the current row at the result set may not be set yet
if(pFound->aSelection.getLength())
{
sal_Int32 nSelIndex = pFound->nSelectionIndex;
if(nSelIndex >= pFound->aSelection.getLength())
nSelIndex = pFound->aSelection.getLength() -1;
pFound->aSelection.getConstArray()[nSelIndex] >>= nRet;
}
else
nRet = pFound->xResultSet->getRow();
2000-09-18 16:15:01 +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)
{
//the only thing done here is to reset the selection index
//all connections stay open
for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++)
{
SwDSParam* pParam = aDataSourceParams[nPos];
if(bIncludingMerge || pParam != pImpl->pMergeData)
{
pParam->nSelectionIndex = 0;
pParam->bAfterSelection = sal_False;
pParam->bEndOfDB = sal_False;
try
{
if(!bInMerge && pParam->xResultSet.is())
pParam->xResultSet->first();
}
catch(Exception& )
{}
}
}
2000-09-18 16:15:01 +00:00
}
SwDSParam* SwNewDBMgr::FindDSData(const SwDBData& rData, BOOL bCreate)
2000-09-18 16:15:01 +00:00
{
//prefer merge data if available
if(pImpl->pMergeData && rData.sDataSource == pImpl->pMergeData->sDataSource &&
rData.sCommand == pImpl->pMergeData->sCommand &&
(rData.nCommandType == -1 || rData.nCommandType == pImpl->pMergeData->nCommandType ||
(bCreate && pImpl->pMergeData->nCommandType == -1)))
{
return pImpl->pMergeData;
}
2000-09-18 16:15:01 +00:00
SwDSParam* pFound = 0;
for(USHORT nPos = aDataSourceParams.Count(); nPos; nPos--)
2000-09-18 16:15:01 +00:00
{
SwDSParam* pParam = aDataSourceParams[nPos - 1];
if(rData.sDataSource == pParam->sDataSource &&
rData.sCommand == pParam->sCommand &&
(rData.nCommandType == -1 || rData.nCommandType == pParam->nCommandType ||
(bCreate && pParam->nCommandType == -1)))
2000-09-18 16:15:01 +00:00
{
//#94779# calls from the calculator may add a connection with an invalid commandtype
//later added "real" data base connections have to re-use the already available
//DSData and set the correct CommandType
if(bCreate && pParam->nCommandType == -1)
pParam->nCommandType = rData.nCommandType;
2000-09-18 16:15:01 +00:00
pFound = pParam;
break;
}
}
if(bCreate)
{
if(!pFound)
{
pFound = new SwDSParam(rData);
2000-09-18 16:15:01 +00:00
aDataSourceParams.Insert(pFound, aDataSourceParams.Count());
try
{
uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
if(xComponent.is())
xComponent->addEventListener(pImpl->xDisposeListener);
}
catch(Exception&)
{
}
2000-09-18 16:15:01 +00:00
}
}
return pFound;
}
2001-09-04 11:40:59 +00:00
SwDSParam* SwNewDBMgr::FindDSConnection(const rtl::OUString& rDataSource, BOOL bCreate)
{
//prefer merge data if available
if(pImpl->pMergeData && rDataSource == pImpl->pMergeData->sDataSource )
{
return pImpl->pMergeData;
}
SwDSParam* pFound = 0;
for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++)
{
SwDSParam* pParam = aDataSourceParams[nPos];
if(rDataSource == pParam->sDataSource)
{
pFound = pParam;
break;
}
}
if(bCreate && !pFound)
{
SwDBData aData;
aData.sDataSource = rDataSource;
pFound = new SwDSParam(aData);
aDataSourceParams.Insert(pFound, aDataSourceParams.Count());
try
{
uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
if(xComponent.is())
xComponent->addEventListener(pImpl->xDisposeListener);
}
catch(Exception&)
{
}
}
return pFound;
}
const SwDBData& SwNewDBMgr::GetAddressDBName()
2000-09-18 16:15:01 +00:00
{
return SW_MOD()->GetDBConfig()->GetAddressSource();
2000-09-18 16:15:01 +00:00
}
2001-09-04 11:40:59 +00:00
Sequence<rtl::OUString> SwNewDBMgr::GetExistingDatabaseNames()
2000-09-18 16:15:01 +00:00
{
uno::Reference<XNameAccess> xDBContext;
uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
2000-09-18 16:15:01 +00:00
if( xMgr.is() )
{
uno::Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ;
2000-09-18 16:15:01 +00:00
}
if(xDBContext.is())
{
return xDBContext->getElementNames();
}
2001-09-04 11:40:59 +00:00
return Sequence<rtl::OUString>();
2000-09-18 16:15:01 +00:00
}
String SwNewDBMgr::LoadAndRegisterDataSource()
{
sfx2::FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
String sHomePath(SvtPathOptions().GetWorkPath());
aDlgHelper.SetDisplayDirectory( sHomePath );
Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
String sFilterAll(SW_RES(STR_FILTER_ALL));
String sFilterAllData(SW_RES(STR_FILTER_ALL_DATA));
String sFilterSXB(SW_RES(STR_FILTER_SXB));
String sFilterSXC(SW_RES(STR_FILTER_SXC));
String sFilterDBF(SW_RES(STR_FILTER_DBF));
String sFilterXLS(SW_RES(STR_FILTER_XLS));
String sFilterTXT(SW_RES(STR_FILTER_TXT));
String sFilterCSV(SW_RES(STR_FILTER_CSV));
#ifdef WNT
String sFilterMDB(SW_RES(STR_FILTER_MDB));
2008-10-01 06:46:01 +00:00
String sFilterACCDB(SW_RES(STR_FILTER_ACCDB));
#endif
xFltMgr->appendFilter( sFilterAll, C2U("*") );
xFltMgr->appendFilter( sFilterAllData, C2U("*.ods;*.sxc;*.dbf;*.xls;*.txt;*.csv"));
xFltMgr->appendFilter( sFilterSXB, C2U("*.odb") );
xFltMgr->appendFilter( sFilterSXC, C2U("*.ods;*.sxc") );
xFltMgr->appendFilter( sFilterDBF, C2U("*.dbf") );
xFltMgr->appendFilter( sFilterXLS, C2U("*.xls") );
xFltMgr->appendFilter( sFilterTXT, C2U("*.txt") );
xFltMgr->appendFilter( sFilterCSV, C2U("*.csv") );
#ifdef WNT
xFltMgr->appendFilter( sFilterMDB, C2U("*.mdb") );
2008-10-01 06:46:01 +00:00
xFltMgr->appendFilter( sFilterACCDB, C2U("*.accdb") );
#endif
xFltMgr->setCurrentFilter( sFilterAll ) ;
String sFind;
bool bTextConnection = false;
if( ERRCODE_NONE == aDlgHelper.Execute() )
{
String sURL = xFP->getFiles().getConstArray()[0];
//data sources have to be registered depending on their extensions
INetURLObject aURL( sURL );
String sExt( aURL.GetExtension() );
Any aURLAny;
Any aTableFilterAny;
Any aSuppressVersionsAny;
Any aInfoAny;
INetURLObject aTempURL(aURL);
bool bStore = true;
if(sExt.EqualsAscii("odb"))
{
bStore = false;
}
else if(sExt.EqualsIgnoreCaseAscii("sxc")
|| sExt.EqualsIgnoreCaseAscii("ods")
|| sExt.EqualsIgnoreCaseAscii("xls"))
{
rtl::OUString sDBURL(C2U("sdbc:calc:"));
sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
aURLAny <<= sDBURL;
}
else if(sExt.EqualsIgnoreCaseAscii("dbf"))
{
aTempURL.removeSegment();
aTempURL.removeFinalSlash();
rtl::OUString sDBURL(C2U("sdbc:dbase:"));
sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
aURLAny <<= sDBURL;
//set the filter to the file name without extension
Sequence<rtl::OUString> aFilters(1);
rtl::OUString sTmp(aURL.getBase());
aFilters[0] = aURL.getBase();
aTableFilterAny <<= aFilters;
}
else if(sExt.EqualsIgnoreCaseAscii("csv") || sExt.EqualsIgnoreCaseAscii("txt"))
{
aTempURL.removeSegment();
aTempURL.removeFinalSlash();
rtl::OUString sDBURL(C2U("sdbc:flat:"));
//only the 'path' has to be added
sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
aURLAny <<= sDBURL;
bTextConnection = true;
//set the filter to the file name without extension
Sequence<rtl::OUString> aFilters(1);
rtl::OUString sTmp(aURL.getBase());
aFilters[0] = aURL.getBase();
aTableFilterAny <<= aFilters;
}
#ifdef WNT
else if(sExt.EqualsIgnoreCaseAscii("mdb"))
{
rtl::OUString sDBURL(C2U("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="));
sDBURL += aTempURL.PathToFileName();
aURLAny <<= sDBURL;
aSuppressVersionsAny <<= makeAny(true);
}
2008-10-01 06:46:01 +00:00
else if(sExt.EqualsIgnoreCaseAscii("accdb"))
{
rtl::OUString sDBURL(C2U("sdbc:ado:PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE="));
sDBURL += aTempURL.PathToFileName();
aURLAny <<= sDBURL;
aSuppressVersionsAny <<= makeAny(true);
}
#endif
try
{
Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
Reference<XNameAccess> xDBContext(xInstance, UNO_QUERY_THROW);
Reference<XSingleServiceFactory> xFact( xDBContext, UNO_QUERY);
String sNewName = INetURLObject::decode( aURL.getName(),
INET_HEX_ESCAPE,
INetURLObject::DECODE_UNAMBIGUOUS,
RTL_TEXTENCODING_UTF8 );
xub_StrLen nExtLen = static_cast< xub_StrLen >(aURL.GetExtension().getLength());
sNewName.Erase( sNewName.Len() - nExtLen - 1, nExtLen + 1 );
//find a unique name if sNewName already exists
sFind = sNewName;
sal_Int32 nIndex = 0;
while(xDBContext->hasByName(sFind))
{
sFind = sNewName;
sFind += String::CreateFromInt32(++nIndex);
}
Reference<XInterface> xNewInstance;
if(!bStore)
{
//odb-file
Any aDataSource = xDBContext->getByName(aTempURL.GetMainURL(INetURLObject::NO_DECODE));
aDataSource >>= xNewInstance;
}
else
{
xNewInstance = xFact->createInstance();
Reference<XPropertySet> xDataProperties(xNewInstance, UNO_QUERY);
if(aURLAny.hasValue())
xDataProperties->setPropertyValue(C2U("URL"), aURLAny);
if(aTableFilterAny.hasValue())
xDataProperties->setPropertyValue(C2U("TableFilter"), aTableFilterAny);
if(aSuppressVersionsAny.hasValue())
xDataProperties->setPropertyValue(C2U("SuppressVersionColumns"), aSuppressVersionsAny);
if(aInfoAny.hasValue())
xDataProperties->setPropertyValue(C2U("Info"), aInfoAny);
if( bTextConnection )
{
uno::Reference < ui::dialogs::XExecutableDialog > xSettingsDlg(
xMgr->createInstance( C2U( "com.sun.star.sdb.TextConnectionSettings" ) ), uno::UNO_QUERY);
if( xSettingsDlg->execute() )
{
uno::Any aSettings = xDataProperties->getPropertyValue( C2U( "Settings" ) );
uno::Reference < beans::XPropertySet > xDSSettings;
aSettings >>= xDSSettings;
::comphelper::copyProperties(
uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY ),
xDSSettings );
xDSSettings->setPropertyValue( C2U("Extension"), uno::makeAny( ::rtl::OUString( sExt )));
}
}
Reference<XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW);
Reference<XStorable> xStore(xDS->getDatabaseDocument(), UNO_QUERY_THROW);
String sOutputExt = String::CreateFromAscii(".odb");
String sTmpName;
{
utl::TempFile aTempFile(sNewName , &sOutputExt, &sHomePath);
aTempFile.EnableKillingFile(sal_True);
sTmpName = aTempFile.GetURL();
}
xStore->storeAsURL(sTmpName, Sequence< PropertyValue >());
}
Reference<XNamingService> xNaming(xDBContext, UNO_QUERY);
xNaming->registerObject( sFind, xNewInstance );
}
catch(Exception&)
{
}
}
return sFind;
}
2000-11-13 07:32:00 +00:00
void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh,
const Sequence<PropertyValue>& rProperties,
BOOL bWithDataSourceBrowser)
2000-11-13 07:32:00 +00:00
{
2001-02-16 13:58:11 +00:00
//prevent second call
if(pImpl->pMergeDialog)
2001-02-16 13:58:11 +00:00
return ;
2001-09-04 11:40:59 +00:00
rtl::OUString sDataSource, sDataTableOrQuery;
Sequence<Any> aSelection;
2000-11-13 07:32:00 +00:00
sal_Int16 nCmdType = CommandType::TABLE;
uno::Reference< XConnection> xConnection;
ODataAccessDescriptor aDescriptor(rProperties);
sDataSource = aDescriptor.getDataSource();
aDescriptor[daCommand] >>= sDataTableOrQuery;
aDescriptor[daCommandType] >>= nCmdType;
if ( aDescriptor.has(daSelection) )
aDescriptor[daSelection] >>= aSelection;
if ( aDescriptor.has(daConnection) )
aDescriptor[daConnection] >>= xConnection;
if(!sDataSource.getLength() || !sDataTableOrQuery.getLength())
2000-11-13 07:32:00 +00:00
{
DBG_ERROR("PropertyValues missing or unset");
2000-11-13 07:32:00 +00:00
return;
}
//always create a connection for the dialog and dispose it after the dialog has been closed
SwDSParam* pFound = 0;
if(!xConnection.is())
{
xConnection = SwNewDBMgr::RegisterConnection(sDataSource);
pFound = FindDSConnection(sDataSource, TRUE);
}
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "Dialogdiet fail!");
pImpl->pMergeDialog = pFact->CreateMailMergeDlg( DLG_MAILMERGE,
&rSh.GetView().GetViewFrame()->GetWindow(), rSh,
sDataSource,
sDataTableOrQuery,
nCmdType,
xConnection,
bWithDataSourceBrowser ? 0 : &aSelection);
DBG_ASSERT(pImpl->pMergeDialog, "Dialogdiet fail!");
if(pImpl->pMergeDialog->Execute() == RET_OK)
2000-11-13 07:32:00 +00:00
{
aDescriptor[daSelection] <<= pImpl->pMergeDialog->GetSelection();
uno::Reference<XResultSet> xResSet = pImpl->pMergeDialog->GetResultSet();
if(xResSet.is())
aDescriptor[daCursor] <<= xResSet;
SfxObjectShellRef xDocShell = rSh.GetView().GetViewFrame()->GetObjectShell();
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xDocShell));
{
//copy rSh to aTempFile
::rtl::OUString sTempURL;
const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
String::CreateFromAscii( FILTER_XML ),
SwDocShell::Factory().GetFilterContainer() );
try
{
uno::Sequence< beans::PropertyValue > aValues(1);
beans::PropertyValue* pValues = aValues.getArray();
pValues[0].Name = C2U("FilterName");
pValues[0].Value <<= ::rtl::OUString(pSfxFlt->GetFilterName());
uno::Reference< frame::XStorable > xStore( xDocShell->GetModel(), uno::UNO_QUERY);
sTempURL = URIHelper::SmartRel2Abs( INetURLObject(), utl::TempFile::CreateTempName() );
xStore->storeToURL( sTempURL, aValues );
}
catch( const uno::Exception& rEx )
{
(void) rEx;
}
if( xDocShell->GetError() )
{
// error message ??
ErrorHandler::HandleError( xDocShell->GetError() );
}
else
{
SfxObjectShellRef xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL ));
SfxMedium* pWorkMed = new SfxMedium( sTempURL, STREAM_STD_READ, TRUE );
pWorkMed->SetFilter( pSfxFlt );
if( xWorkDocSh->DoLoad(pWorkMed) )
{
SfxViewFrame *pFrame = SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 );
SwView *pView = (SwView*) pFrame->GetViewShell();
pView->AttrChangedNotify( &pView->GetWrtShell() );//Damit SelectShell gerufen wird.
//set the current DBMgr
SwDoc* pWorkDoc = pView->GetWrtShell().GetDoc();
SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
pWorkDoc->SetNewDBMgr( this );
SwMergeDescriptor aMergeDesc( pImpl->pMergeDialog->GetMergeType(), pView->GetWrtShell(), aDescriptor );
aMergeDesc.sSaveToFilter = pImpl->pMergeDialog->GetSaveFilter();
2009-09-01 08:22:04 +00:00
aMergeDesc.bCreateSingleFile= true;
MergeNew(aMergeDesc);
pWorkDoc->SetNewDBMgr( pWorkDBMgr );
//close the temporary file
uno::Reference< util::XCloseable > xClose( xWorkDocSh->GetModel(), uno::UNO_QUERY );
if (xClose.is())
{
try
{
//! 'sal_True' -> transfer ownership to vetoing object if vetoed!
//! I.e. now that object is responsible for closing the model and doc shell.
xClose->close( sal_True );
}
catch ( const uno::Exception& )
{
}
}
}
}
//remove the temporary file
SWUnoHelper::UCB_DeleteFile( sTempURL );
}
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), rSh.GetView().GetViewFrame()->GetObjectShell()));
// reset the cursor inside
xResSet = NULL;
aDescriptor[daCursor] <<= xResSet;
2000-11-13 07:32:00 +00:00
}
if(pFound)
{
for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++)
{
SwDSParam* pParam = aDataSourceParams[nPos];
if(pParam == pFound)
{
try
{
uno::Reference<XComponent> xComp(pParam->xConnection, UNO_QUERY);
if(xComp.is())
xComp->dispose();
}
catch(const RuntimeException& )
{
//may be disposed already since multiple entries may have used the same connection
}
break;
}
//pFound doesn't need to be removed/deleted -
//this has been done by the SwConnectionDisposedListener_Impl already
}
}
DELETEZ(pImpl->pMergeDialog);
2000-11-13 07:32:00 +00:00
}
void SwNewDBMgr::InsertText(SwWrtShell& rSh,
const Sequence< PropertyValue>& rProperties)
{
2001-09-04 11:40:59 +00:00
rtl::OUString sDataSource, sDataTableOrQuery;
uno::Reference<XResultSet> xResSet;
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();
uno::Reference< XConnection> xConnection;
2000-11-13 07:32:00 +00:00
for(sal_Int32 nPos = 0; nPos < rProperties.getLength(); nPos++)
{
if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cDataSourceName)))
2000-11-13 07:32:00 +00:00
pValues[nPos].Value >>= sDataSource;
else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCommand)))
2000-11-13 07:32:00 +00:00
pValues[nPos].Value >>= sDataTableOrQuery;
else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCursor)))
2000-11-13 07:32:00 +00:00
pValues[nPos].Value >>= xResSet;
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;
}
else if(pValues[nPos].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cCommandType)))
2000-11-13 07:32:00 +00:00
pValues[nPos].Value >>= nCmdType;
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");
2000-11-13 07:32:00 +00:00
return;
}
uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
uno::Reference<XDataSource> xSource;
uno::Reference<XChild> xChild(xConnection, UNO_QUERY);
if(xChild.is())
xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
if(!xSource.is())
xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(sDataSource, xMgr);
uno::Reference< XColumnsSupplier > xColSupp( xResSet, UNO_QUERY );
SwDBData aDBData;
aDBData.sDataSource = sDataSource;
aDBData.sCommand = sDataTableOrQuery;
aDBData.nCommandType = nCmdType;
2000-11-13 07:32:00 +00:00
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
AbstractSwInsertDBColAutoPilot* pDlg = pFact->CreateSwInsertDBColAutoPilot( rSh.GetView(),
xSource,
xColSupp,
aDBData,
DLG_AP_INSERT_DB_SEL );
DBG_ASSERT(pDlg, "Dialogdiet fail!");
2000-11-13 07:32:00 +00:00
if( RET_OK == pDlg->Execute() )
{
2001-09-04 11:40:59 +00:00
rtl::OUString sDummy;
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");
2001-05-21 12:45:09 +00:00
}
2000-11-13 07:32:00 +00:00
}
delete pDlg;
}
SwDbtoolsClient* SwNewDBMgr::pDbtoolsClient = NULL;
SwDbtoolsClient& SwNewDBMgr::GetDbtoolsClient()
{
if ( !pDbtoolsClient )
pDbtoolsClient = new SwDbtoolsClient;
return *pDbtoolsClient;
}
void SwNewDBMgr::RemoveDbtoolsClient()
{
delete pDbtoolsClient;
pDbtoolsClient = 0;
}
uno::Reference<XDataSource> SwNewDBMgr::getDataSourceAsParent(const uno::Reference< XConnection>& _xConnection,const ::rtl::OUString& _sDataSourceName)
{
uno::Reference<XDataSource> xSource;
try
{
uno::Reference<XChild> xChild(_xConnection, UNO_QUERY);
if ( xChild.is() )
xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
if ( !xSource.is() )
xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(_sDataSourceName, ::comphelper::getProcessServiceFactory());
}
catch(const Exception&)
{
DBG_ERROR("exception in getDataSourceAsParent caught");
}
return xSource;
}
uno::Reference<XResultSet> SwNewDBMgr::createCursor(const ::rtl::OUString& _sDataSourceName,
const ::rtl::OUString& _sCommand,
sal_Int32 _nCommandType,
const uno::Reference<XConnection>& _xConnection
)
{
uno::Reference<XResultSet> xResultSet;
try
{
uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
if( xMgr.is() )
{
uno::Reference<XInterface> xInstance = xMgr->createInstance(
C2U( "com.sun.star.sdb.RowSet" ));
uno::Reference<XPropertySet> xRowSetPropSet(xInstance, UNO_QUERY);
if(xRowSetPropSet.is())
{
xRowSetPropSet->setPropertyValue(C2U("DataSourceName"), makeAny(_sDataSourceName));
xRowSetPropSet->setPropertyValue(C2U("ActiveConnection"), makeAny(_xConnection));
xRowSetPropSet->setPropertyValue(C2U("Command"), makeAny(_sCommand));
xRowSetPropSet->setPropertyValue(C2U("CommandType"), makeAny(_nCommandType));
uno::Reference< XCompletedExecution > xRowSet(xInstance, UNO_QUERY);
if ( xRowSet.is() )
{
autorecovery: more sophisticated configuration data for interaction handlers The generic css.task.InteractionHandler implementation in module uui is now able to instantiate "sub handlers", i.e. components to delegate a request to, based on the type of the request, and some configuration data. The "old" (and now deprecated) configuration scheme at org.openoffice.ucb.InteractionHandler did not contain type information, so any handlers registered there were always called when no default implementation for a given request was available. The "new" configuration scheme at org.openoffice.Interaction contains UNO type information. That is, a given handler implementation can declare itself responsible for an arbitrary set of UNO types, and for each of those types, whether it is also responsible for sub types. The generic interaction handler implementation uses this configuration data, when it encounteres an interaction request it cannot fullfill itself, to instantiate a component to delegate the request to. As with the "old" data, such a component is required to support the css.task.XInteractionHandler2 interface. Also, if it supports css.lang.XInitialization, then it will be initialized with a name-value pair, the name being "Parent", the value being the XWindow interface of the parent window for any message boxes. As an examplary implementation for this feature, the css.sdb.InteractionHandler has been deprecated. Now the css.sdb.DatabaseInteractionHandler is reponsible for database-related interactions, and the new configuration scheme is pre-filled with data assigning this responsibility. Consequently, a lot of places previously creating an css.sdb.InteractionHandler have been modified to create the default css.task.InteractionHandler.
2010-02-01 21:32:33 +01:00
uno::Reference< XInteractionHandler > xHandler(xMgr->createInstance(C2U("com.sun.star.task.InteractionHandler")), UNO_QUERY);
xRowSet->executeWithCompletion(xHandler);
}
xResultSet = uno::Reference<XResultSet>(xRowSet, UNO_QUERY);
}
}
}
catch(const Exception&)
{
DBG_ASSERT(0,"Caught exception while creating a new RowSet!");
}
return xResultSet;
}
2010-10-11 17:38:56 -05:00
/*-- 13.05.2004 16:14:15---------------------------------------------------
merge all data into one resulting document and return the number of
merged documents
-----------------------------------------------------------------------*/
sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
SwView& rSourceView )
{
// check the availability of all data in the config item
uno::Reference< XResultSet> xResultSet = rMMConfig.GetResultSet();
if(!xResultSet.is())
return false;
bInMerge = TRUE;
sal_Int32 nRet = 0;
pImpl->pMergeData = new SwDSParam(
rMMConfig.GetCurrentDBData(), xResultSet, rMMConfig.GetSelection());
try{
//set to start position
if(pImpl->pMergeData->aSelection.getLength())
{
sal_Int32 nPos = 0;
pImpl->pMergeData->aSelection.getConstArray()[ pImpl->pMergeData->nSelectionIndex++ ] >>= nPos;
pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->absolute( nPos );
pImpl->pMergeData->CheckEndOfDB();
if(pImpl->pMergeData->nSelectionIndex >= pImpl->pMergeData->aSelection.getLength())
pImpl->pMergeData->bEndOfDB = TRUE;
}
else
{
pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->first();
pImpl->pMergeData->CheckEndOfDB();
}
}
catch(Exception&)
{
pImpl->pMergeData->bEndOfDB = TRUE;
pImpl->pMergeData->CheckEndOfDB();
DBG_ERROR("exception in MergeNew()");
}
//bCancel is set from the PrintMonitor
bCancel = FALSE;
CreateMonitor aMonitorDlg(&rSourceView.GetEditWin());
aMonitorDlg.SetCancelHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
if (!IsMergeSilent())
{
aMonitorDlg.Show();
aMonitorDlg.Invalidate();
aMonitorDlg.Update();
// the print monitor needs some time to act
for( USHORT i = 0; i < 25; i++)
Application::Reschedule();
}
SwWrtShell& rSourceShell = rSourceView.GetWrtShell();
BOOL bSynchronizedDoc = rSourceShell.IsLabelDoc() && rSourceShell.GetSectionFmtCount() > 1;
//save the settings of the first
rSourceShell.SttEndDoc(TRUE);
USHORT nStartingPageNo = rSourceShell.GetVirtPageNum();
String sModifiedStartingPageDesc;
String sStartingPageDesc = sModifiedStartingPageDesc = rSourceShell.GetPageDesc(
rSourceShell.GetCurPageDesc()).GetName();
try
{
// create a target docshell to put the merged document into
SfxObjectShellRef xTargetDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
xTargetDocShell->DoInitNew( 0 );
SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
//the created window has to be located at the same position as the source window
Window& rTargetWindow = pTargetFrame->GetFrame().GetWindow();
Window& rSourceWindow = rSourceView.GetViewFrame()->GetFrame().GetWindow();
rTargetWindow.SetPosPixel(rSourceWindow.GetPosPixel());
// pTargetFrame->GetFrame().Appear();
SwView* pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() );
rMMConfig.SetTargetView(pTargetView);
//initiate SelectShell() to create sub shells
pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() );
SwWrtShell* pTargetShell = pTargetView->GetWrtShellPtr();
// #i63806#
const SwPageDesc* pSourcePageDesc = rSourceShell.FindPageDescByName( sStartingPageDesc );
const SwFrmFmt& rMaster = pSourcePageDesc->GetMaster();
bool bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive() ||
rMaster.GetFooter().IsActive();
// #122799# copy compatibility options
lcl_CopyCompatibilityOptions( rSourceShell, *pTargetShell);
// #72821# copy dynamic defaults
lcl_CopyDynamicDefaults( *rSourceShell.GetDoc(), *pTargetShell->GetDoc() );
long nStartRow, nEndRow;
ULONG nDocNo = 1;
sal_Int32 nDocCount = 0;
if( !IsMergeSilent() && lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) )
aMonitorDlg.SetTotalCount( nDocCount );
do
{
nStartRow = pImpl->pMergeData->xResultSet->getRow();
if (!IsMergeSilent())
{
aMonitorDlg.SetCurrentPosition( nDocNo );
aMonitorDlg.Invalidate();
aMonitorDlg.Update();
// the print monitor needs some time to act
for( USHORT i = 0; i < 25; i++)
Application::Reschedule();
}
// copy the source document
SfxObjectShellRef xWorkDocSh;
if(nDocNo == 1 )
{
uno::Reference< util::XCloneable > xClone( rSourceView.GetDocShell()->GetModel(), uno::UNO_QUERY);
uno::Reference< lang::XUnoTunnel > xWorkDocShell( xClone->createClone(), uno::UNO_QUERY);
SwXTextDocument* pWorkModel = reinterpret_cast<SwXTextDocument*>(xWorkDocShell->getSomething(SwXTextDocument::getUnoTunnelId()));
xWorkDocSh = pWorkModel->GetDocShell();
}
else
{
xWorkDocSh = rSourceView.GetDocShell()->GetDoc()->CreateCopy(true);
}
//create a ViewFrame
SwView* pWorkView = static_cast< SwView* >( SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 )->GetViewShell() );
SwWrtShell& rWorkShell = pWorkView->GetWrtShell();
pWorkView->AttrChangedNotify( &rWorkShell );//Damit SelectShell gerufen wird.
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
// merge the data
SwDoc* pWorkDoc = rWorkShell.GetDoc();
SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
pWorkDoc->SetNewDBMgr( this );
pWorkDoc->EmbedAllLinks();
if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds())
rWorkShell.Undo();
2009-10-09 15:11:54 +02:00
// #i69485# lock fields to prevent access to the result set while calculating layout
rWorkShell.LockExpFlds();
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
// create a layout
rWorkShell.CalcLayout();
rWorkShell.UnlockExpFlds();
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
rWorkShell.ViewShell::UpdateFlds();
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
// strip invisible content and convert fields to text
rWorkShell.RemoveInvisibleContent();
rWorkShell.ConvertFieldsToText();
rWorkShell.SetNumberingRestart();
// insert the document into the target document
rWorkShell.SttEndDoc(FALSE);
rWorkShell.SttEndDoc(TRUE);
rWorkShell.SelAll();
pTargetShell->SttEndDoc(FALSE);
//#i63806# put the styles to the target document
//if the source uses headers or footers each new copy need to copy a new page styles
if(bPageStylesWithHeaderFooter)
{
//create a new pagestyle
//copy the pagedesc from the current document to the new document and change the name of the to-be-applied style
2009-09-01 03:54:53 +00:00
SwDoc* pTargetDoc = pTargetShell->GetDoc();
String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
pTargetShell->GetDoc()->MakePageDesc( sNewPageDescName );
SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
const SwPageDesc* pWorkPageDesc = rWorkShell.FindPageDescByName( sStartingPageDesc );
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
2009-09-01 03:54:53 +00:00
if(pWorkPageDesc && pTargetPageDesc)
{
2009-09-01 03:54:53 +00:00
pTargetDoc->CopyPageDesc( *pWorkPageDesc, *pTargetPageDesc, sal_False );
sModifiedStartingPageDesc = sNewPageDescName;
2009-09-01 03:54:53 +00:00
lcl_CopyFollowPageDesc( *pTargetShell, *pWorkPageDesc, *pTargetPageDesc, nDocNo );
}
}
if(nDocNo == 1 || bPageStylesWithHeaderFooter)
{
pTargetView->GetDocShell()->_LoadStyles( *rSourceView.GetDocShell(), sal_True );
}
if(nDocNo > 1)
{
pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
}
else
{
pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
}
USHORT nPageCountBefore = pTargetShell->GetPageCnt();
DBG_ASSERT(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
//#i51359# add a second paragraph in case there's only one
{
SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
SwPosition aTestPos( aIdx );
SwCursor aTestCrsr(aTestPos,0,false);
if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
{
//append a paragraph
pWorkDoc->AppendTxtNode( aTestPos );
}
}
pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
//convert fields in page styles (header/footer - has to be done after the first document has been pasted
if(1 == nDocNo)
{
pTargetShell->CalcLayout();
pTargetShell->ConvertFieldsToText();
}
//add the document info to the config item
SwDocMergeInfo aMergeInfo;
aMergeInfo.nStartPageInTarget = nPageCountBefore;
//#i72820# calculate layout to be able to find the correct page index
pTargetShell->CalcLayout();
aMergeInfo.nEndPageInTarget = pTargetShell->GetPageCnt();
aMergeInfo.nDBRow = nStartRow;
rMMConfig.AddMergedDocument( aMergeInfo );
++nRet;
// the print monitor needs some time to act
for( USHORT i = 0; i < 25; i++)
Application::Reschedule();
//restore the ole DBMgr
pWorkDoc->SetNewDBMgr( pWorkDBMgr );
//now the temporary document should be closed
SfxObjectShellRef xDocSh(pWorkView->GetDocShell());
xDocSh->DoClose();
nEndRow = pImpl->pMergeData->xResultSet->getRow();
++nDocNo;
} while( !bCancel &&
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
//deselect all, go out of the frame and go to the beginning of the document
Point aPt(LONG_MIN, LONG_MIN);
pTargetShell->SelectObj(aPt, SW_LEAVE_FRAME);
if (pTargetShell->IsSelFrmMode())
{
pTargetShell->UnSelectFrm();
pTargetShell->LeaveSelFrmMode();
}
pTargetShell->EnterStdMode();
pTargetShell->SttDoc();
//
}
catch( Exception& rEx)
{
(void)rEx;
DBG_ERROR("exception caught in SwNewDBMgr::MergeDocuments");
}
DELETEZ(pImpl->pMergeData);
bInMerge = FALSE;
return nRet;
}
2010-10-11 17:38:56 -05:00
SwConnectionDisposedListener_Impl::SwConnectionDisposedListener_Impl(SwNewDBMgr& rMgr) :
rDBMgr(rMgr)
2010-10-11 17:38:56 -05:00
{
};
SwConnectionDisposedListener_Impl::~SwConnectionDisposedListener_Impl()
2010-10-11 17:38:56 -05:00
{
};
void SwConnectionDisposedListener_Impl::disposing( const EventObject& rSource )
throw (RuntimeException)
{
::vos::OGuard aGuard(Application::GetSolarMutex());
uno::Reference<XConnection> xSource(rSource.Source, UNO_QUERY);
for(USHORT nPos = rDBMgr.aDataSourceParams.Count(); nPos; nPos--)
{
SwDSParam* pParam = rDBMgr.aDataSourceParams[nPos - 1];
if(pParam->xConnection.is() &&
(xSource == pParam->xConnection))
{
rDBMgr.aDataSourceParams.DeleteAndDestroy(nPos - 1);
}
}
}