<!-- Don't forget to update status.xml too! -->
<release version="3.1.1-alpha1" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="add">Initial support for embedded movies and controls in HSLF</action>
<action dev="POI-DEVELOPERS" type="fix">45358 - signed/unsigned error when parsing 3-d area refs, performance problem evaluating area refs, and ClassCastExcecption in IF()</action>
<action dev="POI-DEVELOPERS" type="add">Support for HPBF Publisher hyperlinks, including during text extraction</action>
<action dev="POI-DEVELOPERS" type="fix">26321 and 44958 - preserve position of ArrayRecords and TableRecords among cell value records</action>
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.1.1-alpha1" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="add">Initial support for embedded movies and controls in HSLF</action>
<action dev="POI-DEVELOPERS" type="fix">45358 - signed/unsigned error when parsing 3-d area refs, performance problem evaluating area refs, and ClassCastExcecption in IF()</action>
<action dev="POI-DEVELOPERS" type="add">Support for HPBF Publisher hyperlinks, including during text extraction</action>
<action dev="POI-DEVELOPERS" type="fix">26321 and 44958 - preserve position of ArrayRecords and TableRecords among cell value records</action>
dump(data, pos, size, padding);
} else {
//dump first 100 bytes of the atom data
- dump(out, data, pos, size, padding, true);
+ dump(out, data, pos, Math.min(size, data.length-pos), padding, true);
}
padding--;
write(out, "</"+recname + ">" + CR, padding);
* @author Yegor Kozlov\r
*/\r
public class Hyperlink {\r
-\r
+ public static final byte LINK_NEXTSLIDE = InteractiveInfoAtom.LINK_NextSlide;\r
+ public static final byte LINK_PREVIOUSSLIDE = InteractiveInfoAtom.LINK_PreviousSlide;\r
+ public static final byte LINK_FIRSTSLIDE = InteractiveInfoAtom.LINK_FirstSlide;\r
+ public static final byte LINK_LASTSLIDE = InteractiveInfoAtom.LINK_LastSlide;\r
+ public static final byte LINK_URL = InteractiveInfoAtom.LINK_Url;\r
+ public static final byte LINK_NULL = InteractiveInfoAtom.LINK_NULL;\r
+\r
+ private int id=-1;\r
private int type;\r
private String address;\r
private String title;\r
\r
/**\r
* Gets the type of the hyperlink action.\r
- * Must be a <code>ACTION_*</code> constant defined in <code>InteractiveInfoAtom</code>\r
+ * Must be a <code>LINK_*</code> constant</code>\r
*\r
* @return the hyperlink URL\r
* @see InteractiveInfoAtom\r
return type;\r
}\r
\r
+ public void setType(int val) {\r
+ type = val;\r
+ switch(type){\r
+ case LINK_NEXTSLIDE:\r
+ title = "NEXT";\r
+ address = "1,-1,NEXT";\r
+ break;\r
+ case LINK_PREVIOUSSLIDE:\r
+ title = "PREV";\r
+ address = "1,-1,PREV";\r
+ break;\r
+ case LINK_FIRSTSLIDE:\r
+ title = "FIRST";\r
+ address = "1,-1,FIRST";\r
+ break;\r
+ case LINK_LASTSLIDE:\r
+ title = "LAST";\r
+ address = "1,-1,LAST";\r
+ break;\r
+ default:\r
+ title = "";\r
+ address = "";\r
+ break;\r
+ }\r
+ }\r
+\r
/**\r
* Gets the hyperlink URL\r
*\r
return address;\r
}\r
\r
+ public void setAddress(String str) {\r
+ address = str;\r
+ }\r
+\r
+ public int getId() {\r
+ return id;\r
+ }\r
+\r
+ public void setId(int id) {\r
+ this.id = id;\r
+ }\r
+\r
/**\r
* Gets the hyperlink user-friendly title (if different from URL)\r
*\r
return title;\r
}\r
\r
+ public void setTitle(String str) {\r
+ title = str;\r
+ }\r
+\r
/**\r
* Gets the beginning character position\r
*\r
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hslf.record.ColorSchemeAtom;
import org.apache.poi.hslf.record.Record;
+import org.apache.poi.hslf.record.InteractiveInfo;
+import org.apache.poi.hslf.record.InteractiveInfoAtom;
import org.apache.poi.hslf.exceptions.HSLFException;
import java.awt.*;
_clientData.setRemainingData(out.toByteArray());
}
}
+
+ public void setHyperlink(Hyperlink link){
+ if(link.getId() == -1){
+ throw new HSLFException("You must call SlideShow.addHyperlink(Hyperlink link) first");
+ }
+
+ EscherClientDataRecord cldata = new EscherClientDataRecord();
+ cldata.setOptions((short)0xF);
+ getSpContainer().getChildRecords().add(cldata);
+
+ InteractiveInfo info = new InteractiveInfo();
+ InteractiveInfoAtom infoAtom = info.getInteractiveInfoAtom();
+
+ switch(link.getType()){
+ case Hyperlink.LINK_FIRSTSLIDE:
+ 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());
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ try {
+ info.writeOut(out);
+ } catch(Exception e){
+ throw new HSLFException(e);
+ }
+ cldata.setRemainingData(out.toByteArray());
+
+ }
+
}
* TODO: Figure out if we should always set both
*/
public void setLinkURL(String url) {
- linkDetailsA.setText(url);
-
- // linkDetailsB isn't present in all PPT versions
if(linkDetailsB != null) {
linkDetailsB.setText(url);
}
}
-
+ public void setLinkTitle(String title) {
+ if(linkDetailsA != null) {
+ linkDetailsA.setText(title);
+ }
+ }
+
/**
* Get the link details (field A)
*/
* @return 0-based index of the control
*/
public int addControl(String name, String progId) {
- ExObjList lst = _documentRecord.getExObjList();
+ ExObjList lst = (ExObjList)_documentRecord.findFirstOfType(RecordTypes.ExObjList.typeID);
if (lst == null) {
lst = new ExObjList();
_documentRecord.addChildAfter(lst, _documentRecord.getDocumentAtom());
return objectId;
}
+
+ /**
+ * Add a hyperlink to this presentation
+ *
+ * @return 0-based index of the hyperlink
+ */
+ public int addHyperlink(Hyperlink link) {
+ ExObjList lst = (ExObjList)_documentRecord.findFirstOfType(RecordTypes.ExObjList.typeID);
+ if (lst == null) {
+ lst = new ExObjList();
+ _documentRecord.addChildAfter(lst, _documentRecord.getDocumentAtom());
+ }
+ ExObjListAtom objAtom = lst.getExObjListAtom();
+ //increment the object ID seed
+ int objectId = (int) objAtom.getObjectIDSeed() + 1;
+ objAtom.setObjectIDSeed(objectId);
+
+ ExHyperlink ctrl = new ExHyperlink();
+ ExHyperlinkAtom obj = ctrl.getExHyperlinkAtom();
+ obj.setNumber(objectId);
+ ctrl.setLinkURL(link.getAddress());
+ ctrl.setLinkTitle(link.getTitle());
+ lst.addChildAfter(ctrl, objAtom);
+ link.setId(objectId);
+
+ return objectId;
+ }
}