Issue 68261 - XEnumeration.nextElement() throws despite hasMoreElements()==true
Summary: XEnumeration.nextElement() throws despite hasMoreElements()==true
Alias: None
Product: Writer
Classification: Application
Component: programming (show other issues)
Version: OOo 2.0.3
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: chne
QA Contact: issues@sw
Depends on:
Reported: 2006-08-08 16:45 UTC by mux2005
Modified: 2013-08-07 14:43 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---

XEnumeration.nextElement() throws despite hasMoreElements()==true (18.65 KB, application/vnd.oasis.opendocument.text)
2006-08-08 16:47 UTC, mux2005
no flags Details
a simplified example document (9.54 KB, application/vnd.oasis.opendocument.text)
2006-08-30 11:01 UTC, clutz
no flags Details
new version oh short bugdoc to avoid name clash (9.67 KB, application/octet-stream)
2006-10-06 11:28 UTC, thomas.lange
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description mux2005 2006-08-08 16:45:01 UTC
The attached document demonstrates a case of XEnumeration.nextElement() throwing
NoSuchElementException even if a prior test of hasMoreElements() has returned
true. The contained macro has the usual loop

  xEnum = range2.createEnumeration()
  do while xEnum.hasMoreElements()

but despite the document being completely static the nextElement() call always
throws. I've tested this under Windows 2000 and Linux with both StarBasic and
Java (Actually this is a simplified testcase that I extracted from our
production Java code). Reproducibility is ALWAYS. So it's NOT a case of some
structures disappearing between the call to hasMoreElements() and nextElement().

Background info: The document has been imported from Word and then modified in
OOo. I've noticed that form fields imported from Word seem to be different from
those created in OOo. Maybe that has something to do with it.
Comment 1 mux2005 2006-08-08 16:47:23 UTC
Created attachment 38342 [details]
XEnumeration.nextElement() throws despite hasMoreElements()==true
Comment 2 michael.ruess 2006-08-09 07:03:58 UTC
Reassigned to JSK.
Comment 3 joerg.skottke 2006-08-10 13:04:50 UTC
X-anything is like API -> cn
Comment 4 clutz 2006-08-30 11:01:58 UTC
Created attachment 38846 [details]
a simplified example document
Comment 5 clutz 2006-08-30 11:19:44 UTC
Submitted an simplified example.

as the example shows, the wrong exception occures under the following conditions:

1) the bookmarks (which anchor should be enumerated) is in a TextTable.

2) the paragraph that contains the bookmark is followed by another paragraph. 

If the corresponding paragraph is the one and only paragraph in the cell of the
TextTable or if there are more paragraphs before the corresponding paragraph,
the wrong exception does not occure.
Comment 6 chne 2006-08-30 11:35:26 UTC
cn->tl: I can confirm this
Comment 7 thomas.lange 2006-10-06 11:28:37 UTC
Created attachment 39602 [details]
new version oh short bugdoc to avoid name clash
Comment 8 thomas.lange 2006-10-06 11:28:52 UTC
Comment 9 thomas.lange 2006-10-06 11:30:49 UTC
Fixed in CWS tl25.

Files changed:
- sw/source/core/unocore/unoobj2.cxx

And thanks for the shortened bug doc! ^^
Comment 10 thomas.lange 2006-10-06 11:31:00 UTC
Comment 11 thomas.lange 2006-11-27 12:10:22 UTC
Comment 12 clutz 2007-01-19 12:51:10 UTC
when will this be integrated into an official release?
Comment 13 chne 2007-01-22 14:36:04 UTC
ok in tl25
Comment 14 chne 2007-02-02 13:34:25 UTC
ok in src680_m202
Comment 15 mux2005 2007-03-16 11:28:15 UTC
I see that the fix is not in 2.2.0 even though it's small and obviously correct.
Could we then please at least get a target milestone of 2.2.1? This bug causes
exceptions to be thrown where programmer's are not prepared to handle them and
so this bug may crash custom components.