// Log.debug("Variables-Section in own paragraph " + variables);
StyleUtilities.copyStyle(OfficeToken.PARAGRAPH,
TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, getStylesCollection(),
getGlobalStylesCollection(), getPredefinedStylesCollection());
final XmlWriter xmlWriter = getXmlWriter();
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;
}
if (isTableNS && ObjectUtilities.equal(OfficeToken.TABLE_CELL, elementType))
{
cellEmpty = true;
}
final boolean keepTogetherOnParagraph = true;
if (keepTogetherOnParagraph)
{
if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TEXT_NS, OfficeToken.P, attrs))
{
final int keepTogetherState = getCurrentContext().getKeepTogether();
cellEmpty = false;
if (!firstCellSeen && (sectionKeepTogether || keepTogetherState == PageContext.KEEP_TOGETHER_GROUP))
{
OfficeStyle style = null;
final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TEXT_NS, OfficeToken.STYLE_NAME);
if (styleName == null)
{
final boolean keep = (keepTogetherState == PageContext.KEEP_TOGETHER_GROUP || expectedTableRowCount > 0) && isParentKeepTogether();
final ArrayList propertyNameSpaces = new ArrayList();
final ArrayList propertyNames = new ArrayList();
final ArrayList propertyValues = new ArrayList();
propertyNameSpaces.add(OfficeNamespaces.FO_NS);
propertyNameSpaces.add(OfficeNamespaces.FO_NS);
propertyNames.add(KEEP_TOGETHER);
propertyValues.add(ALWAYS);
if (keep)
{
propertyNames.add(KEEP_WITH_NEXT);
propertyValues.add(ALWAYS);
}
else
{
propertyNames.add(KEEP_WITH_NEXT);
propertyValues.add(null);
}
style = StyleUtilities.queryStyleByProperties(getStylesCollection(), OfficeToken.PARAGRAPH, PARAGRAPH_PROPERTIES, propertyNameSpaces, propertyNames, propertyValues);
}
if (style == null)
{
style = deriveStyle(OfficeToken.PARAGRAPH, styleName);
// Lets set the 'keep-together' flag..
Element paragraphProps = style.getParagraphProperties();
if (paragraphProps == null)
{
paragraphProps = new Section();
paragraphProps.setNamespace(OfficeNamespaces.STYLE_NS);
paragraphProps.setType(PARAGRAPH_PROPERTIES);
style.addNode(paragraphProps);
}
paragraphProps.setAttribute(OfficeNamespaces.FO_NS, KEEP_TOGETHER, ALWAYS);
// We prevent pagebreaks within the two adjacent rows (this one and the next one) if
// either a group-wide keep-together is defined or if we haven't reached the end of the
// current section yet.
if ((keepTogetherState == PageContext.KEEP_TOGETHER_GROUP || expectedTableRowCount > 0) && isParentKeepTogether())
{
paragraphProps.setAttribute(OfficeNamespaces.FO_NS, KEEP_WITH_NEXT, ALWAYS);
}
}
attrs.setAttribute(OfficeNamespaces.TEXT_NS, OfficeToken.STYLE_NAME, style.getStyleName());
}
}
}
if (ObjectUtilities.equal(OfficeNamespaces.DRAWING_NS, namespace) && ObjectUtilities.equal(OfficeToken.FRAME, elementType))
{
final String styleName = (String) attrs.getAttribute(OfficeNamespaces.DRAWING_NS, OfficeToken.STYLE_NAME);
final OfficeStyle predefAutoStyle = getPredefinedStylesCollection().getAutomaticStyles().getStyle(OfficeToken.GRAPHIC, styleName);
if (predefAutoStyle != null)
{
// special ole handling
Element graphicProperties = predefAutoStyle.getGraphicProperties();
graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, VERTICAL_POS, "from-top");
graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, HORIZONTAL_POS, "from-left");
graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "vertical-rel", "paragraph-content");
graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "horizontal-rel", "paragraph");
graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "flow-with-text", "false");
graphicProperties.setAttribute(OfficeNamespaces.DRAWING_NS, "ole-draw-aspect", "1");
// attrs.setAttribute(OfficeNamespaces.DRAWING_NS, OfficeToken.STYLE_NAME, predefAutoStyle.getStyleName());
}
}
// process the styles as usual
performStyleProcessing(attrs);
final XmlWriter xmlWriter = getXmlWriter();
final AttributeList attrList = buildAttributeList(attrs);
xmlWriter.writeTag(namespace, elementType, attrList, XmlWriterSupport.OPEN);
if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TEXT_NS, OfficeToken.P, attrs))
{
cellEmpty = false;
if (tableLayoutConfig != TABLE_LAYOUT_VARIABLES_PARAGRAPH && variables != null)
{
//Log.debug("Variables-Section in existing cell " + variables);
xmlWriter.writeText(variables);
variables = null;
}
}
}
}