From: fotis Date: Fri, 15 Dec 2000 21:35:36 +0000 (+0000) Subject: adds support for fo:character and property character X-Git-Tag: pre-columns~12 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a2aa2ffec9248090958d29ed947e44563b42ecee;p=xmlgraphics-fop.git adds support for fo:character and property character git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193874 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index 597d99951..1476b2031 100644 --- a/STATUS +++ b/STATUS @@ -30,29 +30,31 @@ Jon Smirl Done since 0.15 release -- added vertical alignment for table cell contents [Marcus Crafter] +- added: fo:character and property 'character' [Fotis Jannidis] + (limitation: not included into hyphenation) +- added vertical alignment for table cell contents [Keiron Liddle] - added: Finnish hyphenation patterns [Jarno Elovirta] - added: hyphenation package (Carlos Villegas), integration into Fop [Fotis Jannidis] - added: interim configuration package [Fotis Jannidis] - added: FopImage class that uses JAI [Eric Schaeffer] and JAI compile target [Kelly Campbell] - added: support for rule-style [Fotis Jannidis] - updated tables to handle headers, footers, keep-with, colspan - is partly done [Marcus Crafter] + is partly done [Keiron Liddle] - updated: svg stuff for the latest java bindings [Keiron Liddle] - fixed: enhanced error messages for page layout (region names, master) [Norm Walsh] - fixed: infinite looping bug when TableCell or TableRow is larger than a page [Hani Elabed] - fixed: corrected the size of the "-" char [Marcus Crafter] - fixed: check for unnecessary whitespace at end of line [Marcus Crafter] -- fixed: moves table completely to next page if first row doesn't fit into last page [Marcus Crafter] +- fixed: moves table completely to next page if first row doesn't fit into last page [Keiron Liddle] - fixed: problem where id's where being setup twice for table row going over the page [Kelly Campbell] - fixed colspanning so that the cell state keeps track of the - width so far properly [Marcus Crafter] + width so far properly [Keiron Liddle] - fix to allow JDK 1.1 users to compile and use FOP [Mikko Honkala] - fix: removing duplicate character mappings [Dharamveer Salecha] - fix: NullPointerException in FopImageFactory [Kelly Campbell] -- fixed: space after's where not being removed if table row was being removed [Marcus Crafter] -- fixed problem with keep-with not storing the correct rows [Marcus Crafter] +- fixed: space after's where not being removed if table row was being removed [Keiron Liddle] +- fixed problem with keep-with not storing the correct rows [Keiron Liddle] Done since 0.14 release @@ -146,7 +148,6 @@ first target is basic conformance 1.One category of tasks will be to implement missing formatting objects. basic - fo:character fo:declarations fo:multi-case fo:table-and-caption @@ -194,7 +195,6 @@ extended border-before-precedence border-end-precedence border-start-precedence - character clip column-number content-type @@ -218,7 +218,6 @@ extended reference-orientation relative-align role - rule-style source-document space-after (full) space-before (full) diff --git a/docs/examples/build.xml b/docs/examples/build.xml index 2186eaed5..42bd51d87 100644 --- a/docs/examples/build.xml +++ b/docs/examples/build.xml @@ -57,6 +57,7 @@ + @@ -91,6 +92,9 @@ + + + diff --git a/src/codegen/foproperties.xml b/src/codegen/foproperties.xml index 5f6af34e8..6e6f47650 100644 --- a/src/codegen/foproperties.xml +++ b/src/codegen/foproperties.xml @@ -967,6 +967,14 @@ none + + character + Character + false + Character + none + + diff --git a/src/org/apache/fop/fo/StandardElementMapping.java b/src/org/apache/fop/fo/StandardElementMapping.java index b882012b0..0aade4fff 100644 --- a/src/org/apache/fop/fo/StandardElementMapping.java +++ b/src/org/apache/fop/fo/StandardElementMapping.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $Id$ -- ============================================================================ The Apache Software License, Version 1.1 ============================================================================ - + Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - + Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. - + 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. - + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -41,12 +41,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by - James Tauber . For more information on the Apache + James Tauber . For more information on the Apache Software Foundation, please see . - + */ package org.apache.fop.fo; @@ -60,41 +60,41 @@ public class StandardElementMapping implements ElementMapping { String uri = "http://www.w3.org/1999/XSL/Format"; - builder.addMapping(uri, "root", Root.maker()); + builder.addMapping(uri, "root", Root.maker()); builder.addMapping(uri, "layout-master-set", - LayoutMasterSet.maker()); + LayoutMasterSet.maker()); builder.addMapping(uri, "simple-page-master", - SimplePageMaster.maker()); - builder.addMapping(uri, "region-body", RegionBody.maker()); - builder.addMapping(uri, "region-before", RegionBefore.maker()); - builder.addMapping(uri, "region-after", RegionAfter.maker()); - builder.addMapping(uri, "page-sequence", PageSequence.maker()); + SimplePageMaster.maker()); + builder.addMapping(uri, "region-body", RegionBody.maker()); + builder.addMapping(uri, "region-before", RegionBefore.maker()); + builder.addMapping(uri, "region-after", RegionAfter.maker()); + builder.addMapping(uri, "page-sequence", PageSequence.maker()); builder.addMapping(uri, "page-sequence-master", - PageSequenceMaster.maker()); + PageSequenceMaster.maker()); builder.addMapping(uri, "single-page-master-reference", - SinglePageMasterReference.maker()); + SinglePageMasterReference.maker()); builder.addMapping(uri, "repeatable-page-master-reference", - RepeatablePageMasterReference.maker()); + RepeatablePageMasterReference.maker()); builder.addMapping(uri, "conditional-page-master-reference", - ConditionalPageMasterReference.maker()); + ConditionalPageMasterReference.maker()); builder.addMapping(uri, "repeatable-page-master-alternatives", - RepeatablePageMasterAlternatives.maker()); - builder.addMapping(uri, "flow", Flow.maker()); + RepeatablePageMasterAlternatives.maker()); + builder.addMapping(uri, "flow", Flow.maker()); builder.addMapping(uri, "static-content", StaticContent.maker()); - builder.addMapping(uri, "block", Block.maker()); - builder.addMapping(uri, "block-container", BlockContainer.maker()); + builder.addMapping(uri, "block", Block.maker()); + builder.addMapping(uri, "block-container", BlockContainer.maker()); builder.addMapping(uri, "list-block", ListBlock.maker()); builder.addMapping(uri, "list-item", ListItem.maker()); builder.addMapping(uri, "list-item-label", - ListItemLabel.maker()); + ListItemLabel.maker()); builder.addMapping(uri, "list-item-body", ListItemBody.maker()); builder.addMapping(uri, "page-number", PageNumber.maker()); builder.addMapping(uri, "page-number-citation", PageNumberCitation.maker()); builder.addMapping(uri, "display-sequence", - DisplaySequence.maker()); + DisplaySequence.maker()); builder.addMapping(uri, "inline", - Inline.maker()); + Inline.maker()); builder.addMapping(uri, "external-graphic", ExternalGraphic.maker()); builder.addMapping(uri, "table", Table.maker()); @@ -107,5 +107,6 @@ public class StandardElementMapping implements ElementMapping { builder.addMapping(uri, "basic-link", BasicLink.maker()); builder.addMapping(uri, "instream-foreign-object", InstreamForeignObject.maker()); builder.addMapping(uri, "leader", Leader.maker()); + builder.addMapping(uri, "character", org.apache.fop.fo.flow.Character.maker()); } } diff --git a/src/org/apache/fop/layout/BlockArea.java b/src/org/apache/fop/layout/BlockArea.java index 3a7eb48c0..fc31e89f2 100644 --- a/src/org/apache/fop/layout/BlockArea.java +++ b/src/org/apache/fop/layout/BlockArea.java @@ -279,6 +279,45 @@ public class BlockArea extends Area { return 1; } + public void addCharacter(FontState fontState, float red, float green, + float blue, int wrapOption, LinkSet ls, + int whiteSpaceCollapse, char data, boolean ul) { + + this.currentLineArea.changeFont(fontState); + this.currentLineArea.changeColor(red, green, blue); + this.currentLineArea.changeWrapOption(wrapOption); + this.currentLineArea.changeWhiteSpaceCollapse(whiteSpaceCollapse); + + if (ls != null) { + this.currentLinkSet = ls; + ls.setYOffset(currentHeight); + } + + int marker = this.currentLineArea.addCharacter(data, ls, ul); + //if character didn't fit into line, open a new one + if (marker == org.apache.fop.fo.flow.Character.DOESNOT_FIT) { + this.currentLineArea.align(this.align); + this.addLineArea(this.currentLineArea); + + this.currentLineArea = + new LineArea(fontState, lineHeight, halfLeading, + allocationWidth, startIndent, endIndent, + currentLineArea); + this.currentLineArea.changeFont(fontState); + this.currentLineArea.changeColor(red, green, blue); + this.currentLineArea.changeWrapOption(wrapOption); + this.currentLineArea.changeWhiteSpaceCollapse( + whiteSpaceCollapse); + if (ls != null) { + this.currentLinkSet = ls; + ls.setYOffset(currentHeight); + } + + this.currentLineArea.addCharacter(data, ls, ul); + } + this.hasLines = true; + } + public void end() { if (this.hasLines) { diff --git a/src/org/apache/fop/layout/LineArea.java b/src/org/apache/fop/layout/LineArea.java index 63d2ef0d3..9967abb37 100644 --- a/src/org/apache/fop/layout/LineArea.java +++ b/src/org/apache/fop/layout/LineArea.java @@ -250,9 +250,7 @@ public class LineArea extends Area { } else if (prev == TEXT) { // if current is WHITESPACE and previous TEXT - // the current word made it, so - // add the space before the current word (if there // was some) @@ -539,7 +537,7 @@ public class LineArea extends Area { /** * adds pending inline areas to the line area - * normally done,if the line area is filled and + * normally done, when the line area is filled and * added as child to the parent block area */ public void addPending() { @@ -804,4 +802,34 @@ public class LineArea extends Area { } return width; } + + public int addCharacter (char data, LinkSet ls, boolean ul) { + InlineArea ia = null; + int remainingWidth = + this.getContentWidth() - this.getCurrentXPosition(); + int width = this.currentFontState.width(data); + //if it doesn't fit, return + if (width > remainingWidth) { + return org.apache.fop.fo.flow.Character.DOESNOT_FIT; + } else { + //if whitespace-collapse == true, discard character + if (Character.isSpaceChar(data) && whiteSpaceCollapse == WhiteSpaceCollapse.TRUE) { + return org.apache.fop.fo.flow.Character.OK; + } + //create new InlineArea + ia = new InlineArea(currentFontState, + this.red, this.green, this.blue, + new Character(data).toString(),width); + ia.setUnderlined(ul); + pendingAreas.addElement(ia); + if (Character.isSpaceChar(data)) { + this.spaceWidth =+ width; + prev = LineArea.WHITESPACE; + } else { + pendingWidth += width; + prev = LineArea.TEXT; + } + return org.apache.fop.fo.flow.Character.OK; + } + } }