]> source.dussan.org Git - poi.git/commitdiff
Start testing the contents of FeatRecord
authorNick Burch <nick@apache.org>
Sun, 27 Dec 2009 18:22:02 +0000 (18:22 +0000)
committerNick Burch <nick@apache.org>
Sun, 27 Dec 2009 18:22:02 +0000 (18:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@894091 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/FeatRecord.java
src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java

index 8304278e964e74fe4deb9befbafce96fb976c2be..5f8d9a19a36881758187dd92c52807d485562383 100644 (file)
@@ -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;
+               }
+       }
 }
index 4840561e01889f9e4086dd765083cbf8ac13b844..7fe7c3bae04d9cd8651df1f112ede8136e6d9e9d 100644 (file)
@@ -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);
        }
 }