Skip to content

What is a Document in ATF

Gary edited this page Aug 27, 2014 · 1 revision

Table of Contents

A document is a file containing application data. Nearly all applications process data, so most have documents that can be saved and opened for later modification.

IDocument Interface

In ATF, a document object implements the IDocument interface. IDocument derives from IResource, an interface for resources that have a type and unique resource identifier (URI).

IDocument is very simple, consisting of:

  • IsReadOnly property: indicate whether the document is read-only.
  • Dirty property: is the version of the document in memory different than the version in its file?
  • DirtyChanged event: Dirty changed.
  • Type property (IResource): get the text string that identifies this document type to the end-user.
  • Uri property (IResource): get or set the document's URI as an absolute path.
  • UriChanged event (IResource): Uri changed.
The DomDocument class provides an implementation of IDocument you can use in your application. DomDocument is also a DOM adapter. Several ATF samples use DomDocument, such as ATF Simple DOM Editor Sample.

IDocumentClient Interface

Each type of document has one or more IDocumentClient interfaces associated with it. A document client does the work of handling a document and implements IDocumentClient for operations on the document, mainly file-related:

  • Info property: get DocumentClientInfo with information about the document client, such as file type and its file extensions, and so on. For details, see DocumentClientInfo Class below.
  • CanOpen(): can the document be opened?
  • Open(): open the document from a file.
  • Show(): display the document.
  • Save(): save the document to a file.
  • Close(): close the file.
An application typically provides one IDocumentClient interface for each type of document it handles. Different applications can handle the same document in different ways, so they could have different IDocumentClient implementations for the same document. Applications processing text files may do so in very different ways, for instance. In addition, a single application could provide different views of application data and have several implementations of IDocumentClient for the same document type. For example, an application could open an XML file containing a Schema as plain text or as a tree of nodes, as Visual Studio does.

DocumentClientInfo Class

DocumentClientInfo holds information about a document for a particular document client. This information can be used to determine if a file can be opened, for example.

DocumentClientInfo has a set of constructors, who between them, provide the following information:

  • Name describing the type of document, unique for each document type in the application.
  • File extensions (without the initial '.').
  • Name of a "New document" icon used in the UI, such as on a menu item or button.
  • Name of an "Open document" icon used in the UI, such as on a menu item or button.
  • Whether the client can open multiple documents simultaneously.

Topics in this section

Clone this wiki locally