You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ph...@apache.org on 2004/01/10 20:43:58 UTC
cvs commit: xml-fop/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc RtfFootnote.java RtfTextrun.java
pherweg 2004/01/10 11:43:58
Modified: src/java/org/apache/fop/fo FOInputHandler.java
FOTreeHandler.java
src/java/org/apache/fop/render/mif MIFHandler.java
src/java/org/apache/fop/render/rtf RTFHandler.java
src/java/org/apache/fop/fo/flow Footnote.java
FootnoteBody.java
src/java/org/apache/fop/render/rtf/rtflib/rtfdoc
RtfTextrun.java
Added: src/java/org/apache/fop/render/rtf/rtflib/rtfdoc
RtfFootnote.java
Log:
added support for fo:footnote
Revision Changes Path
1.13 +24 -3 xml-fop/src/java/org/apache/fop/fo/FOInputHandler.java
Index: FOInputHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOInputHandler.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- FOInputHandler.java 1 Jan 2004 21:19:55 -0000 1.12
+++ FOInputHandler.java 10 Jan 2004 19:43:58 -0000 1.13
@@ -58,6 +58,8 @@
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 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.
1.12 +24 -4 xml-fop/src/java/org/apache/fop/fo/FOTreeHandler.java
Index: FOTreeHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOTreeHandler.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- FOTreeHandler.java 1 Jan 2004 21:19:55 -0000 1.11
+++ FOTreeHandler.java 10 Jan 2004 19:43:58 -0000 1.12
@@ -62,6 +62,8 @@
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 @@
}
/**
- * @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)
*/
1.4 +24 -4 xml-fop/src/java/org/apache/fop/render/mif/MIFHandler.java
Index: MIFHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/mif/MIFHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MIFHandler.java 1 Jan 2004 21:19:55 -0000 1.3
+++ MIFHandler.java 10 Jan 2004 19:43:58 -0000 1.4
@@ -60,6 +60,8 @@
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 @@
}
/**
- * @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)
*/
1.13 +77 -3 xml-fop/src/java/org/apache/fop/render/rtf/RTFHandler.java
Index: RTFHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/RTFHandler.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- RTFHandler.java 1 Jan 2004 21:19:55 -0000 1.12
+++ RTFHandler.java 10 Jan 2004 19:43:58 -0000 1.13
@@ -64,6 +64,8 @@
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.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 @@
}
/**
- * @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);
+ }
}
/**
1.6 +19 -0 xml-fop/src/java/org/apache/fop/fo/flow/Footnote.java
Index: Footnote.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Footnote.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Footnote.java 19 Sep 2003 14:33:15 -0000 1.5
+++ Footnote.java 10 Jan 2004 19:43:58 -0000 1.6
@@ -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 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);
+ }
}
1.5 +18 -0 xml-fop/src/java/org/apache/fop/fo/flow/FootnoteBody.java
Index: FootnoteBody.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/FootnoteBody.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FootnoteBody.java 16 Sep 2003 05:21:05 -0000 1.4
+++ FootnoteBody.java 10 Jan 2004 19:43:58 -0000 1.5
@@ -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 @@
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);
+ }
}
1.8 +4 -0 xml-fop/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
Index: RtfTextrun.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- RtfTextrun.java 1 Jan 2004 21:19:55 -0000 1.7
+++ RtfTextrun.java 10 Jan 2004 19:43:58 -0000 1.8
@@ -164,6 +164,10 @@
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);
}
1.1 xml-fop/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java
Index: RtfFootnote.java
===================================================================
/*
* $Id: RtfFootnote.java,v 1.1 2004/01/10 19:43:58 pherweg Exp $
* ============================================================================
* 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 <jt...@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;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org