PoDoFo
0.9.6
|
#include <PdfVecObjects.h>
Classes | |
class | Observer |
class | StreamFactory |
Public Member Functions | |
PdfVecObjects () | |
PdfDocument * | GetParentDocument () const |
void | SetParentDocument (PdfDocument *pDocument) |
void | SetAutoDelete (bool bAutoDelete) |
bool | AutoDelete () const |
void | SetCanReuseObjectNumbers (bool bCanReuseObjectNumbers) |
bool | GetCanReuseObjectNumbers () const |
void | Clear () |
size_t | GetSize () const |
size_t | GetObjectCount () const |
PdfObject * | GetObject (const PdfReference &ref) const |
PdfObject * | MustGetObject (const PdfReference &ref) const |
size_t | GetIndex (const PdfReference &ref) const |
PdfObject * | RemoveObject (const PdfReference &ref, bool bMarkAsFree=true) |
PdfObject * | RemoveObject (const TIVecObjects &it) |
PdfObject * | CreateObject (const char *pszType=NULL) |
PdfObject * | CreateObject (const PdfVariant &rVariant) |
void | AddFreeObject (const PdfReference &rReference) |
const TPdfReferenceList & | GetFreeObjects () const |
void | RenumberObjects (PdfObject *pTrailer, TPdfReferenceSet *pNotDelete=NULL, bool bDoGarbageCollection=false) |
void | push_back (PdfObject *pObj) |
void | insert_sorted (PdfObject *pObj) |
void | Sort () |
void | SetMaxReserveSize (size_t size) |
size_t | GetMaxReserveSize () const |
void | Reserve (size_t size) |
void | GetObjectDependencies (const PdfObject *pObj, TPdfReferenceList *pList) const |
void | Attach (Observer *pObserver) |
void | Detach (Observer *pObserver) |
void | SetStreamFactory (StreamFactory *pFactory) |
PdfStream * | CreateStream (PdfObject *pParent) |
PdfStream * | CreateStream (const PdfStream &rhs) |
void | WriteObject (PdfObject *pObject) |
void | Finish () |
void | BeginAppendStream (const PdfStream *pStream) |
void | EndAppendStream (const PdfStream *pStream) |
TIVecObjects | begin () |
TCIVecObjects | begin () const |
TIVecObjects | end () |
TCIVecObjects | end () const |
PdfObject * | GetBack () |
void | CollectGarbage (PdfObject *pTrailer) |
std::string | GetNextSubsetPrefix () |
void | SetObjectCount (const PdfReference &rRef) |
A STL vector of PdfObjects. I.e. a list of PdfObject classes. The PdfParser will read the PdfFile into memory and create a PdfVecObjects of all dictionaries found in the PDF file.
The PdfWriter class contrary creates a PdfVecObjects internally and writes it to a PDF file later with an appropriate table of contents.
These class contains also advanced functions for searching of PdfObject's in a PdfVecObject.
PoDoFo::PdfVecObjects::PdfVecObjects | ( | ) |
Default constuctor
void PoDoFo::PdfVecObjects::AddFreeObject | ( | const PdfReference & | rReference | ) |
Mark a reference as unused so that it can be reused for new objects.
rReference | the reference to reuse |
|
inline |
Attach a new observer
pObserver | to attach |
|
inline |
|
inline |
Iterator pointing at the beginning of the vector
|
inline |
Iterator pointing at the beginning of the vector
void PoDoFo::PdfVecObjects::BeginAppendStream | ( | const PdfStream * | pStream | ) |
Every stream implementation has to call this in BeginAppend
pStream | the stream object that is calling |
void PoDoFo::PdfVecObjects::Clear | ( | ) |
Removes all objects from the vector and resets it to the default state.
If SetAutoDelete is true all objects are deleted. All observers are removed from the vector.
void PoDoFo::PdfVecObjects::CollectGarbage | ( | PdfObject * | pTrailer | ) |
Deletes all objects that are not references by other objects besides the trailer (which references the root dictionary, which in turn should reference all other objects).
pTrailer | trailer object of the PDF |
Warning this might be slow!
PdfObject * PoDoFo::PdfVecObjects::CreateObject | ( | const char * | pszType = NULL | ) |
PdfObject * PoDoFo::PdfVecObjects::CreateObject | ( | const PdfVariant & | rVariant | ) |
Creates a stream object by copying an existing stream
rhs | copy this stream |
Creates a stream object This method is a factory for PdfStream objects.
pParent | parent object |
void PoDoFo::PdfVecObjects::Detach | ( | Observer * | pObserver | ) |
Detach an observer.
pObserver | observer to detach |
|
inline |
Iterator pointing at the end of the vector
|
inline |
Iterator pointing at the end of the vector
void PoDoFo::PdfVecObjects::EndAppendStream | ( | const PdfStream * | pStream | ) |
Every stream implementation has to call this in EndAppend
pStream | the stream object that is calling |
void PoDoFo::PdfVecObjects::Finish | ( | ) |
Call whenever a document is finished
|
inline |
Get the last object in the vector
|
inline |
|
inline |
size_t PoDoFo::PdfVecObjects::GetIndex | ( | const PdfReference & | ref | ) | const |
Finds the object with the given reference in m_vecOffsets and returns the index to it.
ref | the object to be found |
|
inline |
Gets the maximum number of elements Reserve() will work for (to fix CVE-2018-5783) which is called with a value from the PDF in the parser. The default is from Table C.1 in section C.2 of PDF32000_2008.pdf (PDF 1.7 standard free version): 8388607.
std::string PoDoFo::PdfVecObjects::GetNextSubsetPrefix | ( | ) |
Get next unique subset-prefix
PdfObject * PoDoFo::PdfVecObjects::GetObject | ( | const PdfReference & | ref | ) | const |
Finds the object with the given reference in m_vecOffsets and returns a pointer to it if it is found.
ref | the object to be found |
|
inline |
void PoDoFo::PdfVecObjects::GetObjectDependencies | ( | const PdfObject * | pObj, |
TPdfReferenceList * | pList | ||
) | const |
Get a set with all references of objects that the passed object depends on.
pObj | the object to calculate all dependencies for |
pList | write the list of dependencies to this list |
|
inline |
|
inline |
void PoDoFo::PdfVecObjects::insert_sorted | ( | PdfObject * | pObj | ) |
Insert an object into this vector so that the vector remains sorted w.r.t. the ordering based on object and generation numbers m_bObjectCount will be increased for the object.
pObj | pointer to the object you want to insert |
PdfObject * PoDoFo::PdfVecObjects::MustGetObject | ( | const PdfReference & | ref | ) | const |
Finds the object with the given reference in m_vecOffsets and returns a pointer to it if it is found. Throws a PdfError exception with error code ePdfError_NoObject if no object was found
ref | the object to be found |
PdfError(ePdfError_NoObject) |
void PoDoFo::PdfVecObjects::push_back | ( | PdfObject * | pObj | ) |
Simple forward to insert sorted, as PdfVecObjects is always sorted.
PdfObject * PoDoFo::PdfVecObjects::RemoveObject | ( | const PdfReference & | ref, |
bool | bMarkAsFree = true |
||
) |
Remove the object with the given object and generation number from the list of objects. The object is returned if it was found. Otherwise NULL is returned. The caller has to delete the object by himself.
ref | the object to be found |
bMarkAsFree | if true the removed object reference is marked as free object you will always want to have this true as invalid PDF files can be generated otherwise |
PdfObject * PoDoFo::PdfVecObjects::RemoveObject | ( | const TIVecObjects & | it | ) |
Remove the object with the iterator it from the vector and return it
it | the object to remove |
void PoDoFo::PdfVecObjects::RenumberObjects | ( | PdfObject * | pTrailer, |
TPdfReferenceSet * | pNotDelete = NULL , |
||
bool | bDoGarbageCollection = false |
||
) |
Renumbers all objects according to there current position in the vector. All references remain intact. Warning! This function is very calculation intensive.
pTrailer | the trailer object |
pNotDelete | a list of object which must not be deleted |
bDoGarbageCollection | enable garbage collection, which deletes all objects that are not reachable from the trailer. This might be slow! |
|
inline |
Causes the internal vector to reserve space for size elements.
size | reserve space for that much elements in the internal vector |
|
inline |
Enable/disable auto deletion. By default auto deletion is disabled.
bAutoDelete | if true all objects will be deleted when the PdfVecObjects is deleted. |
void PoDoFo::PdfVecObjects::SetCanReuseObjectNumbers | ( | bool | bCanReuseObjectNumbers | ) |
Enable/disable object numbers re-use. By default object numbers re-use is enabled.
bCanReuseObjectNumbers | if true, free object numbers can be re-used when creating new objects. |
If set to false, the list of free object numbers is automatically cleared.
|
inline |
Set the maximum number of elements Reserve() will work for (to fix CVE-2018-5783) which is called with a value from the PDF in the parser. The default is from Table C.1 in section C.2 of PDF32000_2008.pdf (PDF 1.7 standard free version). This sets a static variable, so don't use from multiple threads (without proper locking).
size | Number of elements to allow to be reserved |
|
inline |
Set the object count so that the object described this reference is contained in the object count.
rRef | reference of newly added object |
|
inline |
Sets a parent document of this vector
pDocument | the parent of this vector |
|
inline |
Sets a StreamFactory which is used whenever CreateStream is called.
pFactory | a stream factory or NULL to reset to the default factory |
void PoDoFo::PdfVecObjects::Sort | ( | ) |
Sort the objects in the vector based on their object and generation numbers