Browse Source

Get rtflib (jfor) files to compile.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196532 13f79535-47bb-0310-9956-ffa450edef68
pull/30/head
William Victor Mote 21 years ago
parent
commit
ebffd2b458

+ 0
- 10
build.xml View File

@@ -118,12 +118,6 @@ list of possible build targets.
<exclude name="org/apache/fop/pdf/PDFEncryptionJCE.java" unless="jce.present"/>
</patternset>

<!-- jfor RTF library has been moved here but needs tweaking before it compiles -->
<!-- remove this once the RTF library compiles -->
<patternset id="exclude-rtflib">
<exclude name="org/apache/fop/rtf/rtflib/**/*.java"/>
</patternset>

<patternset id="base-sources">
<include name="**/*.java"/>
<exclude name="**/*${ignore_this}"/>
@@ -438,10 +432,6 @@ list of possible build targets.
<patternset refid="exclude-jce-dependencies"/>
<patternset refid="exclude-jai"/>
<patternset refid="exclude-jimi"/>

<!-- remove this once the RTF library compiles -->
<patternset refid="exclude-rtflib"/>

<classpath refid="libs-build-classpath"/>
<patternset refid="base-sources"/>
</javac>

+ 6
- 6
src/java/org/apache/fop/rtf/renderer/RTFHandler.java View File

@@ -79,12 +79,12 @@ import org.apache.fop.fo.flow.TableCell;
import org.apache.fop.fo.flow.TableRow;

// JFOR
import org.jfor.jfor.rtflib.rtfdoc.RtfAttributes;
import org.jfor.jfor.rtflib.rtfdoc.RtfFile;
import org.jfor.jfor.rtflib.rtfdoc.RtfSection;
import org.jfor.jfor.rtflib.rtfdoc.RtfText;
import org.jfor.jfor.rtflib.rtfdoc.RtfParagraph;
import org.jfor.jfor.rtflib.rtfdoc.RtfDocumentArea;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfAttributes;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfFile;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfText;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;

/**
* RTF Handler: generates RTF output using the structure events from

+ 1
- 1
src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java View File

@@ -119,7 +119,7 @@ public class RtfBookmark extends RtfElement
*/
public void writeRtfContent () throws IOException
{
this.getRtfFile ().getLog ().logInfo ("Write bookmark '" + bookmark + "'.");
// this.getRtfFile ().getLog ().logInfo ("Write bookmark '" + bookmark + "'.");
// No content to write
}


+ 3
- 3
src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java View File

