Class PropertyResolver

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

public class PropertyResolver
extends java.lang.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.
Author:
jharrop
  • Constructor Details

  • Method Details

    • getDocumentDefaultRPr

      public RPr getDocumentDefaultRPr()
    • getDocumentDefaultPPr

      public PPr getDocumentDefaultPPr()
    • getEffectiveTableStyle

      public Style getEffectiveTableStyle​(TblPr tblPr)
    • 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​(java.lang.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​(java.lang.String styleId)
      apply the rPr in the stack of styles, including documentDefaultRPr
      Parameters:
      styleId -
      Returns:
    • getEffectiveRPr

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

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

      public boolean hasDirectRPrFormatting​(RPr rPrToApply)
    • applyRPr

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

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

      public int getLvlFromHeadingStyle​(java.lang.String style)
    • activateStyle

      public boolean activateStyle​(java.lang.String styleId)
    • activateStyle

      public boolean activateStyle​(Style s)
    • getStyle

      public Style getStyle​(java.lang.String styleId)