// 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.
// LOGGER.debug("Variables-Section with new Master-Page " + variables + " " + masterPageName);
final OfficeStyle style = deriveStyle(OfficeToken.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, OfficeToken.P, OfficeToken.STYLE_NAME, style.getStyleName(), XmlWriterSupport.OPEN);
masterPageName = null;
//breakDefinition = null;
}
else if (isColumnBreakPending())
{
setColumnBreakPending(false);
final OfficeStyle style = deriveStyle(OfficeToken.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, OfficeToken.P, OfficeToken.STYLE_NAME, style.getStyleName(), XmlWriterSupport.OPEN);
}
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.
// LOGGER.debug("Variables-Section " + variables);
StyleUtilities.copyStyle(OfficeToken.PARAGRAPH,
TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, getStylesCollection(),
getGlobalStylesCollection(), getPredefinedStylesCollection());
xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, OfficeToken.P, OfficeToken.STYLE_NAME,
TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, XmlWriterSupport.OPEN);
}
xmlWriter.writeText(variables);
xmlWriter.writeCloseTag();
variables = null;
}
final boolean keepWithNext = isKeepTableWithNext();
final boolean localKeepTogether = OfficeToken.TRUE.equals(attrs.getAttribute(OfficeNamespaces.OOREPORT_NS, KEEP_TOGETHER));
final boolean tableMergeActive = isTableMergeActive();
this.sectionKeepTogether = tableMergeActive && localKeepTogether;
// Check, whether we have a reason to derive a style...
if (masterPageName != null || (!tableMergeActive && (localKeepTogether || keepWithNext)) || isColumnBreakPending())
{
final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME);
final OfficeStyle style = deriveStyle("table", styleName);
if (masterPageName != null)
{
// LOGGER.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)
{
if (localKeepTogether)
{
final Element tableProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, TABLE_PROPERTIES);
tableProps.setAttribute(OfficeNamespaces.STYLE_NS, MAY_BREAK_BETWEEN_ROWS, OfficeToken.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)
{
boolean addKeepWithNext = true;
if (currentRole == ROLE_GROUP_FOOTER)
{
addKeepWithNext = isParentKeepTogether();
}
final Element tableProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, TABLE_PROPERTIES);
tableProps.setAttribute(OfficeNamespaces.STYLE_NS, MAY_BREAK_BETWEEN_ROWS, OfficeToken.FALSE);
if (addKeepWithNext)
{
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 ..
}
}
attrs.setAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.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)
{
if (keepWithNext)
{
final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME);
final OfficeStyle style = deriveStyle(OfficeToken.TABLE, styleName);
final Element tableProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, TABLE_PROPERTIES);
// 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, OfficeToken.FALSE);
final String hasGroupFooter = (String) attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, "has-group-footer");
if (hasGroupFooter != null && hasGroupFooter.equals(OfficeToken.TRUE))
{
tableProps.setAttribute(OfficeNamespaces.FO_NS, KEEP_WITH_NEXT, ALWAYS);
}
attrs.setAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME, style.getStyleName());
}
detailBandProcessingState = DETAIL_SECTION_FIRST_STARTED;
}
else if (detailBandProcessingState == DETAIL_SECTION_FIRST_PRINTED)
{