From 8c85c8c3cf48a69cd6961f18f9b2eaf25c62f081 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 2 Jun 2010 16:01:26 +0000 Subject: [PATCH] Fix bug #49096 - add clone support to Chart begin and end records, to allow cloning of more Chart containing sheets git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@950611 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + .../poi/hssf/record/chart/BeginRecord.java | 6 ++++++ .../apache/poi/hssf/record/chart/EndRecord.java | 6 ++++++ .../org/apache/poi/hssf/usermodel/TestBugs.java | 16 ++++++++++++++++ test-data/spreadsheet/49096.xls | Bin 0 -> 14336 bytes 5 files changed, 29 insertions(+) create mode 100644 test-data/spreadsheet/49096.xls diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 11d5441eb7..65790b4f89 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 49096 - add clone support to Chart begin and end records, to allow cloning of more Chart containing sheets List attachment names in the output of OutlookTextExtractor (to get attachment contents, use ExtractorFactory as normal) 48872 - allow DateFormatter.formatRawCellContents to handle 1904 as well as 1900 dates 48872 - handle MMMMM and elapsed time formatting rules in DataFormatter diff --git a/src/java/org/apache/poi/hssf/record/chart/BeginRecord.java b/src/java/org/apache/poi/hssf/record/chart/BeginRecord.java index 85e80f024c..2a7baf1497 100644 --- a/src/java/org/apache/poi/hssf/record/chart/BeginRecord.java +++ b/src/java/org/apache/poi/hssf/record/chart/BeginRecord.java @@ -63,4 +63,10 @@ public final class BeginRecord extends StandardRecord { { return sid; } + + public Object clone() { + BeginRecord br = new BeginRecord(); + // No data so nothing to copy + return br; + } } diff --git a/src/java/org/apache/poi/hssf/record/chart/EndRecord.java b/src/java/org/apache/poi/hssf/record/chart/EndRecord.java index 44a5099e29..4879761192 100644 --- a/src/java/org/apache/poi/hssf/record/chart/EndRecord.java +++ b/src/java/org/apache/poi/hssf/record/chart/EndRecord.java @@ -64,4 +64,10 @@ public final class EndRecord extends StandardRecord { { return sid; } + + public Object clone() { + EndRecord er = new EndRecord(); + // No data so nothing to copy + return er; + } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 337499415b..c6b47848f7 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -1572,4 +1572,20 @@ public final class TestBugs extends BaseTestBugzillaIssues { assertEquals("RT", withoutExt.getString()); assertTrue((withoutExt.getOptionFlags() & 0x0004) == 0x0000); } + + /** + * Problem with cloning a sheet with a chart + * contained in it. + */ + public void test49096() throws Exception { + HSSFWorkbook wb = openSample("49096.xls"); + assertEquals(1, wb.getNumberOfSheets()); + + assertNotNull(wb.getSheetAt(0)); + wb.cloneSheet(0); + assertEquals(2, wb.getNumberOfSheets()); + + wb = writeOutAndReadBack(wb); + assertEquals(2, wb.getNumberOfSheets()); + } } diff --git a/test-data/spreadsheet/49096.xls b/test-data/spreadsheet/49096.xls new file mode 100644 index 0000000000000000000000000000000000000000..4c1e817b2386af94d3dfdb66178ad470c8a5277a GIT binary patch literal 14336 zcmeHOYiv}<75?tsYkQ3WUz>*uh0SFR!5D%}NCB0=E-ggO4?;?)8YNDRZ8pNS6H~L1 zs9Ke!G*VQxDQToWBqWkP5*|@PR4GVJt1SJMs!B^LMOE`Bq~cGNR#~c4O(bCZeRFsA z#jbIyrfQ=*)|r`m=FB-~zBza9%-!n?zw5gA^oxt%MqS#97_JrD(OSiKSYK?feXzY) z)TJ#Ku})T${*Mr7k8>hhTaXK0Yx{Mc)fn(LT%7gJGY9@e8pHv#0NWoKAI=8}VC@(jE!tT{MN?p!P~o^_jip2=S@a=$S77Ib63a|oyVo?Wtuy}^F>x@jZ#ZIdTW zK9{+JbEeOmhO>^*{VL^)hmR@Lfw2~68>TRZVNBq|Z7qB#b`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