Logo Search packages:      
Sourcecode: libpodofo version File versions  Download package

void PoDoFo::PdfPagesTree::DeletePageFromNode ( PdfObject pNode,
const PdfObjectList &  rlstParents,
int  nIndex,
PdfObject pPage 
) [private]

Delete a page object from a pages node

Parameters:
pNodewhich is the direct parent of pPage and where the page must be deleted
rlstParentslist of all parent pages nodes in the pages tree of pPage
nIndexindex where pPage is to be deleted in pNode's kids array
pPagethe page object which is to be deleted

Definition at line 488 of file PdfPagesTree.cpp.

References ChangePagesCount(), DeletePageNode(), PoDoFo::ePdfError_InvalidHandle, PoDoFo::PdfElement::GetObject(), PoDoFo::PdfObject::GetOwner(), GetPosInKids(), GetRoot(), IsEmptyPageNode(), PODOFO_RAISE_ERROR, and PoDoFo::PdfVecObjects::RemoveObject().

Referenced by DeletePage().

{
    if( !pParent || !pPage ) 
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }

    // 1. Delete the reference from the kids array of pParent
    // 2. Decrease count of every node in lstParents (which also includes pParent)
    // 3. Remove empty page nodes

    // TODO: Tell cache to free page object

    // 1. Delete reference
    this->DeletePageNode( pParent, nIndex ) ;

    // 2. Decrease count
    PdfObjectList::const_reverse_iterator itParents = rlstParents.rbegin();
    while( itParents != rlstParents.rend() )
    {
        this->ChangePagesCount( *itParents, -1 );

        ++itParents;
    } 

    // 3. Remove empty pages nodes
    itParents = rlstParents.rbegin();
    while( itParents != rlstParents.rend() )
    {
        // Never delete root node
        if( IsEmptyPageNode( *itParents ) && *itParents != GetRoot() ) 
        {
            PdfObject* pParentOfNode = *(itParents + 1);
            int nKidsIndex = this->GetPosInKids( *itParents, pParentOfNode );
            DeletePageNode( pParentOfNode, nKidsIndex );

            // Delete empty page nodes
            delete this->GetObject()->GetOwner()->RemoveObject( (*itParents)->Reference() );
        }

        ++itParents;
    } 
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index