From: William Victor Mote Date: Thu, 26 Jun 2003 06:41:48 +0000 (+0000) Subject: Get rtflib (jfor) files to compile. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~1390 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=05dfbea9a7a5f567edb49e3899e96c31b3d626a0;p=xmlgraphics-fop.git Get rtflib (jfor) files to compile. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196532 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/build.xml b/build.xml index c4cd4ba76..c1232c09c 100644 --- a/build.xml +++ b/build.xml @@ -118,12 +118,6 @@ list of possible build targets. - - - - - - @@ -438,10 +432,6 @@ list of possible build targets. - - - - diff --git a/src/java/org/apache/fop/rtf/renderer/RTFHandler.java b/src/java/org/apache/fop/rtf/renderer/RTFHandler.java index b2f3d13e9..105efd91c 100644 --- a/src/java/org/apache/fop/rtf/renderer/RTFHandler.java +++ b/src/java/org/apache/fop/rtf/renderer/RTFHandler.java @@ -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 diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java index 9750fec5f..a84af528f 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java @@ -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 } diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java index 55d393f9f..13841dc32 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java @@ -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. diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfElement.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfElement.java index 8e2fc6ef5..25a4db059 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfElement.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfElement.java @@ -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"); diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java index 9fd7ee93e..465bf540d 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java @@ -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 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 could not be created (src = '" + url + "'"); +// } +// finally { out.close(); - } +// } } else { type = ImageConstants.I_NOT_SUPPORTED; diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java index d0a1c1df0..c5cbb9f9a 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java @@ -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 { diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java index bda13c1dd..67880e86f 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java @@ -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); diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfJforCmd.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfJforCmd.java index 86541b73c..303a79790 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfJforCmd.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfJforCmd.java @@ -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); } - + } - + } - - - + + + } \ No newline at end of file diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListTable.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListTable.java index fe0c33899..359b593ba 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListTable.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListTable.java @@ -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; } - - + + } \ No newline at end of file diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java index 934f1b9fc..8ea29a6d9 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java @@ -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); diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java index eadd5e5bc..23dfde4ab 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java @@ -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); diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java index 94193e012..7d3b26574 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java @@ -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();