]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Support fo:character.
authorFinn Bock <bckfnn@apache.org>
Fri, 1 Oct 2004 08:58:52 +0000 (08:58 +0000)
committerFinn Bock <bckfnn@apache.org>
Fri, 1 Oct 2004 08:58:52 +0000 (08:58 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197988 13f79535-47bb-0310-9956-ffa450edef68

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

index 60162c3d05dfde8df4e1042ee2ca0c90520d39e8..7c8efa5aec87c57326bed126b2fccc99fec564e1 100644 (file)
@@ -32,6 +32,7 @@ import org.apache.fop.fo.FOEventHandler;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.flow.BasicLink;
 import org.apache.fop.fo.flow.Block;
+import org.apache.fop.fo.flow.Character;
 import org.apache.fop.fo.flow.ExternalGraphic;
 import org.apache.fop.fo.flow.Footnote;
 import org.apache.fop.fo.flow.FootnoteBody;
@@ -1066,6 +1067,37 @@ public class RTFHandler extends FOEventHandler {
     public void leader(Leader l) {
     }
 
+    /**
+     * @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(c.getPropString(Constants.PR_CHARACTER));
+            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)
      */
@@ -1154,6 +1186,11 @@ public class RTFHandler extends FOEventHandler {
                 FOText text = (FOText) fobj;
                 characters(text.ca, text.startIndex, text.endIndex);
             }
+        } else if (fobj instanceof Character) {
+            if (bStart) {
+                Character c = (Character) fobj;
+                character(c);
+            }
         } else if (fobj instanceof BasicLink) {
             if (bStart) {
                 startLink( (BasicLink) fobj);