diff options
author | Oliver Specht <os@openoffice.org> | 2001-03-30 11:05:13 +0000 |
---|---|---|
committer | Oliver Specht <os@openoffice.org> | 2001-03-30 11:05:13 +0000 |
commit | 609829ae1332da4df20844370758db331092dfa9 (patch) | |
tree | 8b9bdb946a8fbdcc10c3ac57d7a66fc7416e4cb1 /sw | |
parent | efc1312f1f3e577318eb4680a556f24a75e81db4 (diff) |
#85318# some old database functions removed/replaced
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/dbmgr.hxx | 71 | ||||
-rw-r--r-- | sw/inc/swdbdata.hxx | 6 | ||||
-rw-r--r-- | sw/sdi/_basesh.sdi | 27 | ||||
-rw-r--r-- | sw/source/core/doc/docfld.cxx | 16 | ||||
-rw-r--r-- | sw/source/ui/dbui/dbinsdlg.cxx | 7 | ||||
-rw-r--r-- | sw/source/ui/dbui/dbmgr.cxx | 505 | ||||
-rw-r--r-- | sw/source/ui/shells/basesh.cxx | 93 | ||||
-rw-r--r-- | sw/source/ui/shells/textsh2.cxx | 141 |
8 files changed, 169 insertions, 697 deletions
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx index 74d4af391d1d..2a8e28b66fd3 100644 --- a/sw/inc/dbmgr.hxx +++ b/sw/inc/dbmgr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: dbmgr.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: os $ $Date: 2001-02-26 10:26:01 $ + * last change: $Author: os $ $Date: 2001-03-30 11:59:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,15 +66,20 @@ #include <tools/string.hxx> #endif -#ifndef _SBAITEMS_HXX -#include "offmgr/sbaitems.hxx" +#ifndef _LINK_HXX +#include <tools/link.hxx> +#endif +#ifndef _SVARRAY_HXX +#include <svtools/svarray.hxx> #endif #ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ #include <com/sun/star/util/Date.hpp> #endif #include "swtypes.hxx" // fuer aEmptyStr - +#ifndef _SWDBDATA_HXX +#include <swdbdata.hxx> +#endif #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ #include <com/sun/star/uno/Reference.h> #endif @@ -119,7 +124,7 @@ class ListBox; class Button; class SvNumberFormatter; class SwMailMergeDlg; -struct SwDBData; + // ----------------------------------------------------------------------- enum DBMgrOptions @@ -140,12 +145,8 @@ enum DBMgrOptions #define SW_DB_SELECT_TABLE 1 #define SW_DB_SELECT_QUERY 2 -struct SwDSParam +struct SwDSParam : public SwDBData { - String sDataSource; - String sTableOrQuery; - BYTE nTableOrQuery; - String sStatement; com::sun::star::util::Date aNullDate; ::com::sun::star::uno::Reference<com::sun::star::util::XNumberFormatter> xFormatter; @@ -153,33 +154,24 @@ struct SwDSParam ::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::Sequence< sal_Int32 > aSelection; - SbaSelectionListRef xSelectionList; BOOL bScrollable; - BOOL bSelectionList; BOOL bEndOfDB; BOOL bAfterSelection; long nSelectionIndex; - SwDSParam(const String& rSource, const String& rTable, BYTE nType, const String& rStatement) : - sDataSource(rSource), - sTableOrQuery(rTable), - nTableOrQuery(nType), - sStatement(rStatement), + SwDSParam(const SwDBData& rData) : + SwDBData(rData), bScrollable(FALSE), - bSelectionList(FALSE), bEndOfDB(FALSE), bAfterSelection(FALSE), nSelectionIndex(0) {} - SwDSParam(const String& rSource, const String& rTable, BYTE nType, + SwDSParam(const SwDBData& rData, ::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), + SwDBData(rData), bScrollable(TRUE), - bSelectionList(FALSE), bEndOfDB(FALSE), bAfterSelection(FALSE), nSelectionIndex(0), @@ -199,7 +191,6 @@ SV_DECL_PTRARR_DEL(SwDSParamArr, SwDSParamPtr, 0, 5) class SwNewDBMgr { - SbaSelectionListRef pMergeList; // Liste der fr Serienbrief selektierten Eintrge String sEMailAddrFld; // Mailing: Spaltenname der E-Mail Adresse String sSubject; // Mailing: Subject String sAttached; // Mailing: Attachte Files @@ -214,11 +205,7 @@ class SwNewDBMgr SwDSParam* pMergeData; SwMailMergeDlg* pMergeDialog; - BOOL OpenMergeSource(const String& rDataSource, - const String& rDataTableOrQuery, - const String& rStatement, - const SbaSelectionListRef xSelectionList); - SwDSParam* FindDSData(const String& rDBName, BOOL bCreate); + SwDSParam* FindDSData(const SwDBData& rData, BOOL bCreate); DECL_LINK( PrtCancelHdl, Button * ); @@ -236,11 +223,6 @@ class SwNewDBMgr public: SwNewDBMgr(); ~SwNewDBMgr(); - // Am Dokument Datenbank- Tabellenname und SQL-Select-Statement setzen - void ChgDBName( SwWrtShell* pSh, - const String& rDataSource, - const String& rTableOrQuery, - const String& rStatement ); // Art des aktellen Mergens. Siehe DBMgrOptions-enum inline USHORT GetMergeType() const { return nMergeType; } @@ -250,17 +232,10 @@ public: 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, - const String& rTableOrQuery, - const String *pPrinter = NULL); BOOL Merge(SwWrtShell* pSh); // Mischen von Datensaetzen in Felder, dann drucken BOOL MergePrint( SwView& rView, SwPrtOptions& rOpt, SfxProgress& rProgress ); - inline SbaSelectionListRef& GetMergeList() { return pMergeList; } - // Datenbankfelder mit fehlendem Datenbankname initialisieren inline BOOL IsInitDBFields() const { return bInitDBFields; } inline void SetInitDBFields(BOOL b) { bInitDBFields = b; } @@ -303,18 +278,18 @@ public: BOOL IsDataSourceOpen(const String& rDataSource, const String& rTableOrQuery)const; // add data source information to the data source array - was PreInitDBData - void AddDSData(const String& rDBName, long nSelStart, long nSelEnd); - void GetDSSelection(const String& sDBDesc, long& rSelStart, long& rSelEnd); + void AddDSData(const SwDBData& rData, long nSelStart, long nSelEnd); + void GetDSSelection(const SwDBData& rData, long& rSelStart, long& rSelEnd); // open the source while fields are updated - for the calculator only! - BOOL OpenDataSource(const String& rDataSource, const String& rTableOrQuery); - sal_uInt32 GetSelectedRecordId(const String& rDataSource, const String& rTableOrQuery); + BOOL OpenDataSource(const String& rDataSource, const String& rTableOrQuery, sal_Int32 nCommandType = -1); + sal_uInt32 GetSelectedRecordId(const String& rDataSource, const String& rTableOrQuery, sal_Int32 nCommandType = -1); BOOL GetColumnCnt(const String& rSourceName, const String& rTableName, const String& rColumnName, sal_uInt32 nAbsRecordId, long nLanguage, String& rResult, double* pNumber); - const SwDSParam* CreateDSData(const String& rDBName) - {return FindDSData(rDBName, TRUE);} + const SwDSParam* CreateDSData(const SwDBData& rData) + {return FindDSData(rData, TRUE);} const SwDSParamArr& GetDSParamArray() const {return aDataSourceParams;} diff --git a/sw/inc/swdbdata.hxx b/sw/inc/swdbdata.hxx index 81b88b6044f7..8e6c89006607 100644 --- a/sw/inc/swdbdata.hxx +++ b/sw/inc/swdbdata.hxx @@ -2,9 +2,9 @@ * * $RCSfile: swdbdata.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: os $ $Date: 2001-02-21 12:04:41 $ + * last change: $Author: os $ $Date: 2001-03-30 11:59:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,7 +70,7 @@ struct SwDBData { ::rtl::OUString sDataSource; ::rtl::OUString sCommand; //table, query or statement - sal_Int16 nCommandType; //com::sun::star::sdb::CommandType + sal_Int32 nCommandType; //com::sun::star::sdb::CommandType SwDBData() : nCommandType(0){} diff --git a/sw/sdi/_basesh.sdi b/sw/sdi/_basesh.sdi index 090f21aad120..e39611b17250 100644 --- a/sw/sdi/_basesh.sdi +++ b/sw/sdi/_basesh.sdi @@ -2,7 +2,7 @@ $Workfile: _BASESH.SDI $ - $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/sdi/_basesh.sdi,v 1.1.1.1 2000-09-18 17:14:29 hr Exp $ + $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/sdi/_basesh.sdi,v 1.2 2001-03-30 12:00:08 os Exp $ Beschreibung: interface Base - gemeinsame Basisfunktionalitaet fuer SW und SW/WEB @@ -99,28 +99,6 @@ interface BaseTextSelection : Selection DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] - SID_SBA_BRW_UPDATE - [ - StateMethod = GetState; - ExecMethod = ExecDB; - Export = FALSE - ] - - SID_SBA_BRW_INSERT - [ - StateMethod = GetState; - ExecMethod = ExecDB; - Export = FALSE - DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; - ] - - SID_SBA_BRW_MERGE - [ - StateMethod = GetState; - ExecMethod = ExecDB; - Export = FALSE - ] - FN_UPDATE_FIELDS // status(final|play) [ ExecMethod = Execute ; @@ -488,6 +466,9 @@ interface BaseTextSelection : Selection /*------------------------------------------------------------------------ $Log: not supported by cvs2svn $ + Revision 1.1.1.1 2000/09/18 17:14:29 hr + initial import + Revision 1.46 2000/05/30 10:12:26 os unused slots removed diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 5f0d1413723a..56bc48dd37c3 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -2,9 +2,9 @@ * * $RCSfile: docfld.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: os $ $Date: 2001-02-21 12:40:22 $ + * last change: $Author: os $ $Date: 2001-03-30 12:02:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1418,7 +1418,7 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, BOOL bUpdRefFlds ) SwDBData aDBData(((SwDBField*)pFld)->GetDBData()); if( pMgr->OpenDataSource( aDBData.sDataSource, aDBData.sCommand )) - aCalc.VarChange( sDBNumNm, pMgr->GetSelectedRecordId(aDBData.sDataSource, aDBData.sCommand)); + aCalc.VarChange( sDBNumNm, pMgr->GetSelectedRecordId(aDBData.sDataSource, aDBData.sCommand, aDBData.nCommandType)); const String& rName = pFld->GetTyp()->GetName(); @@ -1601,7 +1601,7 @@ void SwDoc::UpdateDBNumFlds( SwDBNameInfField& rDBFld, SwCalc& rCalc ) if( pMgr->OpenDataSource( aDBData.sDataSource, aDBData.sCommand )) rCalc.VarChange( lcl_GetDBVarName( *this, rDBFld), - pMgr->GetSelectedRecordId(aDBData.sDataSource, aDBData.sCommand) ); + pMgr->GetSelectedRecordId(aDBData.sDataSource, aDBData.sCommand, aDBData.nCommandType) ); } else { @@ -1787,7 +1787,7 @@ void SwDoc::GetAllDBNames( SvStringsDtor& rAllDBNames ) SwDSParam* pParam = rArr[i]; String* pStr = new String( pParam->sDataSource ); (*pStr) += DB_DELIM; - (*pStr) += pParam->sTableOrQuery; + (*pStr) += (String)pParam->sCommand; rAllDBNames.Insert( pStr, rAllDBNames.Count() ); } } @@ -1858,7 +1858,11 @@ void SwDoc::AddUsedDBToList( SvStringsDtor& rDBNameList, const String& rDBName) rDBNameList.GetObject(i)->GetToken(0) ))) return; - const SwDSParam* pParam = GetNewDBMgr()->CreateDSData(rDBName); + SwDBData aData; + aData.sDataSource = rDBName.GetToken(0, DB_DELIM); + aData.sCommand = rDBName.GetToken(1, DB_DELIM); + aData.nCommandType = -1; + const SwDSParam* pParam = GetNewDBMgr()->CreateDSData(aData); String* pNew = new String( rDBName ); rDBNameList.Insert( pNew, rDBNameList.Count() ); } diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index 712289705d95..ddd6a47bdcc9 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.18 $ + * $Revision: 1.19 $ * - * last change: $Author: jp $ $Date: 2001-02-21 13:24:21 $ + * last change: $Author: os $ $Date: 2001-03-30 12:03:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -132,6 +132,9 @@ #ifndef _NUMUNO_HXX #include <svtools/numuno.hxx> #endif +#ifndef _SFXSTRITEM_HXX +#include <svtools/stritem.hxx> +#endif #include <float.h> diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 897c36f4ec53..96e90a8aaa75 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.24 $ + * $Revision: 1.25 $ * - * last change: $Author: os $ $Date: 2001-03-07 13:38:59 $ + * last change: $Author: os $ $Date: 2001-03-30 12:03:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -329,16 +329,7 @@ BOOL lcl_MoveAbsolute(SwDSParam* pParam, long nAbsPos) } else { - pParam->nSelectionIndex = 0; - pParam->xResultSet = pParam->xStatement->executeQuery( pParam->sStatement ); - bRet = TRUE; - while(nAbsPos >= 0 && bRet) - { - bRet &= !pParam->xResultSet->next(); - pParam->nSelectionIndex++; - nAbsPos--; - } - bRet &= nAbsPos != -1; + DBG_ERROR("no absolute positioning available") } } catch(Exception aExcept) @@ -367,7 +358,7 @@ BOOL lcl_GetColumnCnt(SwDSParam* pParam, aFormatData.xFormatter = pParam->xFormatter; String sLanguage, sCountry; - ::ConvertLanguageToIsoNames( nLanguage, sLanguage, sCountry ); + ::ConvertLanguageToIsoNames( (USHORT)nLanguage, sLanguage, sCountry ); aFormatData.aLocale.Language = sLanguage; aFormatData.aLocale.Country = sCountry; @@ -384,29 +375,34 @@ BOOL SwNewDBMgr::MergeNew(USHORT nOpt, SwWrtShell& rSh, DBG_ASSERT(!bInMerge && !pMergeData, "merge already activated!") - OUString sDataSource, sDataTableOrQuery; + SwDBData aData; + aData.nCommandType = CommandType::TABLE; 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; + pValues[nPos].Value >>= aData.sDataSource; else if(!pValues[nPos].Name.compareToAscii("Command")) - pValues[nPos].Value >>= sDataTableOrQuery; + pValues[nPos].Value >>= aData.sCommand; 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; + pValues[nPos].Value >>= aData.nCommandType; } - if(!sDataSource.getLength() || !sDataTableOrQuery.getLength() || !xResSet.is()) + if(!aData.sDataSource.getLength() || !aData.sCommand.getLength() || !xResSet.is()) { return FALSE; } - pMergeData = new SwDSParam(sDataSource, sDataTableOrQuery, SW_DB_SELECT_UNKNOWN, xResSet, aSelection); + pMergeData = new SwDSParam(aData, xResSet, aSelection); + SwDSParam* pTemp = FindDSData(aData, FALSE); + if(pTemp) + *pTemp = *pMergeData; + else + aDataSourceParams.Insert(new SwDSParam(*pMergeData), aDataSourceParams.Count()); try{ //set to start position @@ -424,7 +420,7 @@ BOOL SwNewDBMgr::MergeNew(USHORT nOpt, SwWrtShell& rSh, pMergeData->CheckEndOfDB(); } } - catch(Exception& rExcept) + catch(Exception&) { pMergeData->bEndOfDB = TRUE; pMergeData->CheckEndOfDB(); @@ -432,12 +428,11 @@ BOOL SwNewDBMgr::MergeNew(USHORT nOpt, SwWrtShell& rSh, } Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - Reference<XDataSource> xSource = dbtools::getDataSource(sDataSource, xMgr); + Reference<XDataSource> xSource = dbtools::getDataSource(aData.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); @@ -458,7 +453,7 @@ BOOL SwNewDBMgr::MergeNew(USHORT nOpt, SwWrtShell& rSh, } } - ChgDBName(&rSh, sDataSource, sDataTableOrQuery, aEmptyStr); + rSh.ChgDBData(aData); bInMerge = TRUE; if (IsInitDBFields()) @@ -524,87 +519,6 @@ BOOL SwNewDBMgr::MergeNew(USHORT nOpt, SwWrtShell& rSh, return bRet; } -BOOL SwNewDBMgr::Merge( USHORT nOpt, SwWrtShell* pSh, - const String& rStatement, - const SbaSelectionListRef xSelectionList, - const String& rDataSource, - const String& rTableOrQuery, - const String *pPrinter) -{ - ChgDBName(pSh, rDataSource, rTableOrQuery,rStatement); - // Falls noch nicht offen, spaetestens hier - - if(!OpenMergeSource(rDataSource, rTableOrQuery, rStatement, xSelectionList)) - return FALSE; - - if (IsInitDBFields()) - { - // Bei Datenbankfeldern ohne DB-Name DB-Name von Dok einsetzen - SvStringsDtor aDBNames(1, 1); - aDBNames.Insert( new String(), 0); - SwDBData aData = pSh->GetDBData(); - String sDBName = aData.sDataSource; - sDBName += DB_DELIM; - sDBName += (String)aData.sCommand; - sDBName += DB_DELIM; - sDBName += String::CreateFromInt32(aData.nCommandType); - pSh->ChangeDBFields( aDBNames, sDBName); - SetInitDBFields(FALSE); - } - const SbaSelectionList* pSelList = 0; - if( xSelectionList.Is() && (long)xSelectionList->GetObject(0) != -1L ) - { - if( xSelectionList->Count() ) - pSelList = &xSelectionList; - } - - BOOL bRet = TRUE; - switch(nOpt) - { - case DBMGR_MERGE: - bRet = Merge(pSh); // Mischen - break; - - case DBMGR_MERGE_MAILMERGE: // Serienbrief - { - SfxDispatcher *pDis = pSh->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(pSh); // Mailing - break; - - case DBMGR_MERGE_MAILFILES: - bRet = MergeMailFiles(pSh); // Serienbriefe als Dateien abspeichern - break; - - default: // Einfuegen der selektierten Eintraege - // (war: InsertRecord) - ImportFromConnection(pSh ); - break; - } - - EndMerge(); - return bRet; -} /*-------------------------------------------------------------------- Beschreibung: Daten importieren --------------------------------------------------------------------*/ @@ -614,12 +528,6 @@ BOOL SwNewDBMgr::Merge(SwWrtShell* pSh) { pSh->StartAllAction(); -/* for (ULONG i = 0 ; i < GetDBData().pSelectionList->Count(); i++) - { - ULONG nIndex = (ULONG)GetDBData().pSelectionList->GetObject(i); - DBG_TRACE(String(nIndex)); - }*/ - pSh->ViewShell::UpdateFlds(TRUE); pSh->SetModified(); @@ -629,41 +537,8 @@ BOOL SwNewDBMgr::Merge(SwWrtShell* pSh) } /*-------------------------------------------------------------------- - Beschreibung: Daten importieren - --------------------------------------------------------------------*/ - - -/*void SwNewDBMgr::UpdateImport( const BOOL bBasic, SwWrtShell* pSh, - const String& rDBName, - const String& rStatement, - const SbaSelectionListRef xSelectionList ) -{ - ChgDBName(pSh, rDBName, rStatement); - - if( OpenDB( bBasic, pSh->GetDBDesc()) ) - { - OfaDBParam& rParam = GetDBData(bBasic); - - ChangeStatement(bBasic, rStatement); - - const SbaSelectionList* pSelList = 0; - rParam.pSelectionList->Clear(); - if( xSelectionList.Is() && -1L != (long)xSelectionList->GetObject(0) ) - { - *rParam.pSelectionList = *xSelectionList; - if( xSelectionList->Count() ) - pSelList = &xSelectionList; - } - - ImportFromConnection( bBasic, pSh, pSelList ); - } -} */ - -/*-------------------------------------------------------------------- Beschreibung: --------------------------------------------------------------------*/ - - void SwNewDBMgr::ImportFromConnection( SwWrtShell* pSh ) { if(pMergeData && !pMergeData->bEndOfDB) @@ -697,8 +572,6 @@ void SwNewDBMgr::ImportFromConnection( SwWrtShell* pSh ) } } } - - /*-----------------24.02.97 10.30------------------- --------------------------------------------------*/ @@ -738,9 +611,8 @@ String lcl_FindColumn(const String& sFormatStr,USHORT &nUsedPos, BYTE &nSepara Beschreibung: --------------------------------------------------------------------*/ -inline String lcl_GetDBInsertMode( String sDBName ) +inline String lcl_GetDBInsertMode( const SwDBData& rData ) { - sDBName.SearchAndReplace( DB_DELIM, '.'); return aEmptyStr; #if 0 //JP 13.11.00: must be change to the new configuration @@ -757,10 +629,7 @@ void SwNewDBMgr::ImportDBEntry(SwWrtShell* pSh) { Reference< XColumnsSupplier > xColsSupp( pMergeData->xResultSet, UNO_QUERY ); Reference <XNameAccess> xCols = xColsSupp->getColumns(); - String sSymDBName(pMergeData->sDataSource); - sSymDBName += DB_DELIM; - sSymDBName += pMergeData->sTableOrQuery; - String sFormatStr( lcl_GetDBInsertMode( sSymDBName )); + String sFormatStr( lcl_GetDBInsertMode( *pMergeData )); USHORT nFmtLen = sFormatStr.Len(); if( nFmtLen ) { @@ -821,27 +690,6 @@ void SwNewDBMgr::ImportDBEntry(SwWrtShell* pSh) } } } - -/*-------------------------------------------------------------------- - Beschreibung: - --------------------------------------------------------------------*/ - - -void SwNewDBMgr::ChgDBName(SwWrtShell* pSh, - const String& rDataSource, - const String& rTableOrQuery, - const String& rStatement) -{ - if (pSh) - { - SwDBData aData; - aData.sDataSource = rDataSource; - aData.sCommand = rStatement.Len() ? rStatement : rTableOrQuery; - aData.nCommandType = rStatement.Len() ? CommandType::COMMAND : CommandType::TABLE; - pSh->ChgDBData(aData); - } -} - /*-------------------------------------------------------------------- Beschreibung: Listbox mit Tabellenliste fuellen --------------------------------------------------------------------*/ @@ -914,7 +762,6 @@ SwNewDBMgr::SwNewDBMgr() : nMergeType(DBMGR_INSERT), bInitDBFields(FALSE) { - pMergeList = new SbaSelectionList; } /* -----------------------------18.07.00 08:56-------------------------------- @@ -934,16 +781,10 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, //check if the doc is synchronized and contains at least one linked section BOOL bSynchronizedDoc = pSh->IsLabelDoc() && pSh->GetSectionFmtCount() > 1; //merge source is already open - rOpt.nMergeCnt = pMergeData && pMergeData->xSelectionList.Is() ? - pMergeData->xSelectionList->Count() : 0; + rOpt.nMergeCnt = pMergeData && pMergeData->aSelection.getLength(); -// if (IsPrintFromBasicDB()) -// rOpt.bSinglePrtJobs = IsSingleJobs(); -// else -// { - SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); - rOpt.bSinglePrtJobs = pModOpt->IsSinglePrintJob(); -// } + SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); + rOpt.bSinglePrtJobs = pModOpt->IsSinglePrintJob(); SfxPrinter *pPrt = pSh->GetPrt(); Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); @@ -1402,7 +1243,7 @@ ULONG SwNewDBMgr::GetColumnFmt( const String& rDBName, Reference< XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY); String sLanguage, sCountry; - ::ConvertLanguageToIsoNames( nLanguage, sLanguage, sCountry ); + ::ConvertLanguageToIsoNames( (USHORT)nLanguage, sLanguage, sCountry ); Locale aLocale; aLocale.Language = sLanguage; aLocale.Country = sCountry; @@ -1649,105 +1490,6 @@ String SwNewDBMgr::GetDBField(Reference<XPropertySet> xColumnProps, return sRet; } -/* -----------------------------06.07.00 14:26-------------------------------- - opens a data source table or query and keeps the reference - until EndMerge() is called - ---------------------------------------------------------------------------*/ -BOOL SwNewDBMgr::OpenMergeSource(const String& rDataSource, - const String& rDataTableOrQuery, - const String& rStatement, - const SbaSelectionListRef xSelectionList) -{ - DBG_ASSERT(!bInMerge && !pMergeData, "merge already activated!") - bInMerge = TRUE; - pMergeData = new SwDSParam(rDataSource, rDataTableOrQuery, SW_DB_SELECT_UNKNOWN, rStatement); - //remove corresponding data from aDataSourceParams and insert the merge data - String sDBName(rDataSource); - sDBName += DB_DELIM; - sDBName += rDataTableOrQuery; - SwDSParam* pTemp = FindDSData(sDBName, FALSE); - if(pTemp) - pTemp = pMergeData; - else - aDataSourceParams.Insert(pMergeData, aDataSourceParams.Count()); - - Reference<XDataSource> xSource; - pMergeData->xConnection = SwNewDBMgr::GetConnection(rDataSource, xSource); - pMergeData->xSelectionList = xSelectionList; - if( xSelectionList.Is() && xSelectionList->Count() && (long)xSelectionList->GetObject(0) != -1L ) - { - pMergeData->bSelectionList = TRUE; - } - - if(pMergeData->xConnection.is()) - { - try - { - pMergeData->bScrollable = pMergeData->xConnection->getMetaData() - ->supportsResultSetType((sal_Int32)ResultSetType::SCROLL_INSENSITIVE); - pMergeData->xStatement = pMergeData->xConnection->createStatement(); - pMergeData->xResultSet = pMergeData->xStatement->executeQuery( rStatement ); - //after executeQuery the cursor must be positioned - if(pMergeData->bSelectionList) - { - if(pMergeData->bScrollable) - { - pMergeData->bEndOfDB = !pMergeData->xResultSet->absolute( - (ULONG)pMergeData->xSelectionList->GetObject( 0 ) ); - } - else - { - ULONG nPos = (ULONG)pMergeData->xSelectionList->GetObject( 0 ); - while(nPos > 0 && !pMergeData->bEndOfDB) - { - pMergeData->bEndOfDB |= !pMergeData->xResultSet->next(); - nPos--; - } - } - pMergeData->CheckEndOfDB(); - if(1 == pMergeData->xSelectionList->Count()) - pMergeData->bEndOfDB = TRUE; - } - else - { - pMergeData->bEndOfDB = !pMergeData->xResultSet->next(); - pMergeData->CheckEndOfDB(); - ++pMergeData->nSelectionIndex; - } - Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - if( xMgr.is() ) - { - Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.util.NumberFormatter" )); - pMergeData->xFormatter = Reference<util::XNumberFormatter>(xInstance, UNO_QUERY) ; - } - - Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY); - if(xSourceProps.is()) - { - Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier")); - if(aFormats.hasValue()) - { - Reference<XNumberFormatsSupplier> xSuppl = *(Reference<util::XNumberFormatsSupplier>*) aFormats.getValue(); - if(xSuppl.is()) - { - Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings(); - Any aNull = xSettings->getPropertyValue(C2U("NullDate")); - if(aNull.hasValue()) - pMergeData->aNullDate = *(util::Date*)aNull.getValue(); - } - } - } - } - catch(Exception aExcept) - { - DBG_ERROR("exception caught") - } - } - BOOL bRet = pMergeData && pMergeData->xResultSet.is(); - if(!bRet) - pMergeData = 0; - return bRet; -} /* -----------------------------06.07.00 14:28-------------------------------- releases the merge data source table or query after merge is completed ---------------------------------------------------------------------------*/ @@ -1765,8 +1507,8 @@ BOOL SwNewDBMgr::IsDataSourceOpen(const String& rDataSource, const String& rT { if(pMergeData) { - return rDataSource == pMergeData->sDataSource && - rTableOrQuery == pMergeData->sTableOrQuery && + return rDataSource == (String)pMergeData->sDataSource && + rTableOrQuery == (String)pMergeData->sCommand && pMergeData->xResultSet.is(); } else @@ -1783,8 +1525,8 @@ BOOL SwNewDBMgr::GetColumnCnt(const String& rSourceName, const String& rTableNam BOOL bRet = FALSE; //check if it's the merge data source if(pMergeData && - rSourceName == pMergeData->sDataSource && - rTableName == pMergeData->sTableOrQuery) + rSourceName == (String)pMergeData->sDataSource && + rTableName == (String)pMergeData->sCommand) { if(!pMergeData->xResultSet.is()) return FALSE; @@ -1833,45 +1575,7 @@ BOOL SwNewDBMgr::ToNextMergeRecord() } try { - if(pMergeData->bSelectionList) - { - DBG_ERROR("remove old code") - if(pMergeData->bScrollable) - { - pMergeData->bEndOfDB = !pMergeData->xResultSet->absolute( - (ULONG)pMergeData->xSelectionList->GetObject( ++pMergeData->nSelectionIndex ) ); - } - else - { - ULONG nOldPos = pMergeData->nSelectionIndex ? - (ULONG)pMergeData->xSelectionList->GetObject(pMergeData->nSelectionIndex): 0; - ULONG nPos = (ULONG)pMergeData->xSelectionList->GetObject( ++pMergeData->nSelectionIndex ); - DBG_ASSERT(nPos >=0, "selection invalid!") - long nDiff = nPos - nOldPos; - //if a backward move is necessary then the result set must be created again - if(nDiff < 0) - { - try - { - pMergeData->xResultSet = pMergeData->xStatement->executeQuery( pMergeData->sStatement ); - } - catch(Exception&) - { - pMergeData->bEndOfDB = TRUE; - } - nDiff = nPos; - } - while(nDiff > 0 && !pMergeData->bEndOfDB) - { - pMergeData->bEndOfDB |= !pMergeData->xResultSet->next(); - nDiff--; - } - } - pMergeData->CheckEndOfDB(); - if(pMergeData->nSelectionIndex >= pMergeData->xSelectionList->Count()) - pMergeData->bEndOfDB = TRUE; - } - else if(pMergeData->aSelection.getLength()) + if(pMergeData->aSelection.getLength()) { pMergeData->bEndOfDB = !pMergeData->xResultSet->absolute( (ULONG)pMergeData->aSelection.getConstArray()[ pMergeData->nSelectionIndex++ ] ); @@ -1929,16 +1633,7 @@ sal_Bool SwNewDBMgr::ToRecordId(sal_Int32 nSet) if(!pMergeData || !pMergeData->xResultSet.is()|| nSet < 0) return FALSE; sal_Bool bRet = FALSE; - sal_Int32 nAbsPos = -1; - if(pMergeData->bSelectionList) - { - if(pMergeData->xSelectionList->Count() > nSet) - { - nAbsPos = (sal_Int32)pMergeData->xSelectionList->GetObject(nSet); - } - } - else - nAbsPos = nSet; + sal_Int32 nAbsPos = nSet; if(nAbsPos >= 0) { @@ -1993,13 +1688,14 @@ void lcl_ExtractMembers(const String& rDBName, String& sSource, String& sTable, /* -----------------------------17.07.00 14:17-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwNewDBMgr::OpenDataSource(const String& rDataSource, const String& rTableOrQuery) +BOOL SwNewDBMgr::OpenDataSource(const String& rDataSource, const String& rTableOrQuery, sal_Int32 nCommandType) { - String sDBName = rDataSource; - sDBName += DB_DELIM; - sDBName += rTableOrQuery; - SwDSParam* pFound = FindDSData(sDBName, TRUE); - pFound->bSelectionList = pFound->xSelectionList.Is() && pFound->xSelectionList->Count(); + SwDBData aData; + aData.sDataSource = rDataSource; + aData.sCommand = rTableOrQuery; + aData.nCommandType = nCommandType; + + SwDSParam* pFound = FindDSData(aData, TRUE); Reference< XDataSource> xSource; if(pFound->xResultSet.is()) return TRUE; @@ -2012,45 +1708,18 @@ BOOL SwNewDBMgr::OpenDataSource(const String& rDataSource, const String& rTableO pFound->bScrollable = xMetaData ->supportsResultSetType((sal_Int32)ResultSetType::SCROLL_INSENSITIVE); pFound->xStatement = pFound->xConnection->createStatement(); - if(!pFound->sStatement.Len()) - { - OUString aQuoteChar = xMetaData->getIdentifierQuoteString(); - OUString sStatement(C2U("SELECT * FROM ")); - sStatement = C2U("SELECT * FROM "); - sStatement += aQuoteChar; - sStatement += rTableOrQuery; - sStatement += aQuoteChar; - pFound->sStatement = sStatement; - } - pFound->xResultSet = pFound->xStatement->executeQuery( pFound->sStatement ); + OUString aQuoteChar = xMetaData->getIdentifierQuoteString(); + OUString sStatement(C2U("SELECT * FROM ")); + sStatement = C2U("SELECT * FROM "); + sStatement += aQuoteChar; + sStatement += rTableOrQuery; + sStatement += aQuoteChar; + pFound->xResultSet = pFound->xStatement->executeQuery( sStatement ); //after executeQuery the cursor must be positioned - if(pFound->bSelectionList) - { - if(pFound->bScrollable) - { - pFound->bEndOfDB = !pFound->xResultSet->absolute( - (ULONG)pFound->xSelectionList->GetObject( 0 ) ); - } - else - { - ULONG nPos = (ULONG)pFound->xSelectionList->GetObject( 0 ); - while(nPos > 0 && !pFound->bEndOfDB) - { - pFound->bEndOfDB |= !pFound->xResultSet->next(); - nPos--; - } - } - pFound->CheckEndOfDB(); - if(1 == pFound->xSelectionList->Count()) - pFound->bEndOfDB = TRUE; - } - else - { - pFound->bEndOfDB = !pFound->xResultSet->next(); - pFound->CheckEndOfDB(); - ++pFound->nSelectionIndex; - } + pFound->bEndOfDB = !pFound->xResultSet->next(); + pFound->CheckEndOfDB(); + ++pFound->nSelectionIndex; } catch (Exception&) { @@ -2064,20 +1733,23 @@ BOOL SwNewDBMgr::OpenDataSource(const String& rDataSource, const String& rTableO /* -----------------------------17.07.00 15:55-------------------------------- ---------------------------------------------------------------------------*/ -sal_uInt32 SwNewDBMgr::GetSelectedRecordId(const String& rDataSource, const String& rTableOrQuery) +sal_uInt32 SwNewDBMgr::GetSelectedRecordId( + const String& rDataSource, const String& rTableOrQuery, sal_Int32 nCommandType) { sal_uInt32 nRet = -1; //check for merge data source first - if(pMergeData && rDataSource == pMergeData->sDataSource && - rTableOrQuery == pMergeData->sTableOrQuery && + if(pMergeData && rDataSource == (String)pMergeData->sDataSource && + rTableOrQuery == (String)pMergeData->sCommand && + (nCommandType == -1 || nCommandType == pMergeData->nCommandType) && pMergeData->xResultSet.is()) nRet = GetSelectedRecordId(); else { - String sDBName(rDataSource); - sDBName += DB_DELIM; - sDBName += rTableOrQuery; - SwDSParam* pFound = SwNewDBMgr::FindDSData(sDBName, FALSE); + SwDBData aData; + aData.sDataSource = rDataSource; + aData.sCommand = rTableOrQuery; + aData.nCommandType = nCommandType; + SwDSParam* pFound = FindDSData(aData, FALSE); if(pFound && pFound->xResultSet.is()) { try @@ -2109,19 +1781,15 @@ void SwNewDBMgr::CloseAll(BOOL bIncludingMerge) /* -----------------------------17.07.00 14:54-------------------------------- ---------------------------------------------------------------------------*/ -SwDSParam* SwNewDBMgr::FindDSData(const String& rDBName, BOOL bCreate) +SwDSParam* SwNewDBMgr::FindDSData(const SwDBData& rData, BOOL bCreate) { - String sSource; - String sTable; - String sStatement; - lcl_ExtractMembers(rDBName, sSource, sTable, sStatement); SwDSParam* pFound = 0; - for(USHORT nPos = 0; nPos < aDataSourceParams.Count(); nPos++) { SwDSParam* pParam = aDataSourceParams[nPos]; - if(sSource == pParam->sDataSource && - sTable == pParam->sTableOrQuery) + if(rData.sDataSource == pParam->sDataSource && + rData.sCommand == pParam->sCommand && + (rData.nCommandType == -1 || rData.nCommandType == pParam->nCommandType)) { pFound = pParam; break; @@ -2131,63 +1799,48 @@ SwDSParam* SwNewDBMgr::FindDSData(const String& rDBName, BOOL bCreate) { if(!pFound) { - pFound = new SwDSParam(sSource, sTable, SW_DB_SELECT_UNKNOWN, sStatement); + pFound = new SwDSParam(rData); aDataSourceParams.Insert(pFound, aDataSourceParams.Count()); } - else - pFound->sStatement = sStatement; } return pFound; } /* -----------------------------17.07.00 14:31-------------------------------- rDBName: <Source> + DB_DELIM + <Table>; + <Statement> ---------------------------------------------------------------------------*/ -void SwNewDBMgr::AddDSData(const String& rDBName, long nSelStart, long nSelEnd) +void SwNewDBMgr::AddDSData(const SwDBData& rData, long nSelStart, long nSelEnd) { - SwDSParam* pFound = FindDSData(rDBName, TRUE); - if(pFound->xSelectionList.Is()) - pFound->xSelectionList->Clear(); - else - pFound->xSelectionList = new SbaSelectionList; - if (nSelStart > 0) + SwDSParam* pFound = FindDSData(rData, TRUE); + if(nSelStart > 0) { - if (nSelEnd < nSelStart) + if(nSelEnd < nSelStart) { sal_uInt32 nZw = nSelEnd; nSelEnd = nSelStart; nSelStart = nZw; } - for (long i = nSelStart; i <= nSelEnd; i++) - pFound->xSelectionList->Insert((void*)i , LIST_APPEND); + pFound->aSelection.realloc(nSelEnd - nSelStart + 1); + sal_Int32* pSelection = pFound->aSelection.getArray(); + sal_Int32 nIdx = 0; + for (long i = nSelStart; i <= nSelEnd; i++, nIdx++) + pSelection[nIdx] = i; } + else + pFound->aSelection.realloc(0); } /* -----------------------------17.07.00 14:31-------------------------------- ---------------------------------------------------------------------------*/ -void SwNewDBMgr::GetDSSelection(const String& rDBDesc, long& rSelStart, long& rSelEnd) +void SwNewDBMgr::GetDSSelection(const SwDBData& rData, long& rSelStart, long& rSelEnd) { - SwDSParam* pFound = FindDSData(rDBDesc, FALSE); - if(!pFound || !pFound->xSelectionList.Is() || !pFound->xSelectionList->Count()) + SwDSParam* pFound = FindDSData(rData, FALSE); + if(!pFound || !pFound->aSelection.getLength()) rSelStart = -1L; else { - if(pFound->xSelectionList->Count()) - { - rSelStart = (sal_uInt32)pFound->xSelectionList->GetObject(0); - for (sal_uInt32 i = 1; i < pFound->xSelectionList->Count(); i++) - { - long nPrev = (sal_uInt32)pFound->xSelectionList->GetObject(i - 1); - long nNow = (sal_uInt32)pFound->xSelectionList->GetObject(i); - - if (nNow - nPrev > 1) - { - rSelEnd = nPrev; - return; - } - } - rSelEnd = (sal_uInt32)pFound->xSelectionList->GetObject(i - 1); - } + rSelStart = pFound->aSelection.getConstArray()[0]; + rSelEnd = pFound->aSelection.getConstArray()[pFound->aSelection.getLength() - 1]; } } /* -----------------------------17.07.00 14:34-------------------------------- diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx index 08f25b1894c8..e76503d2e14f 100644 --- a/sw/source/ui/shells/basesh.cxx +++ b/sw/source/ui/shells/basesh.cxx @@ -2,9 +2,9 @@ * * $RCSfile: basesh.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: jp $ $Date: 2001-03-23 15:50:38 $ + * last change: $Author: os $ $Date: 2001-03-30 12:05:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1473,18 +1473,6 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) } break; - case SID_SBA_BRW_UPDATE: - case SID_SBA_BRW_INSERT: - case SID_SBA_BRW_MERGE: - { - //Damit der Datenbankbrowser die Buttons fuer alle Shells - //anzeigt. Aber nur disabled, enabled wird nur in der Textsh. - const int nSelType = rSh.GetSelectionType(); - rSet.Put(SfxBoolItem(nWhich, - nSelType & SwWrtShell::SEL_TXT ? TRUE : FALSE )); - } - break; - case FN_TOOL_ANKER: case FN_TOOL_ANKER_PAGE: case FN_TOOL_ANKER_PARAGRAPH: @@ -2528,81 +2516,4 @@ void SwBaseShell::ExecField( SfxRequest& rReq ) } } -/*------------------------------------------------------------------------ - - $Log: not supported by cvs2svn $ - Revision 1.7 2001/03/01 12:33:49 os - State contour dialog: not disabled in if swapped out anymore - - Revision 1.6 2001/02/27 12:21:02 os - #82741# Enable image map editor also if graphic is swapped out - - Revision 1.5 2001/02/02 17:43:37 jp - use new clipboard - - Revision 1.4 2000/12/22 12:07:32 jp - Bug #81672#: asynch loaded graphics for status updates - - Revision 1.3 2000/11/23 20:08:52 jp - Task #80648#: use new class SvxScriptSetItem - - Revision 1.2 2000/11/13 13:19:55 jp - new method GetTextFontCtrl - - Revision 1.1.1.1 2000/09/18 17:14:46 hr - initial import - - Revision 1.404 2000/09/18 16:06:02 willem.vandorp - OpenOffice header added. - - Revision 1.403 2000/09/13 11:38:45 ka - use URL method of Gallery instead of DirEntry method - - Revision 1.402 2000/09/12 13:16:50 kz - add. include tools/fsys.hxx - - Revision 1.401 2000/09/08 08:12:51 os - Change: Set/Toggle/Has/Knows/Show/GetChildWindow - - Revision 1.400 2000/09/07 15:59:28 os - change: SFX_DISPATCHER/SFX_BINDINGS removed - - Revision 1.399 2000/08/17 11:42:20 jp - remove the SW graphicmanager - - Revision 1.398 2000/08/15 13:51:49 os - #77616# allow background color for graphic objects - - Revision 1.397 2000/07/11 18:54:25 jp - Task #70407#: use the GraphikObject - - Revision 1.396 2000/07/11 17:56:35 jp - Bug #76736#: Execute - UpdateFields reativate - - Revision 1.395 2000/06/26 13:17:56 os - INetURLObject::SmartRelToAbs removed - - Revision 1.394 2000/06/07 13:18:20 os - using UCB - - Revision 1.393 2000/05/30 10:40:31 os - unused slots removed - - Revision 1.392 2000/05/26 07:21:31 os - old SW Basic API Slots removed - - Revision 1.391 2000/05/10 11:53:01 os - Basic API removed - - Revision 1.390 2000/05/09 14:41:35 os - BASIC interface partially removed - - Revision 1.389 2000/05/08 11:22:47 os - CreateSubObject - - Revision 1.388 2000/04/18 14:58:23 os - UNICODE - -------------------------------------------------------------------------*/ - diff --git a/sw/source/ui/shells/textsh2.cxx b/sw/source/ui/shells/textsh2.cxx index cd9a53d758a6..a93db5a9e186 100644 --- a/sw/source/ui/shells/textsh2.cxx +++ b/sw/source/ui/shells/textsh2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: textsh2.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: os $ $Date: 2001-02-21 12:27:37 $ + * last change: $Author: os $ $Date: 2001-03-30 12:05:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -165,88 +165,6 @@ inline void AddSelList( List& rLst, long nRow ) { rLst.Insert( (void*)nRow , LIST_APPEND ); } - -void lcl_QRY_UPDATE( const SfxItemSet *pArgs, SwNewDBMgr *pNewDBMgr, - SwWrtShell &rSh, USHORT nSlot ) -{ - DBG_ASSERT( pArgs, "arguments expected" ); - if (pArgs) - { - SbaSelectionListRef pSelectionList; - - const SfxStringItem &rDBNameItem = (const SfxStringItem&) pArgs->Get(SID_ATTR_SBA_DATABASE); - const SfxStringItem &rTableNameItem = (const SfxStringItem&) pArgs->Get(SID_ATTR_SBA_DBOBJ_NAME); - const SfxStringItem &rStatementItem = (const SfxStringItem&) pArgs->Get(SID_ATTR_SBA_STATEMENT); - DBG_ASSERT( rStatementItem.ISA(SfxStringItem), "invalid argument type" ); - - const SbaSelectionItem &rSelectionItem = (const SbaSelectionItem&) pArgs->Get(SID_ATTR_SBA_SELECTION); - pSelectionList = rSelectionItem.GetSelectionList(); - - - String sDBName(rDBNameItem.GetValue()); - String sTableName(rTableNameItem.GetValue()); - String sStatement(rStatementItem.GetValue()); - - pNewDBMgr->SetMergeType( DBMGR_MERGE ); - pNewDBMgr->Merge(DBMGR_MERGE, &rSh, - sStatement, pSelectionList, sDBName, sTableName); - } -} - -/* --------------------------------------------------------------------------- - - ---------------------------------------------------------------------------*/ -void SwBaseShell::ExecDB(SfxRequest &rReq) -{ - const SfxItemSet *pArgs = rReq.GetArgs(); - SwNewDBMgr* pNewDBMgr = GetShell().GetNewDBMgr(); - USHORT nSlot = rReq.GetSlot(); - - switch (nSlot) - { - - case SID_SBA_BRW_UPDATE: - lcl_QRY_UPDATE( pArgs, pNewDBMgr, GetShell(), nSlot ); - break; - - case SID_SBA_BRW_INSERT: - DBG_ASSERT( pArgs, "arguments expected" ); - if( pArgs ) - { - String sDBName = ((SfxStringItem&)pArgs->Get( - SID_ATTR_SBA_DATABASE)).GetValue(); - String sTblName = ((SfxStringItem&)pArgs->Get( - SID_ATTR_SBA_DBOBJ_NAME)).GetValue(); - String sStatmnt = ((SfxStringItem&)pArgs->Get( - SID_ATTR_SBA_STATEMENT)).GetValue(); - SbaSelectionListRef xSelectionList( ((SbaSelectionItem&) - pArgs->Get(SID_ATTR_SBA_SELECTION)).GetSelectionList()); - - String* pDataStr = new String( sDBName ); - ((((((*pDataStr) += char(DB_DD_DELIM) ) - += sTblName ) += char(DB_DD_DELIM) ) - += '0' ) += char(DB_DD_DELIM) ) // Flag fuer Tabelle oder Query - unused! - += sStatmnt; - - if( xSelectionList.Is() ) - for( ULONG n = 0, nEnd = xSelectionList->Count(); - n < nEnd; ++n ) - ((*pDataStr) += char(DB_DD_DELIM) ) - += String::CreateFromInt32( - (long)xSelectionList->GetObject( n )); - - SwBaseShell::InsertDBTextHdl( this, pDataStr ); - // der String wird im InsertDBTextHdl geloescht !! - } - break; - default: - ASSERT(!this, falscher Dispatcher); - return; - } -} - - - void SwTextShell::ExecDB(SfxRequest &rReq) { const SfxItemSet *pArgs = rReq.GetArgs(); @@ -273,19 +191,49 @@ void SwTextShell::ExecDB(SfxRequest &rReq) BOOL bTable = sSbaData.GetToken(2, DB_DD_DELIM) == C2S("1"); String sStatement = sSbaData.GetToken(3, DB_DD_DELIM); - SbaSelectionListRef pSelectionList; - pSelectionList.Clear(); - pSelectionList = new SbaSelectionList; USHORT nCount = sSbaData.GetTokenCount(DB_DD_DELIM); + Sequence<sal_Int32> aSelection(nCount - 4); + sal_Int32 * pSelection = aSelection.getArray(); + sal_Int32 nIdx = 0; + for( USHORT i = 4; i < nCount; i++ , nIdx++) + pSelection[nIdx] = sSbaData.GetToken( i, DB_DD_DELIM).ToInt32(); + + Reference<XResultSet> xResultSet; + Reference<XDataSource> xSource; + SwDBData aData; + aData.sDataSource = sDBName; + aData.sCommand = sTableName; + aData.nCommandType = 0; + Reference< XConnection> xConnection = pNewDBMgr->GetConnection(sDBName, xSource); + if(!xConnection.is()) + return ; + Reference<XStatement> xStatement = xConnection->createStatement(); + if(!sStatement.Len()) + { + Reference< sdbc::XDatabaseMetaData > xMetaData = xConnection->getMetaData(); + OUString aQuoteChar = xMetaData->getIdentifierQuoteString(); + OUString sStatement(C2U("SELECT * FROM ")); + sStatement = C2U("SELECT * FROM "); + sStatement += aQuoteChar; + sStatement += aData.sCommand; + sStatement += aQuoteChar; + } + xResultSet = xStatement->executeQuery( sStatement ); + Sequence<PropertyValue> aProperties(5); + PropertyValue* pProperties = aProperties.getArray(); + pProperties[0].Name = C2U("DataSourceName"); + pProperties[0].Value <<= (OUString)sDBName; + pProperties[1].Name = C2U("Command"); + pProperties[1].Value <<= (OUString)sTableName; + pProperties[2].Name = C2U("Cursor"); + pProperties[2].Value <<= xResultSet; + pProperties[3].Name = C2U("Selection"); + pProperties[3].Value <<= aSelection; + pProperties[4].Name = C2U("CommandType"); + pProperties[4].Value <<= (sal_Int32)0; + + pNewDBMgr->MergeNew(DBMGR_MERGE, *GetShellPtr(), aProperties); - for( USHORT i = 4; i < nCount; i++ ) - AddSelList( *pSelectionList, - sSbaData.GetToken( i, DB_DD_DELIM).ToInt32() ); - - pNewDBMgr->SetMergeType( DBMGR_MERGE ); - pNewDBMgr->Merge(DBMGR_MERGE, - GetShellPtr(), sStatement, - pSelectionList, sDBName, sTableName); } break; @@ -314,8 +262,6 @@ void SwTextShell::ExecDB(SfxRequest &rReq) Beschreibung: --------------------------------------------------------------------*/ - - IMPL_STATIC_LINK( SwBaseShell, InsertDBTextHdl, String*, pString ) { if( pString ) @@ -349,7 +295,6 @@ IMPL_STATIC_LINK( SwBaseShell, InsertDBTextHdl, String*, pString ) { Sequence<sal_Int32> aSelection(pString->GetTokenCount(DB_DD_DELIM) - 4 ); sal_Int32* pSelection = aSelection.getArray(); - SbaSelectionList aSelectionList; for(sal_Int32 nPos = 0; nPos < aSelection.getLength(); nPos++) { pSelection[nPos] = pString->GetToken( 0, DB_DD_DELIM, nTokenPos ).ToInt32(); |