no need to load ExportPPT symbol at runtime
Change-Id: I01e06fe89f95141a177298e400ccd0f54c2a05db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139936 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -183,7 +183,6 @@ with open("bin/find-can-be-private-symbols.functions.results", "wt") as f:
|
||||
elif sym == "CreateDialogFactory": continue
|
||||
elif sym == "CreateUnoWrapper": continue
|
||||
elif sym == "ExportDOC": continue
|
||||
elif sym == "ExportPPT": continue
|
||||
elif sym == "ExportRTF": continue
|
||||
elif sym == "GetSaveWarningOfMSVBAStorage_ww8": continue
|
||||
elif sym == "GetSpecialCharsForEdit": continue
|
||||
|
||||
+17
-6
@@ -21,16 +21,19 @@
|
||||
|
||||
#include <osl/module.h>
|
||||
#include <rtl/ustring.hxx>
|
||||
#include <tools/ref.hxx>
|
||||
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||
#include <com/sun/star/frame/XModel.hpp>
|
||||
#include <com/sun/star/task/XStatusIndicator.hpp>
|
||||
#include "sddllapi.h"
|
||||
#include <vector>
|
||||
|
||||
// SdFilter
|
||||
class SfxMedium;
|
||||
namespace sd {
|
||||
class DrawDocShell;
|
||||
}
|
||||
class SdDrawDocument;
|
||||
namespace osl { class Module; }
|
||||
namespace sd { class DrawDocShell; }
|
||||
class SdDrawDocument;
|
||||
class SfxMedium;
|
||||
class SotStorage;
|
||||
class SvMemoryStream;
|
||||
|
||||
class SdFilter
|
||||
{
|
||||
@@ -63,4 +66,12 @@ private:
|
||||
|
||||
};
|
||||
|
||||
SD_DLLPUBLIC 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 );
|
||||
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include <sfx2/docinf.hxx>
|
||||
#include <oox/export/utils.hxx>
|
||||
#include <oox/ole/olehelper.hxx>
|
||||
#include <sdfilter.hxx>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
@@ -1417,7 +1418,7 @@ void PPTWriter::ImplWriteAtomEnding()
|
||||
|
||||
// - exported function -
|
||||
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool ExportPPT( const std::vector< css::beans::PropertyValue >& rMediaData,
|
||||
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,
|
||||
|
||||
+111
-131
@@ -40,22 +40,12 @@ using namespace ::com::sun::star::beans;
|
||||
using namespace ::com::sun::star::task;
|
||||
using namespace ::com::sun::star::frame;
|
||||
|
||||
typedef sal_Bool ( *ExportPPTPointer )( const std::vector< css::beans::PropertyValue >&, tools::SvRef<SotStorage> const&,
|
||||
Reference< XModel > const &,
|
||||
Reference< XStatusIndicator > const &,
|
||||
SvMemoryStream*, sal_uInt32 nCnvrtFlags );
|
||||
|
||||
typedef sal_Bool ( *ImportPPTPointer )( SdDrawDocument*, SvStream&, SotStorage&, SfxMedium& );
|
||||
|
||||
typedef sal_Bool ( *SaveVBAPointer )( SfxObjectShell&, SvMemoryStream*& );
|
||||
|
||||
#ifdef DISABLE_DYNLOADING
|
||||
|
||||
extern "C" sal_Bool ExportPPT( const std::vector< css::beans::PropertyValue >&, tools::SvRef<SotStorage> const&,
|
||||
Reference< XModel > const &,
|
||||
Reference< XStatusIndicator > const &,
|
||||
SvMemoryStream*, sal_uInt32 nCnvrtFlags );
|
||||
|
||||
extern "C" sal_Bool ImportPPT( SdDrawDocument*, SvStream&, SotStorage&, SfxMedium& );
|
||||
|
||||
extern "C" sal_Bool SaveVBA( SfxObjectShell&, SvMemoryStream*& );
|
||||
@@ -221,138 +211,128 @@ bool SdPPTFilter::Export()
|
||||
|
||||
if( mxModel.is() )
|
||||
{
|
||||
#ifdef DISABLE_DYNLOADING
|
||||
ExportPPTPointer PPTExport = ExportPPT;
|
||||
#else
|
||||
ExportPPTPointer PPTExport = reinterpret_cast< ExportPPTPointer >(
|
||||
SdFilter::GetLibrarySymbol(mrMedium.GetFilter()->GetUserData(), "ExportPPT"));
|
||||
#endif
|
||||
sal_uInt32 nCnvrtFlags = 0;
|
||||
const SvtFilterOptions& rFilterOptions = SvtFilterOptions::Get();
|
||||
if ( rFilterOptions.IsMath2MathType() )
|
||||
nCnvrtFlags |= OLE_STARMATH_2_MATHTYPE;
|
||||
if ( rFilterOptions.IsWriter2WinWord() )
|
||||
nCnvrtFlags |= OLE_STARWRITER_2_WINWORD;
|
||||
if ( rFilterOptions.IsCalc2Excel() )
|
||||
nCnvrtFlags |= OLE_STARCALC_2_EXCEL;
|
||||
if ( rFilterOptions.IsImpress2PowerPoint() )
|
||||
nCnvrtFlags |= OLE_STARIMPRESS_2_POWERPOINT;
|
||||
if ( rFilterOptions.IsEnablePPTPreview() )
|
||||
nCnvrtFlags |= 0x8000;
|
||||
|
||||
if( PPTExport)
|
||||
CreateStatusIndicator();
|
||||
|
||||
//OUString sBaseURI( "BaseURI");
|
||||
std::vector< PropertyValue > aProperties;
|
||||
PropertyValue aProperty;
|
||||
aProperty.Name = "BaseURI";
|
||||
aProperty.Value <<= mrMedium.GetBaseURL( true );
|
||||
aProperties.push_back( aProperty );
|
||||
|
||||
SvStream * pOutputStrm = mrMedium.GetOutStream();
|
||||
|
||||
Sequence< NamedValue > aEncryptionData;
|
||||
Reference< css::packages::XPackageEncryption > xPackageEncryption;
|
||||
const SfxUnoAnyItem* pEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(mrMedium.GetItemSet(), SID_ENCRYPTIONDATA, false);
|
||||
std::shared_ptr<SvStream> pMediaStrm;
|
||||
if (pEncryptionDataItem && (pEncryptionDataItem->GetValue() >>= aEncryptionData))
|
||||
{
|
||||
sal_uInt32 nCnvrtFlags = 0;
|
||||
const SvtFilterOptions& rFilterOptions = SvtFilterOptions::Get();
|
||||
if ( rFilterOptions.IsMath2MathType() )
|
||||
nCnvrtFlags |= OLE_STARMATH_2_MATHTYPE;
|
||||
if ( rFilterOptions.IsWriter2WinWord() )
|
||||
nCnvrtFlags |= OLE_STARWRITER_2_WINWORD;
|
||||
if ( rFilterOptions.IsCalc2Excel() )
|
||||
nCnvrtFlags |= OLE_STARCALC_2_EXCEL;
|
||||
if ( rFilterOptions.IsImpress2PowerPoint() )
|
||||
nCnvrtFlags |= OLE_STARIMPRESS_2_POWERPOINT;
|
||||
if ( rFilterOptions.IsEnablePPTPreview() )
|
||||
nCnvrtFlags |= 0x8000;
|
||||
::comphelper::SequenceAsHashMap aHashData(aEncryptionData);
|
||||
OUString sCryptoType = aHashData.getUnpackedValueOrDefault("CryptoType", OUString());
|
||||
|
||||
CreateStatusIndicator();
|
||||
|
||||
//OUString sBaseURI( "BaseURI");
|
||||
std::vector< PropertyValue > aProperties;
|
||||
PropertyValue aProperty;
|
||||
aProperty.Name = "BaseURI";
|
||||
aProperty.Value <<= mrMedium.GetBaseURL( true );
|
||||
aProperties.push_back( aProperty );
|
||||
|
||||
SvStream * pOutputStrm = mrMedium.GetOutStream();
|
||||
|
||||
Sequence< NamedValue > aEncryptionData;
|
||||
Reference< css::packages::XPackageEncryption > xPackageEncryption;
|
||||
const SfxUnoAnyItem* pEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(mrMedium.GetItemSet(), SID_ENCRYPTIONDATA, false);
|
||||
std::shared_ptr<SvStream> pMediaStrm;
|
||||
if (pEncryptionDataItem && (pEncryptionDataItem->GetValue() >>= aEncryptionData))
|
||||
if (sCryptoType.getLength())
|
||||
{
|
||||
::comphelper::SequenceAsHashMap aHashData(aEncryptionData);
|
||||
OUString sCryptoType = aHashData.getUnpackedValueOrDefault("CryptoType", OUString());
|
||||
|
||||
if (sCryptoType.getLength())
|
||||
{
|
||||
Reference<XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
|
||||
Sequence<Any> aArguments{
|
||||
Any(NamedValue("Binary", Any(true))) };
|
||||
xPackageEncryption.set(
|
||||
xComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext(
|
||||
"com.sun.star.comp.oox.crypto." + sCryptoType, aArguments, xComponentContext), UNO_QUERY);
|
||||
|
||||
if (xPackageEncryption.is())
|
||||
{
|
||||
// We have an encryptor. Export document into memory stream and encrypt it later
|
||||
pMediaStrm = std::make_shared<SvMemoryStream>();
|
||||
pOutputStrm = pMediaStrm.get();
|
||||
|
||||
// Temp removal of EncryptionData to avoid password protection triggering
|
||||
mrMedium.GetItemSet()->ClearItem(SID_ENCRYPTIONDATA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tools::SvRef<SotStorage> xStorRef = new SotStorage(pOutputStrm, false);
|
||||
|
||||
if (xStorRef.is())
|
||||
{
|
||||
bRet = PPTExport(aProperties, xStorRef, mxModel, mxStatusIndicator, pBas, nCnvrtFlags);
|
||||
xStorRef->Commit();
|
||||
Reference<XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
|
||||
Sequence<Any> aArguments{
|
||||
Any(NamedValue("Binary", Any(true))) };
|
||||
xPackageEncryption.set(
|
||||
xComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext(
|
||||
"com.sun.star.comp.oox.crypto." + sCryptoType, aArguments, xComponentContext), UNO_QUERY);
|
||||
|
||||
if (xPackageEncryption.is())
|
||||
{
|
||||
// Perform DRM encryption
|
||||
pOutputStrm->Seek(0);
|
||||
// We have an encryptor. Export document into memory stream and encrypt it later
|
||||
pMediaStrm = std::make_shared<SvMemoryStream>();
|
||||
pOutputStrm = pMediaStrm.get();
|
||||
|
||||
xPackageEncryption->setupEncryption(aEncryptionData);
|
||||
|
||||
Reference<css::io::XInputStream > xInputStream(new utl::OSeekableInputStreamWrapper(pOutputStrm, false));
|
||||
Sequence<NamedValue> aStreams = xPackageEncryption->encrypt(xInputStream);
|
||||
|
||||
tools::SvRef<SotStorage> xEncryptedRootStrg = new SotStorage(mrMedium.GetOutStream(), false);
|
||||
for (const NamedValue & aStreamData : std::as_const(aStreams))
|
||||
{
|
||||
// To avoid long paths split and open substorages recursively
|
||||
// Splitting paths manually, since comphelper::string::split is trimming special characters like \0x01, \0x09
|
||||
tools::SvRef<SotStorage> pStorage = xEncryptedRootStrg.get();
|
||||
OUString sFileName;
|
||||
sal_Int32 idx = 0;
|
||||
do
|
||||
{
|
||||
OUString sPathElem = aStreamData.Name.getToken(0, L'/', idx);
|
||||
if (!sPathElem.isEmpty())
|
||||
{
|
||||
if (idx < 0)
|
||||
{
|
||||
sFileName = sPathElem;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStorage = pStorage->OpenSotStorage(sPathElem);
|
||||
}
|
||||
}
|
||||
} while (pStorage && idx >= 0);
|
||||
|
||||
if (!pStorage)
|
||||
{
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
|
||||
tools::SvRef<SotStorageStream> pStream = pStorage->OpenSotStream(sFileName);
|
||||
if (!pStream)
|
||||
{
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
Sequence<sal_Int8> aStreamContent;
|
||||
aStreamData.Value >>= aStreamContent;
|
||||
size_t nBytesWritten = pStream->WriteBytes(aStreamContent.getConstArray(), aStreamContent.getLength());
|
||||
if (nBytesWritten != static_cast<size_t>(aStreamContent.getLength()))
|
||||
{
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
xEncryptedRootStrg->Commit();
|
||||
|
||||
// Restore encryption data
|
||||
mrMedium.GetItemSet()->Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, Any(aEncryptionData)));
|
||||
// Temp removal of EncryptionData to avoid password protection triggering
|
||||
mrMedium.GetItemSet()->ClearItem(SID_ENCRYPTIONDATA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tools::SvRef<SotStorage> xStorRef = new SotStorage(pOutputStrm, false);
|
||||
|
||||
if (xStorRef.is())
|
||||
{
|
||||
bRet = ExportPPT(aProperties, xStorRef, mxModel, mxStatusIndicator, pBas, nCnvrtFlags);
|
||||
xStorRef->Commit();
|
||||
|
||||
if (xPackageEncryption.is())
|
||||
{
|
||||
// Perform DRM encryption
|
||||
pOutputStrm->Seek(0);
|
||||
|
||||
xPackageEncryption->setupEncryption(aEncryptionData);
|
||||
|
||||
Reference<css::io::XInputStream > xInputStream(new utl::OSeekableInputStreamWrapper(pOutputStrm, false));
|
||||
Sequence<NamedValue> aStreams = xPackageEncryption->encrypt(xInputStream);
|
||||
|
||||
tools::SvRef<SotStorage> xEncryptedRootStrg = new SotStorage(mrMedium.GetOutStream(), false);
|
||||
for (const NamedValue & aStreamData : std::as_const(aStreams))
|
||||
{
|
||||
// To avoid long paths split and open substorages recursively
|
||||
// Splitting paths manually, since comphelper::string::split is trimming special characters like \0x01, \0x09
|
||||
tools::SvRef<SotStorage> pStorage = xEncryptedRootStrg.get();
|
||||
OUString sFileName;
|
||||
sal_Int32 idx = 0;
|
||||
do
|
||||
{
|
||||
OUString sPathElem = aStreamData.Name.getToken(0, L'/', idx);
|
||||
if (!sPathElem.isEmpty())
|
||||
{
|
||||
if (idx < 0)
|
||||
{
|
||||
sFileName = sPathElem;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStorage = pStorage->OpenSotStorage(sPathElem);
|
||||
}
|
||||
}
|
||||
} while (pStorage && idx >= 0);
|
||||
|
||||
if (!pStorage)
|
||||
{
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
|
||||
tools::SvRef<SotStorageStream> pStream = pStorage->OpenSotStream(sFileName);
|
||||
if (!pStream)
|
||||
{
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
Sequence<sal_Int8> aStreamContent;
|
||||
aStreamData.Value >>= aStreamContent;
|
||||
size_t nBytesWritten = pStream->WriteBytes(aStreamContent.getConstArray(), aStreamContent.getLength());
|
||||
if (nBytesWritten != static_cast<size_t>(aStreamContent.getLength()))
|
||||
{
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
xEncryptedRootStrg->Commit();
|
||||
|
||||
// Restore encryption data
|
||||
mrMedium.GetItemSet()->Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, Any(aEncryptionData)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bRet;
|
||||
|
||||
Reference in New Issue
Block a user