diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2016-11-19 19:20:58 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2016-11-25 18:24:34 +0000 |
commit | 7c43cba9804e70b23b71783d362401c75f9caa54 (patch) | |
tree | bc77704c9216a1283ea98491deb56640a3ca04e5 /sw | |
parent | db05c78ef5571d4204ed555d6d7cff906d25a6dd (diff) |
tdf#104032: use correct text length
Change-Id: I16e6af179be3d7bee947c4054ae4fa6924b298f0
Reviewed-on: https://gerrit.libreoffice.org/30980
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/uiwriter/data/tdf104032.odt | bin | 0 -> 8967 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 19 | ||||
-rw-r--r-- | sw/source/core/docnode/nodes.cxx | 2 |
3 files changed, 20 insertions, 1 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf104032.odt b/sw/qa/extras/uiwriter/data/tdf104032.odt Binary files differnew file mode 100644 index 000000000000..535e8cec7cf1 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf104032.odt diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 46fd478f5fe8..c3ca4ee7717d 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -215,6 +215,7 @@ public: void testCursorWindows(); void testLandscape(); void testTdf95699(); + void testTdf104032(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -326,6 +327,7 @@ public: CPPUNIT_TEST(testCursorWindows); CPPUNIT_TEST(testLandscape); CPPUNIT_TEST(testTdf95699); + CPPUNIT_TEST(testTdf104032); CPPUNIT_TEST_SUITE_END(); private: @@ -4067,6 +4069,23 @@ void SwUiWriterTest::testTdf95699() CPPUNIT_ASSERT_EQUAL(OUString("vnd.oasis.opendocument.field.FORMCHECKBOX"), pFieldMark->GetFieldname()); } +void SwUiWriterTest::testTdf104032() +{ + // Open the document with FORMCHECKBOX field, select it and copy to clipboard + // Go to end of document and paste it, then undo + // Previously that asserted in debug build. + SwDoc* pDoc = createDoc("tdf104032.odt"); + sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); + SwDoc aClipboard; + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->SttDoc(); + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false); + pWrtShell->Copy(&aClipboard); + pWrtShell->EndDoc(); + pWrtShell->Paste(&aClipboard); + rUndoManager.Undo(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index e5846b55c16d..1e0b282cfe43 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -1479,7 +1479,7 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) // move the content into the new node bool bOneNd = pStt->nNode == pEnd->nNode; const sal_Int32 nLen = - ( (bOneNd) ? pEnd->nContent.GetIndex() : pSrcNd->Len() ) + ( (bOneNd) ? std::min(pEnd->nContent.GetIndex(), pSrcNd->Len()) : pSrcNd->Len() ) - pStt->nContent.GetIndex(); if( !pEnd->nNode.GetNode().IsContentNode() ) |