#include <cstream.h>
Public Types | |
| typedef char | StreamChar |
| typedef std::vector< StreamChar > | Buffer |
| 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< IProperty > | getProperty (PropertyId id) const |
| bool | containsProperty (PropertyId id) const |
| PropertyType | getPropertyType (PropertyId id) const |
| boost::shared_ptr< IProperty > | setProperty (PropertyId id, IProperty &ip) |
| boost::shared_ptr< IProperty > | addProperty (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 Buffer & | getBuffer () 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 |
Static Public Attributes | |
| static const PropertyType | type = pStream |
Protected Member Functions | |
| virtual IProperty * | doClone () const |
| virtual CStream * | _newInstance () const |
| void | createReqEntries () |
Protected Attributes | |
| CDict | dictionary |
| Buffer | buffer |
| ::Parser * | parser |
| mutable::Object | curObj |
Private Types | |
| typedef std::string | PropertyId |
Private Member Functions | |
| void | open () |
| void | close () |
| void | getXpdfObject (::Object &obj) |
| ::Stream * | getXpdfStream () |
| bool | eof () const |
| void | _objectChanged (boost::shared_ptr< const ObserverContext > context) |
| size_t | getLength () const |
| void | setLength (size_t len) |
| ObserverContext * | _createContext () const |
Private Attributes | |
| ::Object * | tmpObj |
Friends | |
| class | CStreamsXpdfReader |
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.
| typedef std::vector<StreamChar> pdfobjects::CStream::Buffer |
typedef std::string pdfobjects::CStream::PropertyId [private] |
| typedef char pdfobjects::CStream::StreamChar |
Constructor. Stream will be associated with specified pdf.
| p | Pointer to pdf object. | |
| o | Xpdf object. | |
| rf | Indirect id and gen id. |
Referenced by _newInstance().
| pdfobjects::CStream::CStream | ( | const Object & | o | ) |
Constructor. Stream will not be associated with a pdf.
| o | Xpdf object. |
| pdfobjects::CStream::CStream | ( | const CDict & | dict | ) |
Constructor. Stream will not be associated with a pdf.
| dict | reference to a dictionary which will be associated with this stream | |
| buffer | reference to buffer associtated with this stream |
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.
| makeReqEntries | If true required entries are added to the stream dictionary. |
References createReqEntries(), debug::DBG_DBG, and kernelPrintDbg.
| pdfobjects::CStream::~CStream | ( | ) |
Destructor.
References curObj, debug::DBG_DBG, xpdf::freeXpdfObject(), kernelPrintDbg, parser, and tmpObj.
| IProperty::ObserverContext * pdfobjects::CStream::_createContext | ( | ) | const [private] |
Create context of a change.
REMARK: Be carefull. Deallocate the object.
Referenced by setBuffer(), and setRawBuffer().
| void pdfobjects::CStream::_getAllChildObjects | ( | Storage & | store | ) | const [inline] |
Return all child objects.
| store | Container of objects. |
References dictionary, and pdfobjects::CDict::value.
| 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.
| ObjBadValueE | Thrown when xpdf can't parse the string representation of this object correctly. |
Implements pdfobjects::IProperty.
Reimplemented in pdfobjects::CInlineImage.
References buffer, debug::DBG_DBG, debug::DBG_WARN, getLength(), kernelPrintDbg, and pdfobjects::utils::xpdfStreamObjFromBuffer().
Referenced by open().
| virtual CStream* pdfobjects::CStream::_newInstance | ( | ) | const [inline, protected, virtual] |
Return new instance.
Reimplemented in pdfobjects::CInlineImage.
References CStream().
Referenced by doClone().
| void pdfobjects::CStream::_objectChanged | ( | boost::shared_ptr< const ObserverContext > | context | ) | [private] |
Indicate that the object has changed. Notifies all observers associated with this property about the change.
| context | Context in which a change occured. |
Referenced by setBuffer(), and setRawBuffer().
| boost::shared_ptr<IProperty> pdfobjects::CStream::addProperty | ( | PropertyId | id, | |
| const IProperty & | newIp | |||
| ) | [inline] |
Delagate this operation to underlying dictionary.
References pdfobjects::CDict::addProperty(), and dictionary.
| void pdfobjects::CStream::close | ( | ) | [private] |
Close parser.
References curObj, debug::DBG_DBG, xpdf::freeXpdfObject(), kernelPrintDbg, parser, and tmpObj.
| bool pdfobjects::CStream::containsProperty | ( | PropertyId | id | ) | const [inline] |
Delagate this operation to underlying dictionary.
References pdfobjects::CDict::containsProperty(), and dictionary.
Referenced by gui::QSStream::exist().
| void pdfobjects::CStream::createReqEntries | ( | ) | [protected] |
Create required entries.
Referenced by CStream().
| void pdfobjects::CStream::delProperty | ( | PropertyId | id | ) | [inline] |
Delagate this operation to underlying dictionary.
References pdfobjects::CDict::delProperty(), and dictionary.
| IProperty * pdfobjects::CStream::doClone | ( | ) | const [protected, virtual] |
Implementation of clone method.
Implements pdfobjects::IProperty.
References _newInstance(), buffer, pdfobjects::IProperty::clone(), debug::DBG_DBG, dictionary, kernelPrintDbg, parser, and pdfobjects::CDict::value.
| bool pdfobjects::CStream::eof | ( | ) | const [private] |
Is the last object end of stream.
This is not very common behaviour, but we can not use caching
References curObj, and parser.
Referenced by getXpdfObject().
| void pdfobjects::CStream::getAllPropertyNames | ( | Container & | container | ) | const [inline] |
Delagate this operation to underlying dictionary.
References dictionary, and pdfobjects::CDict::getAllPropertyNames().
Referenced by gui::TreeItemCStream::getChildNames(), and gui::QSStream::propertyNames().
| const Buffer& pdfobjects::CStream::getBuffer | ( | ) | const [inline] |
Get encoded buffer. Can contain non printable characters.
References buffer.
Referenced by gui::QSStream::getBuffer(), gui::QSStream::getBufferString(), and gui::QSStream::saveBuffer().
| virtual void pdfobjects::CStream::getDecodedStringRepresentation | ( | std::string & | str | ) | const [virtual] |
Returns decoded string representation of this object.
| str | Output string representation. |
| void pdfobjects::CStream::getFilters | ( | Container & | container | ) | const [inline] |
Get filters.
| container | Container of filter names. |
References debug::DBG_DBG, dictionary, pdfobjects::CDict::getProperty(), pdfobjects::isArray(), pdfobjects::isName(), and kernelPrintDbg.
Referenced by setBuffer().
| size_t pdfobjects::CStream::getLength | ( | ) | const [private] |
Get length.
References pdfobjects::utils::getReferencedObject(), and pdfobjects::isInt().
Referenced by _makeXpdfObject().
| boost::shared_ptr<IProperty> pdfobjects::CStream::getProperty | ( | PropertyId | id | ) | const [inline] |
Delagate this operation to underlying dictionary.
References dictionary, and pdfobjects::CDict::getProperty().
Referenced by gui::TreeItemCStream::createChild(), gui::TreeItemCStream::getChildNames(), gui::TreeItemCStream::getChildType(), gui::QSStream::property(), and gui::TreeItemCStream::validChild().
| size_t pdfobjects::CStream::getPropertyCount | ( | ) | const [inline] |
Delagate this operation to underlying dictionary.
References dictionary, and pdfobjects::CDict::getPropertyCount().
Referenced by gui::QSStream::count(), and gui::TreeItemCStream::haveChild().
| PropertyType pdfobjects::CStream::getPropertyType | ( | PropertyId | id | ) | const [inline] |
Delagate this operation to underlying dictionary.
References dictionary, and pdfobjects::CDict::getPropertyType().
| virtual void pdfobjects::CStream::getStringRepresentation | ( | std::string & | str | ) | const [virtual] |
Returns string representation of this object.
| str | Output string representation. |
Implements pdfobjects::IProperty.
Reimplemented in pdfobjects::CInlineImage.
| virtual PropertyType pdfobjects::CStream::getType | ( | ) | const [inline, virtual] |
Returns type of object.
Implements pdfobjects::IProperty.
References pdfobjects::pStream.
| void pdfobjects::CStream::getXpdfObject | ( | ::Object & | obj | ) | [private] |
Get next xpdf object from the stream.
REMARK: We can not do any buffering (caching) of xpdf objects, because xpdf already does caching and it will NOT work correctly with inline images. We would buffer WRONG data.
| obj | Next xpdf object. |
References curObj, debug::DBG_ERR, eof(), kernelPrintDbg, and parser.
| Stream * pdfobjects::CStream::getXpdfStream | ( | ) | [private] |
Get xpdf stream. Be carefull this is not a copy.
References debug::DBG_DBG, kernelPrintDbg, and parser.
| void pdfobjects::CStream::open | ( | ) | [private] |
Initialize parsing mechanism.
REMARK: if CObject is not in a pdf, we MUST be sure that it does not use indirect objects.
References _makeXpdfObject(), curObj, debug::DBG_DBG, xpdf::freeXpdfObject(), pdfobjects::IProperty::getPdf(), kernelPrintDbg, parser, and tmpObj.
| void pdfobjects::CStream::setBuffer | ( | const Container & | buf | ) | [inline] |
Set decoded (raw) buffer. Drops all filters if present.
| buf | New buffer (can be string or Buffer types). |
References _createContext(), _objectChanged(), buffer, pdfobjects::IProperty::canChange(), debug::DBG_DBG, pdfobjects::CDict::delProperty(), dictionary, getFilters(), kernelPrintDbg, pdfobjects::utils::makeStreamPdfValid(), parser, and setLength().
| void pdfobjects::CStream::setIndiRef | ( | const IndiRef & | rf | ) | [virtual] |
Set ref to itself and also to all children.
| rf | New indirect reference numbers. |
Reimplemented from pdfobjects::IProperty.
Referenced by pdfobjects::CInlineImage::CInlineImage().
| void pdfobjects::CStream::setLength | ( | size_t | len | ) | [private] |
| void pdfobjects::CStream::setPdf | ( | boost::weak_ptr< CPdf > | ) | [virtual] |
Set pdf to itself and also to all children.
| New pdf. |
Reimplemented from pdfobjects::IProperty.
Referenced by pdfobjects::CInlineImage::CInlineImage().
| boost::shared_ptr<IProperty> pdfobjects::CStream::setProperty | ( | PropertyId | id, | |
| IProperty & | ip | |||
| ) | [inline] |
Delagate this operation to underlying dictionary.
References dictionary, and pdfobjects::CDict::setProperty().
| void pdfobjects::CStream::setRawBuffer | ( | const Buffer & | buf | ) |
Set encoded buffer.
| buf | New buffer. |
References _createContext(), _objectChanged(), buffer, pdfobjects::IProperty::canChange(), parser, and setLength().
friend class CStreamsXpdfReader [friend] |
Buffer pdfobjects::CStream::buffer [protected] |
Stream buffer.
Referenced by _makeXpdfObject(), pdfobjects::CInlineImage::CInlineImage(), doClone(), getBuffer(), pdfobjects::CInlineImage::getStringRepresentation(), setBuffer(), and setRawBuffer().
mutable ::Object pdfobjects::CStream::curObj [protected] |
Current object in an opened stream.
Referenced by close(), eof(), getXpdfObject(), open(), and ~CStream().
CDict pdfobjects::CStream::dictionary [protected] |
Stream dictionary.
Referenced by _getAllChildObjects(), addProperty(), pdfobjects::CInlineImage::CInlineImage(), containsProperty(), delProperty(), doClone(), getAllPropertyNames(), getFilters(), getProperty(), getPropertyCount(), getPropertyType(), pdfobjects::CInlineImage::getStringRepresentation(), setBuffer(), and setProperty().
::Parser* pdfobjects::CStream::parser [protected] |
Xpdf parser.
Referenced by close(), doClone(), eof(), getXpdfObject(), getXpdfStream(), open(), setBuffer(), setRawBuffer(), and ~CStream().
::Object* pdfobjects::CStream::tmpObj [private] |
Helper object, because xpdf stream does NOT automatically deallocated specified object.
Referenced by close(), open(), 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.