connectivity/source/drivers/dbase/DTable.cxx | 16 ++++++++-------- connectivity/source/inc/dbase/DTable.hxx | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-)
New commits: commit 7f21b800ad6d92255667f57dc4b9ccb747e57a07 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Thu Oct 25 11:16:24 2012 +0200 fdo#52392 dbase: correctly NULL out non-filled in fields in inserted rows Change-Id: Id2e8ad5b6bed1c184de6dccf7fa43254099fb958 Reviewed-on: https://gerrit.libreoffice.org/923 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 18d531e..3add204 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -1513,7 +1513,7 @@ sal_Bool ODbaseTable::InsertRow(OValueRefVector& rRow, sal_Bool bFlush,const Ref sal_uInt32 nTempPos = m_nFilePos; m_nFilePos = (sal_uIntPtr)m_aHeader.db_anz + 1; - sal_Bool bInsertRow = UpdateBuffer( rRow, NULL, _xCols ); + sal_Bool bInsertRow = UpdateBuffer( rRow, NULL, _xCols, true ); if ( bInsertRow ) { sal_uInt32 nFileSize = 0, nMemoFileSize = 0; @@ -1575,7 +1575,7 @@ sal_Bool ODbaseTable::UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,con m_pMemoStream->Seek(STREAM_SEEK_TO_END); nMemoFileSize = m_pMemoStream->Tell(); } - if (!UpdateBuffer(rRow, pOrgRow,_xCols) || !WriteBuffer()) + if (!UpdateBuffer(rRow, pOrgRow, _xCols, false) || !WriteBuffer()) { if (HasMemoFields() && m_pMemoStream) m_pMemoStream->SetStreamSize(nMemoFileSize); // restore old size @@ -1676,7 +1676,7 @@ static double toDouble(const rtl::OString& rString) } //------------------------------------------------------------------ -sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const Reference<XIndexAccess>& _xCols) +sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow, const Reference<XIndexAccess>& _xCols, const bool bForceAllFields) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "ocke.jans...@sun.com", "ODbaseTable::UpdateBuffer" ); OSL_ENSURE(m_pBuffer,"Buffer is NULL!"); @@ -1822,10 +1822,10 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c ++nPos; // the row values start at 1 - // If the variable is bound at all? - if ( !rRow.get()[nPos]->isBound() ) + // don't overwrite non-bound columns + if ( ! (bForceAllFields || rRow.get()[nPos]->isBound()) ) { - // No - the next field. + // No - don't overwrite this field, it has not changed. nByteOffset += nLen; continue; } @@ -1836,14 +1836,14 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) ); OSL_ENSURE(pIndex,"ODbaseTable::UpdateBuffer: No Index returned!"); // Update !! - if (pOrgRow.is() && !rRow.get()[nPos]->getValue().isNull() ) + if (pOrgRow.is() && rRow.get()[nPos]->isBound() && !rRow.get()[nPos]->getValue().isNull() ) pIndex->Update(m_nFilePos,*(pOrgRow->get())[nPos],*rRow.get()[nPos]); else pIndex->Insert(m_nFilePos,*rRow.get()[nPos]); } char* pData = (char *)(m_pBuffer + nByteOffset); - if (rRow.get()[nPos]->getValue().isNull()) + if (rRow.get()[nPos]->getValue().isNull() || !rRow.get()[nPos]->isBound()) { if ( bSetZero ) memset(pData,0,nLen); // Clear to NULL diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx index 6ee8364..ec31dbc 100644 --- a/connectivity/source/inc/dbase/DTable.hxx +++ b/connectivity/source/inc/dbase/DTable.hxx @@ -116,7 +116,7 @@ namespace connectivity sal_Bool WriteMemo(ORowSetValue& aVariable, sal_uIntPtr& rBlockNr); sal_Bool WriteBuffer(); - sal_Bool UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols); + sal_Bool UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols, bool bForceAllFields); ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> isUniqueByColumnName(sal_Int32 _nColumnPos); void AllocBuffer();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits