pdfedit  0.4.5
About: PDFedit is a free and open source library for manipulating PDF documents.
  Fossies Dox: pdfedit-0.4.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pdfobjects::CStream Class Reference

#include <cstream.h>

Inheritance diagram for pdfobjects::CStream:
Collaboration diagram for pdfobjects::CStream:

Public Types

typedef char StreamChar
 
typedef std::vector< StreamCharBuffer
 
typedef
observer::BasicChangeContext
< IProperty
BasicObserverContext
 

Public Member Functions

 CStream (boost::weak_ptr< CPdf > p, const Object &o, const IndiRef &rf)
 
 CStream (const Object &o)
 
 CStream (const CDict &dict)
 
 CStream (bool makeReqEntries=true)
 
size_t getPropertyCount () const
 
template<typename Container >
void getAllPropertyNames (Container &container) const
 
boost::shared_ptr< IPropertygetProperty (PropertyId id) const
 
bool containsProperty (PropertyId id) const
 
PropertyType getPropertyType (PropertyId id) const
 
boost::shared_ptr< IPropertysetProperty (PropertyId id, IProperty &ip)
 
boost::shared_ptr< IPropertyaddProperty (PropertyId id, const IProperty &newIp)
 
void delProperty (PropertyId id)
 
virtual PropertyType getType () const
 
virtual void getStringRepresentation (std::string &str) const
 
virtual void getDecodedStringRepresentation (std::string &str) const
 
const BuffergetBuffer () const
 
template<typename Container >
void getFilters (Container &container) const
 
virtual void setPdf (boost::weak_ptr< CPdf > pdf)
 
virtual void setIndiRef (const IndiRef &rf)
 
void setRawBuffer (const Buffer &buf)
 
template<typename Container >
void setBuffer (const Container &buf)
 
 ~CStream ()
 
virtual Object_makeXpdfObject () const
 
template<typename Storage >
void _getAllChildObjects (Storage &store) const
 
- Public Member Functions inherited from pdfobjects::IProperty
boost::shared_ptr< IPropertyclone () const
 
boost::weak_ptr< CPdfgetPdf () const
 
void canChange () const
 
const IndiRefgetIndiRef () const
 
void setIndiRef (IndiRef::ObjNum n, IndiRef::GenNum g)
 
PropertyMode getMode () const
 
void setMode (PropertyMode md)
 
void dispatchChange () const
 
void lockChange ()
 
void unlockChange ()
 
virtual ~IProperty ()
 
- Public Member Functions inherited from observer::ObserverHandler< T >
virtual ~ObserverHandler ()
 
virtual void registerObserver (const Observer &observer)
 
virtual void unregisterObserver (const Observer &observer)
 
virtual void notifyObservers (boost::shared_ptr< T > newValue, boost::shared_ptr< const ObserverContext > context)
 

Static Public Attributes

static const PropertyType type = pStream
 

Protected Member Functions

virtual IPropertydoClone () const
 
virtual CStream_newInstance () const
 
void createReqEntries ()
 
- Protected Member Functions inherited from pdfobjects::IProperty
 IProperty (boost::weak_ptr< CPdf > _pdf=boost::shared_ptr< CPdf >())
 
 IProperty (boost::weak_ptr< CPdf > _pdf, const IndiRef &rf)
 
- Protected Member Functions inherited from observer::ObserverHandler< T >
void dumpObservers () const
 

Protected Attributes

CDict dictionary
 
Buffer buffer
 
::Parserparser
 
mutable::Object curObj
 

Friends

template<typename T >
class CStreamsXpdfReader
 

Additional Inherited Members

- Static Public Member Functions inherited from pdfobjects::IProperty
template<typename T >
static boost::shared_ptr< T > getSmartCObjectPtr (const boost::shared_ptr< IProperty > &ptr)
 

Detailed Description

Class representing stream object from pdf specification v1.5.

We do not want to use xpdf stream because it is a real mess and it is really not suitable for editing. We use xpdf object just for initializing and for reading objects.

According to pdf specification, stream is a dictionary and a stream of characters of specified length. Dictionary is used to describe the stream (its length, filters, parameters, etc..)

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.

Definition at line 63 of file cstream.h.

Member Typedef Documentation

Definition at line 72 of file cstream.h.

Definition at line 71 of file cstream.h.

Constructor & Destructor Documentation

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

Constructor. Stream will be associated with specified pdf.

Parameters
pPointer to pdf object.
oXpdf object.
rfIndirect id and gen id.

Referenced by _newInstance().

