home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / oletxt.zip / OLETXT.TXT
Text File  |  1991-01-09  |  171KB  |  2,981 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. December 10 Pre-release version
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. Extensible Application Protocols 
  36. Object Linking and Embedding
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. Microsoft Corporation
  44. One Microsoft Way
  45. Redmond WA, 98052
  46.  
  47. 2 December, 1990    Copyright ⌐ 1990, Microsoft Corporation
  48.  
  49.  
  50. Etymological Note, and Acknowledgement
  51. The protocol defined in this specification was initiated by Rick Hawes of the Microsoft Applications 
  52. Graphics Business Unit. Concurrently, a very similar protocol was proposed by Rick Trent of Aldus, 
  53. called PEZ. This work is a synthesis of the earlier proposals, refined and completed with the help of 
  54. many people at Microsoft, Lotus, Aldus, and Word Perfect Corp.  The original working title of the 
  55. specification of this protocol was "Linked and Embedded Documents".  Following review and 
  56. comment, the working title was changed to "Extensible Compound Document Architecture" with the 
  57. intent to convey the nature and purpose of the specification.  To avoid confusion with the acronym 
  58. CDA which is owned by Digital Equipment Corporation, and to convey that the specification defines a 
  59. protocol between application components, the title was changed to "Compound Document Protocol".  
  60. Finally, we have decided to return almost to the beginning, and have settled on the current title.
  61.  
  62.  
  63.  
  64. User Conceptual Model    8
  65. User Task: Compound Document Management    8
  66. Conceptual Model: Visual Containment and Links    8
  67. Semantic Model    8
  68. Objects    8
  69. Containers    9
  70. Containment    9
  71. Behaviors: editing    9
  72. Presentation: display and printing    9
  73. Dependent objects    9
  74. Operations    10
  75. Move    10
  76. Copy    10
  77. Link    11
  78. Variations    11
  79. Dynamic Objects    11
  80. Voice, sound and animations    11
  81. Actions: executable objects    12
  82. Hypertext and Annotations    12
  83. Client-provided hypertext links    12
  84. Client-provided annotations    12
  85. User Interface    13
  86. Terminology    13
  87. Commands for Embedding and Creating Links    14
  88. Copy    14
  89. Cut    15
  90. Paste    15
  91. Paste Link    15
  92. Insert New Object    15
  93. Paste Special    16
  94. Presentation in Containers    16
  95. Normal Display    16
  96. Section Boundaries    16
  97. Selection Behavior    17
  98. Editing in Containers    17
  99. Opening    17
  100. Operations in Containers    17
  101. Displaying Properties    18
  102. Properties Dialogs for Links    19
  103. Properties Dialogs for Embedded Objects    20
  104. Opening Objects    20
  105. Control of Updates for Links    21
  106. Changing Update Rules    21
  107. Updating Presentations    21
  108. "Disconnecting" Links    21
  109. Repairing Broken Links    21
  110. "Freezing" Presentations of Objects    21
  111. Displaying Section Boundaries    22
  112. Undoing Changes to Embedded Objects    22
  113. Operations in Editors    22
  114. Updating Presentations    22
  115. Saving Copies of Objects    22
  116. Returning to Containers    23
  117. Implementor's Guide    24
  118. Introduction    24
  119. Clipboard Conventions    24
  120. Registration    27
  121. Client    27
  122. Protocol Checking    27
  123. Open a Document    27
  124. Save or Close a Document    28
  125. Display and Print    28
  126. Open an Object    29
  127. Change Printer, Resize    29
  128. Cut and Copy    29
  129. Paste    29
  130. Paste Link    30
  131. Undo    30
  132. Links    30
  133. Properties    31
  134. Shutdown    31
  135. Server    31
  136. Opening    31
  137. Shutdown    31
  138. Copy    32
  139. Save a Copy    32
  140. Update    32
  141. Exit, Close    32
  142. Renaming a Document    32
  143. Installation of Classes    32
  144. API specification    33
  145. Introduction and general definitions    33
  146. Client API specification    33
  147. Types, Data structures and parameter definitions    33
  148. ECDSTATUS    34
  149. Structures provided by the library for the client    34
  150. ECDOBJECT, LPECDOBJECT    34
  151. Structures provided by the client for the library    34
  152. ECD_NOTIFICATION    35
  153. ECDCLIENT, LPECDCLIENT    35
  154. ECDCLIENT: CallBack    35
  155. ECDSTREAM, LPECDSTREAM    36
  156. ECDSTREAM: Get    36
  157. ECDSTREAM: Put    37
  158. ECDSTREAM: Seek    37
  159. Protocol naming and checking    37
  160. Rendering Options    37
  161. ECDOPT_RENDER, ECDCLIPFORMAT    38
  162. API functions    38
  163. Utility functions    38
  164. Enabling Paste and Paste link commands    38
  165. EcdQueryCreateFromClip    38
  166. EcdQueryLinkFromClip    39
  167. Executing Paste and Paste link commands    39
  168. EcdCreateFromClip    39
  169. EcdCreateLinkFromClip    39
  170. Copying or cutting an object to the clipboard    39
  171. EcdCopyToClipboard    39
  172. EcdCutToClipboard    40
  173. Load from  and Save to client's file    40
  174. EcdLoadFromStream    40
  175. EcdSaveToStream    40
  176. Object creation    41
  177. Creating new objects    41
  178. EcdCreate    41
  179. EcdCreateFromTemplate    41
  180. Creating an object by converting an existing object    41
  181. EcdObjectConvert    41
  182. Copying and comparing objects    42
  183. EcdClone    42
  184. EcdEqual    42
  185. Making a local copy of a linked object    42
  186. EcdCopyFromLink    42
  187. Object method functions    43
  188. Protocol extensibility    43
  189. EcdQueryProtocol    43
  190. Destroying an object    43
  191. EcdDelete    43
  192. Finding the display size of an object    44
  193. EcdQueryBounds    44
  194. Formatting an object    44
  195. EcdSetTargetDevice    44
  196. EcdSetBounds    44
  197. EcdSetHostNames    44
  198. Rendering an object    45
  199. EcdDraw    45
  200. Initializing and retrieving data    45
  201. EcdEnumObjectFormats    46
  202. EcdGetData    46
  203. EcdSetData    46
  204. Repairing broken links    46
  205. Update control    47
  206. ECDOPT_UPDATE    47
  207. EcdGetLinkUpdateOptions    47
  208. EcdSetLinkUpdateOptions    47
  209. Opening and updating    47
  210. EcdOpen    47
  211. EcdQueryOpen    48
  212. EcdUpdate    48
  213. EcdReconnect    48
  214. EcdQueryOutOfDate    48
  215. EcdClose    48
  216. Object handler API specification    49
  217. Overview    49
  218. Object creation and initialization    49
  219. Dll/DefCreateFromClip    49
  220. Dll/DefLoadFromStream    50
  221. Object methods    51
  222. ECDOBJECT, ECDOBJECTVTBL, 
  223. LPECDOBJECT    52
  224. Object release    53
  225. Server API specification    53
  226. Types, Data structures and parameter definitions    53
  227. Structures provided by the server for the library    53
  228. LHSERVER, LHDOCUMENT    53
  229. API functions and callbacks (methods)    54
  230. Startup and registration    54
  231. EcdRegisterServer    54
  232. Server Methods    54
  233. ECDSERVER, LPECDSERVER    55
  234. ECDSERVER: Open    55
  235. ECDSERVER: Create    56
  236. ECDSERVER: CreateFromTemplate    56
  237. ECDSERVER: Edit    57
  238. ECDSERVER: Exit    57
  239. ECDSERVER: Release    57
  240. Shutdown    58
  241. EcdRevokeServer    58
  242. Document creation    58
  243. EcdRegisterDocument    58
  244. Document methods    59
  245. ECDDOCUMENT, LPECDDOCUMENT    59
  246. ECDDOCUMENT: Save    59
  247. ECDDOCUMENT: Close    59
  248. ECDDOCUMENT: SetHostNames    60
  249. ECDDOCUMENT: SetDocDimensions    60
  250. ECDDOCUMENT: GetObject    60
  251. ECDDOCUMENT: Release    61
  252. Closing documents    61
  253. EcdRevokeDocument    61
  254. Object creation    61
  255. Server Object methods    61
  256. ECDOBJECT: Delete    62
  257. ECDOBJECT: Show    62
  258. ECDOBJECT: GetData    62
  259. ECDOBJECT: SetData    63
  260. ECDOBJECT: SetTargetDevice    63
  261. Object release    63
  262. EcdRevokeObject    63
  263. Notification    64
  264. Registration    64
  265. Appendix: DDE-based protocol specification    66
  266. Launching the Server Application    66
  267. DDE Conventions    66
  268. Conversations    66
  269. Formats    66
  270. System Topic Items    67
  271. Standard Item Names and Notification Control    67
  272. Standard Commands in DDE Execute Strings    69
  273. StdNewDocument(ClassName,DocumentName)    69
  274. StdNewFromTemplate(ClassName,DocumentName,TemplateName
  275. )    69
  276. StdEditDocument(DocumentName)    69
  277. StdOpenDocument(DocumentName)    69
  278. StdCloseDocument(DocumentName)    69
  279. StdSaveDocument(DocumentName)    69
  280. StdShowItem(DocumentName,ItemName [, fTakeFocus] )    69
  281. StdExit    70
  282. StdCloseDocument    70
  283. StdSaveDocument    70
  284. StdShowItem(ItemName  [, fTakeFocus] )    70
  285. An example: opening an object for editing    70
  286.  
  287.  
  288.  
  289.   User Conceptual Model
  290.   User Task: Compound Document Management
  291. The model developed here is designed to support the general task of combining information from 
  292. numerous sources. More specifically, it is intended to support the creation, and editing of compound 
  293. documents built from information of various kinds.  This requires that multiple application programs 
  294. be able to cooperate on editing a single document.
  295.   Conceptual Model: Visual Containment and Links
  296. The conceptual model developed here is a simple one:
  297. There are things and there are places those things can reside.
  298. Things may be moved from one place to another, and may be linked to in other places. They may also 
  299. be parts of other things. Things have content and a behavior, neither of which depend on the places 
  300. they are found. Users visualize and manipulate things through their presentations, which are derived 
  301. from their contents, behaviors, and their relationships to the places they are found. Things in the same 
  302. place may have entirely different content, behavior, or presentation; users bring them together because 
  303. they are part of the same task.
  304.   Semantic Model
  305. This section describes the conceptual model in more detail, and presents a more formal definition of its 
  306. semantics. This model has two basic elements, objects and containers, two fundamental relationships, 
  307. containment and reference, and three basic operations, move, copy, and link.
  308.   Objects
  309. Objects are the "things" manipulated by the user. A graph, a range of spreadsheet cells, a paragraph in 
  310. a document, the current selection in an open window, and an entire document are all potential objects. 
  311. Each object has two defining features: content and behavior. An object s behavior determines what ac-
  312. tions the user can perform on it, how it responds to those actions, and what tools are used to effect 
  313. those responses. Behavior is what distinguishes objects from simple "data."
  314. All objects also have a presentation, which determines how it will appear to the user in a given context. 
  315. An object s presentation in a place is derived from its content and behavior, subject to constraints im-
  316. posed by its relationship to that place.
  317. Objects are distinguished from "data" by the possession of behaviors; when they lose them, they cease 
  318. to be objects. The current implementation of "Paste" in Word, for example, "converts"  pasted ranges 
  319. of spreadsheet cells in just this way. The table that this operation creates in a Word document has lost 
  320. most of the behavior-dependency, the ability to edit and insert formulae, etc.-of the original cells. 
  321. What has been pasted is not the original object-a range of cells-nor a copy of the original object, but 
  322. a new object-a Word table-filled with a copy of the original object s data. On the other hand, graphs 
  323. created with PowerPoint s "Insert Graph" command, are objects: they retain all of the behavior that 
  324. they have when they are created in PowerPoint Graph. The user is, in fact, made explicitly aware of this 
  325. by being returned to Graph each time he attempts to perform any operation affecting the content or 
  326. behaviors of the graph.
  327. Each object has a class that is used to identify what kind of object it is. All objects with the same set of 
  328. behaviors (e.g. all PowerPoint graphs, all Excel tables) have the same class.
  329.   Containers
  330. Containers are the "places" that hold objects or links to objects. A file folder, for example, is a 
  331. container for document objects; a PowerPoint slide is a container for a PowerPoint graph. A 
  332. compound document is the paradigmatic container: it contains numerous objects from many sources 
  333. and of many different types, that the user has placed in the same container for the purpose of working 
  334. on them as part of a group of related tasks.
  335. Many objects are also containers; they are distinguished from other objects by the containment 
  336. relationship (see below) that they exhibit with the objects they contain. An object need not act as a 
  337. container; it may simply refuse to contain any other objects, or just objects of specific types. 
  338. PowerPoint graphs, for example, though they behave as objects, cannot act as containers for other 
  339. objects. Whether or not an object acts as a container for another object is one of the behaviors of that 
  340. object.
  341. Most containers are also objects, in the sense that they can be contained, but this is not a requirement. 
  342. The desktop, for example, is typically treated as a "root" or "high-level" container, that cannot be con-
  343. tained in any other containers. Certain kinds of large compound documents or "workspaces" may 
  344. exhibit similar behavior.
  345.   Containment
  346. At the core of the model developed here is the relationship between objects and their containers. 
  347.   Behaviors: editing
  348. The content and behavior of an object are unaffected by its container. A Canvas drawing contained in a 
  349. Word document, for example, behaves exactly as if it were part of a Canvas document: it retains all of 
  350. the behaviors of a Canvas drawing, and all of the operations that are legal for such drawings remain le-
  351. gal. This is the crucial difference between containment and our current implementations of pasting op-
  352. erations: a contained object is conceptually unaltered by its new environment, and all of its behavior is 
  353. managed by the tools that are associated with its class.
  354. Any changes to a contained object are made using the object s (not the container s) tools. In current 
  355. implementations (e.g., embedded graphs in PowerPoint 2.0) the user is made explicitly aware of this: 
  356. editing occurs in a window owned by the application representing the contained object s editing tools.  
  357. While in the container, the object is "shrink-wrapped"; it may be seen, but must be opened in order to 
  358. modify it. In future implementations, editing may occur in situ using interfaces (editable views) 
  359. provided by the object but presented in the container.
  360.   Presentation: display and printing
  361. The presentation of a contained object is also determined by the object, but is constrained by its 
  362. container.  In some cases, for example a hypertext link, a container may simply not request any 
  363. presentation for a contained object, and the object will not be directly visible; instead some marker icon 
  364. or other indication would be displayed as the handle to activate the link. More often, the object s 
  365. presentation will be constrained to a region provided by the container.
  366.   Dependent objects
  367. One object may be part of a larger object, such that it has no real meaning independently of the whole.  
  368. As a result, when such an object is copied (see below) or moved, other parts of the whole may be 
  369. duplicated or moved with it, and any changes to the behavior (editing) of the object can only take place 
  370. in the context of the whole, which is exposed to the user when the object is opened.  When, for 
  371. example, a selection (say a summary table) from a spreadsheet is copied, all the portions of the 
  372. spreadsheet upon which those cells depend are also copied.  For simplicity, this will normally mean that 
  373. the entire spreadsheet is copied even though only a small part is selected and will be visible in the 
  374. destination container.
  375.   Operations
  376. This model has three fundamental "transfer" operations: move, copy, and link. This operation is always 
  377. applied to a specific argument, and has two additional operands: a source and a destination. The source 
  378. contains the argument when the transfer is initiated.
  379. After one of these operations is completed, the contents of the source and destination will vary 
  380. depending on the operation performed. The results of these operations are summarized in the table 
  381. below, and explained in more detail in the following sections.
  382.  
  383. Form of Transfer
  384. Source
  385. Destination
  386.  
  387. Move
  388. Nothing
  389. Argument
  390.  
  391. Copy
  392. Argument
  393. Duplicate of argument
  394.  
  395. Link
  396. Argument
  397. Link to argument
  398.  
  399.  
  400. The argument to one of these operations may be some data managed by the containing document, or it 
  401. may already be a linked or embedded object managed by some application other than that of the 
  402. containing document.  Thus objects once embedded or linked may be moved to other containers.  If the 
  403. argument is initially data manged by the containing document and it is copied or moved to another type 
  404. of document, and embedded object will be created.  The link operation always creates a link to the 
  405. selected region of the source document.
  406. An object or link is copied (moved) from one place to another using the Copy (Cut) command in the 
  407. source, followed by a Paste command in the destination. A link to an object is established by using the 
  408. Copy command followed by Paste Link. (See Parts 2 and 3.)
  409.   Move
  410. When an object or link is moved, it is taken out of the source, and placed in the destination. Note that, 
  411. as mentioned above, since the object must retain all of its content and behaviors in the destination, and 
  412. since these may depend on other parts of the source, those may be duplicated, and moved along with 
  413. the object. If, for example, a range of Excel cells is moved, and if that range has dependencies on other 
  414. parts of a spreadsheet, those parts of the spreadsheet will be duplicated, and moved along with the 
  415. selected cells. It is important also to reiterate that the presentation in the destination depends only on 
  416. the object (not the whole of the source) so that none of these precedent portions of the owner are 
  417. visible in the destination, except to the extent that they influence the object s presentation through its 
  418. content or behavior.
  419. An object or link (see "Link", below) is moved from one container to another using the Cut and Paste 
  420. commands.
  421.   Copy
  422. When an object or link is copied, an exact duplicate of that object or link is created in the destination. 
  423. Note that, as with the move operation, the duplicate must have all of the content and behavior of the 
  424. original, and since these may depend on its owner, parts of the owner may also be duplicated along 
  425. with the object. Also, as is the case for moved objects, none of these precedent portions of the owner of 
  426. the copied object are visible in the destination.
  427. An object or link is copied from one container to another using the Copy and Paste commands.
  428.   Link
  429. The link operation creates a link in the destination to the source argument; the object in the source is 
  430. unaffected. A link behaves as a clone of the object it is a link to. Conceptually, any changes to the 
  431. behavior or content of an object are immediately reflected in all links to it, in practice, containers may 
  432. delay the presentation of these changes. 
  433. Links are subordinate to the objects to which they refer. Because of this difference between objects and 
  434. links, deletion of a link has no effect on the object it refers to, while deletion of an object makes all 
  435. links to it invalid. It is up to containers to decide what to do with any invalid links they contain. In a 
  436. sense, links are a way of sharing objects: an object may exist in only one container, but it may be shared 
  437. with other containers by placing links to it in those containers.
  438. A link to a part of one container is created in another using the Copy and Paste Link commands.
  439.   Variations
  440. The basic functionality described above covers cases where the object is visually contained in the client 
  441. document, whether it is embedded or linked in storage terms.  The model allows for cases where the 
  442. object itself is not visually contained, but may be opened from the container, in analogy to a footnote or 
  443. reference citation in a document.  Similarly, the basic functionality is described in terms of objects with 
  444. a static visualization which may be edited.  The model also allows for dynamic or non-visual objects 
  445. such as voice annotations or actions which may be invoked.
  446.   Dynamic Objects
  447. Some applications provide a kind of pop-up annotation, where some textual or other material is 
  448. attached to some element of a document and may be called up on command.  There may or may not be 
  449. additional visual indication of the existence of the annotation.  Some objects have annotation-like user 
  450. interface appearance and behavior.  For example, a voice object might be  displayed as a small icon, 
  451. which when double-clicked would cause the voice message to be played.   We discuss the nature of the 
  452. object (voice etc.) separately from the characteristics of annotations in general.  Other aspects of 
  453. annotations include the ability to show some or all annotations, suppress them, show markers where 
  454. annotations exist etc., and the ability to specify these attributes separately for display and printing.  
  455. Unless the container provides support for control of annotations (see below) dynamic objects will 
  456. appear in the printed form just as they do in the displayed form.
  457. Voice, sound and animations
  458. When a time-varying object is created by (e.g.) recording a spoken utterance, or constructing a script 
  459. with an animation editor, the result can be copied or linked into a container document.  The creator 
  460. should provide a static visualization that will be inserted into the container at the insertion point.  This 
  461. visualization might be small in the case of non-visual objects like voice, or a full-size picture if the 
  462. animation is visual. The user can open the object, in which case the animation should be run (thus 
  463. playing the voice message, or running the animation or live-action video in place or in a pop-up 
  464. window).
  465. As an example consider adding a voice annotation to a word processor document that does not 
  466. understand voice.  The user would activate the recorder (perhaps simply by switching on a 
  467. microphone) and say his piece.  The recorder tool would construct a voice object with an icon (say a 
  468. pair of lips) as its visualization, and put it on the clipboard.  The user would return to the word 
  469. processor, and simply Paste the voice object into the current insertion point.
  470. Handwritten annotation could work identically except perhaps in how the recorder is started: the user 
  471. may have to click on a freehand tool or otherwise indicate that his input is to be recorded as strokes 
  472. rather than recognized as text.
  473. If the user wishes to modify the object rather than play it, there are two means at his disposal.  First is 
  474. simply to create a new object and replace the first, which is suitable for recording a new voice message 
  475. but not for re-scripting a major motion picture.  The second method is to open the object, stop playing 
  476. and activate the editing commands.
  477. Actions: executable objects
  478. Executable objects such as macro scripts are much the same as animated objects in their creation and 
  479. visualization except that once execution has started it cannot be undone.   A suitable visualization for 
  480. an action would be a button labelled with a creator-defined name.  The editor for the macro script 
  481. would supply this visualization when the object is copied or linked into the container, using the normal 
  482. mechanisms.  Actions would not execute when opened from the container; instead a button click is 
  483. required to start execution.  Editing the action would be supported simply by activating the editing 
  484. commands instead of the execute button.
  485.   Hypertext and Annotations
  486. A hypertext link is represented as a small sensitive element in the container document which the user 
  487. can open to show the linked object.  Clearly, if the server has a small element that can be selected and 
  488. linked, this appearance can be achieved with normal links.  Otherwise, links which do not require the 
  489. full picture of the linked object can be provided without requiring support in either client or server, 
  490. beyond the functionality required for linked and embedded objects.
  491. We will provide an example object type that acts as the intermediary between client and server.  It 
  492. behaves (to the client) as a normal embedded object, and gives as its visualization a small picture.  This 
  493. object acts as a client to the target of the link.  It encapsulates the link and substitutes the alternative 
  494. visualization.  The object interprets the "open" action to mean open the linked object, thus giving the 
  495. look and feel of a simple hypertext-like link.  
  496. The look and feel of the intermediaryobject and its editor will be specified separately from this 
  497. document.  
  498. Client-provided hypertext links
  499. The other case of hypertext link is where the sensitive element is part of the container's data, such as a 
  500. keyword in text, or a drawing element in a picture.  In this second case, a the container must provide a 
  501. Create Link command to attach the link to the selection instead of inserting the visualization of the 
  502. linked object into the container.  The container must have ways to allow the user to activate the link 
  503. and to edit the data to which it is attached.  Typically, containers will have views in which the structure 
  504. of the data is exposed and can be edited, such as a formula bar or a field codes view.  This view should 
  505. be used to edit the data that is attached to the link, and should also permit the user to change a visual 
  506. link to a hypertext link and vice versa.  The normal view should interpret input actions as related to the 
  507. link rather than the data, so that clicking on a word would open the linked object.
  508. Client-provided annotations
  509. Annotations are pieces of information associated with but not an intrinsic part of a document.  
  510. Annotations may be suppressed or shown when printing and displaying the document.  The content of 
  511. the annotation may be shown, or a hypertext-like indication that an annotation exists and can be 
  512. opened.  Annotations should be able to hold any kind of information, just as the main body of the 
  513. document can.  Examples of annotations are hidden text, footnotes, side notes, end notes, voice 
  514. annotations with an icon in the document, handwritten notes on a pop-up post-it note etc.
  515. Annotations of this kind must be managed by the container, in that it provides the user with the ability 
  516. to create annotations, show/hide them on printer/display independently, move information between 
  517. the main body and the annotation etc.
  518.  
  519.  
  520.   User Interface
  521.  
  522. The user interface described here is not definitive.  This 
  523. specification is preliminary, and will be superceded by 
  524. a separate user interface specification document.  The 
  525. latter document will specify the user interface that will 
  526. be implemented by Microsoft products and which is 
  527. recommended for all Windows applications, in the 
  528. interests of consistency.
  529.   Terminology
  530. This document will be clearer to the reader if the following use of terminology is understood.
  531. When an object is put on the clipboard, it is represented by two formats, Native which contains the 
  532. native data for the object, and OwnerLink, which describes the class of the object and identifies the 
  533. part of the object that is to be displayed in the container.  When a link is being copied or moved out of 
  534. a container, it is represented just by the OwnerLink format.  When a new link is being created (with the 
  535. Paste Link command), the ObjectLink format is used.  In all cases, if a class-specific rendering DLL is 
  536. not available, some presentation format (Picture etc) will also be taken from the clipboard by the client 
  537. library.
  538. When describing behavior in the client application or library, the term object, unless qualified, refers to 
  539. either an embedded object or a link.
  540. Client  A document that is a container of objects managed by other applications, or 
  541. the application that manages such documents. The term container is also used 
  542. where the usage is clear.
  543. Server  An application that provides editing and rendering services to clients for linked 
  544. or embedded objects.
  545. Source  The document (and application) that provides data in a transfer operation; 
  546. this will be the application where a Cut or Copy command is invoked.
  547. Destination  The document (and application) that receives data in a transfer 
  548. operation; the site of the paste command (or a variant).
  549. Owner  The server for a linked or embedded object. This may be different from both 
  550. source and destination in the case where an object is selected and transferred.
  551. Presentation  Data sent from the server to the client so that the client can display and 
  552. print the object in the containing document.
  553. Native The data that completely defines the object, whose format and interpretation is 
  554. known only to the server (owner). This data is transferred between client and server 
  555. in the case of embedded objects, where the client provides permanent storage 
  556. (within the container document) and the server provides editing.
  557. Link  A link between a container and another document. The linked object is visible 
  558. in the container document (either the visualization of the object itself, or some 
  559. other indication), and can be opened for editing, but is stored in another document.
  560.  
  561. This term is also used to refer to the existing Link format transferred through DDE 
  562. and the clipboard.
  563. ObjectLink A DDE and clipboard format carrying a descriptor for the source object. 
  564. It is used to identify the class, document, and item that is the source of data for a 
  565. linked object.  An ObjectLink is represented internally as three null-terminated 
  566. strings followed by a null string (i.e. a null character).
  567. OwnerLink  A DDE and clipboard format carrying a descriptor for the owner of a 
  568. linked or embedded object. This has the same representation as ObjectLink, and is 
  569. used to communicate information about the owner of an object, which may be 
  570. distinct from the source.
  571. ClassName  Identifies the type of an object. This is used to identify the editor to be in-
  572. voked.
  573. DocumentName  Identifies the object itself. For linked objects, this is the pathname of 
  574. the file containing the object. For embedded objects, the DocumentName is only 
  575. used when opening the editor, and is a name manufactured by the client to 
  576. guarantee uniqueness of access to the server.
  577. ItemName  Identifies the portion of the server document that is the object. The Item-
  578. Name is manufactured by the server and passed to the client as an uninterpreted 
  579. identifier for latter use. The server must ensure persistence of the mapping from 
  580. this identifier to the object.
  581.  
  582.   Commands for Embedding and Creating Links
  583. Applications support the embedding of objects and the creation of links through four commands (Cut, 
  584. Copy, Paste and Paste Link) on their "Edit" menus.  In addition there are two optional commands, 
  585. Insert new Object, and Paste Special.
  586.   Copy
  587. The "Edit-Copy" and command is used to transfer data, objects, and links out of documents. It places a 
  588. copy of the selected item on the clipboard, and "marks" the current selection for subsequent use in 
  589. paste-link operations.
  590. The Copy command offers formats to the clipboard in three groups: The first group consists of data 
  591. formats that adequately describe the selection, ordered by the fidelity with which they describe it (most 
  592. preferable is offered first-e.g., Word would offer RTF, then CF_TEXT); the second group consists of 
  593. a complete, encapsulated description of the selection that can be used to create an embedded object in 
  594. the destination container (expressed in Native and OwnerLink formats); and, the third group consists 
  595. of presentation formats (minimally CF_METAFILEPICT) and other formats into which the selection 
  596. can be rendered.
  597. It is not possible to link to an embedded object, only to its container; embedded objects are private to 
  598. their containers.  If the source can be a server for links and is not an open embedded object, it will also 
  599. offer ObjectLink format, and Link format if compatibility with existing links is desired.
  600. The following table summarizes the ordering of formats placed on the clipboard by the copy command:
  601.  
  602. Group
  603. Examples
  604.  
  605. Descriptive Formats
  606. XLC, BIFF, RTF, CF_TEXT
  607.  
  608. Encapsulated Object
  609. Native, OwnerLink
  610.  
  611. Presentation Formats
  612. CF_METAFILE, CF_TEXT, RTF
  613.  
  614. Mark
  615. ObjectLink, Link
  616.  
  617.  
  618. Note that the same format may be used in different groups under different circumstances (described in 
  619. more detail in Part 3), but that any given format should only be listed once on the clipboard.
  620.   Cut
  621. The "Edit-Cut" and command behaves exactly like the copy command, except that it never places Link 
  622. on the clipboard. Otherwise, all of the rules described above for the copy command apply.
  623.   Paste
  624. The "Edit-Paste" command pastes the object, data, or link on the clipboard at the current insertion 
  625. point. If data is on the clipboard then the data is converted into a native data type of the container as it 
  626. is pasted; if an object is on the clipboard it is embedded in the container; if a link is on the clipboard it 
  627. is used to create a link in the container.
  628. The Paste enumerates the formats available on the clipboard in order, and takes the first format that is 
  629. compatible with the target for the Paste command. If no suitable data format is found, a compound 
  630. document client will make an embedded object from the Native and OwnerLink formats, and 
  631. enumerate further formats to find and obtain a format for presentation. The destination application 
  632. may have different preferences for formats depending on where the selection is in the destination 
  633. document (e.g. pasting into a picture frame vs. pasting into a stream of text).
  634. After the paste operation is completed, containers should select the newly pasted item, unless the item 
  635. has been converted to a container-native type. This behavior, though not widely implemented in 
  636. existing applications, helps users gain quick access to the properties of a newly embedded or linked 
  637. object.
  638.   Paste Link
  639. The "Edit-Paste Link" command creates a link, at the current insertion point, to the item "marked" by 
  640. the previous copy operation. This command should be disabled if link information is not available on 
  641. the clipboard.
  642. The paste-link command behaves like the paste command in its enumeration and selection of data and 
  643. presentation formats, but first checks for the existence of the ObjectLink format, and ignores the 
  644. Native and OwnerLink formats. If ObjectLink and a useful format are found, the destination 
  645. application uses them to create a link at the current insertion point.  If ObjectLink is not found on the 
  646. clipboard then the destination may look for a Link, to handle links to existing (non-object) applications.
  647. As with the paste operation, containers should select the new link.
  648.   Insert New Object
  649. New objects are created in containers using the "Insert New Object..." command on the Edit menu, or 
  650. alternatively a "New Object..." command on an Insert menu if the application has one. This command is 
  651. not a required part of the user interface for compound documents, since the user can always create 
  652. objects with the editor or copy an existing object, and embed the result into the container. Some 
  653. applications may nevertheless wish to provide such a command, if for example it is a common scenario 
  654. that they wish to accelerate. In that case, the user interface described here should be used.
  655. This command opens a modal dialog as shown below.  The listbox is filled with the names of types of 
  656. objects that support the required protocol.  This list is obtained from the system registration service 
  657. (see Implementor's Guide).
  658. If the user selects a typename the container application will launch the editor for the type. The editor 
  659. creates a new blank object. This new object is inserted in the container the first time the user updates 
  660. from the editor. Once the first update is completed, editing proceeds as for a normal embedded object.
  661.  
  662. Insert New Object dialog
  663.   Paste Special
  664. To be supplied
  665.   Presentation in Containers
  666.   Normal Display
  667. During normal display of an object (e.g., screen display and printing) only the object itself is visible. 
  668. The user is not aware of any precedent parts of the object. The object s container determines the 
  669. region in which the presentation is to be displayed; the presentation itself is provided by its owner.  
  670. Similarly, during normal display of a link only the linked item is visible. The user does not see any other 
  671. parts of the linked item s source. The link s container determines the region in which the presentation 
  672. is to be displayed; the presentation is provided by its source.
  673.   Section Boundaries
  674. Each object or link may have a three-pixel thick section boundary added to its presentation by its 
  675. container. These boundaries are used to identify and manipulate the components of a compound 
  676. document. They immediately circumscribe an item s presentation, and take one of two forms:
  677.  
  678. PC VGA
  679. PC Other 
  680. Macintosh
  681.  
  682. Gray
  683.  
  684. 50% gray pattern
  685.  
  686.  
  687. Concentric lines: 
  688. 50% gray, white, 
  689. 50% gray
  690.  
  691.  
  692.  
  693. Boundaries are applied to an object or link whenever it is part of the current selection. Container 
  694. applications may provide modes where section boundaries are displayed for all objects. Clicking on a 
  695. visible boundary selects the entire object or link it circumscribes. In all other circumstances, section 
  696. boundaries are absent. 
  697.   Selection Behavior
  698. Aside from the special result of selecting a section by clicking on its boundary, the selection behavior of 
  699. objects and links is based entirely on their presentation.  Containers should, however, prevent users 
  700. from selecting items that they cannot edit in the container. 
  701.   Editing in Containers
  702. The  container may allow the user to change any aspect of the presentation of an embedded object or 
  703. link that is preserved when the presentation is updated to reflect changes to the content object. An 
  704. attempt to change anything that is not preserved is not allowed. 
  705.   Opening
  706. When an object is opened for editing, the application responsible for maintaining its editing tools (its 
  707. editor) is launched with at least one new window displaying the object. The editing application may 
  708. present the object in additional views and windows; this is up to the editing application to determine, 
  709. but should be consistent for each type of object the application edits. The titles for windows opened by 
  710. an editor should correspond to the name of the object provided by the container. Any precedent 
  711. portions of the object s owner may also be displayed, and may be directly edited; however, editors 
  712. should size the initial display of objects so that they present only the object and not the parts of its 
  713. owner on which it depends. 
  714. While the editor has a window open for an embedded object, the object s presentation in the container 
  715. is dimmed or grayed out by the container s application; its object properties dialog becomes 
  716. unavailable and its container s "<Object> Properties..." command (see Displaying Properties, below) 
  717. is dimmed when it is selected. The container s presentation of the object need not change to reflect 
  718. changes being made in the object s editor until the user explicitly updates the container s presentation.
  719. When a link is opened, the entire document to which it refers is opened and displayed by its editor, 
  720. with that document s name used in the displaying windows.  Applications should display and select the 
  721. linked portion of the document.
  722.   Operations in Containers
  723. All containers must support a set of operations for all objects or links which they contain.
  724.   Displaying Properties
  725. Applications that support this model must implement an "<Object>  Properties..." command in their 
  726. "Edit" menus; selecting this command produces an object properties dialog  for the currently selected 
  727. object or link. If no object or link is selected, the menu item is disabled, and should read "Properties...". 
  728. Alt-double-clicking on the section boundary of any object or link also produces the object properties 
  729. dialog for that item. All object properties dialogs have the following general components:
  730.  
  731. Function
  732. UI component
  733.  
  734. Description of 
  735. object
  736. Text describing the type, name (if any) and nature (link, embedded object, etc.) of the 
  737. object.
  738.  
  739. Opening
  740. A button that opens the object or link for editing.
  741.  
  742.  
  743. The properties dialogs for links have the following additional components:
  744.  
  745. Function
  746. UI component
  747.  
  748. Select an 
  749. update rule
  750. A flexible list of exclusive options (e.g., pop-up menu) presenting a list of container specific 
  751. rules for updating the presentation with current information about the linked item s content. 
  752.  
  753. Manual 
  754. updating
  755. A button that causes a link s presentation to be immediately updated, regardless of the 
  756. currently specified update rule.
  757.  
  758. Link repair
  759. Edit fields to permit the user to alter the link document name and optionally item name.
  760.  
  761. Unlink from 
  762. source
  763. A button that permanently disconnects a link from the item to which it refers, leaving only 
  764. the presentation.
  765.  
  766.  
  767. The properties dialogs for objects have the following additional component:
  768.  
  769. Function
  770. UI component
  771.  
  772. Convert to 
  773. only the 
  774. presentation
  775. A button that freezes the object s presentation in its current state by discarding the native 
  776. data associated with the object.   The effect is to convert the object into the datatype being 
  777. used for the presentation.
  778.  
  779.  
  780. In addition to the components listed above, each dialog may have components specific to the 
  781. container s presentation of the object or link.  These additional components appear in designated 
  782. areas of the dialogs, but the details of their layout and function is determined by the container. In 
  783. general, however, they should not dismiss the dialog of which they are a part, nor should they cause any 
  784. changes in the container until the OK button is pressed.
  785. The following sections illustrate the behavior and appearance of the object properties dialogs.
  786.   Properties Dialogs for Links
  787. When a link is selected, the "<Object> Properties..." command should be enabled as "Link Proper-
  788. ties..." and should produce the following link properties dialog:
  789.  
  790. When this dialog appears, the class, item and document fields in the link s description should be filled 
  791. with the appropriate information supplied by the link information.  The latter two fields are made 
  792. editable to permit users to repair broken links (e.g. because the file was renamed). The "Update" radio 
  793. buttons should indicate the link s current update rule. Any container-specific controls should be added 
  794. by expanding the dialog downward.
  795. The components of this dialog behave as follows:
  796. The Update radio buttons are used to select an update rule. New update rules do not 
  797. take effect until the dialog is dismissed with the OK or Edit Source button.
  798. The Update button updates the link s presentation, but leaves the dialog open to allow 
  799. the user to cancel the update. If the change can t be cancelled the text of the 
  800. cancel button should be changed to "Close."
  801. The Edit Source button accepts all changes to the update rules and presentation, 
  802. closes the dialog, and opens the linked item in its editor.
  803. The OK button accepts all changes and closes the dialog.
  804. The Cancel button cancels all changes and closes the dialog.
  805. The Unlink button discards the link information and keeps only the current 
  806. presentation of the link.  The link may not be opened after this operation.
  807.   Properties Dialogs for Embedded Objects
  808. When an embedded object is selected, the "<Object> Properties..." command should be enabled, with 
  809. <Object> replaced by the name of the object s class, and should produce a dialog similar to the above, 
  810. with "Reference to" replaced by "Embedded", and without the Update radio buttons.  The Update and 
  811. Edit buttons retain their meaning. The dialog may contain an additional button labelled "Change to 
  812. Picture" (or other data type e.g. text), to permit the object to be converted to data that can be 
  813. manipulated within the container application.  Any container-specific controls should be placed in the 
  814. area beneath the object s description, or added by expanding the dialog downward.
  815.  
  816. The components of this dialog behave as follows:
  817. The Edit button accepts all changes to the object s presentation, closes the dialog, and 
  818. opens the embedded object in its editor.
  819. The OK button accepts all changes and closes the dialog.
  820. The Cancel button cancels all changes and closes the dialog.
  821. The Change to Picture button freezes the object s presentation in its current state by 
  822. discarding the Native data associated with it, leaving behind only the picture 
  823. used for the current presentation. This button leaves the dialog open to allow 
  824. the user to cancel the update, and disables the "Edit" button to indicate that 
  825. the object is no longer editable. If the change can t be cancelled the text of 
  826. the cancel button should be changed to "Close."
  827.   Opening Objects
  828. A contained object or link is opened for editing by pressing the edit button in its object properties 
  829. dialog.  It is simply opened (which implies executing the object's default action such as playing a voice 
  830. message) by double-clicking anywhere on its boundary. Items with atomic presentations may also be 
  831. opened by double-clicking on any part of the presentation.
  832. An attempt to open an object or link fails if its editor or object handler is unavailable; opening a link 
  833. also fails if the document to which it refers is unavailable.
  834. No menu command is provided for these operations.
  835.   Control of Updates for Links
  836.   Changing Update Rules
  837. The update rules for a contained link may be changed at any time by selecting a new update rule from 
  838. the list presented in a link s object properties dialog. Containers determine what update rules they 
  839. support for the links they contain, and may support different update rules for different kinds of links 
  840. based on the nature of the links (data or presentation link) or on the type of the linked item. 
  841. Containers also determine what default update rule to assign to a link when it is created. All containers 
  842. must support "manual" and "automatic" updates, and will typically support the same set of update rules 
  843. for all links.
  844. No menu command is provided for this operation.
  845.   Updating Presentations
  846. The presentation of a link may be updated to reflect the current content of the item to which it refers 
  847. at any time, regardless of the currently specified update rule, by pressing the update button in the 
  848. object s properties dialog. Containers should support an undo of this operation through the cancel 
  849. button in the link properties dialog.
  850. No menu command is provided for this operation. 
  851.   "Disconnecting" Links
  852. A link may be "disconnected" from the item to which it refers in either of two ways: the link may be 
  853. either unlinked from, or replaced by, that item. In the first case, all that remains of the link is its 
  854. presentation, frozen in its state at the time it was unlinked or updated immediately before unlinking; in 
  855. the second case, the link is replaced by a copy of the linked object, and its presentation is updated. This 
  856. second case is essentially the same as an automated "Copy" followed by "Paste." Both operations are 
  857. executed by choosing the appropriate option in the link s unlink dialog.
  858. No menu commands are provided for these operations. 
  859.   Repairing Broken Links
  860. It is possible for a link to be "broken" by deleting or renaming the document that is the target of the 
  861. link.  The user may repair the link in this case by editing the document name (and optionally item 
  862. name) in the Link Properties dialog.
  863.   "Freezing" Presentations of Objects
  864. The presentation of an object may be "frozen" in its current state by pressing the "Change to Picture" 
  865. button in the object s properties dialog. As a result of this operation, the Native and OwnerLink 
  866. information describing the object are discarded, leaving only its current presentation behind. 
  867. Depending on the nature of the container and the presentation, this presentation may either be 
  868. uneditable (e.g., a picture in a word processor) or useful as editable data (e.g., in a picture in a paint or 
  869. draw application). In any case, the object is no longer editable by its original owner.
  870. No menu commands are provided for these operations. 
  871.   Displaying Section Boundaries
  872. The section boundaries of all objects and links in a container may be displayed simultaneously by 
  873. executing a show section boundaries command. This command may be implemented differently, if at 
  874. all, by different applications. Typically it should be implemented as part of any existing commands that 
  875. show document structure and should thus not require a new menu command.
  876.   Undoing Changes to Embedded Objects
  877. On return from an editor of an embedded object (see "Returning to Containers" below) the container 
  878. of that object should enable its "Edit-Undo" command. This command should undo the entire editing 
  879. session for the embedded object; executing this command restores the embedded object to its state 
  880. when it was last opened for editing, and discards all changes made in its editor. 
  881. Note that as a consequence of this behavior, returning to a container from an embedded object s editor 
  882. commits the previous operation in its container-which need not have been opening the embedded 
  883. object-in applications that support only a single level of "undo."
  884.   Operations in Editors
  885. Applications that act as editors for linked or embedded objects need to make minor modifications to 
  886. their behavior and user interfaces.
  887.   Updating Presentations
  888. While an application is acting as an editor for an embedded object (i.e., while its active window 
  889. contains such an object) it should replace its "File-Save" command with "File-Update." Executing this 
  890. command updates the presentation of the object in the container.  When a user closes the main 
  891. editing window for an embedded object or quits the editing application, he is given an opportunity to 
  892. update the presentation in the container.
  893. While an application is editing a new embedded object-one that was created as the result of an "Insert 
  894. New..." operation, but which has not yet been inserted in a container-it should replace its "File-Save" 
  895. command with "File-Insert." Executing this command copies the object to the container,  at which 
  896. point the command is replaced with "File-Update." When a user closes the main editing window for 
  897. such an object or quits the editing application, he is given an opportunity to insert the object in the 
  898. container.
  899. The "File-Save" command behaves normally for editors of linked objects: it saves the document of 
  900. which the object is a part, but has no effect on the link in the client container, other than that specified 
  901. by the link s update rules.
  902.   Saving Copies of Objects
  903. While an application is acting as an editor for an embedded object, it should replace its "File-Save 
  904. As..." menu item with "File-Save Copy As..." When the user executes this command while an embed-
  905. ded object is being edited, the application should save a copy of the object, with the name provided by 
  906. the user, but should continue displaying the original object, and should not display the new copy.  
  907. Applications that already have a "Save Copy As..." command should simply disable their "Save As..." 
  908. commands while editing embedded objects.
  909.   Returning to Containers
  910. When the user quits the editor for an embedded or linked object, the following behavior should result:
  911.  
  912. State of Editor
  913. Result
  914.  
  915. A single linked or embedded object is 
  916. being edited. Other documents may 
  917. also be open.
  918. Focus returns to the container for the 
  919. linked or embedded object.
  920.  
  921. Several linked or embedded objects are 
  922. being edited. Other documents may 
  923. also be open.
  924.     or
  925. No linked or embedded objects are 
  926. being edited.
  927. Focus returns to the layer immediately 
  928. beneath the editor. (Current normal 
  929. behavior.)
  930.  
  931.  
  932. Additionally, if a single linked or embedded object is being edited, and if no other documents are open 
  933. in the editor, then when the object s main window is closed, the editor quits.
  934.  
  935.  
  936.   Implementor's Guide
  937.   Introduction
  938. The implementor s guide gives a description of the main commands related to linked and embedded 
  939. documents, and the actions that clients and servers should take to provide the right results. Part 4 gives 
  940. the specification of the library functions that applications call.  The appendix gives details of the DDE 
  941. messages that the library uses to implement these actions.
  942. The overall structure of the libraries is shown in the diagram below.  A client deals with linked and 
  943. embedded objects through opaque handles and API calls to the compound document library DLL.  
  944. That DLL makes calls on system services (registration,  DDE etc) and may also make use of additional 
  945. DLLs that may be supplied to manage or render particular types of object.  The client application is 
  946. unaffected by this.
  947.  
  948.   Clipboard Conventions
  949. A major part of the compound document support required is concerned with creating objects and 
  950. moving them around among containers. The majority of this will be done with the clipboard-based copy 
  951. and paste commands. The effect of these commands depends on the nature of the selection that is Cut 
  952. or Copied, and the target for the Paste command.
  953. The rules for how the Copy and Paste commands deal with the clipboard are relatively simple. The 
  954. Copy command offers formats to the clipboard in order of their fidelity of description of the selection 
  955. (most preferable is offered first). The clipboard preserves this ordering, and uses it as the order when 
  956. another application enumerates the available formats. The source application will offer data formats 
  957. that adequately describe the selection (e.g. RTF for a part of a structured document), then it will offer 
  958. and embedded object (communicated by Native and OwnerLink formats), then presentation (e.g. 
  959. Picture) and other formats into which the selection can be rendered. If the source can be a server for 
  960. links, it will also offer Link format.
  961. If the source selection is an embedded object, or a link, which is not modified by the source container, 
  962. then the appropriate formats to represent the object are the owner s Native and OwnerLink. If the 
  963. source container has modified the object s presentation (e.g. recolored it), or if the selection is a range 
  964. that includes such an object, then the source should offer descriptive formats if such exist (e.g. some 
  965. enhanced RTF), and offer the source s Native and OwnerLink.
  966. The Paste command will enumerate the formats available on the clipboard in the order in which they 
  967. were offered, and will take the first format that is compatible with the target for the Paste command. If 
  968. no suitable data format is found, a compound document client will make an embedded object from the 
  969. Native and OwnerLink formats, and enumerate further formats to find and obtain a data or 
  970. presentation format. The destination application may have different preferences for formats depending 
  971. on where the selection is in the destination document (e.g. pasting into a picture frame vs. pasting into 
  972. a stream of text).
  973. The Paste Link command behaves like the Paste command in its enumeration and selection of data and 
  974. presentation formats, but first checks for the existence of the ObjectLink format, and ignores the 
  975. Native and OwnerLink formats. If ObjectLink and a useful format are found, the destination 
  976. application makes a data link or a compound document link as appropriate.  If ObjectLink is not 
  977. available, the destination may look for a Link format and create a non-object link  as in existing 
  978. applications.
  979. Non-compound document applications that try to Paste from such a clipboard offering will simply 
  980. ignore the Native, OwnerLink and ObjectLink formats, and behave as they do now. Non-compound 
  981. document applications that Copy to the clipboard will not offer these formats, and a data transfer will 
  982. result, as happens at present. It is possible that some existing applications do not follow the rules on 
  983. offering preferred formats first, and that a compound document application following these Paste rules 
  984. will end up with a different result than it would today.
  985. The following tables show the results of these rules in various representative scenarios.
  986.  
  987. Source selection
  988. Clipboard contents, in order
  989.  
  990. Pictorial data
  991. e.g. a chart in Excel or a CAD 
  992. drawing or part of a 
  993. presentation etc.
  994. Application or domain specific formats e.g. .XLC, DRW
  995. Native(src)
  996. OwnerLink(src)
  997. Picture
  998. ObjectLink, Link
  999.  
  1000. Structured data
  1001. e.g. a range of a spreadsheet 
  1002. or a data table in a DBMS etc
  1003. Structured data formats e.g. Biff
  1004. Structured document formats e.g. SGML, RTF
  1005. Native(src)
  1006. OwnerLink(src)
  1007. Picture, Text etc.
  1008. ObjectLink, Link
  1009.  
  1010. Range of structured document
  1011. Structured document formats e.g. SGML, RTF
  1012. Native(src)
  1013. OwnerLink(src)
  1014. Picture, Text etc.
  1015. ObjectLink, Link
  1016.  
  1017. Compound document link
  1018. (unmodified by the container)
  1019. OwnerLink(owner)
  1020. Picture or other presentation format
  1021. ObjectLink, Link
  1022.  
  1023. Embedded object
  1024. (unmodified by the container)
  1025. Native(owner)
  1026. OwnerLink(owner)
  1027. Picture or other presentation format
  1028. ObjectLink, Link
  1029.  
  1030.  
  1031. Note that because of the ability to have object-specific handler libraries, it will be possible to have 
  1032. Native data in the set of presentation formats available in the above cases.  For this reason the order of 
  1033. appearance of Native and OwnerLink is important to disambiguate an embedded object (Native first) 
  1034. and a link (OwnerLink first) which happens to use (a cached copy of) Native data for its presentation.
  1035.  
  1036. Source selection
  1037. Destination context
  1038.  
  1039.  
  1040. Worksheet
  1041. Structured 
  1042. document
  1043. Picture 
  1044. frame
  1045. Rich text 
  1046. frame
  1047. Presentation 
  1048. graphics
  1049. Draw 
  1050. program
  1051.  
  1052. Pictorial data
  1053. embed
  1054. embed
  1055. embed
  1056. embed
  1057. embed
  1058. embed
  1059.  
  1060. Structured data
  1061. convert
  1062. convert
  1063. embed
  1064. convert
  1065. embed
  1066. embed
  1067.  
  1068. Structured document
  1069. convert
  1070. convert
  1071. embed
  1072. convert
  1073. embed
  1074. embed
  1075.  
  1076. Compound 
  1077. document link
  1078. link to owner
  1079. link to owner
  1080. link to 
  1081. owner
  1082. link to 
  1083. owner
  1084. link to owner
  1085. link to 
  1086. owner
  1087.  
  1088. Embedded object
  1089. embed owner
  1090. embed owner
  1091. embed 
  1092. owner
  1093. embed 
  1094. owner
  1095. embed owner
  1096. embed 
  1097. owner
  1098.  
  1099.  
  1100. Notes:
  1101. ObjectLink always describes the source class, document, and item. Paste Link always 
  1102. uses the ObjectLink format and some data or presentation format (or Link format for 
  1103. non-object sources).
  1104. OwnerLink may describe the source or the owner, but always describes the owner ap-
  1105. plication for the object. Paste will use Native, OwnerLink and some presentation 
  1106. format if no preferable data format is found.
  1107. There are some cases where the user might legitimately want a different result than is given by these 
  1108. rules. There are a number of ways that these can be achieved, some are application-dependent and in-
  1109. volve additional function in applications. Others involve an extra action by the user to achieve the in-
  1110. tended result.
  1111. The first case is where the Copy/Paste rules lead to a data conversion and the user wants to embed. 
  1112. For example, we have chosen to offer structured document formats in preference to Native for 
  1113. structured data, on the grounds that more often the conversion will be what is desired. To force 
  1114. embedding rather than conversion, the user should have ways to select the source material in an 
  1115. unambiguous way (in cases where the source application is rich in both data manipulation and 
  1116. presentation). Additionally, where a destination application is capable of converting document formats 
  1117. as well as embedding, it should offer the user a way to indicate the context into which the Paste is to 
  1118. happen, for example by inserting a picture frame and pasting into that, or through some Paste Special... 
  1119. command.
  1120. Cases where these rules lead to undesired embedding are all dealing with pictures (either source or 
  1121. destination). One variant is that the user wants to take a picture that is the result of a computation (e.g. 
  1122. a chart), and import it into a drawing editor to change it. (The case of annotation is nicely handled by 
  1123. embedding it and adding drawing elements).  Drawing editors might have some special command for 
  1124. this purpose, as it is specific to those applications and is a rare case. The other variant is where the user 
  1125. does not want to pay the storage cost for the Native data, and is prepared to lose the ability to change 
  1126. the picture (except with a drawing editor as above). For this case, command buttons in the property 
  1127. dialogs of the objects allow them to be unlinked or converted to static pictures after the Paste has taken 
  1128. place.  If the user wants to convert an already linked or embedded object, he simply opens it first and 
  1129. selects the data he requires.
  1130. An interesting case occurs where the selection is an embedded picture that the source container has 
  1131. modified (e.g. recolored). Following the rules above, Copy/Paste will cause the recolored object to be 
  1132. embedded in the destination: what the user sees in the source is what he gets in the destination. If the 
  1133. user wants the original picture, he need simply open it or otherwise select the unmodified object, and 
  1134. Copy/Paste that.
  1135.   Registration
  1136. Clients must be able to locate servers for objects that they contain.  This is achieved by servers 
  1137. registering the required information into the system registration database when the server is installed 
  1138. onto the system.  The details of what must be registered are described in the implementor's guide.
  1139. Applications that implemented the protocol prior to the availability of this library and the registration 
  1140. service used a different registration mechanism: they stored information in a special section in win.ini.  
  1141. Applications using this library will have access to those servers transparently, since the registration 
  1142. service will perform the mapping of the registration information.  Similarly, older client applications 
  1143. which look in win.ini will find information about newer servers which were registered with the system 
  1144. since the registration service will store the old format information in win.ini for the purpose.
  1145.   Client
  1146. A client is a container of other objects. A client application uses the services of other applications 
  1147. (servers) to carry out editing and rendering of the objects that the client document contains. The client 
  1148. application provides storage for the object, and contextual information about the target printer, where 
  1149. on the page the picture should be printed, etc., and provides the user with the means to open the object 
  1150. for editing using the correct server application. In order to be a client, or container, the application 
  1151. must provide ways to bring objects into the container and take them out again. The client must provide 
  1152. the permanent storage for the object within the container document s permanent storage (i.e. file).
  1153. For embedded objects, the client library will store the native data for the object, some presentation 
  1154. data for the object (e.g. a metafile), and the link information which contains the ClassName, some 
  1155. client-supplied document name, and the item name associated with the object. Details of use of the link 
  1156. information are given in the protocol reference section later in this document.
  1157. For links to other documents, the client library will store the link information as above, where the 
  1158. document name in this case will be the permanent name for the document (e.g. its pathname), and also 
  1159. the presentation data as above along with a timestamp recording when the presentation data was 
  1160. obtained.
  1161. Certain operations (updating objects, launching and closing down servers etc.) are asynchronous 
  1162. operations.  The library does not retain control during these operations, but marks the objects as busy, 
  1163. and returns to the client so that events can be processed.  As long as the client is dispatching events, the 
  1164. library will process the transactions in a coroutine-like manner.   The library will notify the client by a 
  1165. callback function when the operation completes.
  1166.   Protocol Checking
  1167. A client must check that a server it wants to contact will support the desired protocol. For this 
  1168. specification the protocol is identified by the string "StdFileEditing". The check is performed by 
  1169. passing the protocol name to the library functions that create objects (from clipboard contents, from 
  1170. files etc).
  1171.     if( EcdCreateFromClip( "StdFileEditing", &clientstruct, &lpobj, 
  1172.                     renderopt, cfFormat ) == ECD_OK ) ...
  1173.   Open a Document
  1174. When a client opens a document that contains a link or an embedded object, it should call the client 
  1175. library to load the object.  The client should query the object to determine if it has changed since the 
  1176. document was last loaded and needs to be updated.  If so, the client should accumulate a list of out-of-
  1177. date objects and offer the user the opportunity to update them. Note that for embedded objects it is 
  1178. possible for the presentation data to be out of date, since the embedded object may itself contain links 
  1179. to other objects.
  1180.     load application data from file
  1181.     if found an object
  1182.         if( EcdLoadFromStream( &filestream, "StdFileEditing", &clientstruct, &lpobj) != 
  1183. ECD_OK )
  1184.             return BADFILE
  1185.         if (EcdQueryOutOfDate( lpobj ) != ECD_OK)
  1186.             add object to list of out-of-date items
  1187.     when load completed, if out-of-date objects exist
  1188.         inform the user, offer to update selected objects
  1189.   Save or Close a Document
  1190. When a document containing linked or embedded objects is saved or closed, the client should save the 
  1191. objects into the file by calling EcdSaveToStream.  The library will save up-to-date versions of the 
  1192. relevant data for the objects (native, link, presentation as appropriate) in the client documents 
  1193. permanent storage (e.g. file). If some server is open, the client library will retrieve the data from the 
  1194. servers before saving. If the client launched the server as a slave to edit the object, the client library will 
  1195. close down the server.  Since updates and closing down servers are asynchronous operations, the library 
  1196. may return indicating that the client application should not proceed until the library notifies the client 
  1197. that the operation is complete.
  1198. case SAVE:
  1199.     if( document not saved)
  1200.         save client application data
  1201.         for each object
  1202.             if (EcdSaveToStream( lpobj, &filestream) == ECD_BUSY)
  1203.                 while notification not received
  1204.                     dispatch messages
  1205.     break;
  1206.  
  1207. case CLOSE:
  1208.         for each object
  1209.             if( EcdDelete(lpobj ) == ECD_BUSY)
  1210.                 add to list of objects in process of closing
  1211.         while busy objects remain
  1212.             dispatch messages
  1213.   Display and Print
  1214. The client should set up the device context and bounding rectangle for rendering the object and call
  1215.     EcdDraw( lpobj, hDC, &bounds, hFormatDC );
  1216. The library will either call the class-specific rendering DLL to render the object if available, or will use 
  1217. the presentation data for the objects to display and print in the appropriate place.  The library will 
  1218. periodically call back to the client callback function during drawing.  The client function may check for 
  1219. interrupt etc, and should return zero if it wants to prematurely terminate the drawing.  The EcdDraw 
  1220. function will then return immediately indicating that the drawing was interrupted.
  1221. It is also possible for the client to take some actions within the callback function and return non-zero to 
  1222. indicate that drawing should continue, provided that those actions do not interfere with the drawing e.g. 
  1223. by scrolling the window.  An example is that the client might give up focus during drawing to permit the 
  1224. user to switch to another window.
  1225.   Open an Object
  1226. When the user requests the client to open the object for editing, the client should call EcdOpen(lpobj, 
  1227. fShow).  The library will notify the client when the server is properly open or when something fails.  
  1228. The object may be displayed during this process, but should not otherwise be altered.  FShow tells the 
  1229. server whether to show the window to the user (true, non-zero) or to keep it hidden (false, zero).  The 
  1230. latter is useful for invisibly updating an object.
  1231.   Change Printer, Resize
  1232. Objects are assumed to have a given size on the intended target device (printer etc).  Sizes are all 
  1233. communicated in HIMETRIC units. The client should call EcdSetTargetDevice(lpobj, hTargetDevice) 
  1234. if the target output device is changed, and should call EcdSetBounds(lpobj, &newBounds) if the size of 
  1235. the rectangle is changed (e.g. by user action). See also EcdDraw.
  1236.   Cut and Copy
  1237. Clients must provide support for transferring objects out of their documents through the cut and copy 
  1238. commands, as well as taking them in through paste and paste link commands. There is additional 
  1239. support required for being a server, which is used to create objects from data and to create links. It is 
  1240. likely that many applications will be able to act as both client and server, and it is convenient to 
  1241. describe both here.
  1242. Applications that cannot act as servers for embedded objects would not offer their Native data or Own-
  1243. erLink formats.  Applications that cannot act as servers for links would not offer ObjectLink or Link 
  1244. format. In the case that an application can be a server for embedded objects, it should use the 
  1245. OwnerLink format to convey its name and item information to the receiving application.
  1246. When an linked or embedded object is selected, clients must call EcdCopyToClipboard or 
  1247. EcdCutToClipboard as appropriate.
  1248. The values assigned to each of the formats placed on the clipboard by the copy command will depend 
  1249. on the nature of the current selection. The following algorithm summarizes the rules containers use to 
  1250. assign values to the various formats placed on the clipboard by the copy command:
  1251.     if (selection is link or embedded object)
  1252.         EcdCopyToClipboard( lpobj )     // or EcdCutToClipboard...
  1253.     else
  1254.         offer any data formats that adequately
  1255.                 describe the selection
  1256.         if (can be server for embedded objects)
  1257.             offer Native = source s native data for selection
  1258.             offer OwnerLink = source generated description
  1259.                     of selection
  1260.     offer other formats that can be used to present the selection
  1261.             or into which it can be converted
  1262.     if (can serve links
  1263.             & source is not an open embedded object)
  1264.         offer ObjectLink = source generated description
  1265.                 of location in source
  1266.         if( can serve old kind of links )
  1267.             offer Link = appname/topicname/itemname as in existing applications
  1268.   Paste
  1269. The "Edit-Paste" command pastes the object, data, or link on the clipboard at the current insertion 
  1270. point. If data is on the clipboard then the data is converted into a native data type of the container as it 
  1271. is pasted; if an object is on the clipboard it is embedded in the container; if a link is on the clipboard it 
  1272. is used to create a link in the container.
  1273. The following algorithm summarizes the rules containers apply to the formats on the clipboard to 
  1274. determine how to execute a paste command:
  1275.     for each format on the clipboard in order
  1276.         if format is acceptable for target
  1277.             if format is not Native or OwnerLink
  1278.                 convert the data and paste it in
  1279.             else 
  1280.                 EcdCreateFromClip( "StdFileEditing", &clientstruct, &lpobj,
  1281.                             renderopt, cfFormat )
  1282.         else 
  1283.             continue searching
  1284.     if no format was found
  1285.         refuse paste
  1286. After the paste operation is completed, clients should select the newly pasted item, unless the item has 
  1287. been converted to a container-native type. This will give the user quick access to the properties of the 
  1288. object.
  1289.   Paste Link
  1290. The "Edit-Paste Link" command creates a link at the target identified by the current selection, to the 
  1291. item identified on the clipboard. This command should be disabled if link information is not available 
  1292. on the clipboard.
  1293. The following algorithm summarizes the rules containers apply to the formats on the clipboard to 
  1294. determine how to execute a paste-link command:
  1295.     if ObjectLink format is available
  1296.         if( EcdCreateLinkFromClip( "StdFileEditing", &clientstruct, &lpobj 
  1297.                             renderopt, cfFormat) == ECD_OK )
  1298.             //all done
  1299.         else
  1300.             if Link format is available
  1301.                 do whatever link stuff you do today
  1302. As with the paste operation, clients should select the new object, to give the user quick access to the 
  1303. properties.
  1304.   Undo
  1305. Clients should save a copy of the embedded object when it is opened for editing, so that when the 
  1306. editor is closed and the object is updated, the user still has the chance to undo all of the changes made 
  1307. in the editor. This must be supported in the client, since the server has no way to revert to the prior 
  1308. state.
  1309.   Links
  1310. A client that maintains links might offer functions to the user to manage those links, reconnect broken 
  1311. links to renamed documents etc. This is determined by the client. The library provides functions to 
  1312. query and set the link information for the object so that the client application can implement the user 
  1313. interface for these functions.  Note: the item name may be null in which case the link refers to the 
  1314. whole of the server document.
  1315.   Properties
  1316. Applications that support this model must implement a "<Type> Properties..." command in their 
  1317. "Edit" menus; selecting this command produces an object properties dialog for the currently selected 
  1318. object or link. If a client supports a variety of update rules, it should provide functions whereby the user 
  1319. can change the attributes of the link, change a link to an embedded object (which requires the client to 
  1320. launch the server and request the native data), unlink, leaving only the picture, and so on.
  1321.   Shutdown
  1322. When a client or server shuts down while it is the clipboard owner, it should render all formats to the 
  1323. clipboard, subject to memory availability. The application should ensure that the clipboard presents a 
  1324. consistent state (e.g. there is no native data without corresponding owner link), and reflects the prefer-
  1325. ence order of formats and the nature of the selection that was copied (e.g. not an owner link without 
  1326. native data for and embedded object).
  1327. When shutting down, the client should delete all objects from memory.  EcdDelete may return 
  1328. indicating that the client should not terminate yet, but should wait (dispatching messages) until a 
  1329. notification callback informs the client that it is safe to terminate. 
  1330.   Server
  1331. Server applications provide their service by allocating structures defined in Part 4 and registering them 
  1332. with the server library.  The server library will implement the DDE execute commands and DDE data 
  1333. conventions described in the DDE protocol reference appendix. The library will call back to the server 
  1334. application to use the service.  Servers should be passive, and should not make assumptions about 
  1335. ordering of callbacks.
  1336. Server implementors will also need to refer to the Copy command described in the client section above.
  1337.   Opening
  1338. When a client launches a server to edit a linked or embedded object, it passes a command line switch 
  1339. to the server("-Embedding", for historical reasons). The server should change some of its menu 
  1340. commands as listed below, and be prepared to be controlled partially by the client, through the server 
  1341. library. See Part 4 for details of the latter.
  1342. The library will always launch a new instance of a server in order to edit an embedded or linked object, 
  1343. except in the case that the object is a link to a document that is already open. The intent is that 
  1344. separate instances of applications should be used to avoid interfering with the application s context 
  1345. information (e.g. current window, current selection etc).
  1346. If a server application is unable to run multiple instances, a stub should be provided that will locate an 
  1347. existing instance if possible, and enable the client to communicate with that. The client should be 
  1348. unaware that it does not have a new instance.
  1349.   Shutdown
  1350. For embedded objects, the client library will use DDE commands to instruct the server library to close 
  1351. documents, exit, show the window, etc. The server library will make callbacks to the server application 
  1352. to invoke these functions.  Servers should comply with these commands without confirmation dialogs 
  1353. etc, and should exit when so instructed. The onus is on the client to provide the requisite confirmation 
  1354. dialogs.  For linked objects, although the client will open the server it will not instruct it to close the 
  1355. document or exit (unless it is performing an invisible update).  The linked object has an existence 
  1356. independent of the client and the user (through the server application) controls saving and closing the 
  1357. document.
  1358. There is one case where the server for an embedded object must be more intelligent: if it is a multiple 
  1359. document application, and more than one client has established contact, or the user has opened 
  1360. additional documents, then the server should remain open until the user closes it. Exit commands from 
  1361. clients should be ignored.
  1362. See also the Shutdown in the client section above for clipboard behavior.
  1363.   Copy
  1364. The behavior of the copy command is described in the client section above. If a server cannot also act 
  1365. as a client, it follows that the selection will only ever be server data. The server should offer descriptive 
  1366. data formats first, then Native, OwnerLink, then presentation and other formats, and lastly ObjectLink 
  1367. (and possibly Link) formats.
  1368.   Save a Copy
  1369. When editing an embedded object under control of a client, servers should change the Save as... menu 
  1370. command (if they have one) to be "Save a Copy As...". This allows the user to save a copy of an embed-
  1371. ded object into its own file. The normal "Save As..." command has the additional effect of changing the 
  1372. association of the in-memory document to be the new file, whereas this specification requires that it 
  1373. still be associated with the client s embedded object.
  1374.   Update
  1375. When editing an embedded object, the server should change its Save menu command to be "Update".  
  1376. This should notify the client (via the server library) of changes as described in the protocol reference 
  1377. section.
  1378.   Exit, Close
  1379. The Exit command should be changed to "Exit and Update" or "Exit and return", and the main window 
  1380. close command should have the same effect. When a server that is editing an embedded object is 
  1381. closed, it should perform the same actions as Update, above, before closing. Similarly, a multiple 
  1382. document server that closes a window containing an object embedded in some client, it should perform 
  1383. the Update action as above before closing.
  1384.   Renaming a Document
  1385. If a server of a link renames the document while a client has a conversation with the server (the server 
  1386. library creates an object structure when this happens),  the server should notify the library of the 
  1387. change of name.  The client will in turn be notified of change by the client-side library.
  1388.   Installation of Classes
  1389. Installing a server class is simply a matter of registering the editor. See the registration specification in 
  1390. the API specification section.
  1391.  
  1392.  
  1393.   API specification
  1394. All types, constant values and functions required by clients and servers are declared in a C header file 
  1395. "ecd.h".  Additional types and functions required by class-specific handlers are declared in "objcreate.h".
  1396.   Introduction and general definitions
  1397. A recurrent idiom in these structure definitions is the use of a vtbl, which is a table of function pointers, 
  1398. and a vptr, which is a pointer to a vtbl.  The vptr is stored in a data structure whose address is used to 
  1399. identify and access the data structure.  Extra instance-specific state information may be stored in the 
  1400. data structure that contains the vptr, initialized by and for the use of the object handler functions.  The 
  1401. client for the particular object should not access this state information as its content is entirely 
  1402. determined by the implementor of the handler functions.  In various occurrences of this idiom the 
  1403. creator may be the client application, the client library, and object handler library, the server library, or 
  1404. the server application.
  1405. The convention for calling a function whose address is stored in a vtbl is to pass the address of the 
  1406. object as the first argument.   This permits the function to access the state stored in the structure 
  1407. without use of global data and without use of void* parameters to pass the contextual information.  
  1408. This scheme allows multiple instances of the same type of object, and extension of the state 
  1409. information stored in the structures. 
  1410.  
  1411.   Client API specification
  1412.   Types, Data structures and parameter definitions
  1413. All functions return a status code to indicate success or some failure condition.  Result values are 
  1414. returned through pointer parameters.  Return codes are defined as follows:
  1415. ECDSTATUS
  1416. //  return codes for ECD functions
  1417.  
  1418. typedef enum {
  1419. ECD_OK,                 // function operated correctly
  1420. ECD_ERROR_MEMORY,       // could not allocate or lock memory
  1421. ECD_ERROR_FATAL,        // only DEBUG version. normally fatal error
  1422. ECD_ERROR_STREAM,       // (ECDSTREAM) stream error
  1423. ECD_ERROR_STATIC,       // object is unexpectedly static
  1424. ECD_ERROR_BLANK,        // critical data missing
  1425. ECD_ERROR_LAUNCH,    //failed to launch server
  1426. ECD_ERROR_COMM,          //failed to establish communication with server
  1427. ECD_ERROR_DRAW,      //error or interrupt while drawing
  1428. ECD_ERROR_CLIP,          //failed to get/set clipboard data
  1429. ECD_ERROR_FORMAT,       // requested format is not available
  1430. ECD_ERROR_ILLEGALOBJECT,// Not a valid object
  1431. ECD_ERROR_OPTION,       // invalid option (update or render)
  1432. ECD_ERROR_PROTOCOL,    // server not following protocol
  1433. ECD_WAIT_FOR_RELEASE    // client must dispatch until RELEASE callback before quit.
  1434. } ECDSTATUS;
  1435.  
  1436.  
  1437.   Structures provided by the library for the client
  1438. The object structure is an in-memory structure used to hold information about the embedded or linked 
  1439. object.  It is created by the library when an object is read from a file, pasted from the clipboard, or 
  1440. duplicated.  The client does not see the content of this structure, merely its pointer.  Client programs 
  1441. directly call functions to manipulate these objects.  These functions reside in a DLL, and use the vtbl 
  1442. structure to dispatch to the object-specific implementation.
  1443. ECDOBJECT, LPECDOBJECT
  1444. struct  _ECDOBJECT    /* opaque to clients */
  1445.  
  1446. typedef struct  _ECDOBJECT  ECDOBJECT, FAR* LPECDOBJECT;
  1447. Server programs and class-specific libraries  provide an implementation of the ECDOBJECT type.  
  1448. The set of methods that must be supplied is specified in the sections on object handlers and servers.
  1449.   Structures provided by the client for the library
  1450. Object libraries require certain functionality from the client application in order to do their work.  This 
  1451. functionality is made available to the object libraries through structures and callback functions that the 
  1452. client defines and passes as arguments to the libraries.  In this way the client is given great flexibility in 
  1453. how the functions are implemented.
  1454. ECDCLIENT is a structure allocated by the client and passed to the library when an in-memory object 
  1455. is being created.  It is used to pass a callback function that the library uses to notify the client of various 
  1456. events, along with any state that the client wishes to associate with the object..  The pointer to the client 
  1457. structure and the pointer to the object are remembered by the passed to the callback function along 
  1458. with the reason for the notification. The client may add extra information associated with the object for 
  1459. its own purposes at the end of the client structure.  The library stores the client pointer in the object 
  1460. structure so that it (the library) can locate it when needed.
  1461. ECD_NOTIFICATION
  1462. // Codes for CallBack events
  1463. typedef enum {
  1464. } ECD_NOTIFICATION;
  1465.  
  1466.  
  1467. ECDCLIENT, LPECDCLIENT
  1468. struct _ECDCLIENT;    /*forward*/
  1469.  
  1470. typedef struct _ECDCLIENT FAR *LPECDCLIENT;
  1471.  
  1472. struct _ECDCLIENTVTBL
  1473. {
  1474.     BOOL (FAR PASCAL  *CallBack) (    LPECDCLIENT lpclient,
  1475.                     ECD_NOTIFICATION notification,
  1476.                     LPECDOBJECT lpobject);
  1477. };
  1478.  
  1479. typedef struct _ECDCLIENT {
  1480.     struct _ECDCLIENTVTBL FAR* vptr;
  1481.     /* any client supplied state goes here */
  1482. } ECDCLIENT;
  1483.  
  1484. ECDCLIENT: CallBack
  1485. BOOL (FAR PASCAL *CallBack)( lpclient, notification, lpobject );
  1486. Name    Type    Description
  1487. lpclient    LPECDCLIENT    long pointer to the client structure associated with the 
  1488. object.  The library retrieves this pointer from its object 
  1489. structure when a notification occurs, uses it to locate the 
  1490. callback function, and passes the pointer to the client 
  1491. structure for the client application's use.
  1492. notification    ECD_NOTIFICATION    a value of an enumerated type which indicates the reason 
  1493. for the notification.  Values are:
  1494. ECD_CHANGED: object has changed and needs to be 
  1495. redrawn, will need to be saved etc.
  1496. ECD_SAVED:  a linked object has been saved in its server.
  1497. ECD_CLOSED:  object has been closed (in its server).
  1498. ECD_RENAMED: a linked object has been renamed in its 
  1499. server.  This variant is for information only, as the 
  1500. library takes care of updating its link information.  
  1501. No particular action is required. This notification 
  1502. implies ECD_CHANGED.
  1503. ECD_QUERY_PAINT: This notification is made during 
  1504. lengthy drawing operations to allow interrupt. See 
  1505. return value, below.
  1506. ECD_RELEASE:  This notification informs the client that 
  1507. the object has finally been released and (when all 
  1508. such objects have been released) the client may 
  1509. safely quit.
  1510. lpobject    LPECDOBJECT    a long pointer to the object that caused the notification to 
  1511. be sent.  This pointer is not necessarily useful to the client 
  1512. application, depending on whether the application allocates 
  1513. a different client structure for each object.  This argument is 
  1514. provided so that applications that wish to may use the same 
  1515. client structure for more than one object, and use the object 
  1516. pointer to distinguish notifications.
  1517. return value    BOOL    this value is ignored except in the case of 
  1518. ECD_QUERY_PAINT.   The client should return false 
  1519. (zero) if the painting should be aborted, and true (non-
  1520. zero) if painting should continue.
  1521. The client should act on these notifications at the next appropriate time (e.g. main event loop, closing 
  1522. the object etc).  Update of objects may be deferred until the user requests update, if the client wishes 
  1523. to provide that functionality.  The client may call the library from a notification callback function.  The 
  1524. library will be properly re-entrant.  There will be some things that the client may not do while some 
  1525. operations are in progress (opening etc).
  1526. ECDSTREAM, LPECDSTREAM
  1527. The ECDSTREAM structure is provided by the client application.  It provides stream IO functions 
  1528. (read, write, seek) for the library to use when loading and saving objects.  This permits the client to 
  1529. determine where the permanent storage is by providing variations on the IO procedures, e.g. to store 
  1530. the object in a database.
  1531. // Stream definitions
  1532. typedef struct _ECDSTREAM   FAR * LPECDSTREAM;
  1533.  
  1534. typedef struct  _ECDSTREAMVTBL{
  1535.     LONG  (FAR PASCAL *Get) (LPECDSTREAM, LPSTR, LONG);
  1536.     LONG  (FAR PASCAL *Put) (LPECDSTREAM, LPSTR, LONG);
  1537.     LONG  (FAR PASCAL *Seek)(LPECDSTREAM, LONG, INT);    //like _llseek
  1538. } ECDSTREAMVTBL;
  1539.  
  1540. typedef  ECDSTREAMVTBL  FAR   *LPECDSTREAMVTBL;
  1541.  
  1542. typedef struct  _ECDSTREAM {
  1543.     LPECDSTREAMVTBL      lpstbl;
  1544. } ECDSTREAM;
  1545.  
  1546. The stream need not be valid all the time while the object exists. The stream is only valid for the 
  1547. duration of the function to which it is passed.  The library will obtain everything it needs.  In event of an 
  1548. error reading or writing the stream, the library will indicate the existence of the error back to the client, 
  1549. but not its nature.  The client-supplied stream object should store any needed indication of what the 
  1550. error condition was so that the client can take recovery action.
  1551. ECDSTREAM: Get
  1552. LONG (FAR PASCAL *Get)( lpstream, lpbuf, cbbuf );
  1553. Name    Type    Description
  1554. lpstream    LPECDSTREAM    a long pointer to a stream structure allocated by the client
  1555. lpbuf    LPSTR    a long pointer to a buffer to fill with data from the stream
  1556. cbbuf    LONG    a long count of bytes to read into the buffer
  1557. return value    LONG    a long count of bytes actually read into the buffer.  A return 
  1558. value of zero implies end-of-file was encountered.  A 
  1559. negative return value implies an error was encountered.
  1560. ECDSTREAM: Put
  1561. LONG (FAR PASCAL *Put)( lpstream, lpbuf, cbbuf );
  1562. Name    Type    Description
  1563. lpstream    LPECDSTREAM    a long pointer to a stream structure allocated by the client
  1564. lpbuf    LPSTR    a long pointer to a buffer from which to write data into the 
  1565. stream
  1566. cbbuf    LONG    a long count of bytes to write into the stream
  1567. return value    LONG    a long count of bytes actually written.  A return value less 
  1568. than cbbuf implies an error occurred or insufficient space in 
  1569. the stream.
  1570. ECDSTREAM: Seek
  1571. LONG (FAR PASCAL *Seek)( lpstream, loffset, iorigin );
  1572. Name    Type    Description
  1573. lpstream    LPECDSTREAM    a long pointer to a stream structure allocated by the client.  
  1574. loffset, iorigin and the return value are exactly as specified 
  1575. in the Windows _llseek function.
  1576.   Protocol naming and checking
  1577. Protocols are definitions of API sets.  This API set is the basic compound document protocol.  
  1578. Protocols are named with (null terminated) string names; this one is called StdFileEditing.  The name 
  1579. of the protocol that the client requires (identifying the API functions he needs to call) is passed in to 
  1580. the function that create the object.  The library checks that the object does in fact support that protocol 
  1581. and fails the request if not.
  1582.   Rendering Options
  1583. The client may control the way the object will be rendered.  The library provides support for handling 
  1584. all of the rendering, obtaining data for the client to handle the rendering, or doing nothing.
  1585. ECDOPT_RENDER, ECDCLIPFORMAT
  1586. // rendering options
  1587.  
  1588. typedef enum {
  1589.     ecdrender_none,    //library gets no data, will not draw
  1590.     ecdrender_draw,    //client will call draw, lib manages data
  1591.     ecdrender_format    //client will call getdata and render,
  1592.                 // lib gets and stores data.
  1593. } ECDOPT_RENDER;
  1594.  
  1595. typedef WORD ECDCLIPFORMAT; // standard clipboard format type
  1596.             // tells lib what format to get for ecdrender_format
  1597.  
  1598.   API functions
  1599. Functions that create objects rather than operating on existing objects return the object pointer 
  1600. through a pointer argument (LPECDOBJECT FAR *) rather than taking an object pointer as the first 
  1601. argument.  Windows memory management is used to obtain storage for the object structures.
  1602.   Utility functions
  1603. Some of the functions defined here are implemented in a library of utility functions.  The real work is 
  1604. done by calling method functions on the objects.  To get full flexibility in managing the objects a client 
  1605. can call the object methods directly.  To get a simpler but less flexible interface, the utility functions are 
  1606. provided.
  1607.   Enabling Paste and Paste link commands
  1608. The following functions check that the object on the clipboard supports the required protocol, and can 
  1609. be linked or embedded as appropriate.  They are called when the client wants to check whether to 
  1610. enable a Paste or Paste Link command.  The client should supply the protocol string name 
  1611. "StdFileEditing".
  1612. EcdQueryCreateFromClip
  1613. ECDSTATUS FAR PASCAL EcdQueryCreateFromClip  ( protocol, renderopt, cfFormat );
  1614. Name    Type    Description
  1615. protocol    LPSTR    the name of the protocol that the client wishes to use.  
  1616. Currently the library supports "StdFileEditing" which is the 
  1617. internal name of the object linking and embedding protocol, 
  1618. and "Static", which allows simple clients to use the library to 
  1619. manage static pictures for them.  Static objects will fail if 
  1620. asked to open, and will generate no notifications.
  1621. renderopt    ECDOPT_RENDER    an indication of how the client wants to have the object 
  1622. displayed and printed:
  1623. ecdrender_none: the object is not to be shown at all.  This 
  1624. option may be used to hypertext links etc.  The 
  1625. library will not obtain any presentation data, will 
  1626. not draw
  1627. ecdrender_draw: the client will call EcdDraw, the  library 
  1628. will obtain and manage presentation data
  1629. ecdrender_format: the client will call EcdGetData and do 
  1630. the rendering, the library will obtain and manager 
  1631. the data in the requested format (see below).
  1632. cfFormat    ECDCLIPFORMAT    the clipboard format that the client will request  through 
  1633. EcdGetData, only used with ecdrender_format above.
  1634. EcdQueryLinkFromClip
  1635. ECDSTATUS FAR PASCAL EcdQueryLinkFromClip( protocol, renderoption, cfFormat );
  1636.         arguments are as above
  1637.   Executing Paste and Paste link commands
  1638. The following functions check that the object on the clipboard supports the required protocol, and can 
  1639. be linked or embedded as appropriate, and perform the operation.  They are called when the client 
  1640. wants to execute a Paste or Paste Link command.  The client should supply the protocol string name 
  1641. "StdFileEditing", or "Static" if the object is a non-editable picture.
  1642. EcdCreateFromClip
  1643. ECDSTATUS FAR PASCAL EcdCreateFromClip ( protocol, lpclient, lplpobject , renderopt, 
  1644. cfFormat);
  1645. Name    Type    Description
  1646. protocol    LPSTR    as protocol above
  1647. lpclient    LPECDCLIENT    a long pointer to an ECDCLIENT structure allocated and 
  1648. initialized by the client application.  This pointer will be 
  1649. used to locate the CallBack function, and passed in 
  1650. CallBack notifications.
  1651. lplpobject    LPECDOBJECT FAR *    a long pointer to a long pointer to an ECDOBJECT.  The 
  1652. caller should pass the address of an LPECDOBJECT into 
  1653. which the library will store the address of the created object.
  1654. renderopt    ECDOPT_RENDER    as renderopt above
  1655. cfFormat    ECDCLIPFORMAT    as cfFormat above
  1656. return value    ECDSTATUS    see ECDSTATUS type definition
  1657. EcdCreateLinkFromClip
  1658. ECDSTATUS FAR PASCAL EcdCreateLinkFromClip( protocol, lpclient, &lpobject , renderopt, 
  1659. cfFormat );
  1660.         arguments and return value are as above.  This function 
  1661. creates a link to an object rather than an embedded object.
  1662.   Copying or cutting an object to the clipboard
  1663. EcdCopyToClipboard
  1664. ECDSTATUS FAR PASCAL EcdCopyToClipboard( lpobject );
  1665. Name    Type    Description
  1666. lpobject    LPECDOBJECT    a long pointer to the object to be copied to the clipboard
  1667. return value    ECDSTATUS    see ECDSTATUS type definition
  1668. Puts the object on the clipboard (Copy command).  The client should open the clipboard, offer any 
  1669. data formats on the clipboard, call this function, offer any additional presentation formats, and close 
  1670. the clipboard.   If the client  wishes to support delayed rendering it should use 
  1671. EcdEnumObjectFormats to offer them to the clipboard, and either EcdGetData or 
  1672. EcdCopyToClipboard to actually render the data.  Alternatively, a simple client may render the data 
  1673. immediately with the following functions and avoid deferred rendering.
  1674. EcdCutToClipboard
  1675. ECDSTATUS FAR PASCAL EcdCutToClipboard( lpobject );
  1676. Name    Type    Description
  1677. lpobject    LPECDOBJECT    a long pointer to the object to be cut to the clipboard
  1678. return value    ECDSTATUS    see ECDSTATUS type definition
  1679. This function cuts the object to the clipboard (which may optimize compared to copy/delete).  Usage is 
  1680. as above.
  1681.   Load from  and Save to client's file
  1682. The client should call these functions to load the object from the containing document and save it back 
  1683. after editing.  The client does not need to know the class of the object, or whether it is linked or 
  1684. embedded (although it can find out using EcdEnumObjectFormats).  The client simply needs to 
  1685. remember where objects are stored in the file.
  1686. EcdLoadFromStream
  1687. ECDSTATUS FAR PASCAL EcdLoadFromStream( lpstream, protocol, lpclient, lplpobject );
  1688. Name    Type    Description
  1689. lpstream    LPECDSTREAM    a long pointer to an ECDSTREAM structure allocated and 
  1690. initialized by the client application.  The library will call the 
  1691. Get method in the ECDSTREAM structure to obtain the 
  1692. data for the object.
  1693. protocol    LPSTR    see protocol earlier
  1694. lpclient    LPECDCLIENT    see lpclient earlier
  1695. lplpobject    LPECDOBJECT FAR *    a long pointer to an LPECDOBJECT where the library will 
  1696. store the long pointer to the object
  1697. return value    ECDSTATUS    see ECDSTATUS type definition
  1698. EcdSaveToStream
  1699. ECDSTATUS FAR PASCAL EcdSaveToStream( lpobject, lpstream );
  1700. Name    Type    Description
  1701. lpobject    LPECDOBJECT    a long pointer to the object to be saved into the stream
  1702. lpstream    LPECDSTREAM    a long pointer to an ECDSTREAM structure allocated and 
  1703. initialized by the client application.  The library will call the 
  1704. Put method in the ECDSTREAM structure to store the 
  1705. data from the object.
  1706. return value    ECDSTATUS    see ECDSTATUS type definition
  1707.   Object creation
  1708.   Creating new objects
  1709. EcdCreate
  1710. ECDSTATUS FAR PASCAL EcdCreate( protocol, lpclient,classname, lplpobject ,renderopt, 
  1711. cfFormat );
  1712. This function creates an object of a specified class.  The server is opened to perform the initial editing.
  1713. Name    Type    Description
  1714. protocol    LPSTR    as protocol earlier
  1715. lpclient    LPECDCLIENT    as lpclient earlier
  1716. classname    LPSTR    null terminated string which is the registered name of the 
  1717. class of the object to be created.
  1718. lplpobject    LPECDOBJECT FAR *    as lplpobject earlier
  1719. renderopt    ECDOPT_RENDER    as renderopt earlier
  1720. cfFormat    ECDCLIPFORMAT    as cfFormat earlier
  1721. return value    ECDSTATUS    see ECDSTATUS type definition
  1722. EcdCreateFromTemplate
  1723. ECDSTATUS FAR PASCAL EcdCreateFromTemplate( protocol, lpclient,        objectname, 
  1724. lplpobject, renderopt, cfFormat );
  1725. This function creates an object given the name of an object in a file to use as a template.  The server is 
  1726. opened to perform the initial editing.
  1727. This function creates an object of a specified class.  The server is opened to perform the initial editing.
  1728. Name    Type    Description
  1729. protocol    LPSTR    as protocol earlier
  1730. lpclient    LPECDCLIENT    as lpclient earlier
  1731. objectname    LPSTR    null terminated string which is the pathname of an object to 
  1732. be used as a template for the new object.  The server is 
  1733. opened for editing and loads the initial state of the new 
  1734. object from the named object
  1735. lplpobject    LPECDOBJECT FAR *    as lplpobject earlier
  1736. renderopt    ECDOPT_RENDER    as renderopt earlier
  1737. cfFormat    ECDCLIPFORMAT    as cfFormat earlier
  1738. return value    ECDSTATUS    see ECDSTATUS type definition
  1739.   Creating an object by converting an existing object
  1740. EcdObjectConvert
  1741. ECDSTATUS FAR PASCAL EcdObjectConvert( lpobject, protocol, lpclient,lplpobject );
  1742. This function may be used to request creation of a new object that supports a specified protocol from 
  1743. an existing object.  Today, there are only two protocols: StdFileEditing which manages linked and 
  1744. embedded objects, and Static, which manages embedded pictures only.  As of now, only converting 
  1745. linked or embedded objects to static objects will succeed.  The original object is not deleted or replaced 
  1746. by this call.
  1747. Name    Type    Description
  1748. lpobject    LPECDOBJECT    a long pointer to the object to convert
  1749. protocol    LPSTR    the name of the protocol required for the new object
  1750. lpclient    LPCLIENT    a long pointer to a client structure for the new object
  1751. lplpobject    LPECDOBJECT FAR *    a long pointer to an LPECDOBJECT where the library will 
  1752. store the long pointer to the new object
  1753. return value    ECDSTATUS    see ECDSTATUS type definition
  1754.   Copying and comparing objects
  1755. EcdClone
  1756. ECDSTATUS FAR PASCAL EcdClone( lpobject, lpclient, lplpobject );
  1757. This function makes a duplicate copy of an object.  A new client context may be supplied.
  1758. Name    Type    Description
  1759. lpobject    LPECDOBJECT    a long pointer to the object to be copied
  1760. lpclient    LPECDCLIENT    a long pointer to the client structure for the new object
  1761. lplpobject    LPECDOBJECT FAR *    a long pointer to an LPECDOBJECT where the library will 
  1762. store the long pointer to the new object
  1763. return value    ECDSTATUS    see ECDSTATUS type definition
  1764. EcdEqual
  1765. ECDSTATUS FAR PASCAL EcdEqual( lpobject1, lpobject2 );
  1766. Also a function to compare two objects for equality.  The latter can be used to save storage.  
  1767. Embedded objects are equal if their class, item and Native data are identical.  Linked objects are equal 
  1768. if their class, document, and item are identical.
  1769. Name    Type    Description
  1770. lpobject1,
  1771. lpobject2    LPECDOBJECT    long pointers to the objects to be compared
  1772. return value    ECDSTATUS    see ECDSTATUS type definition.  Returns ECD_OK if the 
  1773. two objects are equal as described above.
  1774.   Making a local copy of a linked object
  1775. EcdCopyFromLink
  1776. ECDSTATUS FAR PASCAL EcdCopyFromLink( lpobject, protocol, lpclient, lplpobject );
  1777. This function makes a local embedded copy of a linked object. This may involve launching the server 
  1778. application.
  1779. Name    Type    Description
  1780. lpobject    LPECDOBJECT    a long pointer to the linked object that is to be embedded
  1781. protocol    LPSTR    the name of the protocol required for the new embedded 
  1782. object
  1783. lpclient    LPECDCLIENT    a long pointer to a client structure for the new object
  1784. lplpobject    LPECDOBJECT FAR *    as lplpobject earlier
  1785. return value    ECDSTATUS    see ECDSTATUS type definition.
  1786.   Object method functions
  1787.   Protocol extensibility
  1788. EcdQueryProtocol
  1789. LPVOID FAR PASCAL *EcdQueryProtocol( lpobj, lpprotocol );
  1790. The design of the object protocol allows for additional protocols to be defined at future times.  It will 
  1791. be necessary for clients to perform a run-time check that an object supports a desired protocol, either 
  1792. at creation time (suitable for protocols on which the client insists) or after the object has been created, 
  1793. to test whether an object supports an optional protocol that the client can exploit if it is available.  For 
  1794. this purpose we define a method on the object that can be called to simultaneously query if the 
  1795. protocol is supported and return a modified object pointer giving access to the method table for the 
  1796. extra protocol.  The pointer returned has the  same form as the LPECDOBJECT pointer, in that it 
  1797. points to a pointer to a table of functions, and additional state information may be stored by the object 
  1798. handler following the vtable pointer.  This secondary pointer is not considered to point to a different 
  1799. object however; if the object is deleted (with EcdDelete), secondary pointers become invalid.  A 
  1800. protocol may elect to include delete methods, and calling any delete method will invalidate all pointers 
  1801. to that object.
  1802. Name    Type    Description
  1803. lpobj    LPECDOBJECT    a long pointer to the object to check for an additional 
  1804. protocol
  1805. lpprotocol    LPSTR    the (null-terminated) string name of the desired protocol.  
  1806. Currently only the name StdFileEditing is defined.
  1807. return value    LPVOID    a long pointer to an object structure (defined as having a 
  1808. long pointer to a table of methods as the first entry).  The 
  1809. definition of the functions is entirely determined by the 
  1810. protocol definition.  This function returns NULL if the 
  1811. object does not support the requested protocol.
  1812.   Destroying an object
  1813. EcdDelete
  1814. ECDSTATUS FAR PASCAL EcdDelete( lpobject );
  1815. Delete and object and reclaim storage.  Closes the object if it is open.
  1816. Name    Type    Description
  1817. lpobject    LPECDOBJECT    a long pointer to the object to be deleted.
  1818. return value    ECDSTATUS    see ECDSTATUS type definition.  In particular, this 
  1819. function will return ECD_WAIT_FOR_RELEASE if the 
  1820. object is still in the process of closing down, which means 
  1821. that the client application must wait (dispatching messages) 
  1822. for a CallBack notification with the ECD_RELEASE 
  1823. argument before it can safely quit.  This notification must 
  1824. be awaited for each object that returns 
  1825. ECD_WAIT_FOR_RELEASE, though the order is not 
  1826. significant.
  1827.   Finding the display size of an object
  1828. EcdQueryBounds
  1829. ECDSTATUS FAR PASCAL EcdQueryBounds( lpobject, lpBounds );
  1830. This function returns the geometric bounding rectangle (on the target device) of the object in 
  1831. MM_HIMETRIC units.
  1832. Name    Type    Description
  1833. lpobject    LPECDOBJECT    a long pointer to the object whose bounds are requested.
  1834. lpBounds    LPRECT    a long pointer to a RECT structure that will be filled with 
  1835. the bounding rectangle for the object.
  1836. return value    ECDSTATUS    see ECDSTATUS type description
  1837.   Formatting an object
  1838. EcdSetTargetDevice
  1839. ECDSTATUS FAR PASCAL  EcdSetTargetDevice( lpobject, hTargetDevice );
  1840. Name    Type    Description
  1841. lpobject    LPECDOBJECT    a long pointer to the object that should be formatted for the 
  1842. specified target device
  1843. hTargetDevice    HANDLE    a handle to a memory structure that describes the target 
  1844. device for the object.  The format of this structure is 
  1845. described in the appendix under StdTargetDevice
  1846. return value    ECDSTATUS    see ECDSTATUS type description
  1847. Specify the target device for output so that the object may format appropriately for that device even 
  1848. when rendering on a different device (e.g. a window).  This function should be called whenever the 
  1849. target device is changed, so that servers can be notified and re-render the picture if necessary.  The 
  1850. client should call the library to redraw the object if it receives a notification that the object has 
  1851. changed.  See the appendix for details of the StdTargetDevice structure.
  1852. EcdSetBounds
  1853. ECDSTATUS FAR PASCAL EcdSetBounds( lpobject, lpBounds );
  1854. Name    Type    Description
  1855. lpobject    LPECDOBJECT    a long pointer to the object that should be formatted for the 
  1856. specified size on the target device
  1857. lpBounds    LPRECT    a long pointer to a RECT structure containing the required 
  1858. bounds for the object.
  1859. return value    ECDSTATUS    see ECDSTATUS type description
  1860. Specify the rectangle to be used as the target size of the object.  This is not necessarily the same as will 
  1861. be used in the EcdDraw call, depending on the view scaling that the container application is using.  
  1862. This call can be used to cause the server to reformat the picture to fit the rectangle better.  The bounds 
  1863. are specified in MM_HIMETRIC units.  This call is ignored for linked objects as their size is 
  1864. determined by the document of which they are a part.
  1865. EcdSetHostNames
  1866. ECDSTATUS FAR PASCAL EcdSetHostNames( lpobject, hostname, hostobjectname );
  1867. Name    Type    Description
  1868. lpobject    LPECDOBJECT    a long pointer to the object that should be formatted for the 
  1869. specified size on the target device
  1870. hostname    LPSTR    the string name of the container application
  1871. hostobjectname    LPSTR    the container's string name for the object.
  1872. return value    ECDSTATUS    see ECDSTATUS type description
  1873. Specify the name of the container application and the container's name for the object, to be used in 
  1874. window titles when editing in the server
  1875.   Rendering an object
  1876. EcdDraw
  1877. ECDSTATUS FAR PASCAL EcdDraw( lpobject, hDC, lpBounds, hFormatDC );
  1878. Name    Type    Description
  1879. lpobject    LPECDOBJECT    a long pointer to the object to be drawn
  1880. hDC    HDC    a handle to the drawing context in which the object should 
  1881. be drawn.
  1882. lpBounds    LPRECT    a long pointer to a RECT structure containing the bounding 
  1883. rectangle (in the units required by the mapping mode for 
  1884. HDC) into which the object should be drawn..
  1885. hFormatDC    HDC    a handle to a device context that describes the target device 
  1886. for which the object should be formatted.
  1887. return value    ECDSTATUS    see ECDSTATUS type description.  This function will 
  1888. return ECD_ERROR_DRAW if the CallBack function 
  1889. returns false (zero) during drawing.
  1890. Draw the object mapped into the specified rectangle on device hDC.  The object should be formatted 
  1891. as if it were to be drawn at the size specified by the EcdSetBounds call on the device context specified 
  1892. by hFormatDC.  In many cases this formatting will already have been done by the server and the 
  1893. library will simply play a metafile with suitable scaling for the required lpBounds.  The hDC argument 
  1894. may include a clipping region smaller than the LPRECT, for cropping or banding purposes.  The DC 
  1895. of the target device is required for this call, since the library may be using an object-specific DLL to 
  1896. render the object instead of keeping a metafile.  In this case, the DLL may need the information about 
  1897. the target device.  The LPRECT argument identifies the rectangle on the hDC (relative to its current 
  1898. mapping mode) that the object should be mapped onto.  This may involve scaling the picture, and can 
  1899. be used by client applications to impose a view scaling between the displayed view and the final printed 
  1900. image.
  1901. This function will periodically call the client CallBack function during drawing, with the notification 
  1902. argument ECD_QUERY_PAINT.  The client may check for input or other reason to interrupt the 
  1903. drawing process in this function, and return false (zero) if the drawing should be interrupted.  The 
  1904. client may also take action in this callback provided it  does  not interfere with the state of the object or 
  1905. where it should be drawn, and return true (non-zero) to indicate that the drawing should continue.  
  1906. This allows the client to (for example) give up focus if requested while a lengthy drawing operation is in 
  1907. progress.
  1908.   Initializing and retrieving data
  1909. Clients may retrieve data in a specified format from the object with the EcdGetData function.  The 
  1910. client must have requested this format when creating the object, using the ecdrender_format option.
  1911. Clients may also provide data to the object with the EcdSetData function.   The server should be active 
  1912. when this call is made, in which case the library will send the data to the server.  This scenario requires 
  1913. that the client know what format to send to the object, and that it will be meaningful.  The intent is to 
  1914. support embedded objects such as charts, and allow the client to provide the data to be graphed.  The 
  1915. Get and SetData functions are modelled on the Windows Get/SetClipboardData functions.
  1916. Objects managed by the standard library (i.e. for which there is no rendering DLL) will not provide 
  1917. conversions: only native, link, and presentation data formats will be offered.
  1918. EcdEnumObjectFormats
  1919. ECDCLIPFORMAT EcdEnumObjectFormats( lpobject, cfFormat );
  1920. The client may enumerate the formats that the object can render using EcdEnumObjectFormats, 
  1921. which is modelled after the windows EnumClipboardFormats function: passing in a null format returns 
  1922. the first available format.  Passing in one that was returned returns the next in sequence.  When no 
  1923. more formats are available, null is returned.
  1924. Name    Type    Description
  1925. lpobject    LPECDOBJECT    a long pointer to the object to be queried
  1926. cfFormat    ECDCLIPFORMAT    previous format returned from this call, or null for first call
  1927. return value    ECDCLIPFORMAT    next format available, or null if no more
  1928. EcdGetData
  1929. HANDLE FAR PASCAL EcdGetData(lpobject, cfFormat);
  1930. This function retrieves data in the requested format from the object.  If the object cannot provide the 
  1931. data, a null handle is returned.
  1932. Name    Type    Description
  1933. lpobject    LPECDOBJECT    a long pointer to the object from which to retrieve data
  1934. cfFormat    ECDCLIPFORMAT    format in which the data should be returned
  1935. return value    HANDLE    handle to a memory object containing the data in the 
  1936. requested format, or null if cannot satisfy the request.
  1937. EcdSetData
  1938. ECDSTATUS FAR PASCAL EcdSetData(lpobject, cfFormat, hData);
  1939. This function sends in the specified format to the object.  If the object cannot accept the data, an error 
  1940. status is returned.
  1941. Name    Type    Description
  1942. lpobject    LPECDOBJECT    a long pointer to the object to which data is to be sent.
  1943. cfFormat    ECDCLIPFORMAT    format of the data.
  1944. hData    HANDLE    handle to a memory object containing the data in the 
  1945. specified format.
  1946. return value    ECDSTATUS    see ECDSTATUS type description
  1947.   Repairing broken links
  1948. The representation of the link information is a buffer containing three null-terminated strings 
  1949. consecutively, followed by a null byte.  These strings are the classname, documentname, and itemname.   
  1950. The client may retrieve the link information using EcdGetData with the ObjectLink format.  The call 
  1951. will fail if the object is not a link (i.e. is embedded).  Class information may be obtained through the 
  1952. OwnerLink format.  The client may let the user edit the link information and store it into the object 
  1953. with the EcdSetData function, specifying the ObjectLink format.
  1954.   Update control
  1955. The client may set and query the update rules for links.  The options are update always (i.e. hot link, try 
  1956. to keep the link up to date at all times), update when the target object is saved, and update only when 
  1957. the client requests (typically on user request).
  1958. ECDOPT_UPDATE
  1959. typedef enum { ecdupdate_always, ecdupdate_onsave, ecdupdate_oncall } ECDOPT_UPDATE;
  1960. EcdGetLinkUpdateOptions
  1961. ECDSTATUS   FAR PASCAL  EcdGetLinkUpdateOptions( lpobject, lpupdateopt );
  1962. This function returns the update options for the specified object.
  1963. Name    Type    Description
  1964. lpobject    LPECDOBJECT    a long pointer to the object to be queried
  1965. lpupdateopt    ECDOPT_UPDATE FAR *    a long pointer to an ECDOPT_UPDATE where 
  1966. the current option setting will be stored.
  1967. return value    ECDSTATUS    see ECDSTATUS type description. 
  1968. EcdSetLinkUpdateOptions
  1969. ECDSTATUS   FAR PASCAL  EcdSetLinkUpdateOptions( lpobject, updateopt );
  1970. This function sets the update options for the specified object.
  1971. Name    Type    Description
  1972. lpobject    LPECDOBJECT    a long pointer to the object to be changed
  1973. lpupdateopt    ECDOPT_UPDATE    the requested update option value
  1974. return value    ECDSTATUS    see ECDSTATUS type description. 
  1975.   Opening and updating
  1976. EcdOpen
  1977. ECDSTATUS FAR PASCAL EcdOpen( lpobject, fShow, hwnd, lpBounds );
  1978. This function opens the object.  Normally a server will be launched in a separate window, and editing 
  1979. proceeds asynchronously with changes being notified to the client through the CallBack function.
  1980. The hwnd and lpBounds parameters identify the window and the rectangle within it where the object is 
  1981. displayed in the client.  They are used for placement hints for the server's editing window, and possibly 
  1982. for "exploding rectangle" feedback to the user.
  1983. Name    Type    Description
  1984. lpobject    LPECDOBJECT    a long pointer to the object to be opened
  1985. fShow    BOOL    indicates whether to show the window (true, non-zero) or 
  1986. not (false, zero).  The latter is useful in conjunction with 
  1987. EcdSetData, so that a client can keep a server active 
  1988. calculating new pictures, but not visible on screen.
  1989. hwnd    HWND    the window handle where he object is displayed in the 
  1990. container (may be null).
  1991. lpBounds    LPRECT    a long pointer to a RECT structure which contains the 
  1992. coordinates of the bounding rectangle where the object is 
  1993. displayed in the container.  May be null.  Coordinates are 
  1994. pixels, relative to the window.
  1995. return value    ECDSTATUS    see ECDSTATUS type description. 
  1996. EcdQueryOpen
  1997. ECDSTATUS FAR PASCAL EcdQueryOpen( lpobject );
  1998. This function queries whether the object is open.
  1999. Name    Type    Description
  2000. lpobject    LPECDOBJECT    a long pointer to the object to be queried
  2001. return value    ECDSTATUS    see ECDSTATUS type description.  returns ECD_OK if 
  2002. the object is open.
  2003. EcdUpdate
  2004. ECDSTATUS FAR PASCAL EcdUpdate( lpobject );
  2005. This function updates the object so that the presentation is up to date and the object itself is up to date 
  2006. with respect to any other objects it depends on.
  2007. Name    Type    Description
  2008. lpobject    LPECDOBJECT    a long pointer to the object to be updated
  2009. return value    ECDSTATUS    see ECDSTATUS type description.
  2010. EcdReconnect
  2011. ECDSTATUS FAR PASCAL EcdReconnect( lpobject );
  2012. This function re-establishes the link to a linked object (if it is open) so that the presentation will be 
  2013. kept up to date.  If the target object is not open, this call will not open it.
  2014. Name    Type    Description
  2015. lpobject    LPECDOBJECT    a long pointer to the object to be connected
  2016. return value    ECDSTATUS    see ECDSTATUS type description.
  2017. EcdQueryOutOfDate
  2018. ECDSTATUS FAR PASCAL EcdQueryOutOfDate( lpobject );
  2019. This function queries whether an object (e.g. a linked object) is out of date with respect to some other 
  2020. object.
  2021. Name    Type    Description
  2022. lpobject    LPECDOBJECT    a long pointer to the object to be queried
  2023. return value    ECDSTATUS    see ECDSTATUS type description.
  2024. EcdClose
  2025. ECDSTATUS FAR PASCAL EcdClose( lpobject );
  2026. This function closes the object if it was open.
  2027. Name    Type    Description
  2028. lpobject    LPECDOBJECT    a long pointer to the object to be closed
  2029. return value    ECDSTATUS    see ECDSTATUS type description.
  2030.   Object handler API specification
  2031.   Overview
  2032. When an memory object structure is being created, the client library uses the class name of the object 
  2033. to try to locate an object handler for that class.  If one is found, the client library loads the handler and 
  2034. calls it to create the object.  The handler may create an object where all of the creation functions and 
  2035. methods are defined by the handler, or call default object creation functions in the client library. 
  2036. Using this feature a class may provide special implementation for some or all of the object methods, 
  2037. and defer to the default implementation in cases where that is appropriate.
  2038. On Windows, creation functions and method functions must be exported and declared "_loadds".
  2039.   Object creation and initialization
  2040. Library functions which create objects are:
  2041.     EcdLoadFromStream
  2042.     EcdCreateFromClip
  2043.     EcdCreateLinkFromClip
  2044.     EcdCreate
  2045.     EcdCreateFromTemplate
  2046. Each of these first locates the classname, and looks in the registration service (under the keyword 
  2047. "Handler") for the name of a DLL that contains a handler.  If not found, the default creation code in 
  2048. the library is invoked.  If a handler is found, the DLL is loaded and entry points for the above creation 
  2049. functions are located (using string names as above with prefix "Ecd" replaced by the prefix "Dll").  
  2050. These are saved in a table, and the appropriate creation function is called.
  2051. The handler should declare a table of type ECDOBJECTVTBL (defined below), copy the table from 
  2052. the object returned by the default creation function, and replace pointers to those methods that the 
  2053. handler wishes to preempt in the new method table.  Finally, the handler should assign the address of 
  2054. the new method table into the object's pointer.  Calls to the client library API are dispatched through 
  2055. the method table, and will be routed either to the client library (if the handler has not overridden that 
  2056. entry) or to the handler-supplied version.  The handler may save (on creation) the pointer to the 
  2057. overridden function, and call it from the handler's version if desired.
  2058. The library exports the default creation functions under the same names but with the prefix "Def" 
  2059. instead of "Ecd".  The handler may import and call these.  Argument types and semantics are the same 
  2060. for the "Def" functions as for the "Dll" functions.  Arguments types and semantics for the latter are the 
  2061. same as for the "Ecd" functions, with the following exceptions:
  2062. Dll/DefCreateFromClip
  2063. ECDSTATUS FAR PASCAL DllCreateFromClip ( protocol, lpclient, lplpobject , renderopt, cfFormat, 
  2064. objtype);
  2065.  
  2066. ECDSTATUS FAR PASCAL DllCreateFromClip ( protocol, lpclient, lplpobject , renderopt, cfFormat, 
  2067. objtype);
  2068. EcdCreateFromClip calls DllCreateFromClip with an additional argument to tell the library what is 
  2069. being created (object or link) depending on what was found on the clipboard.  DllCreateFromClip 
  2070. should pass this and other arguments on to DefCreateFromClip if that is being called, possibly 
  2071. modified as described below.
  2072.  Name    Type    Description
  2073. protocol    LPSTR    the name of the protocol.  The handler should verify that it 
  2074. understands this protocol by comparing this argument 
  2075. against the protocol names known to the handler.  Currently 
  2076. only the name "StdFileEditing" is defined.  This argument 
  2077. should be passed on to DefCreateFromclip.
  2078. lpclient    LPECDCLIENT    long pointer to the client structure for the object.
  2079. lplpobject    LPECDOBJECT FAR *    long pointer to an LPECDOBJECT variable where the 
  2080. address of the created object should be returned.   This can 
  2081. be used in the call to DefCreateFromClip.
  2082. renderopt    ECDOPT_RENDER    indicates whether the client requires no rendering, will call 
  2083. the handler to draw the object, or will call GetData to 
  2084. retrieve a rendering in the format selected by the following 
  2085. argument.  The handler may give a different value for this 
  2086. argument in calling DefCreateFromClip: for example if the 
  2087. client calls this function with ecdrender_draw, the handler 
  2088. may call DefCreateFromClip with ecdrender_none if the 
  2089. handler will do the drawing based on Native data, or 
  2090. ecdrender_format if the handler will call GetData and do 
  2091. the drawing based on some class-specific format.
  2092. cfFormat    ECDCLIPFORMAT    the clipboard format to be retrieved with GetData.  The 
  2093. handler may call DefCreateFromClip with some format that 
  2094. the handler wishes to use for rendering.  The client library 
  2095. will take care of obtaining the data in the first place, and 
  2096. getting updates from the server.
  2097. objtype    LONG    an indication of what is on the clipboard:
  2098. OT_LINK    a link is to be created
  2099. OT_EMBEDDED    an embedded object is to be created.
  2100. return value    ECDSTATUS    as for EcdCreateFromClip
  2101. Dll/DefLoadFromStream
  2102. EcdLoadFromStream calls DllLoadFromStream with three additional parameters.  The handler 
  2103. function should pass these on to DefLoadFromStream if that function is to be called, or may modify 
  2104. them as described below. 
  2105. ECDSTATUS FAR PASCAL DllLoadFromStream( lpstream, protocol, lpclient, lplpobject, objtype, 
  2106. aClass, cfFormat );
  2107.  
  2108. ECDSTATUS FAR PASCAL DllLoadFromStream( lpstream, protocol, lpclient, lplpobject, objtype, 
  2109. aClass, cfFormat );
  2110. Name    Type    Description
  2111. lpstream    LPECDSTREAM    a long pointer to an ECDSTREAM structure allocated and 
  2112. initialized by the client application.  The library will call the 
  2113. Get method in the ECDSTREAM structure to obtain the 
  2114. data for the object.
  2115. protocol    LPSTR    see protocol earlier
  2116. lpclient    LPECDCLIENT    see lpclient earlier
  2117. lplpobject    LPECDOBJECT FAR *    a long pointer to an LPECDOBJECT where the library will 
  2118. store the long pointer to the object
  2119. objtype    LONG    as objtype above, except here the client library obtains the 
  2120. nature of the object from the containing stream data.
  2121. aClass    ATOM    an atom containing the class name for the object.  This 
  2122. should be passed on to DefLoadFromStream.
  2123. cfFormat    ECDCLIPFORMAT    The handler may elect to call DefLoadFromStream with a 
  2124. private format that it will use for rendering; the client 
  2125. library will take care of loading and saving this data as well 
  2126. as getting updates from the server.  If the handler does not 
  2127. use a special format, it should call DefLoadFromStream 
  2128. with the default value that the handler was called with.
  2129. return value    ECDSTATUS    see ECDSTATUS type definition
  2130.   Object methods
  2131. Object method functions implement the bulk of the library functionality.  Arguments and functionality 
  2132. are as defined for the corresponding API function, which has the same name as the method but 
  2133. prefixed by "Ecd".   A handler may override any of the method functions, but must supply a 
  2134. semantically equivalent function in order that clients work correctly.
  2135. ECDOBJECT, ECDOBJECTVTBL, LPECDOBJECT
  2136. typedef struct _ECDOBJECTVTBL {
  2137.     LPVOID (FAR PASCAL *QueryProtocol)( LPECDOBJECT lpobj, LPSTR lpprotocol );
  2138.     ECDSTATUS  (FAR PASCAL  *Delete) ( LPECDOBJECT lpobj );
  2139.     ECDSTATUS (FAR PASCAL *Show)     ( LPECDOBJECT lpobj );
  2140.     ECDSTATUS (FAR  PASCAL *GetData)( LPECDOBJECT lpobj, 
  2141.                         ECDCLIPFORMAT  clipFormat, 
  2142.                         LPHANDLE lpdata );
  2143.     ECDSTATUS (FAR PASCAL *SetData ( LPECDOBJECT lpobj, 
  2144.                         ECDCLIPFORMAT clipFormat,
  2145.                          HANDLE hdata );
  2146.     ECDSTATUS (FAR PASCAL *SetHostNames)( LPECDOBJECT lpobj, LPSTR. LPSTR );
  2147.     ECDSTATUS (FAR PASCAL *SetTargetDevice) ( LPECDOBJECT lpobj, 
  2148.                         HANDLE  hdata );
  2149.     ECDSTATUS (FAR PASCAL *SetBounds)( LPECDOBJECT lpobj, LPRECT );
  2150.     ECDSTATUS (FAR PASCAL *EnumFormats) (LPECDOBJECT lpobj, 
  2151.                             ECDCLIPFORMAT  clipFormat);
  2152.     ECDSTATUS (FAR PASCAL *SaveToStream)(LPECDOBJECT, LPECDSTREAM);
  2153.     ECDSTATUS (FAR PASCAL *Clone)(LPECDOBJECT,LPECDCLIENT, 
  2154.                     LPECDOBJECT FAR * );
  2155.     ECDSTATUS (FAR PASCAL *CopyFromLink)( LPECDOBJECT, LPECDCLIENT,
  2156.                     LPECDOBJECT FAR * );
  2157.     ECDSTATUS (FAR PASCAL *Equal)  (LPECDOBJECT lpobj)
  2158.     ECDSTATUS (FAR PASCAL *CopyToClipboard) (LPECDOBJECT lpobj);
  2159.     ECDSTATUS (FAR PASCAL *CutToClipboard) (LPECDOBJECT lpobj);
  2160.     ECDSTATUS (FAR PASCAL *QueryBounds) (LPECDOBJECT lpobj, 
  2161.                         LPRECT lpbounds);
  2162.     ECDSTATUS  (FAR PASCAL *Draw) (LPECDOBJECT lpobj, 
  2163.                         HDC hdc, 
  2164.                         LPRECT bounds, 
  2165.                         HDC hFormatDC);
  2166.     BOOL (FAR PASCAL *QueryOpen ) (LPECDOBJECT lpobj);
  2167.     ECDSTATUS (FAR PASCAL *Open) (LPECDOBJECT lpobj, 
  2168.                         BOOL fShow, 
  2169.                         HWND hwnd, 
  2170.                         LPRECT lpbounds);
  2171.     ECDSTATUS (FAR PASCAL *Close )( LPECDOBJECT lpobj);
  2172.     ECDSTATUS (FAR PASCAL *Update) (LPECDOBJECT lpobj, 
  2173.                         BOOL  fShow);
  2174.     ECDSTATUS (FAR PASCAL *Reconnect )( LPECDOBJECT lpobj);
  2175.     ECDSTATUS (FAR PASCAL *QueryOutOfDate) (LPECDOBJECT lpobj);
  2176.     ECDSTATUS (FAR PASCAL *ObjectConvert) (LPECDOBJECT lpobj, 
  2177.                         LPSTR lpprotocol, 
  2178.                         LPECDCLIENT lpclient, 
  2179.                         LPECDOBJECT FAR * lplpobject);
  2180. } ECDOBJECTVTBL
  2181. typedef struct _ECDOBJECT{
  2182.     struct _ECDOBJECTVTBL FAR *vptr;
  2183.     /* server supplied object state goes here */
  2184. } ECDOBJECT;
  2185.  
  2186.  
  2187.   Object release
  2188. The Delete method is used to free the object.  Handlers may override this method in order to perform 
  2189. any class-specific termination actions for this object, free any additional resources etc.  The handler 
  2190. should call the library-supplied version of Delete from its version if it overrides, and return the status 
  2191. that the library returns.
  2192.   Server API specification
  2193.   Types, Data structures and parameter definitions
  2194. The server library requires a number of different services from the server application.  These are 
  2195. packaged into different structures that the server application creates and makes available to the library.  
  2196. See the client API specification for a description of the general way that these structures are built and 
  2197. used.
  2198.   Structures provided by the server for the library
  2199. The server application creates memory structures of several types in order to give the library access to 
  2200. the objects that clients know about.  These structures model the concepts of server, document, object.  
  2201. At startup, the server application creates a structure of type ECDSERVER and registers it with the 
  2202. library.  When a document is opened or created (either by the user or on request from the library), a 
  2203. structure of type ECDDOCUMENT is created and registered (or returned if the library requested it).  
  2204. Since each document may have many links, the library requests creation of a structure of type 
  2205. ECDOBJECT for each, and requests functions based on those.  Detailed specification of the methods 
  2206. that must be supplied for server, document and object types are given in the sections following.  The 
  2207. library also maintains information for each of these types, which the server applications sees and 
  2208. identifies through opaque (long) handles.  The overall model is one of mutual courtesy: the server 
  2209. library maintains the association between its internal structure and that of the server application, and 
  2210. passes both handle (to library info) and pointer (to the application's data structure) in calls to the 
  2211. application.  The application in turn is required to remember the library's handle, and pass that in the 
  2212. appropriate calls.
  2213. LHSERVER, LHDOCUMENT
  2214. /* definition of handles passed  back to the server application from server lib */
  2215. typedef LONG LHSERVER;
  2216. typedef LONG LHDOCUMENT;
  2217.  
  2218. typedef  struct _ECDSERVER FAR *LPECDSERVER;
  2219. typedef struct  _ECDDOCUMENT FAR *LPECDDOCUMENT;
  2220.  
  2221. /* LPECDOBJECT is defined to be opaque in the client api specification */
  2222. /* we give a proper object definition here for servers to implement. */
  2223.  
  2224.  
  2225. typedef struct  _ECDOBJECT  FAR *LPECDOBJECT;
  2226.  
  2227.   API functions and callbacks (methods)
  2228.   Startup and registration
  2229. If the server application is started normally, it should proceed with its normal default document 
  2230. creation or whatever.  If the server is launched with "-Embedding" on the command line, it should not 
  2231. create a document or show a window, but should register with the library (see below) and enter a 
  2232. message dispatch loop and wait for calls from the library to create documents etc.
  2233. EcdRegisterServer
  2234. ECDSTATUS FAR PASCAL EcdRegisterServer( classname, lpsrvr , lplhserver, hInst );
  2235. At startup, the server application should create a struct ECDSERVER and call this function to register 
  2236. it with the library together with the classname that the server supports.  Server that support several 
  2237. classnames may allocate a structure for each or may reuse the same structure as they desire.  The 
  2238. classname is passed back to server application functions invoked through the library, so that multi-class 
  2239. servers can distinguish which class is being requested.
  2240. Name    Type    Description
  2241. classname    LPSTR    the name of the class being registered
  2242. lpserver    LPECDSERVER    a long pointer to an ECDSERVER structure allocated and 
  2243. initialized by the server application
  2244. lplhserver    LHSERVER FAR *    a long pointer to an LHSERVER where the library will 
  2245. store the handle for its information.  The server application 
  2246. should remember this handle and use it for further calls to 
  2247. the library (e.g. EcdRevokeServer) to identify the 
  2248. class/server.
  2249. hInst    HANDLE    the instance handle of the server application.  This is used 
  2250. to ensure clients connect to the right instance of a server 
  2251. application.
  2252. return value    ECDSTATUS    see ECDSTATUS type description.
  2253.   Server Methods
  2254. The server library will listen for requests from clients, and invoke methods on the server object to 
  2255. create or open documents, etc.  These methods must be supplied by the server application and are 
  2256. declared as follows:
  2257. ECDSERVER, LPECDSERVER
  2258. struct _ECDSERVERVTBL
  2259. {
  2260.     ECDSTATUS (FAR PASCAL *Open)( LPECDSERVER lpsrvr,
  2261.                 LHDOCUMENT lhdoc,
  2262.                 LPSTR documentname,
  2263.                 LPECDDOCUMENT FAR * lpdoc );
  2264.     ECDSTATUS (FAR PASCAL *Create)( LPECDSERVER lpsrvr,
  2265.                  LHDOCUMENT lhdoc,
  2266.                 LPSTR classname,
  2267.                  LPSTR documentname,
  2268.                  LPECDDOCUMENT FAR * lpdoc );
  2269.     ECDSTATUS (FAR PASCAL *CreateFromTemplate)(LPECDSERVER lpsrvr,
  2270.                          LHDOCUMENT lhdoc,
  2271.                          LPSTR classname,
  2272.                          LPSTR documentname,
  2273.                          LPSTR templatename,
  2274.                          LPECDDOCUMENT FAR * lpdoc );
  2275.     ECDSTATUS (FAR PASCAL *Edit)( LPECDSERVER lpsrvr,
  2276.                 LHDOCUMENT lhdoc, 
  2277.                 LPSTR classname,
  2278.                 LPSTR documentname,
  2279.                 LPECDDOCUMENT FAR * lpdoc );
  2280.  
  2281.     ECDSTATUS (FAR PASCAL *Exit)( LPECDSERVER lpsrvr );
  2282.     ECDSTATUS (FAR PASCAL *Release)(LPECDSERVER lpsrvr); /*ok to quit */
  2283. };
  2284.  
  2285. struct _ECDSERVER{
  2286.     struct _ECDSERVERVTBL FAR* vptr;
  2287.     /* any server supplied state goes here */
  2288. };
  2289.  
  2290. Open is used to open an existing file and prepare to edit the contents.  Save commands should save 
  2291. the changed object back to the original file.  Create is used to make a new object of the given 
  2292. classname which is to be embedded in the client application.  The documentname parameter will 
  2293. be used to identify the object, but should not be used to create a file for the object.  
  2294. CreateFromTemplate is used to create a new document initialized with the data in the file 
  2295. identified by templatename.  As with Create, the document should be treated as untitled, and 
  2296. will be embedded in the client application.  Edit is used to create a document to be initialized with 
  2297. the data in a subsequent SetData call.  The object is embedded in the client application.  In each of 
  2298. these functions, the created document should not be shown to the user for editing until instructed by 
  2299. the library (see below).
  2300. The Exit function is used to instruct the server application to close documents and shut down.  The 
  2301. server should normally comply with this without prompting (e.g. to save modified documents) since this 
  2302. is the client's responsibility.  In the case that the server application has opened other documents on 
  2303. request by the user, the server should ignore the request to exit.
  2304. ECDSERVER: Open
  2305. ECDSTATUS (FAR PASCAL *Open)( lpsrvr,     lhdoc, documentname, lplpdoc );
  2306. This function requests the server application to open a named document, allocate and initialize an 
  2307. ECDDOCUMENT structure, associate the library's handle with it, and return the address of the 
  2308. structure in lplpdoc.
  2309. Name    Type    Description
  2310. lpsrvr    LPECDSERVER    a long pointer to an ECDSERVER structure that was 
  2311. registered by the server application.
  2312. lhdoc    LHDOCUMENT    a long handle that the library will use to identify the 
  2313. document internally.
  2314. documentname    LPSTR    a null-terminated string containing the permanent name of 
  2315. the document to be opened (normally a pathname, but for 
  2316. some applications this might be further qualified, e.g. a 
  2317. table in a database).
  2318. lplpdoc    LPECDDOCUMENT FAR *    a long pointer to an LPECDDOCUMENT where 
  2319. the server application should return a long pointer to the 
  2320. created ECDDOCUMENT structure.
  2321. return value    ECDSTATUS    the server should return ECD_OK if all is well.
  2322. ECDSERVER: Create
  2323. ECDSTATUS (FAR PASCAL *Create)( lpsrvr,lhdoc,classname,documentname,lplpdoc );
  2324. This function requests the server application to create a new document of the specified class, allocate 
  2325. and initialize an ECDDOCUMENT structure, associate the library's handle with it, and return the 
  2326. address of the structure in lplpdoc.  The created document is opened for editing by this call and will be 
  2327. embedded in the client when it is closed.
  2328. Name    Type    Description
  2329. lpsrvr    LPECDSERVER    a long pointer to an ECDSERVER structure that was 
  2330. registered by the server application.
  2331. lhdoc    LHDOCUMENT    a long handle that the library will use to identify the 
  2332. document internally.
  2333. classname    LPSTR    the string name of the class of document to create
  2334. documentname    LPSTR    a null-terminated string containing a name for the 
  2335. document to be created.  This name need not be used by 
  2336. the server application, but  may be used in window titles etc.
  2337. lplpdoc    LPECDDOCUMENT FAR *    a long pointer to an LPECDDOCUMENT where 
  2338. the server application should return a long pointer to the 
  2339. created ECDDOCUMENT structure.
  2340. return value    ECDSTATUS    the server should return ECD_OK if all is well.
  2341. ECDSERVER: CreateFromTemplate
  2342. ECDSTATUS (FAR PASCAL *CreateFromTemplate)( lpsrvr, lhdoc, classname, documentname, 
  2343. templatename, lplpdoc );
  2344. This function requests the server application to create a new document of the specified class, initialized 
  2345. from the content of the document named in "templatename", allocate and initialize an 
  2346. ECDDOCUMENT structure, associate the library's handle with it, and return the address of the 
  2347. structure in lplpdoc.  The created document is opened for editing by this call and will be embedded in 
  2348. the client when it is closed.
  2349. Name    Type    Description
  2350. lpsrvr    LPECDSERVER    a long pointer to an ECDSERVER structure that was 
  2351. registered by the server application.
  2352. lhdoc    LHDOCUMENT    a long handle that the library will use to identify the 
  2353. document internally.
  2354. classname    LPSTR    the string name of the class of document to create
  2355. documentname    LPSTR    a null-terminated string containing a name for the 
  2356. document to be created.  This name need not be used by 
  2357. the server application, but  may be used in window titles etc.
  2358. templatename    LPSTR    the permanent name of the document to use to initialize the 
  2359. new document.  Normally a pathname, but may be further 
  2360. qualified.  See Open, above.
  2361. lplpdoc    LPECDDOCUMENT FAR *    a long pointer to an LPECDDOCUMENT where 
  2362. the server application should return a long pointer to the 
  2363. created ECDDOCUMENT structure.
  2364. return value    ECDSTATUS    the server should return ECD_OK if all is well.
  2365. ECDSERVER: Edit
  2366. ECDSTATUS (FAR PASCAL *Edit)( lpsrvr,lhdoc, classname, documentname, lplpdoc );
  2367. This function requests the server application to create a new document of the specified class, allocate 
  2368. and initialize an ECDDOCUMENT structure, associate the library's handle with it, and return the 
  2369. address of the structure in lplpdoc.  The created document will be given its initial data from the client 
  2370. in a following SetData call.  Subsequently, the document is opened for editing.
  2371. Name    Type    Description
  2372. lpsrvr    LPECDSERVER    a long pointer to an ECDSERVER structure that was 
  2373. registered by the server application.
  2374. lhdoc    LHDOCUMENT    a long handle that the library will use to identify the 
  2375. document internally.
  2376. classname    LPSTR    the string name of the class of document to create
  2377. documentname    LPSTR    a null-terminated string containing a name for the 
  2378. document to be created.  This name need not be used by 
  2379. the server application, but  may be used in window titles etc.
  2380. lplpdoc    LPECDDOCUMENT FAR *    a long pointer to an LPECDDOCUMENT where 
  2381. the server application should return a long pointer to the 
  2382. created ECDDOCUMENT structure.
  2383. return value    ECDSTATUS    the server should return ECD_OK if all is well.
  2384. ECDSERVER: Exit
  2385. ECDSTATUS (FAR PASCAL *Exit)( lpsrvr );
  2386. This function is used to instruct the server to exit.  The server should close any open documents.  If a 
  2387. multiple document server has documents opened by other clients or by user command, it should ignore 
  2388. this call.
  2389. Name    Type    Description
  2390. lpsrvr    LPECDSERVER    a long pointer to an ECDSERVER structure that was 
  2391. registered by the server application.
  2392. return value    ECDSTATUS    see ECDSTATUS type description
  2393. ECDSERVER: Release
  2394. ECDSTATUS (FAR PASCAL *Release)( lpsrvr );
  2395. This function is used to notify the server application when all connections to the server have closed 
  2396. down and it will be safe to terminate.  All registered server structures must be released before the 
  2397. server application can terminate.
  2398.   Shutdown
  2399. Before exiting, the server application should close all documents (see below) and de-register all server 
  2400. classes by calling the following function.
  2401. EcdRevokeServer
  2402. ECDSTATUS FAR PASCAL EcdRevokeServer( lhsrvr );
  2403. This function may be called by the application when (e.g.) the user asks the application to exit.  The 
  2404. library will close any documents that it opened on behalf of clients, and terminate conversations with 
  2405. them.  The library may return ECD_WAIT_FOR_RELEASE if conversations are still in the process of 
  2406. termination, in which case the application should not free the ECDSERVER structure or exit, but 
  2407. should wait (dispatching messages) until a Release call from the library is received.
  2408. Name    Type    Description
  2409. lhsrvr    LHSERVER    a long handle obtained by calling EcdRegisterServer, 
  2410. indicates which server to revoke.
  2411. return value    ECDSTATUS    may be ECD_WAIT_FOR_RELEASE or ECD_OK or 
  2412. some error.
  2413.   Document creation
  2414. EcdRegisterDocument
  2415. ECDSTATUS FAR PASCAL EcdRegisterDocument( lhsrvr, documentname,lplhdoc,lpdoc );
  2416. When the server application creates or opens a document other than on request from the library, it 
  2417. should register the document with the library in case other clients have links to it.  This function is used 
  2418. for this.
  2419. If the document were created or opened in response to request from the library, it should not be 
  2420. registered through this function but instead the pointer to the document struct should be returned 
  2421. through the parameter to the relevant call.
  2422. Name    Type    Description
  2423. lhsrvr    LHSERVER    a long handle obtained by calling EcdRegisterServer, 
  2424. indicates which server to revoke.
  2425. documentname    LPSTR    the permanent name for the document.  Normally a 
  2426. pathname.
  2427. lplhdoc    LHDOCUMENT FAR *    a long pointer to a long handle where the library will return 
  2428. the handle by which it identifies the document internally.
  2429. lpdoc    LPECDDOCUMENT    a long pointer to an ECDDOCUMENT structure allocated 
  2430. and initialized by the server application.
  2431. return value    ECDSTATUS    may be ECD_WAIT_FOR_RELEASE or ECD_OK or 
  2432. some error.
  2433.   Document methods
  2434. ECDDOCUMENT, LPECDDOCUMENT
  2435. struct _ECDDOCUMENTVTBL{
  2436.     ECDSTATUS (FAR PASCAL *Save)( LPECDDOCUMENT lpdoc );
  2437.     ECDSTATUS (FAR PASCAL *Close)( LPECDDOCUMENT lpdoc );
  2438.     ECDSTATUS (FAR PASCAL *SetHostNames) (LPECDOBJECT lpobj,  LPSTR, LPSTR);
  2439.     ECDSTATUS (FAR PASCAL *SetDocDimensions) (LPECDOBJECT  lpobj,
  2440.                                   LPRECT  lpbounds);
  2441.     ECDSTATUS (FAR PASCAL *GetObject)( LPECDDOCUMENT lpdoc,
  2442.                   LPSTR itemname,
  2443.                   LPECDOBJECT FAR* lpobj,
  2444.                   LPECDCLIENT lpclient);
  2445.     ECDSTATUS (FAR PASCAL *Release)(LPECDDOCUMENT lpdoc); /*Finished with 
  2446. document */
  2447. };
  2448.  
  2449. struct _ECDDOCUMENT{
  2450.     struct _ECDDOCUMENTVTBL FAR *vptr;
  2451.     /* server supplied document state goes here */
  2452. };
  2453.  
  2454.  
  2455. Once a document has been created, the library may make calls to it to save it (if it was opened rather 
  2456. than created as an embedded object) or close it.  Save should save the state into the file associated 
  2457. with the document.  Close should simply close the document without saving or prompting.  The 
  2458. document structure and associated resources should be freed.
  2459. The library will call  GetObject to associate a client with the part of the document identified by 
  2460. itemname, where a null itemname (i.e. a null string) means the whole document.  Once a client 
  2461. has been connected by this call, the server should be prepared to send notifications as  described below.  
  2462. Note that documents opened or created on request from the library should not be shown to the user 
  2463. for editing until the library requests it as described below.
  2464. ECDDOCUMENT: Save
  2465. ECDSTATUS (FAR PASCAL *Save)(  lpdoc );
  2466. This function is used to instruct the server to save the document.
  2467. Name    Type    Description
  2468. lpdoc    LPECDDOCUMENT    a long pointer to an ECDDOCUMENT that was returned 
  2469. by a method function of a registered server, and which 
  2470. should be saved.
  2471. return value    ECDSTATUS    the server application should return ECD_OK if all is well.
  2472. ECDDOCUMENT: Close
  2473. ECDSTATUS (FAR PASCAL *Close)( lpdoc );    
  2474. This function is used to instruct the server application to unconditionally close the document.  The 
  2475. server application should not prompt the user to save etc., as that is the responsibility of the client.
  2476. Name    Type    Description
  2477. lpdoc    LPECDDOCUMENT    a long pointer to an ECDDOCUMENT that was returned 
  2478. by a method function of a registered server, and which 
  2479. should be closed.
  2480. return value    ECDSTATUS    the server application should return ECD_OK if all is well.
  2481. ECDDOCUMENT: SetHostNames
  2482. ECDSTATUS (FAR PASCAL *SetHostNames)( lpdoc, lpclientname, lpdocname );
  2483. This function is used to set names that should be used for window titles etc. These names are only used 
  2484. for embedded objects, as linked objects have their own titles.  This call is only used for documents that 
  2485. are embedded objects.
  2486. Name    Type    Description
  2487. lpdoc    LPECDDOCUMENT    a long pointer to the ECDDOCUMENT that is the 
  2488. embedded object for which names are being specified.
  2489. lpclientname    LPSTR    the name of the client
  2490. lpdocname    LPSTR    the client's name for the object.
  2491. return value    ECDSTATUS    see ECDSTATUS type description
  2492. lpclientname    LPSTR    the name of the client
  2493. lpdocname    LPSTR    the client's name for the object.
  2494. return value    ECDSTATUS    see ECDSTATUS type description
  2495. ECDDOCUMENT: SetDocDimensions
  2496. ECDSTATUS (FAR PASCAL *SetDocDimensions)( lpdoc,  lpbounds );
  2497. This function is used to communicate to the server the size on the target device to which the object 
  2498. should be formatted.  The bounds are specified in MM_HIMETRIC units.  This call is only relevant 
  2499. for documents that are embedded objects.
  2500. Name    Type    Description
  2501. lpdoc    LPECDDOCUMENT    a long pointer to the ECDDOCUMENT that is the 
  2502. embedded object for which the target size is being specified.
  2503. lpbounds    LPRECT    a long pointer to a RECT structure containing the target 
  2504. size of the object in MM_HIMETRIC units.
  2505. return value    ECDSTATUS    see ECDSTATUS type description
  2506. ECDDOCUMENT: GetObject
  2507. ECDSTATUS (FAR PASCAL *GetObject)( lpdoc, itemname, lplpobj, lpclient );
  2508. This function is used by the library to request an object structure on behalf of a client.  The server 
  2509. application should allocate and initialize an ECDOBJECT structure, associate the lpclient pointer with 
  2510. it, and return the pointer through the lplpobj argument.
  2511. Name    Type    Description
  2512. lpdoc    LPECDDOCUMENT    a long pointer to an ECDDOCUMENT that was returned 
  2513. by a method function of a registered server
  2514. itemname    LPSTR    the string name of an item in the specified document for 
  2515. which an object structure is requested.  A null item name 
  2516. (i.e. and empty string) implies the entire document, and is 
  2517. the normal case for objects embedded in clients.
  2518. lplpobj    LPECDOBJECT FAR *    a long pointer to an LPECDOBJECT where the server 
  2519. application should return a long pointer to the allocated 
  2520. ECDOBJECT structure.
  2521. lpclient    LPECDCLIENT    a long pointer to an ECDCLIENT structure allocated by 
  2522. the library, which should be associated with the object and 
  2523. used to notify changes etc. to the library.
  2524. return value    ECDSTATUS    the server application should return ECD_OK if all is well.
  2525. ECDDOCUMENT: Release
  2526. ECDSTATUS (FAR PASCAL *Release)( lpdoc );
  2527. This function is used by the library to notify the server application when a revoked document (see 
  2528. below) has finally terminated conversations and may be destroyed.
  2529. Name    Type    Description
  2530. lpdoc    LPECDDOCUMENT    a long pointer to an ECDDOCUMENT whose associated 
  2531. LHDOCUMENT was revoked and which may now be 
  2532. released.
  2533. return value    ECDSTATUS    the server application should return ECD_OK if all is well.
  2534.   Closing documents
  2535. When closing a document other than on request from the library, the server application should first de-
  2536. register all object structures that have been registered with the library, and then de-register the 
  2537. document with the following call:
  2538. EcdRevokeDocument
  2539. ECDSTATUS FAR PASCAL EcdRevokeDocument( lhdoc );
  2540. This function should be called when a registered document is being closed or otherwise made 
  2541. unavailable for clients.
  2542. Name    Type    Description
  2543. lhdoc    LHDOCUMENT    a long handle to a document that was returned from 
  2544. EcdRegisterDocument or was associated with a document 
  2545. through one of the server methods that create documents.
  2546. return value    ECDSTATUS    may return ECD_WAIT_FOR_RELEASE indicating that 
  2547. the server application should not terminate or free the 
  2548. ECDDOCUMENT structure until a Release notification 
  2549. occurs.  This library will return ECD_OK if the document 
  2550. may be freed immediately.
  2551.   Object creation
  2552. Object structures should be created only on request from the library and should be returned through 
  2553. the parameter to the relevant call.
  2554.   Server Object methods
  2555. The object structure in the server library is the same as for the object handler, but only the first few 
  2556. methods are called by the server library, and only these need be implemented by the server application.
  2557.     LPVOID (FAR PASCAL *QueryProtocol)( LPECDOBJECT lpobj, LPSTR lpprotocol );
  2558.     ECDSTATUS  (FAR PASCAL  *Delete) ( LPECDOBJECT lpobj );
  2559. /* Delete is just Release in server, doesn't tell server to destroy data, just free the structure */
  2560.     ECDSTATUS (FAR PASCAL *Show)( LPECDOBJECT lpobj );
  2561.     ECDSTATUS  (FAR  PASCAL *GetData)( LPECDOBJECT lpobj, 
  2562.                         ECDCLIPFORMAT  clipFormat, 
  2563.                         LPHANDLE lpdata );
  2564.     ECDSTATUS (FAR PASCAL *SetData ( LPECDOBJECT lpobj, 
  2565.                         ECDCLIPFORMAT clipFormat,
  2566.                          HANDLE hdata );
  2567.     ECDSTATUS (FAR PASCAL *SetHostNames)( LPECDOBJECT lpobj, LPSTR. LPSTR );
  2568.     ECDSTATUS (FAR PASCAL *SetTargetDevice) ( LPECDOBJECT lpobj, 
  2569.                         HANDLE  hdata );
  2570.     ECDSTATUS (FAR PASCAL *SetBounds)( LPECDOBJECT lpobj, LPRECT );
  2571.     ECDSTATUS (FAR PASCAL *EnumFormats) (LPECDOBJECT lpobj, 
  2572.                             ECDCLIPFORMAT  clipFormat);
  2573.  
  2574. The library will call Show when the server application should show the document to the user for 
  2575. editing, or to request the server to scroll the document to bring the object into view (if the document is 
  2576. already open).  The library will call Delete when no clients are connected to the object.  The object 
  2577. structure and associated resources should be freed.
  2578. ECDOBJECT: Delete
  2579. ECDSTATUS  (FAR PASCAL  *Delete)( lpobject );
  2580. This function tells the server to free the resources associated with the object structure since no clients 
  2581. are currently connected.  It does not tell the server to destroy  any data.
  2582. Name    Type    Description
  2583. lpobject    LPECDOBJECT    a long pointer to the ECDOBJECT to be released
  2584. return value    ECDSTATUS    the server should return ECD_OK if all is well.
  2585. ECDOBJECT: Show
  2586. ECDSTATUS (FAR PASCAL *Show)( lpobject );
  2587. This function tells the server to show the object, showing its window and scrolling if necessary to bring 
  2588. it into view.
  2589. Name    Type    Description
  2590. lpobject    LPECDOBJECT    a long pointer to the ECDOBJECT to be shown
  2591. return value    ECDSTATUS    the server should return ECD_OK if all is well.
  2592. ECDOBJECT: GetData
  2593. ECDSTATUS  (FAR  PASCAL *GetData)( lpobject, cfFormat, lphdata );
  2594. This function is used to retrieve data from the object in a specified format.  The server application 
  2595. should allocate a memory object of adequate size, fill it with the data, and return it through the lphdata 
  2596. argument.
  2597. Name    Type    Description
  2598. lpobject    LPECDOBJECT    a long pointer to the ECDOBJECT from which data is 
  2599. requested
  2600. cfFormat    ECDCLIPFORMAT    the format in which the data is requested
  2601. lphdata    HANDLE FAR *    a long pointer to a memory handle where the server 
  2602. application should return the handle to the allocated 
  2603. memory.  The library will free the memory when it is no 
  2604. longer needed.
  2605. return value    ECDSTATUS    the server should return ECD_OK if all is well.
  2606. ECDOBJECT: SetData
  2607. ECDSTATUS (FAR PASCAL *SetData( lpobject, cfFormat, hdata );
  2608. This function is used to store data into the object in a specified format.  This function is called (with 
  2609. format Native) when a client opens an embedded object for editing (after a document has been created 
  2610. with the server's Edit method).   It is also used if the client calls EcdSetData with some other format.
  2611. Name    Type    Description
  2612. lpobject    LPECDOBJECT    a long pointer to the ECDOBJECT into which data is to be 
  2613. stored
  2614. cfFormat    ECDCLIPFORMAT    the format of the data.
  2615. hdata    HANDLE    a memory handle from which the server application should 
  2616. extract the data
  2617. return value    ECDSTATUS    the server should return ECD_OK if all is well.
  2618. ECDOBJECT: SetTargetDevice
  2619. ECDSTATUS (FAR PASCAL *SetTargetDevice)( lpobject, hdata );
  2620. This function is used to communicate information about the client's target device for the object, which 
  2621. can be used by the server to generate a picture formatted for best results on that  device.
  2622. Name    Type    Description
  2623. lpobject    LPECDOBJECT    a long pointer to the ECDOBJECT for which the target 
  2624. device is being specified.
  2625. hdata    HANDLE    a handle to a memory object containing a StdTargetDevice 
  2626. structure (see appendix for details under StdTargetDevice)
  2627. return value    ECDSTATUS    see ECDSTATUS type description
  2628.   Object release
  2629. Revoking a document will cause the library to release each object associated with that document.  
  2630. Objects may be explicitly revoked by the server application.
  2631. EcdRevokeObject
  2632. ECDSTATUS FAR PASCAL EcdRevokeObject( lpclient );
  2633. The server application can call this function to revoke access to an object, for example if the user 
  2634. destroys it.
  2635. Name    Type    Description
  2636. lpclient    LPECDCLIENT    a long pointer to the ECDCLIENT structure associated 
  2637. with the object which is being revoked.
  2638. return value    ECDSTATUS    will be ECD_OK unless the server application passes a bad 
  2639. pointer.
  2640.   Notification
  2641. The client should notify the library of certain changes to the document.  The library may call the object 
  2642. to retrieve new data either immediately (during the notification call) or at a later time (e.g. on request 
  2643. from a client application).  Notifications are required when an object changes state, or when certain 
  2644. actions happen to the containing document.  The latter actions are saving, closing, renaming.  
  2645. Notification is done through the CallBack function pointer found through the ECDCLIENT structure 
  2646. that is passed to the server when an object structure is created.  See the client API section for details of 
  2647. notification function syntax.
  2648. Note that the library will make callbacks to objects (particularly for rendering data with GetData) from 
  2649. inside the notification call from the server application.
  2650.  
  2651.    Registration
  2652. Servers that support the compound document protocol register their classes in the system registry. This 
  2653. is a general-purpose system registry that is described in the Registration API section of the Windows 
  2654. SDK documentation. This registry stores key-value pairs, where keys and values are null-terminated 
  2655. strings. Keys are hierarchically structured, with component names separated by "\" characters. To 
  2656. make a server available, the following key-value pairs must be registered during installation of the 
  2657. server.
  2658. Applications should register the information described in the shell section of the integration guide, 
  2659. which includes extension-classname pairs, a human-readable form for the classname, and associated 
  2660. actions.
  2661. For this protocol, installing a server application requires that for each class supported by the server, 
  2662. register the classname and server application name resulting in the key-value pairs below.  If the class 
  2663. hasa handler, it should be registered with the "Handler" keyword.
  2664. .classes\.ext = <classname>
  2665. .classes\<classname> = <Human readable classname, localizable>
  2666. .classes\<classname>\protocol\StdFileEditing\Server =     <pathname and arguments>
  2667. .classes\<classname>\protocol\StdFileEditing\Handler = <dll pathname>
  2668. Clients check that a class supports this protocol, and retrieve the command line for launching the 
  2669. server, by querying the registry for the last entry above.
  2670. Pre-release note:
  2671. As of this version of the specification and pre-release code, 
  2672. the registration database is not in use.  In the interim 
  2673. win.ini is used as the registration database.  The 
  2674. interim registration scheme described below will be 
  2675. replaced before the product version is released.
  2676. The relevant parts of the registration API specification are 
  2677. attached to this spec for information.
  2678. For this interim release, two sections of win.ini are used to store registration information:
  2679. [StdFileEditing]
  2680. <classname>\Server = <pathname and arguments>
  2681. <classname>\Handler = <dll pathname>        //optional, handlers only
  2682. ...
  2683. [Embedding]
  2684. <classname>=<comment>,<human readable classname>,<pathname and 
  2685. arguments>,Picture,1
  2686. Servers must be registered in the [StdFileEditing] section above.  In addition, if powerpoint 2.0 is to be 
  2687. used as a client, the servers must also be registered in the [Embedding] section as described.  The 
  2688. keyword Picture indicates to Powerpoint that the server can produce metafiles for the rendering.  The 
  2689. magic value 1 indicates that the server supports the StdFileEditing protocol, and is ignored by 
  2690. Powerpoint.  Powerpoint Graph supports an earlier, slightly different, version of the protocol and 
  2691. should not have the magic value in the [Embedding] section.  Powerpoint 2.0 is compatible with both.
  2692.  
  2693.  
  2694.   Appendix: DDE-based protocol specification
  2695. Implementation of the compound document protocol requires implementation of the underlying DDE 
  2696. protocol, as specified in the Windows and Presentation Manager documentation.
  2697.   Launching the Server Application
  2698. When opening a link or an embedded document, the client application should look up the class name 
  2699. in the system registry as above. The client should unconditionally launch the application, passing "-
  2700. Embedding" as a command line argument. For the interim cases of MDI or single instance 
  2701. applications, the launched program should locate the other instance if available, and send the 
  2702. appropriate command (StdNewDocument, etc). Where necessary for performance, the launched 
  2703. program would be a stub which loads the real application if it must. This approach is adopted rather 
  2704. than putting the burden on the client, to avoid establishing a practice that we may want to change when 
  2705. we move to multiple instances in different workspaces.
  2706. When the server is given the "-Embedding" parameter, it should not create a new default document, 
  2707. but wait until the client sends the StdOpenDocument (or the StdEditDocument command followed by 
  2708. the Native data) and then instructs the server to show the window. The server may optionally use the 
  2709. StdHostNames item (q.v.) to display the client s name in the window title. When the user closes the 
  2710. document in the server, the client should be re-activated.
  2711.   DDE Conventions
  2712. This protocol is a set of conventions for use of DDE. All of the standard DDE rules and facilities 
  2713. apply. Applications that conform to this proposal must also conform to the DDE specification. 
  2714. Conforming to this specification implies supporting the System topic, and the standard items in that 
  2715. topic (Topics, SysTopics, etc).
  2716.   Conversations
  2717. Document operations will be performed in conversation with the application s system topic. The docu-
  2718. ment ClassName is used to establish conversation.
  2719. Data transfer and negotiation operations will be performed in conversation with the document (i.e. 
  2720. topic). The document name is used to establish the conversation.
  2721. Note that the topic name is only use in initiating conversations and is not fixed for the life of the 
  2722. conversation; permitting the document to be renamed (see DocumentName item, below) does not 
  2723. mean that there will be two names. It is therefore reasonable to tie the topic name to the document 
  2724. name.
  2725.   Formats
  2726. Applications supporting extended DDE use four clipboard formats in addition to the regular data and 
  2727. picture formats:
  2728.  
  2729. Format Name
  2730. Structure
  2731.  
  2732. ObjectLink
  2733. szClassname,szDocument,szItem,0
  2734.  
  2735. OwnerLink
  2736. szClassname,szDocument,szItem,0
  2737.  
  2738. Native
  2739. Stream of bytes,only parsed by application rendering it, must 
  2740. be self-contained, i.e. the application must be able to 
  2741. completely reconstruct the item from the bytes in the Native 
  2742. format.
  2743.  
  2744. Binary
  2745. A stream of bytes whose interpretation is implicit in the item; 
  2746. see StdHostNames, StdTargetDevice, and EditEnvItems 
  2747. items.
  2748.  
  2749.   System Topic Items
  2750. Topics returns a list of DDE topic names that the server application has open. Where 
  2751. topics correspond to documents, the topic name will be the permanent document 
  2752. name.
  2753. Protocols returns a list of protocols supported by the application. The list is returned 
  2754. in text format, tab separated. A protocol is a defined set of execute strings and 
  2755. item/format conventions that the application understands. Currently defined is: 
  2756.         Protocol: StdFileEditing    Commands/items/formats: as in this document.
  2757.     For compatibility with older client applications which do not use the library, server 
  2758. applications written directly to the DDE protocol should also list the name 
  2759. "Embedding" in the list of protocols.
  2760. Status is a text item which returns "Ready" if the server is prepared to respond to 
  2761. DDE requests, and "Busy" otherwise. This item can be queried to determine if 
  2762. there is any point in offering functions such as "Update link" to the user. It is 
  2763. possible for the server to reject or defer a request even if this item returned 
  2764. "Ready", so client applications should be prepared for this.
  2765.   Standard Item Names and Notification Control
  2766. New items available on each topic other than the system topic are defined for this protocol. These are:
  2767. StdDocumentName contains the permanent document name associated with the 
  2768. topic. If no permanent storage is associated with the topic, this item is empty. The 
  2769. item supports both request and advise transactions, and may be used to detect 
  2770. renaming of open documents.
  2771. EditEnvItems returns a tab-separated list (in text format) of the items carrying envi-
  2772. ronmental information that the server supports for its documents. Currently defined 
  2773. are StdHostNames, StdDocDimensions and StdTargetDevice. Applications can de-
  2774. clare other items (and define the interpretations if Binary is to be used) to permit 
  2775. clients that know of them to provide richer information. Servers that cannot use 
  2776. particular items should omit their names from this item. Clients should REQUEST 
  2777. this item to determine which items the server can use, and should supply the data 
  2778. through a DDE POKE message.
  2779. StdHostNames accepts information about the client application, in Binary format in-
  2780. terpreted as the following structure:
  2781.         struct {
  2782.             WORD clientNameOffset;
  2783.             WORD documentNameOffset;
  2784.             BYTE data[];
  2785.         } StdHostNames;
  2786.     The offsets indicate the starting point for the appropriate information in the data 
  2787. array (relative to the start of the data array).
  2788. StdTargetDevice accepts information about the target device that the client is using. 
  2789. This information is in Binary format, interpreted as the following structure.  Offsets 
  2790. are relative to the start of the data array.
  2791.         struct {
  2792.             WORD deviceNameOffset;
  2793.             WORD driverNameOffset;
  2794.             WORD portNameOffset;
  2795.             WORD extDevModeOffset;
  2796.             WORD extDevModeSize;
  2797.             WORD environmentOffset;
  2798.             WORD environmentSize;
  2799.             BYTE data[];
  2800.         } StdTargetDevice;
  2801. StdDocDimensions accepts information about the sizes of document that the client is 
  2802. interested in. This information is in Binary format, interpreted as the following 
  2803. structure.
  2804.         struct {
  2805.             WORD defaultWidth;
  2806.             WORD defaultHeight;
  2807.             WORD maxWidth;
  2808.             WORD maxHeight;
  2809.         } StdDocDimensions;
  2810.     The default fields indicate a suggested size for newly created pictures, and the max 
  2811. fields indicate the maximum allowable size (i.e. the page size of the client docu-
  2812. ment). These measurements are specified in MM_HIMETRICS units.
  2813. StdColorScheme returns the colors that the server is currently using, and accepts 
  2814. information about the colors that client wants the server to use. This information is 
  2815. in Binary format, interpreted as a Windows LOGPALETTE structure.
  2816. null is zero length ItemName that specifies a request/advise on the entire data 
  2817. contained in the topic. 
  2818. The update method used for Advises on items follows a convention of appending an update specifier to 
  2819. the actual item name. The item is encoded as follows:
  2820.     <itemname>/<update type>
  2821. For backward compatibility, omission of the update type results in the same as specifying /Change. 
  2822. <update type> may be one of:
  2823.     Change        notify each change
  2824.     Save        notify when topic is saved
  2825.     Close        notify when file closed
  2826. DDE server applications are required to remember each occurrence of an Advise that specifies a 
  2827. unique tuple <item, update type, format, conversation>. Notifications are disabled by a DDE 
  2828. UnAdvise message with corresponding parameters.
  2829.   Standard Commands in DDE Execute Strings
  2830. The syntax for standard commands sent in execute strings is as defined in the DDE manual:
  2831.     [command(argument1,argument2,..)][command2(arg1,arg2)]
  2832. Commands without arguments do not require (). String arguments must be enclosed in double quotes
  2833. Commands that must be supported by server applications are defined in the following sections.
  2834. StdNewDocument(ClassName,DocumentName)
  2835. Creates a new, empty document of the given class, with the given name, but does not save it. The server 
  2836. should not show the window until a StdShowItem command is received. The server should return an 
  2837. error if the DocumentName is already in use, and the client should generate another name and try 
  2838. again.
  2839. StdNewFromTemplate(ClassName,DocumentName,TemplateName)
  2840. Creates a new document of the given class with the given DocumentName from the template with the 
  2841. given permanent name (i.e. filename).
  2842. StdEditDocument(DocumentName)
  2843. Creates a document with the given name, and gets ready to accept data to be poked into it using 
  2844. WM_DDE_POKE. The server should not show the window until a StdShowItem command is received. 
  2845. The server should return an error if the DocumentName is already in use, and the client should 
  2846. generate another name and try again.
  2847. StdOpenDocument(DocumentName)
  2848. Sent to system topic. Opens an existing document with the given name. The server should not show the 
  2849. window until a StdShowItem command is received.
  2850.  
  2851. The above three commands all make the document available for DDE conversations with the name 
  2852. DocumentName. They do not show any window associated with the document; the client must send a 
  2853. StdShowItem command to make the window visible. This enables the client to negotiate additional 
  2854. parameters (e.g. StdTargetDevice) with the server without causing extraneous repaints.
  2855. StdCloseDocument(DocumentName)
  2856. Sent to the system topic. Closes down the window associated with the document. Following acknowl-
  2857. edgement, the server terminates any conversations associated with the document. The server should 
  2858. not activate the window in the process of closing it.
  2859. StdSaveDocument(DocumentName)
  2860. Sent to System conversation. Saves the named document. Preserves the same name. The server should 
  2861. not activate the window in the process of saving it.
  2862. StdShowItem(DocumentName,ItemName [, fTakeFocus] )
  2863. Sent to the system topic, this command makes the window containing the named document visible, and 
  2864. scrolls to show the named item if it is not null.  The optional third argument indicates whether the 
  2865. server should take focus and bring itself to the front or not.  The value of this argument shouldbe the 
  2866. literal TRUE indicating take focus or FALSE indicating not.   If the argument is not present, TRUE is 
  2867. assumed.
  2868. StdExit
  2869. Shuts down the server application. This command should only be used by the client application that 
  2870. launched the server. This command is available in the system topic only.
  2871.  
  2872. The following variants of the above commands may be sent to the document topic rather than the 
  2873. system topic, so that the client does not have to open an additional conversation to the system if it 
  2874. already has a conversation with the document. The document name is omitted from these commands 
  2875. because it is implied by the conversation topic, and because it may have been changed by the server. 
  2876. This kind of name change does not invalidate the conversation, and the client should not be forced to 
  2877. track the change to the name unnecessarily. The implication is that the server must be able to identify 
  2878. the document to be operated on from the conversation information.
  2879. StdCloseDocument
  2880. Sent to document conversation. Closes the document associated with the conversation without 
  2881. activating it. This command causes a DDE terminate to be posted by the server window following the 
  2882. acknowledgement.
  2883. StdSaveDocument
  2884. Sent to document conversation. Saves the document associated with the conversation. Preserves the 
  2885. same name. Should not activate the window or show any confirmation dialog.
  2886. StdShowItem(ItemName  [, fTakeFocus] )
  2887. Sent to document conversation. Shows the document window, scrolling if necessary to bring the item 
  2888. into view. A null item name does not cause scrolling.  The optional third argument indicates whether 
  2889. the server should take focus and bring itself to the front or not.  The value of this argument shouldbe 
  2890. the literal TRUE indicating take focus or FALSE indicating not.   If the argument is not present, 
  2891. TRUE is assumed.
  2892.   An example: opening an object for editing
  2893. When the client application calls the client library to open the object, the library behaves 
  2894. (asynchronously) as follows. Note that the ClassName, DocumentName and item name are 
  2895. components of the link descriptor. Note also that in the case of a link, the client first attempts to locate 
  2896. the document in case it is already open in another application.
  2897.     if (already open)
  2898.         return
  2899.     if (item is a link)
  2900.         Attempt to initiate conversation
  2901.                 with ClassName, DocumentName pair
  2902.     if (connected)
  2903.         ADVISE on StdDocumentName
  2904.         ADVISE on item, desired format, update type
  2905.     else
  2906.         query system registry for ClassName
  2907.                 to identify editor application
  2908.         if (item is link to another document)
  2909.             launch the editor with -Embedding argument
  2910.             establish conversation with ClassName, System
  2911.             send StdOpenDocument( DocumentName )
  2912.             establish conversation with the document topic
  2913.             for each of StdTargetDevice, StdDocDimensions 
  2914.                     that are listed in EditEnvItems item
  2915.                 POKE relevant values
  2916.             ADVISE on StdDocumentName item
  2917.                     in case server renames the document
  2918.             ADVISE on item, desired format,
  2919.                     update type as specified in link
  2920.             send ShowItem command
  2921.         else    // item is embedded object
  2922.             launch the editor with -Embedding command line option
  2923.             establish a DDE conversation with system topic
  2924.             send StdEditDocument command with client-supplied
  2925.                     unique name for the document
  2926.             if edit command fails, try to make another
  2927.                     non-conflicting name.
  2928.                     //The server s Topics item can be of help.
  2929.             establish conversation with the new document
  2930.             POKE the native data
  2931.             for each of StdHostNames,
  2932.                     StdTargetDevice,
  2933.                     StdDocDimensions 
  2934.                     that are listed in EditEnvItems item
  2935.                 POKE relevant values
  2936.             ADVISE on item, desired format, update on close.
  2937.             send ShowItem command
  2938.             remember server was started by this client
  2939.  
  2940.  
  2941.  
  2942.  "Convert" is a word we have used in our discussions to describe the process of making a "non-object" from an object, usually 
  2943. by extracting the objects content (data) without preserving any of its behavior or presentation. Note that the model described 
  2944. here is not intended to replace conversion as a way of moving data from one application to another. The term "convert" is 
  2945. also used to describe the process of transforming an object of one type into an object of another type.
  2946.  Users exercise control over this delay through "update rules" associated with the reference. (See Part 2.)
  2947.  An object s presentation may be supplied by the object (e.g., a metafile or bitmap) only when the object is changed; or it may 
  2948. be generated by interaction between the object and the container (e.g., the container executes display code provided by the 
  2949. object, usually as a DLL or other non-application code resource) each time the object s presentation is redrawn.
  2950.  I.e., all  tables in a given word processor exhibit exactly the same selection behavior, regardless of whether they are 
  2951. presentations of data links to spreadsheets.
  2952.  E.g., in a table that is the presentation of a spreadsheet range, users may select individual cells, but not the text within the cell.
  2953.  For example, changing the format of an entry in a table that presents a spreadsheet is allowed, changing the value in the cell is 
  2954. not.
  2955.  I.e., editors should initially hide the portions of an object that are not displayed in the container.
  2956.  <Object> is replaced by text that describes the selected item.
  2957.  This dialog will evolve into an object property sheet in future interfaces. Currently, however, this dialog displays only those 
  2958. properties related to the linked- or embedded-ness of the object or reference, and to its presentation in the container.
  2959.  A link in a document to a spreadsheet range would, for example, have a link properties dialog with the word processor s 
  2960. usual formatting controls while an embedded graph in a presentation might have an object properties dialog with additional 
  2961. controls for recoloring, sizing, and cropping.
  2962.  Note that this requires that containers maintain the original copy of an embedded object throughout the entire editing 
  2963. session; specifically, containers must preserve this information through updates from the editor.
  2964.  Note that in order to make the changes to the object persistent, the container must be saved.
  2965.  The new object is, of course, inserted at the location that was the current selection at the time the "Insert New Object..." 
  2966. command was executed. Note, however, that this may no longer be the current selection in the container at the time the "File-
  2967. Update" command is executed in the editor.
  2968.  This strangeness is forced by the nature of DDE and its use here to communicate with server applications.
  2969.  "Devotees of object-oriented programming will realize what is going on here" (stolen from David Rosenthal).  This technique 
  2970. can be fully understood (and will be implemented) in terms of C language features and conventions.
  2971.  
  2972. Compound Document Protocol        Extensible Application Protocols
  2973.  
  2974. Printed: 12/3/90    61    12/2/90
  2975.  
  2976. Compound Document Protocol        Extensible Application Protocols
  2977.  
  2978. Printed: 12/3/90    73    12/2/90
  2979.  
  2980.  
  2981.