Rich-Text Format Specification V. 2 Introduction 2 rtf syntax 2 Conventions of an rtf reader 4



Download 1.09 Mb.
Page10/15
Date conversion29.04.2016
Size1.09 Mb.
1   ...   7   8   9   10   11   12   13   14   15

Objects


Microsoft OLE Links, Microsoft OLE Embedded Objects, and Macintosh Edition Manager Subscriber Objects are represented in RTF as objects. Objects are destinations that contain a data part and a result part. The data part is generally hidden to the application that produced the document. A separate application uses the data and supplies the appearance of the data. This appearance is the result part of the object.

The representation of objects in RTF is designed to allow RTF readers that don't understand objects or don't use a particular type of object to use the current result in place of the object. This allows the appearance of the object to be maintained through the conversion even though the object functionality is lost. Each object comes with optional information about the object, a required destination that contains the object data, and an optional result that contains the current appearance of the object. This result contains standard RTF. It is an important responsibility of the RTF writer to provide the result so that existing RTF readers that either do not support objects or that do not support the particular type of object will be able to display the object.

When the object is an OLE embedded or linked object, the data part of the object is the structure produced by the OLESaveToStream function. Some OLE clients rely on the OLE system to render the object and a copy of the result is not available to the RTF writer for that application. For these cases, the object result may be extracted from the structure produced by the OLESaveToStream function. For information about the OLESaveToStream function, see the Microsoft Object Linking and Embedding SDK.

The syntax for this destination is:





( '{' \ object ( & ? & ? & ? & ? & ? & ?) '}' ) |




\ objemb | \ objlink | \ objautlink | \ objsub | \ objpub | \ objicemb



\ linkself? & \ objlock? | \objupdate?



'{\ *' \ objclass #PCDATA '}'



'{\ *' \ objname #PCDATA '}'



'{\ *' \ objtime



\ rsltmerge? & ?



\ rsltrtf | \ rslttxt | \ rsltpict | \ rsltbmp



\ objsetsize? & \ objalign? & \ objtransy? & ? & \ objcropt? & \ objcropb? & \ objcropl? & \ objcropr? & \ objscalex? & \ objscaley?



\ objh & \ objw



'{\ *' \ objdata (? & ?) '}'



'{\ *' \ objalias '}'



'{\ *' \ objsect '}'



'{' \ result
+ '}'




Control word

Meaning

Object type




\ objemb

An object type of OLE embedded object. If no type is given for the object then the object is assumed to be of type \ objemb.

\ objlink

An object type of OLE link

\ objautlink

An object type of OLE autolink

\ objsub

An object type of Macintosh Edition Manager Subscriber

\ objpub

An object type of Macintosh Edition Manager Publisher

\ objicemb

An object type of MS Word for the Macintosh IC Embedder

Object information




\ linkself

The object is a link to another part of the same document.

\ objlock

Locks the object from any updates.

\ objupdate

Force an update to the object before displaying it.

\ objclass

The text argument is the object class to use for this object; ignore the class specified in the object data. This is a destination control word.

\ objname

The text argument is the name of this object. This is a destination control word.

\ objtime

Describes the time that the object was last updated.

Object size, position, cropping, and scaling




\ objhN

N is the original object height in twips, assuming the object has a graphical representation.

\ objwN

N is the original object width in twips, assuming the object has a graphical representation.

\ objsetsize

Forces the object server to set the object's dimensions to that specified by the client

\ objalignN

N is the distance in twips from the left edge of the objects that should be aligned on a tab stop. This will be needed to place Math Type equations correctly in line.

\ objtransyN

N is the distance in twips the objects should be moved vertically with respect to the baseline. This will be needed to place Math Type equations correctly in line.

\ objcroptN

N is the top cropping distance in twips.

\ objcropbN

N is the bottom cropping distance in twips.

\ objcroplN

N is the left cropping distance in twips.

\ objcroprN

N is the right cropping distance in twips.

\ objscalexN

N is the horizontal scaling percentage.

\ objscaleyN

N is the vertical scaling percentage.

Object data




\ objdata

This sub-destination contains the data for the object in the appropriate format; OLE objects are in OLESaveToStream format. This is a destination control word.

\ objalias

This sub-destination contains the Alias Record for the publisher object for the Macintosh Edition Manager. This is a destination control word.

\ objsect

This sub-destination contains the Section Record for the publisher object for the Macintosh Edition Manager. This is a destination control word.

Object result




\ rsltrtf

Forces the result to be Rich Text, if possible.

\ rsltpict

Forces the result to be a Windows metafile or MacPict image, if possible.

