Bug 62779 - Paragraph text search results start with an error marker.
Summary: Paragraph text search results start with an error marker.
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 4.0.0-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2018-09-30 02:05 UTC by zhangfugui
Modified: 2018-12-22 17:10 UTC (History)
0 users

Fix the sample (45.91 KB, image/png)
2018-09-30 02:05 UTC, zhangfugui

Note You need to log in before you can comment on or make changes to this bug.
Description zhangfugui 2018-09-30 02:05:41 UTC
Created attachment 36177 [details]
Fix the sample

Fix paragraph text search results start point marking error.

Each loop of rArray in the searchText method causes beginTextPos and beginCharPos to be reset accordingly. The resulting TextSegment returns invalid data.

Such as:
Search ${code} in Runs data ["code:${", "code","}"].
The correct result returned should be

### start
startRun 0
startText 0
startChar 5
### end
endRun 2
endText 0
endChar 0
But the actual interior only retains the startRun state, and startText, startChar are reset at each loop.

startRun 0
startText 0
startChar 0
Comment 1 PJ Fanning 2018-09-30 08:14:02 UTC
Would you be able to provide a test case? Something that reads an input docx and that does a searchText call that fails with existing code but that passes with your change.

A few existing tests can be found in: