Class PropertyResolver

java.lang.Object
org.docx4j.model.PropertyResolver
Direct Known Subclasses:
ImmutablePropertyResolver

public class PropertyResolver extends Object
This class works out the actual set of properties (paragraph or run) which apply, following the order specified in ECMA-376. From ECMA-376 > Part3 > 2 Introduction to WordprocessingML > 2.8 Styles > 2.8.10 Style Application at http://www.documentinteropinitiative.org/implnotes/ecma-376/P3-2.8.10.aspx (See also Part 4, 2.7.2 which is the normative bit...) With the various flavors of styles available, multiple style types can be applied to the same content within a file, which means that properties must be applied in a specific deterministic order. As with inheritance, the resulting formatting properties set by one type can be unchanged, removed, or altered by following types. The following table illustrates the order of application of these defaults, and which properties are impacted by each: This process can be described as follows: First, the document defaults are applied to all runs and paragraphs in the document. Next, the table style properties are applied to each table in the document, following the conditional formatting inclusions and exclusions specified per table. Next, numbered item and paragraph properties are applied to each paragraph formatted with a numbering style. Next, paragraph and run properties are applied to each paragraph as defined by the paragraph style. Next, run properties are applied to each run with a specific character style applied. Finally, we apply direct formatting (paragraph or run properties not from styles). ----------- Things which are unclear: - the role of w:link on a paragraph style (eg Heading1 links to "Heading1char"), experimentation in Word 2007 suggests the w:link is not used at all - indeed, "Heading1char" is not used at all? ----------- docx4all does not use this; its org.docx4all.swing.text.StyleSheet uses MutableAttributeSet's resolve function to climb the style hierarchy. This is most relevant to XSLFO, which unlike CSS, doesn't have a concept of style. HTML NG2 uses CSS inheritance, and so doesn't need it.
  • Field Details

    • log

      private static org.slf4j.Logger log
    • documentDefaultPPr

      private PPr documentDefaultPPr
    • documentDefaultRPr

      private RPr documentDefaultRPr
    • styleDefinitionsPart

      private StyleDefinitionsPart styleDefinitionsPart
    • wordMLPackage

      private WordprocessingMLPackage wordMLPackage
    • styles

      private Styles styles
      All styles in the Style Definitions Part.
    • liveStyles

      private Map<String,Style> liveStyles
      Map of all styles in the Style Definitions Part. Note, you need to manually keep this up to date
    • themePart

      private ThemePart themePart
    • numberingDefinitionsPart

      private NumberingDefinitionsPart numberingDefinitionsPart
    • resolvedStylePPrComponent

      private Map<String,PPr> resolvedStylePPrComponent
    • resolvedStyleRPrComponent

      private Map<String,RPr> resolvedStyleRPrComponent
      This map also contains the rPr component of a pPr
    • themeFontLang

      CTLanguage themeFontLang
    • defaultParagraphStyleId

      String defaultParagraphStyleId
    • defaultCharacterStyleId

      String defaultCharacterStyleId
    • factory

      ObjectFactory factory
    • HEADING_STYLE

      private static final String HEADING_STYLE
      See Also:
  • Constructor Details

  • Method Details

    • getDocumentDefaultRPr

      public RPr getDocumentDefaultRPr()
    • getDocumentDefaultPPr

      public PPr getDocumentDefaultPPr()
    • init

      private void init() throws Docx4JException
      Throws:
      Docx4JException
    • addNormalToResolvedStylePPrComponent

      private void addNormalToResolvedStylePPrComponent()
      Add the effective properties of Normal style to resolvedStylePPrComponent.
    • addDefaultParagraphFontToResolvedStyleRPrComponent

      private void addDefaultParagraphFontToResolvedStyleRPrComponent()
    • getEffectiveTableStyle

      public Style getEffectiveTableStyle(TblPr tblPr)
    • fillTableStyleStack

      private void fillTableStyleStack(String styleId, Stack<Style> tableStyleStack)
      Ascend the style hierarchy, capturing the table styles
      Parameters:
      stylename -
      effectivePPr -
    • getEffectivePPr

      public PPr getEffectivePPr(PPr expressPPr)
      Follow the resolution rules to return the paragraph properties which actually apply, given this pPr element (on a w:p). Note 1: the properties are not the definition of any style name returned. Note 2: run properties are not resolved or returned by this method. What is returned is a live object. If you want to change it, you should clone it first!
      Parameters:
      expressPPr -
      Returns:
    • getEffectivePPr

      public PPr getEffectivePPr(String styleId)
      Follow the resolution rules to return the paragraph properties which actually apply, given this paragraph style Note 1: the properties are not the definition of any style name returned. Note 2: run properties are not resolved or returned by this method. What is returned is a live object. If you want to change it, you should clone it first!
      Parameters:
      expressPPr -
      Returns:
    • getEffectiveRPr

      public RPr getEffectiveRPr(RPr expressRPr, PPr pPr)
      Parameters:
      expressRPr -
      pPr - -
      Returns:
    • getEffectiveRPrUsingPStyleRPr

      public RPr getEffectiveRPrUsingPStyleRPr(RPr expressRPr, RPr rPrFromPStyle)
      Return effective rPr, as follows: Starting with the rPr from the pStyle, apply character style (if any) specified on the run, then any other direct (ad-hoc) run formatting.
      Parameters:
      expressRPr -
      rPrFromPStyle - should be rPr from the paragraph style (as opposed to rPr in the direct pPr, which is only relevant to the paragraph mark)
      Returns:
    • getEffectiveRPr

      public RPr getEffectiveRPr(String styleId)
      apply the rPr in the stack of styles, including documentDefaultRPr
      Parameters:
      styleId -
      Returns:
    • getEffectiveRPr

      public RPr getEffectiveRPr(String styleId, boolean applyDocDefaultsRFonts, boolean applyDocDefaultsSz, boolean applyDocDefaultsLang)
      apply the rPr in the stack of styles, optionally including documentDefaultRPr
      Parameters:
      styleId -
      Returns:
      Since:
      8.2.4
    • newBooleanDefaultTrue

      private BooleanDefaultTrue newBooleanDefaultTrue(boolean val)
    • hasDirectPPrFormatting

      private boolean hasDirectPPrFormatting(PPr pPrToApply)
    • applyPPr

      protected void applyPPr(PPr pPrToApply, PPr effectivePPr)
    • hasDirectRPrFormatting

      public boolean hasDirectRPrFormatting(RPr rPrToApply)
    • hasDirectRPrFormatting

      private boolean hasDirectRPrFormatting(ParaRPr rPrToApply)
    • applyRPr

      protected void applyRPr(RPr rPrToApply, RPr effectiveRPr)
    • applyRPr

      protected void applyRPr(ParaRPr rPrToApply, RPr effectiveRPr)
    • getLvlFromHeadingStyle

      public int getLvlFromHeadingStyle(String style)
    • fillPPrStack

      private void fillPPrStack(String styleId, Stack<PPr> pPrStack)
      Ascend (recursively) the style hierarchy, capturing the pPr bit. Doesn't use StyleTree.
      Parameters:
      stylename -
      effectivePPr -
    • fillRPrStack

      private void fillRPrStack(String styleId, Stack<RPr> rPrStack)
      Ascend the style hierarchy, capturing the rPr bit
      Parameters:
      stylename -
      effectivePPr -
    • initialiseLiveStyles

      private void initialiseLiveStyles()
    • activateStyle

      public boolean activateStyle(String styleId)
    • activateStyle

      public boolean activateStyle(Style s)
    • activateStyle

      private boolean activateStyle(Style s, boolean replace)
    • getStyle

      public Style getStyle(String styleId)