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.

DestinationData.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.area;
  19. import java.util.List;
  20. import org.apache.fop.fo.extensions.destination.Destination;
  21. /**
  22. * An instance of this class is named destination from fox:destination
  23. */
  24. public class DestinationData extends AbstractOffDocumentItem implements Resolvable {
  25. // ID Reference for this bookmark
  26. private String idRef;
  27. // String Array to satisfy getIDRefs method
  28. private String[] idRefs;
  29. // PageViewport that the idRef item refers to
  30. private PageViewport pageRef;
  31. /**
  32. * Create a new pdf destination data object.
  33. * This is used by the destination to create a data object
  34. * with a idref. During processing, this idref will be
  35. * subsequently resolved to a particular PageViewport.
  36. *
  37. * @param destination the fo:bookmark object
  38. */
  39. public DestinationData(Destination destination) {
  40. this(destination.getInternalDestination());
  41. }
  42. /**
  43. * Create a new named destination.
  44. * @param idRef the id reference of the destination
  45. */
  46. public DestinationData(String idRef) {
  47. this.idRef = idRef;
  48. this.idRefs = new String[] {idRef};
  49. }
  50. /**
  51. * Get the idref for this destination
  52. *
  53. * @return the idref for the destination
  54. */
  55. public String getIDRef() {
  56. return idRef;
  57. }
  58. /** {@inheritDoc} */
  59. public String[] getIDRefs() {
  60. return idRefs;
  61. }
  62. /**
  63. * Get the PageViewport object that this destination refers to
  64. *
  65. * @return the PageViewport that this destination points to
  66. */
  67. public PageViewport getPageViewport() {
  68. return pageRef;
  69. }
  70. /**
  71. * Check if this resolvable object has been resolved.
  72. * For now, just return true.
  73. * To do: Find a way to determine whether the destination has been resolved.
  74. *
  75. * @return true if this object has been resolved
  76. */
  77. public boolean isResolved() {
  78. return true;
  79. }
  80. /**
  81. * Resolves the idref of this object by getting the PageViewport
  82. * object that corresponds to the IDRef
  83. *
  84. * {@inheritDoc}
  85. * TODO check to make sure it works if multiple bookmark-items
  86. * have the same idref
  87. */
  88. public void resolveIDRef(String id, List<PageViewport> pages) {
  89. pageRef = pages.get(0);
  90. // TODO get rect area of id on page
  91. }
  92. /** {@inheritDoc} */
  93. public String getName() {
  94. return "Destination";
  95. }
  96. }