canvas/source/vcl/canvas.cxx | 3 - canvas/source/vcl/canvasbitmap.cxx | 3 - canvas/source/vcl/canvascustomsprite.cxx | 3 - canvas/source/vcl/impltools.cxx | 3 - canvas/source/vcl/repainttarget.hxx | 4 + canvas/source/vcl/spritecanvas.cxx | 3 - include/sfx2/digitalsignatures.hxx | 11 +++- sfx2/Library_sfx.mk | 1 sfx2/source/doc/digitalsignatures.cxx | 30 +++++++++++++ sfx2/source/doc/docfile.cxx | 3 - xmlsecurity/source/component/documentdigitalsignatures.cxx | 6 +- 11 files changed, 56 insertions(+), 14 deletions(-)
New commits: commit 89803666621c07d1b1ac9d3bd883f0ca192a91a0 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Wed Dec 14 20:45:25 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Fri Dec 23 14:20:03 2022 +0000 loplugin:unocast (vclcanas::CanvasBitmap) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: If79f69507e939a25a5bbf82f818c44f26077dfce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144767 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/canvas/source/vcl/canvas.cxx b/canvas/source/vcl/canvas.cxx index 48527380f38b..2f6b513f35a0 100644 --- a/canvas/source/vcl/canvas.cxx +++ b/canvas/source/vcl/canvas.cxx @@ -24,7 +24,6 @@ #include <com/sun/star/lang/NoSupportException.hpp> #include <sal/log.hxx> #include <comphelper/diagnose_ex.hxx> -#include <comphelper/servicehelper.hxx> #include <vcl/outdev.hxx> #include "outdevholder.hxx" @@ -98,7 +97,7 @@ namespace vclcanvas } sal_Int64 Canvas::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { - return comphelper::getSomethingImpl<RepaintTarget>(aIdentifier, this); + return RepaintTarget::getSomething(aIdentifier); } bool Canvas::repaint( const GraphicObjectSharedPtr& rGrf, diff --git a/canvas/source/vcl/canvasbitmap.cxx b/canvas/source/vcl/canvasbitmap.cxx index 70ad59f24afa..5a913836ebe7 100644 --- a/canvas/source/vcl/canvasbitmap.cxx +++ b/canvas/source/vcl/canvasbitmap.cxx @@ -86,7 +86,8 @@ namespace vclcanvas } sal_Int64 CanvasBitmap::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { - return comphelper::getSomethingImpl<RepaintTarget>(aIdentifier, this); + return comphelper::getSomethingImpl( + aIdentifier, this, comphelper::FallbackToGetSomethingOf<RepaintTarget>{}); } BitmapEx CanvasBitmap::getBitmap() const diff --git a/canvas/source/vcl/canvascustomsprite.cxx b/canvas/source/vcl/canvascustomsprite.cxx index 1cd22bd3559b..58112d1955a3 100644 --- a/canvas/source/vcl/canvascustomsprite.cxx +++ b/canvas/source/vcl/canvascustomsprite.cxx @@ -23,7 +23,6 @@ #include <basegfx/point/b2dpoint.hxx> #include <cppuhelper/supportsservice.hxx> #include <comphelper/diagnose_ex.hxx> -#include <comphelper/servicehelper.hxx> #include <vcl/outdev.hxx> #include "canvascustomsprite.hxx" @@ -118,7 +117,7 @@ namespace vclcanvas } sal_Int64 CanvasCustomSprite::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { - return comphelper::getSomethingImpl<RepaintTarget>(aIdentifier, this); + return RepaintTarget::getSomething(aIdentifier); } // Sprite diff --git a/canvas/source/vcl/impltools.cxx b/canvas/source/vcl/impltools.cxx index 5539a92d1734..04209f94ac47 100644 --- a/canvas/source/vcl/impltools.cxx +++ b/canvas/source/vcl/impltools.cxx @@ -28,6 +28,7 @@ #include <basegfx/tuple/b2dtuple.hxx> #include <rtl/math.hxx> #include <comphelper/diagnose_ex.hxx> +#include <comphelper/servicehelper.hxx> #include <sal/log.hxx> #include <vcl/bitmapex.hxx> #include <vcl/canvastools.hxx> @@ -50,7 +51,7 @@ namespace vclcanvas::tools { // TODO(F3): CanvasCustomSprite should also be tunnelled // through (also implements XIntegerBitmap interface) - CanvasBitmap* pBitmapImpl = dynamic_cast< CanvasBitmap* >( xBitmap.get() ); + CanvasBitmap* pBitmapImpl = comphelper::getFromUnoTunnel< CanvasBitmap >( xBitmap ); if( pBitmapImpl ) { diff --git a/canvas/source/vcl/repainttarget.hxx b/canvas/source/vcl/repainttarget.hxx index 57c45882a3cd..3ef832fb3426 100644 --- a/canvas/source/vcl/repainttarget.hxx +++ b/canvas/source/vcl/repainttarget.hxx @@ -51,6 +51,10 @@ namespace vclcanvas const ::Size& rSz, const GraphicAttr& rAttr ) const = 0; + sal_Int64 getSomething(css::uno::Sequence<sal_Int8> const & id) { + return comphelper::getSomethingImpl(id, this); + } + static css::uno::Sequence<sal_Int8> const & getUnoTunnelId() { static comphelper::UnoIdInit const id; return id.getSeq(); diff --git a/canvas/source/vcl/spritecanvas.cxx b/canvas/source/vcl/spritecanvas.cxx index 04780d8f0375..b7984e70ddce 100644 --- a/canvas/source/vcl/spritecanvas.cxx +++ b/canvas/source/vcl/spritecanvas.cxx @@ -24,7 +24,6 @@ #include <com/sun/star/lang/NoSupportException.hpp> #include <cppuhelper/supportsservice.hxx> #include <comphelper/diagnose_ex.hxx> -#include <comphelper/servicehelper.hxx> #include "spritecanvas.hxx" #include "outdevholder.hxx" @@ -163,7 +162,7 @@ namespace vclcanvas } sal_Int64 SpriteCanvas::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { - return comphelper::getSomethingImpl<RepaintTarget>(aIdentifier, this); + return RepaintTarget::getSomething(aIdentifier); } bool SpriteCanvas::repaint( const GraphicObjectSharedPtr& rGrf, commit d5e0c2c8db71878d21c2a7255af08cf5f9a6dd04 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Dec 13 12:05:45 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Fri Dec 23 14:19:50 2022 +0000 loplugin:unocast (sfx2::DigitalSignatures) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I74c76452cf7921da55462581ef48aea86f58ea18 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144763 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/include/sfx2/digitalsignatures.hxx b/include/sfx2/digitalsignatures.hxx index b46cdd52e9d9..5e1891e250ed 100644 --- a/include/sfx2/digitalsignatures.hxx +++ b/include/sfx2/digitalsignatures.hxx @@ -12,14 +12,17 @@ #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/io/XStream.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/security/XCertificate.hpp> +#include <cppuhelper/implbase.hxx> #include <sal/types.h> +#include <sfx2/dllapi.h> namespace sfx2 { /// Extension of css::security::XDocumentDigitalSignatures for internal purposes. -class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") DigitalSignatures +class SFX2_DLLPUBLIC DigitalSignatures : public cppu::WeakImplHelper<css::lang::XUnoTunnel> { public: /// Same as signDocumentWithCertificate(), but passes the xModel as well. @@ -30,8 +33,12 @@ public: const css::uno::Reference<css::io::XStream>& xStream) = 0; + sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const& aIdentifier) override; + static css::uno::Sequence<sal_Int8> const& getUnoTunnelId(); + protected: - ~DigitalSignatures() noexcept = default; + DigitalSignatures(); + ~DigitalSignatures() override; }; } diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 7b1dee935ff3..0c1f654d4a1e 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -213,6 +213,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/doc/QuerySaveDocument \ sfx2/source/doc/SfxDocumentMetaData \ sfx2/source/doc/autoredactdialog \ + sfx2/source/doc/digitalsignatures \ sfx2/source/doc/docfac \ sfx2/source/doc/docfile \ sfx2/source/doc/docfilt \ diff --git a/sfx2/source/doc/digitalsignatures.cxx b/sfx2/source/doc/digitalsignatures.cxx new file mode 100644 index 000000000000..73f50cde19aa --- /dev/null +++ b/sfx2/source/doc/digitalsignatures.cxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> + +#include <comphelper/servicehelper.hxx> +#include <sfx2/digitalsignatures.hxx> + +sal_Int64 sfx2::DigitalSignatures::getSomething(css::uno::Sequence<sal_Int8> const& aIdentifier) +{ + return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence<sal_Int8> const& sfx2::DigitalSignatures::getUnoTunnelId() +{ + static comphelper::UnoIdInit const id; + return id.getSeq(); +} + +sfx2::DigitalSignatures::DigitalSignatures() = default; + +sfx2::DigitalSignatures::~DigitalSignatures() = default; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index c81b79e8ec4e..fdebd24107a6 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -78,6 +78,7 @@ #include <comphelper/propertyvalue.hxx> #include <comphelper/interaction.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/servicehelper.hxx> #include <comphelper/simplefileaccessinteraction.hxx> #include <comphelper/string.hxx> #include <framework/interaction.hxx> @@ -4008,7 +4009,7 @@ bool SfxMedium::SignDocumentContentUsingCertificate( uno::Reference< security::XDocumentDigitalSignatures > xSigner( security::DocumentDigitalSignatures::createWithVersionAndValidSignature( comphelper::getProcessComponentContext(), aODFVersion, bHasValidDocumentSignature ) ); - auto xModelSigner = dynamic_cast<sfx2::DigitalSignatures*>(xSigner.get()); + auto xModelSigner = comphelper::getFromUnoTunnel<sfx2::DigitalSignatures>(xSigner); if (!xModelSigner) { return bChanges; diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index d6b5782ba74f..4ab5851581ee 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -72,9 +72,9 @@ using namespace css::xml::crypto; namespace { class DocumentDigitalSignatures - : public cppu::WeakImplHelper<css::security::XDocumentDigitalSignatures, - css::lang::XInitialization, css::lang::XServiceInfo>, - public sfx2::DigitalSignatures + : public cppu::ImplInheritanceHelper<sfx2::DigitalSignatures, + css::security::XDocumentDigitalSignatures, + css::lang::XInitialization, css::lang::XServiceInfo> { private: css::uno::Reference<css::uno::XComponentContext> mxCtx;