From 80e9950b45d7f2078789fb19ce20b4b9d253493b Mon Sep 17 00:00:00 2001 From: William Victor Mote Date: Wed, 18 Jun 2003 02:10:32 +0000 Subject: [PATCH] Add support for text-align in paragraphs. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196508 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/rtf/renderer/RTFHandler.java | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/fop/rtf/renderer/RTFHandler.java b/src/java/org/apache/fop/rtf/renderer/RTFHandler.java index c21354f35..b2f3d13e9 100644 --- a/src/java/org/apache/fop/rtf/renderer/RTFHandler.java +++ b/src/java/org/apache/fop/rtf/renderer/RTFHandler.java @@ -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; + } + } -- 2.39.5