adjust cgm import to make testing easier
Change-Id: I2979af77522e085075d4f1e1e379fe82e614163b
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
<prop oor:name="Flags"><value>IMPORT ALIEN</value></prop>
|
||||
<prop oor:name="UIComponent"/>
|
||||
<prop oor:name="FilterService"/>
|
||||
<prop oor:name="UserData"><value>icg</value></prop>
|
||||
<prop oor:name="UserData"><value></value></prop>
|
||||
<prop oor:name="UIName">
|
||||
<value xml:lang="en-US">CGM - Computer Graphics Metafile</value>
|
||||
</prop>
|
||||
|
@@ -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:
|
||||
|
@@ -26,14 +26,15 @@
|
||||
#include <svx/xflclit.hxx>
|
||||
#include <svx/xfillit0.hxx>
|
||||
|
||||
#include "sddll.hxx"
|
||||
#include "sdpage.hxx"
|
||||
#include "drawdoc.hxx"
|
||||
#include "sdcgmfilter.hxx"
|
||||
|
||||
#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()
|
||||
{
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class CGMPointer
|
||||
{
|
||||
ImportCGMPointer m_pPointer;
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
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()
|
||||
{
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
|
||||
#endif
|
||||
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: */
|
||||
|
@@ -430,6 +430,21 @@ try_again:
|
||||
SvFileStream aFileStream(out, StreamMode::READ);
|
||||
ret = (int) (*pfnImport)(aFileStream);
|
||||
}
|
||||
else if (strcmp(argv[2], "cgm") == 0)
|
||||
{
|
||||
static FFilterCall pfnImport(nullptr);
|
||||
if (!pfnImport)
|
||||
{
|
||||
osl::Module aLibrary;
|
||||
aLibrary.loadRelative(&thisModule, "libsdlo.so", SAL_LOADMODULE_LAZY);
|
||||
pfnImport = reinterpret_cast<FFilterCall>(
|
||||
aLibrary.getFunctionSymbol("TestImportCGM"));
|
||||
aLibrary.release();
|
||||
}
|
||||
SvFileStream aFileStream(out, StreamMode::READ);
|
||||
ret = (int) (*pfnImport)(aFileStream);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user