bin/find-can-be-private-symbols.py |    1 
 sd/inc/sdfilter.hxx                |   23 ++-
 sd/source/filter/eppt/eppt.cxx     |    3 
 sd/source/filter/sdpptwrp.cxx      |  216 ++++++++++++++++---------------------
 4 files changed, 117 insertions(+), 126 deletions(-)

New commits:
commit 412ec9ec100fb377791b9bced8bc61ce75870e10
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Sep 14 12:52:35 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Sep 14 20:31:04 2022 +0200

    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.gran...@collabora.co.uk>

diff --git a/bin/find-can-be-private-symbols.py 
b/bin/find-can-be-private-symbols.py
index 2ac7619d9026..b45dd181caf7 100755
--- a/bin/find-can-be-private-symbols.py
+++ b/bin/find-can-be-private-symbols.py
@@ -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
diff --git a/sd/inc/sdfilter.hxx b/sd/inc/sdfilter.hxx
index 8d7782e4fc92..707679642dee 100644
--- a/sd/inc/sdfilter.hxx
+++ b/sd/inc/sdfilter.hxx
@@ -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: */
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)));
             }
         }
     }

Reply via email to