diff options
author | Glen Mazza <gmazza@apache.org> | 2005-01-02 20:42:51 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2005-01-02 20:42:51 +0000 |
commit | f705dacc16300bea1abff6e6866a9e52c22c7d0f (patch) | |
tree | 6d8b139f8463230c005585cce306a7935f6595d1 | |
parent | 73a83df9636693496269245c4f0b5fcd56aae0b1 (diff) | |
download | xmlgraphics-fop-f705dacc16300bea1abff6e6866a9e52c22c7d0f.tar.gz xmlgraphics-fop-f705dacc16300bea1abff6e6866a9e52c22c7d0f.zip |
Switched from fox:bookmarks to fo:bookmark-tree (of XSL 1.1 2WD). Two more
bookmark-related FO's (fox:outline and fox:label) need conversion and will
be done next.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198216 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | examples/fo/advanced/cid-fonts.fo | 4 | ||||
-rw-r--r-- | examples/fo/basic/pdfoutline.fo | 121 | ||||
-rw-r--r-- | src/java/org/apache/fop/area/AreaTreeHandler.java | 8 | ||||
-rw-r--r-- | src/java/org/apache/fop/area/BookmarkData.java | 8 | ||||
-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/FObj.java | 4 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/PropertySets.java | 21 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/extensions/Bookmarks.java | 66 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java | 7 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/Root.java | 44 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java | 96 |
12 files changed, 209 insertions, 180 deletions
diff --git a/examples/fo/advanced/cid-fonts.fo b/examples/fo/advanced/cid-fonts.fo index d7623ae23..dc55f7ac9 100644 --- a/examples/fo/advanced/cid-fonts.fo +++ b/examples/fo/advanced/cid-fonts.fo @@ -16,7 +16,7 @@ </fo:simple-page-master> </fo:layout-master-set> - +<fo:bookmark-tree> <fox:outline internal-destination="sec0"> <fox:label>Adding Fonts to FOP</fox:label> </fox:outline> @@ -74,7 +74,7 @@ <fox:outline internal-destination="sec5"> <fox:label>Japanese Examples</fox:label> </fox:outline> - +</fo:bookmark-tree> <fo:page-sequence master-reference="A4"> diff --git a/examples/fo/basic/pdfoutline.fo b/examples/fo/basic/pdfoutline.fo index b53e1f743..276d61e99 100644 --- a/examples/fo/basic/pdfoutline.fo +++ b/examples/fo/basic/pdfoutline.fo @@ -58,71 +58,68 @@ This files shows next to the trivial usage of fo:block and fo:inline examples of <!-- end: defines page layout --> -<!-- beginning of the PDF outline extensions --> - <fox:bookmarks> - - <fox:outline internal-destination="sec1"> - <fox:label>What is FOP?</fox:label> - </fox:outline> - - <fox:outline internal-destination="sec2"> - <fox:label>Downloading FOP</fox:label> - </fox:outline> - - <fox:outline internal-destination="sec3"> - <fox:label>Running FOP</fox:label> - - <fox:outline internal-destination="sec3-1"> - <fox:label>Prerequisites</fox:label> - - <fox:outline internal-destination="sec3-1-1"> - <fox:label>Java 1.1</fox:label> +<!-- bookmark section --> + <fo:bookmark-tree> + <fox:outline internal-destination="sec1"> + <fox:label>What is FOP?</fox:label> </fox:outline> - - <fox:outline internal-destination="sec3-1-2"> - <fox:label>XML Parser</fox:label> + + <fox:outline internal-destination="sec2"> + <fox:label>Downloading FOP</fox:label> </fox:outline> - - <fox:outline internal-destination="sec3-1-3"> - <fox:label>XSLT Processor</fox:label> + + <fox:outline internal-destination="sec3"> + <fox:label>Running FOP</fox:label> + + <fox:outline internal-destination="sec3-1"> + <fox:label>Prerequisites</fox:label> + + <fox:outline internal-destination="sec3-1-1"> + <fox:label>Java 1.1</fox:label> + </fox:outline> + + <fox:outline internal-destination="sec3-1-2"> + <fox:label>XML Parser</fox:label> + </fox:outline> + + <fox:outline internal-destination="sec3-1-3"> + <fox:label>XSLT Processor</fox:label> + </fox:outline> + + </fox:outline> + + <fox:outline internal-destination="sec3-2"> + <fox:label>Starting FOP</fox:label> + </fox:outline> + </fox:outline> - - </fox:outline> - - <fox:outline internal-destination="sec3-2"> - <fox:label>Starting FOP</fox:label> - </fox:outline> - - </fox:outline> - - <fox:outline internal-destination="sec4"> - <fox:label>Embedding FOP</fox:label> - </fox:outline> - - <fox:outline internal-destination="sec5"> - <fox:label>What's Implemented?</fox:label> - </fox:outline> - <fox:outline internal-destination="sec6"> - <fox:label>Limitations</fox:label> - </fox:outline> - <fox:outline internal-destination="sec7"> - <fox:label>Bugs</fox:label> - </fox:outline> - <fox:outline internal-destination="sec8"> - <fox:label>Compiling FOP</fox:label> - </fox:outline> - <fox:outline internal-destination="sec9"> - <fox:label>Getting Involved</fox:label> - </fox:outline> - <fox:outline internal-destination="sec10"> - <fox:label>FOP Relevant Specifications</fox:label> - </fox:outline> - <fox:outline internal-destination="sec11"> - <fox:label>License</fox:label> - </fox:outline> - </fox:bookmarks> - - + + <fox:outline internal-destination="sec4"> + <fox:label>Embedding FOP</fox:label> + </fox:outline> + + <fox:outline internal-destination="sec5"> + <fox:label>What's Implemented?</fox:label> + </fox:outline> + <fox:outline internal-destination="sec6"> + <fox:label>Limitations</fox:label> + </fox:outline> + <fox:outline internal-destination="sec7"> + <fox:label>Bugs</fox:label> + </fox:outline> + <fox:outline internal-destination="sec8"> + <fox:label>Compiling FOP</fox:label> + </fox:outline> + <fox:outline internal-destination="sec9"> + <fox:label>Getting Involved</fox:label> + </fox:outline> + <fox:outline internal-destination="sec10"> + <fox:label>FOP Relevant Specifications</fox:label> + </fox:outline> + <fox:outline internal-destination="sec11"> + <fox:label>License</fox:label> + </fox:outline> + </fo:bookmark-tree> <!-- actual layout --> <fo:page-sequence master-reference="basicPSM"> diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java index 949d6a2e4..36bc691a1 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.java @@ -36,9 +36,9 @@ import org.apache.commons.logging.LogFactory; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.FOEventHandler; -import org.apache.fop.fo.extensions.Bookmarks; import org.apache.fop.fo.pagination.PageSequence; import org.apache.fop.fo.pagination.Root; +import org.apache.fop.fo.pagination.bookmarks.BookmarkTree; import org.apache.fop.layoutmgr.PageSequenceLayoutManager; import org.apache.fop.layoutmgr.LayoutManagerMaker; import org.apache.fop.layoutmgr.LayoutManagerMapping; @@ -251,9 +251,9 @@ public class AreaTreeHandler extends FOEventHandler { public void endDocument() throws SAXException { // process fo:bookmark-tree - Bookmarks bookmarks = rootFObj.getBookmarks(); - if (bookmarks != null) { - BookmarkData data = new BookmarkData(bookmarks); + BookmarkTree bookmarkTree = rootFObj.getBookmarkTree(); + if (bookmarkTree != null) { + BookmarkData data = new BookmarkData(bookmarkTree); addOffDocumentItem(data); } diff --git a/src/java/org/apache/fop/area/BookmarkData.java b/src/java/org/apache/fop/area/BookmarkData.java index 8a0a4b39d..23fd92583 100644 --- a/src/java/org/apache/fop/area/BookmarkData.java +++ b/src/java/org/apache/fop/area/BookmarkData.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.List; import java.util.HashMap; -import org.apache.fop.fo.extensions.Bookmarks; +import org.apache.fop.fo.pagination.bookmarks.BookmarkTree; import org.apache.fop.fo.extensions.Outline; /** @@ -52,12 +52,12 @@ public class BookmarkData extends OffDocumentItem implements Resolvable { * * @param bookmarks fo:bookmark-tree for this document */ - public BookmarkData(Bookmarks bookmarks) { + public BookmarkData(BookmarkTree bookmarkTree) { idRef = null; whenToProcess = END_OF_DOC; - for (int count = 0; count < bookmarks.getOutlines().size(); count++) { - Outline out = (Outline)(bookmarks.getOutlines()).get(count); + for (int count = 0; count < bookmarkTree.getBookmarks().size(); count++) { + Outline out = (Outline)(bookmarkTree.getBookmarks()).get(count); addSubData(createBookmarkData(out)); } } diff --git a/src/java/org/apache/fop/fo/Constants.java b/src/java/org/apache/fop/fo/Constants.java index bebc81ac0..7f1d40521 100644 --- a/src/java/org/apache/fop/fo/Constants.java +++ b/src/java/org/apache/fop/fo/Constants.java @@ -113,7 +113,8 @@ public interface Constants { int FO_TABLE_ROW = 54; int FO_TITLE = 55; int FO_WRAPPER = 56; - int FRM_OBJ_COUNT = 56; + int FO_BOOKMARK_TREE = 57; + int FRM_OBJ_COUNT = 57; // 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 18b4e8830..760adeb33 100644 --- a/src/java/org/apache/fop/fo/FOElementMapping.java +++ b/src/java/org/apache/fop/fo/FOElementMapping.java @@ -45,6 +45,7 @@ public class FOElementMapping extends ElementMapping { foObjs.put("root", new RootMaker()); foObjs.put("declarations", new DeclarationsMaker()); foObjs.put("color-profile", new ColorProfileMaker()); + foObjs.put("bookmark-tree", new BookmarkTreeMaker()); foObjs.put("page-sequence", new PageSequenceMaker()); foObjs.put("layout-master-set", new LayoutMasterSetMaker()); foObjs.put("page-sequence-master", @@ -145,6 +146,12 @@ public class FOElementMapping extends ElementMapping { } } + static class BookmarkTreeMaker extends ElementMapping.Maker { + public FONode make(FONode parent) { + return new org.apache.fop.fo.pagination.bookmarks.BookmarkTree(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/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 7820f9acd..dff9dcd29 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -117,12 +117,12 @@ public class FObj extends FONode implements Constants { /** * Bind property values from the property list to the FO node. - * Must be overriden in all FObj subclasses. + * Must be overridden in all FObj subclasses that have properties + * applying to it. * @param pList the PropertyList where the properties can be found. * @throws FOPException */ public void bind(PropertyList pList) throws FOPException { -// throw new ValidationException("Unconverted element " + this, locator); } /** diff --git a/src/java/org/apache/fop/fo/PropertySets.java b/src/java/org/apache/fop/fo/PropertySets.java index 3f12d1866..64e50fd13 100644 --- a/src/java/org/apache/fop/fo/PropertySets.java +++ b/src/java/org/apache/fop/fo/PropertySets.java @@ -201,6 +201,9 @@ public class PropertySets { elem.addProperty(Constants.PR_COLOR_PROFILE_NAME); elem.addProperty(Constants.PR_RENDERING_INTENT); + elem = elements[Constants.FO_BOOKMARK_TREE]; +// elem.addContent(Constants.FO_BOOKMARK); + elem = elements[Constants.FO_PAGE_SEQUENCE]; elem.addProperty(Constants.PR_COUNTRY); elem.addProperty(Constants.PR_FORMAT); @@ -1117,7 +1120,7 @@ public class PropertySets { BitSet relevant = new BitSet(); BitSet valid = new BitSet(); int elementId; - ArrayList children; + ArrayList childFOs; Element(int elementId) { this.elementId = elementId; @@ -1143,14 +1146,14 @@ public class PropertySets { * Add a single fo element as a content child. */ public void addContent(int elementId) { - if (children == null) { - children = new ArrayList(); + if (childFOs == null) { + childFOs = new ArrayList(); } - children.add(elements[elementId]); + childFOs.add(elements[elementId]); } /** - * Add a set of fo elements as content children. + * Add a set of fo elements as content childFOs. */ public void addContent(BitSet elements) { for (int i = 0; i < elements.size(); i++) { @@ -1161,16 +1164,16 @@ public class PropertySets { } /** - * Merge the properties from the children into the set of valid + * Merge the properties from the child FO's into the set of valid * properties. Return true if at least one property could be added. */ public boolean merge() { - if (children == null) { + if (childFOs == null) { return false; } boolean dirty = false; - for (int i = 0; i < children.size(); i++) { - Element child = (Element) children.get(i); + for (int i = 0; i < childFOs.size(); i++) { + Element child = (Element) childFOs.get(i); BitSet childValid = child.valid; int n = childValid.length(); for (int j = 0; j < n; j++) { diff --git a/src/java/org/apache/fop/fo/extensions/Bookmarks.java b/src/java/org/apache/fop/fo/extensions/Bookmarks.java deleted file mode 100644 index 7573da0c1..000000000 --- a/src/java/org/apache/fop/fo/extensions/Bookmarks.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.extensions; - -// Java -import java.util.ArrayList; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.FONode; -import org.apache.fop.fo.pagination.Root; - -/** - * Bookmarks data is the top level element of the pdf bookmark extension. - * This handles the adding of outlines. When the element is ended it - * creates the bookmark data and adds to the area tree. - */ -public class Bookmarks extends ExtensionObj { - private ArrayList outlines = new ArrayList(); - - /** - * Create a new Bookmarks object. - * - * @param parent the parent fo node - */ - public Bookmarks(FONode parent) { - super(parent); - } - - /** - * @see org.apache.fop.fo.FONode#addChildNode(FONode) - */ - protected void addChildNode(FONode obj) { - if (obj instanceof Outline) { - outlines.add(obj); - } - } - - /** - * When this element is finished then it can create - * the bookmark data from the child elements and add - * the extension to the area tree. - */ - protected void endOfNode() throws FOPException { - ((Root) parent).setBookmarks(this); - } - - public ArrayList getOutlines() { - return outlines; - } -} diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java index 13edff78b..16e30ef8a 100644 --- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java @@ -44,18 +44,11 @@ public class ExtensionElementMapping extends ElementMapping { protected void initialize() { if (foObjs == null) { foObjs = new HashMap(); - foObjs.put("bookmarks", new B()); foObjs.put("outline", new O()); foObjs.put("label", new L()); } } - static class B extends ElementMapping.Maker { - public FONode make(FONode parent) { - return new Bookmarks(parent); - } - } - static class O extends ElementMapping.Maker { public FONode make(FONode parent) { return new Outline(parent); diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java index efb01220d..e759a0eb2 100644 --- a/src/java/org/apache/fop/fo/pagination/Root.java +++ b/src/java/org/apache/fop/fo/pagination/Root.java @@ -29,7 +29,7 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; -import org.apache.fop.fo.extensions.Bookmarks; +import org.apache.fop.fo.pagination.bookmarks.BookmarkTree; import org.apache.fop.fo.extensions.ExtensionElementMapping; /** @@ -42,7 +42,7 @@ public class Root extends FObj { private LayoutMasterSet layoutMasterSet; private Declarations declarations; - private Bookmarks bookmarks = null; + private BookmarkTree bookmarkTree = null; private List pageSequences; // temporary until above list populated @@ -82,7 +82,7 @@ public class Root extends FObj { protected void endOfNode() throws FOPException { if (!pageSequenceFound || layoutMasterSet == null) { missingChildElementError("(layout-master-set, declarations?, " + - "fox:bookmarks?, page-sequence+)"); + "bookmark-tree?, page-sequence+)"); } } @@ -103,11 +103,19 @@ public class Root extends FObj { nodesOutOfOrderError(loc, "fo:layout-master-set", "fo:declarations"); } else if (declarations != null) { tooManyNodesError(loc, "fo:declarations"); - } else if (bookmarks != null) { - nodesOutOfOrderError(loc, "fo:declarations", "fox:bookmarks"); + } else if (bookmarkTree != null) { + nodesOutOfOrderError(loc, "fo:declarations", "fo:bookmark-tree"); } else if (pageSequenceFound) { nodesOutOfOrderError(loc, "fo:declarations", "fo:page-sequence"); } + } else if (localName.equals("bookmark-tree")) { + if (layoutMasterSet == null) { + nodesOutOfOrderError(loc, "fo:layout-master-set", "fo:bookmark-tree"); + } else if (bookmarkTree != null) { + tooManyNodesError(loc, "fo:bookmark-tree"); + } else if (pageSequenceFound) { + nodesOutOfOrderError(loc, "fo:bookmark-tree", "fo:page-sequence"); + } } else if (localName.equals("page-sequence")) { if (layoutMasterSet == null) { nodesOutOfOrderError(loc, "fo:layout-master-set", "fo:page-sequence"); @@ -117,16 +125,6 @@ public class Root extends FObj { } else { invalidChildError(loc, nsURI, localName); } - } else if (nsURI.equals(ExtensionElementMapping.URI)) { - if (!localName.equals("bookmarks")) { - invalidChildError(loc, nsURI, localName); - } else if (layoutMasterSet == null) { - nodesOutOfOrderError(loc, "fo:layout-master-set", "fox:bookmarks"); - } else if (bookmarks != null) { - tooManyNodesError(loc, "fox:bookmarks"); - } else if (pageSequenceFound) { - nodesOutOfOrderError(loc, "fox:bookmarks", "fo:page-sequence"); - } } else { invalidChildError(loc, nsURI, localName); } @@ -226,19 +224,19 @@ public class Root extends FObj { } /** - * Set the Bookmarks object for this FO - * @param bookmarks the Bookmarks object + * Set the BookmarkTree object for this FO + * @param bookmarkTree the BookmarkTree object */ - public void setBookmarks(Bookmarks bookmarks) { - this.bookmarks = bookmarks; + public void setBookmarkTree(BookmarkTree bookmarkTree) { + this.bookmarkTree = bookmarkTree; } /** - * Public accessor for the Bookmarks for this FO - * @return the Bookmarks object + * Public accessor for the BookmarkTree object for this FO + * @return the BookmarkTree object */ - public Bookmarks getBookmarks() { - return bookmarks; + public BookmarkTree getBookmarkTree() { + return bookmarkTree; } /** diff --git a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java new file mode 100644 index 000000000..43daeda05 --- /dev/null +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java @@ -0,0 +1,96 @@ +/* + * 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; + +// Java +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; +import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.pagination.Root; +import org.apache.fop.fo.properties.Property; + +/** + * The fo:bookmark-tree formatting object, first introduced in the + * XSL 1.1 WD. Prototype version only, subject to change as XSL 1.1 WD + * evolves. + */ +public class BookmarkTree extends FObj { + private ArrayList bookmarks = new ArrayList(); + + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ + public BookmarkTree(FONode parent) { + super(parent); + } + + /** + * @see org.apache.fop.fo.FONode#addChildNode(FONode) + */ + protected void addChildNode(FONode obj) { + if (obj instanceof Outline) { + bookmarks.add(obj); + } + } + + /** + * @see org.apache.fop.fo.FONode#endOfNode + */ + protected void endOfNode() throws FOPException { + if (bookmarks == null) { + missingChildElementError("(fox:outline+)"); + } + ((Root) parent).setBookmarkTree(this); + } + + /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + XSL/FOP: (conditional-page-master-reference+) + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) + throws ValidationException { + if (!(nsURI == ExtensionElementMapping.URI && + localName.equals("outline"))) { + invalidChildError(loc, nsURI, localName); + } + } + + public ArrayList getBookmarks() { + return bookmarks; + } + + public String getName() { + return "fo:bookmark-tree"; + } + + /** + * @see org.apache.fop.fo.FObj#getNameId() + */ + public int getNameId() { + return FO_BOOKMARK_TREE; + } +} |