protected void performCloseFile(final String sheetName,
final ReportAttributeMap logicalPageBox,
final WriterService writer)
throws IOException, ContentIOException
{
XmlWriter xmlWriter = writer.getXmlWriter();
xmlWriter.writeCloseTag(); // for the opening table ..
final Object rawFooterContent = logicalPageBox.getAttribute(AttributeNames.Html.NAMESPACE,
AttributeNames.Html.EXTRA_RAW_FOOTER_CONTENT);
if (rawFooterContent != null)
{
xmlWriter.writeText(String.valueOf(rawFooterContent));
}
if (isCreateBodyFragment())
{
xmlWriter.close();
return;
}
ContentItem styleFile = getStyleFile();
if (styleFile != null)
{
final String encoding = getConfiguration().getConfigProperty
(HtmlTableModule.ENCODING, EncodingRegistry.getPlatformDefaultEncoding());
final Writer styleOut = new OutputStreamWriter
(new BufferedOutputStream(styleFile.getOutputStream()), encoding);
getStyleManager().write(styleOut);
styleOut.flush();
styleOut.close();
if (isForceBufferedWriting() == false)
{
// A complete header had been written when the processing started ..
xmlWriter.writeCloseTag(); // for the body tag
xmlWriter.writeCloseTag(); // for the HTML tag
xmlWriter.close();
return;
}
}
if (isInlineStylesRequested())
{
xmlWriter.writeCloseTag(); // for the body tag
xmlWriter.writeCloseTag(); // for the HTML tag
xmlWriter.close();
return;
}
// handle external stylesheets. They need to be injected into the header.
// finish the body fragment
xmlWriter.writeCloseTag(); // for the body ..
xmlWriter.flush();
final XmlWriter docWriter = writer.createHeaderXmlWriter();
if (styleFile != null)
{
// now its time to write the header with the link to the style-sheet-file
writeCompleteHeader(docWriter, sheetName, logicalPageBox, getStyleFileUrl(), null);
}
else
{
writeCompleteHeader(docWriter, sheetName, logicalPageBox, null, getStyleManager());
}
// no need to check for IOExceptions here, as we know the implementation does not create such things
final MemoryStringReader stringReader = writer.getBufferWriter().createReader();
docWriter.writeStream(stringReader);
stringReader.close();
docWriter.writeCloseTag(); // for the html ..
docWriter.close();
}