summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2012-08-30 04:50:27 +0200
committerLionel Elie Mamane <lionel@mamane.lu>2012-08-30 05:25:24 +0200
commit92656d5de9e16c429c0dbd2db355bee8026303cd (patch)
treea9c914a8c2a3d3734671d6b78a4476d8247e0f04 /forms
parent3655f2546500d52f2e555fb8d4964a26cf0f341e (diff)
Make impl_doActionInSQLContext_throw more typesafe
Change-Id: I19be63f1cfa57386dd661ab8f98dc21b5ff8d22c
Diffstat (limited to 'forms')
-rw-r--r--forms/source/runtime/formoperations.cxx39
-rw-r--r--forms/source/runtime/formoperations.hxx52
2 files changed, 42 insertions, 49 deletions
diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx
index 457dcfa77999..97ad91c9c3c9 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 825c08ffa3ca..121b96b7be96 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