summaryrefslogtreecommitdiff
path: root/sd/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-09-14 12:52:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-14 20:31:04 +0200
commit412ec9ec100fb377791b9bced8bc61ce75870e10 (patch)
tree616eb3f5ba2bc9adf8930aeda8abce53abeb6175 /sd/source
parent970b87bb7b7d77ef12dbcad6ed7caa8edd92e413 (diff)
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>
Diffstat (limited to 'sd/source')
-rw-r--r--sd/source/filter/eppt/eppt.cxx3
-rw-r--r--sd/source/filter/sdpptwrp.cxx216
2 files changed, 100 insertions, 119 deletions
diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx
index d243496946a2..34f85553e8bf 100644
--- a/sd/source/filter/eppt/eppt.cxx
+++ b/sd/source/filter/eppt/eppt.cxx
@@ -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,
diff --git a/sd/source/filter/sdpptwrp.cxx b/sd/source/filter/sdpptwrp.cxx
index 59829f854ef8..6dd1964b2b73 100644
--- a/sd/source/filter/sdpptwrp.cxx
+++ b/sd/source/filter/sdpptwrp.cxx
@@ -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,136 +211,126 @@ 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
-
- if( PPTExport)
+ 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;
+
+ 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;
-
- 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))
+ ::comphelper::SequenceAsHashMap aHashData(aEncryptionData);
+ OUString sCryptoType = aHashData.getUnpackedValueOrDefault("CryptoType", OUString());
+
+ if (sCryptoType.getLength())
{
- ::comphelper::SequenceAsHashMap aHashData(aEncryptionData);
- OUString sCryptoType = aHashData.getUnpackedValueOrDefault("CryptoType", OUString());
+ 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 (sCryptoType.getLength())
+ if (xPackageEncryption.is())
{
- 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();
+ // 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);
- }
+ // Temp removal of EncryptionData to avoid password protection triggering
+ mrMedium.GetItemSet()->ClearItem(SID_ENCRYPTIONDATA);
}
}
+ }
- tools::SvRef<SotStorage> xStorRef = new SotStorage(pOutputStrm, false);
+ tools::SvRef<SotStorage> xStorRef = new SotStorage(pOutputStrm, false);
- if (xStorRef.is())
- {
- bRet = PPTExport(aProperties, xStorRef, mxModel, mxStatusIndicator, pBas, nCnvrtFlags);
- xStorRef->Commit();
+ if (xStorRef.is())
+ {
+ bRet = ExportPPT(aProperties, xStorRef, mxModel, mxStatusIndicator, pBas, nCnvrtFlags);
+ xStorRef->Commit();
- if (xPackageEncryption.is())
- {
- // Perform DRM encryption
- pOutputStrm->Seek(0);
+ if (xPackageEncryption.is())
+ {
+ // Perform DRM encryption
+ pOutputStrm->Seek(0);
- xPackageEncryption->setupEncryption(aEncryptionData);
+ xPackageEncryption->setupEncryption(aEncryptionData);
- Reference<css::io::XInputStream > xInputStream(new utl::OSeekableInputStreamWrapper(pOutputStrm, false));
- Sequence<NamedValue> aStreams = xPackageEncryption->encrypt(xInputStream);
+ 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))
+ 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
{
- // 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())
{
- OUString sPathElem = aStreamData.Name.getToken(0, L'/', idx);
- if (!sPathElem.isEmpty())
+ if (idx < 0)
{
- if (idx < 0)
- {
- sFileName = sPathElem;
- }
- else
- {
- pStorage = pStorage->OpenSotStorage(sPathElem);
- }
+ sFileName = sPathElem;
+ }
+ else
+ {
+ pStorage = pStorage->OpenSotStorage(sPathElem);
}
- } while (pStorage && idx >= 0);
-
- if (!pStorage)
- {
- bRet = false;
- break;
}
+ } while (pStorage && idx >= 0);
- 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;
- }
+ if (!pStorage)
+ {
+ bRet = false;
+ break;
}
- xEncryptedRootStrg->Commit();
- // Restore encryption data
- mrMedium.GetItemSet()->Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, Any(aEncryptionData)));
+ 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)));
}
}
}