From: Sergey Vladimirov Date: Mon, 4 Jul 2011 19:05:40 +0000 (+0000) Subject: extract private getCharacterRun method with CHPX as parameter (used with reflection... X-Git-Tag: REL_3_8_BETA4~341 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9a17cfcb7fb1f7635a16aa25e01f6567e4e32fe9;p=poi.git extract private getCharacterRun method with CHPX as parameter (used with reflection in workaround in AbstractWordUtils) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1142763 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java index 5c87d3c6cf..a4596b5c89 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java @@ -781,28 +781,36 @@ public class Range { // TODO -instantiable superclass * The index of the character run to get. * @return The character run at the specified index in this range. */ - public CharacterRun getCharacterRun(int index) { - initCharacterRuns(); - CHPX chpx = _characters.get(index + _charStart); - - if (chpx == null) { + public CharacterRun getCharacterRun( int index ) + { + initCharacterRuns(); + CHPX chpx = _characters.get( index + _charStart ); + return getCharacterRun( chpx ); + } + + private CharacterRun getCharacterRun( CHPX chpx ) + { + if ( chpx == null ) + { return null; } - int[] point = findRange(_paragraphs, _parStart, Math.max(chpx.getStart(), _start), chpx - .getEnd()); + int[] point = findRange( _paragraphs, _parStart, + Math.max( chpx.getStart(), _start ), chpx.getEnd() ); - if (point[0] >= _paragraphs.size()) { + if ( point[0] >= _paragraphs.size() ) + { return null; } - PAPX papx = _paragraphs.get(point[0]); - short istd = papx.getIstd(); + PAPX papx = _paragraphs.get( point[0] ); + short istd = papx.getIstd(); - CharacterRun chp = new CharacterRun(chpx, _doc.getStyleSheet(), istd, this); + CharacterRun chp = new CharacterRun( chpx, _doc.getStyleSheet(), istd, + this ); - return chp; - } + return chp; + } /** * Gets the section at index. The index is relative to this range. @@ -1077,10 +1085,16 @@ public class Range { // TODO -instantiable superclass } } + /** + * @return Starting character offset of the range + */ public int getStartOffset() { return _start; } + /** + * @return The ending character offset of this range + */ public int getEndOffset() { return _end; }