\ rsltbmp

Forces the result to be a bitmap, if possible.

\ rslttxt

Forces the result to be plain text, if possible.

\ rsltmerge

Uses the formatting of the current result whenever a new result is obtained.

\ result

The result destination is optional in the \ object destination. It contains the last update of the result of the object. The data of the result destination should be standard RTF so that RTF readers which don't understand objects or the type of object represented will be able to use the current result in the objects place to maintain appearance. This is a destination control word.



Macintosh Edition Manager Publisher Objects

Word for the Macintosh writes Publisher Objects for the Macintosh Edition Manager in terms of bookmarks (see "Bookmarks" earlier in the document). The range of Publisher objects are marked as bookmarks so these controls are all used within the \ bkmkstart destination. The RTF syntax for a Publisher Object is:




'{\ *' \ bkmkstart \ bkmkpub \ pubauto? (? & ) #PCDATA '}'




Control word

Meaning

\ bkmkpub

The bookmark marks a Macintosh Edition Manager Publisher Object.

\ pubauto

The publisher object will update all Macintosh Edition Manager Subscribers of this object automatically whenever it is edited.



Drawing Objects


Drawing objects and the drawn primitives enumerated within drawing object groups use the syntax described by the following tables.



'{\ *' \ do '}'



?



dobxpage | \ dobxcolumn | \ dobxmargin



dobypage | \ dobypara | \ dobymargin



dodhgt



dolock



| |



\ dpgroup \ dpcount + \ dpendgroup



dpcallout ? ? ? ? ? ? ? ? \ dpcooffsetdpcolength







| | | | |



dpline



dprect (\ dproundr)?



dptxbxdptxbxmar '{' \ dptxbxtext
+'}'



dpellipse



dparc \ dparcflipx? \ dparcflipy?



dppolyline (\ dppolygon)? \ dppolycount +



dpptxdppty



dpxdpydpxsizedpysize

Note that in the number of s is equal to the argument of \ dpcount, while in the number of s is equal to the argument of \ dppolycount.

The following elements of the drawing object syntax pertain specifically to callout objects:



dpcotright | \ dpcotsingle | \ dpcotdouble | \ dpcottriple



dpcoa



dpcoaccent



dpcosmarta



dpcobestfit



dpcominusx



dpcominusy



dpcoborder



dpcodtop | \ dpcodcenter | \ dpcodbottom | \ dpcodabs

The remaining elements of the drawing object syntax are properties applied to individual drawn primitives:





? ? ? ? ?



dplinew



dplinesolid | \ dplinehollow | \ dplinedash | \ dplinedot | \ dplinedado | \ dplinedadodo



|



dplinegray



dplinecordplinecogdplinecob?



\ dplinepal



dpfillpat



|



dpfillfggray



dpfillfgcrdpfillfgcg dpfillfgcb?



\ dpfillfgpal



|



\ dpfillbggray



\ dpfillbgcr \ dpfillbgcg \ dpfillbgcb?



\ dpfillbgpal



dpastartldpastartw



dpastartsol | \ dpastarthol



dpaendldpaendw



dpaendsol | \ dpaendhol



dpshadowdpshadxdpshady

The following table describes the control words for the drawing object group in detail. All color values are RGB values between 0-255. All distances are in twips. All other values are as indicated.



Control word

Definition

\ do

Indicates a drawing object (drawing object) is to be inserted at this point in the character stream. This is a destination control word.

\ dolock

The drawing object's anchor is locked and cannot be moved.

\ dobxpage

The drawing object is page relative in the x-direction.

\ dobxcolumn

The drawing object is column relative in the x-direction.

\ dobxmargin

The drawing object is margin relative in the x-direction.

\ dobypage

The drawing object is page relative in the y-direction.

\ dobypara

The drawing object is paragraph relative in the y-direction.

\ dobymargin

The drawing object is margin relative in the y-direction.

\ dodhgtN

The drawing object is positioned at the following numeric address in the z-ordering.

Drawing primitives




\ dpgroup

Begin group of drawing primitives.

\ dpcountN

Number of drawing primitives in current group.

\ dpendgroup

End group of drawing primitives.

\ dparc

Arc drawing primitive.

\ dpcallout

Callout drawing primitive, which consists of both a polyline and a textbox.

\ dpellipse

Ellipse drawing primitive.

\ dpline

Line drawing primitive.

\ dppolygon

Polygon drawing primitive (closed polyline).

\ dppolyline

Polyline drawing primitive.

\ dprect

Rectangle drawing primitive.

\ dptxbx

Text box drawing primitive.

Position and size




\ dpxN

