diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-01-12 09:19:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-01-12 14:46:19 +0000 |
commit | 5fd2f0b93bd7d38a277823bfc251c71da7a6f490 (patch) | |
tree | 274542cbde1e6917ae8e98ed17057c4ae4267636 /forms | |
parent | d85a6fd228b3eaeb9214e73cdec0c6ef88e058e3 (diff) |
use concrete class in Submission
the code already relies on the underlying type of mxModel being Model
rather than XModel
Change-Id: I5b78482d37024a5bc274b0208fa56e4328f3f5f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145390
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'forms')
-rw-r--r-- | forms/source/xforms/model.cxx | 2 | ||||
-rw-r--r-- | forms/source/xforms/model_helper.hxx | 4 | ||||
-rw-r--r-- | forms/source/xforms/submission.cxx | 21 | ||||
-rw-r--r-- | forms/source/xforms/submission.hxx | 11 |
4 files changed, 16 insertions, 22 deletions
diff --git a/forms/source/xforms/model.cxx b/forms/source/xforms/model.cxx index 7001f4aaa8e8..d4eeb0e57980 100644 --- a/forms/source/xforms/model.cxx +++ b/forms/source/xforms/model.cxx @@ -436,7 +436,7 @@ void SAL_CALL Model::submitWithInteraction( Submission* pSubmission = comphelper::getFromUnoTunnel<Submission>( mxSubmissions->getItem( sID ) ); OSL_ENSURE( pSubmission != nullptr, "no submission?" ); - OSL_ENSURE( pSubmission->getModel() == Reference<XModel>( this ), + OSL_ENSURE( pSubmission->getModelImpl() == this, "wrong model" ); // submit. All exceptions are allowed to leave. diff --git a/forms/source/xforms/model_helper.hxx b/forms/source/xforms/model_helper.hxx index d8e98c98ec26..fbb563a1300b 100644 --- a/forms/source/xforms/model_helper.hxx +++ b/forms/source/xforms/model_helper.hxx @@ -92,14 +92,14 @@ protected: { auto pSubmission = comphelper::getFromUnoTunnel<Submission>( t ); OSL_ENSURE( pSubmission != nullptr, "invalid item?" ); - pSubmission->setModel( css::uno::Reference<css::xforms::XModel>( mpModel ) ); + pSubmission->setModel( mpModel ); } virtual void _remove( const T& t ) override { auto pSubmission = comphelper::getFromUnoTunnel<Submission>( t ); OSL_ENSURE( pSubmission != nullptr, "invalid item?" ); - pSubmission->setModel( css::uno::Reference<css::xforms::XModel>( ) ); + pSubmission->setModel( nullptr ); } }; diff --git a/forms/source/xforms/submission.cxx b/forms/source/xforms/submission.cxx index d8d81abd5b23..8260095102b3 100644 --- a/forms/source/xforms/submission.cxx +++ b/forms/source/xforms/submission.cxx @@ -85,7 +85,8 @@ Submission::~Submission() noexcept void Submission::setModel( const Reference<XModel>& xModel ) { - mxModel = xModel; + mxModel = dynamic_cast<Model*>(xModel.get()); + assert((!mxModel || !xModel) && "we only support an instance of Model here"); } @@ -202,12 +203,12 @@ bool Submission::doSubmit( const Reference< XInteractionHandler >& xHandler ) else if( !maRef.getExpression().isEmpty() ) { aExpression.setExpression( maRef.getExpression() ); - aEvalContext = comphelper::getFromUnoTunnel<Model>( mxModel )->getEvaluationContext(); + aEvalContext = mxModel->getEvaluationContext(); } else { aExpression.setExpression( "/" ); - aEvalContext = comphelper::getFromUnoTunnel<Model>( mxModel )->getEvaluationContext(); + aEvalContext = mxModel->getEvaluationContext(); } aExpression.evaluate( aEvalContext ); Reference<XXPathObject> xResult = aExpression.getXPath(); @@ -268,12 +269,9 @@ void Submission::liveCheck() throw RuntimeException(); } -Model* Submission::getModelImpl() const +css::uno::Reference<XModel> Submission::getModel() const { - Model* pModel = nullptr; - if( mxModel.is() ) - pModel = comphelper::getFromUnoTunnel<Model>( mxModel ); - return pModel; + return mxModel; } @@ -404,7 +402,7 @@ void SAL_CALL Submission::submitWithInteraction( { // as long as this class is not really threadsafe, we need to copy // the members we're interested in - Reference< XModel > xModel( mxModel ); + rtl::Reference< Model > xModel( mxModel ); OUString sID( msID ); if ( !xModel.is() || msID.isEmpty() ) @@ -413,12 +411,9 @@ void SAL_CALL Submission::submitWithInteraction( *this ); - Model* pModel = comphelper::getFromUnoTunnel<Model>( xModel ); - OSL_ENSURE( pModel != nullptr, "illegal model?" ); - // #i36765# #i47248# warning on submission of illegal data // check for validity (and query user if invalid) - bool bValid = pModel->isValid(); + bool bValid = xModel->isValid(); if( ! bValid ) { InvalidDataOnSubmitException aInvalidDataException( diff --git a/forms/source/xforms/submission.hxx b/forms/source/xforms/submission.hxx index 1e7f17e4cfc7..31c5b9af07b9 100644 --- a/forms/source/xforms/submission.hxx +++ b/forms/source/xforms/submission.hxx @@ -78,7 +78,7 @@ class Submission : public Submission_t private: /// the Model to which this Submission belongs; may be NULL - css::uno::Reference<css::xforms::XModel> mxModel; + rtl::Reference<Model> mxModel; // this will extract the document from the model that will be submitted css::uno::Reference< css::xml::dom::XDocumentFragment > @@ -96,8 +96,10 @@ public: /// get XForms model - css::uno::Reference<css::xforms::XModel> - getModel() const { return mxModel;} + css::uno::Reference<css::xforms::XModel> getModel() const; + + /// get the model implementation + xforms::Model* getModelImpl() const { return mxModel.get(); } /// set XForms model void setModel( @@ -163,9 +165,6 @@ private: /// @throws css::uno::RuntimeException void liveCheck(); - /// get the model implementation - xforms::Model* getModelImpl() const; - protected: |