Beispiel #1
0
  /**
   * @see de.dante.extex.interpreter.type.Code#execute( de.dante.extex.interpreter.Flags,
   *     de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource,
   *     de.dante.extex.typesetter.Typesetter)
   */
  public void execute(
      final Flags prefix,
      final Context context,
      final TokenSource source,
      final Typesetter typesetter)
      throws InterpreterException {

    Mode mode = typesetter.getMode();
    if (!mode.isHmode()) {
      throw new CantUseInException(printableControlSequence(context), mode.toString());
    }
    Flags flags = prefix.copy();
    prefix.clear();
    Box b =
        new Box(
            context, source, typesetter, false, null, GroupType.VBOX_GROUP, source.getLastToken());

    try {
      typesetter.add(new AdjustNode(b.getNodes()));
    } catch (TypesetterException e) {
      throw new InterpreterException(e);
    } catch (ConfigurationException e) {
      throw new InterpreterException(e);
    }
    prefix.set(flags);
  }
Beispiel #2
0
  /**
   * @see de.dante.extex.interpreter.type.Code#execute( de.dante.extex.interpreter.Flags,
   *     de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource,
   *     de.dante.extex.typesetter.Typesetter)
   */
  public void execute(
      final Flags prefix,
      final Context context,
      final TokenSource source,
      final Typesetter typesetter)
      throws InterpreterException {

    CodeToken cs = source.getControlSequence(context);
    Code code = context.getCode(cs);

    if (code == null) {
      throw new UndefinedControlSequenceException(printable(context, cs));
    }

    boolean horizontal;

    Node node = null;
    if (code instanceof Boxable) {
      Box b = ((Boxable) code).getBox(context, source, typesetter);
      node = b.getNodes();
      horizontal = b.isHbox();
    } else if (code instanceof RuleConvertible) {
      node = ((RuleConvertible) code).getRule(context, source, typesetter);
      horizontal = ((RuleNode) node).isHorizontal();
    } else {
      throw new HelpingException(getLocalizer(), "TTP.BoxExpected");
    }

    CodeToken vskip = source.getControlSequence(context);
    code = context.getCode(vskip);

    if (code == null) {
      throw new UndefinedControlSequenceException( //
          context.esc(vskip.getName()));
    }

    FixedGlue skip;

    if (horizontal) {
      if (!(code instanceof HorizontalSkip)) {
        throw new HelpingException(getLocalizer(), "TTP.BadGlueAfterLeaders");
      }
      skip = ((HorizontalSkip) code).getGlue(context, source, typesetter);
    } else {
      if (!(code instanceof VerticalSkip)) {
        throw new HelpingException(getLocalizer(), "TTP.BadGlueAfterLeaders");
      }
      skip = ((VerticalSkip) code).getGlue(context, source, typesetter);
    }

    try {
      typesetter.add(new CenteredLeadersNode(node, skip, horizontal));
    } catch (TypesetterException e) {
      throw new InterpreterException(e);
    } catch (ConfigurationException e) {
      throw new InterpreterException(e);
    }
  }