1 17 18 19 20 package org.apache.fop.fo.pagination.bookmarks; 21 22 import java.util.ArrayList ; 23 import org.xml.sax.Locator ; 24 import org.apache.fop.apps.FOPException; 25 import org.apache.fop.fo.FObj; 26 import org.apache.fop.fo.FONode; 27 import org.apache.fop.fo.PropertyList; 28 import org.apache.fop.fo.ValidationException; 29 import org.apache.fop.fo.properties.CommonAccessibility; 30 31 32 37 public class Bookmark extends FObj { 38 private BookmarkTitle bookmarkTitle; 39 private ArrayList childBookmarks = new ArrayList (); 40 41 private CommonAccessibility commonAccessibility; 43 private String internalDestination; 44 private String externalDestination; 45 private boolean bShow = true; 47 52 public Bookmark(FONode parent) { 53 super(parent); 54 } 55 56 59 public void bind(PropertyList pList) throws FOPException { 60 commonAccessibility = pList.getAccessibilityProps(); 61 externalDestination = pList.get(PR_EXTERNAL_DESTINATION).getString(); 62 internalDestination = pList.get(PR_INTERNAL_DESTINATION).getString(); 63 bShow = (pList.get(PR_STARTING_STATE).getEnum() == EN_SHOW); 64 65 if (internalDestination.length() > 0) { 67 externalDestination = null; 68 } else if (externalDestination.length() == 0) { 69 attributeError("Missing attribute: Either external-destination or " + 71 "internal-destination must be specified."); 72 } else { 73 attributeWarning("external-destination property not currently supported"); 74 } 75 } 76 77 81 protected void validateChildNode(Locator loc, String nsURI, String localName) 82 throws ValidationException { 83 if (FO_URI.equals(nsURI) && localName.equals("bookmark-title")) { 84 if (bookmarkTitle != null) { 85 tooManyNodesError(loc, "fo:bookmark-title"); 86 } 87 } else if (FO_URI.equals(nsURI) && localName.equals("bookmark")) { 88 if (bookmarkTitle == null) { 89 nodesOutOfOrderError(loc, "fo:bookmark-title", "fo:bookmark"); 90 } 91 } else { 92 invalidChildError(loc, nsURI, localName); 93 } 94 } 95 96 99 protected void endOfNode() throws FOPException { 100 if (bookmarkTitle == null) { 101 missingChildElementError("(bookmark-title, bookmark*)"); 102 } 103 } 104 105 108 protected void addChildNode(FONode obj) { 109 if (obj instanceof BookmarkTitle) { 110 bookmarkTitle = (BookmarkTitle)obj; 111 } else if (obj instanceof Bookmark) { 112 childBookmarks.add(obj); 113 } 114 } 115 116 121 public String getBookmarkTitle() { 122 return bookmarkTitle == null ? "" : bookmarkTitle.getTitle(); 123 } 124 125 public String getInternalDestination() { 126 return internalDestination; 127 } 128 129 public String getExternalDestination() { 130 return externalDestination; 131 } 132 133 139 public boolean showChildItems() { 140 return bShow; 141 } 142 143 public ArrayList getChildBookmarks() { 144 return childBookmarks; 145 } 146 147 148 public String getLocalName() { 149 return "bookmark"; 150 } 151 152 155 public int getNameId() { 156 return FO_BOOKMARK; 157 } 158 } 159 | Popular Tags |