during (writing a test case for) #i105235#: queryFieldData should also work on the insertion row

This commit is contained in:
Frank Schoenheit [fs] 2009-11-05 14:30:27 +01:00
parent f175a7d39c
commit 616109598f
4 changed files with 63 additions and 63 deletions

View file

@ -31,13 +31,8 @@
#define _SVX_FMGRIDCL_HXX
#include <com/sun/star/container/XIndexContainer.hpp>
#ifndef _COM_SUN_STAR_FORM_XINDEXCONTAINER_HPP_
#include <com/sun/star/container/XIndexContainer.hpp>
#endif
#include <com/sun/star/container/XNameContainer.hpp>
// alles nur fuer stl
#include <svx/gridctrl.hxx>
#include <svtools/transfer.hxx>
#include "svx/svxdllapi.h"

View file

@ -584,9 +584,10 @@ protected:
sal_Int32 GetSeekPos() const {return m_nSeekPos;}
sal_Int32 GetTotalCount() const {return m_nTotalCount;}
const DbGridRowRef& GetEmptyRow() const {return m_xEmptyRow;}
const DbGridRowRef& GetSeekRow() const {return m_xSeekRow;}
CursorWrapper* GetSeekCursor() const {return m_pSeekCursor;}
const DbGridRowRef& GetEmptyRow() const { return m_xEmptyRow; }
const DbGridRowRef& GetSeekRow() const { return m_xSeekRow; }
const DbGridRowRef& GetPaintRow() const { return m_xPaintRow; }
CursorWrapper* GetSeekCursor() const { return m_pSeekCursor; }
void ConnectToFields();
void DisconnectFromFields();

View file

@ -69,6 +69,7 @@
using namespace ::svxform;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::view;
@ -1393,8 +1394,8 @@ Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type
// don't use GetCurrentRow as this isn't affected by the above SeekRow
// FS - 30.09.99 - 68644
DbGridRowRef aRow = pGrid->GetSeekRow();
DBG_ASSERT(aRow.Is(), "FmXGridPeer::queryFieldData : invalid current Row !");
DbGridRowRef xPaintRow = pGrid->GetPaintRow();
ENSURE_OR_THROW( xPaintRow.Is(), "invalid paint row" );
// die Columns des Controls brauche ich fuer GetFieldText
DbGridColumns aColumns = pGrid->GetColumns();
@ -1416,39 +1417,40 @@ Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type
// don't use GetCurrentFieldValue to determine the field content as this isn't affected by the above SeekRow
// FS - 30.09.99 - 68644
pCol = aColumns.GetObject(nModelPos);
const DbGridRowRef xRow = pGrid->GetSeekRow();
xFieldContent = (xRow.Is() && xRow->HasField(pCol->GetFieldPos())) ? xRow->GetField(pCol->GetFieldPos()).getColumn() : Reference< ::com::sun::star::sdb::XColumn > ();
xFieldContent = xPaintRow->HasField( pCol->GetFieldPos() )
? xPaintRow->GetField( pCol->GetFieldPos() ).getColumn()
: Reference< XColumn > ();
if (xFieldContent.is())
if ( !xFieldContent.is() )
continue;
if (bRequestedAsAny)
{
if (bRequestedAsAny)
Reference< XPropertySet > xFieldSet(xFieldContent, UNO_QUERY);
pReturnArray[i] = xFieldSet->getPropertyValue(FM_PROP_VALUE);
}
else
{
switch (xType.getTypeClass())
{
Reference< XPropertySet > xFieldSet(xFieldContent, UNO_QUERY);
pReturnArray[i] = xFieldSet->getPropertyValue(FM_PROP_VALUE);
}
else
{
switch (xType.getTypeClass())
// Strings werden direkt ueber das GetFieldText abgehandelt
case TypeClass_STRING :
{
// Strings werden direkt ueber das GetFieldText abgehandelt
case TypeClass_STRING :
{
String sText = aColumns.GetObject(nModelPos)->GetCellText(aRow, pGrid->getNumberFormatter());
pReturnArray[i] <<= ::rtl::OUString(sText);
}
break;
// alles andere wird an der DatabaseVariant erfragt
case TypeClass_FLOAT : pReturnArray[i] <<= xFieldContent->getFloat(); break;
case TypeClass_DOUBLE : pReturnArray[i] <<= xFieldContent->getDouble(); break;
case TypeClass_SHORT : pReturnArray[i] <<= (sal_Int16)xFieldContent->getShort(); break;
case TypeClass_LONG : pReturnArray[i] <<= (sal_Int32)xFieldContent->getLong(); break;
case TypeClass_UNSIGNED_SHORT: pReturnArray[i] <<= (sal_uInt16)xFieldContent->getShort(); break;
case TypeClass_UNSIGNED_LONG : pReturnArray[i] <<= (sal_uInt32)xFieldContent->getLong(); break;
case TypeClass_BOOLEAN : ::comphelper::setBOOL(pReturnArray[i],xFieldContent->getBoolean()); break;
default:
{
throw IllegalArgumentException();
}
String sText = aColumns.GetObject(nModelPos)->GetCellText( xPaintRow, pGrid->getNumberFormatter() );
pReturnArray[i] <<= ::rtl::OUString(sText);
}
break;
// alles andere wird an der DatabaseVariant erfragt
case TypeClass_FLOAT : pReturnArray[i] <<= xFieldContent->getFloat(); break;
case TypeClass_DOUBLE : pReturnArray[i] <<= xFieldContent->getDouble(); break;
case TypeClass_SHORT : pReturnArray[i] <<= (sal_Int16)xFieldContent->getShort(); break;
case TypeClass_LONG : pReturnArray[i] <<= (sal_Int32)xFieldContent->getLong(); break;
case TypeClass_UNSIGNED_SHORT : pReturnArray[i] <<= (sal_uInt16)xFieldContent->getShort(); break;
case TypeClass_UNSIGNED_LONG : pReturnArray[i] <<= (sal_uInt32)xFieldContent->getLong(); break;
case TypeClass_BOOLEAN : ::comphelper::setBOOL(pReturnArray[i],xFieldContent->getBoolean()); break;
default:
{
throw IllegalArgumentException();
}
}
}

