OLE2 File Format


_____________________________________________________________________________________



Ole2 places the OLE DLL management data in two streams and the presentation
data in other stream(s). It is up to the server app to decide on the number
of streams (and their names) that are necessary to save the native data in
the DOCFILE.

As indicated in the spec., certain sets of stream names are reserved for use
by OLE (and other system components). When the first character of the stream
is in the range 1 to 1F (hexadecimal), the stream has a defined format,
purpose and most often a single body of code to read and write it. Only four
such sets of names are used at present:

"\0x01..." - basic control streams (two at present)

"\0x02..." - OLE presentations (one per FORMATETC)

"\0x03..." - used by container of this object (no defined number of them)

"\0x04..." - used by storage implementation to hold properties.

The container has control over the streams beginning with \0x03 as indicated
above, the number and nature of the presentation streams and the document
bit contained in the Ole2 control stream ("\1Ole"). The document bit is in
the Ole2 control stream so as not to create another stream for the one piece
of information. The only way to set and clear the bit is through the
Set/GetDocumentBitStg apis. Once set, this bit stays set, even in the face
of saves and copying.

CompObj Private Stream

Following is the layout of the CompObj private stream; its name is
"\1CompObj"



Byte Order Indicator

Format Version

Originating OS Version

Class Name

Display Name of Class

Format Name



Word

Word

Dword

-1L CLSID

Variable

Variable





Byte Order Indicator - same byte order indicator as used in UNICODE
(0xfffe).

Format Version - version of the format of this stream. Future formats will
always be upward and downward compatible.

Originating OS Version - some indication of OS type and version (e.g. Win
3.1)

Class Name - the class id of the object which wrote this data (-1L followed
by a CLSID).

Display Name of Class - a string representing the display name (user
readable) of the class; for now this string is always empty.

Format Name - the format of the data (same as the clipboard format; see
below).



All of the information except the Format Name is written by WriteClassStg.
The format name is written by WriteFmtStg (which must be called after
WriteClassStg). If the format name is missing, ReadFmtStg will concoct a
unique format tag derived from the class.

Format Storage Layout

The format tag for an object indicates the type of the native data and is
treated the same as clipboard formats. If the format value of the
presentation data is one of the Windows pre-defined clipboard format values
then the first field in the above structure will have -1L and the second
field will contain the format number. For MAC four-byte tags, the first
field is -2L and second field is the tag. Otherwise the format of
presentation data must have been registered via RegisterClipboardFormat (or
some Mac equivalent, if any). In this case the first field will be the
length of the string and the second field will have the clipboard format
name (zero terminated). There are some uses where the format name is empty.
Thus there are four cases:



-1L

Windows Clipboard format value



Long

Dword





-2L

Mac format value



Long

Dword





Length of name

Clipboard format name



Long

Variable





0L



Long





OLE Private Stream



Data specific to the management of OLE objects will be placed in this
stream. The name of the stream is "\1Ole". If the object is a link object,
all the fields are used.



OLE Version

Object flags

Update options

Reserved

Moniker (rel)

...



Dword

Dword

Dword

Dword

Variable

...







...

Source Moniker (rel)

Source Moniker (abs)

Last Class

Last Display

ltChange
OfUpdate

ltKnown
UpToDate

rtUpdate



...

Variable

Variable

-1L CLSID

Variable

FILETIME

FILETIME

FILETIME





OLE Version - high word is product version (major number in high byte) and
the low word is format number of this stream. The format number is similar,
but not necessarily the same value as, the format number in the stream
above.

Object flags - General attribute flags for object. The bits in this dword as
allocated according to the following enum:

typedef enum tagOBJFLAGS

{

OBJFLAGS_LINK=1,

OBJFLAGS_DOCUMENT=2// the infamous document bit; this is
container-controlled

} OBJFLAGS;

The other bits are unused and will be zero.

Update options - when the object is a link, the update options for the link;
otherwise 0.

Moniker (rel) - the moniker of this object relative to its container (for
both embedded objects and links).



And if the object is a link, the following fields are present:

Source Moniker (rel) - moniker of the source of the link, relative to the
link object (see below for details).

Source Moniker (abs) - moniker of the source of the link, absolute (see
below for details).

(NOTE: we might need to store a network name as well).

Last Class name - the class id of the object the last time the moniker was
bound (-1L follwed by a CLSID).

Last Display name - this field is non-null iff the monikers are null and
indicates the last display name given (see above for details).

ltChangeOfUpdate, ltKnownUpToDate, rtUpdate - see spec (moniker chapter,
link subsections).

Moniker format

The format of the moniker data is up to the moniker class. Here we preceed
the data by its size to facilitate skipping it and to indicate (when 0) that
there is no moniker.



Length of moniker data

Moniker (rel or abs)



Long

Variable





0L



Long





String storage layout

Zero terminated strings are stored as follows. If the value of the length is
0 then the second column will not exist.



Length of string including null terminator

Stream of bytes with null terminator



Long

Variable





0L



Long



Presentation Streams

Presentation data can be either standard or generic presentation data. The
standard presentation data in turn can be one of METAFILE, BITMAP, DIB. If
an object has multiple presentation data, then each of the presentation data
will be given a separate stream. The names of the presentation streams will
be of the format "\2OlePres?", where ? is the number of the presentation
stream (just to ensure uniqueness). Following is the proposed layout for the
presentation data.



Each presentation stream contains the following:



Clipboard format

Target device structure

Aspect

Lindex (must be -1L)

Flags

...



Variable

Variable

Dword

Long

Dword

...





...

Compression (must be 0)

Width in

mm-himetric

Height in

mm-himetric

Presentation data size in bytes

Presentation data



...

Dword

Long

Long

Long

Variable





Clipboard Format - The format of the data (same as format name above).

Target device structure - The target device structure (a direct copy of
DVTARGETDEVICE with the addition that the length Dword may be 4 indicating
the screen device). NOTE: the length Dword here is different than the others
in that it includes the length Dword itself; that is why it is 4 when the
device structure is NULL.

Aspect - the aspect for which this presentation is the display

Lindex - currently we are not supporting layout negotiation, so it must be
-1L

Flags - the advise flags used in the cache setup

Compression - must be 0 indicating no compression; later other values will
be defined to indicate the kind of compression used.

Width in mm-himetric - width of presentation

Height in mm-himetric - height of presentation

Presentation data size in bytes - size of data

Presentation data - stream of bytes



(c) Microsoft Corporation 1992. All Rights Reserved.





Page:









