[Libreoffice-commits] core.git: sw/inc sw/source vcl/workben

Caolán McNamara caolanm at redhat.com
Thu Jul 28 11:51:52 UTC 2016


 sw/inc/shellio.hxx                |    2 ++
 sw/source/filter/rtf/swparrtf.cxx |   29 +++++++++++++++++++++++++++++
 vcl/workben/fftester.cxx          |   13 +++++++++++++
 3 files changed, 44 insertions(+)

New commits:
commit 1b36d5f37450b07015710ed2ccad209653647eb0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 28 11:34:27 2016 +0100

    add rtf to fftester
    
    Change-Id: If00b1de1e1be16214df78d15554d95847e3239e7

diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index dd1ceae..56880e3 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 bd76719..5bd3826 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 dda8367..c239638 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) )
             {


More information about the Libreoffice-commits mailing list