summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2016-11-19 19:20:58 +0300
committerAndras Timar <andras.timar@collabora.com>2017-02-17 12:32:14 +0100
commitbec45bc9f88545ec397c1f11f39f946087ee06fc (patch)
treead5d4ee462714ddf3b89f0a30185db5b0357291e /sw
parent1c08313e1ef7fe3d753634fccdfcda31cc88691e (diff)
tdf#104032: use correct text length
Reviewed-on: https://gerrit.libreoffice.org/30980 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 7c43cba9804e70b23b71783d362401c75f9caa54) Change-Id: I16e6af179be3d7bee947c4054ae4fa6924b298f0
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/data/tdf104032.odtbin0 -> 8967 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx19
-rw-r--r--sw/source/core/docnode/nodes.cxx2
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
new file mode 100644
index 000000000000..535e8cec7cf1
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf104032.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 0ba241259e31..aec74fa044c5 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -217,6 +217,7 @@ public:
void testCursorWindows();
void testLandscape();
void testTdf95699();
+ void testTdf104032();
void testTdf104425();
void testTdf104814();
void testTdf105417();
@@ -331,6 +332,7 @@ public:
CPPUNIT_TEST(testCursorWindows);
CPPUNIT_TEST(testLandscape);
CPPUNIT_TEST(testTdf95699);
+ CPPUNIT_TEST(testTdf104032);
CPPUNIT_TEST(testTdf104425);
CPPUNIT_TEST(testTdf104814);
CPPUNIT_TEST(testTdf105417);
@@ -4075,6 +4077,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();
+}
+
void SwUiWriterTest::testTdf104425()
{
createDoc("tdf104425.odt");
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() )