Kaydet (Commit) 03a2b4a8 authored tarafından Lionel Elie Mamane's avatar Lionel Elie Mamane

fdo#82151 when constructing column object, replace m_aCurrentRow by a function

The passed m_aCurrentRow becomes out-of-date as soon as the current row changes.
This also hides an implementation detail of ORowSet to ORowSet(Data)Column.

Change-Id: Ib9188743e5dd6dec240e9f5fd3fd9655c6761abc
Reviewed-on: https://gerrit.libreoffice.org/10792Reviewed-by: 's avatarLionel Elie Mamane <lionel@mamane.lu>
Tested-by: 's avatarLionel Elie Mamane <lionel@mamane.lu>
üst 1e1b2c56
...@@ -36,9 +36,13 @@ using namespace ::com::sun::star::beans; ...@@ -36,9 +36,13 @@ using namespace ::com::sun::star::beans;
namespace dbaccess namespace dbaccess
{ {
ORowSetColumn::ORowSetColumn( const Reference < XResultSetMetaData >& _xMetaData, const Reference < XRow >& _xRow, sal_Int32 _nPos, ORowSetColumn::ORowSetColumn( const Reference < XResultSetMetaData >& _xMetaData,
const Reference< XDatabaseMetaData >& _rxDBMeta, const OUString& _rDescription, const OUString& i_sLabel,ORowSetCacheIterator& _rColumnValue ) const Reference < XRow >& _xRow, sal_Int32 _nPos,
:ORowSetDataColumn( _xMetaData, _xRow, NULL, _nPos, _rxDBMeta, _rDescription, i_sLabel,_rColumnValue ) const Reference< XDatabaseMetaData >& _rxDBMeta,
const OUString& _rDescription,
const OUString& i_sLabel,
const boost::function< const ::connectivity::ORowSetValue& ( sal_Int32 ) > &_getValue )
:ORowSetDataColumn( _xMetaData, _xRow, NULL, _nPos, _rxDBMeta, _rDescription, i_sLabel, _getValue )
{ {
} }
......
...@@ -38,7 +38,7 @@ namespace dbaccess ...@@ -38,7 +38,7 @@ namespace dbaccess
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta,
const OUString& _rDescription, const OUString& _rDescription,
const OUString& i_sLabel, const OUString& i_sLabel,
ORowSetCacheIterator& _rColumnValue); const boost::function< const ::connectivity::ORowSetValue& ( sal_Int32 ) > &_getValue);
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE; virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE; virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
......
...@@ -39,16 +39,16 @@ using namespace cppu; ...@@ -39,16 +39,16 @@ using namespace cppu;
using namespace osl; using namespace osl;
ORowSetDataColumn::ORowSetDataColumn( const Reference < XResultSetMetaData >& _xMetaData, ORowSetDataColumn::ORowSetDataColumn( const Reference < XResultSetMetaData >& _xMetaData,
const Reference < XRow >& _xRow, const Reference < XRow >& _xRow,
const Reference < XRowUpdate >& _xRowUpdate, const Reference < XRowUpdate >& _xRowUpdate,
sal_Int32 _nPos, sal_Int32 _nPos,
const Reference< XDatabaseMetaData >& _rxDBMeta, const Reference< XDatabaseMetaData >& _rxDBMeta,
const OUString& _rDescription, const OUString& _rDescription,
const OUString& i_sLabel, const OUString& i_sLabel,
const ORowSetCacheIterator& _rColumnValue) const boost::function< const ORowSetValue& (sal_Int32)> &_getValue)
:ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta) :ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta)
,m_aColumnValue(_rColumnValue) ,m_pGetValue(_getValue)
,m_sLabel(i_sLabel) ,m_sLabel(i_sLabel)
,m_aDescription(_rDescription) ,m_aDescription(_rDescription)
{ {
...@@ -105,16 +105,7 @@ void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nH ...@@ -105,16 +105,7 @@ void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nH
{ {
if ( PROPERTY_ID_VALUE == nHandle ) if ( PROPERTY_ID_VALUE == nHandle )
{ {
if ( !m_aColumnValue.isNull() && m_aColumnValue->is() ) rValue = m_pGetValue(m_nPos).makeAny();
{
::osl::Mutex* pMutex = m_aColumnValue.getMutex();
::osl::MutexGuard aGuard( *pMutex );
#if OSL_DEBUG_LEVEL > 0
ORowSetRow aRow = *m_aColumnValue;
#endif
OSL_ENSURE((sal_Int32)aRow->get().size() > m_nPos,"Pos is greater than size of vector");
rValue = ((*m_aColumnValue)->get())[m_nPos].makeAny();
}
} }
else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() ) else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() )
rValue <<= m_sLabel; rValue <<= m_sLabel;
...@@ -179,19 +170,12 @@ Sequence< sal_Int8 > ORowSetDataColumn::getImplementationId() throw (RuntimeExce ...@@ -179,19 +170,12 @@ Sequence< sal_Int8 > ORowSetDataColumn::getImplementationId() throw (RuntimeExce
void ORowSetDataColumn::fireValueChange(const ORowSetValue& _rOldValue) void ORowSetDataColumn::fireValueChange(const ORowSetValue& _rOldValue)
{ {
if ( !m_aColumnValue.isNull() && m_aColumnValue->is() && (((*m_aColumnValue)->get())[m_nPos] != _rOldValue) ) const ORowSetValue &value(m_pGetValue(m_nPos));
if ( value != _rOldValue)
{ {
sal_Int32 nHandle = PROPERTY_ID_VALUE; sal_Int32 nHandle(PROPERTY_ID_VALUE);
m_aOldValue = _rOldValue.makeAny(); m_aOldValue = _rOldValue.makeAny();
Any aNew = ((*m_aColumnValue)->get())[m_nPos].makeAny(); Any aNew = value.makeAny();
fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
}
else if ( !m_aColumnValue.isNull() && !_rOldValue.isNull() )
{
sal_Int32 nHandle = PROPERTY_ID_VALUE;
m_aOldValue = _rOldValue.makeAny();
Any aNew;
fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False ); fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
} }
......
...@@ -21,12 +21,13 @@ ...@@ -21,12 +21,13 @@
#include "datacolumn.hxx" #include "datacolumn.hxx"
#include "RowSetRow.hxx" #include "RowSetRow.hxx"
#include "RowSetCacheIterator.hxx"
#include "columnsettings.hxx" #include "columnsettings.hxx"
#include <connectivity/CommonTools.hxx> #include <connectivity/CommonTools.hxx>
#include <comphelper/proparrhlp.hxx> #include <comphelper/proparrhlp.hxx>
#include <boost/function.hpp>
namespace dbaccess namespace dbaccess
{ {
class ORowSetDataColumn; class ORowSetDataColumn;
...@@ -37,7 +38,7 @@ namespace dbaccess ...@@ -37,7 +38,7 @@ namespace dbaccess
public ORowSetDataColumn_PROP public ORowSetDataColumn_PROP
{ {
protected: protected:
ORowSetCacheIterator m_aColumnValue; const boost::function< const ::connectivity::ORowSetValue& ( sal_Int32 ) > m_pGetValue;
::com::sun::star::uno::Any m_aOldValue; ::com::sun::star::uno::Any m_aOldValue;
OUString m_sLabel; OUString m_sLabel;
...@@ -52,7 +53,7 @@ namespace dbaccess ...@@ -52,7 +53,7 @@ namespace dbaccess
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta,
const OUString& _rDescription, const OUString& _rDescription,
const OUString& i_sLabel, const OUString& i_sLabel,
const ORowSetCacheIterator& _rColumnValue); const boost::function< const ::connectivity::ORowSetValue& ( sal_Int32 ) > &_getValue);
// com::sun::star::lang::XTypeProvider // com::sun::star::lang::XTypeProvider
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <map> #include <map>
#include <utility> #include <utility>
#include <boost/bind.hpp>
#include <string.h> #include <string.h>
#include "RowSet.hxx" #include "RowSet.hxx"
...@@ -1876,7 +1877,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi ...@@ -1876,7 +1877,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi
m_xActiveConnection->getMetaData(), m_xActiveConnection->getMetaData(),
aDescription, aDescription,
OUString(), OUString(),
m_aCurrentRow); boost::bind(&ORowSet::getInsertValue, this, _1));
aColumnMap.insert(std::make_pair(sName,0)); aColumnMap.insert(std::make_pair(sName,0));
aColumns->get().push_back(pColumn); aColumns->get().push_back(pColumn);
pColumn->setName(sName); pColumn->setName(sName);
...@@ -1978,7 +1979,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi ...@@ -1978,7 +1979,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi
m_xActiveConnection->getMetaData(), m_xActiveConnection->getMetaData(),
aDescription, aDescription,
sParseLabel, sParseLabel,
m_aCurrentRow); boost::bind(&ORowSet::getInsertValue, this, _1));
aColumns->get().push_back(pColumn); aColumns->get().push_back(pColumn);
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i) != rKeyColumns.end())); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i) != rKeyColumns.end()));
...@@ -2810,7 +2811,7 @@ ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowS ...@@ -2810,7 +2811,7 @@ ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowS
rParent.m_xActiveConnection->getMetaData(), rParent.m_xActiveConnection->getMetaData(),
aDescription, aDescription,
sParseLabel, sParseLabel,
m_aCurrentRow); boost::bind(&ORowSetClone::getValue, this, _1));
aColumns->get().push_back(pColumn); aColumns->get().push_back(pColumn);
pColumn->setName(*pIter); pColumn->setName(*pIter);
aNames.push_back(*pIter); aNames.push_back(*pIter);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment