You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ph...@apache.org on 2005/08/29 22:46:21 UTC

svn commit: r264639 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf: RTFHandler.java TextAttributesConverter.java rtflib/rtfdoc/RtfText.java

Author: pherweg
Date: Mon Aug 29 13:46:15 2005
New Revision: 264639

URL: http://svn.apache.org/viewcvs?rev=264639&view=rev
Log:
added support for text-decoration

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=264639&r1=264638&r2=264639&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java Mon Aug 29 13:46:15 2005
@@ -1075,40 +1075,9 @@
     }
 
     /**
-     * @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 @@
             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 @@
         } 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) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java?rev=264639&r1=264638&r2=264639&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java Mon Aug 29 13:46:15 2005
@@ -25,6 +25,7 @@
 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.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 @@
      * @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 @@
 
         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 @@
         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,11 +165,21 @@
 
 
 
-    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);
         }
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java?rev=264639&r1=264638&r2=264639&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java Mon Aug 29 13:46:15 2005
@@ -60,6 +60,8 @@
     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 */



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org