private RtfDocumentArea docArea;
private RtfParagraph para;
private boolean warned = false;
- private boolean bPrevHeaderSpecified=false;//true, if there has been a
- //header in any page-sequence
- private boolean bPrevFooterSpecified=false;//true, if there has been a
- //footer in any page-sequence
+ private boolean bPrevHeaderSpecified = false;//true, if there has been a
+ //header in any page-sequence
+ private boolean bPrevFooterSpecified = false;//true, if there has been a
+ //footer in any page-sequence
private boolean bHeaderSpecified = false; //true, if there is a header
//in current page-sequence
private boolean bFooterSpecified = false; //true, if there is a footer
//in current page-sequence
- private BuilderContext m_context = new BuilderContext(null);
+ private BuilderContext builderContext = new BuilderContext(null);
private static final String ALPHA_WARNING = "WARNING: RTF renderer is "
+ "veryveryalpha at this time, see class org.apache.fop.rtf.renderer.RTFHandler";
/**
* Creates a new RTF structure handler.
+ * @param doc the Document for which this RTFHandler is processing
* @param os OutputStream to write to
*/
public RTFHandler(Document doc, OutputStream os) {
public void startPageSequence(PageSequence pageSeq) {
try {
sect = docArea.newSection();
- m_context.pushContainer(sect);
+ builderContext.pushContainer(sect);
- bHeaderSpecified=false;
- bFooterSpecified=false;
+ bHeaderSpecified = false;
+ bFooterSpecified = false;
} catch (IOException ioe) {
// FIXME could we throw Exception in all FOInputHandler events?
log.error("startPageSequence: " + ioe.getMessage());
* @see org.apache.fop.fo.FOInputHandler#endPageSequence(PageSequence)
*/
public void endPageSequence(PageSequence pageSeq) throws FOPException {
- m_context.popContainer();
+ builderContext.popContainer();
}
/**
// if there is no header in current page-sequence but there has been
// a header in a previous page-sequence, insert an empty header.
if (bPrevHeaderSpecified && !bHeaderSpecified) {
- RtfAttributes attr=new RtfAttributes();
+ RtfAttributes attr = new RtfAttributes();
attr.set(RtfBefore.HEADER);
- final IRtfBeforeContainer contBefore = (IRtfBeforeContainer)m_context.getContainer(IRtfBeforeContainer.class,true,this);
+ final IRtfBeforeContainer contBefore =
+ (IRtfBeforeContainer)builderContext.getContainer
+ (IRtfBeforeContainer.class, true, this);
contBefore.newBefore(attr);
}
// if there is no footer in current page-sequence but there has been
// a footer in a previous page-sequence, insert an empty footer.
if (bPrevFooterSpecified && !bFooterSpecified) {
- RtfAttributes attr=new RtfAttributes();
+ RtfAttributes attr = new RtfAttributes();
attr.set(RtfAfter.FOOTER);
- final IRtfAfterContainer contAfter = (IRtfAfterContainer)m_context.getContainer(IRtfAfterContainer.class,true,this);
+ final IRtfAfterContainer contAfter =
+ (IRtfAfterContainer)builderContext.getContainer
+ (IRtfAfterContainer.class, true, this);
contAfter.newAfter(attr);
}
sect.newParagraph().newText(ALPHA_WARNING);
warned = true;
}
- } else if(fl.getFlowName().equals("xsl-region-before")) {
- bHeaderSpecified=true;
- bPrevHeaderSpecified=true;
+ } else if (fl.getFlowName().equals("xsl-region-before")) {
+ bHeaderSpecified = true;
+ bPrevHeaderSpecified = true;
- final IRtfBeforeContainer c = (IRtfBeforeContainer)m_context.getContainer(IRtfBeforeContainer.class,true,this);
+ final IRtfBeforeContainer c =
+ (IRtfBeforeContainer)builderContext.getContainer(IRtfBeforeContainer.class,
+ true, this);
RtfAttributes beforeAttributes = ((RtfElement)c).getRtfAttributes();
- if ( beforeAttributes == null ) {
+ if (beforeAttributes == null) {
beforeAttributes = new RtfAttributes();
}
beforeAttributes.set(RtfBefore.HEADER);
RtfBefore before = c.newBefore(beforeAttributes);
- m_context.pushContainer(before);
- } else if(fl.getFlowName().equals("xsl-region-after")) {
- bFooterSpecified=true;
- bPrevFooterSpecified=true;
+ builderContext.pushContainer(before);
+ } else if (fl.getFlowName().equals("xsl-region-after")) {
+ bFooterSpecified = true;
+ bPrevFooterSpecified = true;
- final IRtfAfterContainer c = (IRtfAfterContainer)m_context.getContainer(IRtfAfterContainer.class,true,this);
+ final IRtfAfterContainer c =
+ (IRtfAfterContainer)builderContext.getContainer(IRtfAfterContainer.class,
+ true, this);
RtfAttributes afterAttributes = ((RtfElement)c).getRtfAttributes();
- if ( afterAttributes == null ) {
+ if (afterAttributes == null) {
afterAttributes = new RtfAttributes();
}
afterAttributes.set(RtfAfter.FOOTER);
RtfAfter after = c.newAfter(afterAttributes);
- m_context.pushContainer(after);
+ builderContext.pushContainer(after);
}
- } catch(IOException ioe) {
+ } catch (IOException ioe) {
log.error("startFlow: " + ioe.getMessage());
throw new Error(ioe.getMessage());
- } catch(Exception e) {
+ } catch (Exception e) {
log.error("startFlow: " + e.getMessage());
throw new Error(e.getMessage());
}
if (fl.getFlowName().equals("xsl-region-body")) {
//just do nothing
} else if (fl.getFlowName().equals("xsl-region-before")) {
- m_context.popContainer();
+ builderContext.popContainer();
} else if (fl.getFlowName().equals("xsl-region-after")) {
- m_context.popContainer();
+ builderContext.popContainer();
}
- } catch(Exception e){
+ } catch (Exception e) {
log.error("endFlow: " + e.getMessage());
throw new Error(e.getMessage());
}
attrBlockFontWeight(bl, rtfAttr);
IRtfParagraphContainer pc =
- (IRtfParagraphContainer)m_context.getContainer
+ (IRtfParagraphContainer)builderContext.getContainer
(IRtfParagraphContainer.class, true, null);
para = pc.newParagraph(rtfAttr);
- m_context.pushContainer(para);
+ builderContext.pushContainer(para);
} catch (IOException ioe) {
// FIXME could we throw Exception in all FOInputHandler events?
log.error("startBlock: " + ioe.getMessage());
* @see org.apache.fop.fo.FOInputHandler#endBlock(Block)
*/
public void endBlock(Block bl) {
- m_context.popContainer();
+ builderContext.popContainer();
}
/**
*/
public void startTable(Table tbl) {
// create an RtfTable in the current table container
- TableContext tableContext = new TableContext(m_context);
+ TableContext tableContext = new TableContext(builderContext);
RtfAttributes atts = new RtfAttributes();
try {
final IRtfTableContainer tc =
- (IRtfTableContainer)m_context.getContainer(IRtfTableContainer.class,
+ (IRtfTableContainer)builderContext.getContainer(IRtfTableContainer.class,
true, null);
- m_context.pushContainer(tc.newTable(atts, tableContext));
+ builderContext.pushContainer(tc.newTable(atts, tableContext));
} catch (Exception e) {
log.error("startTable:" + e.getMessage());
throw new Error(e.getMessage());
}
- m_context.pushTableContext(tableContext);
+ builderContext.pushTableContext(tableContext);
}
/**
* @see org.apache.fop.fo.FOInputHandler#endTable(Table)
*/
public void endTable(Table tbl) {
- m_context.popTableContext();
- m_context.popContainer();
+ builderContext.popTableContext();
+ builderContext.popContainer();
}
/**
*
- * @param th TableColumn that is starting;
+ * @param tc TableColumn that is starting;
*/
public void startColumn(TableColumn tc) {
try {
Integer iWidth = new Integer(tc.getColumnWidth() / 1000);
- m_context.getTableContext().setNextColumnWidth(iWidth.toString() + "pt");
- m_context.getTableContext().setNextColumnRowSpanning(new Integer(0), null);
+ builderContext.getTableContext().setNextColumnWidth(iWidth.toString() + "pt");
+ builderContext.getTableContext().setNextColumnRowSpanning(new Integer(0), null);
} catch (Exception e) {
log.error("startColumn: " + e.getMessage());
throw new Error(e.getMessage());
/**
*
- * @param th TableColumn that is ending;
+ * @param tc TableColumn that is ending;
*/
public void endColumn(TableColumn tc) {
RtfAttributes atts = TableAttributesConverter.convertRowAttributes (tb.properties,
null, null);
- RtfTable tbl = (RtfTable)m_context.getContainer(RtfTable.class, true, this);
+ RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class, true, this);
tbl.setHeaderAttribs(atts);
} catch (Exception e) {
log.error("startBody: " + e.getMessage());
*/
public void endBody(TableBody tb) {
try {
- RtfTable tbl = (RtfTable)m_context.getContainer(RtfTable.class, true, this);
+ RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class, true, this);
tbl.setHeaderAttribs(null);
} catch (Exception e) {
log.error("endBody: " + e.getMessage());
public void startRow(TableRow tr) {
try {
// create an RtfTableRow in the current RtfTable
- final RtfTable tbl = (RtfTable)m_context.getContainer(RtfTable.class,
+ final RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class,
true, null);
RtfAttributes tblAttribs = tbl.getRtfAttributes();
RtfAttributes atts = TableAttributesConverter.convertRowAttributes(tr.properties,
null, tbl.getHeaderAttribs());
- m_context.pushContainer(tbl.newTableRow(atts));
+ builderContext.pushContainer(tbl.newTableRow(atts));
// reset column iteration index to correctly access column widths
- m_context.getTableContext().selectFirstColumn();
+ builderContext.getTableContext().selectFirstColumn();
} catch (Exception e) {
log.error("startRow: " + e.getMessage());
throw new Error(e.getMessage());
* @see org.apache.fop.fo.FOInputHandler#endRow(TableRow)
*/
public void endRow(TableRow tr) {
- m_context.popContainer();
- m_context.getTableContext().decreaseRowSpannings();
+ builderContext.popContainer();
+ builderContext.getTableContext().decreaseRowSpannings();
}
/**
*/
public void startCell(TableCell tc) {
try {
- TableContext tctx = m_context.getTableContext();
- final RtfTableRow row = (RtfTableRow)m_context.getContainer(RtfTableRow.class,
+ TableContext tctx = builderContext.getTableContext();
+ final RtfTableRow row = (RtfTableRow)builderContext.getContainer(RtfTableRow.class,
true, null);
tctx.setCurrentColumnRowSpanning(new Integer(1), null);
}
- m_context.pushContainer(cell);
+ builderContext.pushContainer(cell);
} catch (Exception e) {
log.error("startCell: " + e.getMessage());
throw new Error(e.getMessage());
* @see org.apache.fop.fo.FOInputHandler#endCell(TableCell)
*/
public void endCell(TableCell tc) {
- m_context.popContainer();
- m_context.getTableContext().selectNextColumn();
+ builderContext.popContainer();
+ builderContext.getTableContext().selectNextColumn();
}
// Lists
public void startPageNumber(PageNumber pagenum) {
try {
//insert page number
- IRtfPageNumberContainer pageNumberContainer = (IRtfPageNumberContainer)m_context.getContainer(IRtfPageNumberContainer.class,true,this);
- m_context.pushContainer(pageNumberContainer.newPageNumber());
+ IRtfPageNumberContainer pageNumberContainer =
+ (IRtfPageNumberContainer)builderContext.getContainer
+ (IRtfPageNumberContainer.class, true, this);
+ builderContext.pushContainer(pageNumberContainer.newPageNumber());
//set Attribute "WhiteSpaceFalse" in order to prevent the rtf library from
//stripping the whitespaces. This applies to whole paragraph.
- if(pageNumberContainer instanceof RtfParagraph) {
- RtfParagraph para=(RtfParagraph)pageNumberContainer;
+ if (pageNumberContainer instanceof RtfParagraph) {
+ RtfParagraph para = (RtfParagraph)pageNumberContainer;
para.getRtfAttributes().set("WhiteSpaceFalse");
}
- } catch(Exception e) {
+ } catch (Exception e) {
log.error("startPageNumber: " + e.getMessage());
throw new Error(e.getMessage());
}
* @param pagenum PageNumber that is ending.
*/
public void endPageNumber(PageNumber pagenum) {
- m_context.popContainer();
+ builderContext.popContainer();
}
}