pdfobjects::CArray Class Reference

#include <carray.h>

Inheritance diagram for pdfobjects::CArray:
pdfobjects::IProperty observer::ObserverHandler< T >

List of all members.

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< IPropertygetProperty (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< IPropertysetProperty (PropertyId id, IProperty &ip)
boost::shared_ptr< IPropertyaddProperty (const IProperty &newIp)
boost::shared_ptr< IPropertyaddProperty (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 IPropertydoClone () 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

Detailed Description

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)

See also:
CObjectSimple, CDict, CStream

Member Typedef Documentation

typedef std::vector<boost::shared_ptr<IProperty> > pdfobjects::CArray::Value
typedef const std::string& pdfobjects::CArray::WriteType

Constructor & Destructor Documentation

pdfobjects::CArray::CArray ( boost::weak_ptr< CPdf p,
const Object &  o,
const IndiRef rf 
)

Constructor.

Parameters:
p Pointer to pdf object.
o Xpdf object.
rf Indirect id and gen id.

References value.

pdfobjects::CArray::CArray ( const Object &  o  ) 

Constructor.

Parameters:
o Xpdf object.

References value.

pdfobjects::CArray::CArray (  )  [inline]

Public constructor. This object will not be associated with a pdf.

pdfobjects::CArray::~CArray (  )  [inline]

Destructor


Member Function Documentation

ObserverContext* pdfobjects::CArray::_createContext ( boost::shared_ptr< IProperty changedIp,
PropertyId  id 
) [private]

Create context of a change.

REMARK: Be carefull. Deallocate the object.

Parameters:
changedIp Pointer to old value.
id Id identifies changed property.
Returns:
Context in which a change occured.

Referenced by addProperty(), delProperty(), and setProperty().

template<typename Storage >
void pdfobjects::CArray::_getAllChildObjects ( Storage &  store  )  const [inline]

Return all child objects.

Parameters:
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.

Returns:
Xpdf object representing this object.
Exceptions:
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.

Returns:
New complex object.

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.

Parameters:
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.

Parameters:
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.

Parameters:
newIp New property.
Returns:
Pointer to the new property.
Exceptions:
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.

shared_ptr< IProperty > pdfobjects::CArray::addProperty ( 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.

Parameters:
newIp New property.
Returns:
Pointer to the new property.
Exceptions:
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.

Parameters:
id Position of property
Exceptions:
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.

Returns:
Deep copy of this object.

Implements pdfobjects::IProperty.

References _newInstance(), and value.

template<typename Fctor >
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.

Parameters:
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.

Parameters:
id Variable identifying position of the property.
Returns:
Output variable where the value will be stored.

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.

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.

Parameters:
id Position of the property.
Returns:
Property type.
Exceptions:
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.

Parameters:
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.

Returns:
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.

Parameters:
rf New indirect reference number.

Reimplemented from pdfobjects::IProperty.

References value.

void pdfobjects::CArray::setPdf ( boost::weak_ptr< CPdf pdf  )  [virtual]

Set pdf to this object and its children.

Parameters:
pdf 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.

Parameters:
id Position of property
ip Value, for simple types (int,string,...) and for complex types IProperty*
Returns:
Pointer to the new property.

References _createContext(), _objectChanged(), _setMode(), addProperty(), pdfobjects::IProperty::canChange(), pdfobjects::IProperty::clone(), pdfobjects::IProperty::getIndiRef(), pdfobjects::IProperty::getPdf(), pdfobjects::hasValidPdf(), pdfobjects::hasValidRef(), and value.


Member Data Documentation

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().


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