24#include <svx/svxids.hrc>
26#include <formcontroller.hxx>
29#include <com/sun/star/form/runtime/FormOperations.hpp>
30#include <com/sun/star/form/runtime/FormFeature.hpp>
31#include <com/sun/star/beans/XPropertySet.hpp>
32#include <com/sun/star/sdbc/SQLException.hpp>
38#include <osl/diagnose.h>
47 using ::com::sun::star::uno::Reference;
48 using ::com::sun::star::form::runtime::XFormController;
49 using ::com::sun::star::form::runtime::FormOperations;
50 using ::com::sun::star::uno::Exception;
51 using ::com::sun::star::sdbc::XRowSet;
52 using ::com::sun::star::form::runtime::FeatureState;
53 using ::com::sun::star::uno::Any;
54 using ::com::sun::star::uno::Sequence;
55 using ::com::sun::star::beans::NamedValue;
57 using ::com::sun::star::uno::UNO_QUERY_THROW;
58 using ::com::sun::star::sdbc::SQLException;
59 using ::com::sun::star::sdb::SQLErrorEvent;
60 using ::com::sun::star::lang::EventObject;
62 namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
69 struct FeatureDescription
75 typedef ::std::vector< FeatureDescription > FeatureDescriptions;
78 const FeatureDescriptions& getFeatureDescriptions()
80 static const FeatureDescriptions s_aFeatureDescriptions({
88 { OUString(
FMURL_RECORD_SAVE), SID_FM_RECORD_SAVE, FormFeature::SaveRecordChanges },
92 SID_FM_REFRESH_FORM_CONTROL,FormFeature::RefreshCurrentControl },
93 { OUString(
FMURL_RECORD_UNDO), SID_FM_RECORD_UNDO, FormFeature::UndoRecordChanges },
96 { OUString(
FMURL_FORM_SORT), SID_FM_ORDERCRIT, FormFeature::InteractiveSort },
98 { OUString(
FMURL_FORM_FILTER), SID_FM_FILTERCRIT, FormFeature::InteractiveFilter },
102 return s_aFeatureDescriptions;
110 struct MatchFeatureDescriptionByURL
112 const OUString& m_rURL;
113 explicit MatchFeatureDescriptionByURL(
const OUString& _rURL ) :m_rURL( _rURL ) { }
115 bool operator()(
const FeatureDescription& _compare )
117 return m_rURL == _compare.sURL;
122 struct MatchFeatureDescriptionBySlotId
125 explicit MatchFeatureDescriptionBySlotId( sal_Int32 _nSlotId ) :m_nSlotId( _nSlotId ) { }
127 bool operator()(
const FeatureDescription& _compare )
129 return m_nSlotId == _compare.nSlotId;
134 struct MatchFeatureDescriptionByFormFeature
136 sal_Int32 m_nFormFeature;
137 explicit MatchFeatureDescriptionByFormFeature( sal_Int32 _nFormFeature ) :m_nFormFeature( _nFormFeature ) { }
139 bool operator()(
const FeatureDescription& _compare )
141 return m_nFormFeature == _compare.nFormFeature;
146 struct FormFeatureToSlotId
148 sal_Int32 operator()( sal_Int16 FormFeature )
158 const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
159 FeatureDescriptions::const_iterator
pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionByURL( _rMainURL ) );
160 return (
pos != rDescriptions.end() ) ?
pos->nSlotId : -1;
166 const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
167 FeatureDescriptions::const_iterator
pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionBySlotId( _nSlotId ) );
168 OSL_ENSURE(
pos != rDescriptions.end(),
"FeatureSlotTranslation::getFormFeatureForSlotId: not found!" );
169 return (
pos != rDescriptions.end() ) ?
pos->nFormFeature : -1;
175 const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
176 FeatureDescriptions::const_iterator
pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionByFormFeature( _nFormFeature ) );
177 OSL_ENSURE(
pos != rDescriptions.end(),
"FeatureSlotTranslation::getSlotIdForFormFeature: not found!" );
178 return (
pos != rDescriptions.end() ) ?
pos->nSlotId : -1;
182 :m_pInvalidationCallback( _pInvalidationCallback )
188 :m_pInvalidationCallback( nullptr )
217 :m_pInvalidationCallback( _pInvalidationCallback )
219 osl_atomic_increment( &m_refCount );
223 if ( m_xFormOperations.is() )
224 m_xFormOperations->setFeatureInvalidation(
this );
226 catch(
const Exception& )
230 osl_atomic_decrement( &m_refCount );
266 Reference< XRowSet > xCursor;
294 Sequence< NamedValue >
aArguments { { _rParamName, _rParamValue } };
300 const Sequence< NamedValue >& _rArguments )
const
306 bool bSuccess =
false;
339 catch (
const SQLException& )
342 aError = ::cppu::getCaughtException();
344 catch(
const Exception& )
347 SQLException aFallbackError;
348 aFallbackError.Message = ::comphelper::anyToString( ::cppu::getCaughtException() );
349 aError <<= aFallbackError;
358 else if ( aError.hasValue() )
361 OSL_FAIL(
"FormControllerHelper::impl_operateForm_nothrow: no success, but no error?" );
370 Sequence< NamedValue >() );
380 ::std::vector< sal_Int32 > aFeatures( Features.getLength() );
385 FormFeatureToSlotId()
401 ::std::vector< sal_Int32 > aSupportedFeatures;
402 const sal_Int32 pSupportedFeatures[] =
409 SID_FM_RECORD_DELETE,
410 SID_FM_RECORD_ABSOLUTE,
414 SID_FM_REMOVE_FILTER_SORT,
420 SID_FM_FORM_FILTERED,
422 SID_FM_REFRESH_FORM_CONTROL,
428 aSupportedFeatures.reserve(nFeatureCount);
429 aSupportedFeatures.insert( aSupportedFeatures.begin(), pSupportedFeatures, pSupportedFeatures + nFeatureCount );
437 OSL_ENSURE( !
m_aOperationError.hasValue(),
"FormControllerHelper::errorOccurred: two errors during one operation?" );
473 Reference< XPropertySet > xCursorProperties(
m_xFormOperations->getCursor(), UNO_QUERY_THROW );
475 bool bEscapeProcessing(
false );
478 OUString sActiveCommand;
481 bool bInsertOnlyForm(
false );
482 OSL_VERIFY( xCursorProperties->getPropertyValue(
FM_PROP_INSERTONLY ) >>= bInsertOnlyForm );
484 bCanDo = bEscapeProcessing && !sActiveCommand.isEmpty() && !bInsertOnlyForm;
rtl::Reference< FormControllerHelper > m_pImpl
void assign(const css::uno::Reference< css::form::runtime::XFormController > &_rxController)
assign to a controller
void dispose()
clears the instance so that it cannot be used afterwards
ControllerFeatures(IControllerFeatureInvalidation *_pInvalidationCallback)
standard ctor
IControllerFeatureInvalidation * m_pInvalidationCallback
~ControllerFeatures()
dtor
static sal_Int32 getControllerFeatureSlotIdForURL(const OUString &_rMainURL)
retrieves the feature id for a given feature URL
static sal_Int16 getFormFeatureForSlotId(sal_Int32 _nSlotId)
retrieves the css.form.runtime.FormFeature ID for a given slot ID
static sal_Int32 getSlotIdForFormFeature(sal_Int16 _nFormFeature)
retrieves the slot id for a given css.form.runtime.FormFeature ID
virtual void invalidateFeatures(const ::std::vector< sal_Int32 > &_rFeatures)=0
invalidates the given features
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr OUStringLiteral FM_PROP_ACTIVECOMMAND
constexpr OUStringLiteral FM_PROP_ESCAPE_PROCESSING
constexpr OUStringLiteral FM_PROP_INSERTONLY
constexpr OUStringLiteral FMURL_FORM_APPLY_FILTER
constexpr OUStringLiteral FMURL_FORM_AUTO_FILTER
constexpr OUStringLiteral FMURL_RECORD_MOVETONEW
constexpr OUStringLiteral FMURL_RECORD_SAVE
constexpr OUStringLiteral FMURL_FORM_RECORDCOUNT
constexpr OUStringLiteral FMURL_FORM_REMOVE_FILTER
constexpr OUStringLiteral FMURL_RECORD_MOVELAST
constexpr OUStringLiteral FMURL_FORM_REFRESH_CURRENT_CONTROL
constexpr OUStringLiteral FMURL_FORM_REFRESH
constexpr OUStringLiteral FMURL_FORM_FILTER
constexpr OUStringLiteral FMURL_RECORD_DELETE
constexpr OUStringLiteral FMURL_RECORD_MOVENEXT
constexpr OUStringLiteral FMURL_FORM_POSITION
constexpr OUStringLiteral FMURL_FORM_SORT_DOWN
constexpr OUStringLiteral FMURL_RECORD_MOVEPREV
constexpr OUStringLiteral FMURL_FORM_SORT
constexpr OUStringLiteral FMURL_RECORD_MOVEFIRST
constexpr OUStringLiteral FMURL_FORM_SORT_UP
constexpr OUStringLiteral FMURL_RECORD_UNDO
Sequence< PropertyValue > aArguments
#define SAL_N_ELEMENTS(arr)
class SAL_NO_VTABLE XPropertySet
Reference< XComponentContext > getProcessComponentContext()