[Libreoffice-commits] core.git: 3 commits - connectivity/source

Andrzej J.R. Hunt andrzej at ahunt.org
Mon Aug 26 11:05:14 PDT 2013


 connectivity/source/drivers/firebird/PreparedStatement.cxx |    4 
 connectivity/source/drivers/firebird/ResultSet.cxx         |  144 +++----------
 connectivity/source/drivers/firebird/ResultSet.hxx         |   48 +---
 3 files changed, 63 insertions(+), 133 deletions(-)

New commits:
commit 3b228541290b6d6b8ef390b941f812abc280d438
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Mon Aug 26 18:43:16 2013 +0100

    Quick hack to make driver usable with dbaccess/KeySet. (firebird-sdbc)
    
    Change-Id: I6500a7666ad2fc2ffcb29934d6f2b36761867950

diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index 9f4637a..7645748 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -307,7 +307,9 @@ sal_Int32 SAL_CALL OPreparedStatement::executeUpdate()
 {
     execute();
     // TODO: get the number of rows changed -- look in Statement::executeUpdate for details
-    return 0;
+    // 1 is a temporary hack so that things like dbaccess's keyset which rely
+    // on the value work correctly.
+    return 1;
 }
 
 Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery()
commit b3b560e29514616382d687cb95d6fe7632c223b3
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Fri Aug 23 19:42:55 2013 +0100

    Clean up PropertyHelper stuff, set ResultSet properties. (firebird-sdbc)
    
    Change-Id: If2f2041b0f072f36fe56e92b9e54bbb0be8a5860

diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx
index 237d569..2afd1a4 100644
--- a/connectivity/source/drivers/firebird/ResultSet.cxx
+++ b/connectivity/source/drivers/firebird/ResultSet.cxx
@@ -57,7 +57,7 @@ OResultSet::OResultSet(OConnection* pConnection,
                        isc_stmt_handle& aStatementHandle,
                        XSQLDA* pSqlda)
     : OResultSet_BASE(pConnection->getMutex())
-    , OPropertySetHelper(OResultSet_BASE::rBHelper)
+    , OPropertyContainer(OResultSet_BASE::rBHelper)
     , m_pConnection(pConnection)
     , m_xStatement(xStatement)
     , m_xMetaData(0)
@@ -69,6 +69,31 @@ OResultSet::OResultSet(OConnection* pConnection,
     , m_fieldCount(pSqlda? pSqlda->sqld : 0)
 {
     SAL_INFO("connectivity.firebird", "OResultSet().");
+    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE),
+                     PROPERTY_ID_ISBOOKMARKABLE,
+                     PropertyAttribute::READONLY,
+                     &m_bIsBookmarkable,
+                     ::getCppuType(&m_bIsBookmarkable));
+    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),
+                     PROPERTY_ID_FETCHSIZE,
+                     PropertyAttribute::READONLY,
+                     &m_nFetchSize,
+                     ::getCppuType(&m_nFetchSize));
+    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),
+                     PROPERTY_ID_RESULTSETTYPE,
+                     PropertyAttribute::READONLY,
+                     &m_nResultSetType,
+                     ::getCppuType(&m_nResultSetType));
+    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),
+                     PROPERTY_ID_FETCHDIRECTION,
+                     PropertyAttribute::READONLY,
+                     &m_nFetchDirection,
+                     ::getCppuType(&m_nFetchDirection));
+    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY),
+                     PROPERTY_ID_RESULTSETCONCURRENCY,
+                     PropertyAttribute::READONLY,
+                     &m_nResultSetConcurrency,
+                     ::getCppuType(&m_nResultSetConcurrency));
 
     if (!pSqlda)
         return; // TODO: what?
@@ -258,33 +283,16 @@ void SAL_CALL OResultSet::checkRowIndex()
         throw SQLException( "Row index is out of valid range.", *this, OUString(),1, Any() );
     }
 }
-// -------------------------------------------------------------------------
-void OResultSet::disposing(void)
-{
-
-    OPropertySetHelper::disposing();
-
-    MutexGuard aGuard(m_pConnection->getMutex());
 
-    m_xMetaData     = NULL;
-}
-// -------------------------------------------------------------------------
 Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
 {
     Any aRet = OPropertySetHelper::queryInterface(rType);
-    if(!aRet.hasValue())
-        aRet = OResultSet_BASE::queryInterface(rType);
-    return aRet;
+    return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType);
 }
