#include <cpageannots.h>
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 |
Class representing annotations. Provides convinient access and modify operations on "Annots" entry of a page dictionary.
| typedef std::vector<boost::shared_ptr<CAnnotation> > pdfobjects::CPageAnnots::Annotations |
Type for annotation storage.
| pdfobjects::CPageAnnots::CPageAnnots | ( | CPage * | page | ) |
References _annotations, _page, pdfobjects::CPage::getDictionary(), and reg_observers().
| pdfobjects::CPageAnnots::~CPageAnnots | ( | ) |
References reset().
| 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.
| annot | Annotation to add. |
| 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.
| 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.
| 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).
References _annotations, _page, debug::DBG_DBG, debug::DBG_ERR, debug::DBG_INFO, pdfobjects::CPage::getDictionary(), and kernelPrintDbg.
| 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.
| 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.
| annots | Annots property. |
Referenced by CPageAnnots().
| void pdfobjects::CPageAnnots::reset | ( | ) | [virtual] |
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.
| annots | Annots property. |
References _page, pdfobjects::Specification::Page::ANNOTS, debug::DBG_DBG, pdfobjects::CPage::getDictionary(), kernelPrintDbg, and UNREGISTER_SHAREDPTR_OBSERVER.
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.
CPage* pdfobjects::CPageAnnots::_page [private] |
Referenced by add(), CPageAnnots(), del(), reset(), and unreg_observers().
boost::shared_ptr<PropWatchDog> pdfobjects::CPageAnnots::_prop_wd [private] |
Watchdog for Annots property.