protected void processText(
      final ReportElement element, String computedValue, final Object rawValue) {
    final SimpleStyleSheet resolverStyleSheet = element.getComputedStyle();
    if (computedValue != null
        && resolverStyleSheet.getBooleanStyleProperty(TextStyleKeys.TRIM_TEXT_CONTENT)) {
      computedValue = computedValue.trim();
    }

    if (this.context.getRenderBox().isAcceptInlineBoxes() == false) {
      final StyleSheet elementStyle;
      final int parentNodeType = this.context.getRenderBox().getLayoutNodeType();
      if (strictLegacyMode
          && (parentNodeType & LayoutNodeTypes.MASK_BOX_CANVAS)
              == LayoutNodeTypes.MASK_BOX_CANVAS) {
        // A table always claims all elements as dynamic. Use the max-height to limit the expansion
        // of elements.
        if (isTableContext(this.context.getRenderBox()) == false
            && resolverStyleSheet.getBooleanStyleProperty(ElementStyleKeys.DYNAMIC_HEIGHT)
                == false) {
          elementStyle = new NonDynamicHeightWrapperStyleSheet(resolverStyleSheet);
        } else {
          elementStyle = new DynamicHeightWrapperStyleSheet(resolverStyleSheet);
        }
      } else {
        elementStyle = resolverStyleSheet;
      }

      this.textProducer.startText();

      final RenderBox renderBox =
          renderNodeFactory.createAutoParagraph(element, elementStyle, stateKey);
      final RenderNode[] renderNodes =
          textProducer.getRenderNodes(element, elementStyle, computedValue);
      renderBox.addChilds(renderNodes);
      renderBox.setRawValue(rawValue);

      this.context = new DefaultLayoutModelBuilderContext(this.context, renderBox);
      this.context.setEmpty(
          renderNodes.length == 0 && isEmptyElement(element, resolverStyleSheet, metaData));
      this.context = this.context.close();
    } else {
      final StyleSheet safeElementStyle = renderNodeFactory.createStyle(resolverStyleSheet);
      final RenderBox renderBox =
          renderNodeFactory.produceRenderBox(
              element, resolverStyleSheet, BandStyleKeys.LAYOUT_INLINE, stateKey);
      final RenderNode[] renderNodes =
          textProducer.getRenderNodes(element, safeElementStyle, computedValue);
      renderBox.addChilds(renderNodes);
      renderBox.setRawValue(rawValue);

      this.context = new DefaultLayoutModelBuilderContext(this.context, renderBox);
      this.context.setEmpty(
          renderNodes.length == 0 && isEmptyElement(element, resolverStyleSheet, metaData));
      this.context = this.context.close();
    }
  }
  public void addManualPageBreakBox(final long range) {
    final RenderBox breakIndicatorBox =
        renderNodeFactory.createPageBreakIndicatorBox(stateKey, range);

    this.context.addChild(breakIndicatorBox);
    this.context.setEmpty(false);
  }
 public InstanceID createSubflowPlaceholder(final ReportElement element) {
   final StyleSheet resolverStyleSheet = element.getComputedStyle();
   final RenderBox subReportBox =
       renderNodeFactory.produceSubReportPlaceholder(element, resolverStyleSheet, stateKey);
   this.context.addChild(subReportBox);
   this.context.setEmpty(false);
   return subReportBox.getInstanceId();
 }
 private void ensureEmptyChildIsAdded(final RenderBox parent, final ReportElement element) {
   final StyleSheet resolverStyleSheet = element.getComputedStyle();
   final RenderBox box;
   if (parent.isAcceptInlineBoxes()) {
     box =
         renderNodeFactory.produceRenderBox(
             element, resolverStyleSheet, BandStyleKeys.LAYOUT_INLINE, getStateKey());
   } else {
     box =
         renderNodeFactory.produceRenderBox(
             element, resolverStyleSheet, BandStyleKeys.LAYOUT_BLOCK, getStateKey());
   }
   box.getStaticBoxLayoutProperties()
       .setPlaceholderBox(StaticBoxLayoutProperties.PlaceholderType.SECTION);
   box.close();
   parent.addChild(box);
 }
  public void startSection(final ReportElement element, final int sectionSize) {
    final StyleSheet resolverStyleSheet = element.getComputedStyle();
    final String layoutMode;
    final boolean legacyMode =
        metaData.isFeatureSupported(OutputProcessorFeature.STRICT_COMPATIBILITY);
    if (legacyMode) {
      layoutMode = BandStyleKeys.LAYOUT_BLOCK;
    } else {
      String layout =
          (String)
              resolverStyleSheet.getStyleProperty(BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_AUTO);
      if (BandStyleKeys.LAYOUT_INLINE.equals(layout)
          && !this.context.getRenderBox().isAcceptInlineBoxes()) {
        layoutMode = BandStyleKeys.LAYOUT_BLOCK;
      } else {
        layoutMode = layout;
      }
    }

    final GroupSection groupSection =
        new GroupSection(
            renderNodeFactory.produceRenderBox(element, resolverStyleSheet, layoutMode, null),
            renderNodeFactory.createAutoGeneratedSectionStyleSheet(resolverStyleSheet),
            sectionSize,
            legacyMode);
    this.context = new SectionLayoutModelBuilderContext(this.context, groupSection, legacyMode);
    this.context.setEmpty(true);

    if (element instanceof GroupBody || element instanceof Group) {
      // PRD-3154 - do we need to set placeholder to true?
      // todo: PRD-3154: This is black magic, placeholder box true is evil.
      // Need to evaluate side-effects of this beast. Is it safe for keep-together boxes?
      this.context
          .getRenderBox()
          .getStaticBoxLayoutProperties()
          .setPlaceholderBox(StaticBoxLayoutProperties.PlaceholderType.SECTION);
    }
    this.textProducer.startText();
  }
  public void startSubFlow(final ReportElement element) {
    final StyleSheet resolverStyleSheet = element.getComputedStyle();

    final RenderBox box;
    if (metaData.isFeatureSupported(OutputProcessorFeature.STRICT_COMPATIBILITY)) {
      final StyleSheet styleSheet =
          new SubReportStyleSheet(
              resolverStyleSheet.getBooleanStyleProperty(BandStyleKeys.PAGEBREAK_BEFORE),
              (resolverStyleSheet.getBooleanStyleProperty(BandStyleKeys.PAGEBREAK_AFTER)));

      final SimpleStyleSheet reportStyle = new SimpleStyleSheet(styleSheet);
      final BoxDefinition boxDefinition = renderNodeFactory.getBoxDefinition(reportStyle);
      box =
          new BlockRenderBox(
              reportStyle,
              element.getObjectID(),
              boxDefinition,
              SubReportType.INSTANCE,
              element.getAttributes(),
              null);
    } else {
      box =
          renderNodeFactory.produceRenderBox(
              element, resolverStyleSheet, BandStyleKeys.LAYOUT_BLOCK, stateKey);
    }

    box.getStaticBoxLayoutProperties()
        .setPlaceholderBox(StaticBoxLayoutProperties.PlaceholderType.SECTION);
    if (element.getName() != null) {
      box.setName("Banded-SubReport-Section" + ": name=" + element.getName());
    } else {
      box.setName("Banded-SubReport-Section");
    }

    pushBoxToContext(box, false);
  }
  public InlineSubreportMarker processSubReport(final SubReport element) {
    if (isLimitedSubReports()) {
      logger.debug("Not adding subreport: Subreports in header or footer area are not allowed.");
      return null;
    }

    final RenderBox parentBox = this.context.getRenderBox();
    if (parentBox.isAcceptInlineBoxes()) {
      logger.warn("Not adding subreport: Subreports in inline-contexts are not supported.");
      return null;
    }

    final StyleSheet resolverStyleSheet = element.getComputedStyle();
    final RenderBox subReportBox =
        renderNodeFactory.produceSubReportPlaceholder(element, resolverStyleSheet, stateKey);
    this.context.addChild(subReportBox);
    this.context.setEmpty(false);
    final InstanceID subReportBoxId = subReportBox.getInstanceId();
    // the box will be closed
    return new InlineSubreportMarker(element, subReportBoxId, SubReportProcessType.INLINE);
  }
  protected void processReplacedContent(
      final ReportElement element, final Object value, final Object rawValue) {
    final RenderBox box = this.context.getRenderBox();
    final SimpleStyleSheet resolverStyleSheet = element.getComputedStyle();

    final StyleSheet elementStyle;
    if (box.isAcceptInlineBoxes() == false) {
      if (isTableContext(box) == false
          && resolverStyleSheet.getBooleanStyleProperty(ElementStyleKeys.DYNAMIC_HEIGHT) == false) {
        elementStyle = new NonDynamicReplacedContentStyleSheet(resolverStyleSheet);
      } else {
        elementStyle = new DynamicReplacedContentStyleSheet(resolverStyleSheet);
      }
    } else {
      elementStyle = resolverStyleSheet;
    }

    final RenderableReplacedContentBox child =
        renderNodeFactory.createReplacedContent(element, elementStyle, value, rawValue, stateKey);
    child.setName(element.getName());
    this.context.addChild(child);
    this.context.setEmpty(false);
  }
  public void startSection() {
    final String layoutMode;
    if (metaData.isFeatureSupported(OutputProcessorFeature.STRICT_COMPATIBILITY)) {
      layoutMode = BandStyleKeys.LAYOUT_BLOCK;
    } else {
      layoutMode = BandStyleKeys.LAYOUT_AUTO;
    }

    final RenderBox renderBox = renderNodeFactory.produceSectionBox(layoutMode, null);
    if (isAllowMergeSection()) {
      this.context =
          new BandSectionLayoutModelBuilderContext(this.metaData, this.context, renderBox);
    } else {
      this.context = new DefaultLayoutModelBuilderContext(this.context, renderBox);
    }
    this.context.setEmpty(true);

    if (legacySectionName != null) {
      this.context.getRenderBox().setName(legacySectionName);
    }

    this.textProducer.startText();
  }
  private InstanceID startBox(
      final ReportElement element,
      final StyleSheet styleSheet,
      final String layout,
      final boolean auto) {
    closeAutoGeneratedPostfixBoxes();

    if (BandStyleKeys.LAYOUT_AUTO.equals(layout)) {
      this.context =
          new DefaultLayoutModelBuilderContext(
              this.context,
              renderNodeFactory.produceRenderBox(element, styleSheet, layout, stateKey));
    } else if (BandStyleKeys.LAYOUT_INLINE.equals(layout)) {
      if (this.context.getRenderBox().isAcceptInlineBoxes() == false) {
        // parent context is not a inline-inside context.
        // So we need to create a auto-paragraph wrapper to open a inline-context
        this.context =
            new DefaultLayoutModelBuilderContext(
                this.context, renderNodeFactory.createAutoParagraph(element, styleSheet, stateKey));

        // PRD-3750 - A empty inline-band that creates a auto-paragraph reserves space on the
        // vertical axis.
        if (metaData.isFeatureSupported(OutputProcessorFeature.STRICT_COMPATIBILITY)
            || metaData.isFeatureSupported(OutputProcessorFeature.PRD_3750)) {
          this.context.setAutoGeneratedWrapperBox(true);

          this.context =
              new DefaultLayoutModelBuilderContext(
                  this.context,
                  renderNodeFactory.produceRenderBox(
                      element,
                      styleSheet,
                      DefaultRenderNodeFactory.LAYOUT_PARAGRAPH_LINEBOX,
                      stateKey));
        }
      } else {
        this.context =
            new DefaultLayoutModelBuilderContext(
                this.context,
                renderNodeFactory.produceRenderBox(element, styleSheet, layout, stateKey));
      }
    } else if (this.context.getRenderBox().isAcceptInlineBoxes()) {
      // inline elements only accept inline element childs
      this.context =
          new DefaultLayoutModelBuilderContext(
              this.context,
              renderNodeFactory.produceRenderBox(
                  element, styleSheet, BandStyleKeys.LAYOUT_INLINE, stateKey));
    } else if (BandStyleKeys.LAYOUT_TABLE_CELL.equals(layout)) {
      // a table body always needs a table parent ..
      if (LayoutNodeTypes.TYPE_BOX_TABLE_ROW != this.context.getRenderBox().getLayoutNodeType()) {
        startBox(
            element,
            renderNodeFactory.createAutoGeneratedSectionStyleSheet(styleSheet),
            BandStyleKeys.LAYOUT_TABLE_ROW,
            true);
      }
      this.context =
          new DefaultLayoutModelBuilderContext(
              this.context,
              renderNodeFactory.produceRenderBox(element, styleSheet, layout, stateKey));
    } else if (BandStyleKeys.LAYOUT_TABLE_ROW.equals(layout)) {
      // a table body always needs a table parent ..
      if (LayoutNodeTypes.TYPE_BOX_TABLE_SECTION
          != this.context.getRenderBox().getLayoutNodeType()) {
        startBox(
            element,
            renderNodeFactory.createAutoGeneratedSectionStyleSheet(styleSheet),
            BandStyleKeys.LAYOUT_TABLE_BODY,
            true);
      }
      this.context =
          new DefaultLayoutModelBuilderContext(
              this.context,
              renderNodeFactory.produceRenderBox(element, styleSheet, layout, stateKey));
    } else if (BandStyleKeys.LAYOUT_TABLE_BODY.equals(layout)
        || BandStyleKeys.LAYOUT_TABLE_FOOTER.equals(layout)
        || BandStyleKeys.LAYOUT_TABLE_HEADER.equals(layout)) {
      // a table body always needs a table parent ..
      if (LayoutNodeTypes.TYPE_BOX_TABLE != this.context.getRenderBox().getLayoutNodeType()) {
        startBox(
            element,
            renderNodeFactory.createAutoGeneratedSectionStyleSheet(styleSheet),
            BandStyleKeys.LAYOUT_TABLE,
            true);
      }
      this.context =
          new DefaultLayoutModelBuilderContext(
              this.context,
              renderNodeFactory.produceRenderBox(element, styleSheet, layout, stateKey));
    } else {
      // handle ordinary elements, block, canvas, row ..
      this.context =
          new DefaultLayoutModelBuilderContext(
              this.context,
              renderNodeFactory.produceRenderBox(element, styleSheet, layout, stateKey));
    }

    this.context.setAutoGeneratedWrapperBox(auto);
    this.context.setEmpty(isEmptyElement(element, styleSheet, metaData));
    if (!auto) {
      if (isControlBand(styleSheet)) {
        this.context
            .getRenderBox()
            .getStaticBoxLayoutProperties()
            .setPlaceholderBox(StaticBoxLayoutProperties.PlaceholderType.SECTION);
      } else {
        this.context
            .getRenderBox()
            .getStaticBoxLayoutProperties()
            .setPlaceholderBox(StaticBoxLayoutProperties.PlaceholderType.NONE);
      }
    }
    this.textProducer.startText();
    return this.context.getRenderBox().getInstanceId();
  }