From f80c74dd16aeb6fdf15615beecf2803e64efbe13 Mon Sep 17 00:00:00 2001 From: Peter Herweg Date: Tue, 30 Aug 2005 21:00:41 +0000 Subject: added support for superscript and subscript git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@264856 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/rtf/TextAttributesConverter.java | 15 +++++++++++++-- .../org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java index 319059d4a..f0b8120ac 100644 --- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java @@ -28,7 +28,6 @@ import org.apache.fop.fo.Constants; import org.apache.fop.fo.FOText; import org.apache.fop.fo.flow.Block; import org.apache.fop.fo.flow.BlockContainer; -import org.apache.fop.fo.flow.Character; import org.apache.fop.fo.flow.Inline; import org.apache.fop.fo.flow.PageNumber; import org.apache.fop.fo.properties.ColorTypeProperty; @@ -36,6 +35,7 @@ import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonTextDecoration; import org.apache.fop.fo.properties.CommonMarginBlock; +import org.apache.fop.fo.properties.EnumLength; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFontManager; @@ -97,6 +97,7 @@ class TextAttributesConverter { attrFont(fobj.getCommonFont(), attrib); attrFontColor(fobj.getColor(), attrib); attrTextDecoration(fobj.getTextDecoration(), attrib); + attrBaseLineShift(fobj.getBaseLineShift(), attrib); return attrib; } @@ -252,6 +253,17 @@ class TextAttributesConverter { rtfAttr.set(RtfText.ATTR_BACKGROUND_COLOR, rtfColor); } + + private static void attrBaseLineShift(EnumLength baselineShift, RtfAttributes rtfAttr) { + + String s = baselineShift.getString(); + + if (s=="SUPER") { + rtfAttr.set(RtfText.ATTR_SUPERSCRIPT); + } else if (s=="SUB") { + rtfAttr.set(RtfText.ATTR_SUBSCRIPT); + } + } /** * Converts a FOP ColorType to the integer pointing into the RTF color table @@ -265,5 +277,4 @@ class TextAttributesConverter { return RtfColorTable.getInstance().getColorNumber(redComponent, greenComponent, blueComponent).intValue(); } - } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java index ae17d849f..9ef08f1e4 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java @@ -70,6 +70,10 @@ public class RtfText extends RtfElement { public static final String ATTR_FONT_COLOR = "cf"; /** constant for background color */ public static final String ATTR_BACKGROUND_COLOR = "chcbpat"; // Added by Boris on 06/25//02 + /** constant for superscript */ + public static final String ATTR_SUPERSCRIPT = "super"; + /** constant for subscript */ + public static final String ATTR_SUBSCRIPT = "sub"; /** RtfText attributes: alignment attributes */ /** constant for align center */ -- cgit v1.2.3