/** {@inheritDoc} */
 @Override
 public void resolveReferences(final LayoutMasterSet layoutMasterSet) throws ValidationException {
   this.master = layoutMasterSet.getSimplePageMaster(this.masterReference);
   if (this.master == null) {
     BlockLevelEventProducer.Provider.get(getUserAgent().getEventBroadcaster())
         .noMatchingPageMaster(this, this.parent.getName(), this.masterReference, getLocator());
   }
 }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  public List getNextKnuthElements(final LayoutContext context, final int alignment) {

    final List returnList = new LinkedList();

    /*
     * Compute the IPD and adjust it if necessary (overconstrained)
     */
    this.referenceIPD = context.getRefIPD();
    if (getTable().getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) {
      final int contentIPD =
          getTable().getInlineProgressionDimension().getOptimum(this).getLength().getValue(this);
      updateContentAreaIPDwithOverconstrainedAdjust(contentIPD);
    } else {
      if (!getTable().isAutoLayout()) {
        final BlockLevelEventProducer eventProducer =
            BlockLevelEventProducer.Provider.get(getTable().getUserAgent().getEventBroadcaster());
        eventProducer.tableFixedAutoWidthNotSupported(this, getTable().getLocator());
      }
      updateContentAreaIPDwithOverconstrainedAdjust();
    }
    final int sumOfColumns = this.columns.getSumOfColumnWidths(this);
    if (!this.autoLayout && sumOfColumns > getContentAreaIPD()) {
      log.debug(
          FONode.decorateWithContextInfo(
              "The sum of all column widths is larger than the specified table width.",
              getTable()));
      updateContentAreaIPDwithOverconstrainedAdjust(sumOfColumns);
    }
    final int availableIPD = this.referenceIPD - getIPIndents();
    if (getContentAreaIPD() > availableIPD) {
      final BlockLevelEventProducer eventProducer =
          BlockLevelEventProducer.Provider.get(getTable().getUserAgent().getEventBroadcaster());
      eventProducer.objectTooWide(
          this,
          getTable().getName(),
          getContentAreaIPD(),
          context.getRefIPD(),
          getTable().getLocator());
    }

    /*
     * initialize unit to determine computed values for
     * proportional-column-width()
     */
    if (this.tableUnit == 0.0) {
      this.tableUnit = this.columns.computeTableUnit(this);
    }

    if (!this.firstVisibleMarkServed) {
      addKnuthElementsForSpaceBefore(returnList, alignment);
    }

    if (getTable().isSeparateBorderModel()) {
      addKnuthElementsForBorderPaddingBefore(returnList, !this.firstVisibleMarkServed);
      this.firstVisibleMarkServed = true;
      // Border and padding to be repeated at each break
      // This must be done only in the separate-border model, as in
      // collapsing
      // tables have no padding and borders are determined at the cell
      // level
      addPendingMarks(context);
    }

    // Elements for the table-header/footer/body
    List contentKnuthElements;
    this.contentLM = new TableContentLayoutManager(this);
    final LayoutContext childLC = new LayoutContext(0);
    /*
     * childLC.setStackLimit( MinOptMax.subtract(context.getStackLimit(),
     * stackSize));
     */
    childLC.setRefIPD(context.getRefIPD());
    childLC.copyPendingMarksFrom(context);

    contentKnuthElements = this.contentLM.getNextKnuthElements(childLC, alignment);
    // Set index values on elements coming from the content LM
    final Iterator iter = contentKnuthElements.iterator();
    while (iter.hasNext()) {
      final ListElement el = (ListElement) iter.next();
      notifyPos(el.getPosition());
    }
    // TODO fixme : don't toString() a list...
    log.debug(contentKnuthElements.toString());
    wrapPositionElements(contentKnuthElements, returnList);

    context.updateKeepWithPreviousPending(getKeepWithPrevious());
    context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());

    context.updateKeepWithNextPending(getKeepWithNext());
    context.updateKeepWithNextPending(childLC.getKeepWithNextPending());

    if (getTable().isSeparateBorderModel()) {
      addKnuthElementsForBorderPaddingAfter(returnList, true);
    }
    addKnuthElementsForSpaceAfter(returnList, alignment);

    if (!context.suppressBreakBefore()) {
      // addKnuthElementsForBreakBefore(returnList, context);
      final int breakBefore =
          BreakUtil.compareBreakClasses(getTable().getBreakBefore(), childLC.getBreakBefore());
      if (breakBefore != Constants.EN_AUTO) {
        returnList.add(
            0,
            new BreakElement(
                getAuxiliaryPosition(), 0, -KnuthElement.INFINITE, breakBefore, context));
      }
    }

    // addKnuthElementsForBreakAfter(returnList, context);
    final int breakAfter =
        BreakUtil.compareBreakClasses(getTable().getBreakAfter(), childLC.getBreakAfter());
    if (breakAfter != Constants.EN_AUTO) {
      returnList.add(
          new BreakElement(getAuxiliaryPosition(), 0, -KnuthElement.INFINITE, breakAfter, context));
    }

    setFinished(true);
    resetSpaces();
    return returnList;
  }