editeng/qa/unit/core-test.cxx |   36 ++++++++++++++++++++++++++++++++++++
 include/editeng/editeng.hxx   |   10 +++++-----
 2 files changed, 41 insertions(+), 5 deletions(-)

New commits:
commit 685767dbe7dc6677eaee8edf3c9f94105705fafa
Author: Varun Dhall <varun.vd1...@gmail.com>
Date:   Wed Feb 22 21:57:44 2017 +0530

    Added Test for EditEngine - Copy/Paste using Legacy Format
    
    Change-Id: I3153010f4e327abd2ef48bdefa50ade1c0ba2f81
    Reviewed-on: https://gerrit.libreoffice.org/34552
    Reviewed-by: Michael Stahl <mst...@redhat.com>
    Tested-by: Michael Stahl <mst...@redhat.com>

diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 8048fea..23defaa 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -52,6 +52,9 @@ public:
     /// AutoCorrect tests
     void testAutocorrect();
 
+    /// Test Copy/Paste using Legacy Format
+    void testCopyPaste();
+
     /// Test hyperlinks
     void testHyperlinkSearch();
 
@@ -61,6 +64,7 @@ public:
     CPPUNIT_TEST(testConstruction);
     CPPUNIT_TEST(testUnoTextFields);
     CPPUNIT_TEST(testAutocorrect);
+    CPPUNIT_TEST(testCopyPaste);
     CPPUNIT_TEST(testHyperlinkSearch);
     CPPUNIT_TEST(testSectionAttributes);
     CPPUNIT_TEST_SUITE_END();
@@ -363,6 +367,38 @@ void Test::testAutocorrect()
     }
 }
 
+void Test::testCopyPaste()
+{
+    // Create EditEngine's instance
+    EditEngine aEditEngine( mpItemPool );
+
+    // Get EditDoc for current EditEngine's instance
+    EditDoc &rDoc = aEditEngine.GetEditDoc();
+
+    // Initially no text should be there
+    CPPUNIT_ASSERT_EQUAL( sal_uLong(0), rDoc.GetTextLen() );
+    CPPUNIT_ASSERT_EQUAL( OUString(""), rDoc.GetParaAsString(sal_Int32(0)) );
+
+    // Set initial text
+    OUString aText = "This is custom initial text";
+    sal_Int32 aTextLen = aText.getLength();
+    aEditEngine.SetText( aText );
+
+    // Assert changes
+    CPPUNIT_ASSERT_EQUAL( sal_uLong(aTextLen), rDoc.GetTextLen() );
+    CPPUNIT_ASSERT_EQUAL( aText, rDoc.GetParaAsString(sal_Int32(0)) );
+
+    // Copy initial text using legacy format
+    uno::Reference< datatransfer::XTransferable > xData = 
aEditEngine.CreateTransferable( ESelection(0,0,0,aTextLen) );
+
+    // Paste text at the end
+    aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true );
+
+    // Assert changes
+    CPPUNIT_ASSERT_EQUAL( sal_uLong(aTextLen + aTextLen), rDoc.GetTextLen() );
+    CPPUNIT_ASSERT_EQUAL( OUString(aText + aText), 
rDoc.GetParaAsString(sal_Int32(0)) );
+}
+
 namespace {
     class UrlEditEngine : public EditEngine
     {
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx
index d3e3f7e..921b60f 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -157,6 +157,10 @@ class EDITENG_DLLPUBLIC EditEngine
 public:
     typedef std::vector<EditView*> ViewsType;
 
+    EditSelection InsertText(
+        css::uno::Reference<css::datatransfer::XTransferable > const & 
rxDataObj,
+        const OUString& rBaseURL, const EditPaM& rPaM, bool bUseSpecial);
+
 private:
     std::unique_ptr<ImpEditEngine>  pImpEditEngine;
 
@@ -175,10 +179,6 @@ private:
         css::datatransfer::XTransferable>
             CreateTransferable(const EditSelection& rSelection);
 
-    EDITENG_DLLPRIVATE EditSelection InsertText(
-        css::uno::Reference<css::datatransfer::XTransferable > const & 
rxDataObj,
-        const OUString& rBaseURL, const EditPaM& rPaM, bool bUseSpecial);
-
     EDITENG_DLLPRIVATE EditPaM EndOfWord(const EditPaM& rPaM);
 
     EDITENG_DLLPRIVATE EditPaM GetPaM(const Point& aDocPos, bool bSmart = 
true);
@@ -370,7 +370,7 @@ public:
     void            Draw( OutputDevice* pOutDev, const Rectangle& rOutRect, 
const Point& rStartDocPos, bool bClip );
     void            Draw( OutputDevice* pOutDev, const Point& rStartPos, short 
nOrientation = 0 );
 
-//  sal_uInt32: Error code of the stream.
+    //  sal_uInt32: Error code of the stream.
     sal_uLong       Read( SvStream& rInput, const OUString& rBaseURL, 
EETextFormat, SvKeyValueIterator* pHTTPHeaderAttrs = nullptr );
     void            Write( SvStream& rOutput, EETextFormat );
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to