summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-07-28 11:34:27 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-07-28 12:48:22 +0100
commit1b36d5f37450b07015710ed2ccad209653647eb0 (patch)
tree53af777f7c1c0e17548d1014d724e647887c3745
parent1ebd5de9de4291e7b5cbaaa912f5b4524c14ad81 (diff)
add rtf to fftester
Change-Id: If00b1de1e1be16214df78d15554d95847e3239e7
-rw-r--r--sw/inc/shellio.hxx2
-rw-r--r--sw/source/filter/rtf/swparrtf.cxx29
-rw-r--r--vcl/workben/fftester.cxx13
3 files changed, 44 insertions, 0 deletions
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index dd1ceae91f47..56880e3de5f2 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -179,11 +179,13 @@ protected:
#define SW_STORAGE_READER 2
extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportDOC(const OUString &rUrl, const OUString &rFltName);
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportRTF(const OUString &rUrl);
class SW_DLLPUBLIC Reader
{
friend class SwReader;
friend bool TestImportDOC(const OUString &rUrl, const OUString &rFltName);
+ friend bool TestImportRTF(const OUString &rUrl);
SwDoc* pTemplate;
OUString aTemplateNm;
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx
index bd76719ed8f4..5bd382608f56 100644
--- a/sw/source/filter/rtf/swparrtf.cxx
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -23,6 +23,7 @@
#include <doc.hxx>
#include <docsh.hxx>
#include <IDocumentStylePoolAccess.hxx>
+#include <swdll.hxx>
#include <swerror.h>
#include <unotextrange.hxx>
@@ -157,4 +158,32 @@ extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportRTF()
return new SwRTFReader();
}
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportRTF(const OUString &rURL)
+{
+ Reader *pReader = ImportRTF();
+
+ SvFileStream aFileStream(rURL, StreamMode::READ);
+ tools::SvRef<SotStorage> xStorage;
+ pReader->pStrm = &aFileStream;
+ pReader->SetFltName("FILTER_RTF");
+
+ 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);
+ bool bRet = pReader->Read(*pD, OUString(), aPaM, OUString()) == 0;
+ delete pReader;
+ return bRet;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index dda8367d9786..c23963884763 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -369,6 +369,19 @@ try_again:
else
ret = (int) (*pfnImport)(out, OUString("CWW8"));
}
+ else if (strcmp(argv[2], "rtf") == 0)
+ {
+ static HFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ osl::Module aLibrary;
+ aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY);
+ pfnImport = reinterpret_cast<HFilterCall>(
+ aLibrary.getFunctionSymbol("TestImportRTF"));
+ aLibrary.release();
+ }
+ ret = (int) (*pfnImport)(out);
+ }
else if ( (strcmp(argv[2], "xls") == 0) ||
(strcmp(argv[2], "wb2") == 0) )
{