[Libreoffice-commits] .: 2 commits - dbaccess/source forms/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Aug 29 20:26:38 PDT 2012


 dbaccess/source/core/api/querycomposer.cxx |   18 ---------
 dbaccess/source/ui/browser/brwctrlr.cxx    |   17 --------
 forms/source/runtime/formoperations.cxx    |   55 +++--------------------------
 forms/source/runtime/formoperations.hxx    |   52 ++++++++++++++++++---------
 4 files changed, 44 insertions(+), 98 deletions(-)

New commits:
commit 92656d5de9e16c429c0dbd2db355bee8026303cd
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Thu Aug 30 04:50:27 2012 +0200

    Make impl_doActionInSQLContext_throw more typesafe
    
    Change-Id: I19be63f1cfa57386dd661ab8f98dc21b5ff8d22c

diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx
index 457dcfa..97ad91c 100644
--- a/forms/source/runtime/formoperations.cxx
+++ b/forms/source/runtime/formoperations.cxx
@@ -46,7 +46,6 @@
 #include <com/sun/star/form/XConfirmDeleteListener.hpp>
 #include <com/sun/star/sdb/RowChangeEvent.hpp>
 #include <com/sun/star/sdb/RowChangeAction.hpp>
-#include <com/sun/star/sdb/SQLFilterOperator.hpp>
 #include <com/sun/star/sdbc/DataType.hpp>
 #include <com/sun/star/form/XReset.hpp>
 #include <com/sun/star/beans/XMultiPropertySet.hpp>
@@ -1497,14 +1496,8 @@ namespace frm
             // automatic sort by field is expected to always resets the previous sort order
             m_xParser->setOrder( ::rtl::OUString() );
 
-            param_appendOrderByColumn aParam;
-            aParam.xField = xBoundField;
-            aParam.bUp = _bUp;
-            impl_doActionInSQLContext_throw(
-                (Action)&FormOperations::impl_appendOrderByColumn_throw,
-                static_cast< const void* >( &aParam ),
-                (sal_uInt16)RID_STR_COULD_NOT_SET_ORDER
-            );
+            impl_appendOrderByColumn_throw aAction(this, xBoundField, _bUp);
+            impl_doActionInSQLContext_throw(aAction, RID_STR_COULD_NOT_SET_ORDER );
 
             WaitObject aWO( NULL );
             try
@@ -1569,13 +1562,8 @@ namespace frm
             if ( !bApplied )
                 m_xParser->setFilter( ::rtl::OUString() );
 
-            param_appendFilterByColumn aParam;
-            aParam.xField = xBoundField;
-            impl_doActionInSQLContext_throw(
-                (Action)&FormOperations::impl_appendFilterByColumn_throw,
-                static_cast< const void* >( &aParam ),
-                (sal_uInt16)RID_STR_COULD_NOT_SET_FILTER
-            );
+            impl_appendFilterByColumn_throw aAction(this, xBoundField);
+            impl_doActionInSQLContext_throw( aAction, RID_STR_COULD_NOT_SET_FILTER );
 
             WaitObject aWO( NULL );
             try
@@ -1675,25 +1663,12 @@ namespace frm
     }
 
     //------------------------------------------------------------------------------
