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

void PoDoFo::PdfCanvas::AddResource ( const PdfName rIdentifier,
const PdfReference rRef,
const PdfName rName 
) [inherited]

Register an object in the resource dictionary of this page or XObbject so that it can be used for any following drawing operations.

Parameters:
rIdentifieridentifier of this object, e.g. /Ft0
rRefreference to the object you want to register
rNameregister under this key in the resource dictionary

Definition at line 102 of file PdfCanvas.cpp.

References PoDoFo::PdfDictionary::AddKey(), PoDoFo::ePdfDataType_Reference, PoDoFo::ePdfError_InvalidHandle, PoDoFo::ePdfError_NoObject, PoDoFo::PdfVariant::GetDataType(), PoDoFo::PdfVariant::GetDictionary(), PoDoFo::PdfDictionary::GetKey(), PoDoFo::PdfName::GetLength(), PoDoFo::PdfVecObjects::GetObject(), PoDoFo::PdfObject::GetOwner(), PoDoFo::PdfVariant::GetReference(), PoDoFo::PdfCanvas::GetResources(), PoDoFo::PdfDictionary::HasKey(), and PODOFO_RAISE_ERROR.

Referenced by PoDoFo::PdfCanvas::AddColorResource(), and PoDoFo::PdfPainter::AddToPageResources().

{
    if( !rName.GetLength() || !rIdentifier.GetLength() )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }

    PdfObject* pResource = this->GetResources();
    
    if( !pResource )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }

    if( !pResource->GetDictionary().HasKey( rName ) )
    {
        pResource->GetDictionary().AddKey( rName, PdfDictionary() );
    }

    // Peter Petrov: 18 December 2008. Bug fix
      if (ePdfDataType_Reference == pResource->GetDictionary().GetKey( rName )->GetDataType())
    {
        PdfObject *directObject = pResource->GetOwner()->GetObject(pResource->GetDictionary().GetKey( rName )->GetReference());

        if (0 == directObject)
        {
            PODOFO_RAISE_ERROR( ePdfError_NoObject );
        }

        if( !directObject->GetDictionary().HasKey( rIdentifier ) )
            directObject->GetDictionary().AddKey( rIdentifier, rRef );
    }else
    {

        if( !pResource->GetDictionary().GetKey( rName )->GetDictionary().HasKey( rIdentifier ) )
            pResource->GetDictionary().GetKey( rName )->GetDictionary().AddKey( rIdentifier, rRef );
    }
}

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