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 bc...@apache.org on 2004/10/01 11:03:35 UTC
cvs commit: xml-fop/src/java/org/apache/fop/render/rtf RTFHandler.java TextAttributesConverter.java
bckfnn 2004/10/01 02:03:35
Modified: src/java/org/apache/fop/render/rtf RTFHandler.java
TextAttributesConverter.java
Log:
Initial support for fo:blockcontainer.
Revision Changes Path
1.34 +61 -1 xml-fop/src/java/org/apache/fop/render/rtf/RTFHandler.java
Index: RTFHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/RTFHandler.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- RTFHandler.java 1 Oct 2004 08:58:52 -0000 1.33
+++ RTFHandler.java 1 Oct 2004 09:03:35 -0000 1.34
@@ -32,6 +32,7 @@
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.BlockContainer;
import org.apache.fop.fo.flow.Character;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.Footnote;
@@ -374,6 +375,65 @@
return;
}
+ if(bDefer) {
+ return;
+ }
+
+ try {
+ IRtfTextrunContainer container
+ = (IRtfTextrunContainer)builderContext.getContainer(
+ IRtfTextrunContainer.class,
+ true, this);
+
+ RtfTextrun textrun = container.getTextrun();
+
+ textrun.addParagraphBreak();
+ textrun.popAttributes();
+
+ } catch (IOException ioe) {
+ log.error("startBlock:" + ioe.getMessage());
+ throw new RuntimeException(ioe.getMessage());
+ } catch (Exception e) {
+ log.error("startBlock:" + e.getMessage());
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ /**
+ * @see org.apache.fop.fo.FOEventHandler#startBlockContainer(BlockContainer)
+ */
+ public void startBlockContainer(BlockContainer blc) {
+ if (bDefer) {
+ return;
+ }
+
+ try {
+ RtfAttributes rtfAttr
+ = TextAttributesConverter.convertBlockContainerAttributes(blc);
+
+ IRtfTextrunContainer container
+ = (IRtfTextrunContainer)builderContext.getContainer(
+ IRtfTextrunContainer.class,
+ true, this);
+
+ RtfTextrun textrun = container.getTextrun();
+
+ textrun.addParagraphBreak();
+ textrun.pushAttributes(rtfAttr);
+ } catch (IOException ioe) {
+ // TODO could we throw Exception in all FOEventHandler events?
+ log.error("startBlock: " + ioe.getMessage());
+ throw new RuntimeException("IOException: " + ioe);
+ } catch (Exception e) {
+ log.error("startBlock: " + e.getMessage());
+ throw new RuntimeException("Exception: " + e);
+ }
+ }
+
+ /**
+ * @see org.apache.fop.fo.FOEventHandler#endBlockContainer(BlockContainer)
+ */
+ public void endBlockContainer(BlockContainer bl) {
if(bDefer) {
return;
}
1.16 +23 -1 xml-fop/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
Index: TextAttributesConverter.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- TextAttributesConverter.java 30 Aug 2004 12:00:54 -0000 1.15
+++ TextAttributesConverter.java 1 Oct 2004 09:03:35 -0000 1.16
@@ -75,6 +75,28 @@
}
/**
+ * Converts all known text FO properties to RtfAttributes
+ * @param props list of FO properites, which are to be converted
+ */
+ public static RtfAttributes convertBlockContainerAttributes(FObj fobj)
+ throws FOPException {
+ RtfAttributes attrib = new RtfAttributes();
+ attrBlockFontFamily(fobj, attrib);
+ attrBlockFontWeight(fobj, attrib);
+ attrBlockFontSize(fobj, attrib);
+ attrBlockFontColor(fobj, attrib);
+ attrBlockFontItalic(fobj, attrib);
+ attrBlockFontUnderline(fobj, attrib);
+ attrBlockBackgroundColor(fobj, attrib);
+ attrBlockSpaceBeforeAfter(fobj, attrib);
+ attrBlockMargins(fobj, attrib);
+ attrBlockTextAlign(fobj, attrib);
+ //attrBlockDimension(fobj, attrib);
+
+ return attrib;
+ }
+
+ /**
* Converts all character related FO properties to RtfAttributes.
* @param fobj FObj whose properties are to be converted
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org