Class PlainTextExtractionVisitor
Visitor implementation that can be used to build a plain text representation from editor nodes.
Inheritance
Inherited Members
Namespace: Sdl.DesktopEditor.EditorApi.Implementation
Assembly: Sdl.DesktopEditor.EditorApi.dll
Syntax
public class PlainTextExtractionVisitor : INodeVisitor
Remarks
Typically used together with a ContentNodeIterator to extract text content from a range in a document.
To use, call VisitNode(IAbstractContentNode) for a single content node to be processed, or pass this object to AcceptNodeVisitor(INodeVisitor) for the node to be processed.
Constructors
PlainTextExtractionVisitor()
Use a new string builder for the result.
Declaration
public PlainTextExtractionVisitor()
PlainTextExtractionVisitor(StringBuilder)
Append text to an existing string builder.
Declaration
public PlainTextExtractionVisitor(StringBuilder appendResultTo)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | appendResultTo |
Properties
AppendLineBreakForSegments
When true
a line break will be appended for every segment end
Used when copying
When false
no text is appended for segments.
Declaration
public bool AppendLineBreakForSegments { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
AppendTextEquivalentForPlaceholders
When true
placeholder tags will yield text
corresponding to their TextEquivalent property.
When false
no text is appended for placeholder tags.
Declaration
public bool AppendTextEquivalentForPlaceholders { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Result
The resulting string.
Declaration
public StringBuilder Result { get; set; }
Property Value
Type | Description |
---|---|
System.Text.StringBuilder |
Methods
VisitBookmarkNode(IBookmarkNode)
Do nothing.
Declaration
public void VisitBookmarkNode(IBookmarkNode node)
Parameters
Type | Name | Description |
---|---|---|
IBookmarkNode | node |
VisitCommentContainerNode(ICommentContainerNode)
Do nothing.
Declaration
public void VisitCommentContainerNode(ICommentContainerNode node)
Parameters
Type | Name | Description |
---|---|---|
ICommentContainerNode | node |
VisitCommentMarker(ICommentMarker)
Do nothing.
Declaration
public void VisitCommentMarker(ICommentMarker commentMarker)
Parameters
Type | Name | Description |
---|---|---|
ICommentMarker | commentMarker |
VisitDocumentContainerNode(IDocumentContainerNode)
Do nothing.
Declaration
public void VisitDocumentContainerNode(IDocumentContainerNode node)
Parameters
Type | Name | Description |
---|---|---|
IDocumentContainerNode | node |
VisitFileContainerNode(IFileContainerNode)
Do nothing.
Declaration
public void VisitFileContainerNode(IFileContainerNode node)
Parameters
Type | Name | Description |
---|---|---|
IFileContainerNode | node |
VisitLocationMarker(ILocationMarker)
Do nothing.
Declaration
public void VisitLocationMarker(ILocationMarker location)
Parameters
Type | Name | Description |
---|---|---|
ILocationMarker | location |
VisitLocationMarkerNode(ILocationMarkerNode)
Do nothing.
Declaration
public void VisitLocationMarkerNode(ILocationMarkerNode node)
Parameters
Type | Name | Description |
---|---|---|
ILocationMarkerNode | node |
VisitLockedContent(ILockedContent)
Visit all locked items.
Declaration
public void VisitLockedContent(ILockedContent lockedContent)
Parameters
Type | Name | Description |
---|---|---|
ILockedContent | lockedContent |
VisitLockedContentContainerNode(ILockedContentContainerNode)
Visit the locked content.
Declaration
public void VisitLockedContentContainerNode(ILockedContentContainerNode node)
Parameters
Type | Name | Description |
---|---|---|
ILockedContentContainerNode | node |
VisitMarkerContainerNode(IOtherMarkerContainerNode)
Do nothing.
Declaration
public void VisitMarkerContainerNode(IOtherMarkerContainerNode node)
Parameters
Type | Name | Description |
---|---|---|
IOtherMarkerContainerNode | node |
VisitNode(IAbstractContentNode)
Cast the node to a framework node and visit it.
Declaration
public void VisitNode(IAbstractContentNode node)
Parameters
Type | Name | Description |
---|---|---|
IAbstractContentNode | node |
Remarks
This approach is convenient when used with the content node iterator.
VisitOtherMarker(IOtherMarker)
Do nothing.
Declaration
public void VisitOtherMarker(IOtherMarker marker)
Parameters
Type | Name | Description |
---|---|---|
IOtherMarker | marker |
VisitParagraphUnitContainerNode(IParagraphUnitContainerNode)
Do nothing.
Declaration
public void VisitParagraphUnitContainerNode(IParagraphUnitContainerNode node)
Parameters
Type | Name | Description |
---|---|---|
IParagraphUnitContainerNode | node |
VisitPlaceholderTag(IPlaceholderTag)
Append text for the placeholder, depending on settings.
Declaration
public virtual void VisitPlaceholderTag(IPlaceholderTag tag)
Parameters
Type | Name | Description |
---|---|---|
IPlaceholderTag | tag |
VisitPlaceholderTagNode(IPlaceholderTagNode)
Append text for the placeholder, depending on settings.
Declaration
public void VisitPlaceholderTagNode(IPlaceholderTagNode node)
Parameters
Type | Name | Description |
---|---|---|
IPlaceholderTagNode | node |
VisitRevisionMarker(IRevisionMarker)
Do nothing.
Declaration
public void VisitRevisionMarker(IRevisionMarker revisionMarker)
Parameters
Type | Name | Description |
---|---|---|
IRevisionMarker | revisionMarker |
VisitRevisionMarkerContainerNode(IRevisionMarkerContainerNode)
Do nothing.
Declaration
public void VisitRevisionMarkerContainerNode(IRevisionMarkerContainerNode node)
Parameters
Type | Name | Description |
---|---|---|
IRevisionMarkerContainerNode | node |
VisitSegment(ISegment)
Do nothing here: since the typical use case for this class is to be used with a ContentNodeIterator we should handle segments in VisitStartEndNode.
Declaration
public void VisitSegment(ISegment segment)
Parameters
Type | Name | Description |
---|---|---|
ISegment | segment |
VisitSegmentContainerNode(ISegmentContainerNode)
Do nothing.
Declaration
public void VisitSegmentContainerNode(ISegmentContainerNode node)
Parameters
Type | Name | Description |
---|---|---|
ISegmentContainerNode | node |
VisitStartEndNode(IStartEndNode)
Do nothing unless we have a segment container node: if we do we may want to insert a line break.
Declaration
public void VisitStartEndNode(IStartEndNode node)
Parameters
Type | Name | Description |
---|---|---|
IStartEndNode | node |
VisitTagPair(ITagPair)
Do nothing.
Declaration
public void VisitTagPair(ITagPair tagPair)
Parameters
Type | Name | Description |
---|---|---|
ITagPair | tagPair |
VisitTagPairContainerNode(ITagPairContainerNode)
Do nothing.
Declaration
public void VisitTagPairContainerNode(ITagPairContainerNode node)
Parameters
Type | Name | Description |
---|---|---|
ITagPairContainerNode | node |
VisitText(IText)
Append text to the result.
Declaration
public void VisitText(IText text)
Parameters
Type | Name | Description |
---|---|---|
IText | text |
VisitTextNode(ITextNode)
Append text to the result.
Declaration
public void VisitTextNode(ITextNode node)
Parameters
Type | Name | Description |
---|---|---|
ITextNode | node |