#include <carray.h>
Public Types | |
| typedef std::vector < boost::shared_ptr< IProperty > > | Value |
| typedef const std::string & | WriteType |
| typedef size_t | PropertyId |
| typedef observer::ComplexChangeContext < IProperty, PropertyId > | CArrayComplexObserverContext |
Public Member Functions | |
| CArray (boost::weak_ptr< CPdf > p, const Object &o, const IndiRef &rf) | |
| CArray (const Object &o) | |
| CArray () | |
| virtual PropertyType | getType () const |
| virtual void | getStringRepresentation (std::string &str) const |
| size_t | getPropertyCount () 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 IProperty &newIp) |
| boost::shared_ptr< IProperty > | addProperty (PropertyId position, const IProperty &newIp) |
| void | delProperty (PropertyId id) |
| ~CArray () | |
| 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 = pArray |
Protected Member Functions | |
| virtual IProperty * | doClone () const |
| virtual CArray * | _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 |
Class representing array object from pdf specification v1.5.
We do not want to use xpdf array 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, array is a container of values. Value position identifies an item. You can rely on a value position. 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 CDict 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::CArray::CArrayComplexObserverContext |
| typedef size_t pdfobjects::CArray::PropertyId |
| typedef std::vector<boost::shared_ptr<IProperty> > pdfobjects::CArray::Value |
| typedef const std::string& pdfobjects::CArray::WriteType |
Constructor.
| p | Pointer to pdf object. | |
| o | Xpdf object. | |
| rf | Indirect id and gen id. |
References value.
| pdfobjects::CArray::CArray | ( | const Object & | o | ) |
| pdfobjects::CArray::CArray | ( | ) | [inline] |
Public constructor. This object will not be associated with a pdf.
| pdfobjects::CArray::~CArray | ( | ) | [inline] |
Destructor
| ObserverContext* pdfobjects::CArray::_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 addProperty(), delProperty(), and setProperty().
| void pdfobjects::CArray::_getAllChildObjects | ( | Storage & | store | ) | const [inline] |
Return all child objects.
| store | Output container of all child objects. |
References value.
| Object * pdfobjects::CArray::_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 CArray* pdfobjects::CArray::_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::CArray::_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. |
References pdfobjects::IProperty::dispatchChange(), pdfobjects::hasValidPdf(), pdfobjects::hasValidRef(), and observer::ObserverHandler< T >::notifyObservers().
Referenced by addProperty(), delProperty(), and setProperty().
| void pdfobjects::CArray::_setMode | ( | boost::shared_ptr< IProperty > | ip, | |
| PropertyId | id | |||
| ) | const [protected] |
Set mode of a property.
| ip | IProperty which mode will be set. | |
| id | Position of the property. |
References pdfobjects::IProperty::getMode().
Referenced by addProperty(), getProperty(), and setProperty().
| shared_ptr< IProperty > pdfobjects::CArray::addProperty | ( | PropertyId | position, | |
| const IProperty & | newIp | |||
| ) |
Add property to array.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.REMARK: It is automatically associated with the pdf where the object is beeing added.
| newIp | New property. |
| OutOfRange | Thrown when property not found. |
References _createContext(), _objectChanged(), _setMode(), pdfobjects::IProperty::canChange(), pdfobjects::IProperty::clone(), pdfobjects::IProperty::getIndiRef(), pdfobjects::IProperty::getPdf(), pdfobjects::hasValidPdf(), pdfobjects::hasValidRef(), and value.
Add property to array.
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.
REMARK: It is automatically associated with the pdf where the object is beeing added.
| newIp | New property. |
| OutOfRange | Thrown when property not found. |
References value.
Referenced by pdfobjects::CPageDisplay::setMediabox(), and setProperty().
| void pdfobjects::CArray::delProperty | ( | PropertyId | id | ) |
Remove property from array.
| id | Position of property |
| ElementNotFoundException | Thrown when object is not found. |
References _createContext(), _objectChanged(), pdfobjects::IProperty::canChange(), pdfobjects::hasValidPdf(), pdfobjects::hasValidRef(), and value.
| IProperty * pdfobjects::CArray::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::CArray::forEach | ( | Fctor & | fctor | ) | [inline] |
Apply functor operator() on each element. The operator() will get std::pair<int, shared_ptr<IProperty>> as parameter. First item identifies the property.
| fctor | Functor that will do the work. |
References value.
| shared_ptr< IProperty > pdfobjects::CArray::getProperty | ( | PropertyId | id | ) | const |
Returns value of property identified by its position.
| id | Variable identifying position of the property. |
References _setMode(), and value.
Referenced by gui::TreeItemArray::createChild(), gui::TreeItemArray::getChildNames(), gui::TreeItemArray::getChildType(), getPropertyType(), gui::QSArray::property(), pdfobjects::utils::setSimpleValueInArray(), and gui::TreeItemArray::validChild().
| size_t pdfobjects::CArray::getPropertyCount | ( | ) | const [inline] |
Returns property count.
References value.
Referenced by _makeXpdfObject(), gui::QSArray::count(), gui::TreeItemArray::getChildNames(), and gui::TreeItemArray::haveChild().
| PropertyType pdfobjects::CArray::getPropertyType | ( | PropertyId | id | ) | const [inline] |
Returns property type of an item identified by position.
| id | Position of the property. |
| ObjInvalidPositionInComplex | When the id does not correctly identify an item. |
References getProperty().
| virtual void pdfobjects::CArray::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::QSArray::getText().
| virtual PropertyType pdfobjects::CArray::getType | ( | ) | const [inline, virtual] |
Return type of this property.
Implements pdfobjects::IProperty.
References type.
| void pdfobjects::CArray::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::CArray::setPdf | ( | boost::weak_ptr< CPdf > | ) | [virtual] |
Set pdf to this object and its children.
| New pdf. |
Reimplemented from pdfobjects::IProperty.
References value.
| shared_ptr< IProperty > pdfobjects::CArray::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 | Position 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(), pdfobjects::IProperty::getIndiRef(), pdfobjects::IProperty::getPdf(), pdfobjects::hasValidPdf(), pdfobjects::hasValidRef(), and value.
const PropertyType pdfobjects::CArray::type = pArray [static] |
Type of this property object. This association allows us to get the PropertyType from object type.
Referenced by getType().
Value pdfobjects::CArray::value [private] |
Array representation.
Referenced by _getAllChildObjects(), _makeXpdfObject(), addProperty(), CArray(), delProperty(), doClone(), forEach(), getProperty(), getPropertyCount(), setIndiRef(), setPdf(), and setProperty().