From 4ef50e7e949b2e1c89ed67b2ea0de4937446535d Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 12 Apr 2006 17:59:45 +0000 Subject: [PATCH] Fix bug #39177 - Last TextPropCollection needs a length 1 longer than the text that makes it up git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@393550 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hslf/model/TextRun.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java b/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java index 1360d8816..d8b40b085 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java @@ -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);