xref: /trunk/main/svx/source/form/formcontrolling.cxx (revision e8df90a080f9dc7518c4b937d7dcd461d7b4d178)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include "formcontrolling.hxx"
28 #include "fmurl.hxx"
29 #include "svx/svxids.hrc"
30 #include "fmprop.hrc"
31 #include "svx/fmtools.hxx"
32 
33 /** === begin UNO includes === **/
34 #include <com/sun/star/form/runtime/FormOperations.hpp>
35 #include <com/sun/star/form/runtime/FormFeature.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
38 /** === end UNO includes === **/
39 
40 #include <tools/diagnose_ex.h>
41 #include <comphelper/anytostring.hxx>
42 #include <cppuhelper/exc_hlp.hxx>
43 #include <osl/diagnose.h>
44 
45 #include <functional>
46 #include <algorithm>
47 
48 //........................................................................
49 namespace svx
50 {
51 //........................................................................
52 
53     /** === begin UNO using === **/
54     using ::com::sun::star::uno::Reference;
55     using ::com::sun::star::lang::XMultiServiceFactory;
56     using ::com::sun::star::form::runtime::XFormController;
57     using ::com::sun::star::form::XForm;
58     using ::com::sun::star::form::runtime::FormOperations;
59     using ::com::sun::star::uno::Exception;
60     using ::com::sun::star::sdbc::XRowSet;
61     using ::com::sun::star::form::runtime::FeatureState;
62     using ::com::sun::star::uno::Any;
63     using ::com::sun::star::uno::Sequence;
64     using ::com::sun::star::beans::NamedValue;
65     using ::com::sun::star::uno::RuntimeException;
66     using ::com::sun::star::beans::XPropertySet;
67     using ::com::sun::star::uno::UNO_QUERY_THROW;
68     using ::com::sun::star::sdbc::SQLException;
69     using ::com::sun::star::sdb::XSQLErrorBroadcaster;
70     using ::com::sun::star::sdb::SQLErrorEvent;
71     using ::com::sun::star::lang::EventObject;
72     /** === end UNO using === **/
73     namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
74 
75     //====================================================================
76     //= FeatureSlotTranslation
77     //====================================================================
78     namespace
79     {
80         struct FeatureDescription
81         {
82             ::rtl::OUString sURL;           // the URL
83             sal_Int32       nSlotId;        // the SFX-compatible slot ID
84             sal_Int16       nFormFeature;   // the css.form.runtime.FormFeature ID
85         };
86         typedef ::std::vector< FeatureDescription > FeatureDescriptions;
87 
88         //................................................................
getFeatureDescriptions()89         const FeatureDescriptions& getFeatureDescriptions()
90         {
91             static FeatureDescriptions s_aFeatureDescriptions;
92             if ( s_aFeatureDescriptions.empty() )
93             {
94                 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
95                 if ( s_aFeatureDescriptions.empty() )
96                 {
97                     FeatureDescription aDescriptions[] = {
98                         { FMURL_FORM_POSITION,        SID_FM_RECORD_ABSOLUTE,     FormFeature::MoveAbsolute },
99                         { FMURL_FORM_RECORDCOUNT,     SID_FM_RECORD_TOTAL,        FormFeature::TotalRecords },
100                         { FMURL_RECORD_MOVEFIRST,     SID_FM_RECORD_FIRST,        FormFeature::MoveToFirst },
101                         { FMURL_RECORD_MOVEPREV,      SID_FM_RECORD_PREV,         FormFeature::MoveToPrevious },
102                         { FMURL_RECORD_MOVENEXT,      SID_FM_RECORD_NEXT,         FormFeature::MoveToNext },
103                         { FMURL_RECORD_MOVELAST,      SID_FM_RECORD_LAST,         FormFeature::MoveToLast },
104                         { FMURL_RECORD_MOVETONEW,     SID_FM_RECORD_NEW,          FormFeature::MoveToInsertRow },
105                         { FMURL_RECORD_SAVE,          SID_FM_RECORD_SAVE,         FormFeature::SaveRecordChanges },
106                         { FMURL_RECORD_DELETE,        SID_FM_RECORD_DELETE,       FormFeature::DeleteRecord },
107                         { FMURL_FORM_REFRESH,         SID_FM_REFRESH,             FormFeature::ReloadForm },
108                         { FMURL_FORM_REFRESH_CURRENT_CONTROL,
109                                                       SID_FM_REFRESH_FORM_CONTROL,FormFeature::RefreshCurrentControl },
110                         { FMURL_RECORD_UNDO,          SID_FM_RECORD_UNDO,         FormFeature::UndoRecordChanges },
111                         { FMURL_FORM_SORT_UP,         SID_FM_SORTUP,              FormFeature::SortAscending },
112                         { FMURL_FORM_SORT_DOWN,       SID_FM_SORTDOWN,            FormFeature::SortDescending },
113                         { FMURL_FORM_SORT,            SID_FM_ORDERCRIT,           FormFeature::InteractiveSort },
114                         { FMURL_FORM_AUTO_FILTER,     SID_FM_AUTOFILTER,          FormFeature::AutoFilter },
115                         { FMURL_FORM_FILTER,          SID_FM_FILTERCRIT,          FormFeature::InteractiveFilter },
116                         { FMURL_FORM_APPLY_FILTER,    SID_FM_FORM_FILTERED,       FormFeature::ToggleApplyFilter },
117                         { FMURL_FORM_REMOVE_FILTER,   SID_FM_REMOVE_FILTER_SORT,  FormFeature::RemoveFilterAndSort }
118                     };
119                     for ( size_t i=0; i<sizeof(aDescriptions)/sizeof(aDescriptions[0]); ++i )
120                         s_aFeatureDescriptions.push_back( aDescriptions[i] );
121                 }
122             };
123             return s_aFeatureDescriptions;
124         }
125     }
126 
127     //--------------------------------------------------------------------
128     namespace
129     {
130         //................................................................
131         struct MatchFeatureDescriptionByURL
132         {
133             typedef FeatureDescription argument_type;
134             typedef bool result_type;
135             const ::rtl::OUString&  m_rURL;
MatchFeatureDescriptionByURLsvx::__anonf0c011e90211::MatchFeatureDescriptionByURL136             MatchFeatureDescriptionByURL( const ::rtl::OUString& _rURL ) :m_rURL( _rURL ) { }
137 
operator ()svx::__anonf0c011e90211::MatchFeatureDescriptionByURL138             bool operator()( const FeatureDescription& _compare )
139             {
140                 return m_rURL == _compare.sURL;
141             }
142         };
143 
144         //................................................................
145         struct MatchFeatureDescriptionBySlotId
146         {
147             typedef FeatureDescription argument_type;
148             typedef bool result_type;
149             sal_Int32   m_nSlotId;
MatchFeatureDescriptionBySlotIdsvx::__anonf0c011e90211::MatchFeatureDescriptionBySlotId150             MatchFeatureDescriptionBySlotId( sal_Int32 _nSlotId ) :m_nSlotId( _nSlotId ) { }
151 
operator ()svx::__anonf0c011e90211::MatchFeatureDescriptionBySlotId152             bool operator()( const FeatureDescription& _compare )
153             {
154                 return m_nSlotId == _compare.nSlotId;
155             }
156         };
157 
158         //................................................................
159         struct MatchFeatureDescriptionByFormFeature
160         {
161             typedef FeatureDescription argument_type;
162             typedef bool result_type;
163             sal_Int32   m_nFormFeature;
MatchFeatureDescriptionByFormFeaturesvx::__anonf0c011e90211::MatchFeatureDescriptionByFormFeature164             MatchFeatureDescriptionByFormFeature( sal_Int32 _nFormFeature ) :m_nFormFeature( _nFormFeature ) { }
165 
operator ()svx::__anonf0c011e90211::MatchFeatureDescriptionByFormFeature166             bool operator()( const FeatureDescription& _compare )
167             {
168                 return m_nFormFeature == _compare.nFormFeature;
169             }
170         };
171 
172         //................................................................
173         struct FormFeatureToSlotId
174         {
175             typedef sal_Int16 argument_type;
176             typedef sal_Int32 result_type;
operator ()svx::__anonf0c011e90211::FormFeatureToSlotId177             sal_Int32 operator()( sal_Int16 _FormFeature )
178             {
179                 return FeatureSlotTranslation::getSlotIdForFormFeature( _FormFeature );
180             }
181         };
182     }
183 
184     //--------------------------------------------------------------------
getControllerFeatureSlotIdForURL(const::rtl::OUString & _rMainURL)185     sal_Int32 FeatureSlotTranslation::getControllerFeatureSlotIdForURL( const ::rtl::OUString& _rMainURL )
186     {
187         const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
188         FeatureDescriptions::const_iterator pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionByURL( _rMainURL ) );
189         return ( pos != rDescriptions.end() ) ? pos->nSlotId : -1;
190     }
191 
192     //--------------------------------------------------------------------
getControllerFeatureURLForSlotId(sal_Int32 _nSlotId)193     ::rtl::OUString  FeatureSlotTranslation::getControllerFeatureURLForSlotId( sal_Int32 _nSlotId )
194     {
195         const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
196         FeatureDescriptions::const_iterator pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionBySlotId( _nSlotId ) );
197         OSL_ENSURE( pos != rDescriptions.end(), "FeatureSlotTranslation::getControllerFeatureURLForSlotId: not found!" );
198         return ( pos != rDescriptions.end() ) ? pos->sURL : ::rtl::OUString();
199     }
200 
201     //--------------------------------------------------------------------
isFeatureURL(const::rtl::OUString & _rMainURL)202     sal_Bool FeatureSlotTranslation::isFeatureURL( const ::rtl::OUString& _rMainURL )
203     {
204         return ( _rMainURL.indexOf( FMURL_FORMSLOTS_PREFIX ) == 0 );
205     }
206 
207     //--------------------------------------------------------------------
getFormFeatureForSlotId(sal_Int32 _nSlotId)208     sal_Int16 FeatureSlotTranslation::getFormFeatureForSlotId( sal_Int32 _nSlotId )
209     {
210         const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
211         FeatureDescriptions::const_iterator pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionBySlotId( _nSlotId ) );
212         OSL_ENSURE( pos != rDescriptions.end(), "FeatureSlotTranslation::getFormFeatureForSlotId: not found!" );
213         return ( pos != rDescriptions.end() ) ? pos->nFormFeature : -1;
214     }
215 
216     //--------------------------------------------------------------------
getSlotIdForFormFeature(sal_Int16 _nFormFeature)217     sal_Int32 FeatureSlotTranslation::getSlotIdForFormFeature( sal_Int16 _nFormFeature )
218     {
219         const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
220         FeatureDescriptions::const_iterator pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionByFormFeature( _nFormFeature ) );
221         OSL_ENSURE( pos != rDescriptions.end(), "FeatureSlotTranslation::getSlotIdForFormFeature: not found!" );
222         return ( pos != rDescriptions.end() ) ? pos->nSlotId : -1;
223     }
224 
225     //====================================================================
226     //= ControllerFeatures
227     //====================================================================
228     //--------------------------------------------------------------------
ControllerFeatures(const Reference<XMultiServiceFactory> & _rxORB,IControllerFeatureInvalidation * _pInvalidationCallback)229     ControllerFeatures::ControllerFeatures( const Reference< XMultiServiceFactory >& _rxORB, IControllerFeatureInvalidation* _pInvalidationCallback )
230         :m_aContext( _rxORB )
231         ,m_pInvalidationCallback( _pInvalidationCallback )
232         ,m_pImpl( NULL )
233     {
234     }
235 
236     //--------------------------------------------------------------------
ControllerFeatures(const Reference<XMultiServiceFactory> & _rxORB,const Reference<XFormController> & _rxController,IControllerFeatureInvalidation * _pInvalidationCallback)237     ControllerFeatures::ControllerFeatures( const Reference< XMultiServiceFactory >& _rxORB,
238             const Reference< XFormController >& _rxController, IControllerFeatureInvalidation* _pInvalidationCallback )
239         :m_aContext( _rxORB )
240         ,m_pInvalidationCallback( _pInvalidationCallback )
241         ,m_pImpl( NULL )
242     {
243         assign( _rxController );
244     }
245 
246     //--------------------------------------------------------------------
ControllerFeatures(const Reference<XMultiServiceFactory> & _rxORB,const Reference<XForm> & _rxForm,IControllerFeatureInvalidation * _pInvalidationCallback)247     ControllerFeatures::ControllerFeatures( const Reference< XMultiServiceFactory >& _rxORB,
248             const Reference< XForm >& _rxForm, IControllerFeatureInvalidation* _pInvalidationCallback )
249         :m_aContext( _rxORB )
250         ,m_pInvalidationCallback( _pInvalidationCallback )
251         ,m_pImpl( NULL )
252     {
253         assign( _rxForm );
254     }
255 
256     //--------------------------------------------------------------------
assign(const Reference<XFormController> & _rxController)257     void ControllerFeatures::assign( const Reference< XFormController >& _rxController )
258     {
259         dispose();
260         m_pImpl = new FormControllerHelper( m_aContext, _rxController, m_pInvalidationCallback );
261         m_pImpl->acquire();
262     }
263 
264     //--------------------------------------------------------------------
assign(const Reference<XForm> & _rxForm)265     void ControllerFeatures::assign( const Reference< XForm >& _rxForm )
266     {
267         dispose();
268         m_pImpl = new FormControllerHelper( m_aContext, _rxForm, m_pInvalidationCallback );
269         m_pImpl->acquire();
270     }
271 
272     //--------------------------------------------------------------------
~ControllerFeatures()273     ControllerFeatures::~ControllerFeatures()
274     {
275         dispose();
276     }
277 
278     //--------------------------------------------------------------------
dispose()279     void ControllerFeatures::dispose()
280     {
281         if ( m_pImpl )
282         {
283             m_pImpl->dispose();
284             m_pImpl->release();
285             m_pImpl = NULL;
286         }
287     }
288 
289     //====================================================================
290     //= FormControllerHelper
291     //====================================================================
292     //--------------------------------------------------------------------
FormControllerHelper(const::comphelper::ComponentContext & _rContext,const Reference<XFormController> & _rxController,IControllerFeatureInvalidation * _pInvalidationCallback)293     FormControllerHelper::FormControllerHelper( const ::comphelper::ComponentContext& _rContext,
294             const Reference< XFormController >& _rxController, IControllerFeatureInvalidation* _pInvalidationCallback )
295         :m_aContext( _rContext )
296         ,m_pInvalidationCallback( _pInvalidationCallback )
297     {
298         osl_incrementInterlockedCount( &m_refCount );
299         try
300         {
301             m_xFormOperations = FormOperations::createWithFormController( m_aContext.getUNOContext(), _rxController );
302             if ( m_xFormOperations.is() )
303                 m_xFormOperations->setFeatureInvalidation( this );
304 
305             // to prevent the controller from displaying any error messages which happen while we operate on it,
306             // we add ourself as XSQLErrorListener. By contract, a FormController displays errors if and only if
307             // no SQLErrorListeners are registered.
308             Reference< XSQLErrorBroadcaster > xErrorBroadcast( _rxController, UNO_QUERY_THROW );
309             xErrorBroadcast->addSQLErrorListener( this );
310         }
311         catch( const Exception& )
312         {
313             DBG_UNHANDLED_EXCEPTION();
314         }
315         osl_decrementInterlockedCount( &m_refCount );
316     }
317 
318     //--------------------------------------------------------------------
FormControllerHelper(const::comphelper::ComponentContext & _rContext,const Reference<XForm> & _rxForm,IControllerFeatureInvalidation * _pInvalidationCallback)319     FormControllerHelper::FormControllerHelper( const ::comphelper::ComponentContext& _rContext,
320             const Reference< XForm >& _rxForm, IControllerFeatureInvalidation* _pInvalidationCallback )
321         :m_aContext( _rContext )
322         ,m_pInvalidationCallback( _pInvalidationCallback )
323     {
324         osl_incrementInterlockedCount( &m_refCount );
325         try
326         {
327             m_xFormOperations = FormOperations::createWithForm( m_aContext.getUNOContext(), _rxForm );
328             if ( m_xFormOperations.is() )
329                 m_xFormOperations->setFeatureInvalidation( this );
330         }
331         catch( const Exception& )
332         {
333             DBG_UNHANDLED_EXCEPTION();
334         }
335         osl_decrementInterlockedCount( &m_refCount );
336     }
337 
338     //--------------------------------------------------------------------
~FormControllerHelper()339     FormControllerHelper::~FormControllerHelper( )
340     {
341         try
342         {
343             acquire();
344             dispose();
345         }
346         catch( const Exception& )
347         {
348             DBG_UNHANDLED_EXCEPTION();
349         }
350     }
351 
352     //--------------------------------------------------------------------
dispose()353     void FormControllerHelper::dispose()
354     {
355         if ( m_xFormOperations.is() )
356             m_xFormOperations->dispose();
357         m_xFormOperations.clear();
358     }
359 
360     //--------------------------------------------------------------------
isEnabled(sal_Int32 _nSlotId) const361     sal_Bool FormControllerHelper::isEnabled( sal_Int32 _nSlotId ) const
362     {
363         if ( !m_xFormOperations.is() )
364             return sal_False;
365         return m_xFormOperations->isEnabled( FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ) );
366     }
367 
368     //--------------------------------------------------------------------
getCursor() const369     Reference< XRowSet > FormControllerHelper::getCursor() const
370     {
371         Reference< XRowSet > xCursor;
372         if ( m_xFormOperations.is() )
373             xCursor = m_xFormOperations->getCursor();
374         return xCursor;
375     }
376 
377     //--------------------------------------------------------------------
getState(sal_Int32 _nSlotId,FeatureState & _rState) const378     void FormControllerHelper::getState( sal_Int32 _nSlotId, FeatureState& _rState ) const
379     {
380         if ( m_xFormOperations.is() )
381             _rState = m_xFormOperations->getState( FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ) );
382     }
383 
384     //--------------------------------------------------------------------
commitCurrentControl() const385     sal_Bool FormControllerHelper::commitCurrentControl( ) const
386     {
387         return impl_operateForm_nothrow( COMMIT_CONTROL );
388     }
389 
390     //--------------------------------------------------------------------
commitCurrentRecord() const391     sal_Bool FormControllerHelper::commitCurrentRecord() const
392     {
393         return impl_operateForm_nothrow( COMMIT_RECORD );
394     }
395 
396     //--------------------------------------------------------------------
moveRight() const397     bool FormControllerHelper::moveRight( ) const
398     {
399         return impl_operateForm_nothrow( FormFeature::MoveToNext );
400     }
401 
402     //--------------------------------------------------------------------
moveLeft() const403     bool FormControllerHelper::moveLeft( ) const
404     {
405         return impl_operateForm_nothrow( FormFeature::MoveToPrevious );
406     }
407 
408     //--------------------------------------------------------------------
execute(sal_Int32 _nSlotId,const::rtl::OUString & _rParamName,const Any & _rParamValue) const409     void FormControllerHelper::execute( sal_Int32 _nSlotId, const ::rtl::OUString& _rParamName, const Any& _rParamValue ) const
410     {
411         Sequence< NamedValue > aArguments(1);
412         aArguments[0].Name = _rParamName;
413         aArguments[0].Value = _rParamValue;
414 
415         impl_operateForm_nothrow( EXECUTE_ARGS, FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ), aArguments );
416     }
417 
418     //--------------------------------------------------------------------
impl_operateForm_nothrow(const FormOperation _eWhat,const sal_Int16 _nFeature,const Sequence<NamedValue> & _rArguments) const419     bool FormControllerHelper::impl_operateForm_nothrow( const FormOperation _eWhat, const sal_Int16 _nFeature,
420             const Sequence< NamedValue >& _rArguments ) const
421     {
422         if ( !m_xFormOperations.is() )
423             return false;
424 
425         Any aError;
426         bool bSuccess = false;
427         const_cast< FormControllerHelper* >( this )->m_aOperationError.clear();
428         try
429         {
430             switch ( _eWhat )
431             {
432             case COMMIT_CONTROL:
433                 bSuccess = m_xFormOperations->commitCurrentControl();
434                 break;
435 
436             case COMMIT_RECORD:
437             {
438                 sal_Bool bDummy( sal_False );
439                 bSuccess = m_xFormOperations->commitCurrentRecord( bDummy );
440             }
441             break;
442 
443             case EXECUTE:
444                 m_xFormOperations->execute( _nFeature );
445                 bSuccess = true;
446                 break;
447 
448             case EXECUTE_ARGS:
449                 m_xFormOperations->executeWithArguments( _nFeature, _rArguments );
450                 bSuccess = true;
451                 break;
452             }
453         }
454         catch ( const SQLException& )
455         {
456             aError = ::cppu::getCaughtException();
457         }
458         catch( const Exception& )
459         {
460             SQLException aFallbackError;
461             aFallbackError.Message = ::comphelper::anyToString( ::cppu::getCaughtException() );
462             aError <<= aFallbackError;
463         }
464 
465         if ( bSuccess )
466             return true;
467 
468         // display the error. Prefer the one reported in errorOccured over the one caught.
469         if ( m_aOperationError.hasValue() )
470             displayException( m_aOperationError );
471         else if ( aError.hasValue() )
472             displayException( aError );
473         else
474             OSL_ENSURE( false, "FormControllerHelper::impl_operateForm_nothrow: no success, but no error?" );
475 
476         return false;
477     }
478 
479     //--------------------------------------------------------------------
execute(sal_Int32 _nSlotId) const480     void FormControllerHelper::execute( sal_Int32 _nSlotId ) const
481     {
482         impl_operateForm_nothrow( EXECUTE, FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ),
483             Sequence< NamedValue >() );
484     }
485 
486     //--------------------------------------------------------------------
invalidateFeatures(const Sequence<::sal_Int16> & _Features)487     void SAL_CALL FormControllerHelper::invalidateFeatures( const Sequence< ::sal_Int16 >& _Features )
488     {
489         if ( !m_pInvalidationCallback )
490             // nobody's interested in ...
491             return;
492 
493         ::std::vector< sal_Int32 > aFeatures( _Features.getLength() );
494         ::std::transform(
495             _Features.getConstArray(),
496             _Features.getConstArray() + _Features.getLength(),
497             aFeatures.begin(),
498             FormFeatureToSlotId()
499         );
500 
501         m_pInvalidationCallback->invalidateFeatures( aFeatures );
502     }
503 
504     //--------------------------------------------------------------------
invalidateAllFeatures()505     void SAL_CALL FormControllerHelper::invalidateAllFeatures()
506     {
507         if ( !m_pInvalidationCallback )
508             // nobody's interested in ...
509             return;
510 
511         // actually, it's a little bit more than the supported features,
512         // but on the medium term, we are to support everything listed
513         // here
514         ::std::vector< sal_Int32 > aSupportedFeatures;
515         sal_Int32 pSupportedFeatures[] =
516         {
517             SID_FM_RECORD_FIRST,
518             SID_FM_RECORD_NEXT,
519             SID_FM_RECORD_PREV,
520             SID_FM_RECORD_LAST,
521             SID_FM_RECORD_NEW,
522             SID_FM_RECORD_DELETE,
523             SID_FM_RECORD_ABSOLUTE,
524             SID_FM_RECORD_TOTAL,
525             SID_FM_RECORD_SAVE,
526             SID_FM_RECORD_UNDO,
527             SID_FM_REMOVE_FILTER_SORT,
528             SID_FM_SORTUP,
529             SID_FM_SORTDOWN,
530             SID_FM_ORDERCRIT,
531             SID_FM_AUTOFILTER,
532             SID_FM_FILTERCRIT,
533             SID_FM_FORM_FILTERED,
534             SID_FM_REFRESH,
535             SID_FM_REFRESH_FORM_CONTROL,
536             SID_FM_SEARCH,
537             SID_FM_FILTER_START,
538             SID_FM_VIEW_AS_GRID
539         };
540         sal_Int32 nFeatureCount = sizeof( pSupportedFeatures ) / sizeof( pSupportedFeatures[ 0 ] );
541         aSupportedFeatures.resize( nFeatureCount );
542         ::std::copy( pSupportedFeatures, pSupportedFeatures + nFeatureCount, aSupportedFeatures.begin() );
543 
544         m_pInvalidationCallback->invalidateFeatures( aSupportedFeatures );
545     }
546 
547     //--------------------------------------------------------------------
errorOccured(const SQLErrorEvent & _Event)548     void SAL_CALL FormControllerHelper::errorOccured( const SQLErrorEvent& _Event )
549     {
550         OSL_ENSURE( !m_aOperationError.hasValue(), "FormControllerHelper::errorOccured: two errors during one operation?" );
551         m_aOperationError = _Event.Reason;
552     }
553 
554     //--------------------------------------------------------------------
disposing(const EventObject &)555     void SAL_CALL FormControllerHelper::disposing( const EventObject& /*_Source*/ )
556     {
557         // not interested in
558     }
559 
560     //--------------------------------------------------------------------
isInsertionRow() const561     sal_Bool FormControllerHelper::isInsertionRow() const
562     {
563         sal_Bool bIs = sal_False;
564         if ( m_xFormOperations.is() )
565             bIs = m_xFormOperations->isInsertionRow();
566         return bIs;
567     }
568 
569     //--------------------------------------------------------------------
isModifiedRow() const570     sal_Bool FormControllerHelper::isModifiedRow() const
571     {
572         sal_Bool bIs = sal_False;
573         if ( m_xFormOperations.is() )
574             bIs = m_xFormOperations->isModifiedRow();
575         return bIs;
576     }
577     //--------------------------------------------------------------------
canDoFormFilter() const578     bool FormControllerHelper::canDoFormFilter() const
579     {
580         if ( !m_xFormOperations.is() )
581             return false;
582 
583         bool bCanDo = false;
584         try
585         {
586             Reference< XPropertySet > xCursorProperties( m_xFormOperations->getCursor(), UNO_QUERY_THROW );
587 
588             bool bEscapeProcessing( false );
589             OSL_VERIFY( xCursorProperties->getPropertyValue( FM_PROP_ESCAPE_PROCESSING ) >>= bEscapeProcessing );
590 
591             ::rtl::OUString sActiveCommand;
592             OSL_VERIFY( xCursorProperties->getPropertyValue( FM_PROP_ACTIVECOMMAND ) >>= sActiveCommand );
593 
594             bool bInsertOnlyForm( false );
595             OSL_VERIFY( xCursorProperties->getPropertyValue( FM_PROP_INSERTONLY ) >>= bInsertOnlyForm );
596 
597             bCanDo = bEscapeProcessing && ( sActiveCommand.getLength() > 0 ) && !bInsertOnlyForm;
598         }
599         catch( const Exception& )
600         {
601             DBG_UNHANDLED_EXCEPTION();
602         }
603         return bCanDo;
604     }
605 
606 //........................................................................
607 }   // namespace svx
608 //........................................................................
609