13#include <com/sun/star/io/XInputStream.hpp>
14#include <com/sun/star/io/XOutputStream.hpp>
15#include <com/sun/star/io/XStream.hpp>
16#include <com/sun/star/io/XSeekable.hpp>
17#include <com/sun/star/packages/XPackageEncryption.hpp>
18#include <com/sun/star/uno/XComponentContext.hpp>
26using namespace css::io;
27using namespace css::uno;
28using namespace css::beans;
31 Reference<XStream>
const & xDocumentStream,
33 const Sequence<NamedValue>& rMediaEncData)
35 , mxDocumentStream(xDocumentStream)
36 , mrOleStorage(rOleStorage)
37 , mMediaEncData(rMediaEncData)
40 for (
int i = 0;
i < rMediaEncData.getLength();
i++)
42 if (rMediaEncData[
i].
Name ==
"CryptoType")
45 rMediaEncData[
i].Value >>= sCryptoType;
47 if (sCryptoType ==
"Standard")
48 sCryptoType =
"StrongEncryptionDataSpace";
52 mxContext->getServiceManager()->createInstanceWithArgumentsAndContext(
53 "com.sun.star.comp.oox.crypto." + sCryptoType,
aArguments,
mxContext), css::uno::UNO_QUERY);
57 SAL_WARN(
"oox",
"Requested encryption method \"" << sCryptoType <<
"\" is not supported");
70 Reference<XInputStream> xInputStream (
mxDocumentStream->getInputStream(), UNO_SET_THROW);
71 Reference<XSeekable> xSeekable(xInputStream, UNO_QUERY);
85 for (
const NamedValue & aStream : std::as_const(aStreams))
90 css::uno::Sequence<sal_Int8> aStreamSequence;
91 aStream.Value >>= aStreamSequence;
93 aBinaryOutputStream.
writeData(aStreamSequence);
95 aBinaryOutputStream.
close();
Wraps a UNO output stream and provides convenient access functions.
virtual void writeData(const StreamDataSequence &rData, size_t nAtomSize=1) override
Writes the passed data sequence.
void close() override
Flushes and closes the output stream.
bool isStorage() const
Returns true, if the object represents a valid storage.
css::uno::Reference< css::io::XOutputStream > openOutputStream(const OUString &rStreamName)
Opens and returns the specified output stream from the storage.
oox::ole::OleStorage & mrOleStorage
css::uno::Reference< css::packages::XPackageEncryption > mxPackageEncryption
css::uno::Reference< css::uno::XComponentContext > mxContext
DocumentEncryption(const css::uno::Reference< css::uno::XComponentContext > &rxContext, css::uno::Reference< css::io::XStream > const &xDocumentStream, oox::ole::OleStorage &rOleStorage, const css::uno::Sequence< css::beans::NamedValue > &rMediaEncData)
css::uno::Reference< css::io::XStream > mxDocumentStream
const css::uno::Sequence< css::beans::NamedValue > & mMediaEncData
Implements stream access for binary OLE storages.
Sequence< PropertyValue > aArguments
#define SAL_WARN(area, stream)