]> source.dussan.org Git - poi.git/commitdiff
Fix bug #39177 - Last TextPropCollection needs a length 1 longer than the text that...
authorNick Burch <nick@apache.org>
Wed, 12 Apr 2006 17:59:45 +0000 (17:59 +0000)
committerNick Burch <nick@apache.org>
Wed, 12 Apr 2006 17:59:45 +0000 (17:59 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@393550 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java

index 1360d8816f4e32ed7403fe99ca9677442e917863..d8b40b0855228b47429366dfbbdf1d774f64e41e 100644 (file)
@@ -216,6 +216,14 @@ public class TextRun
                // Paragraph might cover other runs to, so remove old size and add new one
                pCol.updateTextSize( pCol.getCharactersCovered() - run.getLength() + s.length());
                
+               // If we were dealing with the last RichTextRun in the set, then
+               //  we need to tell the Character TextPropCollections a size 1 bigger 
+               //  than it really is
+               // (The Paragraph one will keep the extra 1 length from before)
+               if(runID == _rtRuns.length-1) {
+                       cCol.updateTextSize( cCol.getCharactersCovered() + 1 );
+               }
+               
                // Build up the new text
                // As we go through, update the start position for all subsequent runs
                // The building relies on the old text still being present
@@ -271,10 +279,12 @@ public class TextRun
                        LinkedList cStyles = _styleAtom.getCharacterStyles();
                        while(cStyles.size() > 1) { cStyles.removeLast(); }
                        
+                       // Note - TextPropCollection's idea of the text length must
+                       //         be one larger than it actually is!
                        TextPropCollection pCol = (TextPropCollection)pStyles.getFirst();
                        TextPropCollection cCol = (TextPropCollection)cStyles.getFirst();
-                       pCol.updateTextSize(s.length());
-                       cCol.updateTextSize(s.length());
+                       pCol.updateTextSize(s.length()+1);
+                       cCol.updateTextSize(s.length()+1);
                        
                        // Recreate rich text run with first styling
                        _rtRuns[0] = new RichTextRun(this,0,s.length(), pCol, cCol);