]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Add support for text-align in paragraphs.
authorWilliam Victor Mote <vmote@apache.org>
Wed, 18 Jun 2003 02:10:32 +0000 (02:10 +0000)
committerWilliam Victor Mote <vmote@apache.org>
Wed, 18 Jun 2003 02:10:32 +0000 (02:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196508 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/rtf/renderer/RTFHandler.java

index c21354f3560b7d1aca33bd52cf6a7c17b1638bfa..b2f3d13e9dfaee9fd06a6b18505880dbd4855821 100644 (file)
@@ -63,7 +63,9 @@ import org.apache.fop.apps.StructureHandler;
 import org.apache.fop.layout.FontInfo;
 import org.apache.fop.apps.FOPException;
 
+import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.properties.Constants;
 import org.apache.fop.fo.flow.Block;
 import org.apache.fop.fo.flow.Flow;
 import org.apache.fop.fo.flow.ExternalGraphic;
@@ -77,8 +79,10 @@ 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;
 
@@ -184,13 +188,16 @@ public class RTFHandler extends StructureHandler {
      */
     public void startBlock(Block bl) {
         try {
-            para = sect.newParagraph();
+            RtfAttributes rtfAttr = new RtfAttributes();
+            rtfAttr.set(mapBlockTextAlign(bl));
+            para = sect.newParagraph(rtfAttr);
         } catch (IOException ioe) {
             // FIXME could we throw Exception in all StructureHandler events?
             throw new Error("IOException: " + ioe);
         }
     }
 
+
     /**
      * @see org.apache.fop.apps.StructureHandler#endBlock(Block)
      */
@@ -395,5 +402,30 @@ public class RTFHandler extends StructureHandler {
             // FIXME could we throw Exception in all StructureHandler events?
             throw new Error("IOException: " + ioe);
         }
-   }
+    }
+
+    private static String mapBlockTextAlign(Block bl) {
+        int fopValue = bl.properties.get("text-align").getEnum();
+        String rtfValue = null;
+        switch (fopValue) {
+            case Constants.CENTER: {
+                rtfValue = RtfText.ALIGN_CENTER;
+                break;
+            }
+            case Constants.END: {
+                rtfValue = RtfText.ALIGN_RIGHT;
+                break;
+            }
+            case Constants.JUSTIFY: {
+                rtfValue = RtfText.ALIGN_JUSTIFIED;
+                break;
+            }
+            default: {
+                rtfValue = RtfText.ALIGN_LEFT;
+                break;
+            }
+        }
+        return rtfValue;
+    }
+
 }