From 526575b69666adc555ea14c7524e2ba8bf7834b0 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Fri, 29 Jan 2010 15:49:01 +0100 Subject: improve deflate recognition, fix debug output --- sdext/source/pdfimport/pdfparse/pdfentries.cxx | 27 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'sdext/source') diff --git a/sdext/source/pdfimport/pdfparse/pdfentries.cxx b/sdext/source/pdfimport/pdfparse/pdfentries.cxx index 9374e20f12bc..b0e2132fdd9c 100644 --- a/sdext/source/pdfimport/pdfparse/pdfentries.cxx +++ b/sdext/source/pdfimport/pdfparse/pdfentries.cxx @@ -642,8 +642,17 @@ bool PDFObject::getDeflatedStream( char** ppStream, unsigned int* pBytes, const m_pStream->m_pDict->m_aMap.find( "Filter" ); if( it != m_pStream->m_pDict->m_aMap.end() ) { - // is the (first) filter FlateDecode ? PDFName* pFilter = dynamic_cast(it->second); + if( ! pFilter ) + { + PDFArray* pArray = dynamic_cast(it->second); + if( pArray && ! pArray->m_aSubElements.empty() ) + { + pFilter = dynamic_cast(pArray->m_aSubElements.front()); + } + } + + // is the (first) filter FlateDecode ? if( pFilter && pFilter->m_aName.equals( "FlateDecode" ) ) { bIsDeflated = true; @@ -673,8 +682,6 @@ bool PDFObject::getDeflatedStream( char** ppStream, unsigned int* pBytes, const } else *ppStream = NULL, *pBytes = 0; - // FIXME: one could also deflate if FlateDecode ws the - // first filter in an array return bIsDeflated; } @@ -1200,7 +1207,7 @@ PDFFileImplData* PDFFile::impl_getData() const #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "DocId is <" ); for( int i = 0; i < m_pData->m_aDocID.getLength(); i++ ) - fprintf( stderr, "%.2x", sal_uInt32(sal_uInt8(m_pData->m_aDocID.getStr()[i])) ); + fprintf( stderr, "%.2x", (unsigned int)sal_uInt8(m_pData->m_aDocID.getStr()[i]) ); fprintf( stderr, ">\n" ); #endif } @@ -1262,9 +1269,9 @@ PDFFileImplData* PDFFile::impl_getData() const #if OSL_DEBUG_LEVEL > 1 else { - fprintf( stderr, "O entry has length %d, should be 32 <", aEnt.getLength() ); + fprintf( stderr, "O entry has length %d, should be 32 <", (int)aEnt.getLength() ); for( int i = 0; i < aEnt.getLength(); i++ ) - fprintf( stderr, " %.2X", sal_uInt32(sal_uInt8(aEnt.getStr()[i])) ); + fprintf( stderr, " %.2X", (unsigned int)sal_uInt8(aEnt.getStr()[i]) ); fprintf( stderr, ">\n" ); } #endif @@ -1281,9 +1288,9 @@ PDFFileImplData* PDFFile::impl_getData() const #if OSL_DEBUG_LEVEL > 1 else { - fprintf( stderr, "U entry has length %d, should be 32 <", aEnt.getLength() ); + fprintf( stderr, "U entry has length %d, should be 32 <", (int)aEnt.getLength() ); for( int i = 0; i < aEnt.getLength(); i++ ) - fprintf( stderr, " %.2X", sal_uInt32(sal_uInt8(aEnt.getStr()[i])) ); + fprintf( stderr, " %.2X", (unsigned int)sal_uInt8(aEnt.getStr()[i]) ); fprintf( stderr, ">\n" ); } #endif @@ -1301,13 +1308,13 @@ PDFFileImplData* PDFFile::impl_getData() const if( pNum ) m_pData->m_nPEntry = static_cast(static_cast(pNum->m_fValue)); #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "p entry is 0x%x\n", m_pData->m_nPEntry ); + fprintf( stderr, "p entry is %p\n", m_pData->m_nPEntry ); #endif } #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "Encryption dict: sec handler: %s, version = %d, revision = %d, key length = %d\n", pFilter ? OUStringToOString( pFilter->getFilteredName(), RTL_TEXTENCODING_UTF8 ).getStr() : "", - m_pData->m_nAlgoVersion, m_pData->m_nStandardRevision, m_pData->m_nKeyLength ); + (int)m_pData->m_nAlgoVersion, (int)m_pData->m_nStandardRevision, m_pData->m_nKeyLength ); #endif break; } -- cgit