X-offset of the drawing primitive from its anchor.

\ dpxsizeN

X-size of the drawing primitive.

\ dpyN

Y-offset of the drawing primitive from its anchor.

\ dpysizeN

Y-size of the drawing primitive.

Callouts




\ dpcoaN

Angle of callout's diagonal line is restricted to one of the following: 0, 30, 45, 60, or 90. If this keyword is absent, the callout has an arbitrary angle, indicated by the coordinates of its primitives.

\ dpcoaccent

Accent bar on callout. (Vertical bar between polyline and textbox).

\ dpcobestfit

Best fit callout. (X-length of each line in callout is similar).

\ dpcoborder

Visible border on callout textbox.

\ dpcodabsN

Absolute distance attached polyline. N is the offset in twips from the corner that a auto-attached callout would attach to.

\ dpcodbottom

Bottom attached polyline.

\ dpcodcenter

Center attached polyline.

\ dpcodtop

Top attached callout.

\ dpcolengthN

Length of callout.

\ dpcominusx

Textbox falls in quadrants II or III relative to polyline origin.

\ dpcominusy

Textbox falls in quadrants III or IV relative to polyline origin.

\ dpcooffsetN

Offset of callout. This is the distance between the end of the polyline and the edge of the textbox.

\ dpcosmarta

Auto-attached callout. Polyline will attach to either the top or bottom of the textbox depending on the relative quadrant.

\ dpcotdouble

Double line callout.

\ dpcotright

Right angle callout.

\ dpcotsingle

Single line callout.

\ dpcottriple

Triple line callout.

Text boxes and rectangles




\ dptxbxmarN

Internal margin of the text box.

\ dptxbxtext

Group that contains the text of the text box.

\ dproundr

Rectangle is a round rectangle.

Lines and polylines




\ dpptxN

X-coordinate of the current vertex (only for lines and polylines). The coordinate order for a point must be x, y.

\ dpptyN

Y-coordinate of the current vertex (only for lines and polylines). The coordinate order for a point must be x, y.

\ dppolycountN

Number of vertices in polyline drawing primitive.

Arcs




\ dparcflipx

This indicates that the end point of the arc is to the right of the start point. Arcs are drawn counter-clockwise.

\ dparcflipy

This indicates that the end point of the arc is below the start point. Arcs are drawn counter-clockwise.

Line style




\ dplinecobN

Blue value for line color.

\ dplinecogN

Green value for line color.

\ dplinecorN

Red value for line color.

\ dplinepal

Render line color using the PALETTERGB macro instead of the RGB macro in Windows.

\ dplinedado

Dashed-dotted line style.

\ dplinedadodo

Dashed-dotted-dotted line style.

\ dplinedash

Dashed line style.

\ dplinedot

Dotted line style.

\ dplinegrayN

Grayscale value for line color (in half-percentages).

\ dplinehollow

Hollow line style (no line color).

\ dplinesolid

Solid line style.

\ dplinewN

Thickness of line (in twips).

Arrow style




\ dpaendhol

Hollow end arrow (lines only).

\ dpaendlN

Length of end arrow, relative to pen width:

1 Small


2 Medium

3 Large


\ dpaendsol

Solid end arrow (lines only).

\ dpaendwN

Width of end arrow, relative to pen width:

1 Small


2 Medium

3 Large


\ dpastarthol

Hollow start arrow (lines only)

\ dpastartlN

Length of start arrow, relative to pen width

1 Small


2 Medium

3 Large


\ dpastartsol

Solid start arrow (lines only)

\ dpastartwN

Width of start arrow, relative to pen width:

1 Small


2 Medium

3 Large


Fill pattern




\ dpfillbgcbN

Blue value for background fill color.

\ dpfillbgcgN

Green value for background fill color.

\ dpfillbgcrN

Red value for background fill color.

\ dpfillbgpal

Render fill background color using the PALETTERGB macro instead of the RGB macro in Windows.

\ dpfillbggrayN

Grayscale value for background fill (in half-percentages).

\ dpfillfgcbN

Blue value for foreground fill color.

\ dpfillfgcgN

Green value for foreground fill color.

\ dpfillfgcrN

Red value for foreground fill color.

\ dpfillfgpal

Render fill foreground color using the PALETTERGB macro instead of the RGB macro in Windows.

\ dpfillfggrayN

Grayscale value for foreground fill (in half-percentages).

\ dpfillpatN

Index into a list of fill patterns. See below for list.

Shadow




\ dpshadow

Current drawing primitive has a shadow.

\ dpshadxN

X-offset of the shadow.

\ dpshadyN