-    void FormOperations::impl_appendOrderByColumn_throw( const void* _pActionParam ) const
-    {
-        const param_appendOrderByColumn* pParam = static_cast< const param_appendOrderByColumn* >( _pActionParam );
-        m_xParser->appendOrderByColumn( pParam->xField, pParam->bUp );
-    }
-
-    //------------------------------------------------------------------------------
-    void FormOperations::impl_appendFilterByColumn_throw( const void* _pActionParam ) const
-    {
-        const param_appendFilterByColumn* pParam = static_cast< const param_appendFilterByColumn* >( _pActionParam );
-        m_xParser->appendFilterByColumn( pParam->xField, sal_True, SQLFilterOperator::EQUAL );
-    }
-
-    //------------------------------------------------------------------------------
-    void FormOperations::impl_doActionInSQLContext_throw( Action _pAction, const void* _pParam, sal_uInt16 _nErrorResourceId ) const
+    template < typename FunctObj >
+    void FormOperations::impl_doActionInSQLContext_throw( FunctObj Action, sal_uInt16 _nErrorResourceId ) const
     {
         try
         {
-            (this->*_pAction)( _pParam );
+            Action();
         }
         catch( const SQLException& e )
         {
diff --git a/forms/source/runtime/formoperations.hxx b/forms/source/runtime/formoperations.hxx
index 825c08f..121b96b 100644
--- a/forms/source/runtime/formoperations.hxx
+++ b/forms/source/runtime/formoperations.hxx
@@ -29,6 +29,7 @@
 #include <com/sun/star/util/XModifyListener.hpp>
 #include <com/sun/star/container/XIndexAccess.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
 
 #include <comphelper/componentcontext.hxx>
 
@@ -300,34 +301,51 @@ namespace frm
         /// typedef for member method of this class
         typedef void (FormOperations::*Action)( const void* ) const;
 
-        /** calls a member function, catches SQLExceptions, extends them with additional context information,
+        /** calls a (member) function, catches SQLExceptions, extends them with additional context information,
             and rethrows them
 
-            @param _pAction
-                the member function to call
-            @param _pParam
-                the parameters to pass to the member function
+            @param Action
+                a fuctionoid with no arguments to do the work
             @param _nErrorResourceId
                 the id of the resources string to use as error message
         */
-        void        impl_doActionInSQLContext_throw( Action _pAction, const void* _pParam, sal_uInt16 _nErrorResourceId ) const;
+        template < typename FunctObj >
+        void        impl_doActionInSQLContext_throw( FunctObj Action, sal_uInt16 _nErrorResourceId ) const;
 
-        // parameter structure for appendOrderByColumn
-        struct param_appendOrderByColumn
+        // functionoid to call appendOrderByColumn
+        class impl_appendOrderByColumn_throw
         {
-            ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
-                        xField;
-            bool        bUp;
+        public:
+            impl_appendOrderByColumn_throw(const FormOperations *pFO,
+                                           ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xField,
+                                           bool bUp)
+                : m_pFO(pFO)
+                , m_xField(xField)
+                , m_bUp(bUp)
+            {};
+
+            void operator()() { m_pFO->m_xParser->appendOrderByColumn(m_xField, m_bUp); }
+        private:
+            const FormOperations *m_pFO;
+            ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xField;
+            bool m_bUp;
         };
-        void        impl_appendOrderByColumn_throw( const void* _pActionParam ) const;
 
-        // parameter structure for appendFilterByColumn
-        struct param_appendFilterByColumn
+        // functionoid to call appendFilterByColumn
+        class impl_appendFilterByColumn_throw
         {
-            ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
-                        xField;
+        public:
+            impl_appendFilterByColumn_throw(const FormOperations *pFO,
+                                            ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xField)
+                : m_pFO(pFO)
+                , m_xField(xField)
+            {};
+
+            void operator()() { m_pFO->m_xParser->appendFilterByColumn( m_xField, sal_True, ::com::sun::star::sdb::SQLFilterOperator::EQUAL ); }
+        private:
+            const FormOperations *m_pFO;
+            ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xField;
         };
-        void        impl_appendFilterByColumn_throw( const void* _pActionParam ) const;
 
     private:
         FormOperations();                                   // never implemented
commit 3655f2546500d52f2e555fb8d4964a26cf0f341e
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Thu Aug 30 03:58:55 2012 +0200

    fdo#48807 autofilter should not use LIKE operator
    
    This demonstrates a confusion between *values* and *patterns*
    
    Change-Id: I207aa53950166e915bbad22b022c88d07ee6300d

diff --git a/dbaccess/source/core/api/querycomposer.cxx b/dbaccess/source/core/api/querycomposer.cxx
index 01e5adc..1c72c78 100644
--- a/dbaccess/source/core/api/querycomposer.cxx
+++ b/dbaccess/source/core/api/querycomposer.cxx
@@ -225,23 +225,7 @@ void SAL_CALL OQueryComposer::appendFilterByColumn( const Reference< XPropertySe
 
     m_xComposerHelper->setQuery(getQuery());
     m_xComposerHelper->setFilter(::rtl::OUString());
-    sal_Int32 nOp = SQLFilterOperator::EQUAL;
-    if ( column.is() )
-    {
-        sal_Int32 nType = 0;
-        column->getPropertyValue(PROPERTY_TYPE) >>= nType;
-        switch(nType)
-        {
-            case DataType::VARCHAR:
-            case DataType::CHAR:
-            case DataType::LONGVARCHAR:
-                nOp = SQLFilterOperator::LIKE;
-                break;
-            default:
-                nOp = SQLFilterOperator::EQUAL;
-        }
-    }
-    m_xComposerHelper->appendFilterByColumn(column,sal_True,nOp);
+    m_xComposerHelper->appendFilterByColumn(column, sal_True, SQLFilterOperator::EQUAL);
 
     FilterCreator aFilterCreator;
     aFilterCreator.append(getFilter());
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx
index d28d582..a2931e7 100644
--- a/dbaccess/source/ui/browser/brwctrlr.cxx
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -2216,22 +2216,7 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property
 
             sal_Bool bParserSuccess = sal_False;
 
-            sal_Int32 nOp = SQLFilterOperator::EQUAL;
-            if ( xField.is() )
-            {
-                sal_Int32 nType = 0;
-                xField->getPropertyValue(PROPERTY_TYPE) >>= nType;
-                switch(nType)
-                {
-                    case DataType::VARCHAR:
-                    case DataType::CHAR:
-                    case DataType::LONGVARCHAR:
-                        nOp = SQLFilterOperator::LIKE;
-                        break;
-                    default:
-                        nOp = SQLFilterOperator::EQUAL;
-                }
-            }
+            const sal_Int32 nOp = SQLFilterOperator::EQUAL;
 
             if ( bHaving )
             {
diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx
index 3c29f88..457dcfa 100644
--- a/forms/source/runtime/formoperations.cxx
+++ b/forms/source/runtime/formoperations.cxx
@@ -1685,23 +1685,7 @@ namespace frm
     void FormOperations::impl_appendFilterByColumn_throw( const void* _pActionParam ) const
     {
         const param_appendFilterByColumn* pParam = static_cast< const param_appendFilterByColumn* >( _pActionParam );
-        sal_Int32 nOp = SQLFilterOperator::EQUAL;
-        if ( pParam->xField.is() )
-        {
-            sal_Int32 nType = 0;
-            pParam->xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nType;
-            switch(nType)
-            {
-                case DataType::VARCHAR:
-                case DataType::CHAR:
-                case DataType::LONGVARCHAR:
-                    nOp = SQLFilterOperator::LIKE;
-                    break;
-                default:
-                    nOp = SQLFilterOperator::EQUAL;
-            }
-        }
-        m_xParser->appendFilterByColumn( pParam->xField, sal_True,nOp );
+        m_xParser->appendFilterByColumn( pParam->xField, sal_True, SQLFilterOperator::EQUAL );
     }
 
     //------------------------------------------------------------------------------


More information about the Libreoffice-commits mailing list