From 32781f1091b3227044dd80b43743999c81157ac5 Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Thu, 6 Jan 2005 00:56:26 +0000 Subject: [PATCH] 1.) fox:label converted to 1.1 fo:bookmark-title. 2.) FObj, FObjMixed, InlineLevel made abstract. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198227 13f79535-47bb-0310-9956-ffa450edef68 --- examples/fo/advanced/cid-fonts.fo | 33 ++- examples/fo/basic/pdfoutline.fo | 232 ++++++++---------- src/java/org/apache/fop/fo/Constants.java | 3 +- .../org/apache/fop/fo/FOElementMapping.java | 7 + src/java/org/apache/fop/fo/FOTreeBuilder.java | 5 +- src/java/org/apache/fop/fo/FObj.java | 2 +- src/java/org/apache/fop/fo/FObjMixed.java | 2 +- src/java/org/apache/fop/fo/PropertySets.java | 7 +- .../extensions/ExtensionElementMapping.java | 7 - .../org/apache/fop/fo/extensions/Label.java | 70 ------ .../org/apache/fop/fo/flow/InlineLevel.java | 4 +- .../fop/fo/pagination/bookmarks/Bookmark.java | 40 ++- .../pagination/bookmarks/BookmarkTitle.java | 92 +++++++ .../fo/pagination/bookmarks/BookmarkTree.java | 2 +- 14 files changed, 270 insertions(+), 236 deletions(-) delete mode 100644 src/java/org/apache/fop/fo/extensions/Label.java create mode 100644 src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java diff --git a/examples/fo/advanced/cid-fonts.fo b/examples/fo/advanced/cid-fonts.fo index 556aa8a2d..526ebea06 100644 --- a/examples/fo/advanced/cid-fonts.fo +++ b/examples/fo/advanced/cid-fonts.fo @@ -2,8 +2,7 @@ ]> - + - Adding Fonts to FOP + Adding Fonts to FOP - Adding additional Type 1 fonts + Adding additional Type 1 fonts - Generating a font metrics file + Generating a font metrics file - Register the fonts within FOP + Register the fonts within FOP - Adding additional TrueType fonts + Adding additional TrueType fonts - Generating a font metrics file + Generating a font metrics file - TrueType collections + TrueType collections - Register the fonts within FOP + Register the fonts within FOP - Embedding fonts in the PDF + Embedding fonts in the PDF - Example embedding MSGothic + Example embedding MSGothic - Setup CLASSPATH + Setup CLASSPATH - Create the metrics file + Create the metrics file - Edit msgothic.xml + Edit msgothic.xml - Register the font with FOP + Register the font with FOP - Japanese Examples + Japanese Examples diff --git a/examples/fo/basic/pdfoutline.fo b/examples/fo/basic/pdfoutline.fo index ce1aa3597..e09020b2f 100644 --- a/examples/fo/basic/pdfoutline.fo +++ b/examples/fo/basic/pdfoutline.fo @@ -11,141 +11,121 @@ This files shows next to the trivial usage of fo:block and fo:inline examples of - fo:page-number-citation (computes dynamically the page number in section 'content') --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - What is FOP? - + + + + + + + + + - - Downloading FOP - + + + + + + - - Running FOP + + + + + + + + + - - Prerequisites - - - Java 1.1 - - - - XML Parser - - - - XSLT Processor - + + + + What is FOP? - - - Starting FOP + + Downloading FOP - - - - - Embedding FOP - - - - What's Implemented? - - - Limitations - - - Bugs - - - Compiling FOP - - - Getting Involved - - - FOP Relevant Specifications - - - License - - - - - - - - - -This is not the latest Fop documentation, but just an fo example. FOP - p. - - - - - - -FOP: An Open-Source XSL Formatter and Renderer + + Running FOP + + Prerequisites + + Java 1.1 + + + XML Parser + + + XSLT Processor + + + + Starting FOP + + + + Embedding FOP + + + What's Implemented? + + + Limitations + + + Bugs + + + Compiling FOP + + + Getting Involved + + + FOP Relevant Specifications + + + License + + + + + + + This is not the latest Fop documentation, but just an fo example. FOP - p. + + -A) - What is FOP? - FOP is the world's first print formatter driven by XSL formatting - objects. It is a Java 1.1 application that reads a formatting object - tree and then turns it into a PDF document. The formatting object - tree, can be in the form of an XML document (output by an XSLT engine - like XT or Xalan) or can be passed in memory as a DOM Document or (in - the case of XT) SAX events. + + + FOP: An Open-Source XSL Formatter and Renderer + + A) + What is FOP? + FOP is the world's first print formatter driven by XSL formatting + objects. It is a Java 1.1 application that reads a formatting object + tree and then turns it into a PDF document. The formatting object + tree, can be in the form of an XML document (output by an XSLT engine + like XT or Xalan) or can be passed in memory as a DOM Document or (in + the case of XT) SAX events. FOP is part of Apache's XML project. The homepage of FOP is diff --git a/src/java/org/apache/fop/fo/Constants.java b/src/java/org/apache/fop/fo/Constants.java index 192ad5560..3103ca9d8 100644 --- a/src/java/org/apache/fop/fo/Constants.java +++ b/src/java/org/apache/fop/fo/Constants.java @@ -115,7 +115,8 @@ public interface Constants { int FO_WRAPPER = 56; int FO_BOOKMARK_TREE = 57; int FO_BOOKMARK = 58; - int FRM_OBJ_COUNT = 58; + int FO_BOOKMARK_TITLE = 59; + int FRM_OBJ_COUNT = 59; // 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 1fa266778..d19d784a6 100644 --- a/src/java/org/apache/fop/fo/FOElementMapping.java +++ b/src/java/org/apache/fop/fo/FOElementMapping.java @@ -47,6 +47,7 @@ public class FOElementMapping extends ElementMapping { foObjs.put("color-profile", new ColorProfileMaker()); foObjs.put("bookmark-tree", new BookmarkTreeMaker()); foObjs.put("bookmark", new BookmarkMaker()); + foObjs.put("bookmark-title", new BookmarkTitleMaker()); foObjs.put("page-sequence", new PageSequenceMaker()); foObjs.put("layout-master-set", new LayoutMasterSetMaker()); foObjs.put("page-sequence-master", @@ -159,6 +160,12 @@ public class FOElementMapping extends ElementMapping { } } + static class BookmarkTitleMaker extends ElementMapping.Maker { + public FONode make(FONode parent) { + return new org.apache.fop.fo.pagination.bookmarks.BookmarkTitle(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/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 5c9909f64..8d66a5f44 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -246,8 +246,9 @@ public class FOTreeBuilder extends DefaultHandler { "Error: First element must be fo:root formatting object")); } } else { // check that incoming node is valid for currentFObj - if (namespaceURI.equals(FOElementMapping.URI) || - namespaceURI.equals(ExtensionElementMapping.URI)) { + if (namespaceURI.equals(FOElementMapping.URI)) { + // currently no fox: elements to validate + // || namespaceURI.equals(ExtensionElementMapping.URI) */) { try { currentFObj.validateChildNode(locator, namespaceURI, localName); } catch (ValidationException e) { diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index b4c7edce2..3281a4c27 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -35,7 +35,7 @@ import org.xml.sax.Locator; /** * Base class for representation of formatting objects and their processing. */ -public class FObj extends FONode implements Constants { +public abstract class FObj extends FONode implements Constants { public static PropertyMaker[] propertyListTable = null; /** The immediate child nodes of this node. */ diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java index 37f8724af..b7e0a7f29 100644 --- a/src/java/org/apache/fop/fo/FObjMixed.java +++ b/src/java/org/apache/fop/fo/FObjMixed.java @@ -29,7 +29,7 @@ import org.apache.fop.apps.FOPException; * (i.e., those that can contain both child FO's and text nodes/PCDATA). * It should not be instantiated directly. */ -public class FObjMixed extends FObj { +public abstract class FObjMixed extends FObj { /** * @param parent FONode that is the parent of this object */ diff --git a/src/java/org/apache/fop/fo/PropertySets.java b/src/java/org/apache/fop/fo/PropertySets.java index 418d23bac..9b4e7d3b9 100644 --- a/src/java/org/apache/fop/fo/PropertySets.java +++ b/src/java/org/apache/fop/fo/PropertySets.java @@ -205,13 +205,18 @@ public class PropertySets { elem.addContent(Constants.FO_BOOKMARK); elem = elements[Constants.FO_BOOKMARK]; -// elem.addContent(Constants.FO_BOOKMARK_TITLE); + 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_BOOKMARK_TITLE]; + elem.addProperties(CommonAccessibilityProperties); + elem.addProperty(Constants.PR_FONT_STYLE); + elem.addProperty(Constants.PR_FONT_WEIGHT); + elem = elements[Constants.FO_PAGE_SEQUENCE]; elem.addProperty(Constants.PR_COUNTRY); elem.addProperty(Constants.PR_FORMAT); diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java index 3e0067d12..950738e85 100644 --- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java @@ -44,13 +44,6 @@ public class ExtensionElementMapping extends ElementMapping { protected void initialize() { if (foObjs == null) { foObjs = new HashMap(); - foObjs.put("label", new L()); - } - } - - 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/Label.java b/src/java/org/apache/fop/fo/extensions/Label.java deleted file mode 100644 index cfba909b6..000000000 --- a/src/java/org/apache/fop/fo/extensions/Label.java +++ /dev/null @@ -1,70 +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; - -import org.xml.sax.Locator; - -import org.apache.fop.fo.FONode; -import org.apache.fop.fo.PropertyList; - -/** - * Labal for PDF bookmark extension. - * This element contains the label for the bookmark object. - */ -public class Label extends ExtensionObj { - private String label = ""; - - /** - * Create a new label object. - * - * @param parent the fo node parent - */ - public Label(FONode parent) { - super(parent); - } - - /** - * Add the characters to this label. - * The text data inside the label xml element is used for the label string. - * - * @param data the character data - * @param start the start position in the data array - * @param end the end position in the character array - * @param locator location in fo source file. - */ - protected void addCharacters(char data[], int start, int end, - PropertyList pList, - Locator locator) { - label += new String(data, start, end - start); - } - - /** - * Get the string for this label. - * - * @return the label string - */ - public String toString() { - return label; - } - - public String getName() { - return "(http://xml.apache.org/fop/extensions) label"; - } - -} diff --git a/src/java/org/apache/fop/fo/flow/InlineLevel.java b/src/java/org/apache/fop/fo/flow/InlineLevel.java index ab468f6ad..6cdb92b40 100644 --- a/src/java/org/apache/fop/fo/flow/InlineLevel.java +++ b/src/java/org/apache/fop/fo/flow/InlineLevel.java @@ -35,9 +35,9 @@ import org.apache.fop.layoutmgr.InlineLayoutManager; /** * Class modelling the commonalities of several inline-level - * formatting objects. It should not be instantiated directly. + * formatting objects. */ -public class InlineLevel extends FObjMixed { +public abstract class InlineLevel extends FObjMixed { protected CommonBorderPaddingBackground commonBorderPaddingBackground; protected CommonAccessibility commonAccessibility; protected CommonMarginInline commonMarginInline; diff --git a/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java b/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java index 4ba55d317..dce00e128 100644 --- a/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java @@ -19,15 +19,13 @@ 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; +import org.apache.fop.fo.ValidationException; /** @@ -36,7 +34,7 @@ import org.apache.fop.fo.extensions.Label; * XSL 1.1 WD evolves. */ public class Bookmark extends FObj { - private Label bookmarkTitle; + private BookmarkTitle bookmarkTitle; private ArrayList childBookmarks = new ArrayList(); private String internalDestination; @@ -75,12 +73,40 @@ public class Bookmark extends FObj { } + /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + XSL/FOP: (bookmark-title, bookmark*) + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) + throws ValidationException { + if (nsURI == FO_URI && localName.equals("bookmark-title")) { + if (bookmarkTitle != null) { + tooManyNodesError(loc, "fo:bookmark-title"); + } + } else if (nsURI == FO_URI && localName.equals("bookmark")) { + if (bookmarkTitle == null) { + nodesOutOfOrderError(loc, "fo:bookmark-title", "fo:bookmark"); + } + } else { + invalidChildError(loc, nsURI, localName); + } + } + + /** + * @see org.apache.fop.fo.FONode#endOfNode + */ + protected void endOfNode() throws FOPException { + if (bookmarkTitle == null) { + missingChildElementError("(bookmark-title, bookmark*)"); + } + } + /** * @see org.apache.fop.fo.FONode#addChildNode(FONode) */ protected void addChildNode(FONode obj) { - if (obj instanceof Label) { - bookmarkTitle = (Label)obj; + if (obj instanceof BookmarkTitle) { + bookmarkTitle = (BookmarkTitle)obj; } else if (obj instanceof Bookmark) { childBookmarks.add(obj); } @@ -92,7 +118,7 @@ public class Bookmark extends FObj { * @return the bookmark title string or an empty string if not found */ public String getBookmarkTitle() { - return bookmarkTitle == null ? "" : bookmarkTitle.toString(); + return bookmarkTitle == null ? "" : bookmarkTitle.getTitle(); } public String getInternalDestination() { diff --git a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java new file mode 100644 index 000000000..d458408cc --- /dev/null +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java @@ -0,0 +1,92 @@ +/* + * 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 org.xml.sax.Locator; + +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.PropertyList; +import org.apache.fop.fo.ValidationException; + +/** + * The fo:bookmark-title formatting object, first introduced in the + * XSL 1.1 WD. Prototype version only, subject to change as XSL 1.1 WD + * evolves. + */ +public class BookmarkTitle extends FObj { + private String title = ""; + + /** + * Create a new BookmarkTitle object. + * + * @param parent the fo node parent + */ + public BookmarkTitle(FONode parent) { + super(parent); + } + + /** + * Add the characters to this BookmarkTitle. + * The text data inside the BookmarkTitle xml element + * is used for the BookmarkTitle string. + * + * @param data the character data + * @param start the start position in the data array + * @param end the end position in the character array + * @param locator location in fo source file. + */ + protected void addCharacters(char data[], int start, int end, + PropertyList pList, + Locator locator) { + title += new String(data, start, end - start); + } + + /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + XSL/FOP: empty + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) + throws ValidationException { + invalidChildError(loc, nsURI, localName); + } + + /** + * Get the title for this BookmarkTitle. + * + * @return the bookmark title + */ + public String getTitle() { + return title; + } + + /** + * @see org.apache.fop.fo.FObj#getName() + */ + public String getName() { + return "fo:bookmark-title"; + } + + /** + * @see org.apache.fop.fo.FObj#getNameId() + */ + public int getNameId() { + return FO_BOOKMARK_TITLE; + } +} 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 b5af4efcf..d13cdd966 100644 --- a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java @@ -67,7 +67,7 @@ public class BookmarkTree extends FObj { /** * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) - XSL/FOP: (conditional-page-master-reference+) + XSL/FOP: (bookmark+) */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws ValidationException { -- 2.39.5