Lines 1082-1097
Link Here
|
1082 |
} else if (targetLo.endsWith(".pdf")) { |
1082 |
} else if (targetLo.endsWith(".pdf")) { |
1083 |
// Bare PDF file name? |
1083 |
// Bare PDF file name? |
1084 |
return getGoToPDFAction(target, null, -1, newWindow); |
1084 |
return getGoToPDFAction(target, null, -1, newWindow); |
1085 |
} else if ((index = targetLo.indexOf(".pdf#page=")) > 0) { // CSOK: InnerAssignment |
1085 |
} else if ((index = targetLo.indexOf(".pdf#")) > 0) { // CSOK: InnerAssignment |
1086 |
// PDF file + page? |
|
|
1087 |
String filename = target.substring(0, index + 4); |
1086 |
String filename = target.substring(0, index + 4); |
1088 |
int page = Integer.parseInt(target.substring(index + 10)); |
1087 |
String tmp = targetLo.substring(index + 5, index + 10); |
1089 |
return getGoToPDFAction(filename, null, page, newWindow); |
1088 |
int page = -1; |
1090 |
} else if ((index = targetLo.indexOf(".pdf#dest=")) > 0) { // CSOK: InnerAssignment |
1089 |
String dest = null; |
1091 |
// PDF file + destination? |
1090 |
if ("page=".equals(tmp)) { |
1092 |
String filename = target.substring(0, index + 4); |
1091 |
// PDF file + page? |
1093 |
String dest = target.substring(index + 10); |
1092 |
page = Integer.parseInt(target.substring(index + 10)); |
1094 |
return getGoToPDFAction(filename, dest, -1, newWindow); |
1093 |
} else { |
|
|
1094 |
// PDF file + named destination? |
1095 |
dest = target.substring(index + ("dest=".equals(tmp) ? 10 : 5)); |
1096 |
} |
1097 |
return getGoToPDFAction(filename, dest, page, newWindow); |
1098 |
} else if (target.startsWith("#")) { |
1099 |
//actually an _internal_ named destination |
1100 |
return getPDFGoTo(target.substring(1), true, null); |
1095 |
} else { |
1101 |
} else { |
1096 |
// None of the above? Default to URI: |
1102 |
// None of the above? Default to URI: |
1097 |
return new PDFUri(target); |
1103 |
return new PDFUri(target); |
Lines 1159-1183
Link Here
|
1159 |
* @return the GoTo's object reference |
1165 |
* @return the GoTo's object reference |
1160 |
*/ |
1166 |
*/ |
1161 |
public String getGoToReference(String pdfPageRef, float yoffset) { |
1167 |
public String getGoToReference(String pdfPageRef, float yoffset) { |
1162 |
return getPDFGoTo(pdfPageRef, new Point2D.Float(0.0f, yoffset)).referencePDF(); |
1168 |
return getPDFGoTo(pdfPageRef, false, new Point2D.Float(0.0f, yoffset)).referencePDF(); |
1163 |
} |
1169 |
} |
1164 |
|
1170 |
|
1165 |
/** |
1171 |
/** |
1166 |
* Finds and returns a PDFGoTo to the given page and position. |
1172 |
* Finds and returns a PDFGoTo to the given page and position. |
1167 |
* Creates the PDFGoTo if not found. |
1173 |
* Creates the PDFGoTo if not found. |
1168 |
* |
1174 |
* |
1169 |
* @param pdfPageRef the PDF page reference |
1175 |
* @param pdfDestinationRef the PDF destination reference |
1170 |
* @param position the (X,Y) position in points |
1176 |
* @param isNamedDestination indicates whether the destination reference is a |
|
|
1177 |
* named destination (if {@code true}, the position |
1178 |
* parameter is ignored) |
1179 |
* @param position the (X,Y) position in points |
1171 |
* |
1180 |
* |
1172 |
* @return the new or existing PDFGoTo object |
1181 |
* @return the new or existing PDFGoTo object |
1173 |
*/ |
1182 |
*/ |
1174 |
public PDFGoTo getPDFGoTo(String pdfPageRef, Point2D position) { |
1183 |
public PDFGoTo getPDFGoTo(String pdfDestinationRef, boolean isNamedDestination, Point2D position) { |
1175 |
getDocument().getProfile().verifyActionAllowed(); |
1184 |
getDocument().getProfile().verifyActionAllowed(); |
1176 |
PDFGoTo gt = new PDFGoTo(pdfPageRef, position); |
1185 |
PDFGoTo gt; |
|
|
1186 |
if (isNamedDestination) { |
1187 |
gt = new PDFGoTo(pdfDestinationRef, isNamedDestination); |
1188 |
} else { |
1189 |
gt = new PDFGoTo(pdfDestinationRef, position); |
1190 |
} |
1177 |
PDFGoTo oldgt = getDocument().findGoTo(gt); |
1191 |
PDFGoTo oldgt = getDocument().findGoTo(gt); |
1178 |
if (oldgt == null) { |
1192 |
if (oldgt == null) { |
1179 |
getDocument().assignObjectNumber(gt); |
1193 |
getDocument().registerObject(gt); |
1180 |
getDocument().addTrailerObject(gt); |
|
|
1181 |
} else { |
1194 |
} else { |
1182 |
gt = oldgt; |
1195 |
gt = oldgt; |
1183 |
} |
1196 |
} |