22#include <sfx2/sfxsids.hrc>
31#include <com/sun/star/packages/XPackageEncryption.hpp>
32#include <com/sun/star/uno/XComponentContext.hpp>
58 for (
const auto & aElement : aElements)
60 OUString sStreamFullName =
sPrefix.size() ? OUString::Concat(
sPrefix) +
"/" + aElement.GetName() : aElement.GetName();
61 if (aElement.IsStorage())
72 sal_Int32 nStreamSize = rStream->GetSize();
74 oData.realloc(nStreamSize);
75 sal_Int32 nReadBytes = rStream->ReadBytes(oData.getArray(), nStreamSize);
76 if (nStreamSize == nReadBytes)
77 aStreamsData[sStreamFullName] <<= oData;
90 Reference< css::packages::XPackageEncryption > xPackageEncryption(
91 xComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext(
92 "com.sun.star.comp.oox.crypto.DRMDataSpace",
aArguments, xComponentContext), UNO_QUERY);
94 if (!xPackageEncryption.is())
105 if (!xPackageEncryption->readEncryptionInfo(aStreams))
112 if (!rContentStream.
is())
117 rNewStorageStrm = std::make_shared<SvMemoryStream>();
122 if (!xPackageEncryption->decrypt(xInputStream, xDecryptedStream))
128 rNewStorageStrm->Seek(0);
131 aNewStorage =
new SotStorage(*rNewStorageStrm);
134 Sequence<NamedValue> aEncryptionData = xPackageEncryption->createEncryptionData(
"");
137 catch (
const std::exception&)
148 std::shared_ptr<SvStream> aDecryptedStorageStrm;
150 if( !pStorage->GetError() )
155 OUString sDualStorage(
"PP97_DUALSTORAGE" );
156 if ( pStorage->IsContained( sDualStorage ) )
158 xDualStorage = pStorage->OpenSotStorage( sDualStorage, StreamMode::STD_READ );
159 pStorage = xDualStorage;
161 if (pStorage->IsContained(
"\011DRMContent"))
169 pDocStream->SetVersion( pStorage->GetVersion() );
170 pDocStream->SetCryptMaskKey(pStorage->GetKey());
172 if ( pStorage->IsStream(
"EncryptedSummary" ) )
193 sal_uInt32 nCnvrtFlags = 0;
204 nCnvrtFlags |= 0x8000;
210 PropertyValue aProperty;
211 aProperty.Name =
"BaseURI";
217 Sequence< NamedValue > aEncryptionData;
218 Reference< css::packages::XPackageEncryption > xPackageEncryption;
220 std::shared_ptr<SvStream> pMediaStrm;
221 if (pEncryptionDataItem && (pEncryptionDataItem->
GetValue() >>= aEncryptionData))
226 if (sCryptoType.getLength())
230 Any(NamedValue(
"Binary",
Any(
true))) };
231 xPackageEncryption.set(
232 xComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext(
233 "com.sun.star.comp.oox.crypto." + sCryptoType,
aArguments, xComponentContext), UNO_QUERY);
235 if (xPackageEncryption.is())
238 pMediaStrm = std::make_shared<SvMemoryStream>();
239 pOutputStrm = pMediaStrm.get();
254 if (xPackageEncryption.is())
257 pOutputStrm->
Seek(0);
259 xPackageEncryption->setupEncryption(aEncryptionData);
262 Sequence<NamedValue> aStreams = xPackageEncryption->encrypt(xInputStream);
265 for (
const NamedValue & aStreamData : std::as_const(aStreams))
274 OUString sPathElem = aStreamData.Name.getToken(0, L
'/',
idx);
275 if (!sPathElem.isEmpty())
279 sFileName = sPathElem;
283 pStorage = pStorage->OpenSotStorage(sPathElem);
286 }
while (pStorage &&
idx >= 0);
300 Sequence<sal_Int8> aStreamContent;
301 aStreamData.Value >>= aStreamContent;
302 size_t nBytesWritten = pStream->WriteBytes(aStreamContent.getConstArray(), aStreamContent.getLength());
303 if (nBytesWritten !=
static_cast<size_t>(aStreamContent.getLength()))
309 xEncryptedRootStrg->Commit();
PropertiesInfo aProperties
::sd::DrawDocShell & mrDocShell
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator
css::uno::Reference< css::frame::XModel > mxModel
void CreateStatusIndicator()
SdDrawDocument & mrDocument
SdPPTFilter(SfxMedium &rMedium, ::sd::DrawDocShell &rDocShell)
bool Import()
these methods are necessary for the export to PowerPoint
virtual ~SdPPTFilter() override
void PreSaveBasic()
restores the original basic storage
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void SetError(ErrCode nError)
OUString GetBaseURL(bool bForSaving=false)
SfxItemSet & GetItemSet() const
SvStream * GetOutStream()
const css::uno::Any & GetValue() const
void FillInfoList(SvStorageInfoList *) const
tools::SvRef< SotStorageStream > OpenSotStream(const OUString &rEleName, StreamMode=StreamMode::STD_READWRITE)
SotStorage * OpenSotStorage(const OUString &rEleName, StreamMode=StreamMode::STD_READWRITE, bool transacted=true)
sal_uInt64 Seek(sal_uInt64 nPos)
bool IsLoadPPointBasicStorage() const
bool IsCalc2Excel() const
static SvtFilterOptions & Get()
bool IsImpress2PowerPoint() const
bool IsWriter2WinWord() const
bool IsEnablePPTPreview() const
bool IsMath2MathType() const
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
css::uno::Sequence< css::beans::NamedValue > getAsConstNamedValueList() const
SAL_DLLPUBLIC_EXPORT bool SaveVBA(SfxObjectShell &rDocShell, SvMemoryStream *&pBas)
SAL_DLLPUBLIC_EXPORT bool ExportPPT(const std::vector< css::beans::PropertyValue > &rMediaData, tools::SvRef< SotStorage > const &rSvStorage, css::uno::Reference< css::frame::XModel > const &rXModel, css::uno::Reference< css::task::XStatusIndicator > const &rXStatInd, SvMemoryStream *pVBA, sal_uInt32 nCnvrtFlags)
#define SVSTREAM_WRONGVERSION
Sequence< PropertyValue > aArguments
#define OLE_STARIMPRESS_2_POWERPOINT
#define OLE_STARWRITER_2_WINWORD
#define OLE_STARCALC_2_EXCEL
#define OLE_STARMATH_2_MATHTYPE
Reference< XComponentContext > getProcessComponentContext()
SAL_DLLPUBLIC_EXPORT bool ImportPPT(SdDrawDocument *pDocument, SvStream &rDocStream, SotStorage &rStorage, SfxMedium &rMedium)
static tools::SvRef< SotStorage > lcl_DRMDecrypt(const SfxMedium &rMedium, const tools::SvRef< SotStorage > &rStorage, std::shared_ptr< SvStream > &rNewStorageStrm)
static void lcl_getListOfStreams(SotStorage *pStorage, comphelper::SequenceAsHashMap &aStreamsData, std::u16string_view sPrefix)
std::vector< SvStorageInfo > SvStorageInfoList
#define ERRCODE_SVX_READ_FILTER_PPOINT