Browse Source

Initial support for fo:blockcontainer.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197990 13f79535-47bb-0310-9956-ffa450edef68
tags/Root_Temp_KnuthStylePageBreaking
Finn Bock 19 years ago
parent
commit
f15702fe6f

+ 60
- 0
src/java/org/apache/fop/render/rtf/RTFHandler.java View 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.BlockContainer;
import org.apache.fop.fo.flow.Character;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.Footnote;
@@ -398,6 +399,65 @@ public class RTFHandler extends FOEventHandler {
}
}

/**
* @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;
}
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#startTable(Table)
*/

+ 22
- 0
src/java/org/apache/fop/render/rtf/TextAttributesConverter.java View File

@@ -74,6 +74,28 @@ class TextAttributesConverter {
return attrib;
}

/**
* 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

Loading…
Cancel
Save