[Libreoffice-commits] core.git: dbaccess/source

Lionel Elie Mamane lionel at mamane.lu
Wed Aug 6 06:49:51 PDT 2014


 dbaccess/source/core/api/CRowSetColumn.cxx     |   10 +++++--
 dbaccess/source/core/api/CRowSetColumn.hxx     |    2 -
 dbaccess/source/core/api/CRowSetDataColumn.cxx |   32 ++++++-------------------
 dbaccess/source/core/api/CRowSetDataColumn.hxx |    7 +++--
 dbaccess/source/core/api/RowSet.cxx            |    7 +++--
 5 files changed, 24 insertions(+), 34 deletions(-)

New commits:
commit 03a2b4a80c5854bcb8520f2a43e485b98e3eba8f
Author: Lionel Elie Mamane <lionel at mamane.lu>
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.
    
    Change-Id: Ib9188743e5dd6dec240e9f5fd3fd9655c6761abc
    Reviewed-on: https://gerrit.libreoffice.org/10792
    Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>
    Tested-by: Lionel Elie Mamane <lionel at mamane.lu>

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..a047725 100644
--- a/dbaccess/source/core/api/CRowSetDataColumn.cxx
+++ b/dbaccess/source/core/api/CRowSetDataColumn.cxx
@@ -39,16 +39,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,16 +105,7 @@ void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nH
 {
     if ( PROPERTY_ID_VALUE == nHandle )
     {
-        if ( !m_aColumnValue.isNull() && m_aColumnValue->is() )
-        {
-            ::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();
-        }
+        rValue = m_pGetValue(m_nPos).makeAny();
     }
     else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() )
         rValue <<= m_sLabel;
@@ -179,19 +170,12 @@ 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) )
+    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();
-        Any aNew = ((*m_aColumnValue)->get())[m_nPos].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;
+        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 388e153..5912aa9 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);


More information about the Libreoffice-commits mailing list