Class DrawingPropsIdTracker

java.lang.Object
org.docx4j.openpackaging.parts.WordprocessingML.DrawingPropsIdTracker

public class DrawingPropsIdTracker extends Object
wp:docPr/@id must be unique across all parts in a docx, otherwise Word can't open the docx. This problem is difficult to track down if you aren't aware of it, so this class attempts to keep track of Ids in use, and dispense unique values. There is one DocPropIdTracker per package. Relies on Docx4jUnmarshallerListener so is susceptible to those cases where that listener is not listening.
Since:
11.4.6
Author:
jharrop
  • Field Details

    • log

      protected static org.slf4j.Logger log
  • Constructor Details

    • DrawingPropsIdTracker

      public DrawingPropsIdTracker()
  • Method Details

    • registerPart

      public void registerPart(Part part)
      Keep track of parts which are yet to be unmarshalled.
      Parameters:
      part -
    • deregisterPart

      public void deregisterPart(Part part)
      If its been unmarshalled, we'll already know about any docPr ids it may contain, so forget about it.
      Parameters:
      part -
    • registerId

      public void registerId(long num)
    • generateId

      public long generateId() throws Docx4JException
      If this throws an exception, you'll have to create an Id on your own.
      Returns:
      Throws:
      Docx4JException