summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Specht <os@openoffice.org>2000-11-13 07:32:00 +0000
committerOliver Specht <os@openoffice.org>2000-11-13 07:32:00 +0000
commit8f38a32b68e47319a506fa8b4a8e60f03071ed5e (patch)
tree7523a47093fd09470648e102e47e01a24cd9793c
parentc16dc3948793b4b246fcf3f8be82298131ef0d55 (diff)
added methods for dispatch interface
-rw-r--r--sw/inc/dbmgr.hxx32
-rw-r--r--sw/source/ui/dbui/dbinsdlg.cxx87
-rw-r--r--sw/source/ui/dbui/dbmgr.cxx312
-rw-r--r--sw/source/ui/inc/dbinsdlg.hxx24
4 files changed, 378 insertions, 77 deletions
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 1edf694a66de..7c5195394dc1 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dbmgr.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: hr $ $Date: 2000-10-31 15:26:08 $
+ * last change: $Author: os $ $Date: 2000-11-13 08:25:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -94,6 +94,7 @@ namespace com{namespace sun{namespace star{
namespace beans{
class XPropertySet;
+ struct PropertyValue;
}
namespace sdbcx{
class XColumnsSupplier;
@@ -149,8 +150,8 @@ struct SwDSParam
::com::sun::star::uno::Reference<com::sun::star::util::XNumberFormatter> xFormatter;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> xConnection;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement> xStatement;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> xResultSet;
-
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> xResultSet;
+ ::com::sun::star::uno::Sequence< sal_Int32 > aSelection;
SbaSelectionListRef xSelectionList;
BOOL bScrollable;
BOOL bSelectionList;
@@ -167,6 +168,20 @@ struct SwDSParam
bEndOfDB(FALSE),
nSelectionIndex(0)
{}
+
+ SwDSParam(const String& rSource, const String& rTable, BYTE nType,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> xResSet,
+ ::com::sun::star::uno::Sequence< sal_Int32 > rSelection) :
+ sDataSource(rSource),
+ sTableOrQuery(rTable),
+ nTableOrQuery(nType),
+ bScrollable(TRUE),
+ bSelectionList(FALSE),
+ bEndOfDB(FALSE),
+ nSelectionIndex(0),
+ xResultSet(xResSet),
+ aSelection(rSelection)
+ {}
};
typedef SwDSParam* SwDSParamPtr;
SV_DECL_PTRARR_DEL(SwDSParamArr, SwDSParamPtr, 0, 5)
@@ -221,6 +236,9 @@ public:
inline void SetMergeType( USHORT nTyp ) { nMergeType = nTyp; }
// Mischen von Datensaetzen in Felder
+ BOOL MergeNew(USHORT nOpt, SwWrtShell& rSh,
+ const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rProperties,
+ const String *pPrinter = NULL);
BOOL Merge(USHORT nOpt, SwWrtShell* pSh, const String& rStatement,
const SbaSelectionListRef pSelectionList,
const String& rDataSource,
@@ -264,6 +282,12 @@ public:
inline BOOL IsInMerge() const { return bInMerge; }
void EndMerge();
+ void ExecuteFormLetter(SwWrtShell& rSh,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rProperties);
+
+ void InsertText(SwWrtShell& rSh,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rProperties);
+
// check if a data source is open as merge source
BOOL IsDataSourceOpen(const String& rDataSource, const String& rTableOrQuery)const;
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index ad5318754b5a..d3ffb48a3330 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dbinsdlg.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: hr $ $Date: 2000-11-07 15:50:58 $
+ * last change: $Author: os $ $Date: 2000-11-13 08:30:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1179,35 +1179,40 @@ FASTBOOL SwInsertDBColAutoPilot::SplitTextToColArr( const String& rTxt,
/* ---------------------------------------------------------------------------
---------------------------------------------------------------------------*/
-void SwInsertDBColAutoPilot::DataToDoc( const SbaSelectionList* pSelList,
+void SwInsertDBColAutoPilot::DataToDoc( const Sequence<sal_Int32>& rSelection,
Reference< XDataSource> xSource,
- Reference< XConnection> xConnection )
+ Reference< XConnection> xConnection,
+ Reference< sdbc::XResultSet > xResultSet )
{
+ const sal_Int32* pSelection = rSelection.getLength() ? rSelection.getConstArray() : 0;
SwWrtShell& rSh = pView->GetWrtShell();
- Reference< sdbc::XResultSet > xResultSet;
- Reference< sdbc::XRow > xRow;
- Reference< sdbc::XStatement > xStatement;
+ Reference< sdbc::XRow > xRow(xResultSet, UNO_QUERY);
BOOL bScrollable;
- try
+ //TODO: can be removed with the old interface (textsh2.cxx)
+ if(!xRow.is())
{
- bScrollable = xConnection->getMetaData()->supportsResultSetType((sal_Int32)ResultSetType::SCROLL_INSENSITIVE);
+ try
+ {
+ Reference< sdbc::XStatement > xStatement;
+ bScrollable = xConnection->getMetaData()->supportsResultSetType((sal_Int32)ResultSetType::SCROLL_INSENSITIVE);
- xStatement = xConnection->createStatement();
- Reference< XPropertySet > xStatProp(xStatement, UNO_QUERY);
- if(bScrollable)
+ xStatement = xConnection->createStatement();
+ Reference< XPropertySet > xStatProp(xStatement, UNO_QUERY);
+ if(bScrollable)
+ {
+ Any aResType;
+ aResType <<= (sal_Int32)ResultSetType::SCROLL_INSENSITIVE;
+ xStatProp->setPropertyValue(C2U("ResultSetType"), aResType);
+ }
+ if(xStatement.is())
+ xResultSet = xStatement->executeQuery(aDBData.sStatement);
+ xRow = Reference< sdbc::XRow >(xResultSet, UNO_QUERY);
+ }
+ catch(Exception aExcept)
{
- Any aResType;
- aResType <<= (sal_Int32)ResultSetType::SCROLL_INSENSITIVE;
- xStatProp->setPropertyValue(C2U("ResultSetType"), aResType);
+ DBG_ERROR("exception caught")
}
- if(xStatement.is())
- xResultSet = xStatement->executeQuery(aDBData.sStatement);
- xRow = Reference< sdbc::XRow >(xResultSet, UNO_QUERY);
- }
- catch(Exception aExcept)
- {
- DBG_ERROR("exception caught")
}
if(!xResultSet.is() || !xRow.is())
return;
@@ -1229,8 +1234,8 @@ void SwInsertDBColAutoPilot::DataToDoc( const SbaSelectionList* pSelList,
if( aCbTableHeadon.IsChecked() )
nRows++;
- if( pSelList )
- nRows += (USHORT)pSelList->Count();
+ if( pSelection )
+ nRows += (USHORT)rSelection.getLength();
else
++nRows;
@@ -1257,10 +1262,10 @@ void SwInsertDBColAutoPilot::DataToDoc( const SbaSelectionList* pSelList,
BOOL bHTML = 0 != (::GetHtmlMode( pView->GetDocShell() ) & HTMLMODE_ON);
rSh.InsertTable( nRows, nCols, HORI_FULL,
pModOpt->GetInsTblFlags(bHTML),
- (pSelList ? pTAutoFmt : 0));
+ (pSelection ? pTAutoFmt : 0));
rSh.MoveTable( fnTablePrev, fnTableStart );
- if( pSelList && pTblSet )
+ if( pSelection && pTblSet )
SetTabSet();
SfxItemSet aTblSet( rSh.GetAttrPool(), RES_BOXATR_FORMAT,
@@ -1288,15 +1293,15 @@ void SwInsertDBColAutoPilot::DataToDoc( const SbaSelectionList* pSelList,
{
if(bScrollable)
{
- if(pSelList)
- bBreak = !xResultSet->absolute((ULONG)pSelList->GetObject( i ) );
+ if(pSelection)
+ bBreak = !xResultSet->absolute((ULONG)pSelection[i] );
else if(!i)
bBreak = !xResultSet->first();
}
- else if(pSelList)
+ else if(pSelection)
{
- ULONG nOldPos = i ? 0 : (ULONG)pSelList->GetObject( i -1 );
- ULONG nPos = (ULONG)pSelList->GetObject( i );
+ ULONG nOldPos = 0 == i ? 0 : (ULONG)pSelection[i -1];
+ ULONG nPos = (ULONG)pSelection[i];
long nDiff = nPos - nOldPos;
while(nDiff > 0 && !bBreak)
{
@@ -1371,13 +1376,13 @@ void SwInsertDBColAutoPilot::DataToDoc( const SbaSelectionList* pSelList,
}
}
- if( !pSelList )
+ if( !pSelection )
{
BOOL bNext = xResultSet->next();
if(!bNext)
break;
}
- else if( i+1 >= pSelList->Count() )
+ else if( i+1 >= rSelection.getLength() )
break;
if( 10 == i )
@@ -1385,7 +1390,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const SbaSelectionList* pSelList,
}
rSh.MoveTable( fnTableCurr, fnTableStart );
- if( !pSelList && ( pTblSet || pTAutoFmt ))
+ if( !pSelection && ( pTblSet || pTAutoFmt ))
{
if( pTblSet )
SetTabSet();
@@ -1499,15 +1504,15 @@ void SwInsertDBColAutoPilot::DataToDoc( const SbaSelectionList* pSelList,
{
if(bScrollable)
{
- if(pSelList)
- bBreak = !xResultSet->absolute((ULONG)pSelList->GetObject( i ) );
+ if(pSelection)
+ bBreak = !xResultSet->absolute((ULONG)pSelection[i] );
else if(!i)
bBreak = !xResultSet->first();
}
- else if(pSelList)
+ else if(pSelection)
{
- ULONG nOldPos = i ? 0 : (ULONG)pSelList->GetObject( i -1 );
- ULONG nPos = (ULONG)pSelList->GetObject( i );
+ ULONG nOldPos = 0 == i ? 0 : (ULONG)pSelection[i - 1];
+ ULONG nPos = (ULONG)pSelection[i];
long nDiff = nPos - nOldPos;
while(nDiff > 0 && !bBreak)
{
@@ -1608,13 +1613,13 @@ void SwInsertDBColAutoPilot::DataToDoc( const SbaSelectionList* pSelList,
}
}
- if( !pSelList )
+ if( !pSelection )
{
BOOL bNext = xResultSet->next();
if(!bNext)
break;
}
- else if( i+1 >= pSelList->Count() )
+ else if( i+1 >= rSelection.getLength() )
break;
if( aRbAsField.IsChecked() )
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index d5d7b9434262..65dfdff6b2d8 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dbmgr.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: rt $ $Date: 2000-11-08 09:46:34 $
+ * last change: $Author: os $ $Date: 2000-11-13 08:25:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,6 +75,9 @@
#ifndef _UCBHELPER_CONTENT_HXX
#include <ucbhelper/content.hxx>
#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
#ifndef _COM_SUN_STAR_UCB_XCOMMANDENVIRONMENT_HPP_
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#endif
@@ -158,6 +161,9 @@
#ifndef _EDTWIN_HXX
#include <edtwin.hxx>
#endif
+#ifndef _DBINSDLG_HXX
+#include <dbinsdlg.hxx>
+#endif
#ifndef _WRTSH_HXX
#include <wrtsh.hxx>
#endif
@@ -215,6 +221,9 @@
#include <hintids.hxx>
#endif
#include <connectivity/dbconversion.hxx>
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
@@ -269,6 +278,15 @@
#ifndef _NUMUNO_HXX
#include <svtools/numuno.hxx>
#endif
+#include "mailmrge.hxx"
+
+
+#ifndef _SFXEVENT_HXX
+#include <sfx2/event.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
using namespace rtl;
using namespace ::com::sun::star;
@@ -356,6 +374,127 @@ BOOL lcl_GetColumnCnt(SwDSParam* pParam,
/*--------------------------------------------------------------------
Beschreibung: Daten importieren
--------------------------------------------------------------------*/
+BOOL SwNewDBMgr::MergeNew(USHORT nOpt, SwWrtShell& rSh,
+ const Sequence<PropertyValue>& rProperties,
+ const String *pPrinter)
+{
+
+ DBG_ASSERT(!bInMerge && !pMergeData, "merge already activated!")
+
+ OUString sDataSource, sDataTableOrQuery;
+ Reference<XResultSet> xResSet;
+ Sequence<sal_Int32> aSelection;
+ sal_Int32 nCmdType = CommandType::TABLE;
+ const PropertyValue* pValues = rProperties.getConstArray();
+ for(sal_Int32 nPos = 0; nPos < rProperties.getLength(); nPos++)
+ {
+ if(!pValues[nPos].Name.compareToAscii("DataSourceName"))
+ pValues[nPos].Value >>= sDataSource;
+ else if(!pValues[nPos].Name.compareToAscii("Command"))
+ pValues[nPos].Value >>= sDataTableOrQuery;
+ else if(!pValues[nPos].Name.compareToAscii("Cursor"))
+ pValues[nPos].Value >>= xResSet;
+ else if(!pValues[nPos].Name.compareToAscii("Selection"))
+ pValues[nPos].Value >>= aSelection;
+ else if(!pValues[nPos].Name.compareToAscii("CommandType"))
+ pValues[nPos].Value >>= nCmdType;
+ }
+ if(!sDataSource.getLength() || !sDataTableOrQuery.getLength() || !xResSet.is())
+ {
+ return FALSE;
+ }
+ pMergeData = new SwDSParam(sDataSource, sDataTableOrQuery, SW_DB_SELECT_UNKNOWN, xResSet, aSelection);
+ //set to start position
+ pMergeData->bEndOfDB = !pMergeData->xResultSet->absolute(
+ (ULONG)pMergeData->aSelection.getConstArray()[ pMergeData->nSelectionIndex++ ] );
+ if(pMergeData->nSelectionIndex >= pMergeData->aSelection.getLength())
+ pMergeData->bEndOfDB = TRUE;
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ Reference<XDataSource> xSource = dbtools::getDataSource(sDataSource, xMgr);
+ if( xMgr.is() )
+ {
+ Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.util.NumberFormatter" ));
+ pMergeData->xFormatter = Reference<util::XNumberFormatter>(xInstance, UNO_QUERY) ;
+ pMergeData->nTableOrQuery = nCmdType == CommandType::TABLE ? SW_DB_SELECT_TABLE : SW_DB_SELECT_QUERY;
+ }
+
+ Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
+ if(xSourceProps.is())
+ {
+ Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
+ if(aFormats.hasValue())
+ {
+ Reference<XNumberFormatsSupplier> xSuppl;
+ aFormats >>= xSuppl;
+ if(xSuppl.is())
+ {
+ Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
+ Any aNull = xSettings->getPropertyValue(C2U("NullDate"));
+ if(aNull.hasValue())
+ pMergeData->aNullDate = *(util::Date*)aNull.getValue();
+ }
+ }
+ }
+
+ ChgDBName(&rSh, sDataSource, sDataTableOrQuery, aEmptyStr);
+ bInMerge = TRUE;
+
+ if (IsInitDBFields())
+ {
+ // Bei Datenbankfeldern ohne DB-Name DB-Name von Dok einsetzen
+ SvStringsDtor aDBNames(1, 1);
+ aDBNames.Insert( new String(), 0);
+ rSh.ChangeDBFields( aDBNames, rSh.GetDBName());
+ SetInitDBFields(FALSE);
+ }
+
+ BOOL bRet = TRUE;
+ switch(nOpt)
+ {
+ case DBMGR_MERGE:
+ bRet = Merge(&rSh); // Mischen
+ break;
+
+ case DBMGR_MERGE_MAILMERGE: // Serienbrief
+ {
+ SfxDispatcher *pDis = rSh.GetView().GetViewFrame()->GetDispatcher();
+ if (pPrinter) // Aufruf kommt aus dem Basic
+ {
+ SfxBoolItem aSilent( SID_SILENT, TRUE );
+ if (pPrinter)
+ {
+ SfxStringItem aPrinterName(SID_PRINTER_NAME, *pPrinter);
+ pDis->Execute( SID_PRINTDOC, SFX_CALLMODE_SYNCHRON,
+ &aPrinterName, &aSilent, 0L );
+ }
+ else
+ {
+ pDis->Execute( SID_PRINTDOC, SFX_CALLMODE_SYNCHRON,
+ &aSilent, 0L );
+ }
+ }
+ else
+ pDis->Execute(SID_PRINTDOC, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD);
+ }
+ break;
+
+ case DBMGR_MERGE_MAILING:
+ bRet = MergeMailing(&rSh); // Mailing
+ break;
+
+ case DBMGR_MERGE_MAILFILES:
+ bRet = MergeMailFiles(&rSh); // Serienbriefe als Dateien abspeichern
+ break;
+
+ default: // Einfuegen der selektierten Eintraege
+ // (war: InsertRecord)
+ ImportFromConnection(&rSh);
+ break;
+ }
+
+ EndMerge();
+ return bRet;
+}
BOOL SwNewDBMgr::Merge( USHORT nOpt, SwWrtShell* pSh,
const String& rStatement,
@@ -1576,6 +1715,7 @@ void SwNewDBMgr::EndMerge()
{
DBG_ASSERT(bInMerge, "merge is not active")
bInMerge = FALSE;
+ delete pMergeData;
pMergeData = 0;
}
/* -----------------------------06.07.00 14:28--------------------------------
@@ -1648,6 +1788,7 @@ BOOL SwNewDBMgr::ToNextMergeRecord()
{
if(pMergeData->bSelectionList)
{
+ DBG_ERROR("remove old code")
if(pMergeData->bScrollable)
{
pMergeData->bEndOfDB = !pMergeData->xResultSet->absolute(
@@ -1682,6 +1823,13 @@ BOOL SwNewDBMgr::ToNextMergeRecord()
if(pMergeData->nSelectionIndex >= pMergeData->xSelectionList->Count())
pMergeData->bEndOfDB = TRUE;
}
+ else if(pMergeData->aSelection.getLength())
+ {
+ pMergeData->bEndOfDB = !pMergeData->xResultSet->absolute(
+ (ULONG)pMergeData->aSelection.getConstArray()[ pMergeData->nSelectionIndex++ ] );
+ if(pMergeData->nSelectionIndex >= pMergeData->aSelection.getLength())
+ pMergeData->bEndOfDB = TRUE;
+ }
else
{
pMergeData->bEndOfDB = !pMergeData->xResultSet->next();
@@ -1758,12 +1906,6 @@ BOOL SwNewDBMgr::ShowInBeamer(const String& rDBName, const String& rTableName
SwView* pView = SW_MOD()->GetView();
SfxViewFrame* pFrame = pView->GetViewFrame();
Reference<XFrame> xFrame = pFrame->GetFrame()->GetFrameInterface();
-// Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
-// Reference<XInterface> xInstance;
-// if( xMgr.is() )
-// {
-// xInstance = xMgr->createInstance( C2U( "com.sun.star.frame.Desktop" ));
-// }
Reference<XDispatchProvider> xDP(xFrame, UNO_QUERY);
util::URL aURL;
aURL.Complete = C2U(".component:DB/DataSourceBrowser");
@@ -1771,24 +1913,19 @@ BOOL SwNewDBMgr::ShowInBeamer(const String& rDBName, const String& rTableName
C2U("_beamer"),
0x0C);
if (xD.is())
- xD->dispatch(aURL, Sequence<PropertyValue>());
+ {
+ Sequence<PropertyValue> aProperties(3);
+ PropertyValue* pProperties = aProperties.getArray();
+ pProperties[0].Name = C2U("DataSourceName");
+ pProperties[0].Value <<= OUString(rDBName);
+ pProperties[1].Name = C2U("Command");
+ pProperties[1].Value <<= OUString(rTableName);
+ pProperties[2].Name = C2U("CommandType");
+ pProperties[2].Value <<= (sal_Int32)SW_DB_SELECT_TABLE == nType ? CommandType::TABLE : CommandType::QUERY;
+ xD->dispatch(aURL, aProperties);
+ }
else
DBG_ERROR("SwNewDBMgr::ShowInBeamer: no dispatcher for the database URL!");
-// Reference<XComponentLoader> xLoader(xInstance, UNO_QUERY);
-// DBG_ASSERT(xLoader.is(), "no loader available?")
-// if(!xLoader.is())
-// return FALSE;
-
-// Reference<XComponent> xRet;
-// try
-// {
-// xRet = xLoader->loadComponentFromURL(
-// C2U(".component:DB/DataSourceBrowser"),
-// C2U("_beamer"),
-// 0xff,
-// Sequence<PropertyValue>() );
-// }
-// catch(Exception&){DBG_ERROR("Exception: loadComponentFromURL()")}
return TRUE;
}
/* -----------------------------17.07.00 14:50--------------------------------
@@ -1994,7 +2131,14 @@ void SwNewDBMgr::GetDSSelection(const String& rDBDesc, long& rSelStart, long&
---------------------------------------------------------------------------*/
const String& SwNewDBMgr::GetAddressDBName()
{
- DBG_ERROR("no address data base selection available")
+#ifdef DBG_UTIL
+ static BOOL bShowError = TRUE;
+ if(bShowError)
+ {
+ DBG_ERROR("SwNewDBMgr::GetAddressDBName(): no address data base selection available")
+ bShowError=FALSE;
+ }
+#endif
return aEmptyStr;
}
/* -----------------------------18.07.00 13:13--------------------------------
@@ -2015,3 +2159,121 @@ Sequence<OUString> SwNewDBMgr::GetExistingDatabaseNames()
}
return Sequence<OUString>();
}
+/* -----------------------------10.11.00 17:10--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh,
+ const Sequence<PropertyValue>& rProperties)
+{
+ OUString sDataSource, sDataTableOrQuery;
+ Reference<XResultSet> xResSet;
+ Sequence<sal_Int32> aSelection;
+ BOOL bHasSelectionProperty = FALSE;
+ sal_Int32 nSelectionPos = 0;
+ sal_Int16 nCmdType = CommandType::TABLE;
+ const PropertyValue* pValues = rProperties.getConstArray();
+ for(sal_Int32 nPos = 0; nPos < rProperties.getLength(); nPos++)
+ {
+ if(!pValues[nPos].Name.compareToAscii("DataSourceName"))
+ pValues[nPos].Value >>= sDataSource;
+ else if(!pValues[nPos].Name.compareToAscii("Command"))
+ pValues[nPos].Value >>= sDataTableOrQuery;
+ else if(!pValues[nPos].Name.compareToAscii("Cursor"))
+ pValues[nPos].Value >>= xResSet;
+ else if(!pValues[nPos].Name.compareToAscii("Selection"))
+ {
+ bHasSelectionProperty = TRUE;
+ nSelectionPos = nPos;
+ pValues[nPos].Value >>= aSelection;
+ }
+ else if(!pValues[nPos].Name.compareToAscii("CommandType"))
+ pValues[nPos].Value >>= nCmdType;
+ }
+ if(!sDataSource.getLength() || !sDataTableOrQuery.getLength() || !xResSet.is())
+ {
+ DBG_ERROR("PropertyValues missing or unset")
+ return;
+ }
+ SwMailMergeDlg* pDlg = new SwMailMergeDlg(
+ &rSh.GetView().GetViewFrame()->GetWindow(), rSh,
+ sDataSource,
+ sDataTableOrQuery,
+ nCmdType, aSelection );
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ SetMergeType( pDlg->GetMergeType() );
+
+ Sequence<PropertyValue> aNewProperties = rProperties;
+ if(!bHasSelectionProperty)
+ {
+ nSelectionPos = rProperties.getLength();
+ aNewProperties.realloc(rProperties.getLength() + 1);
+ }
+ PropertyValue* pNewValues = aNewProperties.getArray();
+ pNewValues[nSelectionPos].Value <<= pDlg->GetSelection();
+ OFF_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, rSh.GetView().GetViewFrame()->GetObjectShell()));
+ MergeNew(GetMergeType(),
+ rSh,
+ aNewProperties);
+ delete(pDlg);
+ }
+}
+/* -----------------------------13.11.00 08:20--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwNewDBMgr::InsertText(SwWrtShell& rSh,
+ const Sequence< PropertyValue>& rProperties)
+{
+ OUString sDataSource, sDataTableOrQuery;
+ Reference<XResultSet> xResSet;
+ Sequence<sal_Int32> aSelection;
+ BOOL bHasSelectionProperty = FALSE;
+ sal_Int32 nSelectionPos = 0;
+ sal_Int16 nCmdType = CommandType::TABLE;
+ const PropertyValue* pValues = rProperties.getConstArray();
+ for(sal_Int32 nPos = 0; nPos < rProperties.getLength(); nPos++)
+ {
+ if(!pValues[nPos].Name.compareToAscii("DataSourceName"))
+ pValues[nPos].Value >>= sDataSource;
+ else if(!pValues[nPos].Name.compareToAscii("Command"))
+ pValues[nPos].Value >>= sDataTableOrQuery;
+ else if(!pValues[nPos].Name.compareToAscii("Cursor"))
+ pValues[nPos].Value >>= xResSet;
+ else if(!pValues[nPos].Name.compareToAscii("Selection"))
+ {
+ bHasSelectionProperty = TRUE;
+ nSelectionPos = nPos;
+ pValues[nPos].Value >>= aSelection;
+ }
+ else if(!pValues[nPos].Name.compareToAscii("CommandType"))
+ pValues[nPos].Value >>= nCmdType;
+ }
+ if(!sDataSource.getLength() || !sDataTableOrQuery.getLength() || !xResSet.is())
+ {
+ DBG_ERROR("PropertyValues missing or unset")
+ return;
+ }
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ Reference<XDataSource> xSource = dbtools::getDataSource(sDataSource, xMgr);
+ Reference< XColumnsSupplier > xColSupp( xResSet, UNO_QUERY );
+ SwInsDBData aDBData;
+ aDBData.sDataBaseName = sDataSource;
+ aDBData.sDataTableName = sDataTableOrQuery;
+
+ SwInsertDBColAutoPilot *pDlg = new SwInsertDBColAutoPilot(
+ rSh.GetView(),
+ xSource,
+ xColSupp,
+ aDBData );
+ if( RET_OK == pDlg->Execute() )
+ {
+ Reference< sdbc::XConnection> xConnection;
+ OUString sDummy;
+ xConnection = xSource->getConnection(sDummy, sDummy);
+ pDlg->DataToDoc( aSelection , xSource, xConnection, xResSet);
+ }
+ delete pDlg;
+
+}
+
diff --git a/sw/source/ui/inc/dbinsdlg.hxx b/sw/source/ui/inc/dbinsdlg.hxx
index 491340123a8a..36775aaf73fc 100644
--- a/sw/source/ui/inc/dbinsdlg.hxx
+++ b/sw/source/ui/inc/dbinsdlg.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dbinsdlg.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: os $ $Date: 2000-10-27 11:24:26 $
+ * last change: $Author: os $ $Date: 2000-11-13 08:32:00 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -93,13 +93,22 @@
#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
#include <com/sun/star/uno/Reference.h>
#endif
-namespace com{namespace sun{namespace star{namespace sdbcx{
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
+#include <com/sun/star/uno/Sequence.h>
+#endif
+namespace com{namespace sun{namespace star{
+ namespace sdbcx{
class XColumnsSupplier;
-}}}}
+ }
+ namespace sdbc{
+ class XDataSource;
+ class XConnection;
+ class XResultSet;
+ }
+}}}
class SwTableAutoFmt;
class SwView;
-class SbaSelectionList;
class _DB_ColumnConfig;
class SfxItemSet;
class SwTableRep;
@@ -216,9 +225,10 @@ public:
virtual ~SwInsertDBColAutoPilot();
- void DataToDoc( const SbaSelectionList*,
+ void DataToDoc( const ::com::sun::star::uno::Sequence<sal_Int32>& rSelection,
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> rxSource,
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> xConnection);
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> xConnection,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > xResultSet);
};