View file

@ -868,7 +868,7 @@ void DbGridRow::SetState(CursorWrapper* pCur, sal_Bool bPaintCursor)
}
catch(SQLException&)
{
OSL_ENSURE(0,"SQLException catched while getting the bookmark");
DBG_UNHANDLED_EXCEPTION();
m_aBookmark = Any();
m_eStatus = GRS_INVALID;
m_bIsNew = sal_False;
@ -1786,30 +1786,32 @@ void DbGridControl::ColumnMoved(sal_uInt16 nId)
sal_Bool DbGridControl::SeekRow(long nRow)
{
// in filter mode or in insert only mode we don't have any cursor!
if (SeekCursor(nRow))
if ( !SeekCursor( nRow ) )
return sal_False;
if ( IsFilterMode() )
{
if (m_pSeekCursor)
{
// on the current position we have to take the current row for display as we want
// to have the most recent values for display
if ((nRow == m_nCurrentPos) && getDisplaySynchron())
m_xPaintRow = m_xCurrentRow;
// seek to the empty insert row
else if (IsInsertionRow(nRow))
m_xPaintRow = m_xEmptyRow;
else
{
m_xSeekRow->SetState(m_pSeekCursor, sal_True);
m_xPaintRow = m_xSeekRow;
}
}
else if (IsFilterMode())
{
DBG_ASSERT(IsFilterRow(nRow), "DbGridControl::SeekRow(): No filter row, wrong mode");
m_xPaintRow = m_xEmptyRow;
}
DbGridControl_Base::SeekRow(nRow);
DBG_ASSERT( IsFilterRow( nRow ), "DbGridControl::SeekRow(): No filter row, wrong mode" );
m_xPaintRow = m_xEmptyRow;
}
else
{
// on the current position we have to take the current row for display as we want
// to have the most recent values for display
if ( ( nRow == m_nCurrentPos ) && getDisplaySynchron() )
m_xPaintRow = m_xCurrentRow;
// seek to the empty insert row
else if ( IsInsertionRow( nRow ) )
m_xPaintRow = m_xEmptyRow;
else
{
m_xSeekRow->SetState( m_pSeekCursor, sal_True );
m_xPaintRow = m_xSeekRow;
}
}
DbGridControl_Base::SeekRow(nRow);
return m_nSeekPos >= 0;
}
//------------------------------------------------------------------------------
@ -2381,7 +2383,7 @@ sal_Bool DbGridControl::SeekCursor(long nRow, sal_Bool bAbsolute)
// da der letzte Datensatz bereits erreicht wurde!
if (nRow == m_nCurrentPos)
{
// auf die aktuelle Zeile bewegt, dann mu<EFBFBD> kein abgleich gemacht werden, wenn
// auf die aktuelle Zeile bewegt, dann muß kein abgleich gemacht werden, wenn
// gerade ein Datensatz eingefuegt wird
m_nSeekPos = nRow;
}