#include <cdict.h>
Public Types | |
| typedef std::list< std::pair < std::string, boost::shared_ptr< IProperty > > > | Value |
| typedef const std::string & | WriteType |
| typedef const std::string & | PropertyId |
| typedef observer::ComplexChangeContext < IProperty, PropertyId > | CDictComplexObserverContext |
Public Member Functions | |
| CDict (boost::weak_ptr< CPdf > p, const Object &o, const IndiRef &rf) | |
| CDict (const Object &o) | |
| CDict () | |
| virtual PropertyType | getType () const |
| virtual void | getStringRepresentation (std::string &str) const |
| void | init (const CDict &dict) |
| size_t | getPropertyCount () const |
| template<typename Container > | |
| void | getAllPropertyNames (Container &container) const |
| bool | containsProperty (const std::string &name) const |
| boost::shared_ptr< IProperty > | getProperty (PropertyId id) const |
| PropertyType | getPropertyType (PropertyId id) const |
| virtual void | setPdf (boost::weak_ptr< CPdf > pdf) |
| virtual void | setIndiRef (const IndiRef &rf) |
| boost::shared_ptr< IProperty > | setProperty (PropertyId id, IProperty &ip) |
| boost::shared_ptr< IProperty > | addProperty (const std::string &propertyName, const IProperty &newIp) |
| void | delProperty (PropertyId id) |
| ~CDict () | |
| template<typename Fctor > | |
| void | forEach (Fctor &fctor) |
| virtual ::Object * | _makeXpdfObject () const |
| template<typename Storage > | |
| void | _getAllChildObjects (Storage &store) const |
Static Public Attributes | |
| static const PropertyType | type = pDict |
Protected Member Functions | |
| virtual IProperty * | doClone () const |
| virtual CDict * | _newInstance () const |
| void | _setMode (boost::shared_ptr< IProperty > ip, PropertyId id) const |
Private Member Functions | |
| ObserverContext * | _createContext (boost::shared_ptr< IProperty > changedIp, PropertyId id) |
| void | _objectChanged (boost::shared_ptr< IProperty > newValue, boost::shared_ptr< const ObserverContext > context) |
Private Attributes | |
| Value | value |
Friends | |
| class | CStream |
Class representing dictionary object from pdf specification v1.5.
We do not want to use xpdf dictionary because it is a real mess and it is really not suitable for editing. We use xpdf object just for initializing.
According to pdf specification, dictionary is a container of keys and values. Keys are strings identifying items. You can not rely on the position of a value. Value can be any object from pdf specification. Pdf objects form a tree like structure.
This class does not provide default copy constructor because copying a property could be understood either as deep copy or shallow copy. Copying complex types could be very expensive so we have made the decision to avoid it.
REMARK: It is similar to CArray but it has also too much differences to be cleanly implemented as one template class. (It has been implemented like one template class but later was seperated to CArray and CDict)
| typedef observer::ComplexChangeContext<IProperty, PropertyId> pdfobjects::CDict::CDictComplexObserverContext |
| typedef const std::string& pdfobjects::CDict::PropertyId |
| typedef std::list<std::pair<std::string, boost::shared_ptr<IProperty> > > pdfobjects::CDict::Value |
| typedef const std::string& pdfobjects::CDict::WriteType |
Constructor.
| p | Pointer to pdf object. | |
| o | Xpdf object. | |
| rf | Indirect id and gen id. |
References value.
| pdfobjects::CDict::CDict | ( | const Object & | o | ) |
| pdfobjects::CDict::CDict | ( | ) | [inline] |
Public constructor. This object will not be associated with a pdf.
| pdfobjects::CDict::~CDict | ( | ) | [inline] |
Destructor
| ObserverContext* pdfobjects::CDict::_createContext | ( | boost::shared_ptr< IProperty > | changedIp, | |
| PropertyId | id | |||
| ) | [private] |
Create context of a change.
REMARK: Be carefull. Deallocate the object.
| changedIp | Pointer to old value. | |
| id | Id identifies changed property. |
Referenced by delProperty(), and setProperty().
| void pdfobjects::CDict::_getAllChildObjects | ( | Storage & | store | ) | const [inline] |
Return all child objects.
| store | Output container of all child objects. |
References value.
| Object * pdfobjects::CDict::_makeXpdfObject | ( | ) | const [virtual] |
Make xpdf Object from this object. This function allocates and initializes xpdf object. Caller has to deallocate the xpdf Object.
| ObjBadValueE | Thrown when xpdf can't parse the string representation of this object correctly. |
Implements pdfobjects::IProperty.
References pdfobjects::XPdfObjectFactory::getInstance(), pdfobjects::IProperty::getPdf(), getPropertyCount(), pdfobjects::IProperty::pdf, and value.
| virtual CDict* pdfobjects::CDict::_newInstance | ( | ) | const [inline, protected, virtual] |
Return new instance.
This function is a factory method design pattern for creating complex instances.
Referenced by doClone().
| void pdfobjects::CDict::_objectChanged | ( | boost::shared_ptr< IProperty > | newValue, | |
| boost::shared_ptr< const ObserverContext > | context | |||
| ) | [private] |
Indicate that the object has changed. Notifies all observers associated with this property about the change.
| newValue | Pointer to new value of an object. | |
| context | Context in which a change occured. |
Referenced by delProperty(), and setProperty().
| void pdfobjects::CDict::_setMode | ( | boost::shared_ptr< IProperty > | ip, | |
| PropertyId | id | |||
| ) | const [protected] |
Set mode of a property.
| ip | IProperty which mode will be set. | |
| id | Key identifying property. |
Referenced by getProperty(), and setProperty().
| boost::shared_ptr<IProperty> pdfobjects::CDict::addProperty | ( | const std::string & | propertyName, | |
| const IProperty & | newIp | |||
| ) |
Add property to dictionary.
Firstly, the property that is passed as argument is cloned and the cloned object is added. Indicate that this object has changed and return the pointer to the cloned object.
If a property with the same name is already in this dictionary an exception is thrown.
| propertyName | property name | |
| newIp | new property |
| OutOfRange | Thrown when property not found. | |
| CObjInvalid | When the object is invalid |
Referenced by pdfobjects::CPageContents::addInlineImage(), pdfobjects::CStream::addProperty(), pdfobjects::utils::dictFromXpdfObj(), and setProperty().
| bool pdfobjects::CDict::containsProperty | ( | const std::string & | name | ) | const |
Returns true if the property name is present in the dictionary.
| name | Property name |
Referenced by pdfobjects::CStream::containsProperty(), and gui::QSDict::exist().
| void pdfobjects::CDict::delProperty | ( | PropertyId | id | ) |
Remove property from dictionary.
| id | Name/Index of property |
| ElementNotFoundException | Thrown when object is not found. |
References _createContext(), _objectChanged(), pdfobjects::IProperty::canChange(), debug::DBG_DBG, pdfobjects::DictIdxComparator::getIProperty(), pdfobjects::hasValidPdf(), pdfobjects::hasValidRef(), kernelPrintDbg, and value.
Referenced by pdfobjects::CStream::delProperty(), and pdfobjects::CStream::setBuffer().
| IProperty * pdfobjects::CDict::doClone | ( | ) | const [protected, virtual] |
Clone. Performs deep copy. REMARK: It will not copy pdf indirect objects that are referenced from the pdf object tree starting in this object.
Implements pdfobjects::IProperty.
References _newInstance(), and value.
| void pdfobjects::CDict::forEach | ( | Fctor & | fctor | ) | [inline] |
Apply functor operator() on each element. The operator() will get std::pair<string, shared_ptr<IProperty>> as parameter. First item identifies the property.
| fctor | Functor that will do the work. |
References value.
| void pdfobjects::CDict::getAllPropertyNames | ( | Container & | container | ) | const [inline] |
Inserts all property names of this complex type to the container supplied by caller.
| container | Output container of string objects. Could be vector,list,deque etc. |
References value.
Referenced by pdfobjects::CStream::getAllPropertyNames(), gui::TreeItemDict::getChildNames(), pdfobjects::CInlineImage::getStringRepresentation(), and gui::QSDict::propertyNames().
| shared_ptr< IProperty > pdfobjects::CDict::getProperty | ( | PropertyId | id | ) | const |
Returns value of property identified by its name.
| id | Name of the property. |
References _setMode(), pdfobjects::DictIdxComparator::getIProperty(), and value.
Referenced by gui::TreeItemDict::createChild(), gui::TreeItemDict::deepReload(), gui::TreeItemDict::getChildNames(), gui::TreeItemDict::getChildType(), pdfobjects::CStream::getFilters(), pdfobjects::CStream::getProperty(), getPropertyType(), pdfobjects::utils::getSimpleValueFromDict(), pdfobjects::CInlineImage::getStringRepresentation(), gui::QSDict::property(), pdfobjects::utils::setSimpleValueInDict(), and gui::TreeItemDict::validChild().
| size_t pdfobjects::CDict::getPropertyCount | ( | ) | const [inline] |
Returns property count.
References value.
Referenced by _makeXpdfObject(), pdfobjects::CInlineImage::CInlineImage(), gui::QSDict::count(), pdfobjects::utils::dictFromXpdfObj(), pdfobjects::CStream::getPropertyCount(), and gui::TreeItemDict::haveChild().
| PropertyType pdfobjects::CDict::getPropertyType | ( | PropertyId | id | ) | const [inline] |
Returns property type of an item identified by name.
| id | Name of the property. |
| ObjInvalidPositionInComplex | When the id does not correctly identify an item. |
References getProperty().
Referenced by pdfobjects::CStream::getPropertyType().
| virtual void pdfobjects::CDict::getStringRepresentation | ( | std::string & | str | ) | const [virtual] |
Returns string representation of this object according to pdf specification.
| str | Output string that will hold the string representation of current object. |
Implements pdfobjects::IProperty.
Referenced by gui::QSDict::getText().
| virtual PropertyType pdfobjects::CDict::getType | ( | ) | const [inline, virtual] |
Return type of this property.
Implements pdfobjects::IProperty.
References type.
| void pdfobjects::CDict::init | ( | const CDict & | dict | ) |
Simple shallow copy constructor (does not copy pointers).
| dict | dictionary which will be copied |
References value.
| void pdfobjects::CDict::setIndiRef | ( | const IndiRef & | rf | ) | [virtual] |
Set ref to this object and its children.
| rf | New indirect reference number. |
Reimplemented from pdfobjects::IProperty.
References value.
| void pdfobjects::CDict::setPdf | ( | boost::weak_ptr< CPdf > | ) | [virtual] |
Set pdf to this object and its children.
| New pdf. |
Reimplemented from pdfobjects::IProperty.
References value.
Referenced by pdfobjects::CPdf::getTrailer().
| shared_ptr< IProperty > pdfobjects::CDict::setProperty | ( | PropertyId | id, | |
| IProperty & | ip | |||
| ) |
Sets property type of an item.
Firstly, the property that is passed as argument is cloned and the cloned object replaces object specified by id. If the item does not exist it is added.
| id | Name/Index of property | |
| ip | Value, for simple types (int,string,...) and for complex types IProperty* |
References _createContext(), _objectChanged(), _setMode(), addProperty(), pdfobjects::IProperty::canChange(), pdfobjects::IProperty::clone(), debug::DBG_DBG, pdfobjects::IProperty::getIndiRef(), pdfobjects::DictIdxComparator::getIProperty(), pdfobjects::IProperty::getPdf(), pdfobjects::hasValidPdf(), pdfobjects::hasValidRef(), kernelPrintDbg, and value.
Referenced by pdfobjects::CStream::setProperty().
friend class CStream [friend] |
const PropertyType pdfobjects::CDict::type = pDict [static] |
Type of this property object. This association allows us to get the PropertyType from object type.
Referenced by getType().
Value pdfobjects::CDict::value [private] |
Dictionary representation.
Referenced by pdfobjects::CStream::_getAllChildObjects(), _getAllChildObjects(), _makeXpdfObject(), CDict(), delProperty(), pdfobjects::CStream::doClone(), doClone(), forEach(), getAllPropertyNames(), getProperty(), getPropertyCount(), init(), setIndiRef(), setPdf(), and setProperty().