#include <cannotation.h>
Public Types | |
| enum | AnnotType { Text, Link, FreeText, Line, Square, Circle, Polygon, PolyLine, Highlight, Underline, Squiggly, StrikeOut, Stamp, Caret, Ink, Popup, Fileattachement, Sound, Movie, Widget, Screen, Printermark, Trapnet, Watermark, _3D, Unknown } |
| typedef observer::BasicChangeContext < CAnnotation > | ChangeContext |
Public Member Functions | |
| CAnnotation (boost::shared_ptr< CDict > annotDict) | |
| ~CAnnotation () | |
| bool | isValid () const |
| void | invalidate () |
| AnnotType | getType () const |
| boost::shared_ptr< CDict > | getDictionary () const |
| bool | operator== (const CAnnotation &annot) |
Static Public Member Functions | |
| static boost::shared_ptr < CAnnotation > | createAnnotation (libs::Rectangle rect, std::string annotType) |
| static boost::shared_ptr < utils::IAnnotInitializator > | setAnnotInitializator (boost::shared_ptr< utils::IAnnotInitializator > init) |
Private Member Functions | |
| CAnnotation () | |
Private Attributes | |
| boost::shared_ptr< CDict > | annotDictionary |
| bool | valid |
Static Private Attributes | |
| static boost::shared_ptr < utils::IAnnotInitializator > | annotInit = shared_ptr<utils::IAnnotInitializator>(new utils::UniversalAnnotInitializer()) |
High level object for annotations.
This class wrapps pdf annotation dictionary and provides simple interface for manipulation with this dictionary. Also implements logic needed for proper annotation handling.
Instance can be created only from existing annotation dictionary or using factory method createAnnotation.
Each CAnnotation instance is valid while it is accessible from some page dictionary. In moment when reference to it is removed from page (more precisely from Annots array in page dictionary), instance should be invalidated. This is done by annotation maintainer (CPage instance) using invalidate method. Note that all methods are available also when instance is invalidated. Annotation keeper should register observer which handles situation that instance is not valid anymore. Other possibility is to call isValid method.
Maintained dictionary is returned by getDictionary method. This can be used to perform unsupported or unusual operations.
Type for observer change context. This class produces BasicChangeContext.
Annotation type enumeration. List of all known types according pdf specification. See PDF specification chapter 8.4.5. Annotation Types.
CAnnotation doesn't have to support initialization of all listed types (it depends on annotation initializator).
| pdfobjects::CAnnotation::CAnnotation | ( | ) | [private] |
Private constructor.
| pdfobjects::CAnnotation::CAnnotation | ( | boost::shared_ptr< CDict > | annotDict | ) | [inline] |
Initialization constructor.
| annotDict | Annotation dictionary. |
Initializes annotDictionary from given one and sets valid flag to true. Doesn't perform any checking. Given dictionary has to be in pdf and its reference in Annots array.
This should be used when caller is sure that given annotDict is ok (e. g. one returned from createAnnotation method).
| pdfobjects::CAnnotation::~CAnnotation | ( | ) | [inline] |
Destructor.
Deallocates all additional data needed for work. Doesn't do anything with annotDictionary field.
References annotDictionary, observer::ObserverHandler< CAnnotation >::dumpObservers(), observer::ObserverHandler< CAnnotation >::observers, and observer::PriorityList< T, Storage, Compare >::size().
| static boost::shared_ptr<CAnnotation> pdfobjects::CAnnotation::createAnnotation | ( | libs::Rectangle | rect, | |
| std::string | annotType | |||
| ) | [static] |
Static factory method for annotation creation.
| rect | Rectangle for annotation (location on the screen in default user space units). | |
| annotType | Type of the annotation. |
Creates new annotation dictionary and do some initialization according given parameters.
At first fills maintaining information requiered by pdf specification to the dictionary, such as Type, M and Rect fields. Then uses annotInit initializator for type specific initialization with given annotType (it depends on annotInit static initializator what it is done).
Created annotation can be used in CPage::addAnnotation method.
| boost::shared_ptr<CDict> pdfobjects::CAnnotation::getDictionary | ( | ) | const [inline] |
Returns maintained annotation dictionary.
This can be used if CAnnotation interface doesn't provide required functionality. User can perform changes directly on annotation dictionary. Nevertheless this can be rather dangerous becuse nonsese information may be provided.
References annotDictionary.
Referenced by operator==().
| CAnnotation::AnnotType pdfobjects::CAnnotation::getType | ( | ) | const |
Returns type of annotation.
Gets Subtype field value from maintained annotation dictionary and maps it to enumenration AnnotType value. If this type is not one from pdf specification (valid in time of program writting) or Subtype field is not present, Unknown value is returned.
References pdfobjects::utils::annotTypeMapping(), debug::DBG_WARN, pdfobjects::isName(), kernelPrintDbg, and Unknown.
| void pdfobjects::CAnnotation::invalidate | ( | ) |
Invalidates this annotation.
This method should be called when annotation maintainer (there should be only one according pdf specification) releases reference to annotation dictionary. All registered observers are notified - newValue parameter stands for this annotation instance and context is empty (shared_ptr contains NULL).
If valid flag is already false, nothing is done.
References isValid(), and observer::ObserverHandler< CAnnotation >::notifyObservers().
| bool pdfobjects::CAnnotation::isValid | ( | ) | const [inline] |
| bool pdfobjects::CAnnotation::operator== | ( | const CAnnotation & | annot | ) | [inline] |
Equality operator.
| annot | Annotation to compare with this. |
Two annotations are same if they maintain same annotation dictionaries.
References getDictionary().
| static boost::shared_ptr<utils::IAnnotInitializator> pdfobjects::CAnnotation::setAnnotInitializator | ( | boost::shared_ptr< utils::IAnnotInitializator > | init | ) | [inline, static] |
Sets new annotation initializator.
| init | Initializator to be used. |
Static method which sets new implementator for annotation initializator. If given init holds non NULL initializator, sets it to the static annotInit field.
References annotInit.
boost::shared_ptr<CDict> pdfobjects::CAnnotation::annotDictionary [private] |
Annotation dictionary.
Pdf annotation dictionary maintained by this instance.
Referenced by getDictionary(), and ~CAnnotation().
shared_ptr< utils::IAnnotInitializator > pdfobjects::CAnnotation::annotInit = shared_ptr<utils::IAnnotInitializator>(new utils::UniversalAnnotInitializer()) [static, private] |
Initializator for annotations. This implementator is used when annotation dictionary should be initialized. Concrete implementation can be set by setAnnotInitializator method.
Referenced by setAnnotInitializator().
bool pdfobjects::CAnnotation::valid [private] |
Validity flag.
Value is initialized to true in constructor and can be changed by invalidate method to false.
Referenced by isValid().