/** * Check if a given shape is associated with a sound. * @return 0-based reference to a sound in the sound collection * or -1 if the shape is not associated with a sound */ protected static int getSoundReference(HSLFShape shape){ int soundRef = -1; //dive into the shape container and search for InteractiveInfoAtom InteractiveInfoAtom info = shape.getClientDataRecord(RecordTypes.InteractiveInfo.typeID); if (info != null && info.getAction() == InteractiveInfoAtom.ACTION_MEDIA) { soundRef = info.getSoundRef(); } return soundRef; } }
/** * Create a new InteractiveInfo, with blank fields */ public InteractiveInfo() { _header = new byte[8]; _children = new Record[1]; // Setup our header block _header[0] = 0x0f; // We are a container record LittleEndian.putShort(_header, 2, (short)_type); // Setup our child records infoAtom = new InteractiveInfoAtom(); _children[0] = infoAtom; }
@Override public void linkToFirstSlide() { InteractiveInfoAtom iia = info.getInteractiveInfoAtom(); iia.setAction(InteractiveInfoAtom.ACTION_JUMP); iia.setJump(InteractiveInfoAtom.JUMP_FIRSTSLIDE); iia.setHyperlinkType(InteractiveInfoAtom.LINK_FirstSlide); linkToDocument(1,-1,"FIRST",0x10); }
infoAtom.setAction(InteractiveInfoAtom.ACTION_JUMP); infoAtom.setJump(InteractiveInfoAtom.JUMP_FIRSTSLIDE); infoAtom.setHyperlinkType(InteractiveInfoAtom.LINK_FirstSlide); break; case Hyperlink.LINK_LASTSLIDE: infoAtom.setAction(InteractiveInfoAtom.ACTION_JUMP); infoAtom.setJump(InteractiveInfoAtom.JUMP_LASTSLIDE); infoAtom.setHyperlinkType(InteractiveInfoAtom.LINK_LastSlide); break; case Hyperlink.LINK_NEXTSLIDE: infoAtom.setAction(InteractiveInfoAtom.ACTION_JUMP); infoAtom.setJump(InteractiveInfoAtom.JUMP_NEXTSLIDE); infoAtom.setHyperlinkType(InteractiveInfoAtom.LINK_NextSlide); break; case Hyperlink.LINK_PREVIOUSSLIDE: infoAtom.setAction(InteractiveInfoAtom.ACTION_JUMP); infoAtom.setJump(InteractiveInfoAtom.JUMP_PREVIOUSSLIDE); infoAtom.setHyperlinkType(InteractiveInfoAtom.LINK_PreviousSlide); break; case Hyperlink.LINK_URL: infoAtom.setAction(InteractiveInfoAtom.ACTION_HYPERLINK); infoAtom.setJump(InteractiveInfoAtom.JUMP_NONE); infoAtom.setHyperlinkType(InteractiveInfoAtom.LINK_Url); break; infoAtom.setHyperlinkID(link.getId());
/** * * Assigns a hyperlink to this text shape * * @param linkId id of the hyperlink, @see org.apache.poi.hslf.usermodel.SlideShow#addHyperlink(Hyperlink) * @param beginIndex the beginning index, inclusive. * @param endIndex the ending index, exclusive. * @see org.apache.poi.hslf.usermodel.SlideShow#addHyperlink(Hyperlink) */ public void setHyperlink(int linkId, int beginIndex, int endIndex){ //TODO validate beginIndex and endIndex and throw IllegalArgumentException InteractiveInfo info = new InteractiveInfo(); InteractiveInfoAtom infoAtom = info.getInteractiveInfoAtom(); infoAtom.setAction(InteractiveInfoAtom.ACTION_HYPERLINK); infoAtom.setHyperlinkType(InteractiveInfoAtom.LINK_Url); infoAtom.setHyperlinkID(linkId); _txtbox.appendChildRecord(info); TxInteractiveInfoAtom txiatom = new TxInteractiveInfoAtom(); txiatom.setStartIndex(beginIndex); txiatom.setEndIndex(endIndex); _txtbox.appendChildRecord(txiatom); }
private static void find(Record[] records, ExObjList exobj, List out){ for (int i = 0; i < records.length; i++) { //see if we have InteractiveInfo in the textrun's records if( records[i] instanceof InteractiveInfo){ InteractiveInfo hldr = (InteractiveInfo)records[i]; InteractiveInfoAtom info = hldr.getInteractiveInfoAtom(); int id = info.getHyperlinkID(); ExHyperlink linkRecord = exobj.get(id); if (linkRecord != null){ Hyperlink link = new Hyperlink(); link.title = linkRecord.getLinkTitle(); link.address = linkRecord.getLinkURL(); link.type = info.getAction(); if (++i < records.length && records[i] instanceof TxInteractiveInfoAtom){ TxInteractiveInfoAtom txinfo = (TxInteractiveInfoAtom)records[i]; link.startIndex = txinfo.getStartIndex(); link.endIndex = txinfo.getEndIndex(); } out.add(link); } } } } }
/** * Create a new Placeholder and initialize internal structures * * @return the created <code>EscherContainerRecord</code> which holds shape data */ @Override protected EscherContainerRecord createSpContainer(int idx, boolean isChild) { EscherContainerRecord ecr = super.createSpContainer(idx, isChild); setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x1000100); setEscherProperty(EscherProperties.FILL__NOFILLHITTEST, 0x10001); ExObjRefAtom oe = new ExObjRefAtom(); InteractiveInfo info = new InteractiveInfo(); InteractiveInfoAtom infoAtom = info.getInteractiveInfoAtom(); infoAtom.setAction(InteractiveInfoAtom.ACTION_MEDIA); infoAtom.setHyperlinkType(InteractiveInfoAtom.LINK_NULL); AnimationInfo an = new AnimationInfo(); AnimationInfoAtom anAtom = an.getAnimationInfoAtom(); anAtom.setFlag(AnimationInfoAtom.Automatic, true); HSLFEscherClientDataRecord cldata = getClientData(true); cldata.addChild(oe); cldata.addChild(an); cldata.addChild(info); return ecr; }
private static HSLFShape createFrame(EscherContainerRecord spContainer, ShapeContainer<HSLFShape,HSLFTextParagraph> parent) { InteractiveInfo info = getClientDataRecord(spContainer, RecordTypes.InteractiveInfo.typeID); if(info != null && info.getInteractiveInfoAtom() != null){ switch(info.getInteractiveInfoAtom().getAction()){ case InteractiveInfoAtom.ACTION_OLE: return new HSLFObjectShape(spContainer, parent); case InteractiveInfoAtom.ACTION_MEDIA: return new MovieShape(spContainer, parent); default: break; } } ExObjRefAtom oes = getClientDataRecord(spContainer, RecordTypes.ExObjRefAtom.typeID); return (oes != null) ? new HSLFObjectShape(spContainer, parent) : new HSLFPictureShape(spContainer, parent); }
/** * Constructs a brand new link related atom record. */ protected InteractiveInfoAtom() { _header = new byte[8]; _data = new byte[16]; LittleEndian.putShort(_header, 2, (short)getRecordType()); LittleEndian.putInt(_header, 4, _data.length); // It is fine for the other values to be zero }
/** * Creates a new Hyperlink and assign it to a shape * This is only a helper method - use {@link HSLFSimpleShape#createHyperlink()} instead! * * @param shape the shape which receives the hyperlink * @return the new hyperlink * * @see HSLFSimpleShape#createHyperlink() */ /* package */ static HSLFHyperlink createHyperlink(HSLFSimpleShape shape) { // TODO: check if a hyperlink already exists ExHyperlink exHyper = new ExHyperlink(); int linkId = shape.getSheet().getSlideShow().addToObjListAtom(exHyper); ExHyperlinkAtom obj = exHyper.getExHyperlinkAtom(); obj.setNumber(linkId); InteractiveInfo info = new InteractiveInfo(); info.getInteractiveInfoAtom().setHyperlinkID(linkId); HSLFEscherClientDataRecord cldata = shape.getClientData(true); cldata.addChild(info); HSLFHyperlink hyper = new HSLFHyperlink(exHyper, info); hyper.linkToNextSlide(); shape.setHyperlink(hyper); return hyper; }
continue; int id = info.getHyperlinkID(); ExHyperlink exHyper = exobj.get(id); if (exHyper == null) {
/** * Gets the type of the hyperlink action. * Must be a <code>LINK_*</code> constant</code> * * @return the hyperlink URL * @see InteractiveInfoAtom */ @Override public HyperlinkType getType() { switch (info.getInteractiveInfoAtom().getHyperlinkType()) { case InteractiveInfoAtom.LINK_Url: return (exHyper.getLinkURL().startsWith("mailto:")) ? HyperlinkType.EMAIL : HyperlinkType.URL; case InteractiveInfoAtom.LINK_NextSlide: case InteractiveInfoAtom.LINK_PreviousSlide: case InteractiveInfoAtom.LINK_FirstSlide: case InteractiveInfoAtom.LINK_LastSlide: case InteractiveInfoAtom.LINK_SlideNumber: return HyperlinkType.DOCUMENT; case InteractiveInfoAtom.LINK_CustomShow: case InteractiveInfoAtom.LINK_OtherPresentation: case InteractiveInfoAtom.LINK_OtherFile: return HyperlinkType.FILE; default: case InteractiveInfoAtom.LINK_NULL: return HyperlinkType.NONE; } }
InteractiveInfo info = new InteractiveInfo(); InteractiveInfoAtom infoAtom = info.getInteractiveInfoAtom(); infoAtom.setAction(InteractiveInfoAtom.ACTION_MEDIA); infoAtom.setHyperlinkType(InteractiveInfoAtom.LINK_NULL);
OEShapeAtom oes = (OEShapeAtom)getClientDataRecord(spContainer, RecordTypes.OEShapeAtom.typeID); if(info != null && info.getInteractiveInfoAtom() != null){ switch(info.getInteractiveInfoAtom().getAction()){ case InteractiveInfoAtom.ACTION_OLE: shape = new OLEShape(spContainer, parent);
/** * Constructs a brand new link related atom record. */ protected InteractiveInfoAtom() { _header = new byte[8]; _data = new byte[16]; LittleEndian.putShort(_header, 2, (short)getRecordType()); LittleEndian.putInt(_header, 4, _data.length); // It is fine for the other values to be zero }
obj.setNumber(linkId); InteractiveInfo info = new InteractiveInfo(); info.getInteractiveInfoAtom().setHyperlinkID(linkId);
@Override public void linkToLastSlide() { InteractiveInfoAtom iia = info.getInteractiveInfoAtom(); iia.setAction(InteractiveInfoAtom.ACTION_JUMP); iia.setJump(InteractiveInfoAtom.JUMP_LASTSLIDE); iia.setHyperlinkType(InteractiveInfoAtom.LINK_LastSlide); linkToDocument(1,-1,"LAST",0x10); }
/** * Create a new InteractiveInfo, with blank fields */ public InteractiveInfo() { _header = new byte[8]; _children = new Record[1]; // Setup our header block _header[0] = 0x0f; // We are a container record LittleEndian.putShort(_header, 2, (short)_type); // Setup our child records infoAtom = new InteractiveInfoAtom(); _children[0] = infoAtom; }
@Override public void linkToNextSlide() { InteractiveInfoAtom iia = info.getInteractiveInfoAtom(); iia.setAction(InteractiveInfoAtom.ACTION_JUMP); iia.setJump(InteractiveInfoAtom.JUMP_NEXTSLIDE); iia.setHyperlinkType(InteractiveInfoAtom.LINK_NextSlide); linkToDocument(1,-1,"NEXT",0x10); }
@Override public void linkToPreviousSlide() { InteractiveInfoAtom iia = info.getInteractiveInfoAtom(); iia.setAction(InteractiveInfoAtom.ACTION_JUMP); iia.setJump(InteractiveInfoAtom.JUMP_PREVIOUSSLIDE); iia.setHyperlinkType(InteractiveInfoAtom.LINK_PreviousSlide); linkToDocument(1,-1,"PREV",0x10); }