From f575bfa0139c11d95e250e8ae2327e858d79f16b Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Wed, 28 Jul 2010 15:51:57 +0000 Subject: [PATCH] Added clone support for UserSView* and Feat* families of records, see bug #49649 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@980102 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + src/java/org/apache/poi/hssf/record/FeatHdrRecord.java | 7 +++++++ src/java/org/apache/poi/hssf/record/FeatRecord.java | 8 ++++++++ .../org/apache/poi/hssf/record/HeaderFooterRecord.java | 6 ++++++ src/java/org/apache/poi/hssf/record/UserSViewBegin.java | 7 ++++++- src/java/org/apache/poi/hssf/record/UserSViewEnd.java | 6 ++++++ .../org/apache/poi/hssf/record/TestFeatRecord.java | 9 +++++++++ 7 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 4e21fa3a06..6f2623971d 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 49649 - Added clone support for UserSView* and Feat* families of records 49653 - Support for escaped unicode characters in Shared String Table 49579 - prevent ArrayIndexOutOfBoundException in UnknowEscherRecord 49593 - preserve leading and trailing white spaces in XWPFRun diff --git a/src/java/org/apache/poi/hssf/record/FeatHdrRecord.java b/src/java/org/apache/poi/hssf/record/FeatHdrRecord.java index fe7a137eb6..5382bef34b 100644 --- a/src/java/org/apache/poi/hssf/record/FeatHdrRecord.java +++ b/src/java/org/apache/poi/hssf/record/FeatHdrRecord.java @@ -105,4 +105,11 @@ public final class FeatHdrRecord extends StandardRecord { protected int getDataSize() { return 12 + 2+1+4+rgbHdrData.length; } + + //HACK: do a "cheat" clone, see Record.java for more information + public Object clone() { + return cloneViaReserialise(); + } + + } diff --git a/src/java/org/apache/poi/hssf/record/FeatRecord.java b/src/java/org/apache/poi/hssf/record/FeatRecord.java index c9fed7d40d..267eced88e 100644 --- a/src/java/org/apache/poi/hssf/record/FeatRecord.java +++ b/src/java/org/apache/poi/hssf/record/FeatRecord.java @@ -167,4 +167,12 @@ public final class FeatRecord extends StandardRecord { cbFeatData = 0; } } + + + //HACK: do a "cheat" clone, see Record.java for more information + public Object clone() { + return cloneViaReserialise(); + } + + } diff --git a/src/java/org/apache/poi/hssf/record/HeaderFooterRecord.java b/src/java/org/apache/poi/hssf/record/HeaderFooterRecord.java index 23d266fa67..96457b99cd 100755 --- a/src/java/org/apache/poi/hssf/record/HeaderFooterRecord.java +++ b/src/java/org/apache/poi/hssf/record/HeaderFooterRecord.java @@ -94,5 +94,11 @@ public final class HeaderFooterRecord extends StandardRecord { sb.append("[/").append("HEADERFOOTER").append("]\n"); return sb.toString(); } + + //HACK: do a "cheat" clone, see Record.java for more information + public Object clone() { + return cloneViaReserialise(); + } + } \ No newline at end of file diff --git a/src/java/org/apache/poi/hssf/record/UserSViewBegin.java b/src/java/org/apache/poi/hssf/record/UserSViewBegin.java index ad59a5868e..7b632a02e5 100644 --- a/src/java/org/apache/poi/hssf/record/UserSViewBegin.java +++ b/src/java/org/apache/poi/hssf/record/UserSViewBegin.java @@ -83,5 +83,10 @@ public final class UserSViewBegin extends StandardRecord { sb.append("[/").append("USERSVIEWBEGIN").append("]\n"); return sb.toString(); } - + + //HACK: do a "cheat" clone, see Record.java for more information + public Object clone() { + return cloneViaReserialise(); + } + } \ No newline at end of file diff --git a/src/java/org/apache/poi/hssf/record/UserSViewEnd.java b/src/java/org/apache/poi/hssf/record/UserSViewEnd.java index 271dd77583..02f72acf18 100644 --- a/src/java/org/apache/poi/hssf/record/UserSViewEnd.java +++ b/src/java/org/apache/poi/hssf/record/UserSViewEnd.java @@ -72,4 +72,10 @@ public final class UserSViewEnd extends StandardRecord { return sb.toString(); } + //HACK: do a "cheat" clone, see Record.java for more information + public Object clone() { + return cloneViaReserialise(); + } + + } \ No newline at end of file diff --git a/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java b/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java index 288c7ea944..dc884000b0 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java @@ -170,4 +170,13 @@ public final class TestFeatRecord extends TestCase { assertFalse(fferr2.getCheckUnprotectedFormulas()); assertFalse(fferr2.getPerformDataValidation()); } + + /** + * cloning sheets with feat records + */ + public void testCloneSheetWithFeatRecord() throws Exception { + HSSFWorkbook wb = + HSSFTestDataSamples.openSampleWorkbook("46136-WithWarnings.xls"); + wb.cloneSheet(0); + } } -- 2.39.5