diff options
Diffstat (limited to 'src/java/org/apache')
-rw-r--r-- | src/java/org/apache/fop/area/BookmarkData.java | 44 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/Constants.java | 3 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/FOElementMapping.java | 7 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/PropertySets.java | 10 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java | 7 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java (renamed from src/java/org/apache/fop/fo/extensions/Outline.java) | 59 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java | 10 | ||||
-rw-r--r-- | src/java/org/apache/fop/render/pdf/PDFRenderer.java | 4 |
8 files changed, 82 insertions, 62 deletions
diff --git a/src/java/org/apache/fop/area/BookmarkData.java b/src/java/org/apache/fop/area/BookmarkData.java index 23fd92583..3659d1fb1 100644 --- a/src/java/org/apache/fop/area/BookmarkData.java +++ b/src/java/org/apache/fop/area/BookmarkData.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.HashMap; import org.apache.fop.fo.pagination.bookmarks.BookmarkTree; -import org.apache.fop.fo.extensions.Outline; +import org.apache.fop.fo.pagination.bookmarks.Bookmark; /** * An instance of this class is either a PDF bookmark-tree and @@ -33,8 +33,8 @@ import org.apache.fop.fo.extensions.Outline; public class BookmarkData extends OffDocumentItem implements Resolvable { private ArrayList subData = new ArrayList(); - // bookmark label - private String label = null; + // bookmark-title for this bookmark + private String bookmarkTitle = null; // ID Reference for this bookmark private String idRef; @@ -57,8 +57,8 @@ public class BookmarkData extends OffDocumentItem implements Resolvable { whenToProcess = END_OF_DOC; for (int count = 0; count < bookmarkTree.getBookmarks().size(); count++) { - Outline out = (Outline)(bookmarkTree.getBookmarks()).get(count); - addSubData(createBookmarkData(out)); + Bookmark bkmk = (Bookmark)(bookmarkTree.getBookmarks()).get(count); + addSubData(createBookmarkData(bkmk)); } } @@ -100,21 +100,21 @@ public class BookmarkData extends OffDocumentItem implements Resolvable { } /** - * Set the label for this bookmark. + * Set the title for this bookmark. * - * @param l the string label + * @param title the bookmark title */ - public void setLabel(String l) { - label = l; + public void setBookmarkTitle(String title) { + bookmarkTitle = title; } /** - * Get the label for this bookmark object. + * Get the title for this bookmark object. * - * @return the label string + * @return the bookmark title */ - public String getLabel() { - return label; + public String getBookmarkTitle() { + return bookmarkTitle; } /** @@ -195,20 +195,20 @@ public class BookmarkData extends OffDocumentItem implements Resolvable { } /** - * Create and return the bookmark data for this outline. + * Create and return the bookmark data for this bookmark * This creates a bookmark data with the destination - * and adds all the data from child outlines. + * and adds all the data from child bookmarks * - * @param outline the Outline object for which a bookmark entry should be + * @param bookmark the Bookmark object for which a bookmark entry should be * created * @return the new bookmark data */ - private BookmarkData createBookmarkData(Outline outline) { - BookmarkData data = new BookmarkData(outline.getInternalDestination()); - data.setLabel(outline.getLabel()); - for (int count = 0; count < outline.getOutlines().size(); count++) { - Outline out = (Outline)(outline.getOutlines()).get(count); - data.addSubData(createBookmarkData(out)); + private BookmarkData createBookmarkData(Bookmark bookmark) { + BookmarkData data = new BookmarkData(bookmark.getInternalDestination()); + data.setBookmarkTitle(bookmark.getBookmarkTitle()); + for (int count = 0; count < bookmark.getChildBookmarks().size(); count++) { + Bookmark bkmk = (Bookmark)(bookmark.getChildBookmarks()).get(count); + data.addSubData(createBookmarkData(bkmk)); } return data; } diff --git a/src/java/org/apache/fop/fo/Constants.java b/src/java/org/apache/fop/fo/Constants.java index 7f1d40521..192ad5560 100644 --- a/src/java/org/apache/fop/fo/Constants.java +++ b/src/java/org/apache/fop/fo/Constants.java @@ -114,7 +114,8 @@ public interface Constants { int FO_TITLE = 55; int FO_WRAPPER = 56; int FO_BOOKMARK_TREE = 57; - int FRM_OBJ_COUNT = 57; + int FO_BOOKMARK = 58; + int FRM_OBJ_COUNT = 58; // Masks int COMPOUND_SHIFT = 9; diff --git a/src/java/org/apache/fop/fo/FOElementMapping.java b/src/java/org/apache/fop/fo/FOElementMapping.java index 760adeb33..1fa266778 100644 --- a/src/java/org/apache/fop/fo/FOElementMapping.java +++ b/src/java/org/apache/fop/fo/FOElementMapping.java @@ -46,6 +46,7 @@ public class FOElementMapping extends ElementMapping { foObjs.put("declarations", new DeclarationsMaker()); foObjs.put("color-profile", new ColorProfileMaker()); foObjs.put("bookmark-tree", new BookmarkTreeMaker()); + foObjs.put("bookmark", new BookmarkMaker()); foObjs.put("page-sequence", new PageSequenceMaker()); foObjs.put("layout-master-set", new LayoutMasterSetMaker()); foObjs.put("page-sequence-master", @@ -152,6 +153,12 @@ public class FOElementMapping extends ElementMapping { } } + static class BookmarkMaker extends ElementMapping.Maker { + public FONode make(FONode parent) { + return new org.apache.fop.fo.pagination.bookmarks.Bookmark(parent); + } + } + static class PageSequenceMaker extends ElementMapping.Maker { public FONode make(FONode parent) { return new org.apache.fop.fo.pagination.PageSequence(parent); diff --git a/src/java/org/apache/fop/fo/PropertySets.java b/src/java/org/apache/fop/fo/PropertySets.java index 64e50fd13..418d23bac 100644 --- a/src/java/org/apache/fop/fo/PropertySets.java +++ b/src/java/org/apache/fop/fo/PropertySets.java @@ -202,7 +202,15 @@ public class PropertySets { elem.addProperty(Constants.PR_RENDERING_INTENT); elem = elements[Constants.FO_BOOKMARK_TREE]; -// elem.addContent(Constants.FO_BOOKMARK); + elem.addContent(Constants.FO_BOOKMARK); + + elem = elements[Constants.FO_BOOKMARK]; +// elem.addContent(Constants.FO_BOOKMARK_TITLE); + elem.addContent(Constants.FO_BOOKMARK); + elem.addProperties(CommonAccessibilityProperties); + elem.addProperty(Constants.PR_EXTERNAL_DESTINATION); + elem.addProperty(Constants.PR_INTERNAL_DESTINATION); + elem.addProperty(Constants.PR_STARTING_STATE); elem = elements[Constants.FO_PAGE_SEQUENCE]; elem.addProperty(Constants.PR_COUNTRY); diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java index 16e30ef8a..3e0067d12 100644 --- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java @@ -44,17 +44,10 @@ public class ExtensionElementMapping extends ElementMapping { protected void initialize() { if (foObjs == null) { foObjs = new HashMap(); - foObjs.put("outline", new O()); foObjs.put("label", new L()); } } - static class O extends ElementMapping.Maker { - public FONode make(FONode parent) { - return new Outline(parent); - } - } - static class L extends ElementMapping.Maker { public FONode make(FONode parent) { return new Label(parent); diff --git a/src/java/org/apache/fop/fo/extensions/Outline.java b/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java index a7df6327e..4ba55d317 100644 --- a/src/java/org/apache/fop/fo/extensions/Outline.java +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java @@ -14,9 +14,9 @@ * limitations under the License. */ -/* $Id$ */ +/* $Id $ */ -package org.apache.fop.fo.extensions; +package org.apache.fop.fo.pagination.bookmarks; import java.util.ArrayList; @@ -24,35 +24,39 @@ 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 outline object for the pdf bookmark extension. - * The outline element contains a label and optionally more outlines. + * 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 Outline extends ExtensionObj { - private Label label; - private ArrayList outlines = new ArrayList(); +public class Bookmark extends FObj { + private Label bookmarkTitle; + private ArrayList childBookmarks = new ArrayList(); private String internalDestination; private String externalDestination; /** - * Create a new outline object. + * Create a new bookmark object. * * @param parent the parent fo node */ - public Outline(FONode parent) { + public Bookmark(FONode parent) { super(parent); } /** - * The attributes on the outline object are the internal and external + * 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 @@ -62,11 +66,11 @@ public class Outline extends ExtensionObj { externalDestination = attlist.getValue("external-destination"); if (externalDestination != null && !externalDestination.equals("")) { - getLogger().warn("fox:outline external-destination not supported currently."); + getLogger().warn("fo:bookmark external-destination not supported currently."); } if (internalDestination == null || internalDestination.equals("")) { - getLogger().warn("fox:outline requires an internal-destination."); + getLogger().warn("fo:bookmark requires an internal-destination."); } } @@ -76,20 +80,19 @@ public class Outline extends ExtensionObj { */ protected void addChildNode(FONode obj) { if (obj instanceof Label) { - label = (Label)obj; - } else if (obj instanceof Outline) { - outlines.add(obj); + bookmarkTitle = (Label)obj; + } else if (obj instanceof Bookmark) { + childBookmarks.add(obj); } } /** - * Get the label string. - * This gets the label string from the child label element. + * Get the bookmark title for this bookmark * - * @return the label string or empty if not found + * @return the bookmark title string or an empty string if not found */ - public String getLabel() { - return label == null ? "" : label.toString(); + public String getBookmarkTitle() { + return bookmarkTitle == null ? "" : bookmarkTitle.toString(); } public String getInternalDestination() { @@ -100,11 +103,21 @@ public class Outline extends ExtensionObj { return externalDestination; } - public ArrayList getOutlines() { - return outlines; + public ArrayList getChildBookmarks() { + return childBookmarks; } + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { - return "(http://xml.apache.org/fop/extensions) outline"; + 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); } } diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index ac8450881..834333d77 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -311,10 +311,10 @@ public class PDFRenderer extends PrintRenderer { if (parentBookmarkItem == null) { PDFOutline outlineRoot = pdfDoc.getOutlineRoot(); pdfOutline = pdfDoc.getFactory().makeOutline(outlineRoot, - bookmarkItem.getLabel(), intDest, yoffset); + bookmarkItem.getBookmarkTitle(), intDest, yoffset); } else { pdfOutline = pdfDoc.getFactory().makeOutline(parentBookmarkItem, - bookmarkItem.getLabel(), intDest, yoffset); + bookmarkItem.getBookmarkTitle(), intDest, yoffset); } } |