Kaydet (Commit) fc26ea9e authored tarafından Caolán McNamara's avatar Caolán McNamara

add html to fftester

Change-Id: I85c2ce10ff6142d04310f834b16b2ded474e7a34
Reviewed-on: https://gerrit.libreoffice.org/45814Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 58784b89
......@@ -179,6 +179,7 @@ protected:
extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportDOC(SvStream &rStream, const OUString &rFltName);
extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportRTF(SvStream &rStream);
extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportHTML(SvStream &rStream);
SAL_DLLPUBLIC_EXPORT void FlushFontCache();
class SW_DLLPUBLIC Reader
......@@ -186,6 +187,7 @@ class SW_DLLPUBLIC Reader
friend class SwReader;
friend bool TestImportDOC(SvStream &rStream, const OUString &rFltName);
friend bool TestImportRTF(SvStream &rStream);
friend bool TestImportHTML(SvStream &rStream);
rtl::Reference<SwDoc> mxTemplate;
OUString aTemplateNm;
......
......@@ -107,6 +107,7 @@
#include <linkenum.hxx>
#include <breakit.hxx>
#include <SwAppletImpl.hxx>
#include <swdll.hxx>
#include <sfx2/viewfrm.hxx>
......@@ -5499,4 +5500,43 @@ void SwHTMLParser::AddMetaUserDefined( OUString const & i_rMetaName )
}
}
namespace
{
class FontCacheGuard
{
public:
~FontCacheGuard()
{
FlushFontCache();
}
};
}
bool SAL_CALL TestImportHTML(SvStream &rStream)
{
FontCacheGuard aFontCacheGuard;
std::unique_ptr<Reader> xReader(new HTMLReader);
xReader->pStrm = &rStream;
SwGlobals::ensure();
SfxObjectShellLock xDocSh(new SwDocShell(SfxObjectCreateMode::INTERNAL));
xDocSh->DoInitNew();
SwDoc *pD = static_cast<SwDocShell*>((&xDocSh))->GetDoc();
SwNodeIndex aIdx(
*pD->GetNodes().GetEndOfContent().StartOfSectionNode(), 1);
if( !aIdx.GetNode().IsTextNode() )
{
pD->GetNodes().GoNext( &aIdx );
}
SwPaM aPaM( aIdx );
aPaM.GetPoint()->nContent.Assign(aIdx.GetNode().GetContentNode(), 0);
pD->SetInReading(true);
bool bRet = xReader->Read(*pD, OUString(), aPaM, OUString()) == ERRCODE_NONE;
pD->SetInReading(false);
return bRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -6213,14 +6213,17 @@ extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportDOC()
return new WW8Reader;
}
class FontCacheGuard
namespace
{
public:
~FontCacheGuard()
class FontCacheGuard
{
FlushFontCache();
}
};
public:
~FontCacheGuard()
{
FlushFontCache();
}
};
}
bool SAL_CALL TestImportDOC(SvStream &rStream, const OUString &rFltName)
{
......
......@@ -375,6 +375,20 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
SvFileStream aFileStream(out, StreamMode::READ);
ret = (int) (*pfnImport)(aFileStream);
}
else if (strcmp(argv[2], "html") == 0)
{
static FFilterCall pfnImport(nullptr);
if (!pfnImport)
{
osl::Module aLibrary;
aLibrary.loadRelative(&thisModule, "libswlo.so", SAL_LOADMODULE_LAZY);
pfnImport = reinterpret_cast<FFilterCall>(
aLibrary.getFunctionSymbol("TestImportHTML"));
aLibrary.release();
}
SvFileStream aFileStream(out, StreamMode::READ);
ret = (int) (*pfnImport)(aFileStream);
}
else if (strcmp(argv[2], "fodt") == 0)
{
static FFilterCall pfnImport(nullptr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment