[Libreoffice-commits] core.git: 2 commits - sw/inc sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Jan 16 06:18:10 PST 2014
sw/inc/shellio.hxx | 4 ++--
sw/qa/extras/uiwriter/uiwriter.cxx | 30 ++++++++++++++++++++++++++++++
sw/source/filter/basflt/fltini.cxx | 2 +-
3 files changed, 33 insertions(+), 3 deletions(-)
New commits:
commit 8477394f9bbe001d8648c38cd6e3c1c72dd17d8e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Jan 16 15:07:01 2014 +0100
CppunitTest_sw_uiwriter: add testcase for ExportRTF()
Change-Id: I49a86e6a5cd525118d902b37825cfdb7dc8e70d2
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index dd1e63b..dc9004b 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -27,6 +27,7 @@ public:
void testFdo69893();
void testFdo70807();
void testImportRTF();
+ void testExportRTF();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -34,6 +35,7 @@ public:
CPPUNIT_TEST(testFdo69893);
CPPUNIT_TEST(testFdo70807);
CPPUNIT_TEST(testImportRTF);
+ CPPUNIT_TEST(testExportRTF);
CPPUNIT_TEST_SUITE_END();
private:
@@ -168,6 +170,34 @@ void SwUiWriterTest::testImportRTF()
CPPUNIT_ASSERT_EQUAL(OUString("bar"), static_cast<SwTxtNode*>(pDoc->GetNodes()[nIndex])->GetTxt());
}
+void SwUiWriterTest::testExportRTF()
+{
+ // Insert "aaabbbccc" and select "bbb".
+ SwDoc* pDoc = createDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Insert("aaabbbccc");
+ pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 3, /*bBasicCall=*/false);
+ pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 3, /*bBasicCall=*/false);
+
+ // Create the clipboard document.
+ boost::shared_ptr<SwDoc> pClpDoc(new SwDoc());
+ pClpDoc->SetClipBoard(true);
+ pWrtShell->Copy(pClpDoc.get());
+
+ // And finally export it as RTF.
+ WriterRef xWrt;
+ SwReaderWriter::GetWriter("RTF", OUString(), xWrt);
+ SvMemoryStream aStream;
+ SwWriter aWrt(aStream, *pClpDoc);
+ aWrt.Write(xWrt);
+
+ OString aData(static_cast<const sal_Char*>(aStream.GetBuffer()), aStream.GetSize());
+ CPPUNIT_ASSERT(aData.startsWith("{\\rtf1"));
+ CPPUNIT_ASSERT_EQUAL(-1, aData.indexOf("aaa"));
+ CPPUNIT_ASSERT(aData.indexOf("bbb") != -1);
+ CPPUNIT_ASSERT_EQUAL(-1, aData.indexOf("ccc"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
commit 9758961f6c6d2e40eec2d89c7bb1a5d065a6a1d8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Jan 16 15:06:12 2014 +0100
sw: make these public as well for unit tests
All are Sw-prefixed or are in Sw-prefixed namespace, so what can go
wrong.
Change-Id: Icbd8cead5e1db88d34519b09b21e64735ccb2734
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index bfdac41..6fe135b 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -506,7 +506,7 @@ public:
// Interface class for general access on special writers.
-class SwWriter
+class SW_DLLPUBLIC SwWriter
{
SvStream* pStrm;
SotStorageRef pStg;
@@ -566,7 +566,7 @@ namespace SwReaderWriter
Reader* GetReader( const OUString& rFltName );
/// Return writer based on the name.
- void GetWriter( const OUString& rFltName, const OUString& rBaseURL, WriterRef& xWrt );
+ SW_DLLPUBLIC void GetWriter( const OUString& rFltName, const OUString& rBaseURL, WriterRef& xWrt );
}
void GetRTFWriter( const OUString&, const OUString&, WriterRef& );
diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx
index 1f784b7..a415b3a 100644
--- a/sw/source/filter/basflt/fltini.cxx
+++ b/sw/source/filter/basflt/fltini.cxx
@@ -171,7 +171,7 @@ SW_DLLPUBLIC Reader* GetReader( ReaderWriterEnum eReader )
return aReaderWriter[eReader].GetReader();
}
-void GetWriter( const OUString& rFltName, const OUString& rBaseURL, WriterRef& xRet )
+SW_DLLPUBLIC void GetWriter( const OUString& rFltName, const OUString& rBaseURL, WriterRef& xRet )
{
for( sal_uInt16 n = 0; n < MAXFILTER; ++n )
if ( aFilterDetect[n].IsFilter( rFltName ) )
More information about the Libreoffice-commits
mailing list