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

void PoDoFo::PdfParser::ReadXRefSubsection ( long long &  nFirstObject,
long long &  nNumObjects 
) [protected]

Read a xref subsection

Throws ePdfError_NoXref if the number of objects read was not the number specified by the subsection header (as passed in `nNumObjects').

Parameters:
nFirstObjectobject number of the first object
nNumObjectshow many objects should be read from this section

Definition at line 667 of file PdfParser.cpp.

References PoDoFo::PdfError::DebugMessage(), PoDoFo::PdfRefCountedInputDevice::Device(), PoDoFo::eLogSeverity_Warning, PoDoFo::ePdfError_NoXRef, PoDoFo::PdfRefCountedBuffer::GetBuffer(), PoDoFo::PdfInputDevice::GetChar(), PoDoFo::PdfTokenizer::IsWhitespace(), PoDoFo::PdfError::LogMessage(), PoDoFo::PdfInputDevice::Look(), PODOFO_RAISE_ERROR, and PoDoFo::PdfInputDevice::Read().

Referenced by ReadXRefContents().

{
    int count = 0;

#ifdef PODOFO_VERBOSE_DEBUG
    PdfError::DebugMessage("Reading XRef Section: %lli with %lli Objects.\n", nFirstObject, nNumObjects );
#endif // PODOFO_VERBOSE_DEBUG 

    if ( nFirstObject + nNumObjects > m_nNumObjects )
    {
        // Total number of xref entries to read is greater than the /Size
        // specified in the trailer if any. That's an error unless we're trying
        // to recover from a missing /Size entry.
            PdfError::LogMessage( eLogSeverity_Warning,
                        "There are more objects (%lli) in this XRef table than "
                        "specified in the size key of the trailer directory (%lli)!\n",
                        nFirstObject + nNumObjects, m_nNumObjects );

#ifdef _WIN32
            m_nNumObjects = static_cast<long>(nFirstObject + nNumObjects);
            m_offsets.resize(static_cast<long>(nFirstObject+nNumObjects));
#else
            m_nNumObjects = nFirstObject + nNumObjects;
            m_offsets.resize(nFirstObject+nNumObjects);
#endif // _WIN32
      }

    // consume all whitespaces
    int charcode;
    while( this->IsWhitespace((charcode = m_device.Device()->Look())) )
    {
        m_device.Device()->GetChar();
    }

    while( count < nNumObjects && m_device.Device()->Read( m_buffer.GetBuffer(), PDF_XREF_ENTRY_SIZE ) == PDF_XREF_ENTRY_SIZE )
    {
        char empty1;
        char empty2;
        m_buffer.GetBuffer()[PDF_XREF_ENTRY_SIZE] = '\0';

#ifdef _WIN32
            const int objID = static_cast<int>(nFirstObject+count);
#else
            const int objID = nFirstObject+count;
#endif // _WIN32

        if( !m_offsets[objID].bParsed )
        {
            m_offsets[objID].bParsed = true;
#ifdef _WIN64
            sscanf( m_buffer.GetBuffer(), "%10I64d %5ld %c%c%c", 
                    &(m_offsets[objID].lOffset), 
                    &(m_offsets[objID].lGeneration), &(m_offsets[objID].cUsed), &empty1, &empty2 );
#else
            long long int tmp1;
            long int tmp2;
            sscanf( m_buffer.GetBuffer(), "%10lld %5ld %c%c%c", 
                    &tmp1, &tmp2, &(m_offsets[objID].cUsed), &empty1, &empty2 );

            m_offsets[objID].lOffset = static_cast<pdf_long>(tmp1);
            m_offsets[objID].lGeneration = tmp2;
#endif
       }

        ++count;
    }

    if( count != nNumObjects )
    {
        PdfError::LogMessage( eLogSeverity_Warning, "Count of readobject is %i. Expected %lli.\n", count, nNumObjects );
        PODOFO_RAISE_ERROR( ePdfError_NoXRef );
    }

}

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