From 4d6c23216559eb48f9943bb49d6e475a6d64ba15 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 16 Dec 2022 23:02:08 +0100 Subject: loplugin:unocast (oox::ForumlaImExportBase) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I11bc363447c44319bc47f7eebb7084f64ea85511 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144400 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- oox/source/drawingml/shape.cxx | 3 ++- oox/source/export/shapes.cxx | 3 ++- oox/source/mathml/imexport.cxx | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'oox') diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index d5b02455ab35..7c2920eabcbf 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -1295,7 +1296,7 @@ Reference< XShape > const & Shape::createAndInsert( { uno::Reference const xMathModel(xObj->getComponent()); oox::FormulaImExportBase *const pMagic( - dynamic_cast(xMathModel.get())); + comphelper::getFromUnoTunnel(xMathModel)); assert(pMagic); pMagic->readFormulaOoxml(*pMathXml); } diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 137c69fe7c33..ce3787069adb 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -71,6 +71,7 @@ #include #include #include +#include #include #include #include @@ -2473,7 +2474,7 @@ void ShapeExport::WriteMathShape(Reference const& xShape) mpFS->startElementNS(XML_a14, XML_m); oox::FormulaImExportBase *const pMagic( - dynamic_cast(xMathModel.get())); + comphelper::getFromUnoTunnel(xMathModel)); assert(pMagic); pMagic->writeFormulaOoxml(GetFS(), GetFB()->getVersion(), GetDocumentType(), FormulaImExportBase::eFormulaAlign::INLINE); diff --git a/oox/source/mathml/imexport.cxx b/oox/source/mathml/imexport.cxx index 2b5990679bea..ad0389051b42 100644 --- a/oox/source/mathml/imexport.cxx +++ b/oox/source/mathml/imexport.cxx @@ -13,6 +13,7 @@ #include #include +#include #include @@ -21,6 +22,15 @@ using namespace ::com::sun::star; namespace oox { +sal_Int64 FormulaImExportBase::getSomething(css::uno::Sequence const & aIdentifier) { + return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence const & FormulaImExportBase::getUnoTunnelId() { + static comphelper::UnoIdInit const id; + return id.getSeq(); +} + FormulaImExportBase::FormulaImExportBase() { } -- cgit