[PATCH] background properties for all regions + regions precedencesupport

2002-07-13 Thread Oleg Tkachenko

Hello!

Here is my patch about support for background properties of before, 
after, start and end regions and precedence attribute of before and 
after regions (lr-tb writing mode only). Actually this patch also adds 
start and end regions support for AWT renderer and tries to unify 
regions rendering in all renderers.

-- 
Oleg Tkachenko
Multiconn International, Israel


Index: fop-cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionAfter.java
===
RCS file: /home/cvspublic/xml-fop/src/org/apache/fop/fo/pagination/RegionAfter.java,v
retrieving revision 1.9.2.1
diff -u -r1.9.2.1 RegionAfter.java
--- fop-cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionAfter.java   23 Apr 2002 
22:25:25 -  1.9.2.1
+++ fop-cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionAfter.java   13 Jul 2002 
+14:04:23 -
@@ -65,6 +65,20 @@
return area;
 }
 
+RegionArea makeRegionArea(int allocationRectangleXPosition,
+  int allocationRectangleYPosition,
+  int allocationRectangleWidth,
+  int allocationRectangleHeight,
+  int startExtent, int endExtent) {
+if (getPrecedence() == false) {
+allocationRectangleXPosition += startExtent;
+allocationRectangleWidth -= startExtent + endExtent;
+}
+return makeRegionArea(allocationRectangleXPosition,
+  allocationRectangleYPosition,
+  allocationRectangleWidth,
+  allocationRectangleHeight);
+}
 
 protected String getDefaultRegionName() {
 return xsl-region-after;
@@ -82,4 +96,7 @@
 return (precedence == Precedence.TRUE ? true : false);
 }
 
+public int getExtent() {
+return properties.get(extent).getLength().mvalue();
+}
 }
Index: fop-cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionBefore.java
===
RCS file: /home/cvspublic/xml-fop/src/org/apache/fop/fo/pagination/RegionBefore.java,v
retrieving revision 1.9.2.1
diff -u -r1.9.2.1 RegionBefore.java
--- fop-cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionBefore.java  23 Apr 2002 
22:25:25 -  1.9.2.1
+++ fop-cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionBefore.java  13 Jul 2002 
+14:04:24 -
@@ -65,6 +65,20 @@
return area;
 }
 
+RegionArea makeRegionArea(int allocationRectangleXPosition,
+  int allocationRectangleYPosition,
+  int allocationRectangleWidth,
+  int allocationRectangleHeight,
+  int startExtent, int endExtent) {
+if (getPrecedence() == false) {
+allocationRectangleXPosition += startExtent;
+allocationRectangleWidth -= startExtent + endExtent;
+}
+return makeRegionArea(allocationRectangleXPosition,
+  allocationRectangleYPosition,
+  allocationRectangleWidth,
+  allocationRectangleHeight);
+}
 
 protected String getDefaultRegionName() {
 return xsl-region-before;
@@ -82,4 +96,7 @@
 return (precedence == Precedence.TRUE ? true : false);
 }
 
+public int getExtent() {
+return properties.get(extent).getLength().mvalue();
+}
 }
Index: fop-cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionEnd.java
===
RCS file: /home/cvspublic/xml-fop/src/org/apache/fop/fo/pagination/RegionEnd.java,v
retrieving revision 1.3.2.1
diff -u -r1.3.2.1 RegionEnd.java
--- fop-cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionEnd.java 23 Apr 2002 
22:25:25 -  1.3.2.1
+++ fop-cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionEnd.java 13 Jul 2002 
+14:04:25 -
@@ -43,18 +43,18 @@
   int allocationRectangleWidth,
   int allocationRectangleHeight,
   boolean beforePrecedence,
-  boolean afterPrecedence, int beforeHeight,
-  int afterHeight) {
+  boolean afterPrecedence, int beforeExtent,
+  int afterExtent) {
 int extent = this.properties.get(extent).getLength().mvalue();
 
 int startY = allocationRectangleYPosition;
 int startH = allocationRectangleHeight;
 if (beforePrecedence) {
-startY -= beforeHeight;
-startH -= beforeHeight;
+startY -= beforeExtent;
+startH -= beforeExtent;
 }
 if (afterPrecedence)
-startH -= afterHeight;
+startH -= afterExtent;
 RegionArea area = new 

[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