pdfobjects::CPageAnnots Class Reference

#include <cpageannots.h>

Inheritance diagram for pdfobjects::CPageAnnots:
pdfobjects::ICPageModule

List of all members.

Classes

class  ArrayWatchDog
class  PropWatchDog

Public Types

typedef std::vector
< boost::shared_ptr
< CAnnotation > > 
Annotations

Public Member Functions

 CPageAnnots (CPage *page)
 ~CPageAnnots ()
virtual void reset ()
template<typename T >
void getAll (T &container) const
void add (boost::shared_ptr< CAnnotation > annot)
bool del (boost::shared_ptr< CAnnotation > annot)

Private Member Functions

void reg_observers (boost::shared_ptr< IProperty > annots=boost::shared_ptr< IProperty >())
void unreg_observers (boost::shared_ptr< IProperty > annots=boost::shared_ptr< IProperty >())
void consolidate (boost::shared_ptr< IProperty > &oldValue, boost::shared_ptr< IProperty > &newValue)

Private Attributes

CPage_page
Annotations _annotations
boost::shared_ptr< PropWatchDog_prop_wd
boost::shared_ptr< ArrayWatchDog_array_wd

Detailed Description

Class representing annotations. Provides convinient access and modify operations on "Annots" entry of a page dictionary.


Member Typedef Documentation

typedef std::vector<boost::shared_ptr<CAnnotation> > pdfobjects::CPageAnnots::Annotations

Type for annotation storage.


Constructor & Destructor Documentation

pdfobjects::CPageAnnots::CPageAnnots ( CPage page  ) 
pdfobjects::CPageAnnots::~CPageAnnots (  ) 

References reset().


Member Function Documentation

void pdfobjects::CPageAnnots::add ( boost::shared_ptr< CAnnotation annot  ) 

Adds new annotation to this page.

Inserts deep copy of given annotation and stores its reference to Annots array in page dictionary (if this doesn't exist, it is created). User has to call getAllAnnotations to get current annotations state (we don't have identifier for annotations - there are some mechanisms how to do it according pdf specification, but there is no explicit identifier).
Given annotation may come from different CPdf or may belong to nowhere.
As a result _annotations is updated. New indirect object representing annotation dictionary is added to same pdf (dictionary is same as given one except P field is updated to contain correct reference to this page).
Note that this page must belong to pdf and has to have valid indirect reference. This is neccessary, because annotation is indirect object page keeps reference to it. Reference without pdf doesn't make sense.

Parameters:
annot Annotation to add.
Exceptions:
CObjInvalidObject if this page doesn't have valid pdf or indirect reference.
ElementBadTypeException if Annots field from page dictionary is not an array (or reference with array indirect target).

References _page, pdfobjects::Specification::Page::ANNOTS, pdfobjects::utils::checkAndReplace(), debug::DBG_DBG, debug::DBG_ERR, debug::DBG_INFO, pdfobjects::CPage::getDictionary(), pdfobjects::CObjectFactory< Type >::getInstance(), pdfobjects::CArrayFactory::getInstance(), kernelPrintDbg, and REGISTER_SHAREDPTR_OBSERVER.

void pdfobjects::CPageAnnots::consolidate ( boost::shared_ptr< IProperty > &  oldValue,
boost::shared_ptr< IProperty > &  newValue 
) [private]

Consolidates _annotations field according given change. Works in two steps. First handles oldValue and second newValue. At first checkes oldValue type and if it is reference, dereference indirect objects and if it is annotation dictionary, it will invalidate associated CAnnotation and removes it from _annotations.
In second step, checks newValue type and if it is reference to dictionary, it will create new CAnnotation instance and adds it to _annotations.

Parameters:
oldValue Removed reference from _annotations.
newValue Added reference to the _annotations.

References _annotations, debug::DBG_DBG, debug::DBG_WARN, pdfobjects::isRef(), and kernelPrintDbg.

bool pdfobjects::CPageAnnots::del ( boost::shared_ptr< CAnnotation annot  ) 

Removes given annotation from page.

Parameters:
annot Annotation to remove.

Tries to find given annotation in _annotations and if found, removes reference from Annots array.
As a result, removed annotation is invalidated and not accessible. User has to call getAllAnnotations method to get current state (same way as in addAnnotation case).

Returns:
true if annotation was removed.

References _annotations, _page, debug::DBG_DBG, debug::DBG_ERR, debug::DBG_INFO, pdfobjects::CPage::getDictionary(), and kernelPrintDbg.

template<typename T >
void pdfobjects::CPageAnnots::getAll ( T &  container  )  const [inline]

Fills given container with all page's annotations.

Copies _annotations content to given container (which is cleared at first).
Given container must support clear and insert operations and store shared_ptr<CAnnotation$gt; elements.

Parameters:
container Container which is filled in.

References _annotations.

void pdfobjects::CPageAnnots::reg_observers ( boost::shared_ptr< IProperty annots = boost::shared_ptr< IProperty >()  )  [private]

Registers observers for annotation synchronization. Checks type of given property and if it is reference, registers AnnotsPropWatchDog observer to it and dereferences indirect object. If annots or dereferenced object is array, registers _annots_array_wd observer to it and all its reference type elements.

By default, it registers annotation observer for page dictionary.

Parameters:
annots Annots property.

Referenced by CPageAnnots().

void pdfobjects::CPageAnnots::reset (  )  [virtual]
See also:
ICPageModule::reset

Reimplemented from pdfobjects::ICPageModule.

References _annotations, and _page.

Referenced by ~CPageAnnots().

void pdfobjects::CPageAnnots::unreg_observers ( boost::shared_ptr< IProperty annots = boost::shared_ptr<IProperty>()  )  [private]

Unregisters obsevers from given Annots property. This method works reversely to registerAnnotsObservers (observers are unregistered but rest is same).

By default, it registers annotation observer for page dictionary.

Parameters:
annots Annots property.

References _page, pdfobjects::Specification::Page::ANNOTS, debug::DBG_DBG, pdfobjects::CPage::getDictionary(), kernelPrintDbg, and UNREGISTER_SHAREDPTR_OBSERVER.


Member Data Documentation

Annotations on this page.

Referenced by consolidate(), CPageAnnots(), del(), getAll(), and reset().

boost::shared_ptr<ArrayWatchDog> pdfobjects::CPageAnnots::_array_wd [private]

Watchdog for Annotation array.

See also:
AnnotsArrayWatchDog
boost::shared_ptr<PropWatchDog> pdfobjects::CPageAnnots::_prop_wd [private]

Watchdog for Annots property.

See also:
AnnotsPropWatchDog

The documentation for this class was generated from the following files: