From 6605995ac6e43cca52c88ed43a2600ede25fd473 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 18 Jan 2010 12:18:00 +0000 Subject: [PATCH] records.UnicodeString isn't actually a Record, just a common part that exists in many other records. As such, move it to records.common, which is where all the other record components live git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@900362 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hssf/model/InternalWorkbook.java | 2 +- src/java/org/apache/poi/hssf/record/DVRecord.java | 1 + .../org/apache/poi/hssf/record/SSTDeserializer.java | 1 + src/java/org/apache/poi/hssf/record/SSTRecord.java | 1 + src/java/org/apache/poi/hssf/record/SSTSerializer.java | 1 + .../poi/hssf/record/{ => common}/UnicodeString.java | 3 ++- src/java/org/apache/poi/hssf/usermodel/HSSFCell.java | 2 +- .../org/apache/poi/hssf/usermodel/HSSFOptimiser.java | 2 +- .../apache/poi/hssf/usermodel/HSSFRichTextString.java | 2 +- .../org/apache/poi/hssf/usermodel/HSSFWorkbook.java | 2 +- .../org/apache/poi/hssf/model/TestFormulaParser.java | 2 +- .../org/apache/poi/hssf/record/AllRecordTests.java | 1 + .../org/apache/poi/hssf/record/TestSSTRecord.java | 1 + .../poi/hssf/record/TestSSTRecordSizeCalculator.java | 1 + .../hssf/record/{ => common}/TestUnicodeString.java | 5 ++++- .../org/apache/poi/hssf/usermodel/TestBugs.java | 10 ++++++++++ 16 files changed, 29 insertions(+), 8 deletions(-) rename src/java/org/apache/poi/hssf/record/{ => common}/UnicodeString.java (99%) rename src/testcases/org/apache/poi/hssf/record/{ => common}/TestUnicodeString.java (97%) diff --git a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java index 3c2a210ac..868d2a0a6 100644 --- a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java +++ b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java @@ -71,12 +71,12 @@ import org.apache.poi.hssf.record.SSTRecord; import org.apache.poi.hssf.record.StyleRecord; import org.apache.poi.hssf.record.SupBookRecord; import org.apache.poi.hssf.record.TabIdRecord; -import org.apache.poi.hssf.record.UnicodeString; import org.apache.poi.hssf.record.UseSelFSRecord; import org.apache.poi.hssf.record.WindowOneRecord; import org.apache.poi.hssf.record.WindowProtectRecord; import org.apache.poi.hssf.record.WriteAccessRecord; import org.apache.poi.hssf.record.WriteProtectRecord; +import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.hssf.record.formula.NameXPtg; import org.apache.poi.hssf.record.formula.FormulaShifter; import org.apache.poi.hssf.record.formula.Ptg; diff --git a/src/java/org/apache/poi/hssf/record/DVRecord.java b/src/java/org/apache/poi/hssf/record/DVRecord.java index a6d9f11b6..67e873691 100644 --- a/src/java/org/apache/poi/hssf/record/DVRecord.java +++ b/src/java/org/apache/poi/hssf/record/DVRecord.java @@ -17,6 +17,7 @@ package org.apache.poi.hssf.record; +import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.hssf.record.formula.Ptg; import org.apache.poi.hssf.usermodel.HSSFDataValidation; import org.apache.poi.ss.formula.Formula; diff --git a/src/java/org/apache/poi/hssf/record/SSTDeserializer.java b/src/java/org/apache/poi/hssf/record/SSTDeserializer.java index 304dc3bfe..c9f6569b4 100644 --- a/src/java/org/apache/poi/hssf/record/SSTDeserializer.java +++ b/src/java/org/apache/poi/hssf/record/SSTDeserializer.java @@ -19,6 +19,7 @@ package org.apache.poi.hssf.record; +import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.util.IntMapper; /** diff --git a/src/java/org/apache/poi/hssf/record/SSTRecord.java b/src/java/org/apache/poi/hssf/record/SSTRecord.java index 481fa84d3..e95f155eb 100644 --- a/src/java/org/apache/poi/hssf/record/SSTRecord.java +++ b/src/java/org/apache/poi/hssf/record/SSTRecord.java @@ -19,6 +19,7 @@ package org.apache.poi.hssf.record; import java.util.Iterator; +import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.hssf.record.cont.ContinuableRecord; import org.apache.poi.hssf.record.cont.ContinuableRecordOutput; import org.apache.poi.util.IntMapper; diff --git a/src/java/org/apache/poi/hssf/record/SSTSerializer.java b/src/java/org/apache/poi/hssf/record/SSTSerializer.java index 78844deb3..f1022642e 100644 --- a/src/java/org/apache/poi/hssf/record/SSTSerializer.java +++ b/src/java/org/apache/poi/hssf/record/SSTSerializer.java @@ -17,6 +17,7 @@ package org.apache.poi.hssf.record; +import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.hssf.record.cont.ContinuableRecordOutput; import org.apache.poi.util.IntMapper; diff --git a/src/java/org/apache/poi/hssf/record/UnicodeString.java b/src/java/org/apache/poi/hssf/record/common/UnicodeString.java similarity index 99% rename from src/java/org/apache/poi/hssf/record/UnicodeString.java rename to src/java/org/apache/poi/hssf/record/common/UnicodeString.java index 9198e822b..842a7341c 100644 --- a/src/java/org/apache/poi/hssf/record/UnicodeString.java +++ b/src/java/org/apache/poi/hssf/record/common/UnicodeString.java @@ -15,13 +15,14 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.record; +package org.apache.poi.hssf.record.common; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; +import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.cont.ContinuableRecordOutput; import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index 071f1b431..ac7ab6f91 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -41,8 +41,8 @@ import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.RecordBase; import org.apache.poi.hssf.record.SubRecord; import org.apache.poi.hssf.record.TextObjectRecord; -import org.apache.poi.hssf.record.UnicodeString; import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate; +import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.hssf.record.formula.ExpPtg; import org.apache.poi.hssf.record.formula.Ptg; import org.apache.poi.hssf.record.formula.eval.ErrorEval; diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java b/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java index 0de860214..66327d941 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java @@ -21,7 +21,7 @@ import java.util.Iterator; import org.apache.poi.hssf.record.ExtendedFormatRecord; import org.apache.poi.hssf.record.FontRecord; -import org.apache.poi.hssf.record.UnicodeString; +import org.apache.poi.hssf.record.common.UnicodeString; /** * Excel can get cranky if you give it files containing too diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java index e69a203b9..f8e3871bc 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java @@ -21,7 +21,7 @@ import java.util.Iterator; import org.apache.poi.hssf.model.InternalWorkbook; import org.apache.poi.hssf.record.LabelSSTRecord; -import org.apache.poi.hssf.record.UnicodeString; +import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.RichTextString; /** diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index 5c8c30eed..97e534be2 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -52,9 +52,9 @@ import org.apache.poi.hssf.record.ObjRecord; import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.RecordFactory; import org.apache.poi.hssf.record.SSTRecord; -import org.apache.poi.hssf.record.UnicodeString; import org.apache.poi.hssf.record.UnknownRecord; import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor; +import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.hssf.record.formula.Area3DPtg; import org.apache.poi.hssf.record.formula.MemFuncPtg; import org.apache.poi.hssf.record.formula.NameXPtg; diff --git a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java index 2d2784c2d..72e055fe7 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java +++ b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java @@ -24,7 +24,7 @@ import junit.framework.TestCase; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.record.NameRecord; -import org.apache.poi.hssf.record.UnicodeString; +import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.hssf.record.constant.ErrorConstant; import org.apache.poi.hssf.record.formula.AbstractFunctionPtg; import org.apache.poi.hssf.record.formula.AddPtg; diff --git a/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java b/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java index 6d913bb5d..d49475f5c 100644 --- a/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java +++ b/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java @@ -23,6 +23,7 @@ import junit.framework.TestSuite; import org.apache.poi.hssf.record.aggregates.AllRecordAggregateTests; import org.apache.poi.hssf.record.cf.TestCellRange; import org.apache.poi.hssf.record.chart.AllChartRecordTests; +import org.apache.poi.hssf.record.common.TestUnicodeString; import org.apache.poi.hssf.record.constant.TestConstantValueParser; import org.apache.poi.hssf.record.crypto.AllHSSFEncryptionTests; import org.apache.poi.hssf.record.formula.AllFormulaTests; diff --git a/src/testcases/org/apache/poi/hssf/record/TestSSTRecord.java b/src/testcases/org/apache/poi/hssf/record/TestSSTRecord.java index 4a9b7c0b8..65d56cf31 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestSSTRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestSSTRecord.java @@ -30,6 +30,7 @@ import junit.framework.AssertionFailedError; import junit.framework.TestCase; import org.apache.poi.hssf.HSSFTestDataSamples; +import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.util.HexRead; diff --git a/src/testcases/org/apache/poi/hssf/record/TestSSTRecordSizeCalculator.java b/src/testcases/org/apache/poi/hssf/record/TestSSTRecordSizeCalculator.java index 2a0830ac7..b171a77a1 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestSSTRecordSizeCalculator.java +++ b/src/testcases/org/apache/poi/hssf/record/TestSSTRecordSizeCalculator.java @@ -19,6 +19,7 @@ package org.apache.poi.hssf.record; import junit.framework.TestCase; +import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.hssf.record.cont.ContinuableRecordOutput; import org.apache.poi.util.IntMapper; diff --git a/src/testcases/org/apache/poi/hssf/record/TestUnicodeString.java b/src/testcases/org/apache/poi/hssf/record/common/TestUnicodeString.java similarity index 97% rename from src/testcases/org/apache/poi/hssf/record/TestUnicodeString.java rename to src/testcases/org/apache/poi/hssf/record/common/TestUnicodeString.java index 1a80f9e92..6ecab71a5 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestUnicodeString.java +++ b/src/testcases/org/apache/poi/hssf/record/common/TestUnicodeString.java @@ -15,10 +15,13 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.record; +package org.apache.poi.hssf.record.common; import junit.framework.TestCase; +import org.apache.poi.hssf.record.ContinueRecord; +import org.apache.poi.hssf.record.RecordInputStream; +import org.apache.poi.hssf.record.SSTRecord; import org.apache.poi.hssf.record.cont.ContinuableRecordOutput; /** diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 740cd8e59..d96ad7466 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -1536,4 +1536,14 @@ public final class TestBugs extends BaseTestBugzillaIssues { public void test47251() { openSample("47251.xls"); } + + /** + * Round trip a file with an unusual ExtRst record + */ + public void test47847() { + HSSFWorkbook wb = openSample("47251.xls"); + assertEquals(1, wb.getNumberOfSheets()); + wb = writeOutAndReadBack(wb); + assertEquals(1, wb.getNumberOfSheets()); + } }