loplugin:unocast (SignatureVerifierImpl)

(See the upcoming commit introducing that loplugin:unocast on why such
dynamic_casts from UNO types are dangerous.)

Change-Id: I3c2f1eae3d9b2b5ecb6a05c9e7149946b63bb11f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144697
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2022-12-22 06:56:59 +00:00
parent 1a7ad0c10d
commit 24e14afd1b
3 changed files with 19 additions and 3 deletions
@@ -22,6 +22,7 @@
#include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultBroadcaster.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <cppuhelper/implbase.hxx>
#include <xmlsecuritydllapi.h>
@@ -35,7 +36,8 @@ typedef cppu::ImplInheritanceHelper
SignatureEngine,
css::xml::crypto::sax::XSignatureVerifyResultBroadcaster,
css::lang::XInitialization,
css::lang::XServiceInfo
css::lang::XServiceInfo,
css::lang::XUnoTunnel
> SignatureVerifierImpl_Base;
class SignatureVerifierImpl final : public SignatureVerifierImpl_Base
@@ -74,6 +76,9 @@ public:
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override;
static css::uno::Sequence<sal_Int8> const & getUnoTunnelId();
void updateSignature( const css::uno::Reference< css::xml::crypto::XXMLSignature >& xSignature,
const css::uno::Reference< css::xml::crypto::XXMLSecurityContext >& xContext ) { m_xXMLSignature = xSignature; m_xXMLSecurityContext = xContext; }
};
@@ -21,6 +21,7 @@
#include <framework/signatureverifierimpl.hxx>
#include <framework/xmlsignaturetemplateimpl.hxx>
#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <osl/diagnose.h>
#include <rtl/ref.hxx>
@@ -127,4 +128,13 @@ css::uno::Sequence< OUString > SAL_CALL SignatureVerifierImpl::getSupportedServi
return SignatureVerifierImpl_getSupportedServiceNames();
}
sal_Int64 SignatureVerifierImpl::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
return comphelper::getSomethingImpl(aIdentifier, this);
}
css::uno::Sequence<sal_Int8> const & SignatureVerifierImpl::getUnoTunnelId() {
static comphelper::UnoIdInit const id;
return id.getSeq();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+3 -2
View File
@@ -42,6 +42,7 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/seqstream.hxx>
#include <comphelper/servicehelper.hxx>
namespace com::sun::star::graphic { class XGraphic; }
@@ -133,8 +134,8 @@ void XSecController::switchGpgSignature()
return;
SignatureVerifierImpl* pImpl=
dynamic_cast<SignatureVerifierImpl*>(
m_vInternalSignatureInformations.back().xReferenceResolvedListener.get());
comphelper::getFromUnoTunnel<SignatureVerifierImpl>(
m_vInternalSignatureInformations.back().xReferenceResolvedListener);
if (pImpl)
{
css::uno::Reference<css::xml::crypto::XSEInitializer> xGpgSEInitializer(