[Libreoffice-commits] core.git: 2 commits - sw/CppunitTest_sw_uiwriter.mk sw/inc sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Jan 16 02:20:03 PST 2014


 sw/CppunitTest_sw_uiwriter.mk      |    1 +
 sw/inc/docfac.hxx                  |    2 +-
 sw/inc/shellio.hxx                 |    4 ++--
 sw/qa/extras/uiwriter/uiwriter.cxx |   24 ++++++++++++++++++++++++
 sw/source/filter/basflt/fltini.cxx |    2 +-
 5 files changed, 29 insertions(+), 4 deletions(-)

New commits:
commit 82587e9bd4659200ea13ba416f881ff4285ec86e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 16 11:00:36 2014 +0100

    CppunitTest_sw_uiwriter: add testcase for ImportRTF()
    
    Change-Id: I334b21532337c1895a148c949dde60ad774b4759

diff --git a/sw/CppunitTest_sw_uiwriter.mk b/sw/CppunitTest_sw_uiwriter.mk
index 721cbf6..66042c5 100644
--- a/sw/CppunitTest_sw_uiwriter.mk
+++ b/sw/CppunitTest_sw_uiwriter.mk
@@ -77,6 +77,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_uiwriter,\
         vcl/vcl.unx \
     ) \
     $(if $(filter DESKTOP,$(BUILD_TYPE)),xmlhelp/util/ucpchelp1) \
+	writerfilter/util/writerfilter \
     xmloff/util/xo \
 ))
 
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 8b2c122..dd1e63b 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -9,6 +9,8 @@
 #include <swmodeltestbase.hxx>
 #include <ndtxt.hxx>
 #include <wrtsh.hxx>
+#include <crsskip.hxx>
+#include <shellio.hxx>
 
 #include "UndoManager.hxx"
 
@@ -24,12 +26,14 @@ public:
     void testReplaceBackward();
     void testFdo69893();
     void testFdo70807();
+    void testImportRTF();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
     CPPUNIT_TEST(testReplaceBackward);
     CPPUNIT_TEST(testFdo69893);
     CPPUNIT_TEST(testFdo70807);
+    CPPUNIT_TEST(testImportRTF);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -144,6 +148,26 @@ void SwUiWriterTest::testFdo70807()
     }
 }
 
+void SwUiWriterTest::testImportRTF()
+{
+    // Insert "foobar" and position the cursor between "foo" and "bar".
+    SwDoc* pDoc = createDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    pWrtShell->Insert("foobar");
+    pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 3, /*bBasicCall=*/false);
+
+    // Insert the RTF at the cursor position.
+    OString aData = "{\\rtf1 Hello world!\\par}";
+    SvMemoryStream aStream(const_cast<sal_Char*>(aData.getStr()), aData.getLength(), STREAM_READ);
+    SwReader aReader(aStream, OUString(), OUString(), *pWrtShell->GetCrsr());
+    Reader* pRTFReader = SwReaderWriter::GetReader(READER_WRITER_RTF);
+    CPPUNIT_ASSERT_EQUAL(sal_uLong(0), aReader.Read(*pRTFReader));
+
+    sal_uLong nIndex = pWrtShell->GetCrsr()->GetNode()->GetIndex();
+    CPPUNIT_ASSERT_EQUAL(OUString("fooHello world!"), static_cast<SwTxtNode*>(pDoc->GetNodes()[nIndex - 1])->GetTxt());
+    CPPUNIT_ASSERT_EQUAL(OUString("bar"), static_cast<SwTxtNode*>(pDoc->GetNodes()[nIndex])->GetTxt());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
commit 6a445e3231969b4a45f6e9db6f9d8f4044559d6f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 16 10:59:41 2014 +0100

    sw: make these public, they will be needed in unit tests
    
    And they have the Sw prefix already, so should be no issue.
    
    Change-Id: Ibbce389de83b462028dbcf338e5ce277f102d791

diff --git a/sw/inc/docfac.hxx b/sw/inc/docfac.hxx
index a453282..35827e0 100644
--- a/sw/inc/docfac.hxx
+++ b/sw/inc/docfac.hxx
@@ -23,7 +23,7 @@
 
 class SwDoc;
 
-class SwDocFac
+class SW_DLLPUBLIC SwDocFac
 {
 protected:
     SwDoc* pDoc;
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index 1c50d6d..bfdac41 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -146,7 +146,7 @@ public:
     {   ResetAllFmtsOnly(); aASCIIOpts.Reset(); }
 };
 
-class SwReader: public SwDocFac
+class SW_DLLPUBLIC SwReader: public SwDocFac
 {
     SvStream* pStrm;
     SotStorageRef pStg;
@@ -560,7 +560,7 @@ struct SwReaderWriterEntry
 namespace SwReaderWriter
 {
     /// Return reader based on ReaderWriterEnum.
-    Reader* GetReader( ReaderWriterEnum eReader );
+    SW_DLLPUBLIC Reader* GetReader( ReaderWriterEnum eReader );
 
     /// Return reader based on the name.
     Reader* GetReader( const OUString& rFltName );
diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx
index 7018fdb..1f784b7 100644
--- a/sw/source/filter/basflt/fltini.cxx
+++ b/sw/source/filter/basflt/fltini.cxx
@@ -166,7 +166,7 @@ oslGenericFunction Filters::GetMswordLibSymbol( const char *pSymbol )
 
 namespace SwReaderWriter {
 
-Reader* GetReader( ReaderWriterEnum eReader )
+SW_DLLPUBLIC Reader* GetReader( ReaderWriterEnum eReader )
 {
     return aReaderWriter[eReader].GetReader();
 }


More information about the Libreoffice-commits mailing list