pdfobjects::CStream::CStream ( const Object o)

Constructor. Stream will not be associated with a pdf.

Parameters
oXpdf object.
pdfobjects::CStream::CStream ( const CDict dict)

Constructor. Stream will not be associated with a pdf.

Parameters
dictreference to a dictionary which will be associated with this stream
bufferreference to buffer associtated with this stream

Definition at line 101 of file cstream.cc.

References debug::DBG_DBG, and kernelPrintDbg.

pdfobjects::CStream::CStream ( bool  makeReqEntries = true)

Public constructor. This object will not be associated with a pdf. It adds all required properties to object dictionary in compliance with the pdf specification if needed.

Parameters
makeReqEntriesIf true required entries are added to the stream dictionary.

Definition at line 111 of file cstream.cc.

References createReqEntries(), debug::DBG_DBG, and kernelPrintDbg.

pdfobjects::CStream::~CStream ( )

Destructor.

Definition at line 523 of file cstream.cc.

References curObj, curObj, curObj, debug::DBG_DBG, xpdf::freeXpdfObject(), kernelPrintDbg, NULL, NULL, NULL, parser, parser, and parser.

Member Function Documentation

template<typename Storage >
void pdfobjects::CStream::_getAllChildObjects ( Storage &  store) const
inline

Return all child objects.

Parameters
storeContainer of objects.

Definition at line 476 of file cstream.h.

References dictionary, and dictionary.

Object * pdfobjects::CStream::_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 representin this object.
Exceptions
ObjBadValueEThrown when xpdf can't parse the string representation of this object correctly.

Implements pdfobjects::IProperty.

Reimplemented in pdfobjects::CInlineImage.

Definition at line 258 of file cstream.cc.

References buffer, buffer, debug::DBG_DBG, debug::DBG_WARN, Object::getType(), kernelPrintDbg, kernelPrintDbg, NULL, objStream, and pdfobjects::utils::xpdfStreamObjFromBuffer().

Referenced by getDecodedStringRepresentation().

virtual CStream* pdfobjects::CStream::_newInstance ( ) const
inlineprotectedvirtual

Return new instance.

Reimplemented in pdfobjects::CInlineImage.

Definition at line 155 of file cstream.h.

References CStream().

Referenced by doClone().

boost::shared_ptr<IProperty> pdfobjects::CStream::addProperty ( PropertyId  id,
const IProperty newIp 
)
inline

Delagate this operation to underlying dictionary.

See Also
CDict

Definition at line 191 of file cstream.h.

References dictionary.

bool pdfobjects::CStream::containsProperty ( PropertyId  id) const
inline

Delagate this operation to underlying dictionary.

See Also
CDict

Definition at line 179 of file cstream.h.

References dictionary.

Referenced by gui::QSStream::exist().

void pdfobjects::CStream::createReqEntries ( )
protected

Create required entries.

Definition at line 123 of file cstream.cc.

Referenced by CStream().

void pdfobjects::CStream::delProperty ( PropertyId  id)
inline

Delagate this operation to underlying dictionary.

See Also
CDict

Definition at line 195 of file cstream.h.

References dictionary.

IProperty * pdfobjects::CStream::doClone ( ) const
protectedvirtual

Implementation of clone method.

Returns
Deep copy of this object.

Implements pdfobjects::IProperty.

Definition at line 139 of file cstream.cc.

References _newInstance(), buffer, buffer, buffer, pdfobjects::IProperty::clone(), debug::DBG_DBG, dictionary, kernelPrintDbg, NULL, and parser.

template<typename Container >
void pdfobjects::CStream::getAllPropertyNames ( Container &  container) const
inline

Delagate this operation to underlying dictionary.

See Also
CDict

Definition at line 171 of file cstream.h.

References dictionary.

Referenced by gui::TreeItemCStream::getChildNames(), gui::QSStream::propertyNames(), and gui::PropertyEditor::setObject().

const Buffer& pdfobjects::CStream::getBuffer ( ) const
inline

Get encoded buffer. Can contain non printable characters.

Returns
Buffer.

Definition at line 230 of file cstream.h.

References buffer.

Referenced by gui::QSStream::getBuffer(), gui::QSStream::getBufferString(), and gui::QSStream::saveBuffer().

void pdfobjects::CStream::getDecodedStringRepresentation ( std::string &  str) const
virtual

Returns decoded string representation of this object.

Parameters
strOutput string representation.

Definition at line 301 of file cstream.cc.

