# CXRef

CXRef class wrapps Xpdf `XRef` class and provides additional functionality with same interface (see . It provides with protected interface for making changes and internally stores changed objects. When object should be fetched (`fetch` method is called), it will check whether this object is already changed and if so, uses changed value. Otherwise delegates to `XRef` original implementation (this logic is kept in all methods defined in XRef).

CXRef inherits from `XRef` and so can be polymorphicaly used in xpdf code and this code doesn't need any changes to use CXref functionality. Aditional interface enables changes, but as we want to keep this making changes under control so it is protected and so accessible only for its inheritance descendants.

Added functionality includes:

- new indirect objects creation - creates new pdf object and associates it with reserved reference.
- changing of already existing indirect objects. `changeObject` method which changes object with given reference with given object.
- changing of document trailer - add, remove or change elements of .
- checking for type safety - checks whether given object can safely replace original value (in document or currently saved form) according types. Type safe change is consider such change, when new value type is either same as old type, or dereferenced types (if any of types is reference) or if original value is CNull, then new value may have arbitrary type.
- reopen functionality - `reopen` method which is responsible for document content reopen with at specified position. This is then used to change current revision of document, where cross reference table position is specific for desired revision.

For more information about CXref usage, please see .

CXref class scheme