25#include <rtl/strbuf.hxx>
26#include <rtl/ustring.hxx>
27#include <rtl/ustrbuf.hxx>
28#include <rtl/digest.h>
29#include <rtl/cipher.h>
46 typedef std::map< unsigned int, std::pair< unsigned int, unsigned int > >
XRefTable;
54 bool insertXref(
unsigned int nObject,
unsigned int nGeneration,
unsigned int nOffset )
60 m_aXRefTable[ nObject ] = std::pair<unsigned int, unsigned int>(nGeneration,nOffset);
64 if( it->second.first < nGeneration )
66 it->second = std::pair<unsigned int, unsigned int>(nGeneration,nOffset);
78 unsigned int nObject,
unsigned int nGeneration )
const
81 pFile && pFile->
decrypt( pInBuffer, nLen, pOutBuffer, nObject, nGeneration );
147 if( ! rWriteContext.
write(
" /", 2 ) )
159 OStringBuffer aFilter(
m_aName.getLength() );
160 const char* pStr =
m_aName.getStr();
161 unsigned int nLen =
m_aName.getLength();
162 for(
unsigned int i = 0;
i < nLen;
i++ )
164 if( (
i < nLen - 3) && pStr[
i] ==
'#' )
168 if( pStr[
i] >=
'0' && pStr[
i] <=
'9' )
169 rResult = char( pStr[
i]-
'0' ) << 4;
170 else if( pStr[
i] >=
'a' && pStr[
i] <=
'f' )
171 rResult = char( pStr[
i]-
'a' + 10 ) << 4;
172 else if( pStr[
i] >=
'A' && pStr[
i] <=
'F' )
173 rResult = char( pStr[
i]-
'A' + 10 ) << 4;
175 if( pStr[
i] >=
'0' && pStr[
i] <=
'9' )
176 rResult |= char( pStr[
i]-
'0' );
177 else if( pStr[
i] >=
'a' && pStr[
i] <=
'f' )
178 rResult |= char( pStr[
i]-
'a' + 10 );
179 else if( pStr[
i] >=
'A' && pStr[
i] <=
'F' )
180 rResult |= char( pStr[
i]-
'A' + 10 );
181 aFilter.append( rResult );
184 aFilter.append( pStr[
i] );
186 return OStringToOUString( aFilter, RTL_TEXTENCODING_UTF8 );
195 if( ! rWriteContext.
write(
" ", 1 ) )
203 pEData->
decrypt(
reinterpret_cast<sal_uInt8 const *
>(aFiltered.getStr()), aFiltered.getLength(),
204 reinterpret_cast<sal_uInt8 *
>(
const_cast<char *
>(aFiltered.getStr())),
207 const char* pStr = aFiltered.getStr();
208 if( aFiltered.getLength() > 1 &&
209 ( (
static_cast<unsigned char>(pStr[0]) == 0xff &&
static_cast<unsigned char>(pStr[1]) == 0xfe) ||
210 (
static_cast<unsigned char>(pStr[0]) == 0xfe &&
static_cast<unsigned char>(pStr[1]) == 0xff) ) )
212 static const char pHexTab[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
213 '8',
'9',
'A',
'B',
'C',
'D',
'E',
'F' };
214 if( ! rWriteContext.
write(
"<", 1 ) )
216 for( sal_Int32
i = 0;
i < aFiltered.getLength();
i++ )
218 if( ! rWriteContext.
write( pHexTab + ((sal_uInt32(pStr[
i]) >> 4) & 0x0f), 1 ) )
220 if( ! rWriteContext.
write( pHexTab + (sal_uInt32(pStr[
i]) & 0x0f), 1 ) )
223 if( ! rWriteContext.
write(
">", 1 ) )
228 if( ! rWriteContext.
write(
"(", 1 ) )
230 if( ! rWriteContext.
write( aFiltered.getStr(), aFiltered.getLength() ) )
232 if( ! rWriteContext.
write(
")", 1 ) )
248 OStringBuffer
aBuf( nLen );
253 const char* pRun = pStr+1;
254 while( pRun - pStr < nLen-1 )
259 if( pRun - pStr < nLen )
264 else if( *pRun ==
'r' )
266 else if( *pRun ==
't' )
268 else if( *pRun ==
'b' )
270 else if( *pRun ==
'f' )
272 else if( *pRun ==
'(' )
274 else if( *pRun ==
')' )
276 else if( *pRun ==
'\\' )
278 else if( *pRun ==
'\n' )
283 else if( *pRun ==
'\r' )
293 while(
i++ < 3 && *pRun >=
'0' && *pRun <=
'7' )
294 aEsc = 8*aEsc + (*pRun++ -
'0');
302 aBuf.append( *pRun );
307 else if( *pStr ==
'<' )
309 const char* pRun = pStr+1;
310 while( *pRun !=
'>' && pRun - pStr < nLen )
313 if( *pRun >=
'0' && *pRun <=
'9' )
314 rResult = char( ( *pRun-
'0' ) << 4 );
315 else if( *pRun >=
'a' && *pRun <=
'f' )
316 rResult = char( ( *pRun-
'a' + 10 ) << 4 );
317 else if( *pRun >=
'A' && *pRun <=
'F' )
318 rResult = char( ( *pRun-
'A' + 10 ) << 4 );
320 if( *pRun !=
'>' && pRun - pStr < nLen )
322 if( *pRun >=
'0' && *pRun <=
'9' )
323 rResult |= char( *pRun-
'0' );
324 else if( *pRun >=
'a' && *pRun <=
'f' )
325 rResult |= char( *pRun-
'a' + 10 );
326 else if( *pRun >=
'A' && *pRun <=
'F' )
327 rResult |= char( *pRun-
'A' + 10 );
330 aBuf.append( rResult );
334 return aBuf.makeStringAndClear();
343 OStringBuffer
aBuf( 32 );
355 sal_Int64 nInt =
static_cast<sal_Int64
>(fValue);
356 fValue -=
static_cast<double>(nInt);
358 if( fValue == 1.0 || log10( 1.0-fValue ) <= -nPrecision )
366 fValue *= pow( 10.0,
static_cast<double>(nPrecision) );
367 nFrac =
static_cast<sal_Int64
>(fValue);
369 if( bNeg && ( nInt || nFrac ) )
376 sal_Int64 nBound =
static_cast<sal_Int64
>(pow( 10.0, nPrecision - 1.0 )+0.5);
377 for (
i = 0; (
i < nPrecision ) && nFrac;
i++ )
379 sal_Int64 nNumb = nFrac / nBound;
380 nFrac -= nNumb * nBound;
381 aBuf.append( nNumb );
386 return rWriteContext.
write(
aBuf.getStr(),
aBuf.getLength() );
401 return m_bValue ? rWriteContext.
write(
" true", 5 ) : rWriteContext.
write(
" false", 6 );
415 return rWriteContext.
write(
" null", 5 );
432 OString::number( sal_Int32(
m_nNumber ) ) +
436 return rWriteContext.
write(
aBuf.getStr(),
aBuf.getLength() );
451 for(
int i = 0;
i < nEle;
i++ )
471 for(
int i = 0;
i < nEle;
i++ )
478 for(
unsigned int i = 0;
i < nEle;
i++ )
482 pObject->m_nNumber == nNumber &&
483 pObject->m_nGeneration == nGeneration )
497 if( ! rWriteContext.
write(
"[", 1 ) )
501 return rWriteContext.
write(
"]", 1 );
517 if( ! rWriteContext.
write(
"<<\n", 3 ) )
521 return rWriteContext.
write(
"\n>>\n", 4 );
530 std::unordered_map<OString,PDFEntry*>::iterator it =
m_aMap.find( rName );
541 for(
unsigned int i = 0;
i < nSub;
i++ )
550 m_aMap[ rName ] = pValueTmp;
556 for(
unsigned int i = 0;
i < nEle;
i++ )
561 for(
unsigned int j =
i+1; j < nEle; j++ )
583 for(
unsigned int i = 0;
i < nEle;
i++ )
626 std::unordered_map<OString,PDFEntry*>::const_iterator it =
631 if( ! pNum && pContainer )
637 for (
int i = 0;
i < nEle;
i++)
651 return pNum ?
static_cast<unsigned int>(pNum->
m_fValue) : 0;
660 bool bIsDeflated =
false;
666 rpStream.reset(
new char[ nOuterStreamLen ]);
668 if( nRead != nOuterStreamLen )
675 std::unordered_map<OString,PDFEntry*>::const_iterator it =
690 if (pFilter && pFilter->
m_aName ==
"FlateDecode")
696 char*
pStream = rpStream.get();
704 if(
pStream != rpStream.get() )
705 memmove( rpStream.get(),
pStream, *pBytes );
711 reinterpret_cast<sal_uInt8*
>(rpStream.get()),
725 sal_uInt8** pOutBuf, sal_uInt32* pOutLen )
728 aZStr.next_in =
reinterpret_cast<Bytef *
>(pBegin);
729 aZStr.avail_in = nLen;
730 aZStr.total_out = aZStr.total_in = 0;
731 aZStr.zalloc =
nullptr;
732 aZStr.zfree =
nullptr;
733 aZStr.opaque =
nullptr;
735 int err = inflateInit(&aZStr);
737 const unsigned int buf_increment_size = 16384;
739 if (
auto p =
static_cast<sal_uInt8*
>(std::realloc(*pOutBuf, buf_increment_size)))
742 aZStr.next_out =
reinterpret_cast<Bytef*
>(*pOutBuf);
743 aZStr.avail_out = buf_increment_size;
744 *pOutLen = buf_increment_size;
748 while(
err != Z_STREAM_END &&
err >= Z_OK && aZStr.avail_in )
750 err = inflate( &aZStr, Z_NO_FLUSH );
751 if( aZStr.avail_out == 0 )
753 if(
err != Z_STREAM_END )
755 const int nNewAlloc = *pOutLen + buf_increment_size;
756 if (
auto p =
static_cast<sal_uInt8*
>(std::realloc(*pOutBuf, nNewAlloc)))
759 aZStr.next_out =
reinterpret_cast<Bytef*
>(*pOutBuf + *pOutLen);
760 aZStr.avail_out = buf_increment_size;
761 *pOutLen = nNewAlloc;
768 if(
err == Z_STREAM_END )
770 if( aZStr.avail_out > 0 )
771 *pOutLen -= aZStr.avail_out;
776 std::free( *pOutBuf );
787 std::unique_ptr<char[]>
pStream;
788 unsigned int nBytes = 0;
792 sal_uInt32 nOutBytes = 0;
794 rWriteContext.
write( pOutBytes, nOutBytes );
795 std::free( pOutBytes );
803 if( ! rWriteContext.
write(
"\n", 1 ) )
811 OString::number( sal_Int32(
m_nNumber ) ) +
815 if( ! rWriteContext.
write(
aBuf.getStr(),
aBuf.getLength() ) )
822 std::unique_ptr<char[]>
pStream;
823 unsigned int nBytes = 0;
829 sal_uInt32 nOutBytes = 0;
836 nOutBytes =
static_cast<sal_uInt32
>(nBytes);
842 std::unique_ptr<PDFObject> pClone(
static_cast<PDFObject*
>(
clone()));
844 std::unique_ptr<PDFNumber> pNewLen(
new PDFNumber(
double(nOutBytes) ));
845 pClone->m_pStream->m_pDict->insertValue(
"Length", std::move(pNewLen) );
850 std::unordered_map<OString,PDFEntry*>::const_iterator it =
851 pClone->m_pStream->m_pDict->m_aMap.find(
"Filter" );
852 if( it != pClone->m_pStream->m_pDict->m_aMap.end() )
855 if (pFilter && pFilter->
m_aName ==
"FlateDecode")
856 pClone->m_pStream->m_pDict->eraseValue(
"Filter" );
863 if (pFilter && pFilter->
m_aName ==
"FlateDecode")
874 unsigned int nEle = pClone->m_aSubElements.size();
875 for(
unsigned int i = 0;
i < nEle && bRet;
i++ )
877 if( pClone->m_aSubElements[
i].get() != pClone->m_pStream )
878 bRet = pClone->m_aSubElements[
i]->emit( rWriteContext );
883 bRet = rWriteContext.
write(
"stream\n", 7)
884 && rWriteContext.
write(pOutBytes, nOutBytes)
885 && rWriteContext.
write(
"\nendstream\nendobj\n", 18);
887 std::free( pOutBytes );
892 std::free( pOutBytes );
897 rWriteContext.
write(
"\nendobj\n", 8 );
908 for(
unsigned int i = 0;
i < nEle;
i++ )
930 unsigned int nXRefPos = rWriteContext.
getCurPos();
932 if( ! rWriteContext.
write(
"xref\r\n"
934 "0000000000 65535 f\r\n", 31 ) )
942 EmitImplData::XRefTable::const_iterator section_begin, section_end;
943 section_begin = rXRefs.begin();
944 while( section_begin != rXRefs.end() )
947 section_end = section_begin;
948 unsigned int nLast = section_begin->first;
949 while( (++section_end) != rXRefs.end() &&
950 section_end->first == nLast+1 )
951 nLast = section_end->first;
954 OString::number(sal_Int32( section_begin->first ) )
956 + OString::number(sal_Int32(nLast - section_begin->first + 1))
958 if( ! rWriteContext.
write(
aBuf.getStr(),
aBuf.getLength() ) )
960 while( section_begin != section_end )
965 OString aOffset( OString::number( section_begin->second.second ) );
966 int nPad = 10 - aOffset.getLength();
967 for(
int i = 0;
i < nPad;
i++ )
969 aBuf.append( aOffset +
" " );
970 OString aGeneration( OString::number( section_begin->second.first ) );
971 nPad = 5 - aGeneration.getLength();
972 for(
int i = 0;
i < nPad;
i++ )
974 aBuf.append( aGeneration +
" n\r\n" );
975 if( ! rWriteContext.
write(
aBuf.getStr(), 20 ) )
981 if( ! rWriteContext.
write(
"trailer\n", 8 ) )
985 if( ! rWriteContext.
write(
"startxref\n", 10 ) )
987 OString aOffset( OString::number( nXRefPos ) );
988 if( ! rWriteContext.
write( aOffset.getStr(), aOffset.getLength() ) )
990 return rWriteContext.
write(
"\n%%EOF\n", 7 );
998 for(
unsigned int i = 0;
i < nEle;
i++ )
1009#define ENCRYPTION_KEY_LEN 16
1010#define ENCRYPTION_BUF_LEN 32
1048 : m_nMajor( 0 ), m_nMinor( 0 )
1062 unsigned int nObject,
unsigned int nGeneration )
const
1068 m_pData->m_aCipher = rtl_cipher_createARCFOUR( rtl_Cipher_ModeStream );
1071 sal_uInt32
i =
m_pData->m_nKeyLength;
1079 m_pData->m_aDecryptionKey,
i, ::comphelper::HashType::MD5));
1084 rtlCipherError aErr = rtl_cipher_initARCFOUR(
m_pData->m_aCipher,
1085 rtl_Cipher_DirectionDecode,
1088 if( aErr == rtl_Cipher_E_None )
1089 aErr = rtl_cipher_decodeARCFOUR(
m_pData->m_aCipher,
1092 return aErr == rtl_Cipher_E_None;
1097 0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41, 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08,
1098 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80, 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A
1103 int nLen = rStr.getLength();
1106 const char* pStr = rStr.getStr();
1107 memcpy( pBuffer, pStr, nLen );
1121 aDigest.
update(
reinterpret_cast<unsigned char const*
>(aPadPwd),
sizeof(aPadPwd));
1127 aPEntry[1] =
static_cast<sal_uInt8>((
pData->m_nPEntry >> 8 ) & 0xff);
1128 aPEntry[2] =
static_cast<sal_uInt8>((
pData->m_nPEntry >> 16) & 0xff);
1129 aPEntry[3] =
static_cast<sal_uInt8>((
pData->m_nPEntry >> 24) & 0xff);
1130 aDigest.
update(aPEntry,
sizeof(aPEntry));
1131 aDigest.
update(
reinterpret_cast<unsigned char const*
>(
pData->m_aDocID.getStr()),
pData->m_aDocID.getLength());
1133 ::std::vector<unsigned char> nSum(aDigest.
finalize());
1134 if(
pData->m_nStandardRevision == 3 )
1136 for(
int i = 0;
i < 50;
i++ )
1139 ::comphelper::HashType::MD5);
1142 sal_uInt32 nLen =
pData->m_nKeyLength;
1143 if( nLen > RTL_DIGEST_LENGTH_MD5 )
1144 nLen = RTL_DIGEST_LENGTH_MD5;
1145 memcpy( pOutKey, nSum.data(), nLen );
1152 bool bValid =
false;
1156 memcpy(
pData->m_aDecryptionKey, aKey, nKeyLen );
1157 if(
pData->m_nStandardRevision == 2 )
1162 if (rtl_cipher_initARCFOUR(
pData->m_aCipher, rtl_Cipher_DirectionEncode,
1165 != rtl_Cipher_E_None)
1170 nEncryptedEntry,
sizeof( nEncryptedEntry ) );
1171 bValid = (memcmp( nEncryptedEntry,
pData->m_aUEntry, 32 ) == 0);
1173 else if(
pData->m_nStandardRevision == 3 )
1178 aDigest.
update(
reinterpret_cast<unsigned char const*
>(
pData->m_aDocID.getStr()),
pData->m_aDocID.getLength());
1179 ::std::vector<unsigned char> nEncryptedEntry(aDigest.
finalize());
1180 if (rtl_cipher_initARCFOUR(
pData->m_aCipher, rtl_Cipher_DirectionEncode,
1181 aKey,
sizeof(aKey),
nullptr, 0 )
1182 != rtl_Cipher_E_None)
1186 rtl_cipher_encodeARCFOUR(
pData->m_aCipher,
1187 nEncryptedEntry.data(), 16,
1188 nEncryptedEntry.data(), 16 );
1189 for(
int i = 1;
i <= 19;
i++ )
1192 for(
size_t j = 0; j <
sizeof(aTempKey); j++ )
1193 aTempKey[j] =
static_cast<sal_uInt8>( aKey[j] ^
i );
1195 if (rtl_cipher_initARCFOUR(
pData->m_aCipher, rtl_Cipher_DirectionEncode,
1196 aTempKey,
sizeof(aTempKey),
nullptr, 0 )
1197 != rtl_Cipher_E_None)
1201 rtl_cipher_encodeARCFOUR(
pData->m_aCipher,
1202 nEncryptedEntry.data(), 16,
1203 nEncryptedEntry.data(), 16 );
1205 bValid = (memcmp( nEncryptedEntry.data(),
pData->m_aUEntry, 16 ) == 0);
1212 return m_pData->m_bStandardHandler &&
1213 m_pData->m_nAlgoVersion >= 1 &&
1214 m_pData->m_nAlgoVersion <= 2 &&
1215 m_pData->m_nStandardRevision >= 2 &&
1216 m_pData->m_nStandardRevision <= 3;
1222 return rPwd.isEmpty();
1229 m_pData->m_aCipher = rtl_cipher_createARCFOUR(rtl_Cipher_ModeStream);
1241 if(
m_pData->m_nStandardRevision == 2 )
1243 if (rtl_cipher_initARCFOUR(
m_pData->m_aCipher, rtl_Cipher_DirectionDecode,
1244 aKey, nKeyLen,
nullptr, 0 )
1245 != rtl_Cipher_E_None)
1249 rtl_cipher_decodeARCFOUR(
m_pData->m_aCipher,
1253 else if(
m_pData->m_nStandardRevision == 3 )
1255 memcpy( nPwd,
m_pData->m_aOEntry, 32 );
1256 for(
int i = 19;
i >= 0;
i-- )
1259 for(
size_t j = 0; j <
sizeof(nTempKey); j++ )
1261 if (rtl_cipher_initARCFOUR(
m_pData->m_aCipher, rtl_Cipher_DirectionDecode,
1262 nTempKey, nKeyLen,
nullptr, 0 )
1263 != rtl_Cipher_E_None)
1267 rtl_cipher_decodeARCFOUR(
m_pData->m_aCipher,
1288 if( pTrailer && pTrailer->
m_pDict )
1291 PDFDict::Map::iterator doc_id = pTrailer->
m_pDict->
m_aMap.find(
"ID" );
1300#if OSL_DEBUG_LEVEL > 0
1301 OUStringBuffer aTmp;
1302 for(
int i = 0;
i <
m_pData->m_aDocID.getLength();
i++ )
1304 SAL_INFO(
"sdext.pdfimport.pdfparse",
"DocId is <" << aTmp.makeStringAndClear() <<
">");
1309 PDFDict::Map::iterator enc =
1326 PDFDict::Map::iterator
filter = pDict->
m_aMap.find(
"Filter" );
1327 PDFDict::Map::iterator version = pDict->
m_aMap.find(
"V" );
1328 PDFDict::Map::iterator len = pDict->
m_aMap.find(
"Length" );
1329 PDFDict::Map::iterator o_ent = pDict->
m_aMap.find(
"O" );
1330 PDFDict::Map::iterator u_ent = pDict->
m_aMap.find(
"U" );
1331 PDFDict::Map::iterator r_ent = pDict->
m_aMap.find(
"R" );
1332 PDFDict::Map::iterator p_ent = pDict->
m_aMap.find(
"P" );
1335 m_pData->m_bIsEncrypted =
true;
1337 if( version != pDict->
m_aMap.end() )
1343 if(
m_pData->m_nAlgoVersion >= 3 )
1345 if( len != pDict->
m_aMap.end() )
1353 m_pData->m_bStandardHandler =
true;
1354 if( o_ent != pDict->
m_aMap.end() )
1360 if( aEnt.getLength() == 32 )
1361 memcpy(
m_pData->m_aOEntry, aEnt.getStr(), 32 );
1362#if OSL_DEBUG_LEVEL > 0
1365 OUStringBuffer aTmp;
1366 for(
int i = 0;
i < aEnt.getLength();
i++ )
1367 aTmp.append(
" " + OUString::number(
sal_uInt8(aEnt[
i]), 16));
1368 SAL_WARN(
"sdext.pdfimport.pdfparse",
1369 "O entry has length " <<
static_cast<int>(aEnt.getLength()) <<
", should be 32 <" << aTmp.makeStringAndClear() <<
">" );
1374 if( u_ent != pDict->
m_aMap.end() )
1380 if( aEnt.getLength() == 32 )
1381 memcpy(
m_pData->m_aUEntry, aEnt.getStr(), 32 );
1382#if OSL_DEBUG_LEVEL > 0
1385 OUStringBuffer aTmp;
1386 for(
int i = 0;
i < aEnt.getLength();
i++ )
1387 aTmp.append(
" " + OUString::number(
sal_uInt8(aEnt[
i]), 16));
1388 SAL_WARN(
"sdext.pdfimport.pdfparse",
1389 "U entry has length " <<
static_cast<int>(aEnt.getLength()) <<
", should be 32 <" << aTmp.makeStringAndClear() <<
">" );
1394 if( r_ent != pDict->
m_aMap.end() )
1398 m_pData->m_nStandardRevision =
static_cast<sal_uInt32
>(pNum->
m_fValue);
1400 if( p_ent != pDict->
m_aMap.end() )
1404 m_pData->m_nPEntry =
static_cast<sal_uInt32
>(
static_cast<sal_Int32
>(pNum->
m_fValue));
1405 SAL_INFO(
"sdext.pdfimport.pdfparse",
"p entry is " <<
m_pData->m_nPEntry );
1408 SAL_INFO(
"sdext.pdfimport.pdfparse",
"Encryption dict: sec handler: " << (pFilter ? pFilter->
getFilteredName() : OUString(
"<unknown>")) <<
", version = " <<
static_cast<int>(
m_pData->m_nAlgoVersion) <<
", revision = " <<
static_cast<int>(
m_pData->m_nStandardRevision) <<
", key length = " <<
m_pData->m_nKeyLength );
1425 OString::number( sal_Int32(
m_nMajor ) ) +
1427 OString::number( sal_Int32(
m_nMinor ) ) +
1429 if( ! rWriteContext.
write(
aBuf.getStr(),
aBuf.getLength() ) )
std::vector< unsigned char > finalize()
static std::vector< unsigned char > calculateHash(const unsigned char *pInput, size_t length, HashType eType)
void update(const unsigned char *pInput, size_t length)
virtual bool copyOrigBytes(unsigned int nOrigOffset, unsigned int nLen)=0
virtual unsigned int readOrigBytes(unsigned int nOrigOffset, unsigned int nLen, void *pBuf)=0
virtual bool write(const void *pBuf, unsigned int nLen)=0
std::unique_ptr< EmitImplData > m_pImplData
virtual unsigned int getCurPos()=0
EmbeddedObjectRef * pObject
static osl::File * pStream
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::unique_ptr< sal_Int32[]> pData
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
#define ENCRYPTION_BUF_LEN
static sal_uInt32 password_to_key(const OString &rPwd, sal_uInt8 *pOutKey, PDFFileImplData const *pData, bool bComputeO)
const sal_uInt8 nPadString[32]
#define ENCRYPTION_KEY_LEN
static bool check_user_password(const OString &rPwd, PDFFileImplData *pData)
static void pad_or_truncate_to_32(const OString &rStr, char *pBuffer)
static void unzipToBuffer(char *pBegin, unsigned int nLen, sal_uInt8 **pOutBuf, sal_uInt32 *pOutLen)
EmitImplData(const PDFContainer *pTopContainer)
void setDecryptObject(unsigned int nObject, unsigned int nGeneration)
const PDFContainer * m_pObjectContainer
unsigned int m_nDecryptGeneration
void decrypt(const sal_uInt8 *pInBuffer, sal_uInt32 nLen, sal_uInt8 *pOutBuffer, unsigned int nObject, unsigned int nGeneration) const
bool insertXref(unsigned int nObject, unsigned int nGeneration, unsigned int nOffset)
unsigned int m_nDecryptObject
std::map< unsigned int, std::pair< unsigned int, unsigned int > > XRefTable
virtual bool emit(EmitContext &rWriteContext) const override
virtual ~PDFArray() override
virtual PDFEntry * clone() const override
virtual PDFEntry * clone() const override
virtual ~PDFBool() override
virtual bool emit(EmitContext &rWriteContext) const override
bool emitSubElements(EmitContext &rWriteContext) const
PDFObject * findObject(unsigned int nNumber, unsigned int nGeneration) const
void cloneSubElements(std::vector< std::unique_ptr< PDFEntry > > &rNewSubElements) const
std::vector< std::unique_ptr< PDFEntry > > m_aSubElements
virtual ~PDFContainer() override
void eraseValue(std::string_view rName)
void insertValue(const OString &rName, std::unique_ptr< PDFEntry > pValue)
virtual bool emit(EmitContext &rWriteContext) const override
virtual PDFEntry * clone() const override
virtual ~PDFDict() override
virtual bool emit(EmitContext &rWriteContext) const =0
static void setEmitData(EmitContext &rContext, EmitImplData *pNewEmitData)
static EmitImplData * getEmitData(EmitContext const &rContext)
sal_uInt8 m_aDecryptionKey[ENCRYPTION_KEY_LEN+5]
sal_uInt32 m_nStandardRevision
sal_uInt32 m_nAlgoVersion
bool usesSupportedEncryptionFormat() const
virtual bool emit(EmitContext &rWriteContext) const override
bool setupDecryptionData(const OString &rPwd) const
bool decrypt(const sal_uInt8 *pInBuffer, sal_uInt32 nLen, sal_uInt8 *pOutBuffer, unsigned int nObject, unsigned int nGeneration) const
virtual ~PDFFile() override
std::unique_ptr< PDFFileImplData > m_pData
virtual PDFEntry * clone() const override
PDFFileImplData * impl_getData() const
virtual PDFEntry * clone() const override
virtual bool emit(EmitContext &rWriteContext) const override
OUString getFilteredName() const
virtual ~PDFName() override
virtual PDFEntry * clone() const override
virtual ~PDFNull() override
virtual bool emit(EmitContext &rWriteContext) const override
virtual PDFEntry * clone() const override
virtual ~PDFNumber() override
virtual bool emit(EmitContext &rWriteContext) const override
PDFObjectRef(unsigned int nNr, unsigned int nGen)
virtual PDFEntry * clone() const override
unsigned int m_nGeneration
virtual ~PDFObjectRef() override
virtual bool emit(EmitContext &rWriteContext) const override
unsigned int m_nGeneration
PDFObject(unsigned int nNr, unsigned int nGen)
virtual bool emit(EmitContext &rWriteContext) const override
virtual ~PDFObject() override
bool getDeflatedStream(std::unique_ptr< char[]> &rpStream, unsigned int *pBytes, const PDFContainer *pObjectContainer, EmitContext &rContext) const
void writeStream(EmitContext &rContext, const PDFFile *pPDFFile) const
virtual PDFEntry * clone() const override
virtual ~PDFPart() override
virtual bool emit(EmitContext &rWriteContext) const override
virtual PDFEntry * clone() const override
virtual bool emit(EmitContext &rWriteContext) const override
unsigned int getDictLength(const PDFContainer *pObjectContainer) const
PDFStream(unsigned int nBegin, unsigned int nEnd, PDFDict *pStreamDict)
virtual ~PDFStream() override
virtual PDFEntry * clone() const override
unsigned int m_nBeginOffset
unsigned int m_nEndOffset
virtual bool emit(EmitContext &rWriteContext) const override
virtual ~PDFString() override
PDFString(OString aString)
OString getFilteredString() const
virtual PDFEntry * clone() const override
virtual bool emit(EmitContext &rWriteContext) const override
virtual PDFEntry * clone() const override
virtual ~PDFTrailer() override
virtual ~PDFValue() override