From e4a4574a1edd3fcab17356792e7ecb4aba2315f1 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sun, 27 Dec 2009 18:22:02 +0000 Subject: [PATCH] Start testing the contents of FeatRecord git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@894091 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hssf/record/FeatRecord.java | 34 +++++++++++++++++++ .../poi/hssf/record/TestFeatRecord.java | 18 ++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/java/org/apache/poi/hssf/record/FeatRecord.java b/src/java/org/apache/poi/hssf/record/FeatRecord.java index 8304278e96..5f8d9a19a3 100644 --- a/src/java/org/apache/poi/hssf/record/FeatRecord.java +++ b/src/java/org/apache/poi/hssf/record/FeatRecord.java @@ -104,4 +104,38 @@ public final class FeatRecord extends StandardRecord { (cellRefs.length * CellRangeAddress.ENCODED_SIZE) +rgbFeat.length; } + + public int getIsf_sharedFeatureType() { + return isf_sharedFeatureType; + } + public void setIsf_sharedFeatureType(int isfSharedFeatureType) { + isf_sharedFeatureType = isfSharedFeatureType; + } + + public long getCbFeatData() { + return cbFeatData; + } + public void setCbFeatData(long cbFeatData) { + this.cbFeatData = cbFeatData; + } + + public CellRangeAddress[] getCellRefs() { + return cellRefs; + } + public void setCellRefs(CellRangeAddress[] cellRefs) { + this.cellRefs = cellRefs; + } + + public byte[] getRgbFeat() { + return rgbFeat; + } + public void setRgbFeat(byte[] rgbFeat) { + this.rgbFeat = rgbFeat; + + if(isf_sharedFeatureType == FeatHdrRecord.SHAREDFEATURES_ISFFEC2) { + cbFeatData = rgbFeat.length; + } else { + cbFeatData = 0; + } + } } diff --git a/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java b/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java index 4840561e01..7fe7c3bae0 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java @@ -88,6 +88,7 @@ public final class TestFeatRecord extends TestCase { InternalWorkbook wb = HSSFTestHelper.getWorkbookForTest(hssf); FeatRecord fr = null; + FeatHdrRecord fhr = null; assertEquals(1, hssf.getNumberOfSheets()); @@ -125,6 +126,7 @@ public final class TestFeatRecord extends TestCase { countFR++; } if(r instanceof FeatHdrRecord) { + fhr = (FeatHdrRecord)r; countFRH++; } else if (r.getSid() == FeatHdrRecord.sid) { countFRH++; @@ -135,7 +137,23 @@ public final class TestFeatRecord extends TestCase { assertEquals(1, countFR); assertEquals(1, countFRH); assertNotNull(fr); + assertNotNull(fhr); // Now check the contents are as expected + assertEquals( + FeatHdrRecord.SHAREDFEATURES_ISFFEC2, + fr.getIsf_sharedFeatureType() + ); + + // Applies to one cell only + assertEquals(1, fr.getCellRefs().length); + assertEquals(0, fr.getCellRefs()[0].getFirstRow()); + assertEquals(0, fr.getCellRefs()[0].getLastRow()); + assertEquals(0, fr.getCellRefs()[0].getFirstColumn()); + assertEquals(0, fr.getCellRefs()[0].getLastColumn()); + + // TODO - more checking of shared features stuff + assertEquals(4, fr.getCbFeatData()); + assertEquals(4, fr.getRgbFeat().length); } }