Y-offset of the shadow.

The following values are available for specifying fill patterns in drawing objects with the \dpfillpat control word:



Value

Fill Pattern

0 (zero)

Clear (no pattern)

1

Solid (100%)

2

5%

3

10%

4

20%

5

25%

6

30%

7

40%

8

50%

9

60%

10

70%

11

75%

12

80%

13

90%

14

Dark horizontal lines

15

Dark vertical lines

16

Dark left-diagonal lines (\\\)

17

Dark right-diagonal lines (///)

18

Dark grid lines

19

Dark trellis lines

20

Light horizontal lines

21

Light vertical lines

22

Light left-diagonal lines (\\\)

23

Light right-diagonal lines (///)

24

Light grid lines

25

Light trellis lines



Footnotes


The \ footnote control word introduces a footnote. Footnotes are destinations in RTF. A footnote is anchored to the character that immediately precedes the footnote destination (that is, the footnote moves with the character to which it is anchored). If automatic footnote numbering is defined, the destination can be preceded by a footnote reference character, identified by the control word \ chftn. No Microsoft product supports footnotes within headers, footers, or annotations. Placing a footnote within headers, footers, or annotations will often result in a corrupt document.

Footnotes have the following syntax:





'{\ *' \ footnote
+ '}'

Here is an example of a destination containing footnotes.

\ftnbj\ftnrestart \sectd \linemod0\linex0\endnhere \pard\plain

\ri1170 \fs20 {\pu6 Mead's landmark study has been amply annotated.\chftn

{\*\footnote \pard\plain \s246 \fs20 {\up6\chftn }See Sahlins, Bateson, and

Geertz for a complete bibliography.}

It was here work in America during the Second World War, however, that forms

the basis for the paper. As others have noted, \chftn

{\*\footnote \pard\plain \s246 \fs20 {\up6\chftn}

A complete bibliography will be found at the end of this chapter.}

this period was a turning point for Margaret Mead.}

\par
To indicate endnotes, the following combination is emitted: \ footnote\ ftnalt. Existing readers will ignore the \ ftnalt keyword and treat everything as a footnote.

For other control words relating to footnotes, see the sections entitled "Document-Formatting Properties", "Section-Formatting Properties", and "Special Characters".

Annotations


RTF annotations have two parts; the author ID (introduced by the control word \ atnid) and the annotation text (introduced by the control word \ annotation ); there is no group enclosing both parts. No Microsoft product supports annotations within headers, footers, or footnotes. Placing an annotation within headers, footers, or footnotes will often result in a corrupt document. Each part of the annotation is an RTF destination. Annotations are anchored to the character that immediately precedes the annotation.

If an annotation is associated with an annotation bookmark, the following two destination control words precede and follow the bookmark. The alphanumeric string N, such as a long integer, represents the bookmark name.





'{\ *' \ atrfstart N '}'

< atrfend>

'{\ *' \ atrfend N '}'

Annotations have the following syntax:





? \ chatn ?



'{\ *' \ atnid #PCDATA '}'

< atnauthor>

'{\*' \atnauthor #PCDATA '}'



'{\ *' \ annotation
+ '}'

< atnref>

'{\ *' \ atnref N '}'



'{\ *' \ atntime



'{\ *' \ atnicn
'}'

An example of annotation text follows:

An example of a paradigm might be Newtonian physics or

Darwinian biology.{\v\fs16 {\atnid bz}\chatn{\*\annotation

\pard\plain \s224 \fs20 {\field{\fldinst page \\#'"Page:

'#'\line'"}{\fldrslt}}{\fs16 \chatn }

How about some examples that deal with social science?

That's what this paper is about.}}


Annotations may have optional time stamps (contained in the \ atntime destination) or icons (contained in the \ atnicn destination).

Fields


The \ field control word introduces a field destination, which contains the text of Word for Windows fields.

Fields have the following syntax:





'{' \ field ? '}'



\ flddirty? & \ fldedit? & \ fldlock? & \ fldpriv?



'{\ *' \ fldinst + ? '}'



\ fldalt



'{\ *' \ fldrslt
+ '}'

There are several control words that alter the interpretation of the field. These control words are:



Control word

Meaning

\ flddirty

Formatting change has been made to the field result since the field was last updated.

\ fldedit

Text has been added to, or removed from, the field result since the field was last updated.

\ fldlock

Field is locked and cannot be updated.

\ fldpriv

Result is not in a form suitable for display (for example, binary data used by fields whose result is a picture).

Two sub-destinations are required within the \ field destination. They must be enclosed in braces ({}) and begin with the following control words:



Control word

Meaning

\ fldinst

Field instructions. This is a destination control word.

\ fldrslt

Most recent calculated result of the field. This is a destination control word.

If the instruction for a field contains a file name, then the \ cpg control can be used to define the character set of the file name. See “Code Page Support” for details.

The \ fldrslt control word should be included even if no result has been calculated, because even readers that do not recognize fields can generally include the value of the \ fldrslt destination in the document.

An example of some field text follows:

{\field\fldedit{\fldinst author}{\fldrslt Joe Smith}}\par\pard

{\field{\fldinst time \\@ "h:mm AM/PM"}{\fldrslt 8:12 AM}}


You can use the \fldalt keyword to specify that the given field reference is to an endnote. For example, the following field in RTF is a reference to a footnote:

{\ field{\ *\ fldinst NOTEREF _RefNumber } {\ fldrslt 1}}


The following is an example of a reference to an endnote:

{\ field{\ *\ fldinst NOTEREF _RefNumber \ fldalt } {\ fldrslt I}}


If the specified field is a form field, the \*\datafield destination appears as a part of and contains the binary data of a form field instruction. For example:

{\ field{\*\fldinst {\*\bkmkstart Text1} FORMTEXT {{\*\datafield

00000000000000000554657874310008476565207768697a0000000000000000000000}}}{\fldrslt Default Result}}{\*\bkmkend Text1}
Note that the \datafield destination requires the \* prefix.

Index Entries


The \ xe control word introduces an index entry. Index entries in RTF are destinations. An index entry has the following syntax:



'{' \ xe (\xef? & \ bxe? & \ ixe?) + ( | )? '}'



'{' \ txe + '}'



'{' \ rxe #PCDATA '}'

If the text of the index entry is not formatted as hidden text with the \ v control word, the text is put into the document as well as into the index. For more information on the \ v control word, see "Character-Formatting Properties". Similarly, the text of the \ txe sub-destination, described later in this section, becomes part of the document if it is not formatted as hidden text.

The following control words may also be used:

Control word

Meaning

\ xefN

Allows multiple indices within the same document. N is an integer that corresponds to the ASCII value of a letter between A and Z.

\ bxe

Formats the page number or cross-reference in bold.

\ ixe

Formats the page number or cross-reference in italic.

\ txe Text

Text argument to be used instead of a page number. This is a destination control word.

\ rxe BookmarkName

Text argument is a bookmark for the range of page numbers. This is a destination control word.



Table of Contents Entries


The \ tc control word introduces a table of contents entry, which can be used to build the actual table of contents. The \tcn control word marks a table of contents entry that will not have a page number associated with it; this is used in place of \ tc for such entries. Table of contents entries are destinations, and they have the following syntax:



'{' \ tc | \tcn ( \ tcf? & \ tcl?) + '}'

As with index entries, text that is not formatted as hidden with the \ v character-formatting control word is put into the document. The following control words can also be used in this destination:



Control word

Meaning

\ tcfN

Type of table being compiled; n is mapped by existing Microsoft software to a letter between A and Z (default is 67, which maps to C, used for tables of contents).

\ tclN

Level number (default is 1).



Bidirectional language support


RTF supports bidirectional writing orders for languages such as Arabic. The controls are described below (as well as in the appropriate sections). Also refer to the associated character properties defined in “Associated Character Properties,” earlier in this chapter.

All the control words relating to bidirectional language support are repeated here for convenience.



Control word

Meaning

\ rtlch

The character data following this control word will be treated as a right to left run.

\ ltrch

The character data following this control word will be treated as a left to right run. This is the default.

\ rtlmark

The following characters should be displayed from right to left.

\ ltrmark

The following characters should be displayed from left to right.

\ rtlpar

Text in this paragraph will be displayed with right to left precedence

\ ltrpar

Text in this paragraph will be displayed with left to right precedence. This is the default.

\ rtlrow

Cells in this table row will have right to left precedence.

\ ltrrow

Cells in this table row will have left to right precedence. This is the default.

\ rtlsect

This section will thread columns from right to left.

\ ltrsect

This section will thread columns from left to right. This is the default.

\ rtldoc

Text in this document will be displayed from right to left unless overridden by a more specific control.

\ ltrdoc

Text in this document will be displayed from left to right unless overridden by a more specific control. This is the default.

\ zwj

Zero Width Joiner. This is used for ligating words.

\ zwnj

Zero-Width Non-Joiner. This is used for unligating a word.



1   ...   7   8   9   10   11   12   13   14   15


The database is protected by copyright ©essaydocs.org 2016
send message

    Main page