diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-07-28 11:34:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-07-28 12:48:22 +0100 |
commit | 1b36d5f37450b07015710ed2ccad209653647eb0 (patch) | |
tree | 53af777f7c1c0e17548d1014d724e647887c3745 /sw | |
parent | 1ebd5de9de4291e7b5cbaaa912f5b4524c14ad81 (diff) |
add rtf to fftester
Change-Id: If00b1de1e1be16214df78d15554d95847e3239e7
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/shellio.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/rtf/swparrtf.cxx | 29 |
2 files changed, 31 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: */ |