sw/inc/shellio.hxx | 2 + sw/source/filter/html/swhtml.cxx | 40 +++++++++++++++++++++++++++++++++++++++ sw/source/filter/ww8/ww8par.cxx | 15 ++++++++------ vcl/workben/fftester.cxx | 14 +++++++++++++ 4 files changed, 65 insertions(+), 6 deletions(-)
New commits: commit fc26ea9e0e8cd4873ddd1f5736d7fed071f5e3e2 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Dec 4 17:01:09 2017 +0000 add html to fftester Change-Id: I85c2ce10ff6142d04310f834b16b2ded474e7a34 Reviewed-on: https://gerrit.libreoffice.org/45814 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 3509685638f7..abe6d48d209f 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -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; diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 7a6d70b612d1..d5eb72ed2450 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -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: */ diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index e448087db0f3..4e7b346a90fd 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -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) { diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx index db9b8d0f7ca6..3dd2fdb014f6 100644 --- a/vcl/workben/fftester.cxx +++ b/vcl/workben/fftester.cxx @@ -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);
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits