Kaydet (Commit) 5d0b2b01 authored tarafından Noel Grandin's avatar Noel Grandin

fdo#46808, convert comphelper::OStorageHelper to XComponentContext

And drop the optional parameter on CreatePackageEncryptionData
because no-one is using it.

Change-Id: Ia83ebfc099dd121273d2c39431d015b3bc0abd81
üst a9934b36
......@@ -23,7 +23,6 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include "comphelper/comphelperdllapi.h"
......@@ -173,9 +172,7 @@ public:
static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >
CreatePackageEncryptionData(
const ::rtl::OUString& aPassword,
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSF
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() );
const ::rtl::OUString& aPassword );
static sal_Bool IsValidZipEntryFileName( const ::rtl::OUString& aName, sal_Bool bSlashAllowed );
static sal_Bool IsValidZipEntryFileName( const sal_Unicode *pChar, sal_Int32 nLength, sal_Bool bSlashAllowed );
......
......@@ -29,6 +29,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/beans/IllegalTypeException.hpp>
#include <com/sun/star/xml/crypto/NSSInitializer.hpp>
#include <com/sun/star/xml/crypto/XDigestContext.hpp>
#include <com/sun/star/xml/crypto/XDigestContextSupplier.hpp>
#include <com/sun/star/xml/crypto/DigestID.hpp>
......@@ -376,7 +377,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromStream(
}
// ----------------------------------------------------------------------
uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData( const ::rtl::OUString& aPassword, const uno::Reference< lang::XMultiServiceFactory >& xSF )
uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData( const ::rtl::OUString& aPassword )
{
// TODO/LATER: Should not the method be part of DocPasswordHelper?
uno::Sequence< beans::NamedValue > aEncryptionData;
......@@ -386,11 +387,9 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData(
// generate SHA256 start key
try
{
uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
if ( !xFactory.is() )
throw uno::RuntimeException();
uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
uno::Reference< xml::crypto::XDigestContextSupplier > xDigestContextSupplier( xFactory->createInstance( OUString( "com.sun.star.xml.crypto.NSSInitializer" ) ), uno::UNO_QUERY_THROW );
uno::Reference< xml::crypto::XNSSInitializer > xDigestContextSupplier = xml::crypto::NSSInitializer::create(xContext);
uno::Reference< xml::crypto::XDigestContext > xDigestContext( xDigestContextSupplier->getDigestContext( xml::crypto::DigestID::SHA256, uno::Sequence< beans::NamedValue >() ), uno::UNO_SET_THROW );
::rtl::OString aUTF8Password( ::rtl::OUStringToOString( aPassword, RTL_TEXTENCODING_UTF8 ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment