poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1144679 - in /poi/trunk/src/scratchpad: src/org/apache/poi/hwpf/model/ testcases/org/apache/poi/hwpf/converter/
Date Sat, 09 Jul 2011 14:38:43 GMT
Author: sergey
Date: Sat Jul  9 14:38:42 2011
New Revision: 1144679

URL: http://svn.apache.org/viewvc?rev=1144679&view=rev
Log:
sort PAPX and SEPX after loading

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java?rev=1144679&r1=1144678&r2=1144679&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java Sat Jul  9 14:38:42
2011
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.List;
 
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
@@ -38,19 +37,6 @@ import org.apache.poi.util.LittleEndian;
 public class CHPBinTable
 {
 
-    private static final class CHPXStartComparator implements Comparator<CHPX>
-    {
-        static CHPXStartComparator instance = new CHPXStartComparator();
-
-        public int compare( CHPX o1, CHPX o2 )
-        {
-            int thisVal = o1.getStart();
-            int anotherVal = o2.getStart();
-            return ( thisVal < anotherVal ? -1 : ( thisVal == anotherVal ? 0
-                    : 1 ) );
-        }
-    }
-
 /** List of character properties.*/
   protected ArrayList<CHPX> _textRuns = new ArrayList<CHPX>();
 
@@ -104,7 +90,7 @@ public class CHPBinTable
             _textRuns.add(chpx);
       }
     }
-        Collections.sort( _textRuns, CHPXStartComparator.instance );
+        Collections.sort( _textRuns, PropertyNode.StartComparator.instance );
     }
 
   public void adjustForDelete(int listIndex, int offset, int length)

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java?rev=1144679&r1=1144678&r2=1144679&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java Sat Jul  9 14:38:42
2011
@@ -20,6 +20,7 @@ package org.apache.poi.hwpf.model;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.Collections;
 
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
 import org.apache.poi.hwpf.model.io.HWPFOutputStream;
@@ -88,6 +89,7 @@ public class PAPBinTable
     	    _paragraphs.add(papx);
       }
     }
+    Collections.sort( _paragraphs, PropertyNode.StartComparator.instance );
     _dataStream = dataStream;
   }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java?rev=1144679&r1=1144678&r2=1144679&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java Sat Jul  9 14:38:42
2011
@@ -18,6 +18,7 @@
 package org.apache.poi.hwpf.model;
 
 import java.util.Arrays;
+import java.util.Comparator;
 
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
@@ -33,6 +34,20 @@ import org.apache.poi.util.POILogger;
  */
 public abstract class PropertyNode<T extends PropertyNode<T>>  implements Comparable<T>,
Cloneable
 {
+
+    static final class StartComparator implements Comparator<PropertyNode<?>>
+    {
+        static StartComparator instance = new StartComparator();
+
+        public int compare( PropertyNode<?> o1, PropertyNode<?> o2 )
+        {
+            int thisVal = o1.getStart();
+            int anotherVal = o2.getStart();
+            return ( thisVal < anotherVal ? -1 : ( thisVal == anotherVal ? 0
+                    : 1 ) );
+        }
+    }
+
   private final static POILogger _logger = POILogFactory.getLogger(PropertyNode.class);
   protected Object _buf;
   /** The start, in characters */

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java?rev=1144679&r1=1144678&r2=1144679&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java Sat Jul  9 14:38:42
2011
@@ -19,6 +19,7 @@ package org.apache.poi.hwpf.model;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
@@ -105,6 +106,8 @@ public class SectionTable
         	s.setEnd( CPtoFC(node.getEnd()) );
         }
     }
+
+    Collections.sort( _sections, PropertyNode.StartComparator.instance );
   }
 
   public void adjustForInsert(int listIndex, int length)

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java?rev=1144679&r1=1144678&r2=1144679&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
Sat Jul  9 14:38:42 2011
@@ -124,6 +124,11 @@ public class TestWordToHtmlConverter ext
         assertTrue( result.contains( "<table>" ) );
     }
 
+    public void testO_kurs_doc() throws Exception
+    {
+        getHtmlText( "o_kurs.doc" );
+    }
+
     public void testPageref() throws Exception
     {
         String result = getHtmlText( "pageref.doc" );



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


Mime
View raw message