#include <cpagecontents.h>
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 ¶ms=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< CContentStream > | getContentStream (CContentStream *cc) |
| boost::shared_ptr< CContentStream > | getContentStream (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 |
Class representing the Contents entry in a page. Provides convinient access and modify operations on "Contents" entry of a page dictionary.
typedef std::vector<boost::shared_ptr<CContentStream> > pdfobjects::CPageContents::CCs [private] |
| pdfobjects::CPageContents::CPageContents | ( | CPage * | page | ) |
References _dict, _page, pdfobjects::CPage::getDictionary(), and reg_observer().
| pdfobjects::CPageContents::~CPageContents | ( | ) |
References reset().
| 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 | |||
| ) |
Adds simple image to the page.
References pdfobjects::CDict::addProperty(), addToBack(), pdfobjects::createOperator(), pdfobjects::createOperatorScale(), pdfobjects::createOperatorTranslation(), pdfobjects::getLastOperator(), and init().
| void pdfobjects::CPageContents::addText | ( | const std::string & | what, | |
| const libs::Point & | where, | |||
| const std::string & | font_id | |||
| ) |
Adds text in to the page.
References _likely_tm, addToBack(), pdfobjects::createOperator(), pdfobjects::getLastOperator(), init(), and pdfobjects::CPageContents::Tm::set_position().
| 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.
| 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().
| 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.
| 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().
| void pdfobjects::CPageContents::convert | ( | textoutput::OutputBuilder & | out | ) | [inline] |
Get text source of a page.
References debug::DBG_INFO, pdfobjects::PdfOperator::getIterator(), pdfobjects::hasValidPdf(), and kernelPrintDbg.
| 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.
| text | Text to find. | |
| recs | Output container of rectangles of all occurences of the text. | |
| params | Search parameters. |
References _page, and pdfobjects::CPage::display().
| shared_ptr< CContentStream > pdfobjects::CPageContents::getContentStream | ( | size_t | pos | ) |
| shared_ptr< CContentStream > pdfobjects::CPageContents::getContentStream | ( | CContentStream * | cc | ) |
| void pdfobjects::CPageContents::getContentStreams | ( | Container & | container | ) | [inline] |
Fills container with contents streams.
| void pdfobjects::CPageContents::getObjectsAtPosition | ( | OpContainer & | opContainer, | |
| PositionComparator | cmp | |||
| ) | [inline] |
Get pdf operators at specified position. This call will be delegated to content stream object.
| 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.
| 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 | ) |
References _page, pdfobjects::CPage::contents(), and moveAbove().
| 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 | ) |
References _page, pdfobjects::CPage::contents(), and moveBelow().
| 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] |
Parse content stream. Content stream is an optional property. When found it is parsed, nothing is done otherwise.
References _ccs, _likely_tm, _xpdf_display_params(), change(), pdfobjects::Specification::Page::CONTENTS, debug::DBG_ERR, debug::DBG_WARN, pdfobjects::utils::getCStreamFromArray(), iterator::DoubleListIterator< Item >::getCurrent(), pdfobjects::PdfOperator::getIterator(), pdfobjects::utils::getReferencedObject(), pdfobjects::hasValidPdf(), pdfobjects::hasValidRef(), pdfobjects::isArray(), iterator::DoubleListIterator< Item >::isEnd(), pdfobjects::isStream(), kernelPrintDbg, and iterator::DoubleListIterator< Item >::next().
| 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).
| 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] |
Remove one indiref from Contents entry.
References pdfobjects::Specification::Page::CONTENTS, debug::DBG_ERR, pdfobjects::utils::getReferencedObject(), pdfobjects::utils::getRefFromArray(), pdfobjects::isArray(), pdfobjects::isStream(), and kernelPrintDbg.
| 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.
| 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 | |||
| ) |
| void pdfobjects::CPageContents::reset | ( | ) | [virtual] |
Reimplemented from pdfobjects::ICPageModule.
References _page, _wd, and unreg_observer().
Referenced by ~CPageContents().
| 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().
| 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] |
| void pdfobjects::CPageContents::toFront | ( | CRef & | ref | ) | [private] |
| 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.
| ip | property to unregister content stream observer |
References _wd, pdfobjects::Specification::Page::CONTENTS, and UNREGISTER_SHAREDPTR_OBSERVER.
Referenced by reset().
CCs pdfobjects::CPageContents::_ccs [private] |
Referenced by addToBack(), addToFront(), getContentStream(), parse(), remove(), reparse(), and replaceText().
boost::shared_ptr<CDict> pdfobjects::CPageContents::_dict [private] |
Referenced by addToBack(), addToFront(), CPageContents(), and remove().
Tm pdfobjects::CPageContents::_likely_tm [private] |
CPage* pdfobjects::CPageContents::_page [private] |
Referenced by _page_pos(), _xpdf_display_params(), change(), CPageContents(), findText(), moveAbove(), moveBelow(), and reset().
boost::shared_ptr<ContentsWatchDog> pdfobjects::CPageContents::_wd [private] |
Referenced by reg_observer(), reset(), and unreg_observer().