diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-10-27 11:47:29 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-10-27 11:48:07 +0100 |
commit | 91114f68e0a81d4f2a5354bc6057f62c22c780b4 (patch) | |
tree | 53a1905af63afdee457bb6ae5338858239c81fbc | |
parent | cac08e96c753f3aabf3332914da97a49abe1e395 (diff) |
I'm testing inserting a rtf, but really want to test simple loading
Change-Id: I13c6e8394de9b7214f3e4d448a7b18cbf3b637e9
-rw-r--r-- | sw/source/filter/rtf/swparrtf.cxx | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 93ebb2810127..4bc289dfd8f8 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -160,30 +160,36 @@ extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportRTF() 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(); - bool bRet = false; + uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory()); + uno::Reference<uno::XInterface> xInterface(xMultiServiceFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW); + + uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW); + uno::Reference<lang::XComponent> xDstDoc(xDocSh->GetModel(), uno::UNO_QUERY_THROW); + xImporter->setTargetDocument(xDstDoc); + + uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW); + uno::Sequence<beans::PropertyValue> aDescriptor(1); + aDescriptor[0].Name = "InputStream"; + uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(aFileStream)); + aDescriptor[0].Value <<= xStream; + bool bRet(1); try { - SwPaM aPaM(pD->GetNodes().GetEndOfContent()); - bRet = pReader->Read(*pD, OUString(), aPaM, OUString()) == 0; + xFilter->filter(aDescriptor); } - catch (std::exception const&) + catch (...) { + bRet = false; } - delete pReader; return bRet; + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |