diff options
author | Oliver Specht <os@openoffice.org> | 2001-07-10 12:51:01 +0000 |
---|---|---|
committer | Oliver Specht <os@openoffice.org> | 2001-07-10 12:51:01 +0000 |
commit | eb2aa8ef29e97d76a573d3c1e06c04e7772f0cc4 (patch) | |
tree | 34f789937b4dbccba48874682362ff37720c21fe | |
parent | 673acfcd3d65600582be7459e0478ad70c68a7e0 (diff) |
#85318# reading from non-merge data bases corrected
-rw-r--r-- | sw/inc/dbmgr.hxx | 13 | ||||
-rw-r--r-- | sw/source/core/doc/docfld.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/fields/dbfld.cxx | 14 | ||||
-rw-r--r-- | sw/source/core/fields/docufld.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/dbui/dbmgr.cxx | 107 |
5 files changed, 100 insertions, 46 deletions
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx index 9a0233013271..26e54a816ebf 100644 --- a/sw/inc/dbmgr.hxx +++ b/sw/inc/dbmgr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: dbmgr.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: os $ $Date: 2001-06-25 13:42:08 $ + * last change: $Author: os $ $Date: 2001-07-10 13:49:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -220,6 +220,8 @@ class SwNewDBMgr BOOL MergeMailing(SwWrtShell* pSh); // Mischen von Datensaetzen in Felder, dann als Datei abspeichern BOOL MergeMailFiles(SwWrtShell* pSh); + BOOL ToNextRecord(SwDSParam* pParam); + public: SwNewDBMgr(); ~SwNewDBMgr(); @@ -285,8 +287,9 @@ public: 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; + // check if a data source is open + BOOL IsDataSourceOpen(const String& rDataSource, + const String& rTableOrQuery, sal_Bool bMergeOnly); // add data source information to the data source array - was PreInitDBData void AddDSData(const SwDBData& rData, long nSelStart, long nSelEnd); @@ -310,6 +313,8 @@ public: BOOL GetMergeColumnCnt(const String& rColumnName, USHORT nLanguage, String &rResult, double *pNumber, sal_uInt32 *pFormat); BOOL ToNextMergeRecord(); + BOOL ToNextRecord(const String& rDataSource, const String& rTableOrQuery, sal_Int32 nCommandType = -1); + BOOL ExistsNextRecord()const; sal_uInt32 GetSelectedRecordId(); sal_Bool ToRecordId(sal_Int32 nSet); diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 0719c9ed7b91..ee5c1393c8b2 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.7 $ + * $Revision: 1.8 $ * - * last change: $Author: os $ $Date: 2001-07-04 14:01:11 $ + * last change: $Author: os $ $Date: 2001-07-10 13:50:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1417,7 +1417,7 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, BOOL bUpdRefFlds ) SwDBData aDBData(((SwDBField*)pFld)->GetDBData()); - if( pMgr->IsDataSourceOpen(aDBData.sDataSource, aDBData.sCommand)) + if( pMgr->IsDataSourceOpen(aDBData.sDataSource, aDBData.sCommand, sal_False)) aCalc.VarChange( sDBNumNm, pMgr->GetSelectedRecordId(aDBData.sDataSource, aDBData.sCommand, aDBData.nCommandType)); const String& rName = pFld->GetTyp()->GetName(); diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx index 4e856568f94e..2e5274ee990a 100644 --- a/sw/source/core/fields/dbfld.cxx +++ b/sw/source/core/fields/dbfld.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbfld.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: jp $ $Date: 2001-06-13 11:09:20 $ + * last change: $Author: os $ $Date: 2001-07-10 13:50:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -410,7 +410,7 @@ void SwDBField::Evaluate() double nValue = DBL_MAX; const SwDBData& aTmpData = GetDBData(); - if(!pMgr || !pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand)) + if(!pMgr || !pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand, sal_True)) return ; ULONG nFmt; @@ -671,9 +671,9 @@ void SwDBNextSetField::Evaluate(SwDoc* pDoc) SwNewDBMgr* pMgr = pDoc->GetNewDBMgr(); const SwDBData& rData = GetDBData(); if( !bCondValid || - !pMgr || !pMgr->IsDataSourceOpen(rData.sDataSource, rData.sCommand)) + !pMgr || !pMgr->IsDataSourceOpen(rData.sDataSource, rData.sCommand, sal_False)) return ; - pMgr->ToNextMergeRecord(); + pMgr->ToNextRecord(rData.sDataSource, rData.sCommand); } /*-------------------------------------------------------------------- @@ -785,7 +785,7 @@ void SwDBNumSetField::Evaluate(SwDoc* pDoc) const SwDBData& aTmpData = GetDBData(); if( bCondValid && pMgr && pMgr->IsInMerge() && - pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand)) + pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand, sal_True)) { // Bedingug OK -> aktuellen Set einstellen pMgr->ToRecordId(Max((USHORT)aPar2.ToInt32(), USHORT(1))-1); } @@ -972,7 +972,7 @@ void SwDBSetNumberField::Evaluate(SwDoc* pDoc) return; const SwDBData& aTmpData = GetDBData(); - if(!pMgr || !pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand)) + if(!pMgr || !pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand, sal_False)) { nNumber = 0; return ; diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index f24b578ebe1e..f49145c265a8 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -2,9 +2,9 @@ * * $RCSfile: docufld.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: jp $ $Date: 2001-06-13 11:09:20 $ + * last change: $Author: os $ $Date: 2001-07-10 13:50:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1467,7 +1467,7 @@ void SwHiddenTxtField::Evaluate(SwDoc* pDoc) { String sDataSource(sDBName.GetToken(0, DB_DELIM)); String sDataTableOrQuery(sDBName.GetToken(1, DB_DELIM)); - if(pMgr && pMgr->IsDataSourceOpen(sDataSource, sDataTableOrQuery)) + if(pMgr && pMgr->IsDataSourceOpen(sDataSource, sDataTableOrQuery, sal_False)) { double fNumber; sal_uInt32 nFormat; diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 4e68aee31923..320196b1d6b3 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.36 $ + * $Revision: 1.37 $ * - * last change: $Author: os $ $Date: 2001-06-29 08:10:35 $ + * last change: $Author: os $ $Date: 2001-07-10 13:51:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1587,7 +1587,8 @@ void SwNewDBMgr::EndMerge() /* -----------------------------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) const +BOOL SwNewDBMgr::IsDataSourceOpen(const String& rDataSource, + const String& rTableOrQuery, sal_Bool bMergeOnly) { if(pMergeData) { @@ -1595,8 +1596,16 @@ BOOL SwNewDBMgr::IsDataSourceOpen(const String& rDataSource, const String& rT rTableOrQuery == (String)pMergeData->sCommand && pMergeData->xResultSet.is(); } - else - return FALSE; + 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; } /* -----------------------------17.07.00 16:44-------------------------------- read column data a a specified position @@ -1607,27 +1616,36 @@ BOOL SwNewDBMgr::GetColumnCnt(const String& rSourceName, const String& rTableNam String& rResult, double* pNumber) { BOOL bRet = FALSE; + SwDSParam* pFound = 0; //check if it's the merge data source if(pMergeData && rSourceName == (String)pMergeData->sDataSource && rTableName == (String)pMergeData->sCommand) { - if(!pMergeData->xResultSet.is()) - return FALSE; - //keep the old index - sal_Int32 nOldRow = pMergeData->xResultSet->getRow(); + pFound = pMergeData; + } + else + { + SwDBData aData; + aData.sDataSource = rSourceName; + aData.sCommand = rTableName; + aData.nCommandType = -1; + pFound = FindDSData(aData, FALSE); + } + if(pFound && pFound->xResultSet.is() && !pFound->bAfterSelection) + { + sal_Int32 nOldRow = pFound->xResultSet->getRow(); //position to the desired index - BOOL bMove; + BOOL bMove = TRUE; if(nOldRow != nAbsRecordId) - bMove = lcl_MoveAbsolute(pMergeData, nAbsRecordId); + bMove = lcl_MoveAbsolute(pFound, nAbsRecordId); if(bMove) { - bRet = lcl_GetColumnCnt(pMergeData, rColumnName, nLanguage, rResult, pNumber); + bRet = lcl_GetColumnCnt(pFound, rColumnName, nLanguage, rResult, pNumber); } if(nOldRow != nAbsRecordId) - bMove = lcl_MoveAbsolute(pMergeData, nOldRow); + bMove = lcl_MoveAbsolute(pFound, nOldRow); } - // return bRet; } /* -----------------------------06.07.00 16:47-------------------------------- @@ -1650,31 +1668,60 @@ BOOL SwNewDBMgr::GetMergeColumnCnt(const String& rColumnName, USHORT nLanguag ---------------------------------------------------------------------------*/ BOOL SwNewDBMgr::ToNextMergeRecord() { - BOOL bRet = TRUE; DBG_ASSERT(pMergeData && pMergeData->xResultSet.is(), "no data source in merge") - if(!pMergeData || !pMergeData->xResultSet.is() || pMergeData->bEndOfDB) + return ToNextRecord(pMergeData); +} +/* -----------------------------10.07.01 14:28-------------------------------- + + ---------------------------------------------------------------------------*/ +BOOL SwNewDBMgr::ToNextRecord( + const String& rDataSource, const String& rCommand, sal_Int32 nCommandType) +{ + SwDSParam* pFound = 0; + BOOL bRet = TRUE; + if(pMergeData && + rDataSource == (String)pMergeData->sDataSource && + rCommand == (String)pMergeData->sCommand) + pFound = pMergeData; + else { - if(pMergeData) - pMergeData->CheckEndOfDB(); + SwDBData aData; + aData.sDataSource = rDataSource; + aData.sCommand = rCommand; + aData.nCommandType = -1; + pFound = FindDSData(aData, FALSE); + } + return ToNextRecord(pFound); +} +/* -----------------------------10.07.01 14:38-------------------------------- + + ---------------------------------------------------------------------------*/ +BOOL SwNewDBMgr::ToNextRecord(SwDSParam* pParam) +{ + BOOL bRet = TRUE; + if(!pParam || !pParam->xResultSet.is() || pParam->bEndOfDB) + { + if(pParam) + pParam->CheckEndOfDB(); return FALSE; } try { - if(pMergeData->aSelection.getLength()) + if(pParam->aSelection.getLength()) { - pMergeData->bEndOfDB = !pMergeData->xResultSet->absolute( - (ULONG)pMergeData->aSelection.getConstArray()[ pMergeData->nSelectionIndex++ ] ); - pMergeData->CheckEndOfDB(); - bRet = !pMergeData->bEndOfDB; - if(pMergeData->nSelectionIndex >= pMergeData->aSelection.getLength()) - pMergeData->bEndOfDB = TRUE; + pParam->bEndOfDB = !pParam->xResultSet->absolute( + (ULONG)pParam->aSelection.getConstArray()[ pParam->nSelectionIndex++ ] ); + pParam->CheckEndOfDB(); + bRet = !pParam->bEndOfDB; + if(pParam->nSelectionIndex >= pParam->aSelection.getLength()) + pParam->bEndOfDB = TRUE; } else { - pMergeData->bEndOfDB = !pMergeData->xResultSet->next(); - pMergeData->CheckEndOfDB(); - bRet = !pMergeData->bEndOfDB; - ++pMergeData->nSelectionIndex; + pParam->bEndOfDB = !pParam->xResultSet->next(); + pParam->CheckEndOfDB(); + bRet = !pParam->bEndOfDB; + ++pParam->nSelectionIndex; } } catch(Exception&) @@ -1683,6 +1730,7 @@ BOOL SwNewDBMgr::ToNextMergeRecord() } return bRet; } + /* -----------------------------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 @@ -1774,6 +1822,7 @@ BOOL SwNewDBMgr::OpenDataSource(const String& rDataSource, const String& rTableO //after executeQuery the cursor must be positioned pFound->bEndOfDB = !pFound->xResultSet->next(); + pFound->bAfterSelection = sal_False; pFound->CheckEndOfDB(); ++pFound->nSelectionIndex; } |