Bugzilla 53204: Improve performance when opening certain Excel files (PageSettingsBlock)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1364254 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d619711ea4
commit
626e2e7993
@ -34,6 +34,7 @@
|
||||
|
||||
<changes>
|
||||
<release version="3.9-beta1" date="2012-??-??">
|
||||
<action dev="poi-developers" type="add">53204 - Improved performanceof PageSettingsBlock in HSSF </action>
|
||||
<action dev="poi-developers" type="add">53500 - Getter for repeating rows and columns</action>
|
||||
<action dev="poi-developers" type="fix">53369 - Fixed tests failing on JDK 1.7</action>
|
||||
<action dev="poi-developers" type="fix">53360 - Fixed SXSSF to correctly write text before escaped Unicode control character</action>
|
||||
|
@ -18,13 +18,15 @@
|
||||
package org.apache.poi.hssf.record.aggregates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.hssf.model.RecordStream;
|
||||
import org.apache.poi.hssf.model.InternalSheet;
|
||||
import org.apache.poi.hssf.record.*;
|
||||
import org.apache.poi.util.HexDump;
|
||||
|
||||
/**
|
||||
* Groups the page settings records for a worksheet.<p/>
|
||||
@ -653,18 +655,24 @@ public final class PageSettingsBlock extends RecordAggregate {
|
||||
// without concurrency issues
|
||||
List<HeaderFooterRecord> hfRecordsToIterate = new ArrayList<HeaderFooterRecord>(_sviewHeaderFooters);
|
||||
|
||||
final Map<String, HeaderFooterRecord> hfGuidMap = new HashMap<String, HeaderFooterRecord>();
|
||||
|
||||
for(final HeaderFooterRecord hf : hfRecordsToIterate) {
|
||||
hfGuidMap.put(HexDump.toHex(hf.getGuid()), hf);
|
||||
}
|
||||
|
||||
// loop through HeaderFooterRecord records having not-empty GUID and match them with
|
||||
// CustomViewSettingsRecordAggregate blocks having UserSViewBegin with the same GUID
|
||||
for(final HeaderFooterRecord hf : hfRecordsToIterate) {
|
||||
for (RecordBase rb : sheetRecords) {
|
||||
if (rb instanceof CustomViewSettingsRecordAggregate) {
|
||||
final CustomViewSettingsRecordAggregate cv = (CustomViewSettingsRecordAggregate) rb;
|
||||
cv.visitContainedRecords(new RecordVisitor() {
|
||||
public void visitRecord(Record r) {
|
||||
if (r.getSid() == UserSViewBegin.sid) {
|
||||
byte[] guid1 = ((UserSViewBegin) r).getGuid();
|
||||
byte[] guid2 = hf.getGuid();
|
||||
if (Arrays.equals(guid1, guid2)) {
|
||||
String guid = HexDump.toHex(((UserSViewBegin) r).getGuid());
|
||||
HeaderFooterRecord hf = hfGuidMap.get(guid);
|
||||
|
||||
if (hf != null) {
|
||||
cv.append(hf);
|
||||
_sviewHeaderFooters.remove(hf);
|
||||
}
|
||||
@ -675,4 +683,3 @@ public final class PageSettingsBlock extends RecordAggregate {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user