You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by se...@apache.org on 2011/07/09 18:04:47 UTC

svn commit: r1144689 - in /poi/trunk/src/scratchpad/src/org/apache/poi/hwpf: model/CHPX.java usermodel/Section.java

Author: sergey
Date: Sat Jul  9 16:04:46 2011
New Revision: 1144689

URL: http://svn.apache.org/viewvc?rev=1144689&view=rev
Log:
Same workaround for CHPX / SEPX, as for PAPX. Disable SPRM processing for Word95 files.

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java?rev=1144689&r1=1144688&r2=1144689&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java Sat Jul  9 16:04:46 2011
@@ -55,18 +55,20 @@ public final class CHPX extends ByteProp
     return (SprmBuffer)_buf;
   }
 
-  public CharacterProperties getCharacterProperties(StyleSheet ss, short istd)
-  {
-    CharacterProperties baseStyle;
-    if (ss == null) {
-      //old document format
-      baseStyle = new CharacterProperties();
-    } else {
-      baseStyle = ss.getCharacterStyle(istd);
+    public CharacterProperties getCharacterProperties( StyleSheet ss, short istd )
+    {
+        if ( ss == null )
+        {
+            // TODO Fix up for Word 6/95
+            return new CharacterProperties();
+        }
+
+        CharacterProperties baseStyle = ss.getCharacterStyle( istd );
+        CharacterProperties props = CharacterSprmUncompressor.uncompressCHP(
+                baseStyle, getGrpprl(), 0 );
+        ;
+        return props;
     }
-    CharacterProperties props = CharacterSprmUncompressor.uncompressCHP(baseStyle, getGrpprl(), 0);
-    return props;
-  }
 
   public String toString() {
       return "CHPX from " + getStart() + " to " + getEnd() + 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java?rev=1144689&r1=1144688&r2=1144689&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java Sat Jul  9 16:04:46 2011
@@ -17,6 +17,7 @@
 
 package org.apache.poi.hwpf.usermodel;
 
+import org.apache.poi.hwpf.HWPFOldDocument;
 import org.apache.poi.hwpf.model.SEPX;
 
 public final class Section
@@ -25,11 +26,17 @@ public final class Section
 
   private SectionProperties _props;
 
-  public Section(SEPX sepx, Range parent)
-  {
-    super(Math.max(parent._start, sepx.getStart()), Math.min(parent._end, sepx.getEnd()), parent);
-    _props = sepx.getSectionProperties();
-  }
+    public Section( SEPX sepx, Range parent )
+    {
+        super( Math.max( parent._start, sepx.getStart() ), Math.min(
+                parent._end, sepx.getEnd() ), parent );
+
+        // XXX: temporary workaround for old Word95 document
+        if ( parent.getDocument() instanceof HWPFOldDocument )
+            _props = new SectionProperties();
+        else
+            _props = sepx.getSectionProperties();
+    }
 
   public int type()
   {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org