1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 import junit.framework.TestCase; 24 import org.apache.poi.hssf.record.formula.Area3DPtg; 25 26 import java.util.Stack ; 27 28 35 public class TestLinkedDataRecord 36 extends TestCase 37 { 38 39 147 148 byte[] data = new byte[]{ 149 (byte)0x01, (byte)0x02, (byte)0x00,(byte)0x00, (byte)0x00,(byte)0x00, (byte)0x0B,(byte)0x00, (byte)0x3B, (byte)0x00,(byte)0x00, (byte)0x00,(byte)0x00, (byte)0x00,(byte)0x1F, (byte)0x00,(byte)0x00, (byte)0x00,(byte)0x00, }; 161 162 public TestLinkedDataRecord(String name) 163 { 164 super(name); 165 } 166 167 public void testLoad() 168 throws Exception 169 { 170 171 LinkedDataRecord record = new LinkedDataRecord((short)0x1051, (short)data.length, data); 172 assertEquals( LinkedDataRecord.LINK_TYPE_VALUES, record.getLinkType()); 173 assertEquals( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET, record.getReferenceType()); 174 assertEquals( 0, record.getOptions()); 175 assertEquals( false, record.isCustomNumberFormat() ); 176 assertEquals( 0, record.getIndexNumberFmtRecord()); 177 178 Area3DPtg ptg = new Area3DPtg(); 179 ptg.setExternSheetIndex((short)0); 180 ptg.setFirstColumn((short)0); 181 ptg.setLastColumn((short)0); 182 ptg.setFirstRow((short)0); 183 ptg.setLastRow((short)7936); 184 ptg.setFirstColRelative(false); 185 ptg.setLastColRelative(false); 186 ptg.setFirstRowRelative(false); 187 ptg.setLastRowRelative(false); 188 Stack s = new Stack (); 189 s.push(ptg); 190 assertEquals( s, record.getFormulaOfLink().getFormulaTokens() ); 191 192 assertEquals( data.length + 4, record.getRecordSize() ); 193 194 record.validateSid((short)0x1051); 195 196 } 197 198 public void testStore() 199 { 200 LinkedDataRecord record = new LinkedDataRecord(); 201 record.setLinkType( LinkedDataRecord.LINK_TYPE_VALUES ); 202 record.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET ); 203 record.setOptions( (short)0 ); 204 record.setCustomNumberFormat( false ); 205 record.setIndexNumberFmtRecord( (short)0 ); 206 Area3DPtg ptg = new Area3DPtg(); 207 ptg.setExternSheetIndex((short)0); 208 ptg.setFirstColumn((short)0); 209 ptg.setLastColumn((short)0); 210 ptg.setFirstRow((short)0); 211 ptg.setLastRow((short)7936); 212 ptg.setFirstColRelative(false); 213 ptg.setLastColRelative(false); 214 ptg.setFirstRowRelative(false); 215 ptg.setLastRowRelative(false); 216 Stack s = new Stack (); 217 s.push(ptg); 218 LinkedDataFormulaField formulaOfLink = new LinkedDataFormulaField(); 219 formulaOfLink.setFormulaTokens(s); 220 record.setFormulaOfLink(formulaOfLink ); 221 222 byte [] recordBytes = record.serialize(); 223 assertEquals(recordBytes.length - 4, data.length); 224 for (int i = 0; i < data.length; i++) 225 assertEquals("At offset " + i, data[i], recordBytes[i+4]); 226 } 227 } 228 | Popular Tags |