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 2007/01/11 17:18:30 UTC
svn commit: r495278 - in /jakarta/poi/trunk/src/scratchpad:
src/org/apache/poi/hslf/model/TextRun.java
src/org/apache/poi/hslf/record/StyleTextPropAtom.java
testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java
Author: nick
Date: Thu Jan 11 08:18:30 2007
New Revision: 495278
URL: http://svn.apache.org/viewvc?view=rev&rev=495278
Log:
Handle the fact that StyleTextPropAtom needs to work with a text length that's one larger than the underlying text it represents. (Fix from Yegor from bug #40143)
Modified:
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java?view=diff&rev=495278&r1=495277&r2=495278
==============================================================================
--- 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 Thu Jan 11 08:18:30 2007
@@ -417,7 +417,7 @@
}
// Create a new one at the right size
- _styleAtom = new StyleTextPropAtom(getRawText().length());
+ _styleAtom = new StyleTextPropAtom(getRawText().length() + 1);
// Use the TextHeader atom to get at the parent
RecordContainer runAtomsParent = _headerAtom.getParentRecord();
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java?view=diff&rev=495278&r1=495277&r2=495278
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java Thu Jan 11 08:18:30 2007
@@ -228,7 +228,8 @@
// While we have text in need of paragraph stylings, go ahead and
// grok the contents as paragraph formatting data
- while(pos < rawContents.length && textHandled < size) {
+ int prsize = size;
+ while(pos < rawContents.length && textHandled < prsize) {
// First up, fetch the number of characters this applies to
int textLen = LittleEndian.getInt(rawContents,pos);
textHandled += textLen;
@@ -250,11 +251,21 @@
// Save this properties set
paragraphStyles.add(thisCollection);
+
+ // Handle extra 1 paragraph styles at the end
+ if(pos < rawContents.length && textHandled == size) {
+ prsize++;
+ }
+
}
+ if (rawContents.length > 0 && textHandled != (size+1)){
+ System.err.println("Problem reading paragraph style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
+ }
// Now do the character stylings
textHandled = 0;
- while(pos < rawContents.length && textHandled < size) {
+ int chsize = size;
+ while(pos < rawContents.length && textHandled < chsize) {
// First up, fetch the number of characters this applies to
int textLen = LittleEndian.getInt(rawContents,pos);
textHandled += textLen;
@@ -279,9 +290,12 @@
// Handle extra 1 char styles at the end
if(pos < rawContents.length && textHandled == size) {
- size++;
+ chsize++;
}
}
+ if (rawContents.length > 0 && textHandled != (size+1)){
+ System.err.println("Problem reading character style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
+ }
// Handle anything left over
if(pos < rawContents.length) {
Modified: jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java?view=diff&rev=495278&r1=495277&r2=495278
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java (original)
+++ jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java Thu Jan 11 08:18:30 2007
@@ -49,7 +49,7 @@
00, 00, 0x04, 00, // font.color only
0xFF-256, 0x33, 00, 0xFE-256 // red
};
- private int data_a_text_len = 54;
+ private int data_a_text_len = 0x36-1;
/**
* From a real file: 4 paragraphs with text in 4 different styles:
@@ -125,7 +125,7 @@
28, 0, 1, 0, 0, 0, 0, 0,
3, 0, 1, 0, 24, 0
};
- private int data_c_text_len = 123;
+ private int data_c_text_len = 123-1;
public void testRecordType() throws Exception {
---------------------------------------------------------------------
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/