[Libreoffice-commits] core.git: sw/qa sw/source

Mike Kaganski mike.kaganski at collabora.com
Fri Nov 25 18:24:59 UTC 2016


 sw/qa/extras/uiwriter/data/tdf104032.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx       |   19 +++++++++++++++++++
 sw/source/core/docnode/nodes.cxx         |    2 +-
 3 files changed, 20 insertions(+), 1 deletion(-)

New commits:
commit 7c43cba9804e70b23b71783d362401c75f9caa54
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Sat Nov 19 19:20:58 2016 +0300

    tdf#104032: use correct text length
    
    Change-Id: I16e6af179be3d7bee947c4054ae4fa6924b298f0
    Reviewed-on: https://gerrit.libreoffice.org/30980
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/qa/extras/uiwriter/data/tdf104032.odt b/sw/qa/extras/uiwriter/data/tdf104032.odt
new file mode 100644
index 0000000..535e8ce
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf104032.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 46fd478..c3ca4ee 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 e5846b5..1e0b282 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() )


More information about the Libreoffice-commits mailing list