Bildunterschrift für OLE-Icon festlegen
Neue Methoden getSubstitutePictureTitle und setSubstitutePictureTitle wurden zum IOleObjectFrame-Interface und zur OleObjectFrame-Klasse hinzugefügt. Sie ermöglichen das Abrufen, Setzen oder Ändern der Bildunterschrift eines OLE-Icons. Der folgende Codeausschnitt zeigt ein Beispiel zum Erstellen eines Excel-Objekts und zum Festlegen seiner Bildunterschrift.
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SubstitutePictureTitleOfOLEObjectFrame.class); | |
String oleSourceFile = dataDir + "book1.xlsx"; | |
String oleIconFile = dataDir + "aspose-logo.jpg"; | |
Presentation pres = new Presentation(); | |
try | |
{ | |
IPPImage image = null; | |
ISlide slide = pres.getSlides().get_Item(0); | |
// Add Ole objects | |
byte[] allbytes = Files.readAllBytes(Paths.get(oleSourceFile)); | |
IOleObjectFrame oof = slide.getShapes().addOleObjectFrame(20, 20, 50, 50, "Excel.Sheet.12", allbytes); | |
oof.setObjectIcon(true); | |
// Add image object | |
byte[] imgBuf = Files.readAllBytes(Paths.get(oleIconFile)); | |
ByteArrayInputStream bais = new ByteArrayInputStream(imgBuf); | |
try { | |
image = pres.getImages().addImage(ImageIO.read(bais)); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} | |
oof.getSubstitutePictureFormat().getPicture().setImage(image); | |
// Set caption to OLE icon | |
oof.setSubstitutePictureTitle("Caption example"); | |
} finally { | |
pres.dispose(); | |
} | |