summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVarun Dhall <varun.vd1994@gmail.com>2017-02-22 21:57:44 +0530
committerMichael Stahl <mstahl@redhat.com>2017-02-24 16:41:12 +0000
commit685767dbe7dc6677eaee8edf3c9f94105705fafa (patch)
treeef15e0607271abf1133c8eb2bd3e3a4cd794d4b2
parentf21994e7a240563283b7a17dcb435ce7c5156b60 (diff)
Added Test for EditEngine - Copy/Paste using Legacy Format
Change-Id: I3153010f4e327abd2ef48bdefa50ade1c0ba2f81 Reviewed-on: https://gerrit.libreoffice.org/34552 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--editeng/qa/unit/core-test.cxx36
-rw-r--r--include/editeng/editeng.hxx10
2 files changed, 41 insertions, 5 deletions
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 8048feabf131..23defaa4e8c1 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 d3e3f7e4cb9e..921b60f2c954 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 );