From 3f19decc2cdf57bd4197f179cfd2f8b2e8805865 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 25 Apr 2024 16:18:24 +0200 Subject: use more concrete UNO classes in writerfilter (SwXTextDocument) Change-Id: If07817eb5cc687ce8472d2a08c08acf00d3c76e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166812 Tested-by: Noel Grandin Reviewed-by: Noel Grandin --- .../writerfilter/dmapper/FormControlHelper.cxx | 37 +++++++--------------- .../writerfilter/dmapper/FormControlHelper.hxx | 6 ++-- 2 files changed, 16 insertions(+), 27 deletions(-) (limited to 'sw') diff --git a/sw/source/writerfilter/dmapper/FormControlHelper.cxx b/sw/source/writerfilter/dmapper/FormControlHelper.cxx index 40f5d703815e..4baf7490d2cf 100644 --- a/sw/source/writerfilter/dmapper/FormControlHelper.cxx +++ b/sw/source/writerfilter/dmapper/FormControlHelper.cxx @@ -41,6 +41,8 @@ #include #include #include +#include +#include namespace writerfilter::dmapper { @@ -53,11 +55,9 @@ struct FormControlHelper::FormControlHelper_Impl : public virtual SvRefBase uno::Reference rDrawPage; uno::Reference rForm; uno::Reference rFormComponent; - uno::Reference rServiceFactory; - uno::Reference rTextDocument; + rtl::Reference mxTextDocument; uno::Reference const & getDrawPage(); - uno::Reference const & getServiceFactory(); uno::Reference const & getForm(); uno::Reference getFormComps(); }; @@ -66,23 +66,13 @@ uno::Reference const & FormControlHelper::FormControlHelper_ { if (! rDrawPage.is()) { - uno::Reference - xDrawPageSupplier(rTextDocument, uno::UNO_QUERY); - if (xDrawPageSupplier.is()) - rDrawPage = xDrawPageSupplier->getDrawPage(); + if (mxTextDocument) + rDrawPage = mxTextDocument->getDrawPage(); } return rDrawPage; } -uno::Reference const & FormControlHelper::FormControlHelper_Impl::getServiceFactory() -{ - if (! rServiceFactory.is()) - rServiceFactory.set(rTextDocument, uno::UNO_QUERY); - - return rServiceFactory; -} - uno::Reference const & FormControlHelper::FormControlHelper_Impl::getForm() { if (! rForm.is()) @@ -103,7 +93,7 @@ uno::Reference const & FormControlHelper::FormControlHelper_Impl::g sFormName = sDOCXForm + OUString::number(nUnique); } - uno::Reference xForm(getServiceFactory()->createInstance("com.sun.star.form.component.Form")); + uno::Reference xForm(mxTextDocument->createInstance("com.sun.star.form.component.Form")); if (xForm.is()) { uno::Reference @@ -131,12 +121,12 @@ uno::Reference FormControlHelper::FormControlHelper_ } FormControlHelper::FormControlHelper(FieldId eFieldId, - uno::Reference const& xTextDocument, + rtl::Reference const& xTextDocument, FFDataHandler::Pointer_t pFFData) : m_pFFData(std::move(pFFData)), m_pImpl(new FormControlHelper_Impl) { m_pImpl->m_eFieldId = eFieldId; - m_pImpl->rTextDocument = xTextDocument; + m_pImpl->mxTextDocument = xTextDocument; } FormControlHelper::~FormControlHelper() @@ -148,13 +138,10 @@ bool FormControlHelper::createCheckbox(uno::Reference const& x { if ( !m_pFFData ) return false; - uno::Reference - xServiceFactory(m_pImpl->getServiceFactory()); - - if (! xServiceFactory.is()) + if (! m_pImpl->mxTextDocument) return false; - uno::Reference xInterface = xServiceFactory->createInstance("com.sun.star.form.component.CheckBox"); + uno::Reference xInterface = m_pImpl->mxTextDocument->createInstance("com.sun.star.form.component.CheckBox"); if (!xInterface.is()) return false; @@ -342,10 +329,10 @@ void FormControlHelper::insertControl(uno::Reference const& xT uno::Any aAny(m_pImpl->rFormComponent); xFormComps->insertByIndex(xFormComps->getCount(), aAny); - if (! m_pImpl->getServiceFactory().is()) + if (! m_pImpl->mxTextDocument ) return; - uno::Reference xInterface = m_pImpl->getServiceFactory()->createInstance("com.sun.star.drawing.ControlShape"); + uno::Reference xInterface = m_pImpl->mxTextDocument->createInstance("com.sun.star.drawing.ControlShape"); if (! xInterface.is()) return; diff --git a/sw/source/writerfilter/dmapper/FormControlHelper.hxx b/sw/source/writerfilter/dmapper/FormControlHelper.hxx index 326637f85f78..6b0f39dd5ab1 100644 --- a/sw/source/writerfilter/dmapper/FormControlHelper.hxx +++ b/sw/source/writerfilter/dmapper/FormControlHelper.hxx @@ -23,6 +23,9 @@ #include #include #include "FieldTypes.hxx" +#include + +class SwXTextDocument; namespace writerfilter::dmapper { @@ -30,8 +33,7 @@ class FormControlHelper : public virtual SvRefBase { public: typedef tools::SvRef Pointer_t; - FormControlHelper(FieldId eFieldId, - css::uno::Reference const& rTextDocument, + FormControlHelper(FieldId eFieldId, rtl::Reference const& rTextDocument, FFDataHandler::Pointer_t pFFData); ~FormControlHelper() override; -- cgit