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

void PoDoFo::PdfPage::DeleteAnnotation ( const PdfReference ref )

Delete the annotation object with reference ref from this page.

Parameters:
refthe reference of an annotation object of this page.
See also:
GetNumAnnots

Definition at line 366 of file PdfPage.cpp.

References PoDoFo::PdfArray::begin(), PoDoFo::PdfArray::end(), PoDoFo::ePdfError_InvalidDataType, PoDoFo::ePdfError_NoObject, GetAnnotationsArray(), PoDoFo::PdfVariant::GetArray(), PoDoFo::PdfElement::GetObject(), PoDoFo::PdfObject::GetOwner(), PoDoFo::PdfVariant::IsArray(), PODOFO_RAISE_ERROR, and PoDoFo::PdfVecObjects::RemoveObject().

{
    PdfAnnotation*     pAnnot;
    PdfArray::iterator it;
    PdfObject*         pObj   = this->GetAnnotationsArray( false );
    bool               bFound = false;

    // delete the annotation from the array

    if( !(pObj && pObj->IsArray()) )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
    }

    it = pObj->GetArray().begin();
    while( it != pObj->GetArray().end() ) 
    {
        if( (*it).GetReference() == ref ) 
        {
            pObj->GetArray().erase( it );
            bFound = true;
            break;
        }

        ++it;
    }

    // if no such annotation was found
    // throw an error instead of deleting
    // another object with this reference
    if( !bFound ) 
    {
        PODOFO_RAISE_ERROR( ePdfError_NoObject );
    }

    // delete any cached PdfAnnotations
    pAnnot = m_mapAnnotations[ref];
    if( pAnnot )
    {
        delete pAnnot;
        m_mapAnnotations.erase( ref );
    }

    // delete the PdfObject in the file
    delete this->GetObject()->GetOwner()->RemoveObject( ref );
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index