Aliases in the Document

Definition

Objects may be used more than once in a document. A typical example which comes to mind is a pictogram repeated on every page, but there are a lot of other such duplicated use of objects : styles, families, etc.

Rather than storing every identical object multiple times, VP uses an aliasing scheme (also known as linking in UNIX or NTFS file systems). The original object is moved to a special block of the document (the alias block) and every occurrence of the object is replaced by a link, which is called an alias in the VP terminology.

Alias object

An alias object is implemented as a raw object of category OBJCAT_LINK which contains the index of the referrer object directly preceding the aliased object :

 
{
    ObjectHead      head;           //  OBJCAT_LINK
    ObjectIndex     referrer;       //  link to referrer object
};
 

Aliased object and Referrer object

The aliased object is stored in the document alias block. It is preceded by a typed object (a VP::DocObj::ReferrerObject) containing an array of indexes referring to the aliases :

 
struct ReferrerObject : public TypedObject {
    
    ObjectIndex     alias[n];       //  table of referring aliases
};
 

Aliasing an object

Turning an object into an alias is called aliasing. It implies following steps, if the object is not yet aliased :

If the object is already aliased, the following steps are taken :

Document alias manipulation methods

The document class (VP::Document) provides several methods to manipulate aliases :

Locking aliased objects

It is not possible to lock an aliased object, i.e. to avoid that it disappears when there is no longer any visible link to it. This means that an object may not maintain a reference to an aliased object without having guaranteeing that at least one link points to it.

Thus, commands such as CloneStyle have to maintain an alias (link) in the scratch zone for aliased objects they refer to, and for which there is no guarantee that another link exists.