LCOV - code coverage report
Current view: top level - svx/source/form - formcontrolling.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 56 179 31.3 %
Date: 2012-08-25 Functions: 12 37 32.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 29 280 10.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <sal/macros.h>
      31                 :            : #include "formcontrolling.hxx"
      32                 :            : #include "fmurl.hxx"
      33                 :            : #include "svx/svxids.hrc"
      34                 :            : #include "fmprop.hrc"
      35                 :            : #include "svx/fmtools.hxx"
      36                 :            : 
      37                 :            : #include <com/sun/star/form/runtime/FormOperations.hpp>
      38                 :            : #include <com/sun/star/form/runtime/FormFeature.hpp>
      39                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      40                 :            : #include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
      41                 :            : 
      42                 :            : #include <tools/diagnose_ex.h>
      43                 :            : #include <comphelper/anytostring.hxx>
      44                 :            : #include <cppuhelper/exc_hlp.hxx>
      45                 :            : #include <osl/diagnose.h>
      46                 :            : 
      47                 :            : #include <functional>
      48                 :            : #include <algorithm>
      49                 :            : 
      50                 :            : //........................................................................
      51                 :            : namespace svx
      52                 :            : {
      53                 :            : //........................................................................
      54                 :            : 
      55                 :            :     /** === begin UNO using === **/
      56                 :            :     using ::com::sun::star::uno::Reference;
      57                 :            :     using ::com::sun::star::lang::XMultiServiceFactory;
      58                 :            :     using ::com::sun::star::form::runtime::XFormController;
      59                 :            :     using ::com::sun::star::form::XForm;
      60                 :            :     using ::com::sun::star::form::runtime::FormOperations;
      61                 :            :     using ::com::sun::star::uno::Exception;
      62                 :            :     using ::com::sun::star::sdbc::XRowSet;
      63                 :            :     using ::com::sun::star::form::runtime::FeatureState;
      64                 :            :     using ::com::sun::star::uno::Any;
      65                 :            :     using ::com::sun::star::uno::Sequence;
      66                 :            :     using ::com::sun::star::beans::NamedValue;
      67                 :            :     using ::com::sun::star::uno::RuntimeException;
      68                 :            :     using ::com::sun::star::beans::XPropertySet;
      69                 :            :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      70                 :            :     using ::com::sun::star::sdbc::SQLException;
      71                 :            :     using ::com::sun::star::sdb::XSQLErrorBroadcaster;
      72                 :            :     using ::com::sun::star::sdb::SQLErrorEvent;
      73                 :            :     using ::com::sun::star::lang::EventObject;
      74                 :            :     /** === end UNO using === **/
      75                 :            :     namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
      76                 :            : 
      77                 :            :     //====================================================================
      78                 :            :     //= FeatureSlotTranslation
      79                 :            :     //====================================================================
      80                 :            :     namespace
      81                 :            :     {
      82                 :          0 :         struct FeatureDescription
      83                 :            :         {
      84                 :            :             ::rtl::OUString sURL;           // the URL
      85                 :            :             sal_Int32       nSlotId;        // the SFX-compatible slot ID
      86                 :            :             sal_Int16       nFormFeature;   // the css.form.runtime.FormFeature ID
      87                 :            :         };
      88                 :            :         typedef ::std::vector< FeatureDescription > FeatureDescriptions;
      89                 :            : 
      90                 :            :         //................................................................
      91                 :          0 :         const FeatureDescriptions& getFeatureDescriptions()
      92                 :            :         {
      93 [ #  # ][ #  # ]:          0 :             static FeatureDescriptions s_aFeatureDescriptions;
         [ #  # ][ #  # ]
      94         [ #  # ]:          0 :             if ( s_aFeatureDescriptions.empty() )
      95                 :            :             {
      96 [ #  # ][ #  # ]:          0 :                 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
      97         [ #  # ]:          0 :                 if ( s_aFeatureDescriptions.empty() )
      98                 :            :                 {
      99                 :            :                     FeatureDescription aDescriptions[] = {
     100                 :            :                         { FMURL_FORM_POSITION,        SID_FM_RECORD_ABSOLUTE,     FormFeature::MoveAbsolute },
     101                 :            :                         { FMURL_FORM_RECORDCOUNT,     SID_FM_RECORD_TOTAL,        FormFeature::TotalRecords },
     102                 :            :                         { FMURL_RECORD_MOVEFIRST,     SID_FM_RECORD_FIRST,        FormFeature::MoveToFirst },
     103                 :            :                         { FMURL_RECORD_MOVEPREV,      SID_FM_RECORD_PREV,         FormFeature::MoveToPrevious },
     104                 :            :                         { FMURL_RECORD_MOVENEXT,      SID_FM_RECORD_NEXT,         FormFeature::MoveToNext },
     105                 :            :                         { FMURL_RECORD_MOVELAST,      SID_FM_RECORD_LAST,         FormFeature::MoveToLast },
     106                 :            :                         { FMURL_RECORD_MOVETONEW,     SID_FM_RECORD_NEW,          FormFeature::MoveToInsertRow },
     107                 :            :                         { FMURL_RECORD_SAVE,          SID_FM_RECORD_SAVE,         FormFeature::SaveRecordChanges },
     108                 :            :                         { FMURL_RECORD_DELETE,        SID_FM_RECORD_DELETE,       FormFeature::DeleteRecord },
     109                 :            :                         { FMURL_FORM_REFRESH,         SID_FM_REFRESH,             FormFeature::ReloadForm },
     110                 :            :                         { FMURL_FORM_REFRESH_CURRENT_CONTROL,
     111                 :            :                                                       SID_FM_REFRESH_FORM_CONTROL,FormFeature::RefreshCurrentControl },
     112                 :            :                         { FMURL_RECORD_UNDO,          SID_FM_RECORD_UNDO,         FormFeature::UndoRecordChanges },
     113                 :            :                         { FMURL_FORM_SORT_UP,         SID_FM_SORTUP,              FormFeature::SortAscending },
     114                 :            :                         { FMURL_FORM_SORT_DOWN,       SID_FM_SORTDOWN,            FormFeature::SortDescending },
     115                 :            :                         { FMURL_FORM_SORT,            SID_FM_ORDERCRIT,           FormFeature::InteractiveSort },
     116                 :            :                         { FMURL_FORM_AUTO_FILTER,     SID_FM_AUTOFILTER,          FormFeature::AutoFilter },
     117                 :            :                         { FMURL_FORM_FILTER,          SID_FM_FILTERCRIT,          FormFeature::InteractiveFilter },
     118                 :            :                         { FMURL_FORM_APPLY_FILTER,    SID_FM_FORM_FILTERED,       FormFeature::ToggleApplyFilter },
     119                 :            :                         { FMURL_FORM_REMOVE_FILTER,   SID_FM_REMOVE_FILTER_SORT,  FormFeature::RemoveFilterAndSort }
     120 [ #  # ][ #  # ]:          0 :                     };
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     121         [ #  # ]:          0 :                     for ( size_t i=0; i<sizeof(aDescriptions)/sizeof(aDescriptions[0]); ++i )
     122 [ #  # ][ #  # ]:          0 :                         s_aFeatureDescriptions.push_back( aDescriptions[i] );
                 [ #  # ]
     123         [ #  # ]:          0 :                 }
     124                 :            :             };
     125                 :          0 :             return s_aFeatureDescriptions;
     126                 :            :         }
     127                 :            :     }
     128                 :            : 
     129                 :            :     //--------------------------------------------------------------------
     130                 :            :     namespace
     131                 :            :     {
     132                 :            :         //................................................................
     133                 :            :         struct MatchFeatureDescriptionByURL : public ::std::unary_function< FeatureDescription, bool >
     134                 :            :         {
     135                 :            :             const ::rtl::OUString&  m_rURL;
     136                 :          0 :             MatchFeatureDescriptionByURL( const ::rtl::OUString& _rURL ) :m_rURL( _rURL ) { }
     137                 :            : 
     138                 :          0 :             bool operator()( const FeatureDescription& _compare )
     139                 :            :             {
     140                 :          0 :                 return m_rURL == _compare.sURL;
     141                 :            :             }
     142                 :            :         };
     143                 :            : 
     144                 :            :         //................................................................
     145                 :            :         struct MatchFeatureDescriptionBySlotId : public ::std::unary_function< FeatureDescription, bool >
     146                 :            :         {
     147                 :            :             sal_Int32   m_nSlotId;
     148                 :          0 :             MatchFeatureDescriptionBySlotId( sal_Int32 _nSlotId ) :m_nSlotId( _nSlotId ) { }
     149                 :            : 
     150                 :          0 :             bool operator()( const FeatureDescription& _compare )
     151                 :            :             {
     152                 :          0 :                 return m_nSlotId == _compare.nSlotId;
     153                 :            :             }
     154                 :            :         };
     155                 :            : 
     156                 :            :         //................................................................
     157                 :            :         struct MatchFeatureDescriptionByFormFeature : public ::std::unary_function< FeatureDescription, bool >
     158                 :            :         {
     159                 :            :             sal_Int32   m_nFormFeature;
     160                 :          0 :             MatchFeatureDescriptionByFormFeature( sal_Int32 _nFormFeature ) :m_nFormFeature( _nFormFeature ) { }
     161                 :            : 
     162                 :          0 :             bool operator()( const FeatureDescription& _compare )
     163                 :            :             {
     164                 :          0 :                 return m_nFormFeature == _compare.nFormFeature;
     165                 :            :             }
     166                 :            :         };
     167                 :            : 
     168                 :            :         //................................................................
     169                 :            :         struct FormFeatureToSlotId : public ::std::unary_function< sal_Int16, sal_Int32 >
     170                 :            :         {
     171                 :          0 :             sal_Int32 operator()( sal_Int16 _FormFeature )
     172                 :            :             {
     173                 :          0 :                 return FeatureSlotTranslation::getSlotIdForFormFeature( _FormFeature );
     174                 :            :             }
     175                 :            :         };
     176                 :            :     }
     177                 :            : 
     178                 :            :     //--------------------------------------------------------------------
     179                 :          0 :     sal_Int32 FeatureSlotTranslation::getControllerFeatureSlotIdForURL( const ::rtl::OUString& _rMainURL )
     180                 :            :     {
     181         [ #  # ]:          0 :         const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
     182         [ #  # ]:          0 :         FeatureDescriptions::const_iterator pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionByURL( _rMainURL ) );
     183 [ #  # ][ #  # ]:          0 :         return ( pos != rDescriptions.end() ) ? pos->nSlotId : -1;
     184                 :            :     }
     185                 :            : 
     186                 :            :     //--------------------------------------------------------------------
     187                 :          0 :     sal_Int16 FeatureSlotTranslation::getFormFeatureForSlotId( sal_Int32 _nSlotId )
     188                 :            :     {
     189         [ #  # ]:          0 :         const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
     190         [ #  # ]:          0 :         FeatureDescriptions::const_iterator pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionBySlotId( _nSlotId ) );
     191                 :            :         OSL_ENSURE( pos != rDescriptions.end(), "FeatureSlotTranslation::getFormFeatureForSlotId: not found!" );
     192 [ #  # ][ #  # ]:          0 :         return ( pos != rDescriptions.end() ) ? pos->nFormFeature : -1;
     193                 :            :     }
     194                 :            : 
     195                 :            :     //--------------------------------------------------------------------
     196                 :          0 :     sal_Int32 FeatureSlotTranslation::getSlotIdForFormFeature( sal_Int16 _nFormFeature )
     197                 :            :     {
     198         [ #  # ]:          0 :         const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
     199         [ #  # ]:          0 :         FeatureDescriptions::const_iterator pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionByFormFeature( _nFormFeature ) );
     200                 :            :         OSL_ENSURE( pos != rDescriptions.end(), "FeatureSlotTranslation::getSlotIdForFormFeature: not found!" );
     201 [ #  # ][ #  # ]:          0 :         return ( pos != rDescriptions.end() ) ? pos->nSlotId : -1;
     202                 :            :     }
     203                 :            : 
     204                 :            :     //====================================================================
     205                 :            :     //= ControllerFeatures
     206                 :            :     //====================================================================
     207                 :            :     //--------------------------------------------------------------------
     208                 :       3338 :     ControllerFeatures::ControllerFeatures( const Reference< XMultiServiceFactory >& _rxORB, IControllerFeatureInvalidation* _pInvalidationCallback )
     209                 :            :         :m_aContext( _rxORB )
     210                 :            :         ,m_pInvalidationCallback( _pInvalidationCallback )
     211                 :       3338 :         ,m_pImpl( NULL )
     212                 :            :     {
     213                 :       3338 :     }
     214                 :            : 
     215                 :            :     //--------------------------------------------------------------------
     216                 :          0 :     ControllerFeatures::ControllerFeatures( const Reference< XMultiServiceFactory >& _rxORB,
     217                 :            :             const Reference< XFormController >& _rxController, IControllerFeatureInvalidation* _pInvalidationCallback )
     218                 :            :         :m_aContext( _rxORB )
     219                 :            :         ,m_pInvalidationCallback( _pInvalidationCallback )
     220                 :          0 :         ,m_pImpl( NULL )
     221                 :            :     {
     222         [ #  # ]:          0 :         assign( _rxController );
     223                 :          0 :     }
     224                 :            : 
     225                 :            :     //--------------------------------------------------------------------
     226                 :          2 :     void ControllerFeatures::assign( const Reference< XFormController >& _rxController )
     227                 :            :     {
     228                 :          2 :         dispose();
     229         [ +  - ]:          2 :         m_pImpl = new FormControllerHelper( m_aContext, _rxController, m_pInvalidationCallback );
     230                 :          2 :         m_pImpl->acquire();
     231                 :          2 :     }
     232                 :            : 
     233                 :            :     //--------------------------------------------------------------------
     234                 :       3156 :     ControllerFeatures::~ControllerFeatures()
     235                 :            :     {
     236         [ +  - ]:       3156 :         dispose();
     237                 :       3156 :     }
     238                 :            : 
     239                 :            :     //--------------------------------------------------------------------
     240                 :       6318 :     void ControllerFeatures::dispose()
     241                 :            :     {
     242         [ +  + ]:       6318 :         if ( m_pImpl )
     243                 :            :         {
     244                 :          2 :             m_pImpl->dispose();
     245                 :          2 :             m_pImpl->release();
     246                 :          2 :             m_pImpl = NULL;
     247                 :            :         }
     248                 :       6318 :     }
     249                 :            : 
     250                 :            :     //====================================================================
     251                 :            :     //= FormControllerHelper
     252                 :            :     //====================================================================
     253                 :            :     //--------------------------------------------------------------------
     254                 :          2 :     FormControllerHelper::FormControllerHelper( const ::comphelper::ComponentContext& _rContext,
     255                 :            :             const Reference< XFormController >& _rxController, IControllerFeatureInvalidation* _pInvalidationCallback )
     256                 :            :         :m_aContext( _rContext )
     257         [ +  - ]:          2 :         ,m_pInvalidationCallback( _pInvalidationCallback )
     258                 :            :     {
     259         [ +  - ]:          2 :         osl_incrementInterlockedCount( &m_refCount );
     260                 :            :         try
     261                 :            :         {
     262 [ +  - ][ +  - ]:          2 :             m_xFormOperations = FormOperations::createWithFormController( m_aContext.getUNOContext(), _rxController );
                 [ +  - ]
     263         [ +  - ]:          2 :             if ( m_xFormOperations.is() )
     264 [ +  - ][ +  - ]:          2 :                 m_xFormOperations->setFeatureInvalidation( this );
                 [ +  - ]
     265                 :            : 
     266                 :            :             // to prevent the controller from displaying any error messages which happen while we operate on it,
     267                 :            :             // we add ourself as XSQLErrorListener. By contract, a FormController displays errors if and only if
     268                 :            :             // no SQLErrorListeners are registered.
     269         [ +  - ]:          2 :             Reference< XSQLErrorBroadcaster > xErrorBroadcast( _rxController, UNO_QUERY_THROW );
     270 [ +  - ][ +  - ]:          2 :             xErrorBroadcast->addSQLErrorListener( this );
         [ +  - ][ #  # ]
     271                 :            :         }
     272         [ #  # ]:          0 :         catch( const Exception& )
     273                 :            :         {
     274                 :            :             DBG_UNHANDLED_EXCEPTION();
     275                 :            :         }
     276         [ +  - ]:          2 :         osl_decrementInterlockedCount( &m_refCount );
     277                 :          2 :     }
     278                 :            : 
     279                 :            :     //--------------------------------------------------------------------
     280         [ +  - ]:          2 :     FormControllerHelper::~FormControllerHelper( )
     281                 :            :     {
     282                 :            :         try
     283                 :            :         {
     284                 :          2 :             acquire();
     285         [ +  - ]:          2 :             dispose();
     286                 :            :         }
     287         [ #  # ]:          0 :         catch( const Exception& )
     288                 :            :         {
     289                 :            :             DBG_UNHANDLED_EXCEPTION();
     290                 :            :         }
     291 [ -  + ][ #  # ]:          4 :     }
     292                 :            : 
     293                 :            :     //--------------------------------------------------------------------
     294                 :          4 :     void FormControllerHelper::dispose()
     295                 :            :     {
     296         [ +  + ]:          4 :         if ( m_xFormOperations.is() )
     297                 :          2 :             m_xFormOperations->dispose();
     298                 :          4 :         m_xFormOperations.clear();
     299                 :          4 :     }
     300                 :            : 
     301                 :            :     //--------------------------------------------------------------------
     302                 :          0 :     sal_Bool FormControllerHelper::isEnabled( sal_Int32 _nSlotId ) const
     303                 :            :     {
     304         [ #  # ]:          0 :         if ( !m_xFormOperations.is() )
     305                 :          0 :             return sal_False;
     306                 :          0 :         return m_xFormOperations->isEnabled( FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ) );
     307                 :            :     }
     308                 :            : 
     309                 :            :     //--------------------------------------------------------------------
     310                 :          0 :     Reference< XRowSet > FormControllerHelper::getCursor() const
     311                 :            :     {
     312                 :          0 :         Reference< XRowSet > xCursor;
     313         [ #  # ]:          0 :         if ( m_xFormOperations.is() )
     314 [ #  # ][ #  # ]:          0 :             xCursor = m_xFormOperations->getCursor();
                 [ #  # ]
     315                 :          0 :         return xCursor;
     316                 :            :     }
     317                 :            : 
     318                 :            :     //--------------------------------------------------------------------
     319                 :          0 :     void FormControllerHelper::getState( sal_Int32 _nSlotId, FeatureState& _rState ) const
     320                 :            :     {
     321         [ #  # ]:          0 :         if ( m_xFormOperations.is() )
     322                 :          0 :             _rState = m_xFormOperations->getState( FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ) );
     323                 :          0 :     }
     324                 :            : 
     325                 :            :     //--------------------------------------------------------------------
     326                 :          6 :     sal_Bool FormControllerHelper::commitCurrentControl( ) const
     327                 :            :     {
     328                 :          6 :         return impl_operateForm_nothrow( COMMIT_CONTROL );
     329                 :            :     }
     330                 :            : 
     331                 :            :     //--------------------------------------------------------------------
     332                 :          0 :     sal_Bool FormControllerHelper::commitCurrentRecord() const
     333                 :            :     {
     334                 :          0 :         return impl_operateForm_nothrow( COMMIT_RECORD );
     335                 :            :     }
     336                 :            : 
     337                 :            :     //--------------------------------------------------------------------
     338                 :          0 :     void FormControllerHelper::execute( sal_Int32 _nSlotId, const ::rtl::OUString& _rParamName, const Any& _rParamValue ) const
     339                 :            :     {
     340         [ #  # ]:          0 :         Sequence< NamedValue > aArguments(1);
     341         [ #  # ]:          0 :         aArguments[0].Name = _rParamName;
     342         [ #  # ]:          0 :         aArguments[0].Value = _rParamValue;
     343                 :            : 
     344 [ #  # ][ #  # ]:          0 :         impl_operateForm_nothrow( EXECUTE_ARGS, FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ), aArguments );
                 [ #  # ]
     345                 :          0 :     }
     346                 :            : 
     347                 :            :     //--------------------------------------------------------------------
     348                 :          6 :     bool FormControllerHelper::impl_operateForm_nothrow( const FormOperation _eWhat, const sal_Int16 _nFeature,
     349                 :            :             const Sequence< NamedValue >& _rArguments ) const
     350                 :            :     {
     351         [ -  + ]:          6 :         if ( !m_xFormOperations.is() )
     352                 :          0 :             return false;
     353                 :            : 
     354                 :          6 :         Any aError;
     355                 :          6 :         bool bSuccess = false;
     356                 :          6 :         const_cast< FormControllerHelper* >( this )->m_aOperationError.clear();
     357                 :            :         try
     358                 :            :         {
     359   [ +  -  -  -  :          6 :             switch ( _eWhat )
                      - ]
     360                 :            :             {
     361                 :            :             case COMMIT_CONTROL:
     362 [ +  - ][ +  - ]:          6 :                 bSuccess = m_xFormOperations->commitCurrentControl();
     363                 :          6 :                 break;
     364                 :            : 
     365                 :            :             case COMMIT_RECORD:
     366                 :            :             {
     367                 :          0 :                 sal_Bool bDummy( sal_False );
     368 [ #  # ][ #  # ]:          0 :                 bSuccess = m_xFormOperations->commitCurrentRecord( bDummy );
     369                 :            :             }
     370                 :          0 :             break;
     371                 :            : 
     372                 :            :             case EXECUTE:
     373 [ #  # ][ #  # ]:          0 :                 m_xFormOperations->execute( _nFeature );
     374                 :          0 :                 bSuccess = true;
     375                 :          0 :                 break;
     376                 :            : 
     377                 :            :             case EXECUTE_ARGS:
     378 [ #  # ][ #  # ]:          0 :                 m_xFormOperations->executeWithArguments( _nFeature, _rArguments );
     379                 :          0 :                 bSuccess = true;
     380                 :          0 :                 break;
     381                 :            :             }
     382                 :            :         }
     383         [ #  # ]:          0 :         catch ( const SQLException& )
     384                 :            :         {
     385         [ #  # ]:          0 :             aError = ::cppu::getCaughtException();
     386                 :            :         }
     387   [ #  #  #  #  :          0 :         catch( const Exception& )
                      # ]
     388                 :            :         {
     389         [ #  # ]:          0 :             SQLException aFallbackError;
     390   [ #  #  #  # ]:          0 :             aFallbackError.Message = ::comphelper::anyToString( ::cppu::getCaughtException() );
     391   [ #  #  #  # ]:          0 :             aError <<= aFallbackError;
     392                 :            :         }
     393                 :            : 
     394         [ +  - ]:          6 :         if ( bSuccess )
     395                 :          6 :             return true;
     396                 :            : 
     397                 :            :         // display the error. Prefer the one reported in errorOccurred over the one caught.
     398         [ #  # ]:          0 :         if ( m_aOperationError.hasValue() )
     399         [ #  # ]:          0 :             displayException( m_aOperationError );
     400         [ #  # ]:          0 :         else if ( aError.hasValue() )
     401         [ #  # ]:          0 :             displayException( aError );
     402                 :            :         else
     403                 :            :             OSL_FAIL( "FormControllerHelper::impl_operateForm_nothrow: no success, but no error?" );
     404                 :            : 
     405                 :          6 :         return false;
     406                 :            :     }
     407                 :            : 
     408                 :            :     //--------------------------------------------------------------------
     409                 :          0 :     void FormControllerHelper::execute( sal_Int32 _nSlotId ) const
     410                 :            :     {
     411         [ #  # ]:          0 :         impl_operateForm_nothrow( EXECUTE, FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ),
     412         [ #  # ]:          0 :             Sequence< NamedValue >() );
     413                 :          0 :     }
     414                 :            : 
     415                 :            :     //--------------------------------------------------------------------
     416                 :          0 :     void SAL_CALL FormControllerHelper::invalidateFeatures( const Sequence< ::sal_Int16 >& _Features ) throw (RuntimeException)
     417                 :            :     {
     418         [ #  # ]:          0 :         if ( !m_pInvalidationCallback )
     419                 :            :             // nobody's interested in ...
     420                 :          0 :             return;
     421                 :            : 
     422         [ #  # ]:          0 :         ::std::vector< sal_Int32 > aFeatures( _Features.getLength() );
     423                 :            :         ::std::transform(
     424                 :            :             _Features.getConstArray(),
     425                 :          0 :             _Features.getConstArray() + _Features.getLength(),
     426                 :            :             aFeatures.begin(),
     427                 :            :             FormFeatureToSlotId()
     428         [ #  # ]:          0 :         );
     429                 :            : 
     430         [ #  # ]:          0 :         m_pInvalidationCallback->invalidateFeatures( aFeatures );
     431                 :            :     }
     432                 :            : 
     433                 :            :     //--------------------------------------------------------------------
     434                 :          0 :     void SAL_CALL FormControllerHelper::invalidateAllFeatures() throw (RuntimeException)
     435                 :            :     {
     436         [ #  # ]:          0 :         if ( !m_pInvalidationCallback )
     437                 :            :             // nobody's interested in ...
     438                 :          0 :             return;
     439                 :            : 
     440                 :            :         // actually, it's a little bit more than the supported features,
     441                 :            :         // but on the medium term, we are to support everything listed
     442                 :            :         // here
     443         [ #  # ]:          0 :         ::std::vector< sal_Int32 > aSupportedFeatures;
     444                 :            :         sal_Int32 pSupportedFeatures[] =
     445                 :            :         {
     446                 :            :             SID_FM_RECORD_FIRST,
     447                 :            :             SID_FM_RECORD_NEXT,
     448                 :            :             SID_FM_RECORD_PREV,
     449                 :            :             SID_FM_RECORD_LAST,
     450                 :            :             SID_FM_RECORD_NEW,
     451                 :            :             SID_FM_RECORD_DELETE,
     452                 :            :             SID_FM_RECORD_ABSOLUTE,
     453                 :            :             SID_FM_RECORD_TOTAL,
     454                 :            :             SID_FM_RECORD_SAVE,
     455                 :            :             SID_FM_RECORD_UNDO,
     456                 :            :             SID_FM_REMOVE_FILTER_SORT,
     457                 :            :             SID_FM_SORTUP,
     458                 :            :             SID_FM_SORTDOWN,
     459                 :            :             SID_FM_ORDERCRIT,
     460                 :            :             SID_FM_AUTOFILTER,
     461                 :            :             SID_FM_FILTERCRIT,
     462                 :            :             SID_FM_FORM_FILTERED,
     463                 :            :             SID_FM_REFRESH,
     464                 :            :             SID_FM_REFRESH_FORM_CONTROL,
     465                 :            :             SID_FM_SEARCH,
     466                 :            :             SID_FM_FILTER_START,
     467                 :            :             SID_FM_VIEW_AS_GRID
     468                 :          0 :         };
     469                 :          0 :         sal_Int32 nFeatureCount = sizeof( pSupportedFeatures ) / sizeof( pSupportedFeatures[ 0 ] );
     470         [ #  # ]:          0 :         aSupportedFeatures.resize( nFeatureCount );
     471         [ #  # ]:          0 :         ::std::copy( pSupportedFeatures, pSupportedFeatures + nFeatureCount, aSupportedFeatures.begin() );
     472                 :            : 
     473         [ #  # ]:          0 :         m_pInvalidationCallback->invalidateFeatures( aSupportedFeatures );
     474                 :            :     }
     475                 :            : 
     476                 :            :     //--------------------------------------------------------------------
     477                 :          0 :     void SAL_CALL FormControllerHelper::errorOccured( const SQLErrorEvent& _Event ) throw (RuntimeException)
     478                 :            :     {
     479                 :            :         OSL_ENSURE( !m_aOperationError.hasValue(), "FormControllerHelper::errorOccurred: two errors during one operation?" );
     480                 :          0 :         m_aOperationError = _Event.Reason;
     481                 :          0 :     }
     482                 :            : 
     483                 :            :     //--------------------------------------------------------------------
     484                 :          2 :     void SAL_CALL FormControllerHelper::disposing( const EventObject& /*_Source*/ ) throw (RuntimeException)
     485                 :            :     {
     486                 :            :         // not interested in
     487                 :          2 :     }
     488                 :            : 
     489                 :            :     //--------------------------------------------------------------------
     490                 :          0 :     sal_Bool FormControllerHelper::isInsertionRow() const
     491                 :            :     {
     492                 :          0 :         sal_Bool bIs = sal_False;
     493         [ #  # ]:          0 :         if ( m_xFormOperations.is() )
     494                 :          0 :             bIs = m_xFormOperations->isInsertionRow();
     495                 :          0 :         return bIs;
     496                 :            :     }
     497                 :            : 
     498                 :            :     //--------------------------------------------------------------------
     499                 :          6 :     sal_Bool FormControllerHelper::isModifiedRow() const
     500                 :            :     {
     501                 :          6 :         sal_Bool bIs = sal_False;
     502         [ +  - ]:          6 :         if ( m_xFormOperations.is() )
     503                 :          6 :             bIs = m_xFormOperations->isModifiedRow();
     504                 :          6 :         return bIs;
     505                 :            :     }
     506                 :            :     //--------------------------------------------------------------------
     507                 :          0 :     bool FormControllerHelper::canDoFormFilter() const
     508                 :            :     {
     509         [ #  # ]:          0 :         if ( !m_xFormOperations.is() )
     510                 :          0 :             return false;
     511                 :            : 
     512                 :          0 :         bool bCanDo = false;
     513                 :            :         try
     514                 :            :         {
     515 [ #  # ][ #  # ]:          0 :             Reference< XPropertySet > xCursorProperties( m_xFormOperations->getCursor(), UNO_QUERY_THROW );
                 [ #  # ]
     516                 :            : 
     517                 :          0 :             bool bEscapeProcessing( false );
     518 [ #  # ][ #  # ]:          0 :             OSL_VERIFY( xCursorProperties->getPropertyValue( FM_PROP_ESCAPE_PROCESSING ) >>= bEscapeProcessing );
                 [ #  # ]
     519                 :            : 
     520                 :          0 :             ::rtl::OUString sActiveCommand;
     521 [ #  # ][ #  # ]:          0 :             OSL_VERIFY( xCursorProperties->getPropertyValue( FM_PROP_ACTIVECOMMAND ) >>= sActiveCommand );
                 [ #  # ]
     522                 :            : 
     523                 :          0 :             bool bInsertOnlyForm( false );
     524 [ #  # ][ #  # ]:          0 :             OSL_VERIFY( xCursorProperties->getPropertyValue( FM_PROP_INSERTONLY ) >>= bInsertOnlyForm );
                 [ #  # ]
     525                 :            : 
     526 [ #  # ][ #  # ]:          0 :             bCanDo = bEscapeProcessing && !sActiveCommand.isEmpty() && !bInsertOnlyForm;
         [ #  # ][ #  # ]
     527                 :            :         }
     528                 :          0 :         catch( const Exception& )
     529                 :            :         {
     530                 :            :             DBG_UNHANDLED_EXCEPTION();
     531                 :            :         }
     532                 :          0 :         return bCanDo;
     533                 :            :     }
     534                 :            : 
     535                 :            : //........................................................................
     536                 :            : }   // namespace svx
     537                 :            : //........................................................................
     538                 :            : 
     539                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10