From: Nick Burch Date: Thu, 27 May 2010 16:27:09 +0000 (+0000) Subject: Fix bug #44916 - Allow access to the HSSFPatriarch from HSSFSheet once created X-Git-Tag: REL_3_7_BETA1~43 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=da4d5963f3d6402148a3524412dc3f06e4c58799;p=poi.git Fix bug #44916 - Allow access to the HSSFPatriarch from HSSFSheet once created git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@948880 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 4570c02b9c..93047f340e 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 44916 - Allow access to the HSSFPatriarch from HSSFSheet once created 48779 - Allow you to get straight from a CellStyle to a Color, irrespective of if the Color is indexed or inline-defined 48924 - Allow access of the HWPF DateAndTime underlying date values 48926 - Initial support for the HWPF revision marks authors list diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 8ceb1df433..cd667d3b47 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -95,6 +95,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { private final TreeMap _rows; protected final InternalWorkbook _book; protected final HSSFWorkbook _workbook; + private HSSFPatriarch _patriarch; private int _firstrow; private int _lastrow; @@ -1577,11 +1578,11 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { _sheet.aggregateDrawingRecords(_book.getDrawingManager(), true); EscherAggregate agg = (EscherAggregate) _sheet.findFirstRecordBySid(EscherAggregate.sid); - HSSFPatriarch patriarch = new HSSFPatriarch(this, agg); + _patriarch = new HSSFPatriarch(this, agg); agg.clear(); // Initially the behaviour will be to clear out any existing shapes in the sheet when // creating a new patriarch. - agg.setPatriarch(patriarch); - return patriarch; + agg.setPatriarch(_patriarch); + return _patriarch; } /** @@ -1627,11 +1628,13 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * start from scratch! */ public HSSFPatriarch getDrawingPatriarch() { + if(_patriarch != null) return _patriarch; + EscherAggregate agg = getDrawingEscherAggregate(); if(agg == null) return null; - HSSFPatriarch patriarch = new HSSFPatriarch(this, agg); - agg.setPatriarch(patriarch); + _patriarch = new HSSFPatriarch(this, agg); + agg.setPatriarch(_patriarch); // Have it process the records into high level objects // as best it can do (this step may eat anything @@ -1639,7 +1642,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { agg.convertRecordsToUserModel(); // Return what we could cope with - return patriarch; + return _patriarch; } /** diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java index a644f12889..c51ca93892 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java @@ -38,8 +38,7 @@ public final class TestHSSFPatriarch extends TestCase { // assert something more interesting } - // TODO - fix bug 44916 (1-May-2008) - public void DISABLED_test44916() { + public void test44916() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet();