Class PowerpointParagraph

java.lang.Object
pro.verron.officestamper.experimental.PowerpointParagraph
All Implemented Interfaces:
Paragraph

public class PowerpointParagraph extends Object implements Paragraph

A "Run" defines a region of text within a docx document with a common set of properties. Word processors are relatively free in splitting a paragraph of text into multiple runs, so there is no strict rule to say over how many runs a word or a string of words is spread.

This class aggregates multiple runs so they can be treated as a single text, no matter how many runs the text spans.

Since:
1.0.8
Version:
${version}
Author:
Joseph Verron, Tom Hombergs
  • Constructor Details

    • PowerpointParagraph

      public PowerpointParagraph(PptxPart source, org.docx4j.dml.CTTextParagraph paragraph)
      Constructs a new ParagraphWrapper for the given paragraph.
      Parameters:
      paragraph - the paragraph to wrap.
  • Method Details

    • processorContext

      public ProcessorContext processorContext(Placeholder placeholder)
      Description copied from interface: Paragraph
      Creates a processor context for the given placeholder within this paragraph.
      Specified by:
      processorContext in interface Paragraph
      Parameters:
      placeholder - The placeholder to create a context for.
      Returns:
      The processor context for the specified placeholder.
    • remove

      public void remove()
      Description copied from interface: Paragraph
      Removes the paragraph from the document. This method is intended to be used when a paragraph needs to be deleted.
      Specified by:
      remove in interface Paragraph
    • replace

      public void replace(List<org.docx4j.wml.P> toRemove, List<org.docx4j.wml.P> toAdd)
      Description copied from interface: Paragraph
      Replaces specified contiguous elements within the paragraph with new elements.
      Specified by:
      replace in interface Paragraph
      Parameters:
      toRemove - The list of elements to be removed from the paragraph.
      toAdd - The list of elements to be added to the paragraph.
    • getP

      public org.docx4j.wml.P getP()
      Description copied from interface: Paragraph
      Retrieves the paragraph associated with this object. TODO replace with API not exposing the docx4j API directly
      Specified by:
      getP in interface Paragraph
      Returns:
      the paragraph object
    • replace

      public void replace(Placeholder placeholder, Object replacement)
      Replaces the given expression with the replacement object within the paragraph. The replacement object must be a valid DOCX4J Object.
      Specified by:
      replace in interface Paragraph
      Parameters:
      placeholder - the expression to be replaced.
      replacement - the object to replace the expression.
    • asString

      public String asString()
      Returns the aggregated text over all runs.
      Specified by:
      asString in interface Paragraph
      Returns:
      the text of all runs.
    • apply

      public void apply(Consumer<org.docx4j.wml.P> pConsumer)
      Description copied from interface: Paragraph
      Applies the specified consumer function to the paragraph content.
      Specified by:
      apply in interface Paragraph
      Parameters:
      pConsumer - The consumer function to apply to the paragraph content.
    • getComment

      public Collection<org.docx4j.wml.Comments.Comment> getComment()
      Specified by:
      getComment in interface Paragraph
    • parent

      public <T> Optional<T> parent(Class<T> aClass)
      Description copied from interface: Paragraph
      Retrieves the parent of the current paragraph that matches the specified class type.
      Specified by:
      parent in interface Paragraph
      Type Parameters:
      T - The type of the parent element to be returned.
      Parameters:
      aClass - The class type to match for the parent element.
      Returns:
      An Optional containing the matched parent element if found, otherwise an empty Optional.
    • toString

      public String toString()
      Overrides:
      toString in class Object