-// -------------------------------------------------------------------------
- Sequence<  Type > SAL_CALL OResultSet::getTypes(  ) throw( RuntimeException)
-{
-    OTypeCollection aTypes(
-        ::cppu::UnoType< uno::Reference< ::com::sun::star::beans::XMultiPropertySet > >::get(),
-        ::cppu::UnoType< uno::Reference< ::com::sun::star::beans::XFastPropertySet > >::get(),
-        ::cppu::UnoType< uno::Reference< ::com::sun::star::beans::XPropertySet > >::get());
 
-    return concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
+ Sequence<  Type > SAL_CALL OResultSet::getTypes() throw( RuntimeException)
+{
+    return concatSequences(OPropertySetHelper::getTypes(), OResultSet_BASE::getTypes());
 }
 // ---- XColumnLocate ---------------------------------------------------------
 sal_Int32 SAL_CALL OResultSet::findColumn(const OUString& columnName)
@@ -637,94 +645,19 @@ void SAL_CALL OResultSet::refreshRow() throw(SQLException, RuntimeException)
                                                   *this,
                                                   Any());
 }
-// -------------------------------------------------------------------------
-IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
-{
-    Sequence< Property > aProps(6);
-    Property* pProperties = aProps.getArray();
-    sal_Int32 nPos = 0;
-    DECL_PROP1IMPL(CURSORNAME,          OUString) PropertyAttribute::READONLY);
-    DECL_PROP0(FETCHDIRECTION,          sal_Int32);
-    DECL_PROP0(FETCHSIZE,               sal_Int32);
-    DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
-    DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
-    DECL_PROP1IMPL(RESULTSETTYPE,       sal_Int32) PropertyAttribute::READONLY);
 
-    return new OPropertyArrayHelper(aProps);
+//----- OIdPropertyArrayUsageHelper ------------------------------------------
+IPropertyArrayHelper* OResultSet::createArrayHelper() const
+{
+    Sequence< Property > aProperties;
+    describeProperties(aProperties);
+    return new ::cppu::OPropertyArrayHelper(aProperties);
 }
-// -------------------------------------------------------------------------
+
 IPropertyArrayHelper & OResultSet::getInfoHelper()
 {
     return *const_cast<OResultSet*>(this)->getArrayHelper();
 }
