Re: [PATCH] TXTRenderer output encoding

2002-07-15 Thread J.Pietschmann

Oleg Tkachenko wrote:
 Well, encoding-related code looks fine for me, but I cannot build fop in 
 cvs due to Hashtable/HashMap changes:

Oops, didn't clean the build directory before the test build.
It should be fixed now.

J.Pietschmann



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




Re: [PATCH] TXTRenderer output encoding

2002-07-14 Thread J.Pietschmann

Oleg Tkachenko wrote:
 As Torsten Straube pointed out that would be nice to have a possibility 
 to set TXTRenderer output encoding. I like the idea and here is my 
 proposed patch.

Ok, commited to the maintenance branch. I added usage
info and moved the check for a valid encoding somewhere
else and provided a warning in case the encoding is
invalid. PPlease test.

I canät commit it to the head as the TXTRenderer seems
to be in a major overhaul there.

J.Pietschmann



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




[PATCH] TXTRenderer output encoding

2002-07-13 Thread Oleg Tkachenko

Hello!

As Torsten Straube pointed out that would be nice to have a possibility 
to set TXTRenderer output encoding. I like the idea and here is my 
proposed patch. I have added new TXTRenderer option txt.encoding, 
which could be set either from command line:

fop.bat d:\table.fo -txt d:\table.txt -d -txt.encoding Windows-1251

or from java code using TXTRenderer's setOptions(Hashtable) method.
In the case of unsupported encoding TXTStream escapes back to UTF-8.

-- 
Oleg Tkachenko
Multiconn International, Israel


Index: fop-cvs/xml-fop/src/org/apache/fop/apps/CommandLineOptions.java
===
RCS file: /home/cvspublic/xml-fop/src/org/apache/fop/apps/CommandLineOptions.java,v
retrieving revision 1.14.2.4
diff -u -r1.14.2.4 CommandLineOptions.java
--- fop-cvs/xml-fop/src/org/apache/fop/apps/CommandLineOptions.java 6 Jul 2002 
16:43:45 -   1.14.2.4
+++ fop-cvs/xml-fop/src/org/apache/fop/apps/CommandLineOptions.java 13 Jul 2002 
+20:36:29 -
@@ -16,6 +16,7 @@
 import org.apache.fop.configuration.Configuration;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.messaging.MessageHandler;
+import org.apache.fop.render.txt.TXTRenderer;
 
 // Avalon
 import org.apache.avalon.framework.logger.ConsoleLogger;
@@ -252,6 +253,14 @@
 outfile = new File(args[i + 1]);
 i++;
 }
+ } else if (args[i].equals(- + TXTRenderer.encodingOptionName)) {
+if ((i + 1 == args.length)
+|| (args[i + 1].charAt(0) == '-')) {
+throw new FOPException(you must specify text renderer encoding);
+} else {
+rendererOptions.put(TXTRenderer.encodingOptionName, args[i + 1]);
+i++;
+}
 } else {
 printUsage();
 return false;
@@ -587,6 +596,8 @@
 case TXT_OUTPUT:
 log.debug(txt);
 log.debug(output file:  + outfile.toString());
+if (rendererOptions.containsKey(TXTRenderer.encodingOptionName))
+log.debug(output encoding:  + 
+rendererOptions.get(TXTRenderer.encodingOptionName));
 break;
 case SVG_OUTPUT:
 log.debug(svg);
Index: fop-cvs/xml-fop/src/org/apache/fop/render/txt/TXTRenderer.java
===
RCS file: /home/cvspublic/xml-fop/src/org/apache/fop/render/txt/TXTRenderer.java,v
retrieving revision 1.12.2.2
diff -u -r1.12.2.2 TXTRenderer.java
--- fop-cvs/xml-fop/src/org/apache/fop/render/txt/TXTRenderer.java  23 Apr 2002 
22:33:40 -  1.12.2.2
+++ fop-cvs/xml-fop/src/org/apache/fop/render/txt/TXTRenderer.java  13 Jul 2002 
+20:36:41 -
@@ -46,6 +46,7 @@
  * the current stream to add Text commands to
  */
 TXTStream currentStream;
+public static final String encodingOptionName = txt.encoding;
 
 private int pageHeight = 7920;
 
@@ -1605,8 +1606,6 @@
 if (debug)
 System.out.println(TXTRenderer.renderPage() page.getHeight() = 
+ page.getHeight());
-BodyAreaContainer body;
-AreaContainer before, after, start, end;
 
 maxX = (int)(textCPI * page.getWidth() / 72000 + 1);
 maxY = (int)(textLPI * page.getHeight() / 72000 + 1);
@@ -1626,29 +1625,11 @@
+  yFactor= + yFactor +  paperHeight=
+ pageHeight);
 
-body = page.getBody();
-before = page.getBefore();
-after = page.getAfter();
-start = page.getStart();
-end = page.getEnd();
-
 this.currentFontName = ;
 this.currentFontSize = 0;
 
 // currentStream.add(BT\n);
-renderBodyAreaContainer(body);
-
-if (before != null)
-renderAreaContainer(before);
-
-if (after != null)
-renderAreaContainer(after);
-
-if (start != null)
-renderAreaContainer(start);
-
-if (end != null)
-renderAreaContainer(end);
+renderRegions(page);
 
 // Write out the buffers.
 for (int row = 0; row = maxY; row++) {
@@ -1719,6 +1700,7 @@
 throws IOException {
 log.info(rendering areas to TEXT);
 currentStream = new TXTStream(outputStream);
+currentStream.setEncoding((String)options.get(encodingOptionName));
 firstPage=true;
 }
 
Index: fop-cvs/xml-fop/src/org/apache/fop/render/txt/TXTStream.java
===
RCS file: /home/cvspublic/xml-fop/src/org/apache/fop/render/txt/TXTStream.java,v
retrieving revision 1.1
diff -u -r1.1 TXTStream.java
--- fop-cvs/xml-fop/src/org/apache/fop/render/txt/TXTStream.java31 Jan 2002 
18:14:42 -  1.1
+++ fop-cvs/xml-fop/src/org/apache/fop/render/txt/TXTStream.java