I did come up with a way to get the alt text from the properties of a 
picture.

/**
 * Returns the alternative text stored in the EscherProperties
 * @param picture
 * @return
 */
public static String getAltText(Picture picture){
        PICFAndOfficeArtData picfAndOfficeArtData = null;
        try{
                Field field = picture.getClass().getDeclaredField(
"_picfAndOfficeArtData");
                field.setAccessible(true);
                picfAndOfficeArtData = (PICFAndOfficeArtData) 
field.get(picture);
        }catch(Exception e){
                logger.error("Unable to get _picfAndOfficeArtData",e);
                throw new RuntimeException(e);
        }
 
        for(EscherRecord escherRecord : 
picfAndOfficeArtData.getShape().getChildRecords()){
                if(escherRecord instanceof EscherOptRecord){
                        EscherOptRecord escherOptRecord = 
(EscherOptRecord) escherRecord;
                        for(EscherProperty property : 
escherOptRecord.getEscherProperties()){
                                if(EscherProperties.
GROUPSHAPE__DESCRIPTION == property.getPropertyNumber()){
                                        byte[] complexData = 
((EscherComplexProperty)property).getComplexData();
                                        byte[] altTextData = new byte
[(complexData.length/2)-1];
                                        for(int i=0; i<altTextData.length
;i++){
                                                altTextData[i] = 
complexData[i*2];
                                        }
 
                                        return new String(altTextData);
                        }
                        }
                }
        }
 
        return null;
}

Reply via email to