dbaccess/source/core/api/CRowSetColumn.cxx | 10 ++++-- dbaccess/source/core/api/CRowSetColumn.hxx | 2 - dbaccess/source/core/api/CRowSetDataColumn.cxx | 38 +++++++++++-------------- dbaccess/source/core/api/CRowSetDataColumn.hxx | 7 ++-- dbaccess/source/core/api/RowSet.cxx | 7 ++-- 5 files changed, 34 insertions(+), 30 deletions(-)
New commits: commit 3dc29ff5846160060587d41f22868486ffd4e96e Author: Lionel Elie Mamane <[email protected]> Date: Wed Aug 6 15:17:13 2014 +0200 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. Functional squelch of the following master commits: Change-Id: Ib9188743e5dd6dec240e9f5fd3fd9655c6761abc commit id: 03a2b4a80c5854bcb8520f2a43e485b98e3eba8f Change-Id: I527cc35ae120cf083f7c69a9a23526839a2bbddb commit id: 90b09303ef4f9163428107be7b8db23022ce10b7 Change-Id: If813a1544ec9a5dac6f87197982d10576c91cd8c commit id: 5be4407d0716f78acdcdf24de135af91f17e51be + keep older behaviour of confusing no value and null value. Change-Id: Ib9188743e5dd6dec240e9f5fd3fd9655c6761abc Reviewed-on: https://gerrit.libreoffice.org/10796 Reviewed-by: David Tardon <[email protected]> Tested-by: David Tardon <[email protected]> diff --git a/dbaccess/source/core/api/CRowSetColumn.cxx b/dbaccess/source/core/api/CRowSetColumn.cxx index 945b15f..adc3d38 100644 --- a/dbaccess/source/core/api/CRowSetColumn.cxx +++ b/dbaccess/source/core/api/CRowSetColumn.cxx @@ -36,9 +36,13 @@ using namespace ::com::sun::star::beans; namespace dbaccess { -ORowSetColumn::ORowSetColumn( const Reference < XResultSetMetaData >& _xMetaData, const Reference < XRow >& _xRow, sal_Int32 _nPos, - const Reference< XDatabaseMetaData >& _rxDBMeta, const OUString& _rDescription, const OUString& i_sLabel,ORowSetCacheIterator& _rColumnValue ) - :ORowSetDataColumn( _xMetaData, _xRow, NULL, _nPos, _rxDBMeta, _rDescription, i_sLabel,_rColumnValue ) +ORowSetColumn::ORowSetColumn( const Reference < XResultSetMetaData >& _xMetaData, + const Reference < XRow >& _xRow, sal_Int32 _nPos, + 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 ) { } diff --git a/dbaccess/source/core/api/CRowSetColumn.hxx b/dbaccess/source/core/api/CRowSetColumn.hxx index bba7c7d..0c4ec82 100644 --- a/dbaccess/source/core/api/CRowSetColumn.hxx +++ b/dbaccess/source/core/api/CRowSetColumn.hxx @@ -38,7 +38,7 @@ namespace dbaccess const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta, const OUString& _rDescription, 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& SAL_CALL getInfoHelper() SAL_OVERRIDE; diff --git a/dbaccess/source/core/api/CRowSetDataColumn.cxx b/dbaccess/source/core/api/CRowSetDataColumn.cxx index f0de794..3f2901d 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.cxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.cxx @@ -24,6 +24,7 @@ #include <comphelper/types.hxx> #include <cppuhelper/typeprovider.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <tools/debug.hxx> using namespace dbaccess; @@ -39,16 +40,16 @@ using namespace cppu; using namespace osl; -ORowSetDataColumn::ORowSetDataColumn( const Reference < XResultSetMetaData >& _xMetaData, +ORowSetDataColumn::ORowSetDataColumn( const Reference < XResultSetMetaData >& _xMetaData, const Reference < XRow >& _xRow, const Reference < XRowUpdate >& _xRowUpdate, sal_Int32 _nPos, const Reference< XDatabaseMetaData >& _rxDBMeta, const OUString& _rDescription, const OUString& i_sLabel, - const ORowSetCacheIterator& _rColumnValue) + const boost::function< const ORowSetValue& (sal_Int32)> &_getValue) :ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta) - ,m_aColumnValue(_rColumnValue) + ,m_pGetValue(_getValue) ,m_sLabel(i_sLabel) ,m_aDescription(_rDescription) { @@ -105,15 +106,12 @@ void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nH { if ( PROPERTY_ID_VALUE == nHandle ) { - if ( !m_aColumnValue.isNull() && m_aColumnValue->is() ) + try + { + rValue = m_pGetValue(m_nPos).makeAny(); + } + catch(const SQLException &e) { - ::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() ) @@ -179,19 +177,19 @@ Sequence< sal_Int8 > ORowSetDataColumn::getImplementationId() throw (RuntimeExce void ORowSetDataColumn::fireValueChange(const ORowSetValue& _rOldValue) { - if ( !m_aColumnValue.isNull() && m_aColumnValue->is() && (((*m_aColumnValue)->get())[m_nPos] != _rOldValue) ) + ORowSetValue value; + try + { + value = m_pGetValue(m_nPos); + } + catch(const SQLException &e) { - sal_Int32 nHandle = PROPERTY_ID_VALUE; - m_aOldValue = _rOldValue.makeAny(); - Any aNew = ((*m_aColumnValue)->get())[m_nPos].makeAny(); - - fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False ); } - else if ( !m_aColumnValue.isNull() && !_rOldValue.isNull() ) + if ( value != _rOldValue) { - sal_Int32 nHandle = PROPERTY_ID_VALUE; + sal_Int32 nHandle(PROPERTY_ID_VALUE); m_aOldValue = _rOldValue.makeAny(); - Any aNew; + Any aNew = value.makeAny(); fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False ); } diff --git a/dbaccess/source/core/api/CRowSetDataColumn.hxx b/dbaccess/source/core/api/CRowSetDataColumn.hxx index bd6e641..5483f16 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.hxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.hxx @@ -21,12 +21,13 @@ #include "datacolumn.hxx" #include "RowSetRow.hxx" -#include "RowSetCacheIterator.hxx" #include "columnsettings.hxx" #include <connectivity/CommonTools.hxx> #include <comphelper/proparrhlp.hxx> +#include <boost/function.hpp> + namespace dbaccess { class ORowSetDataColumn; @@ -37,7 +38,7 @@ namespace dbaccess public ORowSetDataColumn_PROP { protected: - ORowSetCacheIterator m_aColumnValue; + const boost::function< const ::connectivity::ORowSetValue& ( sal_Int32 ) > m_pGetValue; ::com::sun::star::uno::Any m_aOldValue; OUString m_sLabel; @@ -52,7 +53,7 @@ namespace dbaccess const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta, const OUString& _rDescription, const OUString& i_sLabel, - const ORowSetCacheIterator& _rColumnValue); + const boost::function< const ::connectivity::ORowSetValue& ( sal_Int32 ) > &_getValue); // com::sun::star::lang::XTypeProvider diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index d4795ee..216e2da 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -21,6 +21,7 @@ #include <map> #include <utility> +#include <boost/bind.hpp> #include <string.h> #include "RowSet.hxx" @@ -1876,7 +1877,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi m_xActiveConnection->getMetaData(), aDescription, OUString(), - m_aCurrentRow); + boost::bind(&ORowSet::getInsertValue, this, _1)); aColumnMap.insert(std::make_pair(sName,0)); aColumns->get().push_back(pColumn); pColumn->setName(sName); @@ -1978,7 +1979,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi m_xActiveConnection->getMetaData(), aDescription, sParseLabel, - m_aCurrentRow); + boost::bind(&ORowSet::getInsertValue, this, _1)); aColumns->get().push_back(pColumn); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i) != rKeyColumns.end())); @@ -2810,7 +2811,7 @@ ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowS rParent.m_xActiveConnection->getMetaData(), aDescription, sParseLabel, - m_aCurrentRow); + boost::bind(&ORowSetClone::getValue, this, _1)); aColumns->get().push_back(pColumn); pColumn->setName(*pIter); aNames.push_back(*pIter); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
