summaryrefslogtreecommitdiffstats
path: root/sd
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-04-01 18:01:58 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-04-01 19:51:18 +0100
commit252f59b70223c8fdbd16532125a1089ff8c12c8b (patch)
treec8f6be814ba01b80a380e49c38bcebea81d0f42b /sd
parentubsan: use WrapTextMode_MAKE_FIXED_SIZE instead of -1 as unset flag (diff)
downloadcore-252f59b70223c8fdbd16532125a1089ff8c12c8b.tar.gz
core-252f59b70223c8fdbd16532125a1089ff8c12c8b.zip
adjust cgm import to make testing easier
Change-Id: I2979af77522e085075d4f1e1e379fe82e614163b
Diffstat (limited to 'sd')
-rw-r--r--sd/inc/sdfilter.hxx7
-rw-r--r--sd/source/filter/cgm/sdcgmfilter.cxx59
2 files changed, 46 insertions, 20 deletions
diff --git a/sd/inc/sdfilter.hxx b/sd/inc/sdfilter.hxx
index c88a490c2856..df1421f51727 100644
--- a/sd/inc/sdfilter.hxx
+++ b/sd/inc/sdfilter.hxx
@@ -43,6 +43,10 @@ public:
bool IsDraw() const { return mbIsDraw; }
virtual bool Export() = 0;
+#ifndef DISABLE_DYNLOADING
+ static ::osl::Module* OpenLibrary( const OUString& rLibraryName );
+#endif
+
protected:
css::uno::Reference< css::frame::XModel > mxModel;
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator;
@@ -51,9 +55,6 @@ protected:
::sd::DrawDocShell& mrDocShell;
SdDrawDocument& mrDocument;
bool mbIsDraw : 1;
-#ifndef DISABLE_DYNLOADING
- static ::osl::Module* OpenLibrary( const OUString& rLibraryName );
-#endif
void CreateStatusIndicator();
private:
diff --git a/sd/source/filter/cgm/sdcgmfilter.cxx b/sd/source/filter/cgm/sdcgmfilter.cxx
index 1c22e164f676..6837343e6e79 100644
--- a/sd/source/filter/cgm/sdcgmfilter.cxx
+++ b/sd/source/filter/cgm/sdcgmfilter.cxx
@@ -26,14 +26,15 @@
#include <svx/xflclit.hxx>
#include <svx/xfillit0.hxx>
+#include "sddll.hxx"
#include "sdpage.hxx"
#include "drawdoc.hxx"
#include "sdcgmfilter.hxx"
-#define CGM_IMPORT_CGM 0x00000001
+#include "../../ui/inc/DrawDocShell.hxx"
+#define CGM_IMPORT_CGM 0x00000001
#define CGM_EXPORT_IMPRESS 0x00000100
-
#define CGM_BIG_ENDIAN 0x00020000
using namespace ::com::sun::star;
@@ -58,24 +59,36 @@ SdCGMFilter::~SdCGMFilter()
{
}
-bool SdCGMFilter::Import()
+namespace
{
+ class CGMPointer
+ {
+ ImportCGMPointer m_pPointer;
#ifndef DISABLE_DYNLOADING
- ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
+ std::unique_ptr<osl::Module> m_xLibrary;
#endif
+ public:
+ CGMPointer()
+ {
+#ifdef DISABLE_DYNLOADING
+ m_pPointer = ImportCGM;
+#else
+ m_xLibrary.reset(SdFilter::OpenLibrary("icg"));
+ m_pPointer = m_xLibrary ? reinterpret_cast<ImportCGMPointer>(m_xLibrary->getFunctionSymbol("ImportCGM")) : nullptr;
+#endif
+ }
+ ImportCGMPointer get() { return m_pPointer; }
+ };
+}
+
+bool SdCGMFilter::Import()
+{
bool bRet = false;
- if(
-#ifndef DISABLE_DYNLOADING
- pLibrary &&
-#endif
- mxModel.is() )
+ CGMPointer aPointer;
+ ImportCGMPointer FncImportCGM = aPointer.get();
+ if (FncImportCGM && mxModel.is())
{
-#ifndef DISABLE_DYNLOADING
- ImportCGMPointer FncImportCGM = reinterpret_cast< ImportCGMPointer >( pLibrary->getFunctionSymbol( "ImportCGM" ) );
-#else
- ImportCGMPointer FncImportCGM = ImportCGM;
-#endif
OUString aFileURL( mrMedium.GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
sal_uInt32 nRetValue;
@@ -105,9 +118,6 @@ bool SdCGMFilter::Import()
}
}
}
-#ifndef DISABLE_DYNLOADING
- delete pLibrary;
-#endif
return bRet;
}
@@ -117,4 +127,19 @@ bool SdCGMFilter::Export()
return false;
}
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportCGM(SvStream &rStream)
+{
+ SdDLL::Init();
+
+ ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, false);
+
+ CGMPointer aPointer;
+
+ bool bRet = aPointer.get()(rStream, xDocShRef->GetModel(), CGM_IMPORT_CGM | CGM_BIG_ENDIAN | CGM_EXPORT_IMPRESS, css::uno::Reference<css::task::XStatusIndicator>()) == 0;
+
+ xDocShRef->DoClose();
+
+ return bRet;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */