public Style realize() {
Style basis = null;
Style next = null;
if (realizedStyle != null)
return realizedStyle;
if (basedOn != STYLENUMBER_NONE) {
StyleDefiningDestination styleDest;
styleDest = (StyleDefiningDestination)definedStyles.get(Integer.valueOf(basedOn));
if (styleDest != null && styleDest != this) {
basis = styleDest.realize();
}
}
/* NB: Swing StyleContext doesn't allow distinct styles with
the same name; RTF apparently does. This may confuse the
user. */
realizedStyle = target.addStyle(styleName, basis);
if (characterStyle) {
realizedStyle.addAttributes(currentTextAttributes());
realizedStyle.addAttribute(Constants.StyleType,
Constants.STCharacter);
} else if (sectionStyle) {
realizedStyle.addAttributes(currentSectionAttributes());
realizedStyle.addAttribute(Constants.StyleType,
Constants.STSection);
} else { /* must be a paragraph style */
realizedStyle.addAttributes(currentParagraphAttributes());
realizedStyle.addAttribute(Constants.StyleType,
Constants.STParagraph);
}
if (nextStyle != STYLENUMBER_NONE) {
StyleDefiningDestination styleDest;
styleDest = (StyleDefiningDestination)definedStyles.get(Integer.valueOf(nextStyle));
if (styleDest != null) {
next = styleDest.realize();
}
}
if (next != null)
realizedStyle.addAttribute(Constants.StyleNext, next);
realizedStyle.addAttribute(Constants.StyleAdditive,
Boolean.valueOf(additive));
realizedStyle.addAttribute(Constants.StyleHidden,
Boolean.valueOf(hidden));
return realizedStyle;
}
|