diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-12-10 16:08:05 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-12-10 16:22:13 +0100 |
commit | 6d65e30fbaba383cbb9e1db6230a04865897ac8f (patch) | |
tree | c452229a5c135c813de89767e4aad21e6c1845a7 /sw | |
parent | e3ce885504d19d81b03df621237b73768ce7736d (diff) |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/unocore/unoportenum.cxx | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 039e60f94436..422bce910256 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 |