-// -------------------------------------------------------------------------
-sal_Bool OResultSet::convertFastPropertyValue(
-                            Any & rConvertedValue,
-                            Any & rOldValue,
-                            sal_Int32 nHandle,
-                            const Any& rValue )
-                                throw (::com::sun::star::lang::IllegalArgumentException)
-{
-    (void) rConvertedValue;
-    (void) rOldValue;
-    (void) rValue;
-    switch(nHandle)
-    {
-        case PROPERTY_ID_ISBOOKMARKABLE:
-        case PROPERTY_ID_CURSORNAME:
-        case PROPERTY_ID_RESULTSETCONCURRENCY:
-        case PROPERTY_ID_RESULTSETTYPE:
-            throw ::com::sun::star::lang::IllegalArgumentException();
-            break;
-        case PROPERTY_ID_FETCHDIRECTION:
-        case PROPERTY_ID_FETCHSIZE:
-        default:
-            ;
-    }
-    return sal_False;
-}
-// -------------------------------------------------------------------------
-void OResultSet::setFastPropertyValue_NoBroadcast(
-                                sal_Int32 nHandle,
-                                const Any& rValue
-                                                 )
-                                                 throw (Exception)
-{
-    (void) rValue;
-    switch(nHandle)
-    {
-        case PROPERTY_ID_ISBOOKMARKABLE:
-        case PROPERTY_ID_CURSORNAME:
-        case PROPERTY_ID_RESULTSETCONCURRENCY:
-        case PROPERTY_ID_RESULTSETTYPE:
-            throw Exception();
-            break;
-        case PROPERTY_ID_FETCHDIRECTION:
-            break;
-        case PROPERTY_ID_FETCHSIZE:
-            break;
-        default:
-            ;
-    }
-}
-// -------------------------------------------------------------------------
-void OResultSet::getFastPropertyValue(
-                                Any& rValue,
-                                sal_Int32 nHandle
-                                     ) const
-{
-    (void) rValue;
-    switch(nHandle)
-    {
-        case PROPERTY_ID_ISBOOKMARKABLE:
-        case PROPERTY_ID_CURSORNAME:
-        case PROPERTY_ID_RESULTSETCONCURRENCY:
-        case PROPERTY_ID_RESULTSETTYPE:
-        case PROPERTY_ID_FETCHDIRECTION:
-        case PROPERTY_ID_FETCHSIZE:
-            ;
-    }
-}
 // -----------------------------------------------------------------------------
 void SAL_CALL OResultSet::acquire() throw()
 {
diff --git a/connectivity/source/drivers/firebird/ResultSet.hxx b/connectivity/source/drivers/firebird/ResultSet.hxx
index 68c59a1..e206ceb 100644
--- a/connectivity/source/drivers/firebird/ResultSet.hxx
+++ b/connectivity/source/drivers/firebird/ResultSet.hxx
@@ -26,8 +26,13 @@
 
 #include <connectivity/OSubComponent.hxx>
 #include <cppuhelper/compbase8.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
 
 #include <com/sun/star/util/XCancellable.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
 #include <com/sun/star/sdbc/XCloseable.hpp>
 #include <com/sun/star/sdbc/XColumnLocate.hpp>
 #include <com/sun/star/sdbc/XResultSet.hpp>
@@ -57,10 +62,17 @@ namespace connectivity
          * and ensure that the ResultSet is destroyed before disposing of the
          * SQLDA.
          */
-        class OResultSet :  public  OResultSet_BASE,
-                            public  ::cppu::OPropertySetHelper,
-                            public  OPropertyArrayUsageHelper<OResultSet>
+        class OResultSet: public OResultSet_BASE,
+                          public ::comphelper::OPropertyContainer,
+                          public  ::comphelper::OPropertyArrayUsageHelper<OResultSet>
         {
+        private:
+            sal_Bool m_bIsBookmarkable = sal_False;
+            sal_Int32 m_nFetchSize = 1;
+            sal_Int32 m_nResultSetType = ::com::sun::star::sdbc::ResultSetType::FORWARD_ONLY;
+            sal_Int32 m_nFetchDirection = ::com::sun::star::sdbc::FetchDirection::FORWARD;
+            sal_Int32 m_nResultSetConcurrency = ::com::sun::star::sdbc::ResultSetConcurrency::READ_ONLY;
+
         protected:
             OConnection* m_pConnection;
             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& m_xStatement;
@@ -84,27 +96,9 @@ namespace connectivity
             template <typename T> T safelyRetrieveValue(sal_Int32 columnIndex)
                 throw(::com::sun::star::sdbc::SQLException);
 
-            // OPropertyArrayUsageHelper
-            virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
-            // OPropertySetHelper
-            virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
-
-            virtual sal_Bool SAL_CALL convertFastPropertyValue(
-                                ::com::sun::star::uno::Any & rConvertedValue,
-                                ::com::sun::star::uno::Any & rOldValue,
-                                sal_Int32 nHandle,
-                                const ::com::sun::star::uno::Any& rValue )
-                                    throw (::com::sun::star::lang::IllegalArgumentException);
-            virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
-                                    sal_Int32 nHandle,
-                                    const ::com::sun::star::uno::Any& rValue
-                                     )
-                                     throw (::com::sun::star::uno::Exception);
-            using cppu::OPropertySetHelper::getFastPropertyValue;
-            virtual void SAL_CALL getFastPropertyValue(
-                                    ::com::sun::star::uno::Any& rValue,
-                                    sal_Int32 nHandle
-                                         ) const;
+            // OIdPropertyArrayUsageHelper
+            virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+            virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
 
             virtual void SAL_CALL checkColumnIndex( sal_Int32 index )
                 throw ( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException );
@@ -126,10 +120,10 @@ namespace connectivity
                 return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(OResultSet_BASE*)this);
             }
 
-            // ::cppu::OComponentHelper
-            virtual void SAL_CALL disposing(void);
             // XInterface
-            virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+            virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+                    const ::com::sun::star::uno::Type& rType)
+                throw (::com::sun::star::uno::RuntimeException);
             virtual void SAL_CALL acquire() throw();
             virtual void SAL_CALL release() throw();
             //XTypeProvider
commit 197688f3fd54b6acffe7a6c3c55ce869714ec6f6
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Fri Aug 23 18:03:02 2013 +0100

    Actually set m_bIsAfterLast. (firebird-sdbc)
    
    Change-Id: If8558fb53acd1175fa3fd8724a5febca4286abe6

diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx
index edd1836..237d569 100644
--- a/connectivity/source/drivers/firebird/ResultSet.cxx
+++ b/connectivity/source/drivers/firebird/ResultSet.cxx
@@ -106,11 +106,12 @@ sal_Bool SAL_CALL OResultSet::next() throw(SQLException, RuntimeException)
     else if (fetchStat == 100L) // END OF DATASET
     {
         // TODO: shut the statement
+        m_bIsAfterLastRow = true;
         return sal_False;
     }
     else
     {
-        SAL_WARN("connectivity.firebird", "Error when populating data");
+        SAL_WARN("connectivity.firebird", "Error when fetching data");
         // Throws sql exception as appropriate
         evaluateStatusVector(m_statusVector, "isc_dsql_fetch", *this);
         return sal_False;


More information about the Libreoffice-commits mailing list