pdfobjects::CPageContents Class Reference

#include <cpagecontents.h>

Inheritance diagram for pdfobjects::CPageContents:
pdfobjects::ICPageModule

List of all members.

Classes

struct  ContentsObserverFreeSection
class  ContentsWatchDog
struct  Tm

Public Member Functions

 CPageContents (CPage *page)
 ~CPageContents ()
virtual void reset ()
void reparse ()
template<typename Container >
void addToFront (const Container &cont)
template<typename Container >
void addToBack (const Container &cont)
void remove (size_t csnum)
template<typename RectangleContainer >
size_t findText (std::string text, RectangleContainer &recs, const TextSearchParams &params=TextSearchParams()) const
void replaceText (const std::string &what, const std::string &with)
void addText (const std::string &what, const libs::Point &where, const std::string &font_id)
void addInlineImage (const CStream::Buffer &what, const libs::Point &image_size, const libs::Point &where)
template<typename WordEngine , typename LineEngine , typename ColumnEngine >
void convert (textoutput::OutputBuilder &out)
template<typename OpContainer , typename PositionComparator >
void getObjectsAtPosition (OpContainer &opContainer, PositionComparator cmp)
boost::shared_ptr< CContentStreamgetContentStream (CContentStream *cc)
boost::shared_ptr< CContentStreamgetContentStream (size_t pos)
template<typename Container >
void getContentStreams (Container &container)
void getText (std::string &text, const std::string *encoding=NULL, const libs::Rectangle *rc=NULL) const
void moveAbove (boost::shared_ptr< const CContentStream > ct)
void moveAbove (size_t pos)
void moveBelow (boost::shared_ptr< const CContentStream > ct)
void moveBelow (size_t pos)
template<typename Cont >
void setContents (shared_ptr< CDict > dict, const Cont &cont)

Static Public Member Functions

template<typename Cont >
static void setContents (boost::shared_ptr< CDict > dict, const Cont &cont)

Private Types

typedef std::vector
< boost::shared_ptr
< CContentStream > > 
CCs

Private Member Functions

void toFront (CRef &ref)
void toBack (CRef &ref)
void remove (boost::shared_ptr< const CContentStream > cs)
void remove (const IndiRef &rf)
bool parse ()
void init ()
void change (bool invalid=false)
void _xpdf_display_params (boost::shared_ptr< GfxResources > &res, boost::shared_ptr< GfxState > &state)
size_t _page_pos () const
void reg_observer (boost::shared_ptr< IProperty > ip=boost::shared_ptr< IProperty >()) const
void unreg_observer (boost::shared_ptr< IProperty > ip=boost::shared_ptr< IProperty >()) const

Private Attributes

CCs _ccs
CPage_page
boost::shared_ptr< CDict_dict
boost::shared_ptr
< ContentsWatchDog
_wd
Tm _likely_tm

Detailed Description

Class representing the Contents entry in a page. Provides convinient access and modify operations on "Contents" entry of a page dictionary.


Member Typedef Documentation

typedef std::vector<boost::shared_ptr<CContentStream> > pdfobjects::CPageContents::CCs [private]

Constructor & Destructor Documentation

pdfobjects::CPageContents::CPageContents ( CPage page  ) 
pdfobjects::CPageContents::~CPageContents (  ) 

References reset().


Member Function Documentation

size_t pdfobjects::CPageContents::_page_pos (  )  const [private]

Get xpdf display params.

References _page, and pdfobjects::CPage::getPagePosition().

void pdfobjects::CPageContents::_xpdf_display_params ( boost::shared_ptr< GfxResources > &  res,
boost::shared_ptr< GfxState > &  state 
) [private]

Get xpdf display params.

References _page, and pdfobjects::CPage::display().

Referenced by addToBack(), addToFront(), parse(), and reparse().

