示例#1
0
  /**
   * Ascend the style hierarchy, capturing the rPr bit
   *
   * @param stylename
   * @param effectivePPr
   */
  private void fillRPrStack(String styleId, Stack<RPr> rPrStack) {

    // get the style
    Style style = liveStyles.get(styleId);

    // add it to the stack
    if (style == null) {
      // No such style!
      // For now, just log it..
      log.error("Style definition not found: " + styleId);
      return;
    }
    rPrStack.push(style.getRPr());
    log.debug("Added " + styleId + " to pPr stack");

    // if it is based on, recurse
    if (style.getBasedOn() == null) {
      log.debug("Style " + styleId + " is a root style.");
    } else if (style.getBasedOn().getVal() != null) {
      String basedOnStyleName = style.getBasedOn().getVal();
      fillRPrStack(basedOnStyleName, rPrStack);
    } else {
      log.debug("No basedOn set for: " + style.getStyleId());
    }
  }
示例#2
0
  private void addDefaultParagraphFontToResolvedStyleRPrComponent() {
    Stack<RPr> rPrStack = new Stack<RPr>();

    fillRPrStack(defaultParagraphStyleId, rPrStack);
    // Since default font size might be in there.

    fillRPrStack(defaultCharacterStyleId, rPrStack);
    rPrStack.push(documentDefaultRPr);

    RPr effectiveRPr = factory.createRPr();

    // Now, apply the properties starting at the top of the stack
    while (!rPrStack.empty()) {
      RPr rPr = rPrStack.pop();
      applyRPr(rPr, effectiveRPr);
    }
    resolvedStyleRPrComponent.put(defaultCharacterStyleId, effectiveRPr);
  }
示例#3
0
  public RPr getEffectiveRPr(String styleId) {
    // styleId passed in could be a run style
    // or a *paragraph* style

    RPr resolvedRPr = resolvedStyleRPrComponent.get(styleId);

    if (resolvedRPr != null) {
      return resolvedRPr;
    }

    // Hmm, have to do the work
    Style s = liveStyles.get(styleId);

    if (s == null) {
      log.error("Couldn't find style: " + styleId);
      return null;
    }

    // Comment out - this style might not have rPr,
    // but an ancestor might!

    //		RPr expressRPr = s.getRPr();
    //		if (expressRPr==null) {
    //			log.error("style: " + runStyleId + " has no RPr");
    //			resolvedRPr = resolvedStyleRPrComponent.get(defaultCharacterStyleId);
    //			return resolvedRPr;
    //		}

    //	Next, run properties are applied to each run with a specific character style
    //	applied.
    Stack<RPr> rPrStack = new Stack<RPr>();
    // Haven't done this one yet
    fillRPrStack(styleId, rPrStack);
    // Finally, on top
    rPrStack.push(documentDefaultRPr);

    resolvedRPr = factory.createRPr();
    // Now, apply the properties starting at the top of the stack
    while (!rPrStack.empty()) {
      RPr rPr = rPrStack.pop();
      applyRPr(rPr, resolvedRPr);
    }
    resolvedStyleRPrComponent.put(styleId, resolvedRPr);
    return resolvedRPr;
  }