mirror of https://github.com/apache/poi.git
sort CHPX on load (sometimes out of order)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1144333 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
21ebb4606f
commit
ad91a5f33b
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.apache.poi.hwpf.model;
|
package org.apache.poi.hwpf.model;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
@ -34,7 +36,21 @@ import org.apache.poi.hwpf.sprm.SprmBuffer;
|
||||||
*/
|
*/
|
||||||
public class CHPBinTable
|
public class CHPBinTable
|
||||||
{
|
{
|
||||||
/** List of character properties.*/
|
|
||||||
|
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.getEnd();
|
||||||
|
return ( thisVal < anotherVal ? -1 : ( thisVal == anotherVal ? 0
|
||||||
|
: 1 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** List of character properties.*/
|
||||||
protected ArrayList<CHPX> _textRuns = new ArrayList<CHPX>();
|
protected ArrayList<CHPX> _textRuns = new ArrayList<CHPX>();
|
||||||
|
|
||||||
/** So we can know if things are unicode or not */
|
/** So we can know if things are unicode or not */
|
||||||
|
@ -74,9 +90,12 @@ public class CHPBinTable
|
||||||
|
|
||||||
for (int y = 0; y < fkpSize; y++)
|
for (int y = 0; y < fkpSize; y++)
|
||||||
{
|
{
|
||||||
_textRuns.add(cfkp.getCHPX(y));
|
final CHPX chpx = cfkp.getCHPX(y);
|
||||||
|
if (chpx != null)
|
||||||
|
_textRuns.add(chpx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Collections.sort( _textRuns, CHPXStartComparator.instance );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adjustForDelete(int listIndex, int offset, int length)
|
public void adjustForDelete(int listIndex, int offset, int length)
|
||||||
|
|
Loading…
Reference in New Issue