aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2007-04-03 10:13:20 +0000
committerNick Burch <nick@apache.org>2007-04-03 10:13:20 +0000
commited06515faedb7f01bc89a4e7c33d774fd3ce9051 (patch)
treeb51ce885765590dfd53fb886c58bb29203191c47 /src
parent0a3756d28d5cb6fc88d7189d41b2c01d83d5981b (diff)
downloadpoi-ed06515faedb7f01bc89a4e7c33d774fd3ce9051.tar.gz
poi-ed06515faedb7f01bc89a4e7c33d774fd3ce9051.zip
It seems that some PPT files only have linkAtom + linkDetailsA for their ExHyperlink, and miss the linkDetailsB. For those files, do the right thing
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@525127 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java b/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java
index b27a396171..dd27e5bf44 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java
@@ -33,7 +33,6 @@ public class ExHyperlink extends RecordContainer {
private ExHyperlinkAtom linkAtom;
private CString linkDetailsA;
private CString linkDetailsB;
- private Comment2000Atom commentAtom;
/**
* Returns the ExHyperlinkAtom of this link
@@ -55,7 +54,11 @@ public class ExHyperlink extends RecordContainer {
*/
public void setLinkURL(String url) {
linkDetailsA.setText(url);
- linkDetailsB.setText(url);
+
+ // linkDetailsB isn't present in all PPT versions
+ if(linkDetailsB != null) {
+ linkDetailsB.setText(url);
+ }
}
/**
@@ -90,6 +93,11 @@ public class ExHyperlink extends RecordContainer {
* methods.
*/
private void findInterestingChildren() {
+ // We need to have 2 children, ideally 3, and sometimes have more
+ if(_children.length < 2) {
+ throw new IllegalStateException("We need at least two child records, but we only had " + _children.length);
+ }
+
// First child should be the ExHyperlinkAtom
if(_children[0] instanceof ExHyperlinkAtom) {
linkAtom = (ExHyperlinkAtom)_children[0];
@@ -103,11 +111,16 @@ public class ExHyperlink extends RecordContainer {
} else {
throw new IllegalStateException("Second child record wasn't a CString, was of type " + _children[1].getRecordType());
}
- // Third child should be the second link details
- if(_children[2] instanceof CString) {
- linkDetailsB = (CString)_children[2];
+
+ // Third child, if it exists, should be the second link details
+ if(_children.length >= 3) {
+ if(_children[2] instanceof CString) {
+ linkDetailsB = (CString)_children[2];
+ } else {
+ throw new IllegalStateException("Third child record wasn't a CString, was of type " + _children[2].getRecordType());
+ }
} else {
- throw new IllegalStateException("Third child record wasn't a CString, was of type " + _children[2].getRecordType());
+ // Should be fine to not have one
}
}