Docmosis API 4.8.0

com.docmosis.template.analysis
Class TextWritableSafeAreas

java.lang.Object
  extended by com.docmosis.template.analysis.TextWritableSafeAreas
All Implemented Interfaces:
Serializable

public class TextWritableSafeAreas
extends Object
implements Serializable

This class is used to provide information as to locations in a document where information can be injected safely. Most basically, this is inside a paragraph or a span, but of course these can contain other structures where it is not safe to inject content. Consider

 <text:p> 
 here is good
 <text:span>
 here is good too
 <some other XML>
 no good here
 </some other XML>
 good here again (inside the span)
 </text:span>
 good here too (inside the paragraph>
 </text:p>
 
 
So we simply create an array of areas where we know it's safe and this can be tested against a working index later. This allows us to be able to determine if our current stream index is inside or outside of a paragraph. This means we can decide how we need to proceed when injecting content like error messages.

See Also:
Serialized Form

Nested Class Summary
static class TextWritableSafeAreas.ParagraphMapItem
           
 
Constructor Summary
TextWritableSafeAreas()
           
 
Method Summary
 void add(long startIdx, long endIdx, boolean inSpan, boolean hasFrameAncestor, boolean hasShapeAncestor, boolean requiresArtificialParagraph)
          Start recording a writable area immediately after the given end index.
 boolean equals(Object obj)
           
 void finish()
          Finish and optimise for runtime rendering.
 TextWritableSafeAreas.ParagraphMapItem getNextWritableLocation(long startIdx, long endIdx)
          Get the next safe-to-write location starting from the given start and up to the given end.
 TextWritableSafeAreas.ParagraphMapItem getNextWritableLocation(long startIdx, long endIdx, boolean excludeFrames)
          Get the next safe-to-write location starting from the given start and up to the given end, optionally only returning areas that are not within frames.
 TextWritableSafeAreas.ParagraphMapItem getWritableLocation(long idx)
          Determine if the given idx points to a safe-to-write location and if so return information about it.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextWritableSafeAreas

public TextWritableSafeAreas()
Method Detail

add

public void add(long startIdx,
                long endIdx,
                boolean inSpan,
                boolean hasFrameAncestor,
                boolean hasShapeAncestor,
                boolean requiresArtificialParagraph)
Start recording a writable area immediately after the given end index. The start index is required if we need to close of a previous (parent) writable area.

Parameters:
startIdx - the start index of the tag
endIdx - the end index of the tag
inSpan - indicator whether we are inside a span or not
hasFrameAncestor - specify whether the safe area is within a frame
hasFrameAncestor - specify whether the safe area is within a shape
requiresArtificialParagraph - specify whether the safe area is artificial and requires a paragraph to be constructed to contain it.

finish

public void finish()
Finish and optimise for runtime rendering.


getWritableLocation

public TextWritableSafeAreas.ParagraphMapItem getWritableLocation(long idx)
                                                           throws IllegalStateException
Determine if the given idx points to a safe-to-write location and if so return information about it.

Parameters:
idx - the index to test for safe-writability
Returns:
null if none found, otherwise returns the item indicating the safe area.
Throws:
IllegalStateException - if finish() has not been called.

getNextWritableLocation

public TextWritableSafeAreas.ParagraphMapItem getNextWritableLocation(long startIdx,
                                                                      long endIdx)
                                                               throws IllegalStateException
Get the next safe-to-write location starting from the given start and up to the given end. The writable location may be where text can be written, but note that footnotes can't be written into writable areas deep within frames so writing errors must be limited to writing them without the footnote.

Parameters:
startIdx - the index to test for safe-writability
endIdx - do not go past this index. -1 means ignore the end index.
Returns:
null if none found, otherwise returns the item indicating the safe area.
Throws:
IllegalStateException - if finish() has not been called.

getNextWritableLocation

public TextWritableSafeAreas.ParagraphMapItem getNextWritableLocation(long startIdx,
                                                                      long endIdx,
                                                                      boolean excludeFrames)
                                                               throws IllegalStateException
Get the next safe-to-write location starting from the given start and up to the given end, optionally only returning areas that are not within frames. The writable location may be where text can be written, but note that footnotes can't be written into writable areas deep within frames.

Parameters:
startIdx - the index to test for safe-writability
edIdx - do not go past this index. -1 means ignore the end index
excludeFrames - if true, "safe" locations will not be returned if they are within frames.
Returns:
null if none found, otherwise returns the item indicating the safe area.
Throws:
IllegalStateException - if finish() has not been called.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

Docmosis API 4.8.0

Copyright © 2014–2024 Docmosis Pty Ltd. All rights reserved.