You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ni...@apache.org on 2006/04/12 19:59:47 UTC

svn commit: r393550 - /jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java

Author: nick
Date: Wed Apr 12 10:59:45 2006
New Revision: 393550

URL: http://svn.apache.org/viewcvs?rev=393550&view=rev
Log:
Fix bug #39177 - Last TextPropCollection needs a length 1 longer than the text that makes it up

Modified:
    jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java

Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
URL: http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java?rev=393550&r1=393549&r2=393550&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java Wed Apr 12 10:59:45 2006
@@ -216,6 +216,14 @@
 		// 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 @@
 			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);



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/