void pdfobjects::CPageContents::addInlineImage ( const CStream::Buffer what,
const libs::Point &  image_size,
const libs::Point &  where 
)
void pdfobjects::CPageContents::addText ( const std::string &  what,
const libs::Point &  where,
const std::string &  font_id 
)
template<typename Container >
void pdfobjects::CPageContents::addToBack ( const Container &  cont  )  [inline]

Add new content stream to the back. This function adds new entry in the "Contents" property of a page. The container of provided operators must form a valid contentstream. This function should be used when supplied operators should be handled at the end e.g. should be drawn at the end which means they will appear "above" other objects.

This function can be used to separate our changes from original content stream. Indicats that the page changed.

Parameters:
cont Container of operators to add.

References _ccs, _dict, _xpdf_display_params(), change(), pdfobjects::hasValidPdf(), pdfobjects::hasValidRef(), init(), and toBack().

Referenced by addInlineImage(), and addText().

template<typename Container >
void pdfobjects::CPageContents::addToFront ( const Container &  cont  )  [inline]

Add new content stream to the front. This function adds new entry in the "Contents" property of a page. The container of provided operators must form a valid contentstream. This function should be used when supplied operators should be handled at the beginning end e.g. should be drawn first which means they will appear the "below" other object.

This function can be used to separate our changes from original content stream. Indicats that the page changed.

Parameters:
cont Container of operators to add.

References _ccs, _dict, _xpdf_display_params(), change(), pdfobjects::hasValidPdf(), pdfobjects::hasValidRef(), init(), and toFront().

void pdfobjects::CPageContents::change ( bool  invalid = false  )  [inline, private]

Indicate changed page.

References pdfobjects::CPage::_objectChanged(), and _page.

Referenced by addToBack(), addToFront(), parse(), remove(), reparse(), toBack(), and toFront().

template<typename WordEngine , typename LineEngine , typename ColumnEngine >
void pdfobjects::CPageContents::convert ( textoutput::OutputBuilder out  )  [inline]
template<typename RectangleContainer >
size_t pdfobjects::CPageContents::findText ( std::string  text,
RectangleContainer &  recs,
const TextSearchParams params = TextSearchParams() 
) const [inline]

Find all occurences of a text on this page.

It uses xpdf TextOutputDevice to get the bounding box of found text.

Parameters:
text Text to find.
recs Output container of rectangles of all occurences of the text.
params Search parameters.
Returns:
Number of occurences found.

References _page, and pdfobjects::CPage::display().

shared_ptr< CContentStream > pdfobjects::CPageContents::getContentStream ( size_t  pos  ) 

Returns shared pointer to the specified content stream.

References _ccs, and init().

shared_ptr< CContentStream > pdfobjects::CPageContents::getContentStream ( CContentStream cc  ) 

Returns shared pointer to the specified content stream.

References _ccs, and init().

template<typename Container >
void pdfobjects::CPageContents::getContentStreams ( Container &  container  )  [inline]

Fills container with contents streams.

template<typename OpContainer , typename PositionComparator >
void pdfobjects::CPageContents::getObjectsAtPosition ( OpContainer &  opContainer,
PositionComparator  cmp 
) [inline]

Get pdf operators at specified position. This call will be delegated to content stream object.

Parameters:
opContainer Operator container where operators in specified are wil be stored.
cmp Null if default kernel area comparator should be used otherwise points to an object which will decide whether an operator is "near" a point.
void pdfobjects::CPageContents::getText ( std::string &  text,
const std::string *  encoding = NULL,
const libs::Rectangle *  rc = NULL 
) const

Returns plain text extracted from a page using xpdf code.

This method uses xpdf TextOutputDevice that outputs a page to a text device. Text in a pdf is stored neither word by word nor letter by letter. It is not easy not decide whether two letters form a word. Xpdf uses insane algorithm that works most of the time.

Parameters:
text Output string where the text will be saved.
encoding Encoding format.
rc Rectangle from which to extract the text.
void pdfobjects::CPageContents::init (  )  [inline, private]

Init ccs only when necessary.

Reimplemented from pdfobjects::ICPageModule.

