Browse Source

added support for fo:footnote


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197155 13f79535-47bb-0310-9956-ffa450edef68
tags/Root_Temp_KnuthStylePageBreaking
Peter Herweg 20 years ago
parent
commit
bc0944183c

+ 23
- 2
src/java/org/apache/fop/fo/FOInputHandler.java View File

@@ -58,6 +58,8 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.Footnote;
import org.apache.fop.fo.flow.FootnoteBody;
import org.apache.fop.fo.flow.Inline;
import org.apache.fop.fo.flow.InstreamForeignObject;
import org.apache.fop.fo.flow.Leader;
@@ -365,9 +367,28 @@ public abstract class FOInputHandler extends AbstractLogEnabled {
public abstract void foreignObject(InstreamForeignObject ifo);

/**
* Process a footnote.
* Process the start of a footnote.
* @param footnote Footnote that is starting
*/
public abstract void footnote();
public abstract void startFootnote(Footnote footnote);
/**
* Process the ending of a footnote.
* @param footnote Footnote that is ending
*/
public abstract void endFootnote(Footnote footnote);

/**
* Process the start of a footnote body.
* @param body FootnoteBody that is starting
*/
public abstract void startFootnoteBody(FootnoteBody body);
/**
* Process the ending of a footnote body.
* @param body FootnoteBody that is ending
*/
public abstract void endFootnoteBody(FootnoteBody body);

/**
* Process a Leader.

+ 23
- 3
src/java/org/apache/fop/fo/FOTreeHandler.java View File

@@ -62,6 +62,8 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.Footnote;
import org.apache.fop.fo.flow.FootnoteBody;
import org.apache.fop.fo.flow.InstreamForeignObject;
import org.apache.fop.fo.flow.Inline;
import org.apache.fop.fo.flow.Leader;
@@ -446,11 +448,29 @@ public class FOTreeHandler extends FOInputHandler {
}

/**
* @see org.apache.fop.fo.FOInputHandler#footnote()
* @see org.apache.fop.fo.FOInputHandler#startFootnote()
*/
public void footnote() {
public void startFootnote(Footnote footnote) {
}

/**
* @see org.apache.fop.fo.FOInputHandler#endFootnote()
*/
public void endFootnote(Footnote footnote) {
}
/**
* @see org.apache.fop.fo.FOInputHandler#startFootnoteBody()
*/
public void startFootnoteBody(FootnoteBody body) {
}
/**
* @see org.apache.fop.fo.FOInputHandler#endFootnoteBody()
*/
public void endFootnoteBody(FootnoteBody body) {
}
/**
* @see org.apache.fop.fo.FOInputHandler#leader(Leader)
*/

+ 19
- 0
src/java/org/apache/fop/fo/flow/Footnote.java View File

@@ -50,6 +50,11 @@
*/
package org.apache.fop.fo.flow;

// XML
import org.xml.sax.Attributes;

// FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOTreeVisitor;
import org.apache.fop.fo.FObj;
@@ -95,6 +100,20 @@ public class Footnote extends FObj {
public void acceptVisitor(FOTreeVisitor fotv) {
fotv.serveFootnote(this);
}
/**
* @see org.apache.fop.fo.FObj#handleAttrs
*/
public void handleAttrs(Attributes attlist) throws FOPException {
super.handleAttrs(attlist);

getFOTreeControl().getFOInputHandler().startFootnote(this);
}

protected void end() {
super.end();
getFOTreeControl().getFOInputHandler().endFootnote(this);
}
}


+ 18
- 0
src/java/org/apache/fop/fo/flow/FootnoteBody.java View File

@@ -50,7 +50,11 @@
*/
package org.apache.fop.fo.flow;

// XML
import org.xml.sax.Attributes;

// FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOTreeVisitor;
@@ -79,4 +83,18 @@ public class FootnoteBody extends FObj {
fotv.serveFootnoteBody(this);
}

/**
* @see org.apache.fop.fo.FObj#handleAttrs
*/
public void handleAttrs(Attributes attlist) throws FOPException {
super.handleAttrs(attlist);

getFOTreeControl().getFOInputHandler().startFootnoteBody(this);
}

protected void end() {
super.end();
getFOTreeControl().getFOInputHandler().endFootnoteBody(this);
}
}

+ 23
- 3
src/java/org/apache/fop/render/mif/MIFHandler.java View File

@@ -60,6 +60,8 @@ import org.apache.fop.fo.FOInputHandler;
import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.Footnote;
import org.apache.fop.fo.flow.FootnoteBody;
import org.apache.fop.fo.flow.InstreamForeignObject;
import org.apache.fop.fo.flow.Inline;
import org.apache.fop.fo.flow.Leader;
@@ -429,11 +431,29 @@ public class MIFHandler extends FOInputHandler {
}

/**
* @see org.apache.fop.fo.FOInputHandler#footnote()
* @see org.apache.fop.fo.FOInputHandler#startFootnote()
*/
public void footnote() {
public void startFootnote(Footnote footnote) {
}

/**
* @see org.apache.fop.fo.FOInputHandler#endFootnote()
*/
public void endFootnote(Footnote footnote) {
}
/**
* @see org.apache.fop.fo.FOInputHandler#startFootnoteBody()
*/
public void startFootnoteBody(FootnoteBody body) {
}
/**
* @see org.apache.fop.fo.FOInputHandler#endFootnoteBody()
*/
public void endFootnoteBody(FootnoteBody body) {
}
/**
* @see org.apache.fop.fo.FOInputHandler#leader(Leader)
*/

+ 76
- 2
src/java/org/apache/fop/render/rtf/RTFHandler.java View File

@@ -64,6 +64,8 @@ import org.apache.fop.datatypes.FixedLength;
import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.Footnote;
import org.apache.fop.fo.flow.FootnoteBody;
import org.apache.fop.fo.flow.Inline;
import org.apache.fop.fo.flow.InstreamForeignObject;
import org.apache.fop.fo.flow.Leader;
@@ -96,6 +98,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFootnote;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfHyperLink;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem;
@@ -852,9 +855,80 @@ public class RTFHandler extends FOInputHandler {
}

/**
* @see org.apache.fop.fo.FOInputHandler#footnote()
* @see org.apache.fop.fo.FOInputHandler#startFootnote()
*/
public void footnote() {
public void startFootnote(Footnote footnote) {
try {
RtfAttributes rtfAttr
= TextAttributesConverter.convertAttributes(footnote.propertyList, null);
IRtfTextrunContainer container
= (IRtfTextrunContainer)builderContext.getContainer(
IRtfTextrunContainer.class,
true, this);

RtfTextrun textrun = container.getTextrun();
RtfFootnote rtfFootnote = textrun.addFootnote();
builderContext.pushContainer(rtfFootnote);
} catch (IOException ioe) {
// TODO could we throw Exception in all FOInputHandler events?
log.error("startFootnote: " + ioe.getMessage());
throw new Error("IOException: " + ioe);
} catch (Exception e) {
log.error("startFootnote: " + e.getMessage());
throw new Error("Exception: " + e);
}
}
/**
* @see org.apache.fop.fo.FOInputHandler#endFootnote()
*/
public void endFootnote(Footnote footnote) {
builderContext.popContainer();
}
/**
* @see org.apache.fop.fo.FOInputHandler#startFootnoteBody()
*/
public void startFootnoteBody(FootnoteBody body) {
try {
RtfFootnote rtfFootnote
= (RtfFootnote)builderContext.getContainer(
RtfFootnote.class,
true, this);

rtfFootnote.startBody();
} catch (IOException ioe) {
// TODO could we throw Exception in all FOInputHandler events?
log.error("startFootnoteBody: " + ioe.getMessage());
throw new Error("IOException: " + ioe);
} catch (Exception e) {
log.error("startFootnoteBody: " + e.getMessage());
throw new Error("Exception: " + e);
}
}
/**
* @see org.apache.fop.fo.FOInputHandler#endFootnoteBody()
*/
public void endFootnoteBody(FootnoteBody body) {
try {
RtfFootnote rtfFootnote
= (RtfFootnote)builderContext.getContainer(
RtfFootnote.class,
true, this);

rtfFootnote.endBody();
} catch (IOException ioe) {
// TODO could we throw Exception in all FOInputHandler events?
log.error("endFootnoteBody: " + ioe.getMessage());
throw new Error("IOException: " + ioe);
} catch (Exception e) {
log.error("endFootnoteBody: " + e.getMessage());
throw new Error("Exception: " + e);
}
}

/**

+ 106
- 0
src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java View File

@@ -0,0 +1,106 @@
/*
* $Id$
* ============================================================================
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999-2003 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
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
* DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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 <jtauber@jtauber.com>. For more information on the Apache
* Software Foundation, please see <http://www.apache.org/>.
*/

package org.apache.fop.render.rtf.rtflib.rtfdoc;

//Java
import java.io.Writer;
import java.io.IOException;

//FOP
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun;

/** Model of an RTF footnote
* @author Peter Herweg, pherweg@web.de
*/
public class RtfFootnote extends RtfContainer
implements IRtfTextrunContainer {
RtfTextrun textrunInline = null;
RtfTextrun textrunBody = null;
boolean bBody = false;

/** Create an RTF list item as a child of given container with default attributes */
RtfFootnote(RtfContainer parent, Writer w) throws IOException {
super(parent, w);
textrunInline = new RtfTextrun(this, writer, null);
textrunBody = new RtfTextrun(this, writer, null);
}

public RtfTextrun getTextrun() throws IOException {
if (bBody) {
return textrunBody;
} else {
return textrunInline;
}
}

/**
* write RTF code of all our children
* @throws IOException for I/O problems
*/
protected void writeRtfContent() throws IOException {
textrunInline.writeRtfContent();
writeGroupMark(true);
writeControlWord("footnote");
writeControlWord("ftnalt");
textrunBody.writeRtfContent();
writeGroupMark(false);
}
public void startBody() {
bBody = true;
}
public void endBody() {
bBody = false;
}
}

+ 4
- 0
src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java View File

@@ -164,6 +164,10 @@ public class RtfTextrun extends RtfContainer {
RtfString r = new RtfString(this, writer, s);
}
public RtfFootnote addFootnote() throws IOException {
return new RtfFootnote(this, writer);
}
public void addParagraphBreak() throws IOException {
RtfParagraphBreak r = new RtfParagraphBreak(this, writer);
}

Loading…
Cancel
Save