23#include <formcontroller.hxx>
29#include <svx/strings.hrc>
34#include <com/sun/star/awt/FocusChangeReason.hpp>
35#include <com/sun/star/awt/XCheckBox.hpp>
36#include <com/sun/star/awt/XComboBox.hpp>
37#include <com/sun/star/awt/XListBox.hpp>
38#include <com/sun/star/awt/XVclWindowPeer.hpp>
39#include <com/sun/star/awt/TabController.hpp>
40#include <com/sun/star/beans/PropertyAttribute.hpp>
41#include <com/sun/star/container/XIdentifierReplace.hpp>
42#include <com/sun/star/form/TabulatorCycle.hpp>
43#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
44#include <com/sun/star/form/XBoundComponent.hpp>
45#include <com/sun/star/form/XBoundControl.hpp>
46#include <com/sun/star/form/XGridControl.hpp>
47#include <com/sun/star/form/XLoadable.hpp>
48#include <com/sun/star/form/XReset.hpp>
49#include <com/sun/star/form/control/FilterControl.hpp>
50#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
51#include <com/sun/star/lang/XMultiServiceFactory.hpp>
52#include <com/sun/star/lang/NoSupportException.hpp>
53#include <com/sun/star/sdb/ParametersRequest.hpp>
54#include <com/sun/star/sdb/RowChangeAction.hpp>
55#include <com/sun/star/sdb/SQLFilterOperator.hpp>
56#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
57#include <com/sun/star/sdbc/ColumnValue.hpp>
58#include <com/sun/star/task/InteractionHandler.hpp>
59#include <com/sun/star/form/runtime/FormOperations.hpp>
60#include <com/sun/star/form/runtime/FormFeature.hpp>
61#include <com/sun/star/container/XContainer.hpp>
62#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
63#include <com/sun/star/util/NumberFormatter.hpp>
64#include <com/sun/star/sdb/SQLContext.hpp>
65#include <com/sun/star/sdb/XColumn.hpp>
86#include <osl/mutex.hxx>
98css::uno::Reference< css::uno::XInterface >
107 using ::com::sun::star::sdb::XColumn;
108 using ::com::sun::star::awt::XControl;
109 using ::com::sun::star::awt::TabController;
110 using ::com::sun::star::awt::XToolkit;
111 using ::com::sun::star::awt::XWindowPeer;
112 using ::com::sun::star::form::XGrid;
114 using ::com::sun::star::uno::UNO_SET_THROW;
115 using ::com::sun::star::uno::UNO_QUERY_THROW;
116 using ::com::sun::star::container::XIndexAccess;
117 using ::com::sun::star::uno::Exception;
118 using ::com::sun::star::uno::XInterface;
119 using ::com::sun::star::uno::UNO_QUERY;
120 using ::com::sun::star::uno::Sequence;
121 using ::com::sun::star::uno::Reference;
122 using ::com::sun::star::beans::XPropertySetInfo;
123 using ::com::sun::star::beans::PropertyValue;
124 using ::com::sun::star::lang::IndexOutOfBoundsException;
125 using ::com::sun::star::sdb::XInteractionSupplyParameters;
126 using ::com::sun::star::awt::XTextComponent;
127 using ::com::sun::star::awt::XTextListener;
128 using ::com::sun::star::uno::Any;
129 using ::com::sun::star::frame::XDispatch;
130 using ::com::sun::star::lang::XMultiServiceFactory;
131 using ::com::sun::star::uno::Type;
132 using ::com::sun::star::lang::IllegalArgumentException;
133 using ::com::sun::star::sdbc::XConnection;
134 using ::com::sun::star::sdbc::XRowSet;
135 using ::com::sun::star::sdbc::XDatabaseMetaData;
136 using ::com::sun::star::util::XNumberFormatsSupplier;
137 using ::com::sun::star::util::NumberFormatter;
138 using ::com::sun::star::util::XNumberFormatter;
139 using ::com::sun::star::sdbcx::XColumnsSupplier;
140 using ::com::sun::star::container::XNameAccess;
141 using ::com::sun::star::lang::EventObject;
142 using ::com::sun::star::beans::Property;
143 using ::com::sun::star::container::XEnumeration;
144 using ::com::sun::star::form::XFormComponent;
145 using ::com::sun::star::form::runtime::XFormOperations;
146 using ::com::sun::star::form::runtime::FilterEvent;
147 using ::com::sun::star::form::runtime::XFilterControllerListener;
148 using ::com::sun::star::awt::XControlContainer;
149 using ::com::sun::star::container::XIdentifierReplace;
150 using ::com::sun::star::form::XFormControllerListener;
151 using ::com::sun::star::awt::XWindow;
152 using ::com::sun::star::sdbc::XResultSet;
153 using ::com::sun::star::awt::XControlModel;
154 using ::com::sun::star::awt::XTabControllerModel;
155 using ::com::sun::star::beans::PropertyChangeEvent;
156 using ::com::sun::star::form::validation::XValidatableFormComponent;
157 using ::com::sun::star::form::XLoadable;
158 using ::com::sun::star::form::XBoundControl;
159 using ::com::sun::star::beans::XPropertyChangeListener;
160 using ::com::sun::star::awt::TextEvent;
161 using ::com::sun::star::form::XBoundComponent;
162 using ::com::sun::star::awt::XCheckBox;
163 using ::com::sun::star::awt::XComboBox;
164 using ::com::sun::star::awt::XListBox;
165 using ::com::sun::star::awt::ItemEvent;
166 using ::com::sun::star::util::XModifyListener;
167 using ::com::sun::star::form::XReset;
168 using ::com::sun::star::frame::XDispatchProviderInterception;
169 using ::com::sun::star::form::XGridControl;
170 using ::com::sun::star::awt::XVclWindowPeer;
171 using ::com::sun::star::form::validation::XValidator;
172 using ::com::sun::star::awt::FocusEvent;
173 using ::com::sun::star::sdb::SQLContext;
174 using ::com::sun::star::container::XChild;
175 using ::com::sun::star::form::TabulatorCycle_RECORDS;
176 using ::com::sun::star::container::ContainerEvent;
177 using ::com::sun::star::lang::DisposedException;
178 using ::com::sun::star::lang::Locale;
179 using ::com::sun::star::lang::NoSupportException;
180 using ::com::sun::star::sdb::RowChangeEvent;
181 using ::com::sun::star::frame::XStatusListener;
182 using ::com::sun::star::frame::XDispatchProviderInterceptor;
183 using ::com::sun::star::sdb::SQLErrorEvent;
184 using ::com::sun::star::form::DatabaseParameterEvent;
185 using ::com::sun::star::sdb::ParametersRequest;
186 using ::com::sun::star::task::XInteractionRequest;
187 using ::com::sun::star::util::URL;
188 using ::com::sun::star::frame::FeatureStateEvent;
189 using ::com::sun::star::form::runtime::XFormControllerContext;
190 using ::com::sun::star::task::InteractionHandler;
191 using ::com::sun::star::task::XInteractionHandler;
192 using ::com::sun::star::form::runtime::FormOperations;
193 using ::com::sun::star::container::XContainer;
194 using ::com::sun::star::sdbc::SQLWarning;
196 namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue;
197 namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
198 namespace FocusChangeReason = ::com::sun::star::awt::FocusChangeReason;
199 namespace RowChangeAction = ::com::sun::star::sdb::RowChangeAction;
200 namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
227 :
nNullable( ColumnValue::NULLABLE_UNKNOWN )
240 explicit ColumnInfoCache(
const Reference< XColumnsSupplier >& _rxColSupplier );
257 :m_bControlsInitialized( false )
263 Reference< XIndexAccess > xColumns( _rxColSupplier->getColumns(), UNO_QUERY_THROW );
264 sal_Int32 nColumnCount = xColumns->getCount();
267 Reference< XPropertySet > xColumnProps;
268 for ( sal_Int32
i = 0;
i < nColumnCount; ++
i )
271 aColInfo.xColumn.set( xColumns->getByIndex(
i), UNO_QUERY_THROW );
273 xColumnProps.set( aColInfo.xColumn, UNO_QUERY_THROW );
274 OSL_VERIFY( xColumnProps->getPropertyValue(
FM_PROP_ISNULLABLE ) >>= aColInfo.nNullable );
276 OSL_VERIFY( xColumnProps->getPropertyValue(
FM_PROP_NAME ) >>= aColInfo.sName );
277 OSL_VERIFY( xColumnProps->getPropertyValue(
FM_PROP_ISREADONLY ) >>= aColInfo.bReadOnly );
291 bool lcl_isBoundTo(
const Reference< XPropertySet >& _rxControlModel,
const Reference< XInterface >& _rxNormDBField )
293 Reference< XInterface > xNormBoundField( _rxControlModel->getPropertyValue(
FM_PROP_BOUNDFIELD ), UNO_QUERY );
294 return ( xNormBoundField == _rxNormDBField );
297 bool lcl_isInputRequired(
const Reference< XPropertySet >& _rxControlModel )
299 bool bInputRequired =
false;
301 return bInputRequired;
304 void lcl_resetColumnControlInfo(
ColumnInfo& _rColInfo )
306 _rColInfo.xFirstControlWithInputRequired.clear();
307 _rColInfo.xFirstGridWithInputRequiredColumn.clear();
308 _rColInfo.nRequiredGridColumn = -1;
317 lcl_resetColumnControlInfo( rCol );
330 OSL_ENSURE( !rCol.xFirstControlWithInputRequired.is() && !rCol.xFirstGridWithInputRequiredColumn.is()
331 && ( rCol.nRequiredGridColumn == -1 ),
"ColumnInfoCache::initializeControls: called me twice?" );
333 lcl_resetColumnControlInfo( rCol );
335 Reference< XInterface > xNormColumn( rCol.xColumn, UNO_QUERY_THROW );
337 const Reference< XControl >* pControl( _rControls.getConstArray() );
338 const Reference< XControl >* pControlEnd( pControl + _rControls.getLength() );
339 for ( ; pControl != pControlEnd; ++pControl )
341 if ( !pControl->is() )
344 Reference< XPropertySet >
xModel( (*pControl)->getModel(), UNO_QUERY_THROW );
345 Reference< XPropertySetInfo > xModelPSI(
xModel->getPropertySetInfo(), UNO_SET_THROW );
348 Reference< XGrid > xGrid( *pControl, UNO_QUERY );
351 Reference< XIndexAccess > xGridColAccess(
xModel, UNO_QUERY_THROW );
352 sal_Int32 gridColCount = xGridColAccess->getCount();
353 sal_Int32 gridCol = 0;
354 for ( gridCol = 0; gridCol < gridColCount; ++gridCol )
356 Reference< XPropertySet > xGridColumnModel( xGridColAccess->getByIndex( gridCol ), UNO_QUERY_THROW );
358 if ( !lcl_isBoundTo( xGridColumnModel, xNormColumn )
359 || !lcl_isInputRequired( xGridColumnModel )
366 if ( gridCol < gridColCount )
369 rCol.xFirstGridWithInputRequiredColumn = xGrid;
370 rCol.nRequiredGridColumn = gridCol;
378 || !lcl_isBoundTo(
xModel, xNormColumn )
379 || !lcl_isInputRequired(
xModel )
386 if ( pControl == pControlEnd )
390 rCol.xFirstControlWithInputRequired = *pControl;
405 throw IndexOutOfBoundsException();
412class OParameterContinuation :
public OInteraction< XInteractionSupplyParameters >
417 OParameterContinuation() { }
419 const Sequence< PropertyValue >& getValues()
const {
return m_aValues; }
422 virtual void SAL_CALL setParameters(
const Sequence< PropertyValue >& _rValues )
override;
427void SAL_CALL OParameterContinuation::setParameters(
const Sequence< PropertyValue >& _rValues )
441 FmFieldInfo(
const Reference< XPropertySet >& _xField,
const Reference< XTextComponent >& _xText)
457 virtual OUString GetComponentServiceName()
const override {
return "Edit";}
458 virtual void SAL_CALL createPeer(
const Reference< XToolkit > & rxToolkit,
const Reference< XWindowPeer > & rParentPeer )
override;
461 virtual void ImplSetPeerProperty(
const OUString& rPropName,
const Any& rVal )
override;
466void FmXAutoControl::createPeer(
const Reference< XToolkit > & rxToolkit,
const Reference< XWindowPeer > & rParentPeer )
470 Reference< XTextComponent > xText(getPeer() , UNO_QUERY);
473 xText->setText(
SvxResId(RID_STR_AUTOFIELD));
474 xText->setEditable(
false);
479void FmXAutoControl::ImplSetPeerProperty(
const OUString& rPropName,
const Any& rVal )
496struct UpdateAllListeners
498 bool operator()(
const Reference< XDispatch >& _rxDispatcher )
const
510 ::osl::MutexGuard aGuard(
m_aMutex );
511 for (
const auto& rFeature : m_aInvalidFeatures)
513 DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( rFeature );
514 if ( aDispatcherPos != m_aFeatureDispatchers.end() )
518 UpdateAllListeners( )( aDispatcherPos->second );
526 ,OSQLParserClient( _rxORB )
532 ,m_aRowSetApproveListeners(
m_aMutex)
535 ,m_aTabActivationIdle(
"svx FormController m_aTabActivationIdle")
536 ,m_aFeatureInvalidationTimer(
"svx FormController m_aFeatureInvalidationTimer")
537 ,m_aMode( OUString(
"DataMode" ) )
538 ,m_aLoadEvent(
LINK( this, FormController, OnLoad ) )
539 ,m_aToggleEvent(
LINK( this, FormController, OnToggleAutoFields ) )
540 ,m_aActivationEvent(
LINK( this, FormController, OnActivated ) )
541 ,m_aDeactivationEvent(
LINK( this, FormController, OnDeactivated ) )
542 ,m_nCurrentFilterPosition(-1)
543 ,m_bCurrentRecordModified(false)
544 ,m_bCurrentRecordNew(false)
546 ,m_bDBConnection(false)
550 ,m_bCommitLock(false)
552 ,m_bControlsSorted(false)
554 ,m_bAttachEvents(true)
555 ,m_bDetachEvents(true)
556 ,m_bAttemptedHandlerCreation( false )
557 ,m_bSuspendFilterTextListening( false )
560 osl_atomic_increment(&m_refCount);
562 m_xTabController = TabController::create( m_xComponentContext );
563 m_xAggregate.set( m_xTabController, UNO_QUERY_THROW );
564 m_xAggregate->setDelegator( *
this );
566 osl_atomic_decrement(&m_refCount);
568 m_aTabActivationIdle.SetPriority( TaskPriority::LOWEST );
569 m_aTabActivationIdle.SetInvokeHandler(
LINK(
this, FormController, OnActivateTabOrder ) );
571 m_aFeatureInvalidationTimer.SetTimeout( 200 );
572 m_aFeatureInvalidationTimer.SetInvokeHandler(
LINK(
this, FormController, OnInvalidateFeatures ) );
576FormController::~FormController()
579 ::osl::MutexGuard aGuard(
m_aMutex );
581 m_aLoadEvent.CancelPendingCall();
582 m_aToggleEvent.CancelPendingCall();
583 m_aActivationEvent.CancelPendingCall();
584 m_aDeactivationEvent.CancelPendingCall();
586 if ( m_aTabActivationIdle.IsActive() )
587 m_aTabActivationIdle.Stop();
590 if ( m_aFeatureInvalidationTimer.IsActive() )
591 m_aFeatureInvalidationTimer.Stop();
593 disposeAllFeaturesAndDispatchers();
595 if ( m_xFormOperations.is() )
596 m_xFormOperations->dispose();
597 m_xFormOperations.clear();
600 if ( m_xAggregate.is() )
602 m_xAggregate->setDelegator(
nullptr );
603 m_xAggregate.clear();
608void SAL_CALL FormController::acquire() noexcept
610 FormController_BASE::acquire();
614void SAL_CALL FormController::release() noexcept
616 FormController_BASE::release();
620Any SAL_CALL FormController::queryInterface(
const Type& _rType )
622 Any aRet = FormController_BASE::queryInterface( _rType );
623 if ( !aRet.hasValue() )
624 aRet = OPropertySetHelper::queryInterface( _rType );
625 if ( !aRet.hasValue() )
626 aRet = m_xAggregate->queryAggregation( _rType );
633 return css::uno::Sequence<sal_Int8>();
636Sequence< Type > SAL_CALL FormController::getTypes( )
639 FormController_BASE::getTypes(),
645sal_Bool SAL_CALL FormController::supportsService(
const OUString& ServiceName)
650OUString SAL_CALL FormController::getImplementationName()
652 return "org.openoffice.comp.svx.FormController";
655Sequence< OUString> SAL_CALL FormController::getSupportedServiceNames()
659 Sequence<OUString> aNonCreatableServiceNames {
"com.sun.star.form.FormControllerDispatcher" };
662 Sequence< OUString > aCreatableServiceNames( getSupportedServiceNames_Static() );
663 return ::comphelper::concatSequences( aCreatableServiceNames, aNonCreatableServiceNames );
667sal_Bool SAL_CALL FormController::approveReset(
const EventObject& )
673void SAL_CALL FormController::resetted(
const EventObject& rEvent)
676 if (getCurrentControl().is() && (getCurrentControl()->getModel() == rEvent.Source))
681Sequence< OUString>
const & FormController::getSupportedServiceNames_Static()
683 static Sequence< OUString>
const aServices
685 "com.sun.star.form.runtime.FormController",
686 "com.sun.star.awt.control.TabController"
694 struct ResetComponentText
696 void operator()(
const Reference< XTextComponent >& _rxText )
698 _rxText->setText( OUString() );
702 struct RemoveComponentTextListener
704 explicit RemoveComponentTextListener(
const Reference< XTextListener >& _rxListener )
709 void operator()(
const Reference< XTextComponent >& _rxText )
720void FormController::impl_setTextOnAllFilter_throw()
722 m_bSuspendFilterTextListening =
true;
726 ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), ResetComponentText() );
728 if ( m_aFilterRows.empty() )
732 if ( m_nCurrentFilterPosition < 0 )
737 "FormController::impl_setTextOnAllFilter_throw: m_nCurrentFilterPosition too big" );
741 FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ];
742 for (
const auto& rEntry : rRow)
744 rEntry.first->setText( rEntry.second );
750sal_Bool FormController::convertFastPropertyValue( Any & , Any & ,
751 sal_Int32 ,
const Any& )
757void FormController::setFastPropertyValue_NoBroadcast( sal_Int32 ,
const Any& )
762void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle )
const
768 OUStringBuffer aFilter;
769 Reference<XConnection> xConnection(
getConnection(Reference< XRowSet>(m_xModelAsIndex, UNO_QUERY)));
770 if (xConnection.is())
772 Reference< XNumberFormatsSupplier> xFormatSupplier(
getNumberFormats( xConnection,
true ) );
773 Reference< XNumberFormatter> xFormatter = NumberFormatter::create(m_xComponentContext);
774 xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
784 OUStringBuffer aRowFilter;
785 for ( FmFilterRow::const_iterator condition = rRow.begin(); condition != rRow.end(); ++condition )
788 Reference< XControl > xControl( condition->first, UNO_QUERY_THROW );
789 Reference< XPropertySet > xModelProps( xControl->getModel(), UNO_QUERY_THROW );
790 Reference< XPropertySet > xField( xModelProps->getPropertyValue(
FM_PROP_BOUNDFIELD ), UNO_QUERY_THROW );
792 OUString sFilterValue( condition->second );
795 const std::unique_ptr< OSQLParseNode > pParseNode =
796 predicateTree( sErrorMsg, sFilterValue, xFormatter, xField );
797 OSL_ENSURE( pParseNode !=
nullptr,
"FormController::getFastPropertyValue: could not parse the field value predicate!" );
798 if ( pParseNode !=
nullptr )
802 pParseNode->parseNodeToStr( sCriteria, xConnection );
803 if ( condition != rRow.begin() )
804 aRowFilter.append(
" AND " );
805 aRowFilter.append( sCriteria );
808 if ( !aRowFilter.isEmpty() )
810 if ( !aFilter.isEmpty() )
811 aFilter.append(
" OR " );
813 aFilter.append(
"( " + aRowFilter +
" )" );
817 catch(
const Exception& )
820 aFilter.setLength(0);
823 rValue <<= aFilter.makeStringAndClear();
828 rValue <<= m_xFormOperations;
834Reference< XPropertySetInfo > FormController::getPropertySetInfo()
836 static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
841void FormController::fillProperties(
842 Sequence< Property >& _rProps,
843 Sequence< Property >&
848 Property* pDesc = _rProps.getArray();
852 PropertyAttribute::READONLY);
855 PropertyAttribute::READONLY);
861 return *getArrayHelper();
866void SAL_CALL FormController::addFilterControllerListener(
const Reference< XFilterControllerListener >& Listener )
868 m_aFilterListeners.addInterface( Listener );
872void SAL_CALL FormController::removeFilterControllerListener(
const Reference< XFilterControllerListener >& Listener )
874 m_aFilterListeners.removeInterface( Listener );
878::sal_Int32 SAL_CALL FormController::getFilterComponents()
880 ::osl::MutexGuard aGuard(
m_aMutex );
881 impl_checkDisposed_throw();
883 return m_aFilterComponents.size();
887::sal_Int32 SAL_CALL FormController::getDisjunctiveTerms()
889 ::osl::MutexGuard aGuard(
m_aMutex );
890 impl_checkDisposed_throw();
892 return m_aFilterRows.size();
896void SAL_CALL FormController::setPredicateExpression( ::sal_Int32
Component, ::sal_Int32 Term,
const OUString& PredicateExpression )
898 ::osl::MutexGuard aGuard(
m_aMutex );
899 impl_checkDisposed_throw();
901 if ( (
Component < 0 ) || (
Component >= getFilterComponents() ) || ( Term < 0 ) || ( Term >= getDisjunctiveTerms() ) )
902 throw IndexOutOfBoundsException( OUString(), *
this );
904 Reference< XTextComponent > xText( m_aFilterComponents[
Component ] );
905 xText->setText( PredicateExpression );
908 if ( !PredicateExpression.isEmpty() )
909 rFilterRow[ xText ] = PredicateExpression;
911 rFilterRow.erase( xText );
915Reference< XControl > FormController::getFilterComponent( ::sal_Int32
Component )
917 ::osl::MutexGuard aGuard(
m_aMutex );
918 impl_checkDisposed_throw();
921 throw IndexOutOfBoundsException( OUString(), *
this );
923 return Reference< XControl >( m_aFilterComponents[
Component ], UNO_QUERY );
927Sequence< Sequence< OUString > > FormController::getPredicateExpressions()
929 ::osl::MutexGuard aGuard(
m_aMutex );
930 impl_checkDisposed_throw();
932 Sequence< Sequence< OUString > > aExpressions( m_aFilterRows.size() );
933 auto aExpressionsRange = asNonConstRange(aExpressions);
934 sal_Int32 termIndex = 0;
937 Sequence< OUString > aConjunction( m_aFilterComponents.size() );
938 auto aConjunctionRange = asNonConstRange(aConjunction);
939 sal_Int32 componentIndex = 0;
940 for (
const auto& rComp : m_aFilterComponents)
942 FmFilterRow::const_iterator predicate = rRow.find( rComp );
943 if ( predicate != rRow.end() )
944 aConjunctionRange[ componentIndex ] = predicate->second;
948 aExpressionsRange[ termIndex ] = aConjunction;
956void SAL_CALL FormController::removeDisjunctiveTerm( ::sal_Int32 Term )
959 ::osl::ClearableMutexGuard aGuard(
m_aMutex );
960 impl_checkDisposed_throw();
962 if ( ( Term < 0 ) || ( Term >= getDisjunctiveTerms() ) )
963 throw IndexOutOfBoundsException( OUString(), *
this );
966 if ( Term == m_nCurrentFilterPosition )
968 if ( m_nCurrentFilterPosition < sal_Int32( m_aFilterRows.size() - 1 ) )
969 ++m_nCurrentFilterPosition;
971 --m_nCurrentFilterPosition;
974 FmFilterRows::iterator
pos = m_aFilterRows.begin() + Term;
975 m_aFilterRows.erase(
pos );
978 if ( Term < m_nCurrentFilterPosition )
979 --m_nCurrentFilterPosition;
981 SAL_WARN_IF( !( ( m_nCurrentFilterPosition < 0 ) != ( m_aFilterRows.empty() ) ),
982 "svx.form",
"FormController::removeDisjunctiveTerm: inconsistency!" );
985 impl_setTextOnAllFilter_throw();
989 aEvent.DisjunctiveTerm = Term;
993 m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermRemoved,
aEvent );
997void SAL_CALL FormController::appendEmptyDisjunctiveTerm()
1000 ::osl::ClearableMutexGuard aGuard(
m_aMutex );
1001 impl_checkDisposed_throw();
1003 impl_appendEmptyFilterRow( aGuard );
1008::sal_Int32 SAL_CALL FormController::getActiveTerm()
1010 ::osl::MutexGuard aGuard(
m_aMutex );
1011 impl_checkDisposed_throw();
1013 return m_nCurrentFilterPosition;
1017void SAL_CALL FormController::setActiveTerm( ::sal_Int32 ActiveTerm )
1019 ::osl::MutexGuard aGuard(
m_aMutex );
1020 impl_checkDisposed_throw();
1022 if ( ( ActiveTerm < 0 ) || ( ActiveTerm >= getDisjunctiveTerms() ) )
1023 throw IndexOutOfBoundsException( OUString(), *
this );
1025 if ( ActiveTerm == getActiveTerm() )
1028 m_nCurrentFilterPosition = ActiveTerm;
1029 impl_setTextOnAllFilter_throw();
1036 ::osl::MutexGuard aGuard(
m_aMutex );
1037 return !m_aChildren.empty();
1041Type SAL_CALL FormController::getElementType()
1049Reference< XEnumeration > SAL_CALL FormController::createEnumeration()
1051 ::osl::MutexGuard aGuard(
m_aMutex );
1052 return new ::comphelper::OEnumerationByIndex(
this);
1057sal_Int32 SAL_CALL FormController::getCount()
1059 ::osl::MutexGuard aGuard(
m_aMutex );
1060 return m_aChildren.size();
1064Any SAL_CALL FormController::getByIndex(sal_Int32
Index)
1066 ::osl::MutexGuard aGuard(
m_aMutex );
1069 throw IndexOutOfBoundsException();
1071 return Any( m_aChildren[
Index ] );
1076void SAL_CALL FormController::disposing(
const EventObject& e)
1079 ::osl::MutexGuard aGuard( m_aMutex );
1080 Reference< XControlContainer > xContainer(e.Source, UNO_QUERY);
1081 if (xContainer.is())
1083 setContainer(Reference< XControlContainer > ());
1088 Reference< XControl > xControl(e.Source, UNO_QUERY);
1091 if (getContainer().is())
1092 removeControl(xControl);
1099void FormController::disposeAllFeaturesAndDispatchers()
1101 for (
auto& rDispatcher : m_aFeatureDispatchers)
1105 ::comphelper::disposeComponent( rDispatcher.second );
1112 m_aFeatureDispatchers.clear();
1116void FormController::disposing()
1118 EventObject aEvt( *
this );
1121 if ( m_xActiveControl.is() )
1122 m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated, aEvt );
1125 m_aActivateListeners.disposeAndClear(aEvt);
1126 m_aModifyListeners.disposeAndClear(aEvt);
1127 m_aErrorListeners.disposeAndClear(aEvt);
1128 m_aDeleteListeners.disposeAndClear(aEvt);
1129 m_aRowSetApproveListeners.disposeAndClear(aEvt);
1130 m_aParameterListeners.disposeAndClear(aEvt);
1131 m_aFilterListeners.disposeAndClear(aEvt);
1133 removeBoundFieldListener();
1136 m_aControlBorderManager.restoreAll();
1138 m_aFilterRows.clear();
1140 ::osl::MutexGuard aGuard(
m_aMutex );
1141 m_xActiveControl =
nullptr;
1142 implSetCurrentControl(
nullptr );
1145 for (
const auto& rpChild : m_aChildren)
1148 Reference< XFormComponent > xForm(rpChild->getModel(), UNO_QUERY);
1149 sal_uInt32
nPos = m_xModelAsIndex->getCount();
1150 Reference< XFormComponent > xTemp;
1154 m_xModelAsIndex->getByIndex( --
nPos ) >>= xTemp;
1155 if ( xForm.get() == xTemp.get() )
1157 Reference< XInterface > xIfc( rpChild, UNO_QUERY );
1158 m_xModelAsManager->detach(
nPos, xIfc );
1163 Reference< XComponent > (rpChild, UNO_QUERY_THROW)->dispose();
1165 m_aChildren.clear();
1167 disposeAllFeaturesAndDispatchers();
1169 if ( m_xFormOperations.is() )
1170 m_xFormOperations->dispose();
1171 m_xFormOperations.clear();
1173 if (m_bDBConnection)
1176 setContainer(
nullptr );
1177 setModel(
nullptr );
1178 setParent(
nullptr );
1180 ::comphelper::disposeComponent( m_xComposer );
1182 m_bDBConnection =
false;
1188 bool lcl_shouldUseDynamicControlBorder(
const Reference< XInterface >& _rxForm,
const Any& _rDynamicColorProp )
1190 bool bDoUse =
false;
1191 if ( !( _rDynamicColorProp >>= bDoUse ) )
1193 DocumentType eDocType = DocumentClassification::classifyHostDocument( _rxForm );
1201void SAL_CALL FormController::propertyChange(
const PropertyChangeEvent& evt)
1203 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1206 Reference<XPropertySet> xOldBound;
1207 evt.OldValue >>= xOldBound;
1208 if ( !xOldBound.is() && evt.NewValue.hasValue() )
1210 Reference< XControlModel > xControlModel(evt.Source,UNO_QUERY);
1211 Reference< XControl > xControl = findControl(m_aControls,xControlModel,
false,
false);
1212 if ( xControl.is() )
1214 startControlModifyListening( xControl );
1215 Reference<XPropertySet> xProp(xControlModel,UNO_QUERY);
1225 if (bModifiedChanged || bNewChanged)
1227 ::osl::MutexGuard aGuard(
m_aMutex );
1228 if (bModifiedChanged)
1229 m_bCurrentRecordModified = ::comphelper::getBOOL(evt.NewValue);
1231 m_bCurrentRecordNew = ::comphelper::getBOOL(evt.NewValue);
1234 if (m_bLocked != determineLockState())
1236 m_bLocked = !m_bLocked;
1238 if (isListeningForChanges())
1245 m_aToggleEvent.Call();
1247 if (!m_bCurrentRecordModified)
1248 m_bModified =
false;
1252 bool bEnable = lcl_shouldUseDynamicControlBorder( evt.Source, evt.NewValue );
1255 m_aControlBorderManager.enableDynamicBorderColor();
1256 if ( m_xActiveControl.is() )
1257 m_aControlBorderManager.focusGained( m_xActiveControl );
1261 m_aControlBorderManager.disableDynamicBorderColor();
1268bool FormController::replaceControl(
const Reference< XControl >& _rxExistentControl,
const Reference< XControl >& _rxNewControl )
1270 bool bSuccess =
false;
1273 Reference< XIdentifierReplace > xContainer( getContainer(), UNO_QUERY );
1274 DBG_ASSERT( xContainer.is(),
"FormController::replaceControl: yes, it's not required by the service description, but XIdentifierReplace would be nice!" );
1275 if ( xContainer.is() )
1278 const Sequence< sal_Int32 > aIdentifiers( xContainer->getIdentifiers() );
1279 const sal_Int32* pIdentifiers = std::find_if(aIdentifiers.begin(), aIdentifiers.end(),
1280 [&xContainer, &_rxExistentControl](
const sal_Int32
nId) {
1281 Reference< XControl > xCheck( xContainer->getByIdentifier( nId ), UNO_QUERY );
1282 return xCheck == _rxExistentControl;
1284 DBG_ASSERT( pIdentifiers != aIdentifiers.end(),
"FormController::replaceControl: did not find the control in the container!" );
1285 if ( pIdentifiers != aIdentifiers.end() )
1287 bool bReplacedWasActive = ( m_xActiveControl.get() == _rxExistentControl.get() );
1288 bool bReplacedWasCurrent = ( m_xCurrentControl.get() == _rxExistentControl.get() );
1290 if ( bReplacedWasActive )
1292 m_xActiveControl =
nullptr;
1293 implSetCurrentControl(
nullptr );
1295 else if ( bReplacedWasCurrent )
1297 implSetCurrentControl( _rxNewControl );
1301 _rxNewControl->setModel( _rxExistentControl->getModel() );
1303 xContainer->replaceByIdentifer( *pIdentifiers,
Any( _rxNewControl ) );
1306 if ( bReplacedWasActive )
1308 Reference< XWindow > xControlWindow( _rxNewControl, UNO_QUERY );
1309 if ( xControlWindow.is() )
1310 xControlWindow->setFocus();
1320 Reference< XControl > xDisposeIt( bSuccess ? _rxExistentControl : _rxNewControl );
1321 ::comphelper::disposeComponent( xDisposeIt );
1326void FormController::toggleAutoFields(
bool bAutoFields)
1328 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1331 Sequence< Reference< XControl > > aControlsCopy( m_aControls );
1332 const Reference< XControl >* pControls = aControlsCopy.getConstArray();
1333 sal_Int32 nControls = aControlsCopy.getLength();
1339 m_bAttachEvents =
false;
1340 for (sal_Int32
i = nControls;
i > 0;)
1342 Reference< XControl > xControl = pControls[--
i];
1345 Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
1349 Reference< XPropertySet > xField;
1358 replaceControl( xControl,
new FmXAutoControl() );
1363 m_bAttachEvents =
true;
1367 m_bDetachEvents =
false;
1368 for (sal_Int32
i = nControls;
i > 0;)
1370 Reference< XControl > xControl = pControls[--
i];
1373 Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
1377 Reference< XPropertySet > xField;
1389 replaceControl( xControl, xNewControl );
1394 m_bDetachEvents =
true;
1401 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1403 toggleAutoFields(m_bCurrentRecordNew);
1407void SAL_CALL FormController::textChanged(
const TextEvent& e)
1410 ::osl::ClearableMutexGuard aGuard(
m_aMutex );
1411 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1412 if ( !m_bFiltering )
1418 if ( m_bSuspendFilterTextListening )
1421 Reference< XTextComponent > xText(e.Source,UNO_QUERY);
1422 OUString aText = xText->getText();
1424 if ( m_aFilterRows.empty() )
1425 appendEmptyDisjunctiveTerm();
1428 if ( ( m_nCurrentFilterPosition < 0 ) || (
o3tl::make_unsigned(m_nCurrentFilterPosition) >= m_aFilterRows.size() ) )
1430 OSL_ENSURE(
false,
"FormController::textChanged: m_nCurrentFilterPosition is wrong!" );
1434 FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ];
1437 if (!aText.isEmpty())
1438 rRow[xText] = aText;
1442 FmFilterRow::iterator iter = rRow.find(xText);
1444 if (iter != rRow.end())
1451 aEvent.FilterComponent = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xText ) - m_aFilterComponents.begin();
1452 aEvent.DisjunctiveTerm = getActiveTerm();
1453 aEvent.PredicateExpression = aText;
1459 m_aFilterListeners.notifyEach( &XFilterControllerListener::predicateExpressionChanged,
aEvent );
1463void SAL_CALL FormController::itemStateChanged(
const ItemEvent& )
1465 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1470void SAL_CALL FormController::addModifyListener(
const Reference< XModifyListener > & l)
1472 ::osl::MutexGuard aGuard(
m_aMutex );
1473 impl_checkDisposed_throw();
1474 m_aModifyListeners.addInterface( l );
1477void FormController::removeModifyListener(
const Reference< XModifyListener > & l)
1479 ::osl::MutexGuard aGuard(
m_aMutex );
1480 impl_checkDisposed_throw();
1481 m_aModifyListeners.removeInterface( l );
1485void FormController::modified(
const EventObject& _rEvent )
1487 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1491 if ( _rEvent.Source != m_xActiveControl )
1499 Reference< XWindow > xControlWindow( _rEvent.Source, UNO_QUERY_THROW );
1500 xControlWindow->setFocus();
1511void FormController::impl_checkDisposed_throw()
const
1513 if ( impl_isDisposed_nofail() )
1514 throw DisposedException( OUString(), *
const_cast< FormController*
>(
this ) );
1517void FormController::impl_onModify()
1519 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1522 ::osl::MutexGuard aGuard(
m_aMutex );
1527 EventObject aEvt(getXWeak());
1528 m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt );
1533 m_aFilterRows.push_back( _row );
1535 if ( m_aFilterRows.size() == 1 )
1537 OSL_ENSURE( m_nCurrentFilterPosition == -1,
"FormController::impl_addFilterRow: inconsistency!" );
1538 m_nCurrentFilterPosition = 0;
1542void FormController::impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify )
1550 aEvent.DisjunctiveTerm =
static_cast<sal_Int32
>(m_aFilterRows.size()) - 1;
1551 _rClearBeforeNotify.clear();
1553 m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermAdded,
aEvent );
1556bool FormController::determineLockState()
const
1558 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1563 Reference< XResultSet > xResultSet(m_xModelAsIndex, UNO_QUERY);
1564 if (m_bFiltering || !xResultSet.is() || !
isRowSetAlive(xResultSet))
1567 return !(m_bCanInsert && m_bCurrentRecordNew)
1568 && (xResultSet->isBeforeFirst() || xResultSet->isAfterLast() || xResultSet->rowDeleted() || !m_bCanUpdate);
1572void FormController::focusGained(
const FocusEvent& e)
1575 ::osl::ClearableMutexGuard aGuard(
m_aMutex );
1576 impl_checkDisposed_throw();
1578 m_aControlBorderManager.focusGained( e.Source );
1580 Reference< XControl > xControl(e.Source, UNO_QUERY);
1581 if (m_bDBConnection)
1586 m_bCommitLock = m_bCommitLock && xControl.get() != m_xCurrentControl.get();
1596 if ( ( m_bModified || m_bFiltering )
1597 && m_xCurrentControl.is()
1598 && ( ( xControl.get() != m_xCurrentControl.get() )
1599 || ( ( e.FocusFlags & FocusChangeReason::AROUND )
1600 && ( m_bCycle || m_bFiltering )
1606#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
1607 Reference< XBoundControl > xLockingTest(m_xCurrentControl, UNO_QUERY);
1608 bool bControlIsLocked = xLockingTest.is() && xLockingTest->getLock();
1609 assert(!bControlIsLocked &&
"FormController::Gained: I'm modified and the current control is locked ? How this ?");
1613 DBG_ASSERT(m_xCurrentControl.is(),
"no CurrentControl set");
1615 Reference< XBoundComponent > xBound(m_xCurrentControl, UNO_QUERY);
1616 if (!xBound.is() && m_xCurrentControl.is())
1617 xBound.set(m_xCurrentControl->getModel(), UNO_QUERY);
1620 m_bCommitLock =
true;
1623 if (xBound.is() && !xBound->commit())
1627 Reference< XWindow > xWindow(m_xCurrentControl, UNO_QUERY);
1629 xWindow->setFocus();
1634 m_bModified =
false;
1635 m_bCommitLock =
false;
1639 if (!m_bFiltering && m_bCycle && (e.FocusFlags & FocusChangeReason::AROUND) && m_xCurrentControl.is())
1641 OSL_ENSURE( m_xFormOperations.is(),
"FormController::focusGained: hmm?" );
1645 if ( e.FocusFlags & FocusChangeReason::FORWARD )
1647 if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToNext ) )
1648 m_xFormOperations->execute( FormFeature::MoveToNext );
1652 if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToPrevious ) )
1653 m_xFormOperations->execute( FormFeature::MoveToPrevious );
1665 if ( ( m_xActiveControl == xControl )
1666 && ( xControl == m_xCurrentControl )
1669 DBG_ASSERT(m_xCurrentControl.is(),
"No CurrentControl selected");
1673 bool bActivated = !m_xActiveControl.is() && xControl.is();
1675 m_xActiveControl = xControl;
1677 implSetCurrentControl( xControl );
1678 SAL_WARN_IF( !m_xCurrentControl.is(),
"svx.form",
"implSetCurrentControl did nonsense!" );
1683 m_aActivationEvent.Call();
1687 m_aModifyListeners.notifyEach( &XModifyListener::modified, EventObject( *
this ) );
1691 if ( m_bDBConnection && !m_bFiltering )
1692 implInvalidateCurrentControlDependentFeatures();
1694 if ( !m_xCurrentControl.is() )
1698 Reference< XFormControllerContext > xContext( m_xFormControllerContext );
1699 Reference< XControl > xCurrentControl( m_xCurrentControl );
1703 if ( xContext.is() )
1704 xContext->makeVisible( xCurrentControl );
1711 m_aActivateListeners.notifyEach( &XFormControllerListener::formActivated,
aEvent );
1718 m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated,
aEvent );
1721void FormController::focusLost(
const FocusEvent& e)
1723 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1725 m_aControlBorderManager.focusLost( e.Source );
1727 Reference< XWindowPeer > xNext(e.NextFocus, UNO_QUERY);
1731 Reference< XControl > xNextControl = isInList(xNext);
1732 if (!xNextControl.is())
1734 m_xActiveControl =
nullptr;
1735 m_aDeactivationEvent.Call();
1739void SAL_CALL FormController::mousePressed(
const awt::MouseEvent& )
1744void SAL_CALL FormController::mouseReleased(
const awt::MouseEvent& )
1749void SAL_CALL FormController::mouseEntered(
const awt::MouseEvent& _rEvent )
1751 m_aControlBorderManager.mouseEntered( _rEvent.Source );
1754void SAL_CALL FormController::mouseExited(
const awt::MouseEvent& _rEvent )
1756 m_aControlBorderManager.mouseExited( _rEvent.Source );
1759void SAL_CALL FormController::componentValidityChanged(
const EventObject& _rSource )
1761 Reference< XControl > xControl( findControl( m_aControls, Reference< XControlModel >( _rSource.Source, UNO_QUERY ),
false,
false ) );
1762 Reference< XValidatableFormComponent > xValidatable( _rSource.Source, UNO_QUERY );
1764 OSL_ENSURE( xControl.is() && xValidatable.is(),
"FormController::componentValidityChanged: huh?" );
1766 if ( xControl.is() && xValidatable.is() )
1767 m_aControlBorderManager.validityChanged( xControl, xValidatable );
1771void FormController::setModel(
const Reference< XTabControllerModel > & Model)
1773 ::osl::MutexGuard aGuard(
m_aMutex );
1774 impl_checkDisposed_throw();
1776 DBG_ASSERT(m_xTabController.is(),
"FormController::setModel : invalid aggregate !");
1781 if (m_xModelAsIndex.is())
1783 if (m_bDBConnection)
1786 EventObject aEvt(m_xModelAsIndex);
1790 Reference< XLoadable > xForm(m_xModelAsIndex, UNO_QUERY);
1792 xForm->removeLoadListener(
this);
1794 Reference< XSQLErrorBroadcaster > xBroadcaster(m_xModelAsIndex, UNO_QUERY);
1795 if (xBroadcaster.is())
1796 xBroadcaster->removeSQLErrorListener(
this);
1798 Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(m_xModelAsIndex, UNO_QUERY);
1799 if (xParamBroadcaster.is())
1800 xParamBroadcaster->removeParameterListener(
this);
1804 disposeAllFeaturesAndDispatchers();
1806 if ( m_xFormOperations.is() )
1807 m_xFormOperations->dispose();
1808 m_xFormOperations.clear();
1811 if (m_xTabController.is())
1812 m_xTabController->setModel(
Model);
1813 m_xModelAsIndex.set(
Model, UNO_QUERY);
1814 m_xModelAsManager.set(
Model, UNO_QUERY);
1817 if (!m_xModelAsIndex.is() || !m_xModelAsManager.is())
1819 m_xModelAsManager =
nullptr;
1820 m_xModelAsIndex =
nullptr;
1823 if (m_xModelAsIndex.is())
1826 m_xFormOperations = FormOperations::createWithFormController(
m_xComponentContext,
this );
1827 m_xFormOperations->setFeatureInvalidation(
this );
1830 Reference< XLoadable > xForm(
Model, UNO_QUERY);
1832 xForm->addLoadListener(
this);
1834 Reference< XSQLErrorBroadcaster > xBroadcaster(
Model, UNO_QUERY);
1835 if (xBroadcaster.is())
1836 xBroadcaster->addSQLErrorListener(
this);
1838 Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(
Model, UNO_QUERY);
1839 if (xParamBroadcaster.is())
1840 xParamBroadcaster->addParameterListener(
this);
1844 Reference< XLoadable > xCursor(m_xModelAsIndex, UNO_QUERY);
1845 if (xCursor.is() && xCursor->isLoaded())
1847 EventObject aEvt(xCursor);
1851 Reference< XPropertySet > xModelProps( m_xModelAsIndex, UNO_QUERY );
1852 Reference< XPropertySetInfo > xPropInfo( xModelProps->getPropertySetInfo() );
1860 bool bEnableDynamicControlBorder = lcl_shouldUseDynamicControlBorder(
1862 if ( bEnableDynamicControlBorder )
1863 m_aControlBorderManager.enableDynamicBorderColor();
1865 m_aControlBorderManager.disableDynamicBorderColor();
1884Reference< XTabControllerModel > FormController::getModel()
1886 ::osl::MutexGuard aGuard(
m_aMutex );
1887 impl_checkDisposed_throw();
1889 DBG_ASSERT(m_xTabController.is(),
"FormController::getModel : invalid aggregate !");
1890 if (!m_xTabController.is())
1891 return Reference< XTabControllerModel > ();
1892 return m_xTabController->getModel();
1896void FormController::addToEventAttacher(
const Reference< XControl > & xControl)
1898 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1899 OSL_ENSURE( xControl.is(),
"FormController::addToEventAttacher: invalid control - how did you reach this?" );
1900 if ( !xControl.is() )
1904 Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY);
1905 if (!(xComp.is() && m_xModelAsIndex.is()))
1909 sal_uInt32
nPos = m_xModelAsIndex->getCount();
1910 Reference< XFormComponent > xTemp;
1913 m_xModelAsIndex->getByIndex(--
nPos) >>= xTemp;
1914 if (xComp.get() == xTemp.get())
1916 m_xModelAsManager->attach(
nPos, Reference<XInterface>( xControl, UNO_QUERY ),
Any(xControl) );
1923void FormController::removeFromEventAttacher(
const Reference< XControl > & xControl)
1925 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1926 OSL_ENSURE( xControl.is(),
"FormController::removeFromEventAttacher: invalid control - how did you reach this?" );
1927 if ( !xControl.is() )
1931 Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY);
1932 if ( !(xComp.is() && m_xModelAsIndex.is()) )
1936 sal_uInt32
nPos = m_xModelAsIndex->getCount();
1937 Reference< XFormComponent > xTemp;
1940 m_xModelAsIndex->getByIndex(--
nPos) >>= xTemp;
1941 if (xComp.get() == xTemp.get())
1943 m_xModelAsManager->detach(
nPos, Reference<XInterface>( xControl, UNO_QUERY ) );
1950void FormController::setContainer(
const Reference< XControlContainer > & xContainer)
1952 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
1953 Reference< XTabControllerModel > xTabModel(getModel());
1954 DBG_ASSERT(xTabModel.is() || !xContainer.is(),
"No Model defined");
1956 DBG_ASSERT(m_xTabController.is(),
"FormController::setContainer : invalid aggregate !");
1958 ::osl::MutexGuard aGuard(
m_aMutex );
1959 Reference< XContainer > xCurrentContainer;
1960 if (m_xTabController.is())
1961 xCurrentContainer.set(m_xTabController->getContainer(), UNO_QUERY);
1962 if (xCurrentContainer.is())
1964 xCurrentContainer->removeContainerListener(
this);
1966 if ( m_aTabActivationIdle.IsActive() )
1967 m_aTabActivationIdle.Stop();
1970 ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener(
this ) );
1971 m_aFilterComponents.clear();
1974 for (
const Reference< XControl >& rControl : std::as_const(m_aControls) )
1975 implControlRemoved( rControl,
true );
1978 if (m_bDBConnection && isListeningForChanges())
1981 m_aControls.realloc( 0 );
1984 if (m_xTabController.is())
1985 m_xTabController->setContainer(xContainer);
1988 if (xContainer.is() && xTabModel.is())
1990 const Sequence< Reference< XControlModel > > aModels = xTabModel->getControlModels();
1991 Sequence< Reference< XControl > > aAllControls = xContainer->getControls();
1993 sal_Int32
nCount = aModels.getLength();
1994 m_aControls = Sequence< Reference< XControl > >(
nCount );
1995 Reference< XControl > * pControls = m_aControls.getArray();
1999 for (
const Reference< XControlModel >& rModel : aModels )
2001 Reference< XControl > xControl = findControl( aAllControls, rModel,
false,
true );
2002 if ( xControl.is() )
2004 pControls[j++] = xControl;
2005 implControlInserted( xControl,
true );
2011 m_aControls.realloc(j);
2014 Reference< XContainer > xNewContainer(xContainer, UNO_QUERY);
2015 if (xNewContainer.is())
2016 xNewContainer->addContainerListener(
this);
2019 if (m_bDBConnection)
2021 m_bLocked = determineLockState();
2028 m_bControlsSorted =
true;
2032Reference< XControlContainer > FormController::getContainer()
2034 ::osl::MutexGuard aGuard(
m_aMutex );
2035 impl_checkDisposed_throw();
2037 DBG_ASSERT(m_xTabController.is(),
"FormController::getContainer : invalid aggregate !");
2038 if (!m_xTabController.is())
2039 return Reference< XControlContainer > ();
2040 return m_xTabController->getContainer();
2044Sequence< Reference< XControl > > FormController::getControls()
2046 ::osl::MutexGuard aGuard(
m_aMutex );
2047 impl_checkDisposed_throw();
2049 if (!m_bControlsSorted)
2051 Reference< XTabControllerModel >
xModel = getModel();
2055 const Sequence< Reference< XControlModel > > aControlModels =
xModel->getControlModels();
2056 sal_Int32 nModels = aControlModels.getLength();
2058 Sequence< Reference< XControl > > aNewControls(nModels);
2060 Reference< XControl > * pControls = aNewControls.getArray();
2061 Reference< XControl > xControl;
2065 for (
const Reference< XControlModel >& rModel : aControlModels )
2067 xControl = findControl( m_aControls, rModel,
true,
true );
2068 if ( xControl.is() )
2069 pControls[j++] = xControl;
2074 aNewControls.realloc( j );
2076 m_aControls = aNewControls;
2077 m_bControlsSorted =
true;
2083void FormController::autoTabOrder()
2085 ::osl::MutexGuard aGuard(
m_aMutex );
2086 impl_checkDisposed_throw();
2088 DBG_ASSERT(m_xTabController.is(),
"FormController::autoTabOrder : invalid aggregate !");
2089 if (m_xTabController.is())
2090 m_xTabController->autoTabOrder();
2094void FormController::activateTabOrder()
2096 ::osl::MutexGuard aGuard(
m_aMutex );
2097 impl_checkDisposed_throw();
2099 DBG_ASSERT(m_xTabController.is(),
"FormController::activateTabOrder : invalid aggregate !");
2100 if (m_xTabController.is())
2101 m_xTabController->activateTabOrder();
2105void FormController::setControlLock(
const Reference< XControl > & xControl)
2107 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2108 bool bLocked = isLocked();
2113 Reference< XBoundControl > xBound(xControl, UNO_QUERY);
2114 if (!(xBound.is() &&
2115 ( (bLocked && bLocked !=
bool(xBound->getLock())) ||
2120 Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
2127 bTouch = ::comphelper::getBOOL(xSet->getPropertyValue(
FM_PROP_ENABLED));
2134 Reference< XPropertySet > xField;
2140 xBound->setLock(bLocked);
2146 if (aVal.hasValue() && ::comphelper::getBOOL(aVal))
2147 xBound->setLock(
true);
2149 xBound->setLock(bLocked);
2160void FormController::setLocks()
2162 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2164 for (
const Reference< XControl >& rControl : std::as_const(m_aControls) )
2165 setControlLock( rControl );
2171 bool lcl_shouldListenForModifications(
const Reference< XControl >& _rxControl,
const Reference< XPropertyChangeListener >& _rxBoundFieldListener )
2173 bool bShould =
false;
2175 Reference< XBoundComponent > xBound( _rxControl, UNO_QUERY );
2180 else if ( _rxControl.is() )
2182 Reference< XPropertySet > xModelProps( _rxControl->getModel(), UNO_QUERY );
2183 if ( xModelProps.is() && ::comphelper::hasProperty(
FM_PROP_BOUNDFIELD, xModelProps ) )
2185 Reference< XPropertySet > xField;
2187 bShould = xField.is();
2189 if ( !bShould && _rxBoundFieldListener.is() )
2199void FormController::startControlModifyListening(
const Reference< XControl > & xControl)
2201 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2203 bool bModifyListening = lcl_shouldListenForModifications( xControl,
this );
2206 while ( bModifyListening )
2208 Reference< XModifyBroadcaster > xMod(xControl, UNO_QUERY);
2211 xMod->addModifyListener(
this);
2216 Reference< XTextComponent > xText(xControl, UNO_QUERY);
2219 xText->addTextListener(
this);
2223 Reference< XCheckBox > xBox(xControl, UNO_QUERY);
2226 xBox->addItemListener(
this);
2230 Reference< XComboBox > xCbBox(xControl, UNO_QUERY);
2233 xCbBox->addItemListener(
this);
2237 Reference< XListBox > xListBox(xControl, UNO_QUERY);
2240 xListBox->addItemListener(
this);
2248void FormController::stopControlModifyListening(
const Reference< XControl > & xControl)
2250 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2252 bool bModifyListening = lcl_shouldListenForModifications( xControl,
nullptr );
2255 while (bModifyListening)
2257 Reference< XModifyBroadcaster > xMod(xControl, UNO_QUERY);
2260 xMod->removeModifyListener(
this);
2264 Reference< XTextComponent > xText(xControl, UNO_QUERY);
2267 xText->removeTextListener(
this);
2271 Reference< XCheckBox > xBox(xControl, UNO_QUERY);
2274 xBox->removeItemListener(
this);
2278 Reference< XComboBox > xCbBox(xControl, UNO_QUERY);
2281 xCbBox->removeItemListener(
this);
2285 Reference< XListBox > xListBox(xControl, UNO_QUERY);
2288 xListBox->removeItemListener(
this);
2296void FormController::startListening()
2298 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2299 m_bModified =
false;
2302 for (
const Reference< XControl >& rControl : std::as_const(m_aControls) )
2303 startControlModifyListening( rControl );
2307void FormController::stopListening()
2309 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2310 m_bModified =
false;
2313 for (
const Reference< XControl >& rControl : std::as_const(m_aControls) )
2314 stopControlModifyListening( rControl );
2318Reference< XControl > FormController::findControl(Sequence< Reference< XControl > >& _rControls,
const Reference< XControlModel > & xCtrlModel ,
bool _bRemove,
bool _bOverWrite)
const
2320 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2321 DBG_ASSERT( xCtrlModel.is(),
"findControl - which ?!" );
2323 const Reference< XControl >* pControls = std::find_if(std::cbegin(_rControls), std::cend(_rControls),
2324 [&xCtrlModel](
const Reference< XControl >& rControl) {
2325 return rControl.is() && rControl->getModel().get() == xCtrlModel.get(); });
2326 if (pControls != std::cend(_rControls))
2328 Reference< XControl > xControl( *pControls );
2329 auto i =
static_cast<sal_Int32
>(std::distance(std::cbegin(_rControls), pControls));
2331 ::comphelper::removeElementAt( _rControls,
i );
2332 else if ( _bOverWrite )
2333 _rControls.getArray()[
i].clear();
2336 return Reference< XControl > ();
2340void FormController::implControlInserted(
const Reference< XControl>& _rxControl,
bool _bAddToEventAttacher )
2342 Reference< XWindow > xWindow( _rxControl, UNO_QUERY );
2345 xWindow->addFocusListener(
this );
2346 xWindow->addMouseListener(
this );
2348 if ( _bAddToEventAttacher )
2349 addToEventAttacher( _rxControl );
2353 Reference< XDispatchProviderInterception > xInterception( _rxControl, UNO_QUERY );
2354 if ( xInterception.is() )
2355 createInterceptor( xInterception );
2357 if ( !_rxControl.is() )
2360 Reference< XControlModel >
xModel( _rxControl->getModel() );
2364 Reference< XReset > xReset(
xModel, UNO_QUERY );
2366 xReset->addResetListener(
this );
2369 Reference< XValidatableFormComponent > xValidatable(
xModel, UNO_QUERY );
2370 if ( xValidatable.is() )
2372 xValidatable->addFormComponentValidityListener(
this );
2373 m_aControlBorderManager.validityChanged( _rxControl, xValidatable );
2379void FormController::implControlRemoved(
const Reference< XControl>& _rxControl,
bool _bRemoveFromEventAttacher )
2381 Reference< XWindow > xWindow( _rxControl, UNO_QUERY );
2384 xWindow->removeFocusListener(
this );
2385 xWindow->removeMouseListener(
this );
2387 if ( _bRemoveFromEventAttacher )
2388 removeFromEventAttacher( _rxControl );
2391 Reference< XDispatchProviderInterception > xInterception( _rxControl, UNO_QUERY);
2392 if ( xInterception.is() )
2393 deleteInterceptor( xInterception );
2395 if ( _rxControl.is() )
2397 Reference< XControlModel >
xModel( _rxControl->getModel() );
2399 Reference< XReset > xReset(
xModel, UNO_QUERY );
2401 xReset->removeResetListener(
this );
2403 Reference< XValidatableFormComponent > xValidatable(
xModel, UNO_QUERY );
2404 if ( xValidatable.is() )
2405 xValidatable->removeFormComponentValidityListener(
this );
2410void FormController::implSetCurrentControl(
const Reference< XControl >& _rxControl )
2412 if ( m_xCurrentControl.get() == _rxControl.get() )
2415 Reference< XGridControl > xGridControl( m_xCurrentControl, UNO_QUERY );
2416 if ( xGridControl.is() )
2417 xGridControl->removeGridControlListener(
this );
2419 m_xCurrentControl = _rxControl;
2421 xGridControl.set( m_xCurrentControl, UNO_QUERY );
2422 if ( xGridControl.is() )
2423 xGridControl->addGridControlListener(
this );
2427void FormController::insertControl(
const Reference< XControl > & xControl)
2429 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2430 m_bControlsSorted =
false;
2431 m_aControls.realloc(m_aControls.getLength() + 1);
2432 m_aControls.getArray()[m_aControls.getLength() - 1] = xControl;
2434 if (m_pColumnInfoCache)
2435 m_pColumnInfoCache->deinitializeControls();
2437 implControlInserted( xControl, m_bAttachEvents );
2439 if (m_bDBConnection && !m_bFiltering)
2440 setControlLock(xControl);
2442 if (isListeningForChanges() && m_bAttachEvents)
2443 startControlModifyListening( xControl );
2447void FormController::removeControl(
const Reference< XControl > & xControl)
2449 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2450 auto pControl = std::find_if(std::cbegin(m_aControls), std::cend(m_aControls),
2451 [&xControl](
const Reference< XControl >& rControl) {
return xControl.get() == rControl.get(); });
2452 if (pControl != std::cend(m_aControls))
2454 auto nIndex =
static_cast<sal_Int32
>(std::distance(std::cbegin(m_aControls), pControl));
2455 ::comphelper::removeElementAt( m_aControls,
nIndex );
2458 FilterComponents::iterator componentPos = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl );
2459 if ( componentPos != m_aFilterComponents.end() )
2460 m_aFilterComponents.erase( componentPos );
2462 implControlRemoved( xControl, m_bDetachEvents );
2464 if ( isListeningForChanges() && m_bDetachEvents )
2465 stopControlModifyListening( xControl );
2470void FormController::loaded(
const EventObject& rEvent)
2472 OSL_ENSURE( rEvent.Source == m_xModelAsIndex,
"FormController::loaded: where did this come from?" );
2474 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2475 ::osl::MutexGuard aGuard(
m_aMutex );
2476 Reference< XRowSet > xForm(rEvent.Source, UNO_QUERY);
2480 Reference< XPropertySet > xSet(xForm, UNO_QUERY);
2484 sal_Int32 aVal2 = 0;
2485 ::cppu::enum2int(aVal2,aVal);
2486 m_bCycle = !aVal.hasValue() ||
static_cast<form::TabulatorCycle
>(aVal2) == TabulatorCycle_RECORDS;
2489 m_bCurrentRecordModified = ::comphelper::getBOOL(xSet->getPropertyValue(
FM_PROP_ISMODIFIED));
2490 m_bCurrentRecordNew = ::comphelper::getBOOL(xSet->getPropertyValue(
FM_PROP_ISNEW));
2492 startFormListening( xSet,
false );
2495 if (getContainer().is())
2497 m_aLoadEvent.Call();
2502 m_bCanInsert = m_bCanUpdate = m_bCycle =
false;
2503 m_bCurrentRecordModified =
false;
2504 m_bCurrentRecordNew =
false;
2507 m_bDBConnection =
true;
2511 m_bDBConnection =
false;
2512 m_bCanInsert = m_bCanUpdate = m_bCycle =
false;
2513 m_bCurrentRecordModified =
false;
2514 m_bCurrentRecordNew =
false;
2518 Reference< XColumnsSupplier > xFormColumns( xForm, UNO_QUERY );
2519 m_pColumnInfoCache.reset( xFormColumns.is() ?
new ColumnInfoCache( xFormColumns ) :
nullptr );
2521 updateAllDispatchers();
2525void FormController::updateAllDispatchers()
const
2528 m_aFeatureDispatchers.begin(),
2529 m_aFeatureDispatchers.end(),
2530 [] (
const DispatcherContainer::value_type& dispatcher) {
2531 UpdateAllListeners()(dispatcher.second);
2538 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2539 m_bLocked = determineLockState();
2547 if (m_bCurrentRecordNew)
2548 toggleAutoFields(
true);
2552void FormController::unloaded(
const EventObject& )
2554 ::osl::MutexGuard aGuard(
m_aMutex );
2555 impl_checkDisposed_throw();
2557 updateAllDispatchers();
2561void FormController::reloading(
const EventObject& )
2563 ::osl::MutexGuard aGuard(
m_aMutex );
2564 impl_checkDisposed_throw();
2568 m_aToggleEvent.CancelPendingCall();
2573void FormController::reloaded(
const EventObject& aEvent)
2575 ::osl::MutexGuard aGuard(
m_aMutex );
2576 impl_checkDisposed_throw();
2582void FormController::unloading(
const EventObject& )
2584 ::osl::MutexGuard aGuard(
m_aMutex );
2585 impl_checkDisposed_throw();
2591void FormController::unload()
2593 ::osl::MutexGuard aGuard(
m_aMutex );
2594 impl_checkDisposed_throw();
2596 m_aLoadEvent.CancelPendingCall();
2599 if (m_bCurrentRecordNew)
2600 toggleAutoFields(
false);
2603 removeBoundFieldListener();
2605 if (m_bDBConnection && isListeningForChanges())
2608 Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY );
2609 if ( m_bDBConnection && xSet.is() )
2610 stopFormListening( xSet,
false );
2612 m_bDBConnection =
false;
2613 m_bCanInsert = m_bCanUpdate = m_bCycle =
false;
2614 m_bCurrentRecordModified = m_bCurrentRecordNew = m_bLocked =
false;
2616 m_pColumnInfoCache.reset();
2620void FormController::removeBoundFieldListener()
2622 for (
const Reference< XControl >& rControl : std::as_const(m_aControls) )
2624 Reference< XPropertySet > xProp( rControl, UNO_QUERY );
2631void FormController::startFormListening(
const Reference< XPropertySet >& _rxForm,
bool _bPropertiesOnly )
2635 if ( m_bCanInsert || m_bCanUpdate )
2640 if ( !_bPropertiesOnly )
2643 Reference< XRowSetApproveBroadcaster > xApprove( _rxForm, UNO_QUERY );
2644 if ( xApprove.is() )
2645 xApprove->addRowSetApproveListener(
this );
2648 Reference< XRowSet > xRowSet( _rxForm, UNO_QUERY );
2650 xRowSet->addRowSetListener(
this );
2654 Reference< XPropertySetInfo > xInfo = _rxForm->getPropertySetInfo();
2665void FormController::stopFormListening(
const Reference< XPropertySet >& _rxForm,
bool _bPropertiesOnly )
2669 if ( m_bCanInsert || m_bCanUpdate )
2671 _rxForm->removePropertyChangeListener(
FM_PROP_ISNEW,
this );
2674 if ( !_bPropertiesOnly )
2676 Reference< XRowSetApproveBroadcaster > xApprove( _rxForm, UNO_QUERY );
2678 xApprove->removeRowSetApproveListener(
this);
2680 Reference< XRowSet > xRowSet( _rxForm, UNO_QUERY );
2682 xRowSet->removeRowSetListener(
this );
2686 Reference< XPropertySetInfo > xInfo = _rxForm->getPropertySetInfo();
2698void FormController::cursorMoved(
const EventObject& )
2700 ::osl::MutexGuard aGuard(
m_aMutex );
2701 impl_checkDisposed_throw();
2704 if (m_bLocked != determineLockState())
2706 m_bLocked = !m_bLocked;
2708 if (isListeningForChanges())
2715 m_bCurrentRecordModified = m_bModified =
false;
2719void FormController::rowChanged(
const EventObject& )
2724void FormController::rowSetChanged(
const EventObject& )
2732void SAL_CALL FormController::elementInserted(
const ContainerEvent& evt)
2734 ::osl::MutexGuard aGuard(
m_aMutex );
2735 impl_checkDisposed_throw();
2737 Reference< XControl > xControl( evt.Element, UNO_QUERY );
2738 if ( !xControl.is() )
2741 Reference< XFormComponent >
xModel(xControl->getModel(), UNO_QUERY);
2742 if (
xModel.is() && m_xModelAsIndex ==
xModel->getParent())
2744 insertControl(xControl);
2746 if ( m_aTabActivationIdle.IsActive() )
2747 m_aTabActivationIdle.Stop();
2749 m_aTabActivationIdle.Start();
2752 else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is())
2754 xModel.set(evt.Source, UNO_QUERY);
2755 if (
xModel.is() && m_xModelAsIndex ==
xModel->getParent())
2757 Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
2761 Reference< XPropertySet > xField;
2764 Reference< XTextComponent > xText(xControl, UNO_QUERY);
2766 if (xText.is() && xField.is() && ::comphelper::hasProperty(
FM_PROP_SEARCHABLE, xField) &&
2769 m_aFilterComponents.push_back( xText );
2770 xText->addTextListener(
this );
2778void SAL_CALL FormController::elementReplaced(
const ContainerEvent& evt)
2781 ContainerEvent aRemoveEvent( evt );
2782 aRemoveEvent.Element = evt.ReplacedElement;
2783 aRemoveEvent.ReplacedElement =
Any();
2787 ContainerEvent aInsertEvent( evt );
2788 aInsertEvent.ReplacedElement =
Any();
2793void SAL_CALL FormController::elementRemoved(
const ContainerEvent& evt)
2795 ::osl::MutexGuard aGuard(
m_aMutex );
2796 impl_checkDisposed_throw();
2798 Reference< XControl > xControl;
2799 evt.Element >>= xControl;
2803 Reference< XFormComponent >
xModel(xControl->getModel(), UNO_QUERY);
2804 if (
xModel.is() && m_xModelAsIndex ==
xModel->getParent())
2806 removeControl(xControl);
2810 else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is())
2812 FilterComponents::iterator componentPos = ::std::find(
2813 m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl );
2814 if ( componentPos != m_aFilterComponents.end() )
2815 m_aFilterComponents.erase( componentPos );
2820Reference< XControl > FormController::isInList(
const Reference< XWindowPeer > & xPeer)
const
2822 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2823 const Reference< XControl >* pControls = m_aControls.getConstArray();
2825 sal_uInt32 nCtrls = m_aControls.getLength();
2826 for ( sal_uInt32
n = 0;
n < nCtrls && xPeer.is(); ++
n, ++pControls )
2828 if ( pControls->is() )
2830 Reference< XVclWindowPeer > xCtrlPeer( (*pControls)->getPeer(), UNO_QUERY);
2831 if ( ( xCtrlPeer.get() == xPeer.get() ) || xCtrlPeer->isChild( xPeer ) )
2835 return Reference< XControl > ();
2839void FormController::activateFirst()
2841 ::osl::MutexGuard aGuard(
m_aMutex );
2842 impl_checkDisposed_throw();
2844 DBG_ASSERT(m_xTabController.is(),
"FormController::activateFirst : invalid aggregate !");
2845 if (m_xTabController.is())
2846 m_xTabController->activateFirst();
2850void FormController::activateLast()
2852 ::osl::MutexGuard aGuard(
m_aMutex );
2853 impl_checkDisposed_throw();
2855 DBG_ASSERT(m_xTabController.is(),
"FormController::activateLast : invalid aggregate !");
2856 if (m_xTabController.is())
2857 m_xTabController->activateLast();
2862Reference< XFormOperations > SAL_CALL FormController::getFormOperations()
2864 ::osl::MutexGuard aGuard(
m_aMutex );
2865 impl_checkDisposed_throw();
2867 return m_xFormOperations;
2871Reference< XControl> SAL_CALL FormController::getCurrentControl()
2873 ::osl::MutexGuard aGuard(
m_aMutex );
2874 impl_checkDisposed_throw();
2875 return m_xCurrentControl;
2879void SAL_CALL FormController::addActivateListener(
const Reference< XFormControllerListener > & l)
2881 ::osl::MutexGuard aGuard(
m_aMutex );
2882 impl_checkDisposed_throw();
2883 m_aActivateListeners.addInterface(l);
2886void SAL_CALL FormController::removeActivateListener(
const Reference< XFormControllerListener > & l)
2888 ::osl::MutexGuard aGuard(
m_aMutex );
2889 impl_checkDisposed_throw();
2890 m_aActivateListeners.removeInterface(l);
2894void SAL_CALL FormController::addChildController(
const Reference< XFormController >& ChildController )
2896 ::osl::MutexGuard aGuard(
m_aMutex );
2897 impl_checkDisposed_throw();
2899 if ( !ChildController.is() )
2900 throw IllegalArgumentException( OUString(), *
this, 1 );
2904 Reference< XFormComponent > xFormOfChild( ChildController->getModel(), UNO_QUERY );
2905 if ( !xFormOfChild.is() )
2906 throw IllegalArgumentException( OUString(), *
this, 1 );
2909 if ( xFormOfChild->getParent() != m_xModelAsIndex )
2910 throw IllegalArgumentException( OUString(), *
this, 1 );
2913 m_aChildren.push_back( ChildController );
2914 ChildController->setParent( *
this );
2917 sal_uInt32
nPos = m_xModelAsIndex->getCount();
2918 Reference< XFormComponent > xTemp;
2921 m_xModelAsIndex->getByIndex(--
nPos) >>= xTemp;
2922 if ( xFormOfChild == xTemp )
2924 m_xModelAsManager->attach(
nPos, Reference<XInterface>( ChildController, UNO_QUERY ),
Any( ChildController) );
2931Reference< XFormControllerContext > SAL_CALL FormController::getContext()
2933 ::osl::MutexGuard aGuard(
m_aMutex );
2934 impl_checkDisposed_throw();
2935 return m_xFormControllerContext;
2939void SAL_CALL FormController::setContext(
const Reference< XFormControllerContext >& _context )
2941 ::osl::MutexGuard aGuard(
m_aMutex );
2942 impl_checkDisposed_throw();
2943 m_xFormControllerContext = _context;
2947Reference< XInteractionHandler > SAL_CALL FormController::getInteractionHandler()
2949 ::osl::MutexGuard aGuard(
m_aMutex );
2950 impl_checkDisposed_throw();
2955void SAL_CALL FormController::setInteractionHandler(
const Reference< XInteractionHandler >& _interactionHandler )
2957 ::osl::MutexGuard aGuard(
m_aMutex );
2958 impl_checkDisposed_throw();
2963void FormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos)
2965 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
2967 Reference< XRowSet > xForm(m_xModelAsIndex, UNO_QUERY);
2973 Reference< XMultiServiceFactory >
xFactory( xConnection, UNO_QUERY_THROW );
2975 xFactory->createInstance(
"com.sun.star.sdb.SingleSelectQueryComposer"),
2978 Reference< XPropertySet > xSet( xForm, UNO_QUERY );
2980 OUString sFilter = ::comphelper::getString( xSet->getPropertyValue(
FM_PROP_FILTER ) );
2981 m_xComposer->setElementaryQuery( sStatement );
2982 m_xComposer->setFilter( sFilter );
2990 if (m_xComposer.is())
2992 const Sequence< Sequence < PropertyValue > > aFilterRows = m_xComposer->getStructuredFilter();
2999 Reference< XNameAccess > xQueryColumns =
3000 Reference< XColumnsSupplier >( m_xComposer, UNO_QUERY_THROW )->getColumns();
3002 for (
auto& rFieldInfo : rFieldInfos)
3004 if ( xQueryColumns->hasByName(rFieldInfo.aFieldName) )
3006 if ( (xQueryColumns->getByName(rFieldInfo.aFieldName) >>= rFieldInfo.xField) && rFieldInfo.xField.is() )
3007 rFieldInfo.xField->getPropertyValue(
FM_PROP_REALNAME) >>= rFieldInfo.aFieldName;
3011 Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData());
3016 Reference< XNumberFormatsSupplier> xFormatSupplier(
getNumberFormats(xConnection,
true));
3018 xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
3024 for (
const Sequence < PropertyValue >& rRow : aFilterRows)
3029 for (
const PropertyValue& rRefValue : rRow)
3032 Reference< XPropertySet > xField;
3035 Reference< XPropertySet > xSet;
3039 if (xQueryColumns->hasByName(rRefValue.Name))
3041 xQueryColumns->getByName(rRefValue.Name) >>= xSet;
3044 xSet->getPropertyValue(
"RealName") >>= aRealName;
3047 if (aCompare(aRealName, rRefValue.Name))
3053 Reference< XIndexAccess > xColumnsByIndex(xQueryColumns, UNO_QUERY);
3054 for (sal_Int32
n = 0,
nCount = xColumnsByIndex->getCount();
n <
nCount;
n++)
3056 xColumnsByIndex->getByIndex(
n) >>= xSet;
3057 xSet->getPropertyValue(
"RealName") >>= aRealName;
3058 if (aCompare(aRealName, rRefValue.Name))
3075 for (
const auto& rFieldInfo : rFieldInfos)
3078 if (rFieldInfo.xField == xField)
3081 if (aRow.find(rFieldInfo.xText) != aRow.end())
3083 OString aVal = m_pParser->getContext().getIntlKeywordAscii(IParseContext::InternationalKeyCode::And);
3084 OUString aCompText = aRow[rFieldInfo.xText] +
" " +
3085 OStringToOUString(aVal, RTL_TEXTENCODING_ASCII_US) +
" " +
3086 ::comphelper::getString(rRefValue.Value);
3087 aRow[rFieldInfo.xText] = aCompText;
3091 OUString sPredicate,sErrorMsg;
3092 rRefValue.Value >>= sPredicate;
3093 std::unique_ptr< OSQLParseNode > pParseNode = predicateTree(sErrorMsg, sPredicate, xFormatter, xField);
3094 if ( pParseNode !=
nullptr )
3097 switch (rRefValue.Handle)
3099 case css::sdb::SQLFilterOperator::EQUAL:
3102 case css::sdb::SQLFilterOperator::NOT_EQUAL:
3105 case css::sdb::SQLFilterOperator::LESS:
3108 case css::sdb::SQLFilterOperator::GREATER:
3111 case css::sdb::SQLFilterOperator::LESS_EQUAL:
3114 case css::sdb::SQLFilterOperator::GREATER_EQUAL:
3117 case css::sdb::SQLFilterOperator::LIKE:
3118 sCriteria +=
"LIKE ";
3120 case css::sdb::SQLFilterOperator::NOT_LIKE:
3121 sCriteria +=
"NOT LIKE ";
3123 case css::sdb::SQLFilterOperator::SQLNULL:
3124 sCriteria +=
"IS NULL";
3126 case css::sdb::SQLFilterOperator::NOT_SQLNULL:
3127 sCriteria +=
"IS NOT NULL";
3130 pParseNode->parseNodeToPredicateStr( sCriteria
3136 ,strDecimalSeparator
3137 ,getParseContext());
3138 aRow[rFieldInfo.xText] = sCriteria;
3148 impl_addFilterRow( aRow );
3153 for (
const auto& rFieldInfo : rFieldInfos)
3155 m_aFilterComponents.push_back( rFieldInfo.xText );
3160void FormController::startFiltering()
3162 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
3164 Reference< XConnection > xConnection(
getConnection( Reference< XRowSet >( m_xModelAsIndex, UNO_QUERY ) ) );
3165 if ( !xConnection.is() )
3170 if (isListeningForChanges())
3173 m_bFiltering =
true;
3177 m_bAttachEvents =
false;
3180 Sequence< Reference< XControl > > aControlsCopy( m_aControls );
3181 const Reference< XControl >* pControls = aControlsCopy.getConstArray();
3182 sal_Int32 nControlCount = aControlsCopy.getLength();
3185 Reference< XNumberFormatsSupplier > xFormatSupplier =
getNumberFormats(xConnection,
true);
3187 xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
3190 ::std::vector<FmFieldInfo> aFieldInfos;
3192 for (sal_Int32
i = nControlCount;
i > 0;)
3194 Reference< XControl > xControl = pControls[--
i];
3198 removeFromEventAttacher(xControl);
3201 Reference< XModeSelector > xSelector(xControl, UNO_QUERY);
3204 xSelector->setMode(
"FilterMode" );
3207 Reference< XContainer > xContainer(xSelector, UNO_QUERY);
3208 if (xContainer.is())
3209 xContainer->addContainerListener(
this);
3211 Reference< XEnumerationAccess > xElementAccess(xSelector, UNO_QUERY);
3212 if (xElementAccess.is())
3214 Reference< XEnumeration > xEnumeration(xElementAccess->createEnumeration());
3215 Reference< XControl > xSubControl;
3216 while (xEnumeration->hasMoreElements())
3218 xEnumeration->nextElement() >>= xSubControl;
3219 if (xSubControl.is())
3221 Reference< XPropertySet > xSet(xSubControl->getModel(), UNO_QUERY);
3225 Reference< XPropertySet > xField;
3228 Reference< XTextComponent > xText(xSubControl, UNO_QUERY);
3230 if (xText.is() && xField.is() && ::comphelper::hasProperty(
FM_PROP_SEARCHABLE, xField) &&
3233 aFieldInfos.emplace_back(xField, xText);
3234 xText->addTextListener(
this);
3243 Reference< XPropertySet >
xModel( xControl->getModel(), UNO_QUERY );
3248 Reference< XPropertySet > xField;
3259 Reference< XControl > xFilterControl = form::control::FilterControl::createWithFormat(
3261 getDialogParentWindow(
this),
3265 if ( replaceControl( xControl, xFilterControl ) )
3267 Reference< XTextComponent > xFilterText( xFilterControl, UNO_QUERY );
3268 aFieldInfos.emplace_back( xField, xFilterText );
3269 xFilterText->addTextListener(
this);
3282 setFilter(aFieldInfos);
3284 Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY );
3286 stopFormListening( xSet,
true );
3288 impl_setTextOnAllFilter_throw();
3291 m_bLocked = determineLockState();
3293 m_bAttachEvents =
true;
3297void FormController::stopFiltering()
3299 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
3300 if ( !m_bFiltering )
3305 m_bFiltering =
false;
3306 m_bDetachEvents =
false;
3308 ::comphelper::disposeComponent(m_xComposer);
3311 Sequence< Reference< XControl > > aControlsCopy( m_aControls );
3312 const Reference< XControl > * pControls = aControlsCopy.getConstArray();
3313 sal_Int32 nControlCount = aControlsCopy.getLength();
3316 ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener(
this ) );
3317 m_aFilterComponents.clear();
3319 for ( sal_Int32
i = nControlCount;
i > 0; )
3321 Reference< XControl > xControl = pControls[--
i];
3325 addToEventAttacher(xControl);
3327 Reference< XModeSelector > xSelector(xControl, UNO_QUERY);
3330 xSelector->setMode(
"DataMode" );
3333 Reference< XContainer > xContainer(xSelector, UNO_QUERY);
3334 if (xContainer.is())
3335 xContainer->removeContainerListener(
this);
3339 Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
3343 Reference< XPropertySet > xField;
3355 replaceControl( xControl, xNewControl );
3361 Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY );
3363 startFormListening( xSet,
true );
3365 m_bDetachEvents =
true;
3367 m_aFilterRows.clear();
3368 m_nCurrentFilterPosition = -1;
3372 m_bLocked = determineLockState();
3376 if (isListeningForChanges())
3382void FormController::setMode(
const OUString&
Mode)
3384 ::osl::MutexGuard aGuard(
m_aMutex );
3385 impl_checkDisposed_throw();
3387 if (!supportsMode(
Mode))
3388 throw NoSupportException();
3390 if (
Mode == m_aMode)
3395 if (
Mode ==
"FilterMode" )
3400 for (
const auto& rChild : m_aChildren)
3402 Reference< XModeSelector > xMode(rChild, UNO_QUERY);
3404 xMode->setMode(
Mode);
3409OUString SAL_CALL FormController::getMode()
3411 ::osl::MutexGuard aGuard(
m_aMutex );
3412 impl_checkDisposed_throw();
3418Sequence< OUString > SAL_CALL FormController::getSupportedModes()
3420 ::osl::MutexGuard aGuard(
m_aMutex );
3421 impl_checkDisposed_throw();
3423 static Sequence< OUString >
const aModes
3433 ::osl::MutexGuard aGuard(
m_aMutex );
3434 impl_checkDisposed_throw();
3436 Sequence< OUString > aModes(getSupportedModes());
3440css::uno::Reference<css::awt::XWindow> FormController::getDialogParentWindow(css::uno::Reference<css::form::runtime::XFormController> xFormController)
3444 Reference< XControl > xContainerControl( xFormController->getContainer(), UNO_QUERY_THROW );
3445 Reference<XWindow> xContainerWindow(xContainerControl->getPeer(), UNO_QUERY_THROW);
3446 return xContainerWindow;
3455bool FormController::checkFormComponentValidity( OUString& _rFirstInvalidityExplanation, Reference< XControlModel >& _rxFirstInvalidModel )
3459 Reference< XEnumerationAccess > xControlEnumAcc( getModel(), UNO_QUERY );
3460 Reference< XEnumeration > xControlEnumeration;
3461 if ( xControlEnumAcc.is() )
3462 xControlEnumeration = xControlEnumAcc->createEnumeration();
3463 OSL_ENSURE( xControlEnumeration.is(),
"FormController::checkFormComponentValidity: cannot enumerate the controls!" );
3464 if ( !xControlEnumeration.is() )
3468 Reference< XValidatableFormComponent > xValidatable;
3469 while ( xControlEnumeration->hasMoreElements() )
3471 if ( !( xControlEnumeration->nextElement() >>= xValidatable ) )
3475 if ( xValidatable->isValid() )
3478 Reference< XValidator > xValidator( xValidatable->getValidator() );
3479 OSL_ENSURE( xValidator.is(),
"FormController::checkFormComponentValidity: invalid, but no validator?" );
3480 if ( !xValidator.is() )
3484 _rFirstInvalidityExplanation = xValidator->explainInvalid( xValidatable->getCurrentValue() );
3485 _rxFirstInvalidModel.set(xValidatable, css::uno::UNO_QUERY);
3497Reference< XControl > FormController::locateControl(
const Reference< XControlModel >& _rxModel )
3501 const Sequence< Reference< XControl > > aControls( getControls() );
3503 for (
auto const & control : aControls )
3505 OSL_ENSURE( control.is(),
"FormController::locateControl: NULL-control?" );
3508 if ( control->getModel() == _rxModel )
3512 OSL_FAIL(
"FormController::locateControl: did not find a control for this model!" );
3524 void displayErrorSetFocus(
const OUString& _rMessage,
const Reference<XControl>& _rxFocusControl,
3525 const css::uno::Reference<css::awt::XWindow>& rDialogParent)
3528 aError.Message =
SvxResId(RID_STR_WRITEERROR);
3529 aError.Details = _rMessage;
3532 if ( _rxFocusControl.is() )
3534 Reference< XWindow > xControlWindow( _rxFocusControl, UNO_QUERY );
3535 OSL_ENSURE( xControlWindow.is(),
"displayErrorSetFocus: invalid control!" );
3536 if ( xControlWindow.is() )
3537 xControlWindow->setFocus();
3541 bool lcl_shouldValidateRequiredFields_nothrow(
const Reference< XInterface >& _rxForm )
3545 static constexpr OUStringLiteral s_sFormsCheckRequiredFields =
u"FormsCheckRequiredFields";
3550 Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY_THROW );
3551 Reference< XPropertySetInfo > xPSI( xFormProps->getPropertySetInfo() );
3552 if ( xPSI->hasPropertyByName( s_sFormsCheckRequiredFields ) )
3554 bool bShouldValidate =
true;
3555 OSL_VERIFY( xFormProps->getPropertyValue( s_sFormsCheckRequiredFields ) >>= bShouldValidate );
3556 return bShouldValidate;
3561 Reference< XPropertySet > xDataSource( xConnectionAsChild->getParent(), UNO_QUERY );
3562 if ( !xDataSource.is() )
3566 Reference< XPropertySet > xDataSourceSettings(
3567 xDataSource->getPropertyValue(
"Settings"),
3570 bool bShouldValidate =
true;
3571 OSL_VERIFY( xDataSourceSettings->getPropertyValue( s_sFormsCheckRequiredFields ) >>= bShouldValidate );
3572 return bShouldValidate;
3574 catch(
const Exception& )
3585sal_Bool SAL_CALL FormController::approveRowChange(
const RowChangeEvent& _rEvent)
3587 ::osl::ClearableMutexGuard aGuard(
m_aMutex );
3588 impl_checkDisposed_throw();
3594 RowChangeEvent aEvt( _rEvent );
3595 aEvt.Source = *
this;
3596 bValid = aIter.
next()->approveRowChange(aEvt);
3602 if ( ( _rEvent.Action != RowChangeAction::INSERT )
3603 && ( _rEvent.Action != RowChangeAction::UPDATE )
3608 OUString sInvalidityExplanation;
3609 Reference< XControlModel > xInvalidModel;
3610 if ( !checkFormComponentValidity( sInvalidityExplanation, xInvalidModel ) )
3612 Reference< XControl > xControl( locateControl( xInvalidModel ) );
3614 displayErrorSetFocus( sInvalidityExplanation, xControl, getDialogParentWindow(
this) );
3619 if ( !lcl_shouldValidateRequiredFields_nothrow( _rEvent.Source ) )
3622 OSL_ENSURE(m_pColumnInfoCache,
"FormController::approveRowChange: no column infos!");
3623 if (!m_pColumnInfoCache)
3628 if ( !m_pColumnInfoCache->controlsInitialized() )
3629 m_pColumnInfoCache->initializeControls( getControls() );
3631 size_t colCount = m_pColumnInfoCache->getColumnCount();
3632 for (
size_t col = 0;
col < colCount; ++
col )
3634 const ColumnInfo& rColInfo = m_pColumnInfoCache->getColumnInfo(
col );
3636 if ( rColInfo.bAutoIncrement )
3639 if ( rColInfo.bReadOnly )
3642 if ( !rColInfo.xFirstControlWithInputRequired.is() && !rColInfo.xFirstGridWithInputRequiredColumn.is() )
3648 if ( !rColInfo.xColumn->getString().isEmpty() || !rColInfo.xColumn->wasNull() )
3655 Reference< XControl > xControl( rColInfo.xFirstControlWithInputRequired );
3656 if ( !xControl.is() )
3657 xControl.set( rColInfo.xFirstGridWithInputRequiredColumn, UNO_QUERY );
3660 displayErrorSetFocus(
sMessage, rColInfo.xFirstControlWithInputRequired, getDialogParentWindow(
this) );
3673sal_Bool SAL_CALL FormController::approveCursorMove(
const EventObject& event)
3675 ::osl::MutexGuard aGuard(
m_aMutex );
3676 impl_checkDisposed_throw();
3681 EventObject aEvt(event);
3682 aEvt.Source = *
this;
3683 return aIter.
next()->approveCursorMove(aEvt);
3690sal_Bool SAL_CALL FormController::approveRowSetChange(
const EventObject& event)
3692 ::osl::MutexGuard aGuard(
m_aMutex );
3693 impl_checkDisposed_throw();
3698 EventObject aEvt(event);
3699 aEvt.Source = *
this;
3700 return aIter.
next()->approveRowSetChange(aEvt);
3708void SAL_CALL FormController::addRowSetApproveListener(
const Reference< XRowSetApproveListener > & _rxListener)
3710 ::osl::MutexGuard aGuard(
m_aMutex );
3711 impl_checkDisposed_throw();
3713 m_aRowSetApproveListeners.addInterface(_rxListener);
3717void SAL_CALL FormController::removeRowSetApproveListener(
const Reference< XRowSetApproveListener > & _rxListener)
3719 ::osl::MutexGuard aGuard(
m_aMutex );
3720 impl_checkDisposed_throw();
3722 m_aRowSetApproveListeners.removeInterface(_rxListener);
3727void SAL_CALL FormController::errorOccured(
const SQLErrorEvent& aEvent)
3729 ::osl::ClearableMutexGuard aGuard(
m_aMutex );
3730 impl_checkDisposed_throw();
3735 SQLErrorEvent aEvt(
aEvent);
3736 aEvt.Source = *
this;
3737 aIter.
next()->errorOccured(aEvt);
3748void SAL_CALL FormController::addSQLErrorListener(
const Reference< XSQLErrorListener > & aListener)
3750 ::osl::MutexGuard aGuard(
m_aMutex );
3751 impl_checkDisposed_throw();
3753 m_aErrorListeners.addInterface(aListener);
3757void SAL_CALL FormController::removeSQLErrorListener(
const Reference< XSQLErrorListener > & aListener)
3759 ::osl::MutexGuard aGuard(
m_aMutex );
3760 impl_checkDisposed_throw();
3762 m_aErrorListeners.removeInterface(aListener);
3767void SAL_CALL FormController::addDatabaseParameterListener(
const Reference< XDatabaseParameterListener > & aListener)
3769 ::osl::MutexGuard aGuard(
m_aMutex );
3770 impl_checkDisposed_throw();
3772 m_aParameterListeners.addInterface(aListener);
3776void SAL_CALL FormController::removeDatabaseParameterListener(
const Reference< XDatabaseParameterListener > & aListener)
3778 ::osl::MutexGuard aGuard(
m_aMutex );
3779 impl_checkDisposed_throw();
3781 m_aParameterListeners.removeInterface(aListener);
3786void SAL_CALL FormController::addParameterListener(
const Reference< XDatabaseParameterListener > & aListener)
3788 FormController::addDatabaseParameterListener( aListener );
3792void SAL_CALL FormController::removeParameterListener(
const Reference< XDatabaseParameterListener > & aListener)
3794 FormController::removeDatabaseParameterListener( aListener );
3799sal_Bool SAL_CALL FormController::approveParameter(
const DatabaseParameterEvent& aEvent)
3802 ::osl::MutexGuard aGuard(
m_aMutex );
3803 impl_checkDisposed_throw();
3808 DatabaseParameterEvent aEvt(
aEvent);
3809 aEvt.Source = *
this;
3810 return aIter.
next()->approveParameter(aEvt);
3817 if ( !ensureInteractionHandler() )
3824 ParametersRequest aRequest;
3825 aRequest.Parameters =
aEvent.Parameters;
3829 pParamRequest->addContinuation(pParamValues);
3830 pParamRequest->addContinuation(pAbort);
3835 if (!pParamValues->wasSelected())
3840 Sequence< PropertyValue > aFinalValues = pParamValues->getValues();
3841 if (aFinalValues.getLength() != aRequest.Parameters->getCount())
3843 OSL_FAIL(
"FormController::approveParameter: the InteractionHandler returned nonsense!");
3846 const PropertyValue* pFinalValues = aFinalValues.getConstArray();
3847 for (sal_Int32
i=0;
i<aFinalValues.getLength(); ++
i, ++pFinalValues)
3849 Reference< XPropertySet > xParam(
3850 aRequest.Parameters->getByIndex(
i), css::uno::UNO_QUERY);
3856 DBG_ASSERT(
sName == pFinalValues->Name,
"FormController::approveParameter: suspicious value names!");
3858 try { xParam->setPropertyValue(
FM_PROP_VALUE, pFinalValues->Value); }
3861 OSL_FAIL(
"FormController::approveParameter: setting one of the properties failed!");
3876void SAL_CALL FormController::addConfirmDeleteListener(
const Reference< XConfirmDeleteListener > & aListener)
3878 ::osl::MutexGuard aGuard(
m_aMutex );
3879 impl_checkDisposed_throw();
3881 m_aDeleteListeners.addInterface(aListener);
3885void SAL_CALL FormController::removeConfirmDeleteListener(
const Reference< XConfirmDeleteListener > & aListener)
3887 ::osl::MutexGuard aGuard(
m_aMutex );
3888 impl_checkDisposed_throw();
3890 m_aDeleteListeners.removeInterface(aListener);
3895sal_Bool SAL_CALL FormController::confirmDelete(
const RowChangeEvent& aEvent)
3897 ::osl::MutexGuard aGuard(
m_aMutex );
3898 impl_checkDisposed_throw();
3903 RowChangeEvent aEvt(
aEvent);
3904 aEvt.Source = *
this;
3905 return aIter.
next()->confirmDelete(aEvt);
3913 sTitle =
SvxResId( RID_STR_DELETECONFIRM_RECORDS );
3914 sTitle = sTitle.replaceFirst(
"#", OUString::number(
nLength) );
3917 sTitle =
SvxResId( RID_STR_DELETECONFIRM_RECORD );
3921 if ( !ensureInteractionHandler() )
3929 SQLWarning aWarning;
3930 aWarning.Message = sTitle;
3931 SQLWarning aDetails;
3932 aDetails.Message =
SvxResId(RID_STR_DELETECONFIRM);
3933 aWarning.NextException <<= aDetails;
3938 pRequest->addContinuation( pApprove );
3939 pRequest->addContinuation( pDisapprove );
3944 if ( pApprove->wasSelected() )
3956void SAL_CALL FormController::invalidateFeatures(
const Sequence< ::sal_Int16 >& Features )
3958 ::osl::MutexGuard aGuard(
m_aMutex );
3960 m_aInvalidFeatures.insert( Features.begin(), Features.end() );
3963 if ( !m_aFeatureInvalidationTimer.IsActive() )
3964 m_aFeatureInvalidationTimer.Start();
3968void SAL_CALL FormController::invalidateAllFeatures( )
3970 ::osl::ClearableMutexGuard aGuard(
m_aMutex );
3975 if ( aInterceptedFeatures.hasElements() )
3976 invalidateFeatures( aInterceptedFeatures );
3980Reference< XDispatch >
3981FormController::interceptedQueryDispatch(
const URL& aURL,
3982 const OUString& , sal_Int32 )
3984 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
3985 Reference< XDispatch > xReturn;
3988 || ( (
aURL.Complete ==
"private:/InteractionHandler" )
3989 && ensureInteractionHandler()
3992 xReturn =
static_cast< XDispatch*
>( this );
3995 if ( !xReturn.is() && m_xFormOperations.is() )
4003 DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find(
nFormFeature );
4004 if ( aDispatcherPos == m_aFeatureDispatchers.end() )
4006 aDispatcherPos = m_aFeatureDispatchers.emplace(
4011 OSL_ENSURE( aDispatcherPos->second.is(),
"FormController::interceptedQueryDispatch: should have a dispatcher by now!" );
4012 return aDispatcherPos->second;
4021void SAL_CALL FormController::dispatch(
const URL& _rURL,
const Sequence< PropertyValue >& _rArgs )
4023 if ( _rArgs.getLength() != 1 )
4025 OSL_FAIL(
"FormController::dispatch: no arguments -> no dispatch!" );
4029 if ( _rURL.Complete ==
"private:/InteractionHandler" )
4031 Reference< XInteractionRequest > xRequest;
4032 OSL_VERIFY( _rArgs[0].
Value >>= xRequest );
4033 if ( xRequest.is() )
4040 OSL_FAIL(
"FormController::dispatch: How do you expect me to return something via this call?" );
4045 OSL_FAIL(
"FormController::dispatch: unknown URL!" );
4049void SAL_CALL FormController::addStatusListener(
const Reference< XStatusListener >& _rxListener,
const URL& _rURL )
4053 if (_rxListener.is())
4055 FeatureStateEvent
aEvent;
4056 aEvent.FeatureURL = _rURL;
4058 _rxListener->statusChanged(
aEvent);
4063 OSL_FAIL(
"FormController::addStatusListener: invalid (unsupported) URL!");
4067Reference< XInterface > SAL_CALL FormController::getParent()
4073void SAL_CALL FormController::setParent(
const Reference< XInterface >& Parent)
4079void SAL_CALL FormController::removeStatusListener(
const Reference< XStatusListener >& ,
const URL& _rURL )
4081 OSL_ENSURE(_rURL.Complete ==
FMURL_CONFIRM_DELETION,
"FormController::removeStatusListener: invalid (unsupported) URL!");
4086Reference< XDispatchProviderInterceptor > FormController::createInterceptor(
const Reference< XDispatchProviderInterception > & _xInterception)
4088 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
4091 for (
const auto & it : m_aControlDispatchInterceptors )
4093 if (it->getIntercepted() == _xInterception)
4094 OSL_FAIL(
"FormController::createInterceptor : we already do intercept this objects dispatches !");
4099 m_aControlDispatchInterceptors.push_back( pInterceptor );
4101 return pInterceptor;
4105bool FormController::ensureInteractionHandler()
4109 if ( m_bAttemptedHandlerCreation )
4111 m_bAttemptedHandlerCreation =
true;
4114 getDialogParentWindow(
this));
4119void SAL_CALL FormController::handle(
const Reference< XInteractionRequest >& _rRequest )
4121 if ( !ensureInteractionHandler() )
4127void FormController::deleteInterceptor(
const Reference< XDispatchProviderInterception > & _xInterception)
4129 OSL_ENSURE( !impl_isDisposed_nofail(),
"FormController: already disposed!" );
4131 auto aIter = std::find_if(m_aControlDispatchInterceptors.begin(), m_aControlDispatchInterceptors.end(),
4133 return rpInterceptor->getIntercepted() == _xInterception;
4135 if (aIter != m_aControlDispatchInterceptors.end())
4138 (*aIter)->dispose();
4140 m_aControlDispatchInterceptors.erase(aIter);
4145void FormController::implInvalidateCurrentControlDependentFeatures()
4147 Sequence< sal_Int16 > aCurrentControlDependentFeatures
4149 FormFeature::SortAscending,
4150 FormFeature::SortDescending,
4151 FormFeature::AutoFilter,
4152 FormFeature::RefreshCurrentControl
4155 invalidateFeatures( aCurrentControlDependentFeatures );
4159void SAL_CALL FormController::columnChanged(
const EventObject& )
4161 implInvalidateCurrentControlDependentFeatures();
constexpr OUStringLiteral sServiceName
const LanguageTag & GetUILanguageTag() const
static const AllSettings & GetSettings()
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
const OUString & getNumDecimalSep() const
virtual void ImplSetPeerProperty(const OUString &rPropName, const css::uno::Any &rVal)
void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > &Toolkit, const css::uno::Reference< css::awt::XWindowPeer > &Parent) override
bool hasMoreElements() const
css::uno::Reference< ListenerT > const & next()
css::uno::Sequence< css::uno::Type > getTypes()
css::uno::Type const & get()
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
Reference< XInteractionHandler2 > m_xInteractionHandler
#define DBG_ASSERT(sCon, aError)
#define DBG_UNHANDLED_EXCEPTION(...)
OUString SvxResId(TranslateId aId)
Reference< XComponentContext > const m_xComponentContext
Reference< XSingleServiceFactory > xFactory
constexpr OUStringLiteral FM_PROP_READONLY
#define FM_ATTR_FORM_OPERATIONS
constexpr OUStringLiteral FM_PROP_CYCLE
constexpr OUStringLiteral FM_PROP_DYNAMIC_CONTROL_BORDER
constexpr OUStringLiteral FM_PROP_DEFAULTCONTROL
constexpr OUStringLiteral FM_PROP_ISNULLABLE
constexpr OUStringLiteral FM_PROP_ACTIVE_CONNECTION
constexpr OUStringLiteral FM_PROP_BOUNDFIELD
constexpr OUStringLiteral FM_PROP_ISNEW
constexpr OUStringLiteral FM_PROP_ENABLED
constexpr OUStringLiteral FM_PROP_ACTIVECOMMAND
constexpr OUStringLiteral FM_PROP_INPUT_REQUIRED
constexpr OUStringLiteral FM_PROP_TEXT
constexpr OUStringLiteral FM_PROP_CONTROL_BORDER_COLOR_INVALID
constexpr OUStringLiteral FM_PROP_ISREADONLY
constexpr OUStringLiteral FM_PROP_NAME
constexpr OUStringLiteral FM_PROP_FORM_OPERATIONS
constexpr OUStringLiteral FM_PROP_REALNAME
constexpr OUStringLiteral FM_PROP_FILTER
constexpr OUStringLiteral FM_PROP_AUTOINCREMENT
constexpr OUStringLiteral FM_PROP_SEARCHABLE
constexpr OUStringLiteral FM_PROP_CONTROL_BORDER_COLOR_FOCUS
constexpr OUStringLiteral FM_PROP_VALUE
constexpr OUStringLiteral FM_PROP_ISMODIFIED
constexpr OUStringLiteral FM_PROP_CONTROL_BORDER_COLOR_MOUSE
constexpr OUStringLiteral FMURL_CONFIRM_DELETION
#define LINK(Instance, Class, Member)
void SAL_CALL elementRemoved(const css::container::ContainerEvent &Event) override
DECL_LISTENERMULTIPLEXER_END void SAL_CALL elementInserted(const css::container::ContainerEvent &Event) override
#define SAL_WARN_IF(condition, area, stream)
RttiCompleteObjectLocator col
class SAL_NO_VTABLE XPropertySet
class SvxPropertySetInfoPool
OInteraction< css::task::XInteractionDisapprove > OInteractionDisapprove
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
css::uno::Sequence< typename M::key_type > mapKeysToSequence(M const &map)
OInteraction< css::task::XInteractionApprove > OInteractionApprove
OInteraction< css::task::XInteractionAbort > OInteractionAbort
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral first
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
Reference< XModel > xModel
::std::pair< MetaAction *, int > Component