]> source.dussan.org Git - poi.git/commitdiff
extract private getCharacterRun method with CHPX as parameter (used with reflection...
authorSergey Vladimirov <sergey@apache.org>
Mon, 4 Jul 2011 19:05:40 +0000 (19:05 +0000)
committerSergey Vladimirov <sergey@apache.org>
Mon, 4 Jul 2011 19:05:40 +0000 (19:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1142763 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java

index 5c87d3c6cf073dda44d85dbba2262d079300a4b9..a4596b5c8901f16616538de483ec8c03cc4c468d 100644 (file)
@@ -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;
        }