@@ -97,9 +97,9 @@ public class RtfContainer extends RtfElement {

// warn of this problem
final RtfFile rf = getRtfFile();
if(rf.getLog() != null) {
rf.getLog().logWarning(msg);
}
// if(rf.getLog() != null) {
// rf.getLog().logWarning(msg);
// }

// TODO this should be activated to help detect XSL-FO constructs
// that we do not handle properly.

+ 2
- 2
src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfElement.java View File

@@ -54,7 +54,7 @@ package org.apache.fop.rtf.rtflib.rtfdoc;

import java.io.*;
import java.util.*;
import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
//import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
import org.xml.sax.Attributes;

/** Base class for all elements of an RTF file.
@@ -271,7 +271,7 @@ public abstract class RtfElement {

// make the exception message stand out so that the problem is visible
writeControlWord("fs48");
RtfStringConverter.getInstance().writeRtfString(m_writer,JForVersionInfo.getShortVersionInfo() + ": ");
// RtfStringConverter.getInstance().writeRtfString(m_writer,JForVersionInfo.getShortVersionInfo() + ": ");
RtfStringConverter.getInstance().writeRtfString(m_writer,ie.getClass().getName());

writeControlWord("fs20");

+ 15
- 15
src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java View File

@@ -58,8 +58,8 @@ import org.apache.fop.rtf.rtflib.rtfdoc.RtfAttributes;

import org.apache.fop.rtf.rtflib.tools.ImageConstants;
import org.apache.fop.rtf.rtflib.tools.ImageUtil;
import org.apache.fop.rtf.rtflib.tools.jpeg.Encoder;
import org.apache.fop.rtf.rtflib.tools.jpeg.JPEGException;
//import org.apache.fop.rtf.rtflib.tools.jpeg.Encoder;
//import org.apache.fop.rtf.rtflib.tools.jpeg.JPEGException;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -238,7 +238,7 @@ public class RtfExternalGraphic extends RtfElement
return;
}

getRtfFile ().getLog ().logInfo ("Writing image '" + url + "'.");
// getRtfFile ().getLog ().logInfo ("Writing image '" + url + "'.");


byte[] data = null;
@@ -273,20 +273,20 @@ public class RtfExternalGraphic extends RtfElement

if (to == ImageConstants.I_JPG) {
ByteArrayOutputStream out = null;
try {
// try {
//convert to jpeg
out = new ByteArrayOutputStream();
Encoder jpgEncoder = new Encoder(graphicCompressionRate, out);
jpgEncoder.encodeJPEG(data);
data = out.toByteArray();
type = to;
}
catch (JPEGException e) {
e.setMessage("Image from tag <fo:external-graphic> could not be created (src = '" + url + "'");
}
finally {
// out = new ByteArrayOutputStream();
// Encoder jpgEncoder = new Encoder(graphicCompressionRate, out);
// jpgEncoder.encodeJPEG(data);
// data = out.toByteArray();
// type = to;
// }
// catch (JPEGException e) {
// e.setMessage("Image from tag <fo:external-graphic> could not be created (src = '" + url + "'");
// }
// finally {
out.close();
}
// }
}
else {
type = ImageConstants.I_NOT_SUPPORTED;

+ 19
- 19
src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java View File

@@ -53,7 +53,7 @@
package org.apache.fop.rtf.rtflib.rtfdoc;

import org.apache.fop.rtf.rtflib.exceptions.RtfStructureException;
import org.apache.fop.rtf.rtflib.jfor.converter.ConverterLogChannel;
//import org.apache.fop.rtf.rtflib.jfor.converter.ConverterLogChannel;
import java.io.*;

/** Models the top-level structure of an RTF file.
@@ -69,7 +69,7 @@ extends RtfContainer {
private RtfPageArea m_pageArea;
private RtfListTable m_listTable;
private RtfDocumentArea m_docArea;
private ConverterLogChannel m_log;
// private ConverterLogChannel m_log;
private RtfContainer m_listTableContainer;
private int listNum=0;

@@ -79,21 +79,21 @@ extends RtfContainer {
}

/** optional log channel */
public void setLogChannel(ConverterLogChannel log)
{
m_log = log;
}
// public void setLogChannel(ConverterLogChannel log)
// {
// m_log = log;
// }

/**
* Gets the log channel.
* If logchannel not set, it will return a empty log channel.
* @return our log channel, it is never null */
ConverterLogChannel getLog()
{
if (m_log == null)
m_log = new ConverterLogChannel (null);
return m_log;
}
// ConverterLogChannel getLog()
// {
// if (m_log == null)
// m_log = new ConverterLogChannel (null);
// return m_log;
// }

/** If called, must be called before startDocumentArea */
public RtfHeader startHeader()
@@ -103,7 +103,7 @@ extends RtfContainer {
m_listTableContainer = new RtfContainer(this,m_writer);
return m_header;
}
/** Creates the list table.*/
public RtfListTable startListTable(RtfAttributes attr)
throws IOException{
@@ -112,7 +112,7 @@ extends RtfContainer {
m_listTableContainer.addChild(m_listTable);
return m_listTable;
}
/** Closes the RtfHeader if not done yet, and starts the docment area.
Like startDocumentArea, is only called once. This is not optimal,
must be able to have multiple page definition, and corresponding
@@ -127,14 +127,14 @@ extends RtfContainer {
addChild(m_pageArea);
return m_pageArea;
}
/** Call startPageArea if needed and return the page area object. */
public RtfPageArea getPageArea()
throws IOException,RtfStructureException {
if(m_pageArea== null) return startPageArea();
return m_pageArea;
}
/** Closes the RtfHeader if not done yet, and starts the document area.
* Must be called once only.
*/
@@ -148,9 +148,9 @@ extends RtfContainer {
addChild(m_docArea);
return m_docArea;
}
/** Call startDocumentArea if needed and return the document area object. */
public RtfDocumentArea getDocumentArea()
throws IOException,RtfStructureException {

+ 7
- 7
src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java View File

@@ -55,7 +55,7 @@ package org.apache.fop.rtf.rtflib.rtfdoc;
import java.util.*;
import java.io.Writer;
import java.io.IOException;
import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
//import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;

/** RTF file header, contains style, font and other document-level information.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
@@ -65,14 +65,14 @@ import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
class RtfHeader extends RtfContainer {
private final String m_charset = "ansi";
private final Map m_userProperties = new HashMap();
/** Create an RTF header */
RtfHeader(RtfFile f,Writer w) throws IOException {
super(f,w);
new RtfFontTable(this,w);
m_userProperties.put("jforVersion",JForVersionInfo.getLongVersionInfo());
// m_userProperties.put("jforVersion",JForVersionInfo.getLongVersionInfo());
}
/** Overridden to write our own data before our children's data */
protected void writeRtfContent() throws IOException {
writeControlWord(m_charset);
@@ -83,7 +83,7 @@ class RtfHeader extends RtfContainer {
RtfStyleSheetTable.getInstance().writeStyleSheet(this);

}
/** write user properties if any */
private void writeUserProperties() throws IOException {
if(m_userProperties.size() > 0) {
@@ -104,7 +104,7 @@ class RtfHeader extends RtfContainer {
writeGroupMark(false);
}
}
/** write directly to our Writer
* TODO should check that this done at the right point, or even better, store
* what is written here to render it in writeRtfContent. <-- it is for the color table
@@ -112,7 +112,7 @@ class RtfHeader extends RtfContainer {
void write(String toWrite) throws IOException {
m_writer.write(toWrite);
}
/** write to our Writer using an RtfStringConverter */
void writeRtfString(String toWrite) throws IOException {
RtfStringConverter.getInstance().writeRtfString(m_writer,toWrite);

+ 19
- 19
src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfJforCmd.java View File

@@ -63,49 +63,49 @@ import java.io.IOException;
*
*/
public class RtfJforCmd extends RtfContainer {
private final String PARA_KEEP_ON ="para-keep:on";
private final String PARA_KEEP_OFF ="para-keep:off";
private final RtfAttributes m_attrib;
private ParagraphKeeptogetherContext m_paragraphKeeptogetherContext;

RtfJforCmd(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException {
super((RtfContainer)parent,w);
m_attrib = attrs;
m_paragraphKeeptogetherContext=ParagraphKeeptogetherContext.getInstance();
}

public boolean isEmpty() {
return true;
return true;
}
public void process() {
//Execute all jfor-cmd commands
//TODO create one class for each jfor command ?
for(Iterator it = m_attrib.nameIterator(); it.hasNext(); ) {
final String cmd = (String)it.next();
if (cmd.equals(PARA_KEEP_ON)) {
m_paragraphKeeptogetherContext.KeepTogetherOpen();
m_paragraphKeeptogetherContext.KeepTogetherOpen();
}else if (cmd.equals(PARA_KEEP_OFF)) {
m_paragraphKeeptogetherContext.KeepTogetherClose();
}else {
this.getRtfFile ().getLog ().logInfo ("JFOR-CMD ignored, command not recognised:"+cmd);
// this.getRtfFile ().getLog ().logInfo ("JFOR-CMD ignored, command not recognised:"+cmd);
}
}

}
}

+ 13
- 13
src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListTable.java View File

@@ -55,7 +55,7 @@ package org.apache.fop.rtf.rtflib.rtfdoc;
import java.util.*;
import java.io.Writer;
import java.io.IOException;
import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
//import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;

/**RtfListTable: used to make the list table in the header section of the RtfFile.
* This is the method that Word uses to make lists in RTF and the way most RTF readers,
@@ -63,7 +63,7 @@ import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
* @author Christopher Scott, scottc@westinghouse.com
*/
public class RtfListTable extends RtfContainer{
//number of list in document
private Integer listNum;
//id of list
@@ -86,12 +86,12 @@ public class RtfListTable extends RtfContainer{
public static final String LIST_NAME = "listname ;";
public static final String LIST_ID = "listid";
public static final String LIST_FONT_TYPE ="f";
public static final String LIST_OVR_TABLE = "listoverridetable";
public static final String LIST_OVR = "listoverride";
public static final String LIST_OVR_COUNT = "listoverridecount";
public static final String LIST_NUMBER = "ls";
public static final String [] LIST_TABLE_ATTR = {
LIST_TABLE, LIST, LIST_TEMPLATE_ID,
LIST_NUMBER_TYPE, LIST_JUSTIFICATION, LIST_FOLLOWING_CHAR,
@@ -100,7 +100,7 @@ public class RtfListTable extends RtfContainer{
LIST_OVR_TABLE, LIST_OVR, LIST_OVR_COUNT,
LIST_NUMBER, LIST_LEVEL
};
/**RtfListTable Constructor: sets the number of the list, and allocates
* for the RtfAttributes */
public RtfListTable(RtfContainer parent, Writer w, Integer num, RtfAttributes attrs)
@@ -115,15 +115,15 @@ public class RtfListTable extends RtfContainer{
listTemplateId = new Integer(listIdGenerator.nextInt());
m_attrib.set(LIST_NUMBER_TYPE,0);
}
public void setParentList(RtfList parent) {
parentList = parent;
}
public Integer getListNumber() {
return listNum;
}
/** Set whether the list is a bulleted list not, and set attributes
* accordingly */
private void setListType() {
@@ -142,13 +142,13 @@ public class RtfListTable extends RtfContainer{
m_attrib.set(LIST_FONT_TYPE,0);
}
}
public void writeRtfContent() throws IOException {
setListType();
writeGroupMark(true);
writeStarControlWordNS(LIST_TABLE);
writeGroupMark(true);
writeControlWordNS(LIST);
writeOneAttributeNS(LIST_TEMPLATE_ID,listTemplateId.toString());
writeOneAttributeNS(LIST,m_attrib.getValue(LIST));
@@ -184,12 +184,12 @@ public class RtfListTable extends RtfContainer{
writeGroupMark(false);
writeGroupMark(false);
}
//since this has no text content we have to overwrite isEmpty to print
//the table
public boolean isEmpty() {
return false;
}
}

+ 1
- 1
src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java View File

@@ -321,7 +321,7 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
if(rightPadStr != null) gaph = (gaph + rightPadStr.intValue()) / 2;
} catch(Exception e) {
final String msg = "RtfTableRow.writePaddingAttributes: " + e.toString();
getRtfFile().getLog().logWarning(msg);
// getRtfFile().getLog().logWarning(msg);
}
if(gaph >= 0) {
m_attrib.set(ATTR_RTF_15_TRGAPH,gaph);

+ 2
- 2
src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java View File

@@ -54,7 +54,7 @@ package org.apache.fop.rtf.rtflib.testdocs;

import java.io.File;
import java.io.IOException;
import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
//import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;

/** Create test RTF documents from classes found in this package.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
@@ -112,7 +112,7 @@ public class CreateTestDocuments {
System.exit(1);
}

System.err.println("CreateTestDocuments - using " + JForVersionInfo.getLongVersionInfo());
// System.err.println("CreateTestDocuments - using " + JForVersionInfo.getLongVersionInfo());
System.err.println("Generates documents to test the jfor RTF library.");
final File outDir = new File(args[0]);
new CreateTestDocuments(outDir);

+ 9
- 9
src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java View File

@@ -55,7 +55,7 @@ package org.apache.fop.rtf.rtflib.testdocs;
import java.util.Date;
import java.io.*;
import org.apache.fop.rtf.rtflib.rtfdoc.*;
import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
//import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;

/** Base class for generating RTF documents used to test the jfor rtflib package.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
@@ -63,13 +63,13 @@ import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;

abstract class TestDocument {
private File m_output;
final void setOutputDir(File outDir)
throws IOException
{
m_output = new File(outDir,getRtfFilename());
}
final String getRtfFilename()
{
// use class name for output filename
@@ -77,7 +77,7 @@ abstract class TestDocument {
final int pos = name.lastIndexOf('.');
return name.substring(pos + 1) + ".rtf";
}
final void generateOutput()
throws IOException
{
@@ -89,21 +89,21 @@ abstract class TestDocument {
generateDocument(rda,sect);
f.flush();
}
protected abstract void generateDocument(RtfDocumentArea rda,RtfSection sect) throws IOException;
void debugMsg(String msg)
{
System.err.println(msg);
}
protected void addIntroComments(RtfSection sect) throws IOException
{
final RtfParagraph para = sect.newParagraph();
para.newText("jfor RTF library test document.");
para.newLineBreak();
para.newText(JForVersionInfo.getLongVersionInfo());
// para.newText(JForVersionInfo.getLongVersionInfo());
para.newLineBreak();
para.newText("generated by class " + getClass().getName());
para.newLineBreak();

Loading…
Cancel
Save