// If we have a manual pagebreak, then activate the current master-page again.
masterPageName = currentMasterPage.getStyleName();
}
}
final XmlWriter xmlWriter = getXmlWriter();
if (detailBandProcessingState == DETAIL_SECTION_OTHER_PRINTED &&
masterPageName != null)
{
// close the last table-tag, we will open a new one
xmlWriter.writeCloseTag();
// Reset the detail-state to 'started' so that the table's columns get printed now.
detailBandProcessingState = DETAIL_SECTION_OTHER_STARTED;
}
if (tableLayoutConfig == TABLE_LAYOUT_VARIABLES_PARAGRAPH && variables != null)
{
if (masterPageName != null)
{
// write a paragraph that uses the VARIABLES_HIDDEN_STYLE as
// primary style. Derive that one and add the manual pagebreak.
// The predefined style already has the 'keep-together' flags set.
// Log.debug("Variables-Section with new Master-Page " + variables + " " + masterPageName);
final OfficeStyle style = deriveStyle("paragraph", TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT);
style.setAttribute(OfficeNamespaces.STYLE_NS, "master-page-name", masterPageName);
if (breakDefinition.isResetPageNumber())
{
final Element paragraphProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "paragraph-properties");
paragraphProps.setAttribute(OfficeNamespaces.STYLE_NS, "page-number", "1");
}
if (isColumnBreakPending())
{
final Element paragraphProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "paragraph-properties");
paragraphProps.setAttribute(OfficeNamespaces.FO_NS, "break-before", "column");
setColumnBreakPending(false);
}
xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, "p", "style-name", style.getStyleName(), XmlWriterSupport.OPEN);
xmlWriter.writeText(variables);
xmlWriter.writeCloseTag();
variables = null;
masterPageName = null;
breakDefinition = null;
}
else if (isColumnBreakPending())
{
setColumnBreakPending(false);
final OfficeStyle style = deriveStyle("paragraph", TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT);
final Element paragraphProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "paragraph-properties");
paragraphProps.setAttribute(OfficeNamespaces.STYLE_NS, "page-number", "1");
xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, "p", "style-name", style.getStyleName(), XmlWriterSupport.OPEN);
xmlWriter.writeText(variables);
xmlWriter.writeCloseTag();
variables = null;
}
else
{
// Write a paragraph without adding the pagebreak. We can reuse the global style, but we have to make
// sure that the style is part of the current 'auto-style' collection.
// Log.debug("Variables-Section " + variables);
StyleUtilities.copyStyle("paragraph",
TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, getStylesCollection(),
getGlobalStylesCollection(), getPredefinedStylesCollection());
xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, "p", "style-name",
TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, XmlWriterSupport.OPEN);
xmlWriter.writeText(variables);
xmlWriter.writeCloseTag();
variables = null;
}
}
final boolean keepWithNext = isKeepTableWithNext();
final boolean localKeepTogether = "true".equals
(attrs.getAttribute(OfficeNamespaces.OOREPORT_NS, "keep-together"));
final boolean tableMergeActive = isTableMergeActive();
if (tableMergeActive == false)
{
this.sectionKeepTogether = false;
}
else
{
this.sectionKeepTogether = localKeepTogether;
}
// Check, whether we have a reason to derive a style...
if (masterPageName != null ||
(tableMergeActive == false && (localKeepTogether || keepWithNext)) || isColumnBreakPending())
{
final String styleName = (String)
attrs.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
final OfficeStyle style = deriveStyle("table", styleName);
if (masterPageName != null)
{
// Log.debug("Starting a new MasterPage: " + masterPageName);
// Patch the current styles.
// This usually only happens on Table-Styles or Paragraph-Styles
style.setAttribute(OfficeNamespaces.STYLE_NS, "master-page-name", masterPageName);
if (breakDefinition.isResetPageNumber())
{
final Element paragraphProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "paragraph-properties");
paragraphProps.setAttribute(OfficeNamespaces.STYLE_NS, "page-number", "1");
}
}
if (isColumnBreakPending())
{
final Element paragraphProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "paragraph-properties");
paragraphProps.setAttribute(OfficeNamespaces.FO_NS, "break-before", "column");
setColumnBreakPending(false);
}
// Inhibit breaks inside the table only if it has been defined and if we do not create one single
// big detail section. In that case, this flag would be invalid and would cause layout-errors.
if (tableMergeActive == false)
{
if (localKeepTogether)
{
final Element tableProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "table-properties");
tableProps.setAttribute(OfficeNamespaces.STYLE_NS, "may-break-between-rows", "false");
}
}
else
{
if (detailBandProcessingState == DETAIL_SECTION_WAIT)
{
detailBandProcessingState = DETAIL_SECTION_FIRST_STARTED;
}
else if (detailBandProcessingState == DETAIL_SECTION_FIRST_PRINTED)
{
detailBandProcessingState = DETAIL_SECTION_OTHER_STARTED;
}
}
if (keepWithNext)
{
final Element tableProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "table-properties");
tableProps.setAttribute(OfficeNamespaces.FO_NS, "keep-with-next", "always");
// A keep-with-next does not work, if the may-break-betweek rows is not set to false ..
tableProps.setAttribute(OfficeNamespaces.STYLE_NS, "may-break-between-rows", "false");
}
attrs.setAttribute(OfficeNamespaces.TABLE_NS, "style-name", style.getStyleName());
// no need to copy the styles, this was done while deriving the
// style ..
}
else
{
// Check, whether we may be able to skip the table.
if (tableMergeActive)
{
if (detailBandProcessingState == DETAIL_SECTION_OTHER_PRINTED)
{
// Skip the whole thing ..
return;
}
else if (detailBandProcessingState == DETAIL_SECTION_WAIT)
{
detailBandProcessingState = DETAIL_SECTION_FIRST_STARTED;
}
else if (detailBandProcessingState == DETAIL_SECTION_FIRST_PRINTED)
{
detailBandProcessingState = DETAIL_SECTION_OTHER_STARTED;
}
}
// process the styles as usual
performStyleProcessing(attrs);
}
final String namespace = ReportTargetUtil.getNamespaceFromAttribute(attrs);
final String elementType = ReportTargetUtil.getElemenTypeFromAttribute(attrs);
final AttributeList attrList = buildAttributeList(attrs);
xmlWriter.writeTag(namespace, elementType, attrList, XmlWriterSupport.OPEN);
}