summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-12-04 17:01:09 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-12-04 22:07:34 +0100
commitfc26ea9e0e8cd4873ddd1f5736d7fed071f5e3e2 (patch)
treee893eee420862e37b165772248bbc4ad065520e6 /sw
parent58784b89c22c6d63fff18fea0aa6636a1370044c (diff)
add html to fftester
Change-Id: I85c2ce10ff6142d04310f834b16b2ded474e7a34 Reviewed-on: https://gerrit.libreoffice.org/45814 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/shellio.hxx2
-rw-r--r--sw/source/filter/html/swhtml.cxx40
-rw-r--r--sw/source/filter/ww8/ww8par.cxx15
3 files changed, 51 insertions, 6 deletions
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)
{