You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PDFLaunch.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.pdf;
  19. /**
  20. * This class represents the /Launch action.
  21. */
  22. public class PDFLaunch extends PDFAction {
  23. private PDFReference externalFileSpec;
  24. /**
  25. * Creates a new /Launch action.
  26. * @param fileSpec the file specification to launch
  27. */
  28. public PDFLaunch(PDFFileSpec fileSpec) {
  29. this(fileSpec.makeReference());
  30. }
  31. /**
  32. * Creates a new /Launch action.
  33. * @param fileSpec a reference to the file specification
  34. */
  35. public PDFLaunch(PDFReference fileSpec) {
  36. PDFObject fs = fileSpec.getObject();
  37. if (fs != null) {
  38. assert fs instanceof PDFFileSpec;
  39. }
  40. this.externalFileSpec = fileSpec;
  41. }
  42. /** {@inheritDoc} */
  43. public String getAction() {
  44. return this.referencePDF();
  45. }
  46. /** {@inheritDoc} */
  47. public String toPDFString() {
  48. StringBuffer sb = new StringBuffer(64);
  49. sb.append("<<\n/S /Launch\n/F ");
  50. sb.append(externalFileSpec.toString());
  51. sb.append("\n>>");
  52. return sb.toString();
  53. }
  54. /** {@inheritDoc} */
  55. protected boolean contentEquals(PDFObject obj) {
  56. if (this == obj) {
  57. return true;
  58. }
  59. if (obj == null || !(obj instanceof PDFLaunch)) {
  60. return false;
  61. }
  62. PDFLaunch launch = (PDFLaunch) obj;
  63. if (!launch.externalFileSpec.toString().equals(externalFileSpec.toString())) {
  64. return false;
  65. }
  66. return true;
  67. }
  68. }