more flexible creation of a cluster
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@652290 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c5ce487ede
commit
bd4e1ac388
@ -38,6 +38,7 @@ public class EscherDggRecord
|
||||
private int field_3_numShapesSaved;
|
||||
private int field_4_drawingsSaved;
|
||||
private FileIdCluster[] field_5_fileIdClusters;
|
||||
private int maxDgId;
|
||||
|
||||
public static class FileIdCluster
|
||||
{
|
||||
@ -87,6 +88,7 @@ public class EscherDggRecord
|
||||
for (int i = 0; i < field_5_fileIdClusters.length; i++)
|
||||
{
|
||||
field_5_fileIdClusters[i] = new FileIdCluster(LittleEndian.getInt( data, pos + size ), LittleEndian.getInt( data, pos + size + 4 ));
|
||||
maxDgId = Math.max(maxDgId, field_5_fileIdClusters[i].getDrawingGroupId());
|
||||
size += 8;
|
||||
}
|
||||
bytesRemaining -= size;
|
||||
@ -229,6 +231,13 @@ public class EscherDggRecord
|
||||
this.field_4_drawingsSaved = field_4_drawingsSaved;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The maximum drawing group ID
|
||||
*/
|
||||
public int getMaxDrawingGroupId(){
|
||||
return maxDgId;
|
||||
}
|
||||
|
||||
public FileIdCluster[] getFileIdClusters()
|
||||
{
|
||||
return field_5_fileIdClusters;
|
||||
@ -240,10 +249,23 @@ public class EscherDggRecord
|
||||
}
|
||||
|
||||
public void addCluster( int dgId, int numShapedUsed )
|
||||
{
|
||||
addCluster(dgId, numShapedUsed, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new cluster
|
||||
*
|
||||
* @param dgId id of the drawing group (stored in the record options)
|
||||
* @param numShapedUsed initial value of the numShapedUsed field
|
||||
* @param sort if true then sort clusters by drawing group id.(
|
||||
* In Excel the clusters are sorted but in PPT they are not)
|
||||
*/
|
||||
public void addCluster( int dgId, int numShapedUsed, boolean sort )
|
||||
{
|
||||
List clusters = new ArrayList(Arrays.asList(field_5_fileIdClusters));
|
||||
clusters.add(new FileIdCluster(dgId, numShapedUsed));
|
||||
Collections.sort(clusters, new Comparator()
|
||||
if(sort) Collections.sort(clusters, new Comparator()
|
||||
{
|
||||
public int compare( Object o1, Object o2 )
|
||||
{
|
||||
@ -257,6 +279,7 @@ public class EscherDggRecord
|
||||
return +1;
|
||||
}
|
||||
} );
|
||||
maxDgId = Math.min(maxDgId, dgId);
|
||||
field_5_fileIdClusters = (FileIdCluster[]) clusters.toArray( new FileIdCluster[clusters.size()] );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user