diff options
author | Glen Mazza <gmazza@apache.org> | 2005-01-04 00:21:47 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2005-01-04 00:21:47 +0000 |
commit | 0f57433994428964c64cbb377c018b6324ecc384 (patch) | |
tree | 2ebacfc9c7369490fdc6f187e139531d4ff613c7 /src/java/org/apache/fop/fo/pagination/bookmarks | |
parent | 9a6bb29965e0e6daa71f3c27641af9104f5af433 (diff) | |
download | xmlgraphics-fop-0f57433994428964c64cbb377c018b6324ecc384.tar.gz xmlgraphics-fop-0f57433994428964c64cbb377c018b6324ecc384.zip |
PR:
Obtained from:
Submitted by:
Reviewed by:
Converted fox:outline to fo:bookmark. fox:label/fo:bookmark-title still to
be done.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198221 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/pagination/bookmarks')
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java | 123 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java | 10 |
2 files changed, 127 insertions, 6 deletions
diff --git a/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java b/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java new file mode 100644 index 000000000..4ba55d317 --- /dev/null +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java @@ -0,0 +1,123 @@ +/* + * Copyright 1999-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id $ */ + +package org.apache.fop.fo.pagination.bookmarks; + +import java.util.ArrayList; + +import org.xml.sax.Attributes; +import org.xml.sax.Locator; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.PropertyList; +import org.apache.fop.fo.extensions.Label; + + +/** + * The fo:bookmark formatting object, first introduced in the + * XSL 1.1 WD. Prototype version only, subject to change as + * XSL 1.1 WD evolves. + */ +public class Bookmark extends FObj { + private Label bookmarkTitle; + private ArrayList childBookmarks = new ArrayList(); + + private String internalDestination; + private String externalDestination; + + /** + * Create a new bookmark object. + * + * @param parent the parent fo node + */ + public Bookmark(FONode parent) { + super(parent); + } + + /** + * The attributes on the bookmark object are the internal and external + * destination. One of these is required. + * + * @see org.apache.fop.fo.FObj#processNode + * @todo to include all properties of fo:bookmark + */ + public void processNode(String elementName, Locator locator, + Attributes attlist, PropertyList propertyList) throws FOPException + { + internalDestination = + attlist.getValue("internal-destination"); + externalDestination = + attlist.getValue("external-destination"); + if (externalDestination != null && !externalDestination.equals("")) { + getLogger().warn("fo:bookmark external-destination not supported currently."); + } + + if (internalDestination == null || internalDestination.equals("")) { + getLogger().warn("fo:bookmark requires an internal-destination."); + } + + } + + /** + * @see org.apache.fop.fo.FONode#addChildNode(FONode) + */ + protected void addChildNode(FONode obj) { + if (obj instanceof Label) { + bookmarkTitle = (Label)obj; + } else if (obj instanceof Bookmark) { + childBookmarks.add(obj); + } + } + + /** + * Get the bookmark title for this bookmark + * + * @return the bookmark title string or an empty string if not found + */ + public String getBookmarkTitle() { + return bookmarkTitle == null ? "" : bookmarkTitle.toString(); + } + + public String getInternalDestination() { + return internalDestination; + } + + public String getExternalDestination() { + return externalDestination; + } + + public ArrayList getChildBookmarks() { + return childBookmarks; + } + + /** + * @see org.apache.fop.fo.FObj#getName() + */ + public String getName() { + return "fo:bookmark"; + } + + /** + * @see org.apache.fop.fo.FObj#getNameId() + */ + public int getNameId() { + return FO_BOOKMARK; + } +} diff --git a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java index 43daeda05..b5af4efcf 100644 --- a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java @@ -24,8 +24,6 @@ import java.util.ArrayList; import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.extensions.ExtensionElementMapping; -import org.apache.fop.fo.extensions.Outline; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; @@ -52,7 +50,7 @@ public class BookmarkTree extends FObj { * @see org.apache.fop.fo.FONode#addChildNode(FONode) */ protected void addChildNode(FONode obj) { - if (obj instanceof Outline) { + if (obj instanceof Bookmark) { bookmarks.add(obj); } } @@ -62,7 +60,7 @@ public class BookmarkTree extends FObj { */ protected void endOfNode() throws FOPException { if (bookmarks == null) { - missingChildElementError("(fox:outline+)"); + missingChildElementError("(fo:bookmark+)"); } ((Root) parent).setBookmarkTree(this); } @@ -73,8 +71,8 @@ public class BookmarkTree extends FObj { */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws ValidationException { - if (!(nsURI == ExtensionElementMapping.URI && - localName.equals("outline"))) { + if (!(nsURI == FO_URI && + localName.equals("bookmark"))) { invalidChildError(loc, nsURI, localName); } } |