diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-04 12:02:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-04 19:21:07 +0200 |
commit | 41a46a306f40a7296c56bdeea0ba8a6d630aa15c (patch) | |
tree | 6dfa116917069cc48976ee005429f7da01028382 | |
parent | 50238bddf0e95169007cb90479cca86849a19007 (diff) |
dynamic_cast -> static_cast (tdf#130795)
the dynamic_cast is hot here,
and none of these dynamic_casts are necessary, we already assert that
they must succeed, so just use static_cast
Change-Id: I88ade90431c4da4792c778b5cdab22332ed1c428
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121637
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx | 3 | ||||
-rw-r--r-- | writerperfect/inc/ImportFilter.hxx | 2 | ||||
-rw-r--r-- | writerperfect/source/calc/MSWorksCalcImportFilter.cxx | 2 | ||||
-rw-r--r-- | writerperfect/source/writer/WordPerfectImportFilter.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/draw/XMLNumberStyles.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextFrameContext.cxx | 8 | ||||
-rw-r--r-- | xmloff/source/transform/TransformerBase.cxx | 3 |
8 files changed, 12 insertions, 14 deletions
diff --git a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx index 4e62aba199e7..27c483d98f71 100644 --- a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx +++ b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx @@ -191,8 +191,7 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& } else if (xConverter1 && xFastParser) { - auto pImport = dynamic_cast<SvXMLImport*>(xFastParser.get()); - assert(pImport); + auto pImport = static_cast<SvXMLImport*>(xFastParser.get()); Reference<XDocumentHandler> xLegacyDocHandler = new SvXMLLegacyToFastDocHandler(pImport); if (!xConverter1->importer(aDescriptor,xLegacyDocHandler,msUserData)) { if (xStatusIndicator.is()) diff --git a/writerperfect/inc/ImportFilter.hxx b/writerperfect/inc/ImportFilter.hxx index 972bda6b7d0d..69b0e77631e0 100644 --- a/writerperfect/inc/ImportFilter.hxx +++ b/writerperfect/inc/ImportFilter.hxx @@ -87,7 +87,7 @@ public: // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here // writes to in-memory target doc DocumentHandler aHandler( - new SvXMLLegacyToFastDocHandler(dynamic_cast<SvXMLImport*>(xInternalHandler.get()))); + new SvXMLLegacyToFastDocHandler(static_cast<SvXMLImport*>(xInternalHandler.get()))); WPXSvInputStream input(xInputStream); diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx index 494991878282..c43be95bc7bf 100644 --- a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx +++ b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx @@ -333,7 +333,7 @@ MSWorksCalcImportFilter::filter(const css::uno::Sequence<css::beans::PropertyVal // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here // writes to in-memory target doc writerperfect::DocumentHandler aHandler( - new SvXMLLegacyToFastDocHandler(dynamic_cast<SvXMLImport*>(xInternalHandler.get()))); + new SvXMLLegacyToFastDocHandler(static_cast<SvXMLImport*>(xInternalHandler.get()))); writerperfect::WPXSvInputStream input(xInputStream); OdsGenerator exporter; diff --git a/writerperfect/source/writer/WordPerfectImportFilter.cxx b/writerperfect/source/writer/WordPerfectImportFilter.cxx index 8888134e2ebf..8779fb618d19 100644 --- a/writerperfect/source/writer/WordPerfectImportFilter.cxx +++ b/writerperfect/source/writer/WordPerfectImportFilter.cxx @@ -138,7 +138,7 @@ bool WordPerfectImportFilter::importImpl( // OO Document Handler: abstract class to handle document SAX messages, concrete implementation here // writes to in-memory target doc DocumentHandler aHandler( - new SvXMLLegacyToFastDocHandler(dynamic_cast<SvXMLImport*>(xInternalHandler.get()))); + new SvXMLLegacyToFastDocHandler(static_cast<SvXMLImport*>(xInternalHandler.get()))); OdtGenerator collector; collector.addDocumentHandler(&aHandler, ODF_FLAT_XML); diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index a4f709836427..ea5e88b47603 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -785,7 +785,7 @@ void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element, const SvXMLImportContextRef & pHandler = maContexts.top(); SAL_INFO("xmloff.core", "calling createFastChildContext on " << typeid(*pHandler.get()).name()); auto tmp = pHandler->createFastChildContext( Element, Attribs ); - xContext = dynamic_cast<SvXMLImportContext*>(tmp.get()); + xContext = static_cast<SvXMLImportContext*>(tmp.get()); assert((tmp && xContext) || (!tmp && !xContext)); } else @@ -823,7 +823,7 @@ void SAL_CALL SvXMLImport::startUnknownElement (const OUString & rNamespace, con const SvXMLImportContextRef & pHandler = maContexts.top(); SAL_INFO("xmloff.core", "calling createUnknownChildContext on " << typeid(*pHandler.get()).name()); auto tmp = pHandler->createUnknownChildContext( rNamespace, rName, Attribs ); - xContext = dynamic_cast<SvXMLImportContext*>(tmp.get()); + xContext = static_cast<SvXMLImportContext*>(tmp.get()); assert((tmp && xContext) || (!tmp && !xContext)); } else diff --git a/xmloff/source/draw/XMLNumberStyles.cxx b/xmloff/source/draw/XMLNumberStyles.cxx index 33bafa2b4435..baf9f1fbf924 100644 --- a/xmloff/source/draw/XMLNumberStyles.cxx +++ b/xmloff/source/draw/XMLNumberStyles.cxx @@ -704,7 +704,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLNumberFormatImpor const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { return new SdXMLNumberFormatMemberImportContext( GetImport(), nElement, xAttrList, - this, &dynamic_cast<SvXMLImportContext&>(*SvXMLNumFormatContext::createFastChildContext( nElement, xAttrList )) ); + this, static_cast<SvXMLImportContext*>(SvXMLNumFormatContext::createFastChildContext( nElement, xAttrList ).get()) ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index fdf40897e563..0100a25ef03e 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -1636,7 +1636,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextFrameContext::c // note: no more draw:image can be added once we get here m_xImplContext = solveMultipleImages(); } - xContext = &dynamic_cast<SvXMLImportContext&>(*m_xImplContext->createFastChildContext( nElement, xAttrList )); + xContext = static_cast<SvXMLImportContext*>(m_xImplContext->createFastChildContext( nElement, xAttrList ).get()); } else if (nElement == XML_ELEMENT(LO_EXT, XML_SIGNATURELINE)) { @@ -1645,7 +1645,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextFrameContext::c // note: no more draw:image can be added once we get here m_xImplContext = solveMultipleImages(); } - xContext = &dynamic_cast<SvXMLImportContext&>(*m_xImplContext->createFastChildContext(nElement, xAttrList)); + xContext = static_cast<SvXMLImportContext*>(m_xImplContext->createFastChildContext(nElement, xAttrList).get()); } else if (nElement == XML_ELEMENT(LO_EXT, XML_QRCODE)) { @@ -1654,11 +1654,11 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextFrameContext::c // note: no more draw:image can be added once we get here m_xImplContext = solveMultipleImages(); } - xContext = &dynamic_cast<SvXMLImportContext&>(*m_xImplContext->createFastChildContext(nElement, xAttrList)); + xContext = static_cast<SvXMLImportContext*>(m_xImplContext->createFastChildContext(nElement, xAttrList).get()); } else if (nElement == XML_ELEMENT(DRAW, XML_A)) { - xContext = &dynamic_cast<SvXMLImportContext&>(*m_xImplContext->createFastChildContext(nElement, xAttrList)); + xContext = static_cast<SvXMLImportContext*>(m_xImplContext->createFastChildContext(nElement, xAttrList).get()); } else { diff --git a/xmloff/source/transform/TransformerBase.cxx b/xmloff/source/transform/TransformerBase.cxx index f75a2755223e..90f8b198862a 100644 --- a/xmloff/source/transform/TransformerBase.cxx +++ b/xmloff/source/transform/TransformerBase.cxx @@ -387,8 +387,7 @@ void SAL_CALL XMLTransformerBase::initialize( const Sequence< Any >& aArguments css::uno::Reference< XFastDocumentHandler > xFastHandler; if( (rArgument >>= xFastHandler) && xFastHandler ) { - SvXMLImport *pFastHandler = dynamic_cast<SvXMLImport*>( xFastHandler.get() ); - assert(pFastHandler); + SvXMLImport *pFastHandler = static_cast<SvXMLImport*>( xFastHandler.get() ); m_xHandler.set( new SvXMLLegacyToFastDocHandler( pFastHandler ) ); } // document handler |