bdelacretaz 2002/10/31 22:44:15
Modified: . build.xml
src/org/apache/fop/apps Driver.java
Added: lib jfor-0.7.1.jar jfor.LICENSE.txt
src/org/apache/fop/rtf/renderer RTFHandler.java
Log:
first shot at RTFHandler using jfor RTF library
Revision Changes Path
1.66 +1 -0 xml-fop/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-fop/build.xml,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- build.xml 31 Oct 2002 17:16:07 -0000 1.65
+++ build.xml 1 Nov 2002 06:44:14 -0000 1.66
@@ -64,6 +64,7 @@
<include name="lib/batik.jar"/>
<include name="lib/avalon-framework*.jar"/>
<include name="lib/jimi*"/>
+ <include name="lib/jfor*.jar"/>
</fileset>
<fileset dir="${basedir}" id="dist.src">
1.1 xml-fop/lib/jfor-0.7.1.jar
<<Binary file>>
1.1 xml-fop/lib/jfor.LICENSE.txt
Index: jfor.LICENSE.txt
===================================================================
* ====================================================================
* jfor Apache-Style Software License.
* Copyright (c) 2002 by the jfor project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, 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 jfor project (http://www.jfor.org)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The name "jfor" must not be used to endorse
* or promote products derived from this software without prior written
* permission. For written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "jfor",
* nor may "jfor" appear in their name, without prior written
* permission of [EMAIL PROTECTED]
*
* 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 JFOR PROJECT OR ITS CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, 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.
* ====================================================================
1.57 +16 -6 xml-fop/src/org/apache/fop/apps/Driver.java
Index: Driver.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Driver.java,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- Driver.java 31 Oct 2002 17:26:04 -0000 1.56
+++ Driver.java 1 Nov 2002 06:44:15 -0000 1.57
@@ -145,6 +145,11 @@
private FOTreeBuilder _treeBuilder;
/**
+ * the renderer type code given by setRenderer
+ */
+ private int _rendererType;
+
+ /**
* the renderer to use to output the area tree
*/
private Renderer _renderer;
@@ -318,6 +323,7 @@
* @param renderer the type of renderer to use
*/
public void setRenderer(int renderer) throws IllegalArgumentException {
+ _rendererType = renderer;
switch (renderer) {
case RENDER_PDF:
setRenderer("org.apache.fop.render.pdf.PDFRenderer");
@@ -336,7 +342,7 @@
setRenderer("org.apache.fop.render.txt.TXTRenderer()");
break;
case RENDER_MIF:
- //structHandler = new org.apache.fop.mif.MIFHandler(_stream);
+ //structHandler will be set later
break;
case RENDER_XML:
setRenderer("org.apache.fop.render.xml.XMLRenderer");
@@ -345,7 +351,7 @@
setRenderer("org.apache.fop.render.svg.SVGRenderer");
break;
case RENDER_RTF:
- if(true) throw new IllegalArgumentException("-rtf option recognized but
RTF output is not implemented yet");
+ //structHandler will be set later
break;
default:
throw new IllegalArgumentException("Unknown renderer type");
@@ -456,11 +462,15 @@
*/
public ContentHandler getContentHandler() {
// TODO - do this stuff in a better way
- if (_renderer != null) {
- structHandler = new LayoutHandler(_stream, _renderer, true);
- } else {
+ if(_rendererType == RENDER_MIF) {
structHandler = new org.apache.fop.mif.MIFHandler(_stream);
+ } else if(_rendererType == RENDER_RTF) {
+ structHandler = new org.apache.fop.rtf.renderer.RTFHandler(_stream);
+ } else {
+ if (_renderer == null) throw new Error("_renderer not set when using
standard structHandler");
+ structHandler = new LayoutHandler(_stream, _renderer, true);
}
+
structHandler.enableLogging(getLogger());
_treeBuilder.setUserAgent(getUserAgent());
1.1 xml-fop/src/org/apache/fop/rtf/renderer/RTFHandler.java
Index: RTFHandler.java
===================================================================
/*
* $Id: RTFHandler.java,v 1.1 2002/11/01 06:44:15 bdelacretaz Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
package org.apache.fop.rtf.renderer;
import org.apache.fop.apps.StructureHandler;
import org.apache.fop.layout.FontInfo;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.LayoutMasterSet;
import org.apache.fop.fo.pagination.SimplePageMaster;
import org.apache.fop.fo.Title;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.Flow;
import org.jfor.jfor.rtflib.rtfdoc.RtfFile;
import org.jfor.jfor.rtflib.rtfdoc.RtfSection;
import org.jfor.jfor.rtflib.rtfdoc.RtfParagraph;
import org.jfor.jfor.rtflib.rtfdoc.RtfDocumentArea;
import org.xml.sax.SAXException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.IOException;
/**
* RTF Handler: generates RTF output using the structure events from
* the FO Tree sent to this structure handler.
*
* @author [EMAIL PROTECTED]
*/
public class RTFHandler extends StructureHandler {
private FontInfo _fontInfo = new FontInfo();
private RtfFile _rtfFile;
private RtfSection _sect;
private RtfDocumentArea _docArea;
private RtfParagraph _para;
private boolean _warned = false;
private static final String ALPHA_WARNING = "WARNING: RTF renderer is
veryveryalpha at this time, see class org.apache.fop.rtf.renderer.RTFHandler";
public RTFHandler(OutputStream os) throws IOException {
_rtfFile = new RtfFile(new OutputStreamWriter(os));
// use pdf fonts for now, this is only for resolving names
org.apache.fop.render.pdf.FontSetup.setup(_fontInfo, null);
System.err.println(ALPHA_WARNING);
}
public FontInfo getFontInfo() {
return _fontInfo;
}
public void startDocument() throws SAXException {
// FIXME sections should be created
try {
_docArea = _rtfFile.startDocumentArea();
} catch(IOException ioe) {
// FIXME could we throw Exception in all StructureHandler events?
throw new SAXException("IOException: " + ioe);
}
}
public void endDocument() throws SAXException {
try {
_rtfFile.flush();
} catch(IOException ioe) {
// FIXME could we throw Exception in all StructureHandler events?
throw new SAXException("IOException: " + ioe);
}
}
public void startPageSequence(PageSequence pageSeq, Title seqTitle,
LayoutMasterSet lms) {
try {
_sect = _docArea.newSection();
if(!_warned) {
_sect.newParagraph().newText(ALPHA_WARNING);
_warned = true;
}
} catch(IOException ioe) {
// FIXME could we throw Exception in all StructureHandler events?
throw new Error("IOException: " + ioe);
}
}
public void endPageSequence(PageSequence pageSeq) throws FOPException {
}
public void startFlow(Flow fl) {
}
public void endFlow(Flow fl) {
}
public void startBlock(Block bl) {
try {
_para = _sect.newParagraph();
} catch(IOException ioe) {
// FIXME could we throw Exception in all StructureHandler events?
throw new Error("IOException: " + ioe);
}
}
public void endBlock(Block bl) {
}
public void characters(char data[], int start, int length) {
try {
_para.newText(new String(data,start,length));
} catch(IOException ioe) {
// FIXME could we throw Exception in all StructureHandler events?
throw new Error("IOException: " + ioe);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]