summaryrefslogtreecommitdiff
path: root/sdext/source/pdfimport/pdfparse/pdfentries.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sdext/source/pdfimport/pdfparse/pdfentries.cxx')
-rw-r--r--sdext/source/pdfimport/pdfparse/pdfentries.cxx70
1 files changed, 35 insertions, 35 deletions
diff --git a/sdext/source/pdfimport/pdfparse/pdfentries.cxx b/sdext/source/pdfimport/pdfparse/pdfentries.cxx
index c41e3acfb902..51bf6a1b7348 100644
--- a/sdext/source/pdfimport/pdfparse/pdfentries.cxx
+++ b/sdext/source/pdfimport/pdfparse/pdfentries.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -60,7 +60,7 @@ struct EmitImplData
XRefTable m_aXRefTable;
// container of all indirect objects (usually a PDFFile*)
const PDFContainer* m_pObjectContainer;
-
+
// returns true if the xref table was updated
bool insertXref( unsigned int nObject, unsigned int nGeneration, unsigned int nOffset )
{
@@ -79,7 +79,7 @@ struct EmitImplData
}
return false;
}
-
+
EmitImplData( const PDFContainer* pTopContainer ) :
m_pObjectContainer( pTopContainer )
{}
@@ -212,7 +212,7 @@ OString PDFString::getFilteredString() const
{
int nLen = m_aString.getLength();
OStringBuffer aBuf( nLen );
-
+
const sal_Char* pStr = m_aString.getStr();
if( *pStr == '(' )
{
@@ -296,7 +296,7 @@ OString PDFString::getFilteredString() const
aBuf.append( rResult );
}
}
-
+
return aBuf.makeStringAndClear();
}
@@ -308,7 +308,7 @@ bool PDFNumber::emit( EmitContext& rWriteContext ) const
{
rtl::OStringBuffer aBuf( 32 );
aBuf.append( ' ' );
-
+
double fValue = m_fValue;
bool bNeg = false;
int nPrecision = 5;
@@ -348,7 +348,7 @@ bool PDFNumber::emit( EmitContext& rWriteContext ) const
nBound /= 10;
}
}
-
+
return rWriteContext.write( aBuf.getStr(), aBuf.getLength() );
}
@@ -485,7 +485,7 @@ void PDFDict::insertValue( const OString& rName, PDFEntry* pValue )
{
if( ! pValue )
eraseValue( rName );
-
+
std::hash_map<OString,PDFEntry*,OStringHash>::iterator it = m_aMap.find( rName );
if( it == m_aMap.end() )
{
@@ -648,7 +648,7 @@ bool PDFObject::getDeflatedStream( char** ppStream, unsigned int* pBytes, const
pFilter = dynamic_cast<PDFName*>(pArray->m_aSubElements.front());
}
}
-
+
// is the (first) filter FlateDecode ?
if( pFilter && pFilter->m_aName.equals( "FlateDecode" ) )
{
@@ -692,7 +692,7 @@ static void unzipToBuffer( const char* pBegin, unsigned int nLen,
aZStr.zfree = ( free_func )0;
aZStr.opaque = ( voidpf )0;
inflateInit(&aZStr);
-
+
const unsigned int buf_increment_size = 16384;
*pOutBuf = (sal_uInt8*)rtl_reallocateMemory( *pOutBuf, buf_increment_size );
@@ -755,11 +755,11 @@ bool PDFObject::emit( EmitContext& rWriteContext ) const
{
if( ! rWriteContext.write( "\n", 1 ) )
return false;
-
+
EmitImplData* pEData = getEmitData( rWriteContext );
if( pEData )
pEData->insertXref( m_nNumber, m_nGeneration, rWriteContext.getCurPos() );
-
+
OStringBuffer aBuf( 32 );
aBuf.append( sal_Int32( m_nNumber ) );
aBuf.append( ' ' );
@@ -767,7 +767,7 @@ bool PDFObject::emit( EmitContext& rWriteContext ) const
aBuf.append( " obj\n" );
if( ! rWriteContext.write( aBuf.getStr(), aBuf.getLength() ) )
return false;
-
+
if( rWriteContext.m_bDeflate && pEData )
{
char* pStream = NULL;
@@ -944,9 +944,9 @@ struct PDFFileImplData
OString m_aDocID;
rtlCipher m_aCipher;
rtlDigest m_aDigest;
-
+
sal_uInt8 m_aDecryptionKey[ENCRYPTION_KEY_LEN+5]; // maximum handled key length
-
+
PDFFileImplData() :
m_bIsEncrypted( false ),
m_bStandardHandler( false ),
@@ -961,7 +961,7 @@ struct PDFFileImplData
rtl_zeroMemory( m_aUEntry, sizeof( m_aUEntry ) );
rtl_zeroMemory( m_aDecryptionKey, sizeof( m_aDecryptionKey ) );
}
-
+
~PDFFileImplData()
{
if( m_aCipher )
@@ -988,10 +988,10 @@ bool PDFFile::decrypt( const sal_uInt8* pInBuffer, sal_uInt32 nLen, sal_uInt8* p
{
if( ! isEncrypted() )
return false;
-
+
if( ! m_pData->m_aCipher )
m_pData->m_aCipher = rtl_cipher_createARCFOUR( rtl_Cipher_ModeStream );
-
+
// modify encryption key
sal_uInt32 i = m_pData->m_nKeyLength;
m_pData->m_aDecryptionKey[i++] = sal_uInt8(nObject&0xff);
@@ -999,11 +999,11 @@ bool PDFFile::decrypt( const sal_uInt8* pInBuffer, sal_uInt32 nLen, sal_uInt8* p
m_pData->m_aDecryptionKey[i++] = sal_uInt8((nObject>>16)&0xff);
m_pData->m_aDecryptionKey[i++] = sal_uInt8(nGeneration&0xff);
m_pData->m_aDecryptionKey[i++] = sal_uInt8((nGeneration>>8)&0xff);
-
+
sal_uInt8 aSum[ENCRYPTION_KEY_LEN];
rtl_digest_updateMD5( m_pData->m_aDigest, m_pData->m_aDecryptionKey, i );
rtl_digest_getMD5( m_pData->m_aDigest, aSum, sizeof( aSum ) );
-
+
if( i > 16 )
i = 16;
@@ -1086,12 +1086,12 @@ static bool check_user_password( const OString& rPwd, PDFFileImplData* pData )
{
// see PDF reference 1.4 Algorithm 3.4
// encrypt pad string
- rtl_cipher_initARCFOUR( pData->m_aCipher, rtl_Cipher_DirectionEncode,
+ rtl_cipher_initARCFOUR( pData->m_aCipher, rtl_Cipher_DirectionEncode,
aKey, nKeyLen,
NULL, 0 );
rtl_cipher_encodeARCFOUR( pData->m_aCipher, nPadString, sizeof( nPadString ),
nEncryptedEntry, sizeof( nEncryptedEntry ) );
- bValid = (rtl_compareMemory( nEncryptedEntry, pData->m_aUEntry, 32 ) == 0);
+ bValid = (rtl_compareMemory( nEncryptedEntry, pData->m_aUEntry, 32 ) == 0);
}
else if( pData->m_nStandardRevision == 3 )
{
@@ -1099,7 +1099,7 @@ static bool check_user_password( const OString& rPwd, PDFFileImplData* pData )
rtl_digest_updateMD5( pData->m_aDigest, nPadString, sizeof( nPadString ) );
rtl_digest_updateMD5( pData->m_aDigest, pData->m_aDocID.getStr(), pData->m_aDocID.getLength() );
rtl_digest_getMD5( pData->m_aDigest, nEncryptedEntry, sizeof(nEncryptedEntry) );
- rtl_cipher_initARCFOUR( pData->m_aCipher, rtl_Cipher_DirectionEncode,
+ rtl_cipher_initARCFOUR( pData->m_aCipher, rtl_Cipher_DirectionEncode,
aKey, sizeof(aKey), NULL, 0 );
rtl_cipher_encodeARCFOUR( pData->m_aCipher,
nEncryptedEntry, 16,
@@ -1109,14 +1109,14 @@ static bool check_user_password( const OString& rPwd, PDFFileImplData* pData )
sal_uInt8 aTempKey[ENCRYPTION_KEY_LEN];
for( sal_uInt32 j = 0; j < sizeof(aTempKey); j++ )
aTempKey[j] = static_cast<sal_uInt8>( aKey[j] ^ i );
-
- rtl_cipher_initARCFOUR( pData->m_aCipher, rtl_Cipher_DirectionEncode,
+
+ rtl_cipher_initARCFOUR( pData->m_aCipher, rtl_Cipher_DirectionEncode,
aTempKey, sizeof(aTempKey), NULL, 0 );
rtl_cipher_encodeARCFOUR( pData->m_aCipher,
nEncryptedEntry, 16,
nEncryptedEntry, 16 ); // encrypt in place
}
- bValid = (rtl_compareMemory( nEncryptedEntry, pData->m_aUEntry, 16 ) == 0);
+ bValid = (rtl_compareMemory( nEncryptedEntry, pData->m_aUEntry, 16 ) == 0);
}
return bValid;
}
@@ -1125,7 +1125,7 @@ bool PDFFile::setupDecryptionData( const OString& rPwd ) const
{
if( !impl_getData()->m_bIsEncrypted )
return rPwd.getLength() == 0;
-
+
// check if we can handle this encryption at all
if( ! m_pData->m_bStandardHandler ||
m_pData->m_nAlgoVersion < 1 ||
@@ -1133,15 +1133,15 @@ bool PDFFile::setupDecryptionData( const OString& rPwd ) const
m_pData->m_nStandardRevision < 2 ||
m_pData->m_nStandardRevision > 3 )
return false;
-
+
if( ! m_pData->m_aCipher )
m_pData->m_aCipher = rtl_cipher_createARCFOUR(rtl_Cipher_ModeStream);
if( ! m_pData->m_aDigest )
m_pData->m_aDigest = rtl_digest_createMD5();
-
+
// first try user password
bool bValid = check_user_password( rPwd, m_pData );
-
+
if( ! bValid )
{
// try owner password
@@ -1152,7 +1152,7 @@ bool PDFFile::setupDecryptionData( const OString& rPwd ) const
sal_uInt32 nKeyLen = password_to_key( rPwd, aKey, m_pData, true );
if( m_pData->m_nStandardRevision == 2 )
{
- rtl_cipher_initARCFOUR( m_pData->m_aCipher, rtl_Cipher_DirectionDecode,
+ rtl_cipher_initARCFOUR( m_pData->m_aCipher, rtl_Cipher_DirectionDecode,
aKey, nKeyLen, NULL, 0 );
rtl_cipher_decodeARCFOUR( m_pData->m_aCipher,
m_pData->m_aOEntry, 32,
@@ -1166,7 +1166,7 @@ bool PDFFile::setupDecryptionData( const OString& rPwd ) const
sal_uInt8 nTempKey[ENCRYPTION_KEY_LEN];
for( unsigned int j = 0; j < sizeof(nTempKey); j++ )
nTempKey[j] = sal_uInt8(aKey[j] ^ i);
- rtl_cipher_initARCFOUR( m_pData->m_aCipher, rtl_Cipher_DirectionDecode,
+ rtl_cipher_initARCFOUR( m_pData->m_aCipher, rtl_Cipher_DirectionDecode,
nTempKey, nKeyLen, NULL, 0 );
rtl_cipher_decodeARCFOUR( m_pData->m_aCipher,
nPwd, 32,
@@ -1316,17 +1316,17 @@ PDFFileImplData* PDFFile::impl_getData() const
break;
}
}
- }
+ }
}
}
-
+
return m_pData;
}
bool PDFFile::emit( EmitContext& rWriteContext ) const
{
setEmitData( rWriteContext, new EmitImplData( this ) );
-
+
OStringBuffer aBuf( 32 );
aBuf.append( "%PDF-" );
aBuf.append( sal_Int32( m_nMajor ) );