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

Matúš Kukan matus.kukan at collabora.com
Wed Dec 10 07:22:59 PST 2014


 sw/qa/extras/uiwriter/data/uno-cycle.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx       |   17 +++++++++++++++++
 sw/source/core/unocore/unoportenum.cxx   |    5 +++++
 3 files changed, 22 insertions(+)

New commits:
commit 4a3328a98f00818044694a9b6a0f7cda392273c6
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Wed Dec 10 12:06:49 2014 +0100

    sw: Unit test for cycle in lcl_CreatePortions
    
    Reviewed on:
    	https://gerrit.libreoffice.org/13413
    Conflicts:
    	sw/qa/extras/uiwriter/uiwriter.cxx
    
    Change-Id: I26a8707046d7f30381fb51c41e49f8dee4796ba7

diff --git a/sw/qa/extras/uiwriter/data/uno-cycle.odt b/sw/qa/extras/uiwriter/data/uno-cycle.odt
new file mode 100644
index 0000000..51e798f
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/uno-cycle.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 4229877..d3649d0 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -63,6 +63,7 @@ public:
     void testAutoCorr();
     void testFdo87005();
     void testMergeDoc();
+    void testCreatePortions();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -89,6 +90,7 @@ public:
     CPPUNIT_TEST(testAutoCorr);
     CPPUNIT_TEST(testFdo87005);
     CPPUNIT_TEST(testMergeDoc);
+    CPPUNIT_TEST(testCreatePortions);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -662,6 +664,21 @@ void SwUiWriterTest::testMergeDoc()
     getParagraph(7, "");
 }
 
+void SwUiWriterTest::testCreatePortions()
+{
+    createDoc("uno-cycle.odt");
+    uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextContent> xText(xBookmarksSupplier->getBookmarks()->getByName("Mark"), uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> xTextCursor(xText->getAnchor(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xTextCursor.is());
+
+    uno::Reference<container::XEnumerationAccess> xParagraph(
+            xTextCursor->createEnumeration()->nextElement(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xParagraph.is());
+    // This looped forever in lcl_CreatePortions
+    xParagraph->createEnumeration();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
commit 6d65e30fbaba383cbb9e1db6230a04865897ac8f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Dec 10 16:08:05 2014 +0100

    sw UNO API: fix infinite loop when building portions of a bookmark range
    
    The problem was that in case the bookmark range points to a number of
    characters in a text node, where neither the start or the end is the paragraph
    start and end, and in case there is an at-char anchored object at the beginning
    of the paragraph, then lcl_CreatePortions() never ended.
    
    It is assumed that the loop in lcl_CreatePortions() will end at some stage, as
    every iteration moves the cursor forward. But this wasn't true in the above
    situation: the first frame was anchored at char pos 0, the range was char
    positions 1..7, and we failed to ignore frames which are anchored before start:
    so position was constantly 1.
    
    Fix the problem by explicitly ignoring frames before the current position, so
    lcl_ExportFrames() properly returns -1 when there are no anchored objects in
    the current range. Testcase is in the next commit.
    
    Change-Id: I73662e09cd09ee7e0ea4575b1150beb40f1ccc3a

diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 039e60f..422bce9 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -1193,6 +1193,11 @@ static sal_Int32 lcl_ExportFrames(
     FrameDependSortList_t & i_rFrames,
     sal_Int32 const i_nCurrentIndex)
 {
+    // Ignore frames which are not exported, as we are exporting a selection
+    // and they are anchored before the start of the selection.
+    while (i_rFrames.size() && i_rFrames.front().nIndex < i_nCurrentIndex)
+        i_rFrames.pop_front();
+
     // find first Frame in (sorted) i_rFrames at current position
     while (i_rFrames.size() && (i_rFrames.front().nIndex == i_nCurrentIndex))
     // do not check for i_nEnd here; this is done implicity by lcl_MoveCursor


More information about the Libreoffice-commits mailing list