Bug 30630 - [PATCH] Allow HSSFWorkbook to be used with subclasses Workbook objects
Summary: [PATCH] Allow HSSFWorkbook to be used with subclasses Workbook objects
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-12 18:47 UTC by Brian Sanders
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Sanders 2004-08-12 18:47:59 UTC
A constructor for HSSFWorkbook that takes a Workbook object as an argument would
allow the wrapping of subclasses of Workbook.


Index: src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
===================================================================
RCS file:
/home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java,v
retrieving revision 1.34
diff -u -r1.34 HSSFWorkbook.java
--- src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java	20 Jun 2004
10:18:50 -0000	1.34
+++ src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java	12 Aug 2004
18:26:17 -0000
@@ -122,7 +122,12 @@
 
     public HSSFWorkbook()
     {
-        workbook = Workbook.createWorkbook();
+        this(Workbook.createWorkbook());
+    }
+
+    protected HSSFWorkbook(Workbook book)
+    {
+        workbook = book;
         sheets = new ArrayList(INITIAL_CAPACITY);
         names  = new ArrayList(INITIAL_CAPACITY);
     }
Comment 1 Brian Sanders 2004-08-12 19:32:15 UTC
Additionally, subclassing would be simpler if the "sheets" collection in
HSSFWorkbook was given protected visibility.
Comment 2 Glen Stampoultzis 2004-08-24 12:56:01 UTC
You haven't explained why you need to subclass but I can't see that harm in it
so I've committed the changes.