FileDocCategorySizeDatePackage
TestTextObjectBaseRecord.javaAPI DocApache Poi 3.0.13827Mon Jan 01 12:39:46 GMT 2007org.apache.poi.hssf.record

TestTextObjectBaseRecord

public class TestTextObjectBaseRecord extends TestCase
Tests the serialization and deserialization of the TextObjectBaseRecord class works correctly. Test data taken directly from a real Excel file.
author
Glen Stampoultzis (glens at apache.org)

Fields Summary
byte[]
data
Constructors Summary
public TestTextObjectBaseRecord(String name)


      
    
        super(name);
    
Methods Summary
public voidtestLoad()

        TextObjectBaseRecord record = new TextObjectBaseRecord(new TestcaseRecordInputStream((short)0x1B6, (short)data.length, data));


//        assertEquals( (short), record.getOptions());
        assertEquals( false, record.isReserved1() );
        assertEquals( TextObjectBaseRecord.HORIZONTAL_TEXT_ALIGNMENT_CENTERED, record.getHorizontalTextAlignment() );
        assertEquals( TextObjectBaseRecord.VERTICAL_TEXT_ALIGNMENT_JUSTIFY, record.getVerticalTextAlignment() );
        assertEquals( 0, record.getReserved2() );
        assertEquals( true, record.isTextLocked() );
        assertEquals( 0, record.getReserved3() );
        assertEquals( TextObjectBaseRecord.TEXT_ORIENTATION_ROT_RIGHT, record.getTextOrientation());
        assertEquals( 0, record.getReserved4());
        assertEquals( 0, record.getReserved5());
        assertEquals( 0, record.getReserved6());
        assertEquals( 2, record.getTextLength());
        assertEquals( 2, record.getFormattingRunLength());
        assertEquals( 0, record.getReserved7());


        assertEquals( 22, record.getRecordSize() );

        record.validateSid((short)0x1B6);
    
public voidtestStore()

        TextObjectBaseRecord record = new TextObjectBaseRecord();



//        record.setOptions( (short) 0x0000);
        record.setReserved1( false );
        record.setHorizontalTextAlignment( TextObjectBaseRecord.HORIZONTAL_TEXT_ALIGNMENT_CENTERED );
        record.setVerticalTextAlignment( TextObjectBaseRecord.VERTICAL_TEXT_ALIGNMENT_JUSTIFY );
        record.setReserved2( (short)0 );
        record.setTextLocked( true );
        record.setReserved3( (short)0 );
        record.setTextOrientation( TextObjectBaseRecord.TEXT_ORIENTATION_ROT_RIGHT );
        record.setReserved4( (short)0 );
        record.setReserved5( (short)0 );
        record.setReserved6( (short)0 );
        record.setTextLength( (short)2 );
        record.setFormattingRunLength( (short)2 );
        record.setReserved7( 0 );

        byte [] recordBytes = record.serialize();
        assertEquals(recordBytes.length - 4, data.length);
        for (int i = 0; i < data.length; i++)
            assertEquals("At offset " + i, data[i], recordBytes[i+4]);