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 <sbergman@redhat.com>
This commit is contained in:
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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: */
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user