include/xmloff/xmlimp.hxx | 2 +- reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx | 3 ++- sdext/source/pdfimport/sax/emitcontext.cxx | 3 ++- writerperfect/source/common/DocumentHandler.cxx | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-)
New commits: commit 5f70b0b9f6bc4ab145ddbd9155590ed4a3b1b9ec Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Dec 15 14:49:35 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Fri Dec 16 22:03:14 2022 +0000 loplugin:unocast (SvXMLImport) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I773095e51958a0a050bcece6f44fe3847f962eaf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144333 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx index 26873175268d..14c7b92556b1 100644 --- a/include/xmloff/xmlimp.hxx +++ b/include/xmloff/xmlimp.hxx @@ -176,7 +176,7 @@ public: virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override; }; -class XMLOFF_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") SvXMLImport : public cppu::WeakImplHelper< +class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper< css::xml::sax::XFastDocumentHandler, css::lang::XServiceInfo, css::lang::XInitialization, diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx index eb3da46309f8..3f919548d47d 100644 --- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/reflection/ProxyFactory.hpp> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/namedvaluecollection.hxx> +#include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <utility> #include <xmloff/attrlist.hxx> @@ -339,7 +340,7 @@ void SAL_CALL ImportDocumentHandler::initialize( const uno::Sequence< uno::Any > if (!m_xDocumentHandler.is() || !m_xModel.is()) throw uno::Exception("no delegatee and no model", nullptr); - m_xDelegatee.set(new SvXMLLegacyToFastDocHandler(dynamic_cast<SvXMLImport*>(m_xDocumentHandler.get()))); + m_xDelegatee.set(new SvXMLLegacyToFastDocHandler(comphelper::getFromUnoTunnel<SvXMLImport>(m_xDocumentHandler))); m_xDatabaseDataProvider.set(m_xModel->getDataProvider(),uno::UNO_QUERY); if ( !m_xDatabaseDataProvider.is() ) diff --git a/sdext/source/pdfimport/sax/emitcontext.cxx b/sdext/source/pdfimport/sax/emitcontext.cxx index a923488d688d..59f110191bfd 100644 --- a/sdext/source/pdfimport/sax/emitcontext.cxx +++ b/sdext/source/pdfimport/sax/emitcontext.cxx @@ -25,6 +25,7 @@ #include <rtl/strbuf.hxx> #include <osl/diagnose.h> #include <com/sun/star/xml/sax/SAXException.hpp> +#include <comphelper/servicehelper.hxx> #include <xmloff/xmlimp.hxx> #if OSL_DEBUG_LEVEL > 0 @@ -42,7 +43,7 @@ SaxEmitter::SaxEmitter( const uno::Reference< xml::sax::XDocumentHandler >& xDoc m_xDocHdl( xDocHdl ) { OSL_PRECOND(m_xDocHdl.is(), "SaxEmitter(): invalid doc handler"); - if (SvXMLImport *pFastHandler = dynamic_cast<SvXMLImport*>(m_xDocHdl.get())) + if (SvXMLImport *pFastHandler = comphelper::getFromUnoTunnel<SvXMLImport>(m_xDocHdl)) m_xDocHdl.set( new SvXMLLegacyToFastDocHandler( pFastHandler ) ); try { diff --git a/writerperfect/source/common/DocumentHandler.cxx b/writerperfect/source/common/DocumentHandler.cxx index 6b5ffe58ad9e..6cf42c168a51 100644 --- a/writerperfect/source/common/DocumentHandler.cxx +++ b/writerperfect/source/common/DocumentHandler.cxx @@ -15,6 +15,7 @@ #include <com/sun/star/xml/sax/XDocumentHandler.hpp> #include <com/sun/star/xml/sax/XAttributeList.hpp> +#include <comphelper/servicehelper.hxx> #include <xmloff/attrlist.hxx> #include <xmloff/xmlimp.hxx> @@ -115,7 +116,7 @@ using com::sun::star::xml::sax::XDocumentHandler; DocumentHandler::DocumentHandler(Reference<XDocumentHandler> const& xHandler) : mxHandler(xHandler) { - if (SvXMLImport* pFastHandler = dynamic_cast<SvXMLImport*>(mxHandler.get())) + if (SvXMLImport* pFastHandler = comphelper::getFromUnoTunnel<SvXMLImport>(mxHandler)) mxHandler.set(new SvXMLLegacyToFastDocHandler(pFastHandler)); }