public interface RichTextProcessor
MDAccess for DOORS natively supports the conversion of DOORS RTF values as XHTML content. For that, it relies on the DOORS client itself and its ability to parse RTF content.
The DOORS client RTF parser supports all RTF constructs a user can create using DOORS client Edit menu. It does not however support all RTF constructs defined by the RTF specification. RTF tables are for example not supported by the DOORS client parser. Though a user is not able to manually create such construct using DOORS client Edit menu, they might appear in an RTF value injected programmatically by DXL code or manually created by copying and pasting content from a Word document. As the DOORS client RTF parser ignores those unsupported constructs, they are not available when reading data through MDAccess for DOORS.
This class enables a developer to control and extend the conversion of RTF values to XHTML. It provides two hooks:
As an example, an implementation could:
\cell
construct to a plain text value like [RTF_CELL]
.[RTF_CELL]
to <td>
.
An instance of RichTextProcessor
can be set as model reader option using the Common.OPTION_RICH_TEXT_PROCESSOR
key.
Common.OPTION_RICH_TEXT_PROCESSOR
Modifier and Type | Method and Description |
---|---|
DXLFragment |
getPreprocessor()
Returns a DXL code that pre-processes a DOORS RTF value before it is converted to XHTML.
|
RichText |
postprocess(RichText value)
Post-processes an XHTML value.
|
DXLFragment getPreprocessor()
Returns a DXL code that pre-processes a DOORS RTF value before it is converted to XHTML. This method is called by the time the model reader connects to DOORS to read data (before actually processing rich text values). It gives a hook to customize the content of the RTF buffer.
The method returns a DXL fragment that contains the body of a DXL function, with the following contract:
buffer
of type Buffer
.
This buffer holds the RTF content about to be parsed.
buffer
variable.buffer
variable was altered by the function
execution. Returning true
means to the framework that the RTF value contains formatted text and shall not be considered as plain
text in any case.
The implementation is recommended to use DXLFileFragment
to return content loaded from a resource file,
as the DXL body is likely to be fixed.
An alternative is to use a DXLBufferFragment
if the DXL body is to compute dynamically.
DXLFileFragment
,
DXLBufferFragment
RichText postprocess(RichText value)
This method is called by the time an XHTML value was read and before attaching it to the related model element. It enables post-processing the XHTML value by injecting content related to the RTF pre-processing applied at first.
Note that this method is called for any non-plain text value read from DOORS, regardless the associated preprocessor returned
true
or false
for each of these values.
value
- the XHTML content that was extracted from a DOORS rich text value.