Referenced by addInlineImage(), addText(), addToBack(), addToFront(), getContentStream(), remove(), and replaceText().

void pdfobjects::CPageContents::moveAbove ( size_t  pos  ) 
void pdfobjects::CPageContents::moveAbove ( boost::shared_ptr< const CContentStream ct  ) 

Move contentstream up one level. Which means it will be repainted by less objects.

Referenced by moveAbove().

void pdfobjects::CPageContents::moveBelow ( size_t  pos  ) 
void pdfobjects::CPageContents::moveBelow ( boost::shared_ptr< const CContentStream ct  ) 

Move contentstream below one level. Which means it will be repainted by more objects.

Referenced by moveBelow().

bool pdfobjects::CPageContents::parse (  )  [private]
void pdfobjects::CPageContents::reg_observer ( boost::shared_ptr< IProperty ip = boost::shared_ptr<IProperty>()  )  const [private]

Register content stream observer either on page dictionary or supplied object if valid. The observer is registered on page dictionary and on its Contents entry (if any).

Parameters:
ip property to register content stream observer

References _wd, pdfobjects::Specification::Page::CONTENTS, and REGISTER_SHAREDPTR_OBSERVER.

Referenced by CPageContents().

void pdfobjects::CPageContents::remove ( const IndiRef rf  )  [private]
void pdfobjects::CPageContents::remove ( boost::shared_ptr< const CContentStream cs  )  [private]

Remove content streams references from Contents entry.

void pdfobjects::CPageContents::remove ( size_t  csnum  ) 

Remove content stream. This function removes all objects from "Contents" entry which form specified contentstream. Indicats that the page changed.

Parameters:
csnum Number of content stream to remove.

References _ccs, _dict, change(), pdfobjects::hasValidPdf(), and init().

void pdfobjects::CPageContents::reparse (  ) 

Reparse content stream using actual display parameters.

References _ccs, _xpdf_display_params(), change(), pdfobjects::hasValidPdf(), and pdfobjects::hasValidRef().

void pdfobjects::CPageContents::replaceText ( const std::string &  what,
const std::string &  with 
)

Replaces text in the whole page.

References _ccs, and init().

void pdfobjects::CPageContents::reset (  )  [virtual]
See also:
ICPageModule::reset

Reimplemented from pdfobjects::ICPageModule.

References _page, _wd, and unreg_observer().

Referenced by ~CPageContents().

template<typename Cont >
void pdfobjects::CPageContents::setContents ( shared_ptr< CDict dict,
const Cont &  cont 
) [inline]

Set Contents entry from a container of content streams. Indicats that the page changed.

References pdfobjects::Specification::Page::CONTENTS, pdfobjects::hasValidPdf(), and pdfobjects::hasValidRef().

template<typename Cont >
static void pdfobjects::CPageContents::setContents ( boost::shared_ptr< CDict dict,
const Cont &  cont 
) [inline, static]

Set Contents entry from a container of content streams. Indicats that the page changed.

Referenced by pdfobjects::CPageChanges::displayChange().

void pdfobjects::CPageContents::toBack ( CRef ref  )  [private]

Add ref to back.

References change().

Referenced by addToBack().

void pdfobjects::CPageContents::toFront ( CRef ref  )  [private]

Add ref to front.

References change().

Referenced by addToFront().

void pdfobjects::CPageContents::unreg_observer ( boost::shared_ptr< IProperty ip = boost::shared_ptr<IProperty>()  )  const [private]

Unregister observer from page dictionary or supplied object if valid.

Parameters:
ip property to unregister content stream observer

References _wd, pdfobjects::Specification::Page::CONTENTS, and UNREGISTER_SHAREDPTR_OBSERVER.

Referenced by reset().


Member Data Documentation

boost::shared_ptr<CDict> pdfobjects::CPageContents::_dict [private]

Referenced by addText(), and parse().

boost::shared_ptr<ContentsWatchDog> pdfobjects::CPageContents::_wd [private]

Referenced by reg_observer(), reset(), and unreg_observer().


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