You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by kl...@apache.org on 2004/06/09 19:51:51 UTC
cvs commit: jakarta-poi/src/java/org/apache/poi/hpsf MutableSection.java
klute 2004/06/09 10:51:51
Modified: src/java/org/apache/poi/hpsf MutableSection.java
Log:
- Write properties sorted by property ID now. This hopefully fixes M$ Word compatibility.
Revision Changes Path
1.9 +21 -3 jakarta-poi/src/java/org/apache/poi/hpsf/MutableSection.java
Index: MutableSection.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/MutableSection.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MutableSection.java 9 Apr 2004 13:05:16 -0000 1.8
+++ MutableSection.java 9 Jun 2004 17:51:51 -0000 1.9
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -20,9 +19,12 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
@@ -370,9 +372,25 @@
("The codepage property (ID = 1) must be set.");
}
+ /* Sort the property list by their property IDs: */
+ Collections.sort(preprops, new Comparator()
+ {
+ public int compare(final Object o1, final Object o2)
+ {
+ final Property p1 = (Property) o1;
+ final Property p2 = (Property) o2;
+ if (p1.getID() < p2.getID())
+ return -1;
+ else if (p1.getID() == p2.getID())
+ return 0;
+ else
+ return 1;
+ }
+ });
+
/* Write the properties and the property list into their respective
* streams: */
- for (final Iterator i = preprops.iterator(); i.hasNext();)
+ for (final ListIterator i = preprops.listIterator(); i.hasNext();)
{
final MutableProperty p = (MutableProperty) i.next();
final long id = p.getID();
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org