Search in sources :

Example 6 with EscherComplexProperty

use of org.apache.poi.ddf.EscherComplexProperty in project poi by apache.

the class TestOfficeDrawings method testWatermark.

/**
     * Tests watermark text extraction
     */
public void testWatermark() throws Exception {
    HWPFDocument hwpfDocument = HWPFTestDataSamples.openSampleFile("watermark.doc");
    OfficeDrawing drawing = hwpfDocument.getOfficeDrawingsHeaders().getOfficeDrawings().iterator().next();
    EscherContainerRecord escherContainerRecord = drawing.getOfficeArtSpContainer();
    EscherOptRecord officeArtFOPT = escherContainerRecord.getChildById((short) 0xF00B);
    EscherComplexProperty gtextUNICODE = (EscherComplexProperty) officeArtFOPT.lookup(0x00c0);
    String text = StringUtil.getFromUnicodeLE(gtextUNICODE.getComplexData());
    assertEquals("DRAFT CONTRACT\0", text);
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherComplexProperty(org.apache.poi.ddf.EscherComplexProperty) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord)

Example 7 with EscherComplexProperty

use of org.apache.poi.ddf.EscherComplexProperty in project poi by apache.

the class HSSFPatriarch method containsChart.

/**
     * Does this HSSFPatriarch contain a chart?
     * (Technically a reference to a chart, since they
     * get stored in a different block of records)
     * FIXME - detect chart in all cases (only seems
     * to work on some charts so far)
     */
public boolean containsChart() {
    // TODO - support charts properly in usermodel
    // We're looking for a EscherOptRecord
    EscherOptRecord optRecord = (EscherOptRecord) _boundAggregate.findFirstWithId(EscherOptRecord.RECORD_ID);
    if (optRecord == null) {
        // No opt record, can't have chart
        return false;
    }
    for (Iterator<EscherProperty> it = optRecord.getEscherProperties().iterator(); it.hasNext(); ) {
        EscherProperty prop = it.next();
        if (prop.getPropertyNumber() == 896 && prop.isComplex()) {
            EscherComplexProperty cp = (EscherComplexProperty) prop;
            String str = StringUtil.getFromUnicodeLE(cp.getComplexData());
            if (str.equals("Chart 1\0")) {
                return true;
            }
        }
    }
    return false;
}
Also used : EscherComplexProperty(org.apache.poi.ddf.EscherComplexProperty) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord) EscherProperty(org.apache.poi.ddf.EscherProperty)

Aggregations

EscherComplexProperty (org.apache.poi.ddf.EscherComplexProperty)7 AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)3 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)3 EscherProperty (org.apache.poi.ddf.EscherProperty)2 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)1 ExControl (org.apache.poi.hslf.record.ExControl)1 HWPFDocument (org.apache.poi.hwpf.HWPFDocument)1