gmazza 2005/01/12 16:06:25 Modified: src/java/org/apache/fop/area BookmarkData.java src/java/org/apache/fop/fo/pagination/bookmarks Bookmark.java src/java/org/apache/fop/pdf PDFDocument.java PDFFactory.java PDFOutline.java src/java/org/apache/fop/render/pdf PDFRenderer.java Log: "starting-state" property implemented for fo:bookmark. Revision Changes Path 1.11 +21 -15 xml-fop/src/java/org/apache/fop/area/BookmarkData.java Index: BookmarkData.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/BookmarkData.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- BookmarkData.java 4 Jan 2005 00:21:46 -0000 1.10 +++ BookmarkData.java 13 Jan 2005 00:06:25 -0000 1.11 @@ -33,9 +33,12 @@ public class BookmarkData extends OffDocumentItem implements Resolvable { private ArrayList subData = new ArrayList(); - // bookmark-title for this bookmark + // bookmark-title for this fo:bookmark private String bookmarkTitle = null; + // indicator of whether to initially display/hide child bookmarks of this object + private boolean bShow = true; + // ID Reference for this bookmark private String idRef; @@ -55,6 +58,8 @@ public BookmarkData(BookmarkTree bookmarkTree) { idRef = null; whenToProcess = END_OF_DOC; + // top level defined in Rec to show all child bookmarks + bShow = true; for (int count = 0; count < bookmarkTree.getBookmarks().size(); count++) { Bookmark bkmk = (Bookmark)(bookmarkTree.getBookmarks()).get(count); @@ -68,10 +73,12 @@ * with a idref. During processing, this idref will be * subsequently resolved to a particular PageViewport. * - * @param idref the id reference + * @param bookmark the fo:bookmark object */ - public BookmarkData(String idref) { - this.idRef = idref; + public BookmarkData(Bookmark bookmark) { + bookmarkTitle = bookmark.getBookmarkTitle(); + bShow = bookmark.showChildItems(); + this.idRef = bookmark.getInternalDestination(); unresolvedIDRefs.put(idRef, this); } @@ -100,21 +107,21 @@ } /** - * Set the title for this bookmark. + * Get the title for this bookmark object. * - * @param title the bookmark title + * @return the bookmark title */ - public void setBookmarkTitle(String title) { - bookmarkTitle = title; + public String getBookmarkTitle() { + return bookmarkTitle; } /** - * Get the title for this bookmark object. + * Indicator of whether to initially display child bookmarks. * - * @return the bookmark title + * @return true to initially display child bookmarks, false otherwise */ - public String getBookmarkTitle() { - return bookmarkTitle; + public boolean showChildItems() { + return bShow; } /** @@ -204,8 +211,7 @@ * @return the new bookmark data */ private BookmarkData createBookmarkData(Bookmark bookmark) { - BookmarkData data = new BookmarkData(bookmark.getInternalDestination()); - data.setBookmarkTitle(bookmark.getBookmarkTitle()); + BookmarkData data = new BookmarkData(bookmark); for (int count = 0; count < bookmark.getChildBookmarks().size(); count++) { Bookmark bkmk = (Bookmark)(bookmark.getChildBookmarks()).get(count); data.addSubData(createBookmarkData(bkmk)); 1.5 +10 -4 xml-fop/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java Index: Bookmark.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Bookmark.java 11 Jan 2005 00:07:52 -0000 1.4 +++ Bookmark.java 13 Jan 2005 00:06:25 -0000 1.5 @@ -42,7 +42,7 @@ private CommonAccessibility commonAccessibility; private String internalDestination; private String externalDestination; - private int startingState; + private boolean bShow = true; // from starting-state property /** * Create a new bookmark object. @@ -60,7 +60,7 @@ commonAccessibility = pList.getAccessibilityProps(); externalDestination = pList.get(PR_EXTERNAL_DESTINATION).getString(); internalDestination = pList.get(PR_INTERNAL_DESTINATION).getString(); - // startingState = pList.get(PR_STARTING_STATE); + bShow = (pList.get(PR_STARTING_STATE).getEnum() == EN_SHOW); // per spec, internal takes precedence if both specified if (internalDestination.length() > 0) { @@ -130,8 +130,14 @@ return externalDestination; } - public int getStartingState() { - return startingState; + /** + * Determines if this fo:bookmark's subitems should be initially displayed + * or hidden, based on the starting-state property set on this FO. + * + * @return true if this bookmark's starting-state is "show", false if "hide". + */ + public boolean showChildItems() { + return bShow; } public ArrayList getChildBookmarks() { 1.10 +1 -1 xml-fop/src/java/org/apache/fop/pdf/PDFDocument.java Index: PDFDocument.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFDocument.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- PDFDocument.java 2 Apr 2004 09:14:51 -0000 1.9 +++ PDFDocument.java 13 Jan 2005 00:06:25 -0000 1.10 @@ -741,7 +741,7 @@ return outlineRoot; } - outlineRoot = new PDFOutline(null, null); + outlineRoot = new PDFOutline(null, null, true); assignObjectNumber(outlineRoot); addTrailerObject(outlineRoot); root.setRootOutline(outlineRoot); 1.13 +5 -3 xml-fop/src/java/org/apache/fop/pdf/PDFFactory.java Index: PDFFactory.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFFactory.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- PDFFactory.java 23 Apr 2004 03:05:11 -0000 1.12 +++ PDFFactory.java 13 Jan 2005 00:06:25 -0000 1.13 @@ -897,13 +897,15 @@ * @param label the title for the new outline object * @param destination the reference string for the action to go to * @param yoffset the yoffset on the destination page + * @param showSubItems whether to initially display child outline items * @return the new PDF outline object */ public PDFOutline makeOutline(PDFOutline parent, String label, - String destination, float yoffset) { - String goToRef = getGoToReference(destination, yoffset); + String destination, float yoffset, + boolean showSubItems) { - PDFOutline obj = new PDFOutline(label, goToRef); + String goToRef = getGoToReference(destination, yoffset); + PDFOutline obj = new PDFOutline(label, goToRef, showSubItems); if (parent != null) { parent.addOutline(obj); 1.5 +14 -11 xml-fop/src/java/org/apache/fop/pdf/PDFOutline.java Index: PDFOutline.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFOutline.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- PDFOutline.java 2 Apr 2004 09:14:51 -0000 1.4 +++ PDFOutline.java 13 Jan 2005 00:06:25 -0000 1.5 @@ -49,7 +49,10 @@ private PDFOutline last; private int count; - + + // whether to show this outline item's child outline items + private boolean openItem = false; + /** * title to display for the bookmark entry */ @@ -62,8 +65,9 @@ * * @param title the title of the outline entry (can only be null for root Outlines obj) * @param action the action for this outline + * @param openItem indicator of whether child items are visible or not */ - public PDFOutline(String title, String action) { + public PDFOutline(String title, String action, boolean openItem) { super(); subentries = new java.util.ArrayList(); count = 0; @@ -74,6 +78,7 @@ last = null; this.title = title; actionRef = action; + this.openItem = openItem; } /** @@ -136,30 +141,28 @@ // no count... we start with the outline completely closed for now } } else { - // subentry Outline object + // subentry Outline item object bout.write(encode(" /Title ")); bout.write(encodeText(this.title)); bout.write(encode("\n")); bout.write(encode(" /Parent " + parent.referencePDF() + "\n")); - if (first != null && last != null) { - bout.write(encode(" /First " + first.referencePDF() + "\n")); - bout.write(encode(" /Last " + last.referencePDF() + "\n")); - } if (prev != null) { bout.write(encode(" /Prev " + prev.referencePDF() + "\n")); } if (next != null) { bout.write(encode(" /Next " + next.referencePDF() + "\n")); } + if (first != null && last != null) { + bout.write(encode(" /First " + first.referencePDF() + "\n")); + bout.write(encode(" /Last " + last.referencePDF() + "\n")); + } if (count > 0) { - bout.write(encode(" /Count -" + count + "\n")); + bout.write(encode(" /Count " + (openItem ? "" : "-") + + count + "\n")); } - if (actionRef != null) { bout.write(encode(" /A " + actionRef + "\n")); } - - } bout.write(encode(">> endobj\n")); } catch (IOException ioe) { 1.67 +7 -2 xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java Index: PDFRenderer.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- PDFRenderer.java 12 Jan 2005 12:03:00 -0000 1.66 +++ PDFRenderer.java 13 Jan 2005 00:06:25 -0000 1.67 @@ -125,6 +125,7 @@ * for pdf this means we need the pdf page reference */ protected Map pageReferences = new java.util.HashMap(); + /** Page viewport references */ protected Map pvReferences = new java.util.HashMap(); @@ -316,10 +317,14 @@ if (parentBookmarkItem == null) { PDFOutline outlineRoot = pdfDoc.getOutlineRoot(); pdfOutline = pdfDoc.getFactory().makeOutline(outlineRoot, - bookmarkItem.getBookmarkTitle(), intDest, yoffset); + bookmarkItem.getBookmarkTitle(), + intDest, yoffset, + bookmarkItem.showChildItems()); } else { pdfOutline = pdfDoc.getFactory().makeOutline(parentBookmarkItem, - bookmarkItem.getBookmarkTitle(), intDest, yoffset); + bookmarkItem.getBookmarkTitle(), + intDest, yoffset, + bookmarkItem.showChildItems()); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]