aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorPeter Herweg <pherweg@apache.org>2005-08-29 20:46:15 +0000
committerPeter Herweg <pherweg@apache.org>2005-08-29 20:46:15 +0000
commit8ff5b13709a136cb342b3271c8d71b0c8dc31f90 (patch)
tree318336419ef7442b1d72b97231115d4574e37554 /src/java
parent0acbef0d3f65b1f2404cb2f507a7e2171f04726b (diff)
downloadxmlgraphics-fop-8ff5b13709a136cb342b3271c8d71b0c8dc31f90.tar.gz
xmlgraphics-fop-8ff5b13709a136cb342b3271c8d71b0c8dc31f90.zip
added support for text-decoration
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@264639 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/render/rtf/RTFHandler.java42
-rw-r--r--src/java/org/apache/fop/render/rtf/TextAttributesConverter.java31
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java2
3 files changed, 29 insertions, 46 deletions
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java
index 1c31c81f2..a76ecdd02 100644
--- a/src/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -1075,40 +1075,9 @@ public class RTFHandler extends FOEventHandler {
}
/**
- * @see org.apache.fop.fo.FOEventHandler#character(Character)
- */
- public void character(Character c) {
- if (bDefer) {
- return;
- }
-
- try {
- RtfAttributes rtfAttr
- = TextAttributesConverter.convertCharacterAttributes(c);
-
- IRtfTextrunContainer container
- = (IRtfTextrunContainer)builderContext.getContainer(
- IRtfTextrunContainer.class, true, this);
-
- RtfTextrun textrun = container.getTextrun();
-
- textrun.pushAttributes(rtfAttr);
- textrun.addString(new String(new char[] {c.getCharacter()}));
- textrun.popAttributes();
- } catch (IOException ioe) {
- // FIXME could we throw Exception in all FOEventHandler events?
- log.error("character: " + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
- } catch (Exception e) {
- log.error("character:" + e.getMessage());
- throw new RuntimeException(e.getMessage());
- }
- }
-
- /**
* @see org.apache.fop.fo.FOEventHandler#characters(char[], int, int)
*/
- public void characters(char[] data, int start, int length) {
+ public void text(FOText text, char[] data, int start, int length) {
if (bDefer) {
return;
}
@@ -1117,9 +1086,14 @@ public class RTFHandler extends FOEventHandler {
IRtfTextrunContainer container
= (IRtfTextrunContainer)builderContext.getContainer(
IRtfTextrunContainer.class, true, this);
-
+
RtfTextrun textrun = container.getTextrun();
+ RtfAttributes rtfAttr
+ = TextAttributesConverter.convertCharacterAttributes(text);
+
+ textrun.pushAttributes(rtfAttr);
textrun.addString(new String(data, start, length - start));
+ textrun.popAttributes();
} catch (IOException ioe) {
// FIXME could we throw Exception in all FOEventHandler events?
log.error("characters: " + ioe.getMessage());
@@ -1216,7 +1190,7 @@ public class RTFHandler extends FOEventHandler {
} else if (foNode instanceof FOText) {
if (bStart) {
FOText text = (FOText) foNode;
- characters(text.ca, text.startIndex, text.endIndex);
+ text(text, text.ca, text.startIndex, text.endIndex);
}
} else if (foNode instanceof Character) {
if (bStart) {
diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
index 0c2cc05b9..319059d4a 100644
--- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
@@ -25,6 +25,7 @@ import org.apache.commons.logging.impl.SimpleLog;
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.ColorType;
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;
@@ -33,6 +34,7 @@ import org.apache.fop.fo.flow.PageNumber;
import org.apache.fop.fo.properties.ColorTypeProperty;
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.render.rtf.rtflib.rtfdoc.RtfAttributes;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable;
@@ -89,18 +91,15 @@ class TextAttributesConverter {
* @param fobj FObj whose properties are to be converted
*/
public static RtfAttributes convertCharacterAttributes(
- Character fobj) throws FOPException {
+ FOText fobj) throws FOPException {
FOPRtfAttributes attrib = new FOPRtfAttributes();
attrFont(fobj.getCommonFont(), attrib);
attrFontColor(fobj.getColor(), attrib);
- //TODO Fix text-decoration here!
- //attrTextDecoration(fobj.getTextDecoration(), attrib);
-
- attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
+ attrTextDecoration(fobj.getTextDecoration(), attrib);
return attrib;
}
-
+
/**
* Converts all character related FO properties to RtfAttributes.
* @param fobj FObj whose properties are to be converted
@@ -110,8 +109,7 @@ class TextAttributesConverter {
FOPRtfAttributes attrib = new FOPRtfAttributes();
attrFont(fobj.getCommonFont(), attrib);
- //TODO Fix text-decoration here!
- //attrTextDecoration(fobj.getTextDecoration(), attrib);
+ attrTextDecoration(fobj.getTextDecoration(), attrib);
attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
return attrib;
}
@@ -126,8 +124,7 @@ class TextAttributesConverter {
FOPRtfAttributes attrib = new FOPRtfAttributes();
attrFont(fobj.getCommonFont(), attrib);
attrFontColor(fobj.getColor(), attrib);
- //TODO Fix text-decoration here!
- //attrTextDecoration(fobj.getTextDecoration(), attrib);
+
attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
return attrib;
}
@@ -168,12 +165,22 @@ class TextAttributesConverter {
- private static void attrTextDecoration(int textDecoration, RtfAttributes rtfAttr) {
- if (textDecoration == Constants.EN_UNDERLINE) {
+ private static void attrTextDecoration(CommonTextDecoration textDecoration, RtfAttributes rtfAttr) {
+ if (textDecoration == null) {
+ return;
+ }
+
+ if (textDecoration.hasUnderline()) {
rtfAttr.set(RtfText.ATTR_UNDERLINE, 1);
} else {
rtfAttr.set(RtfText.ATTR_UNDERLINE, 0);
}
+
+ if (textDecoration.hasLineThrough()) {
+ rtfAttr.set(RtfText.ATTR_STRIKETHROUGH, 1);
+ } else {
+ rtfAttr.set(RtfText.ATTR_STRIKETHROUGH, 0);
+ }
}
private static void attrBlockMargin(CommonMarginBlock cmb, FOPRtfAttributes rtfAttr) {
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 7a1525b4a..ae17d849f 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
@@ -60,6 +60,8 @@ public class RtfText extends RtfElement {
public static final String ATTR_ITALIC = "i";
/** constant for underline */
public static final String ATTR_UNDERLINE = "ul";
+ /** constant for underline */
+ public static final String ATTR_STRIKETHROUGH = "strike";
/** constant for font size */
public static final String ATTR_FONT_SIZE = "fs";
/** constant for font family */