References _makeXpdfObject(), debug::DBG_DBG, xpdf::freeXpdfObject(), pdfobjects::utils::getStringFromXpdfStream(), kernelPrintDbg, and NULL.

template<typename Container >
void pdfobjects::CStream::getFilters ( Container &  container) const
inline

Get filters.

Parameters
containerContainer of filter names.

Definition at line 238 of file cstream.h.

References debug::DBG_DBG, debug::DBG_DBG, debug::DBG_DBG, dictionary, pdfobjects::isArray(), pdfobjects::isName(), kernelPrintDbg, kernelPrintDbg, kernelPrintDbg, name, and name.

Referenced by setBuffer().

boost::shared_ptr<IProperty> pdfobjects::CStream::getProperty ( PropertyId  id) const
inline
size_t pdfobjects::CStream::getPropertyCount ( ) const
inline

Delagate this operation to underlying dictionary.

See Also
CDict

Definition at line 166 of file cstream.h.

References dictionary.

Referenced by gui::QSStream::count(), and gui::TreeItemCStream::haveChild().

PropertyType pdfobjects::CStream::getPropertyType ( PropertyId  id) const
inline

Delagate this operation to underlying dictionary.

See Also
CDict

Definition at line 183 of file cstream.h.

References dictionary.

void pdfobjects::CStream::getStringRepresentation ( std::string &  str) const
virtual

Returns string representation of this object.

Parameters
strOutput string representation.

Implements pdfobjects::IProperty.

Reimplemented in pdfobjects::CInlineImage.

Definition at line 281 of file cstream.cc.

References buffer, buffer, debug::DBG_DBG, kernelPrintDbg, and pdfobjects::utils::streamToString().

virtual PropertyType pdfobjects::CStream::getType ( ) const
inlinevirtual

Returns type of object.

Returns
Type of this class.

Implements pdfobjects::IProperty.

Definition at line 209 of file cstream.h.

References pdfobjects::pStream.

template<typename Container >
void pdfobjects::CStream::setBuffer ( const Container &  buf)
inline

Set decoded (raw) buffer. Drops all filters if present.

Parameters
bufNew buffer (can be string or Buffer types).

Definition at line 316 of file cstream.h.

References buffer, buffer, buffer, pdfobjects::IProperty::canChange(), debug::DBG_DBG, dictionary, getFilters(), kernelPrintDbg, kernelPrintDbg, pdfobjects::utils::makeStreamPdfValid(), NULL, NULL, parser, and parser.

void pdfobjects::CStream::setIndiRef ( const IndiRef rf)
virtual

Set ref to itself and also to all children.

Parameters
rfNew indirect reference numbers.

Reimplemented from pdfobjects::IProperty.

Definition at line 185 of file cstream.cc.

References pdfobjects::IProperty::setIndiRef().

Referenced by pdfobjects::CInlineImage::CInlineImage().

void pdfobjects::CStream::setPdf ( boost::weak_ptr< CPdf pdf)
virtual

Set pdf to itself and also to all children.

Parameters
pdfNew pdf.

Reimplemented from pdfobjects::IProperty.

Definition at line 174 of file cstream.cc.

References pdfobjects::IProperty::setPdf().

Referenced by pdfobjects::CInlineImage::CInlineImage().

boost::shared_ptr<IProperty> pdfobjects::CStream::setProperty ( PropertyId  id,
IProperty ip 
)
inline

Delagate this operation to underlying dictionary.

See Also
CDict

Definition at line 187 of file cstream.h.

References dictionary.

void pdfobjects::CStream::setRawBuffer ( const Buffer buf)

Set encoded buffer.

Parameters
bufNew buffer.

Definition at line 197 of file cstream.cc.

References buffer, buffer, buffer, pdfobjects::IProperty::canChange(), NULL, NULL, parser, and parser.

Friends And Related Function Documentation

template<typename T >
friend class CStreamsXpdfReader
friend

Definition at line 69 of file cstream.h.

Member Data Documentation

mutable ::Object pdfobjects::CStream::curObj
protected

Current object in an opened stream.

Definition at line 97 of file cstream.h.

Referenced by ~CStream(), ~CStream(), and ~CStream().

::Parser* pdfobjects::CStream::parser
protected

Xpdf parser.

Definition at line 95 of file cstream.h.

Referenced by doClone(), setBuffer(), setBuffer(), setRawBuffer(), setRawBuffer(), ~CStream(), ~CStream(), and ~CStream().

const PropertyType pdfobjects::CStream::type = pStream
static

Type of this property object. This association allows us to get the PropertyType from object type.

Definition at line 79 of file cstream.h.


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