| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
| 8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
| 9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
| 10 #include "pageint.h" | 10 #include "pageint.h" |
| 11 #include <limits.h> | 11 #include <limits.h> |
| 12 const FX_CHAR* const _PDF_OpCharType = | 12 const FX_CHAR* const _PDF_OpCharType = |
| 13 "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" | 13 "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" |
| 14 "IIVIIIIVIIVIIIIIVVIIIIIIIIIIIIII" | 14 "IIVIIIIVIIVIIIIIVVIIIIIIIIIIIIII" |
| 15 "IIVVVVVVIVVVVVVIVVVVVIIVVIIIIIII" | 15 "IIVVVVVVIVVVVVVIVVVVVIIVVIIIIIII" |
| 16 "IIVVVVVVVVVVVVVVIVVVIIVVIVVIIIII" | 16 "IIVVVVVVVVVVVVVVIVVVIIVVIVVIIIII" |
| 17 "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" | 17 "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" |
| 18 "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" | 18 "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" |
| 19 "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" | 19 "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" |
| 20 "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"; | 20 "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"; |
| 21 bool _PDF_HasInvalidOpChar(const FX_CHAR* op) | 21 FX_BOOL _PDF_HasInvalidOpChar(const FX_CHAR* op) |
| 22 { | 22 { |
| 23 if(!op) { | 23 if(!op) { |
| 24 return false; | 24 return FALSE; |
| 25 } | 25 } |
| 26 uint8_t ch; | 26 uint8_t ch; |
| 27 while((ch = *op++)) { | 27 while((ch = *op++)) { |
| 28 if(_PDF_OpCharType[ch] == 'I') { | 28 if(_PDF_OpCharType[ch] == 'I') { |
| 29 return true; | 29 return TRUE; |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 return false; | 32 return FALSE; |
| 33 } | 33 } |
| 34 class CPDF_StreamParserAutoClearer { | 34 class CPDF_StreamParserAutoClearer { |
| 35 public: | 35 public: |
| 36 CPDF_StreamParserAutoClearer(CPDF_StreamParser** scoped_variable, CPDF_Strea
mParser* new_parser) | 36 CPDF_StreamParserAutoClearer(CPDF_StreamParser** scoped_variable, CPDF_Strea
mParser* new_parser) |
| 37 : scoped_variable_(scoped_variable) { | 37 : scoped_variable_(scoped_variable) { |
| 38 *scoped_variable_ = new_parser; | 38 *scoped_variable_ = new_parser; |
| 39 } | 39 } |
| 40 ~CPDF_StreamParserAutoClearer() { *scoped_variable_ = NULL; } | 40 ~CPDF_StreamParserAutoClearer() { *scoped_variable_ = NULL; } |
| 41 private: | 41 private: |
| 42 CPDF_StreamParser** scoped_variable_; | 42 CPDF_StreamParser** scoped_variable_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 53 while (1) { | 53 while (1) { |
| 54 FX_DWORD cost = m_pObjectList->CountObjects() - InitObjCount; | 54 FX_DWORD cost = m_pObjectList->CountObjects() - InitObjCount; |
| 55 if (max_cost && cost >= max_cost) { | 55 if (max_cost && cost >= max_cost) { |
| 56 break; | 56 break; |
| 57 } | 57 } |
| 58 switch (syntax.ParseNextElement()) { | 58 switch (syntax.ParseNextElement()) { |
| 59 case CPDF_StreamParser::EndOfData: | 59 case CPDF_StreamParser::EndOfData: |
| 60 return m_pSyntax->GetPos(); | 60 return m_pSyntax->GetPos(); |
| 61 case CPDF_StreamParser::Keyword: | 61 case CPDF_StreamParser::Keyword: |
| 62 if(!OnOperator((char*)syntax.GetWordBuf()) && _PDF_HasInvalidOpC
har((char*)syntax.GetWordBuf())) { | 62 if(!OnOperator((char*)syntax.GetWordBuf()) && _PDF_HasInvalidOpC
har((char*)syntax.GetWordBuf())) { |
| 63 m_bAbort = true; | 63 m_bAbort = TRUE; |
| 64 } | 64 } |
| 65 if (m_bAbort) { | 65 if (m_bAbort) { |
| 66 return m_pSyntax->GetPos(); | 66 return m_pSyntax->GetPos(); |
| 67 } | 67 } |
| 68 ClearAllParams(); | 68 ClearAllParams(); |
| 69 break; | 69 break; |
| 70 case CPDF_StreamParser::Number: | 70 case CPDF_StreamParser::Number: |
| 71 AddNumberParam((char*)syntax.GetWordBuf(), syntax.GetWordSize())
; | 71 AddNumberParam((char*)syntax.GetWordBuf(), syntax.GetWordSize())
; |
| 72 break; | 72 break; |
| 73 case CPDF_StreamParser::Name: | 73 case CPDF_StreamParser::Name: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 if (m_Options.m_bTextOnly) { | 137 if (m_Options.m_bTextOnly) { |
| 138 if (pStream) { | 138 if (pStream) { |
| 139 pStream->Release(); | 139 pStream->Release(); |
| 140 } else { | 140 } else { |
| 141 pDict->Release(); | 141 pDict->Release(); |
| 142 } | 142 } |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 pDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Image")); | 145 pDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Image")); |
| 146 CPDF_ImageObject *pImgObj = AddImage(pStream, NULL, true); | 146 CPDF_ImageObject *pImgObj = AddImage(pStream, NULL, TRUE); |
| 147 if (!pImgObj) { | 147 if (!pImgObj) { |
| 148 if (pStream) { | 148 if (pStream) { |
| 149 pStream->Release(); | 149 pStream->Release(); |
| 150 } else { | 150 } else { |
| 151 pDict->Release(); | 151 pDict->Release(); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 void CPDF_StreamContentParser::ParsePathObject() | 155 void CPDF_StreamContentParser::ParsePathObject() |
| 156 { | 156 { |
| 157 FX_FLOAT params[6] = {}; | 157 FX_FLOAT params[6] = {}; |
| 158 int nParams = 0; | 158 int nParams = 0; |
| 159 int last_pos = m_pSyntax->GetPos(); | 159 int last_pos = m_pSyntax->GetPos(); |
| 160 while (1) { | 160 while (1) { |
| 161 CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement(); | 161 CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement(); |
| 162 bool bProcessed = true; | 162 FX_BOOL bProcessed = TRUE; |
| 163 switch (type) { | 163 switch (type) { |
| 164 case CPDF_StreamParser::EndOfData: | 164 case CPDF_StreamParser::EndOfData: |
| 165 return; | 165 return; |
| 166 case CPDF_StreamParser::Keyword: { | 166 case CPDF_StreamParser::Keyword: { |
| 167 int len = m_pSyntax->GetWordSize(); | 167 int len = m_pSyntax->GetWordSize(); |
| 168 if (len == 1) { | 168 if (len == 1) { |
| 169 switch (m_pSyntax->GetWordBuf()[0]) { | 169 switch (m_pSyntax->GetWordBuf()[0]) { |
| 170 case 'm': | 170 case 'm': |
| 171 AddPathPoint(params[0], params[1], FXPT_MOVETO); | 171 AddPathPoint(params[0], params[1], FXPT_MOVETO); |
| 172 nParams = 0; | 172 nParams = 0; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 191 AddPathPoint(params[0], params[1], FXPT_BEZIERTO
); | 191 AddPathPoint(params[0], params[1], FXPT_BEZIERTO
); |
| 192 AddPathPoint(params[2], params[3], FXPT_BEZIERTO
); | 192 AddPathPoint(params[2], params[3], FXPT_BEZIERTO
); |
| 193 AddPathPoint(params[2], params[3], FXPT_BEZIERTO
); | 193 AddPathPoint(params[2], params[3], FXPT_BEZIERTO
); |
| 194 nParams = 0; | 194 nParams = 0; |
| 195 break; | 195 break; |
| 196 case 'h': | 196 case 'h': |
| 197 Handle_ClosePath(); | 197 Handle_ClosePath(); |
| 198 nParams = 0; | 198 nParams = 0; |
| 199 break; | 199 break; |
| 200 default: | 200 default: |
| 201 bProcessed = false; | 201 bProcessed = FALSE; |
| 202 break; | 202 break; |
| 203 } | 203 } |
| 204 } else if (len == 2) { | 204 } else if (len == 2) { |
| 205 if (m_pSyntax->GetWordBuf()[0] == 'r' && m_pSyntax->GetW
ordBuf()[1] == 'e') { | 205 if (m_pSyntax->GetWordBuf()[0] == 'r' && m_pSyntax->GetW
ordBuf()[1] == 'e') { |
| 206 AddPathRect(params[0], params[1], params[2], params[
3]); | 206 AddPathRect(params[0], params[1], params[2], params[
3]); |
| 207 nParams = 0; | 207 nParams = 0; |
| 208 } else { | 208 } else { |
| 209 bProcessed = false; | 209 bProcessed = FALSE; |
| 210 } | 210 } |
| 211 } else { | 211 } else { |
| 212 bProcessed = false; | 212 bProcessed = FALSE; |
| 213 } | 213 } |
| 214 if (bProcessed) { | 214 if (bProcessed) { |
| 215 last_pos = m_pSyntax->GetPos(); | 215 last_pos = m_pSyntax->GetPos(); |
| 216 } | 216 } |
| 217 break; | 217 break; |
| 218 } | 218 } |
| 219 case CPDF_StreamParser::Number: { | 219 case CPDF_StreamParser::Number: { |
| 220 if (nParams == 6) { | 220 if (nParams == 6) { |
| 221 break; | 221 break; |
| 222 } | 222 } |
| 223 bool bInteger; | 223 FX_BOOL bInteger; |
| 224 int value; | 224 int value; |
| 225 FX_atonum(CFX_ByteStringC(m_pSyntax->GetWordBuf(), m_pSyntax
->GetWordSize()), bInteger, &value); | 225 FX_atonum(CFX_ByteStringC(m_pSyntax->GetWordBuf(), m_pSyntax
->GetWordSize()), bInteger, &value); |
| 226 params[nParams++] = bInteger ? (FX_FLOAT)value : *(FX_FLOAT*
)&value; | 226 params[nParams++] = bInteger ? (FX_FLOAT)value : *(FX_FLOAT*
)&value; |
| 227 break; | 227 break; |
| 228 } | 228 } |
| 229 default: | 229 default: |
| 230 bProcessed = false; | 230 bProcessed = FALSE; |
| 231 } | 231 } |
| 232 if (!bProcessed) { | 232 if (!bProcessed) { |
| 233 m_pSyntax->SetPos(last_pos); | 233 m_pSyntax->SetPos(last_pos); |
| 234 return; | 234 return; |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, FX_DWORD dwSize) | 238 CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, FX_DWORD dwSize) |
| 239 { | 239 { |
| 240 m_pBuf = pData; | 240 m_pBuf = pData; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 FXSYS_memcpy(dest_buf + row * pitch, pLine, pitch); | 272 FXSYS_memcpy(dest_buf + row * pitch, pLine, pitch); |
| 273 } | 273 } |
| 274 FX_DWORD srcoff = pDecoder->GetSrcOffset(); | 274 FX_DWORD srcoff = pDecoder->GetSrcOffset(); |
| 275 delete pDecoder; | 275 delete pDecoder; |
| 276 return srcoff; | 276 return srcoff; |
| 277 } | 277 } |
| 278 ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(const uint8_t* src_buf, FX_DWOR
D src_size, int width, int height, | 278 ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(const uint8_t* src_buf, FX_DWOR
D src_size, int width, int height, |
| 279 const CPDF_Dictionary* pParams); | 279 const CPDF_Dictionary* pParams); |
| 280 FX_DWORD _A85Decode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_bu
f, FX_DWORD& dest_size); | 280 FX_DWORD _A85Decode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_bu
f, FX_DWORD& dest_size); |
| 281 FX_DWORD _HexDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_bu
f, FX_DWORD& dest_size); | 281 FX_DWORD _HexDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_bu
f, FX_DWORD& dest_size); |
| 282 FX_DWORD FPDFAPI_FlateOrLZWDecode(bool bLZW, const uint8_t* src_buf, FX_DWORD sr
c_size, CPDF_Dictionary* pParams, | 282 FX_DWORD FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, const uint8_t* src_buf, FX_DWORD
src_size, CPDF_Dictionary* pParams, |
| 283 FX_DWORD estimated_size, uint8_t*& dest_buf, F
X_DWORD& dest_size); | 283 FX_DWORD estimated_size, uint8_t*& dest_buf, F
X_DWORD& dest_size); |
| 284 FX_DWORD PDF_DecodeInlineStream(const uint8_t* src_buf, FX_DWORD limit, | 284 FX_DWORD PDF_DecodeInlineStream(const uint8_t* src_buf, FX_DWORD limit, |
| 285 int width, int height, CFX_ByteString& decoder, | 285 int width, int height, CFX_ByteString& decoder, |
| 286 CPDF_Dictionary* pParam, uint8_t*& dest_buf, FX_
DWORD& dest_size) | 286 CPDF_Dictionary* pParam, uint8_t*& dest_buf, FX_
DWORD& dest_size) |
| 287 { | 287 { |
| 288 if (decoder == FX_BSTRC("CCITTFaxDecode") || decoder == FX_BSTRC("CCF")) { | 288 if (decoder == FX_BSTRC("CCITTFaxDecode") || decoder == FX_BSTRC("CCF")) { |
| 289 ICodec_ScanlineDecoder* pDecoder = FPDFAPI_CreateFaxDecoder(src_buf, lim
it, width, height, pParam); | 289 ICodec_ScanlineDecoder* pDecoder = FPDFAPI_CreateFaxDecoder(src_buf, lim
it, width, height, pParam); |
| 290 return _DecodeAllScanlines(pDecoder, dest_buf, dest_size); | 290 return _DecodeAllScanlines(pDecoder, dest_buf, dest_size); |
| 291 } | 291 } |
| 292 if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) { | 292 if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) { |
| 293 return _A85Decode(src_buf, limit, dest_buf, dest_size); | 293 return _A85Decode(src_buf, limit, dest_buf, dest_size); |
| 294 } | 294 } |
| 295 if (decoder == FX_BSTRC("ASCIIHexDecode") || decoder == FX_BSTRC("AHx")) { | 295 if (decoder == FX_BSTRC("ASCIIHexDecode") || decoder == FX_BSTRC("AHx")) { |
| 296 return _HexDecode(src_buf, limit, dest_buf, dest_size); | 296 return _HexDecode(src_buf, limit, dest_buf, dest_size); |
| 297 } | 297 } |
| 298 if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) { | 298 if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) { |
| 299 return FPDFAPI_FlateOrLZWDecode(false, src_buf, limit, pParam, dest_size
, dest_buf, dest_size); | 299 return FPDFAPI_FlateOrLZWDecode(FALSE, src_buf, limit, pParam, dest_size
, dest_buf, dest_size); |
| 300 } | 300 } |
| 301 if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) { | 301 if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) { |
| 302 return FPDFAPI_FlateOrLZWDecode(true, src_buf, limit, pParam, 0, dest_bu
f, dest_size); | 302 return FPDFAPI_FlateOrLZWDecode(TRUE, src_buf, limit, pParam, 0, dest_bu
f, dest_size); |
| 303 } | 303 } |
| 304 if (decoder == FX_BSTRC("DCTDecode") || decoder == FX_BSTRC("DCT")) { | 304 if (decoder == FX_BSTRC("DCTDecode") || decoder == FX_BSTRC("DCT")) { |
| 305 ICodec_ScanlineDecoder* pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule(
)->CreateDecoder( | 305 ICodec_ScanlineDecoder* pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule(
)->CreateDecoder( |
| 306 src_buf, limit, width, height, 0, pParam ? pParam->GetInteger(FX_BST
RC("ColorTransform"), 1) : 1); | 306 src_buf, limit, width, height, 0, pParam ? pParam->GetInteger(FX_BST
RC("ColorTransform"), 1) : 1); |
| 307 return _DecodeAllScanlines(pDecoder, dest_buf, dest_size); | 307 return _DecodeAllScanlines(pDecoder, dest_buf, dest_size); |
| 308 } | 308 } |
| 309 if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL")) { | 309 if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL")) { |
| 310 return RunLengthDecode(src_buf, limit, dest_buf, dest_size); | 310 return RunLengthDecode(src_buf, limit, dest_buf, dest_size); |
| 311 } | 311 } |
| 312 dest_size = 0; | 312 dest_size = 0; |
| 313 dest_buf = 0; | 313 dest_buf = 0; |
| 314 return (FX_DWORD) - 1; | 314 return (FX_DWORD) - 1; |
| 315 } | 315 } |
| 316 CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, CPDF_Dicti
onary* pDict, CPDF_Object* pCSObj, bool bDecode) | 316 CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, CPDF_Dicti
onary* pDict, CPDF_Object* pCSObj, FX_BOOL bDecode) |
| 317 { | 317 { |
| 318 if (m_Pos == m_Size) { | 318 if (m_Pos == m_Size) { |
| 319 return NULL; | 319 return NULL; |
| 320 } | 320 } |
| 321 if (PDF_CharType[m_pBuf[m_Pos]] == 'W') { | 321 if (PDF_CharType[m_pBuf[m_Pos]] == 'W') { |
| 322 m_Pos ++; | 322 m_Pos ++; |
| 323 } | 323 } |
| 324 CFX_ByteString Decoder; | 324 CFX_ByteString Decoder; |
| 325 CPDF_Dictionary* pParam = NULL; | 325 CPDF_Dictionary* pParam = NULL; |
| 326 CPDF_Object* pFilter = pDict->GetElementValue(FX_BSTRC("Filter")); | 326 CPDF_Object* pFilter = pDict->GetElementValue(FX_BSTRC("Filter")); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 #define FXDWORD_TRUE FXDWORD_FROM_LSBFIRST(0x65757274) | 440 #define FXDWORD_TRUE FXDWORD_FROM_LSBFIRST(0x65757274) |
| 441 #define FXDWORD_NULL FXDWORD_FROM_LSBFIRST(0x6c6c756e) | 441 #define FXDWORD_NULL FXDWORD_FROM_LSBFIRST(0x6c6c756e) |
| 442 #define FXDWORD_FALS FXDWORD_FROM_LSBFIRST(0x736c6166) | 442 #define FXDWORD_FALS FXDWORD_FROM_LSBFIRST(0x736c6166) |
| 443 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() | 443 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() |
| 444 { | 444 { |
| 445 if (m_pLastObj) { | 445 if (m_pLastObj) { |
| 446 m_pLastObj->Release(); | 446 m_pLastObj->Release(); |
| 447 m_pLastObj = NULL; | 447 m_pLastObj = NULL; |
| 448 } | 448 } |
| 449 m_WordSize = 0; | 449 m_WordSize = 0; |
| 450 bool bIsNumber = true; | 450 FX_BOOL bIsNumber = TRUE; |
| 451 if (m_Pos >= m_Size) { | 451 if (m_Pos >= m_Size) { |
| 452 return EndOfData; | 452 return EndOfData; |
| 453 } | 453 } |
| 454 int ch = m_pBuf[m_Pos++]; | 454 int ch = m_pBuf[m_Pos++]; |
| 455 int type = PDF_CharType[ch]; | 455 int type = PDF_CharType[ch]; |
| 456 while (1) { | 456 while (1) { |
| 457 while (type == 'W') { | 457 while (type == 'W') { |
| 458 if (m_Size <= m_Pos) { | 458 if (m_Size <= m_Pos) { |
| 459 return EndOfData; | 459 return EndOfData; |
| 460 } | 460 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 478 if (type == 'D' && ch != '/') { | 478 if (type == 'D' && ch != '/') { |
| 479 m_Pos --; | 479 m_Pos --; |
| 480 m_pLastObj = ReadNextObject(); | 480 m_pLastObj = ReadNextObject(); |
| 481 return Others; | 481 return Others; |
| 482 } | 482 } |
| 483 while (1) { | 483 while (1) { |
| 484 if (m_WordSize < MAX_WORD_BUFFER) { | 484 if (m_WordSize < MAX_WORD_BUFFER) { |
| 485 m_WordBuffer[m_WordSize++] = ch; | 485 m_WordBuffer[m_WordSize++] = ch; |
| 486 } | 486 } |
| 487 if (type != 'N') { | 487 if (type != 'N') { |
| 488 bIsNumber = false; | 488 bIsNumber = FALSE; |
| 489 } | 489 } |
| 490 if (m_Size <= m_Pos) { | 490 if (m_Size <= m_Pos) { |
| 491 break; | 491 break; |
| 492 } | 492 } |
| 493 ch = m_pBuf[m_Pos++]; | 493 ch = m_pBuf[m_Pos++]; |
| 494 type = PDF_CharType[ch]; | 494 type = PDF_CharType[ch]; |
| 495 if (type == 'D' || type == 'W') { | 495 if (type == 'D' || type == 'W') { |
| 496 m_Pos --; | 496 m_Pos --; |
| 497 break; | 497 break; |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 m_WordBuffer[m_WordSize] = 0; | 500 m_WordBuffer[m_WordSize] = 0; |
| 501 if (bIsNumber) { | 501 if (bIsNumber) { |
| 502 return Number; | 502 return Number; |
| 503 } | 503 } |
| 504 if (m_WordBuffer[0] == '/') { | 504 if (m_WordBuffer[0] == '/') { |
| 505 return Name; | 505 return Name; |
| 506 } | 506 } |
| 507 if (m_WordSize == 4) { | 507 if (m_WordSize == 4) { |
| 508 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_TRUE) { | 508 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_TRUE) { |
| 509 m_pLastObj = CPDF_Boolean::Create(true); | 509 m_pLastObj = CPDF_Boolean::Create(TRUE); |
| 510 return Others; | 510 return Others; |
| 511 } | 511 } |
| 512 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_NULL) { | 512 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_NULL) { |
| 513 m_pLastObj = CPDF_Null::Create(); | 513 m_pLastObj = CPDF_Null::Create(); |
| 514 return Others; | 514 return Others; |
| 515 } | 515 } |
| 516 } else if (m_WordSize == 5) { | 516 } else if (m_WordSize == 5) { |
| 517 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_FALS && m_WordBuffer[4] == 'e')
{ | 517 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_FALS && m_WordBuffer[4] == 'e')
{ |
| 518 m_pLastObj = CPDF_Boolean::Create(false); | 518 m_pLastObj = CPDF_Boolean::Create(FALSE); |
| 519 return Others; | 519 return Others; |
| 520 } | 520 } |
| 521 } | 521 } |
| 522 return Keyword; | 522 return Keyword; |
| 523 } | 523 } |
| 524 void CPDF_StreamParser::SkipPathObject() | 524 void CPDF_StreamParser::SkipPathObject() |
| 525 { | 525 { |
| 526 FX_DWORD command_startpos = m_Pos; | 526 FX_DWORD command_startpos = m_Pos; |
| 527 if (m_Pos >= m_Size) { | 527 if (m_Pos >= m_Size) { |
| 528 return; | 528 return; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 if (m_pBuf[op_startpos] == 'r' && m_pBuf[op_startpos + 1] == 'e'
) { | 577 if (m_pBuf[op_startpos] == 'r' && m_pBuf[op_startpos + 1] == 'e'
) { |
| 578 command_startpos = m_Pos; | 578 command_startpos = m_Pos; |
| 579 break; | 579 break; |
| 580 } | 580 } |
| 581 } | 581 } |
| 582 m_Pos = command_startpos; | 582 m_Pos = command_startpos; |
| 583 return; | 583 return; |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 } | 586 } |
| 587 CPDF_Object* CPDF_StreamParser::ReadNextObject(bool bAllowNestedArray, bool bInA
rray) | 587 CPDF_Object* CPDF_StreamParser::ReadNextObject(FX_BOOL bAllowNestedArray, FX_BOO
L bInArray) |
| 588 { | 588 { |
| 589 bool bIsNumber; | 589 FX_BOOL bIsNumber; |
| 590 GetNextWord(bIsNumber); | 590 GetNextWord(bIsNumber); |
| 591 if (m_WordSize == 0) { | 591 if (m_WordSize == 0) { |
| 592 return NULL; | 592 return NULL; |
| 593 } | 593 } |
| 594 if (bIsNumber) { | 594 if (bIsNumber) { |
| 595 m_WordBuffer[m_WordSize] = 0; | 595 m_WordBuffer[m_WordSize] = 0; |
| 596 return CPDF_Number::Create(CFX_ByteStringC(m_WordBuffer, m_WordSize)); | 596 return CPDF_Number::Create(CFX_ByteStringC(m_WordBuffer, m_WordSize)); |
| 597 } | 597 } |
| 598 int first_char = m_WordBuffer[0]; | 598 int first_char = m_WordBuffer[0]; |
| 599 if (first_char == '/') { | 599 if (first_char == '/') { |
| 600 return CPDF_Name::Create(PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1
, m_WordSize - 1))); | 600 return CPDF_Name::Create(PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1
, m_WordSize - 1))); |
| 601 } | 601 } |
| 602 if (first_char == '(') { | 602 if (first_char == '(') { |
| 603 return CPDF_String::Create(ReadString()); | 603 return CPDF_String::Create(ReadString()); |
| 604 } | 604 } |
| 605 if (first_char == '<') { | 605 if (first_char == '<') { |
| 606 if (m_WordSize == 1) { | 606 if (m_WordSize == 1) { |
| 607 return CPDF_String::Create(ReadHexString(), true); | 607 return CPDF_String::Create(ReadHexString(), TRUE); |
| 608 } | 608 } |
| 609 CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); | 609 CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); |
| 610 while (1) { | 610 while (1) { |
| 611 GetNextWord(bIsNumber); | 611 GetNextWord(bIsNumber); |
| 612 if (m_WordSize == 0) { | 612 if (m_WordSize == 0) { |
| 613 pDict->Release(); | 613 pDict->Release(); |
| 614 return NULL; | 614 return NULL; |
| 615 } | 615 } |
| 616 if (m_WordSize == 2 && m_WordBuffer[0] == '>') { | 616 if (m_WordSize == 2 && m_WordBuffer[0] == '>') { |
| 617 break; | 617 break; |
| 618 } | 618 } |
| 619 if (m_WordBuffer[0] != '/') { | 619 if (m_WordBuffer[0] != '/') { |
| 620 pDict->Release(); | 620 pDict->Release(); |
| 621 return NULL; | 621 return NULL; |
| 622 } | 622 } |
| 623 CFX_ByteString key = PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1
, m_WordSize - 1)); | 623 CFX_ByteString key = PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1
, m_WordSize - 1)); |
| 624 CPDF_Object* pObj = ReadNextObject(true); | 624 CPDF_Object* pObj = ReadNextObject(TRUE); |
| 625 if (pObj == NULL) { | 625 if (pObj == NULL) { |
| 626 if (pDict) { | 626 if (pDict) { |
| 627 pDict->Release(); | 627 pDict->Release(); |
| 628 } | 628 } |
| 629 return NULL; | 629 return NULL; |
| 630 } | 630 } |
| 631 if (!key.IsEmpty()) { | 631 if (!key.IsEmpty()) { |
| 632 pDict->SetAt(key, pObj); | 632 pDict->SetAt(key, pObj); |
| 633 } else { | 633 } else { |
| 634 pObj->Release(); | 634 pObj->Release(); |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 return pDict; | 637 return pDict; |
| 638 } | 638 } |
| 639 if (first_char == '[') { | 639 if (first_char == '[') { |
| 640 if (!bAllowNestedArray && bInArray) { | 640 if (!bAllowNestedArray && bInArray) { |
| 641 return NULL; | 641 return NULL; |
| 642 } | 642 } |
| 643 CPDF_Array* pArray = CPDF_Array::Create(); | 643 CPDF_Array* pArray = CPDF_Array::Create(); |
| 644 while (1) { | 644 while (1) { |
| 645 CPDF_Object* pObj = ReadNextObject(bAllowNestedArray, true); | 645 CPDF_Object* pObj = ReadNextObject(bAllowNestedArray, TRUE); |
| 646 if (pObj == NULL) { | 646 if (pObj == NULL) { |
| 647 if (m_WordSize == 0 || m_WordBuffer[0] == ']') { | 647 if (m_WordSize == 0 || m_WordBuffer[0] == ']') { |
| 648 return pArray; | 648 return pArray; |
| 649 } | 649 } |
| 650 if (m_WordBuffer[0] == '[') { | 650 if (m_WordBuffer[0] == '[') { |
| 651 continue; | 651 continue; |
| 652 } | 652 } |
| 653 } else { | 653 } else { |
| 654 pArray->Add(pObj); | 654 pArray->Add(pObj); |
| 655 } | 655 } |
| 656 } | 656 } |
| 657 } | 657 } |
| 658 if (m_WordSize == 4) { | 658 if (m_WordSize == 4) { |
| 659 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_TRUE) { | 659 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_TRUE) { |
| 660 return CPDF_Boolean::Create(true); | 660 return CPDF_Boolean::Create(TRUE); |
| 661 } | 661 } |
| 662 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_NULL) { | 662 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_NULL) { |
| 663 return CPDF_Null::Create(); | 663 return CPDF_Null::Create(); |
| 664 } | 664 } |
| 665 } else if (m_WordSize == 5) { | 665 } else if (m_WordSize == 5) { |
| 666 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_FALS && m_WordBuffer[4] == 'e')
{ | 666 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_FALS && m_WordBuffer[4] == 'e')
{ |
| 667 return CPDF_Boolean::Create(false); | 667 return CPDF_Boolean::Create(FALSE); |
| 668 } | 668 } |
| 669 } | 669 } |
| 670 return NULL; | 670 return NULL; |
| 671 } | 671 } |
| 672 void CPDF_StreamParser::GetNextWord(bool& bIsNumber) | 672 void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber) |
| 673 { | 673 { |
| 674 m_WordSize = 0; | 674 m_WordSize = 0; |
| 675 bIsNumber = true; | 675 bIsNumber = TRUE; |
| 676 if (m_Size <= m_Pos) { | 676 if (m_Size <= m_Pos) { |
| 677 return; | 677 return; |
| 678 } | 678 } |
| 679 int ch = m_pBuf[m_Pos++]; | 679 int ch = m_pBuf[m_Pos++]; |
| 680 int type = PDF_CharType[ch]; | 680 int type = PDF_CharType[ch]; |
| 681 while (1) { | 681 while (1) { |
| 682 while (type == 'W') { | 682 while (type == 'W') { |
| 683 if (m_Size <= m_Pos) { | 683 if (m_Size <= m_Pos) { |
| 684 return; | 684 return; |
| 685 } | 685 } |
| 686 ch = m_pBuf[m_Pos++]; | 686 ch = m_pBuf[m_Pos++]; |
| 687 type = PDF_CharType[ch]; | 687 type = PDF_CharType[ch]; |
| 688 } | 688 } |
| 689 if (ch != '%') { | 689 if (ch != '%') { |
| 690 break; | 690 break; |
| 691 } | 691 } |
| 692 while (1) { | 692 while (1) { |
| 693 if (m_Size <= m_Pos) { | 693 if (m_Size <= m_Pos) { |
| 694 return; | 694 return; |
| 695 } | 695 } |
| 696 ch = m_pBuf[m_Pos++]; | 696 ch = m_pBuf[m_Pos++]; |
| 697 if (ch == '\r' || ch == '\n') { | 697 if (ch == '\r' || ch == '\n') { |
| 698 break; | 698 break; |
| 699 } | 699 } |
| 700 } | 700 } |
| 701 type = PDF_CharType[ch]; | 701 type = PDF_CharType[ch]; |
| 702 } | 702 } |
| 703 if (type == 'D') { | 703 if (type == 'D') { |
| 704 bIsNumber = false; | 704 bIsNumber = FALSE; |
| 705 m_WordBuffer[m_WordSize++] = ch; | 705 m_WordBuffer[m_WordSize++] = ch; |
| 706 if (ch == '/') { | 706 if (ch == '/') { |
| 707 while (1) { | 707 while (1) { |
| 708 if (m_Size <= m_Pos) { | 708 if (m_Size <= m_Pos) { |
| 709 return; | 709 return; |
| 710 } | 710 } |
| 711 ch = m_pBuf[m_Pos++]; | 711 ch = m_pBuf[m_Pos++]; |
| 712 type = PDF_CharType[ch]; | 712 type = PDF_CharType[ch]; |
| 713 if (type != 'R' && type != 'N') { | 713 if (type != 'R' && type != 'N') { |
| 714 m_Pos --; | 714 m_Pos --; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 739 m_Pos --; | 739 m_Pos --; |
| 740 } | 740 } |
| 741 } | 741 } |
| 742 return; | 742 return; |
| 743 } | 743 } |
| 744 while (1) { | 744 while (1) { |
| 745 if (m_WordSize < MAX_WORD_BUFFER) { | 745 if (m_WordSize < MAX_WORD_BUFFER) { |
| 746 m_WordBuffer[m_WordSize++] = ch; | 746 m_WordBuffer[m_WordSize++] = ch; |
| 747 } | 747 } |
| 748 if (type != 'N') { | 748 if (type != 'N') { |
| 749 bIsNumber = false; | 749 bIsNumber = FALSE; |
| 750 } | 750 } |
| 751 if (m_Size <= m_Pos) { | 751 if (m_Size <= m_Pos) { |
| 752 return; | 752 return; |
| 753 } | 753 } |
| 754 ch = m_pBuf[m_Pos++]; | 754 ch = m_pBuf[m_Pos++]; |
| 755 type = PDF_CharType[ch]; | 755 type = PDF_CharType[ch]; |
| 756 if (type == 'D' || type == 'W') { | 756 if (type == 'D' || type == 'W') { |
| 757 m_Pos --; | 757 m_Pos --; |
| 758 break; | 758 break; |
| 759 } | 759 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 } | 855 } |
| 856 return buf.GetByteString(); | 856 return buf.GetByteString(); |
| 857 } | 857 } |
| 858 CFX_ByteString CPDF_StreamParser::ReadHexString() | 858 CFX_ByteString CPDF_StreamParser::ReadHexString() |
| 859 { | 859 { |
| 860 if (m_Size <= m_Pos) { | 860 if (m_Size <= m_Pos) { |
| 861 return CFX_ByteString(); | 861 return CFX_ByteString(); |
| 862 } | 862 } |
| 863 int ch = m_pBuf[m_Pos++]; | 863 int ch = m_pBuf[m_Pos++]; |
| 864 CFX_ByteTextBuf buf; | 864 CFX_ByteTextBuf buf; |
| 865 bool bFirst = true; | 865 FX_BOOL bFirst = TRUE; |
| 866 int code = 0; | 866 int code = 0; |
| 867 while (1) { | 867 while (1) { |
| 868 if (ch == '>') { | 868 if (ch == '>') { |
| 869 break; | 869 break; |
| 870 } | 870 } |
| 871 if (ch >= '0' && ch <= '9') { | 871 if (ch >= '0' && ch <= '9') { |
| 872 if (bFirst) { | 872 if (bFirst) { |
| 873 code = (ch - '0') * 16; | 873 code = (ch - '0') * 16; |
| 874 } else { | 874 } else { |
| 875 code += ch - '0'; | 875 code += ch - '0'; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 m_pData = NULL; | 940 m_pData = NULL; |
| 941 m_Status = Ready; | 941 m_Status = Ready; |
| 942 } | 942 } |
| 943 void CPDF_ContentParser::Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions) | 943 void CPDF_ContentParser::Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions) |
| 944 { | 944 { |
| 945 if (m_Status != Ready || pPage == NULL || pPage->m_pDocument == NULL || pPag
e->m_pFormDict == NULL) { | 945 if (m_Status != Ready || pPage == NULL || pPage->m_pDocument == NULL || pPag
e->m_pFormDict == NULL) { |
| 946 m_Status = Done; | 946 m_Status = Done; |
| 947 return; | 947 return; |
| 948 } | 948 } |
| 949 m_pObjects = pPage; | 949 m_pObjects = pPage; |
| 950 m_bForm = false; | 950 m_bForm = FALSE; |
| 951 if (pOptions) { | 951 if (pOptions) { |
| 952 m_Options = *pOptions; | 952 m_Options = *pOptions; |
| 953 } | 953 } |
| 954 m_Status = ToBeContinued; | 954 m_Status = ToBeContinued; |
| 955 m_InternalStage = PAGEPARSE_STAGE_GETCONTENT; | 955 m_InternalStage = PAGEPARSE_STAGE_GETCONTENT; |
| 956 m_CurrentOffset = 0; | 956 m_CurrentOffset = 0; |
| 957 CPDF_Object* pContent = pPage->m_pFormDict->GetElementValue(FX_BSTRC("Conten
ts")); | 957 CPDF_Object* pContent = pPage->m_pFormDict->GetElementValue(FX_BSTRC("Conten
ts")); |
| 958 if (pContent == NULL) { | 958 if (pContent == NULL) { |
| 959 m_Status = Done; | 959 m_Status = Done; |
| 960 return; | 960 return; |
| 961 } | 961 } |
| 962 if (pContent->GetType() == PDFOBJ_STREAM) { | 962 if (pContent->GetType() == PDFOBJ_STREAM) { |
| 963 m_nStreams = 0; | 963 m_nStreams = 0; |
| 964 m_pSingleStream = new CPDF_StreamAcc; | 964 m_pSingleStream = new CPDF_StreamAcc; |
| 965 m_pSingleStream->LoadAllData((CPDF_Stream*)pContent, false); | 965 m_pSingleStream->LoadAllData((CPDF_Stream*)pContent, FALSE); |
| 966 } else if (pContent->GetType() == PDFOBJ_ARRAY) { | 966 } else if (pContent->GetType() == PDFOBJ_ARRAY) { |
| 967 CPDF_Array* pArray = (CPDF_Array*)pContent; | 967 CPDF_Array* pArray = (CPDF_Array*)pContent; |
| 968 m_nStreams = pArray->GetCount(); | 968 m_nStreams = pArray->GetCount(); |
| 969 if (m_nStreams == 0) { | 969 if (m_nStreams == 0) { |
| 970 m_Status = Done; | 970 m_Status = Done; |
| 971 return; | 971 return; |
| 972 } | 972 } |
| 973 m_pStreamArray = FX_Alloc(CPDF_StreamAcc*, m_nStreams); | 973 m_pStreamArray = FX_Alloc(CPDF_StreamAcc*, m_nStreams); |
| 974 } else { | 974 } else { |
| 975 m_Status = Done; | 975 m_Status = Done; |
| 976 return; | 976 return; |
| 977 } | 977 } |
| 978 } | 978 } |
| 979 void CPDF_ContentParser::Start(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates, | 979 void CPDF_ContentParser::Start(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates, |
| 980 CFX_AffineMatrix* pParentMatrix, CPDF_Type3Char*
pType3Char, CPDF_ParseOptions* pOptions, int level) | 980 CFX_AffineMatrix* pParentMatrix, CPDF_Type3Char*
pType3Char, CPDF_ParseOptions* pOptions, int level) |
| 981 { | 981 { |
| 982 m_pType3Char = pType3Char; | 982 m_pType3Char = pType3Char; |
| 983 m_pObjects = pForm; | 983 m_pObjects = pForm; |
| 984 m_bForm = true; | 984 m_bForm = TRUE; |
| 985 CFX_AffineMatrix form_matrix = pForm->m_pFormDict->GetMatrix(FX_BSTRC("Matri
x")); | 985 CFX_AffineMatrix form_matrix = pForm->m_pFormDict->GetMatrix(FX_BSTRC("Matri
x")); |
| 986 if (pGraphicStates) { | 986 if (pGraphicStates) { |
| 987 form_matrix.Concat(pGraphicStates->m_CTM); | 987 form_matrix.Concat(pGraphicStates->m_CTM); |
| 988 } | 988 } |
| 989 CPDF_Array* pBBox = pForm->m_pFormDict->GetArray(FX_BSTRC("BBox")); | 989 CPDF_Array* pBBox = pForm->m_pFormDict->GetArray(FX_BSTRC("BBox")); |
| 990 CFX_FloatRect form_bbox; | 990 CFX_FloatRect form_bbox; |
| 991 CPDF_Path ClipPath; | 991 CPDF_Path ClipPath; |
| 992 if (pBBox) { | 992 if (pBBox) { |
| 993 form_bbox = pBBox->GetRect(); | 993 form_bbox = pBBox->GetRect(); |
| 994 ClipPath.New(); | 994 ClipPath.New(); |
| 995 ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right, f
orm_bbox.top); | 995 ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right, f
orm_bbox.top); |
| 996 ClipPath.Transform(&form_matrix); | 996 ClipPath.Transform(&form_matrix); |
| 997 if (pParentMatrix) { | 997 if (pParentMatrix) { |
| 998 ClipPath.Transform(pParentMatrix); | 998 ClipPath.Transform(pParentMatrix); |
| 999 } | 999 } |
| 1000 form_bbox.Transform(&form_matrix); | 1000 form_bbox.Transform(&form_matrix); |
| 1001 if (pParentMatrix) { | 1001 if (pParentMatrix) { |
| 1002 form_bbox.Transform(pParentMatrix); | 1002 form_bbox.Transform(pParentMatrix); |
| 1003 } | 1003 } |
| 1004 } | 1004 } |
| 1005 CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDict(FX_BSTRC("Resource
s")); | 1005 CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDict(FX_BSTRC("Resource
s")); |
| 1006 m_pParser = new CPDF_StreamContentParser( | 1006 m_pParser = new CPDF_StreamContentParser( |
| 1007 pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources, | 1007 pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources, |
| 1008 pParentMatrix, pForm, pResources, &form_bbox, pOptions, pGraphicStates, | 1008 pParentMatrix, pForm, pResources, &form_bbox, pOptions, pGraphicStates, |
| 1009 level); | 1009 level); |
| 1010 | 1010 |
| 1011 m_pParser->GetCurStates()->m_CTM = form_matrix; | 1011 m_pParser->GetCurStates()->m_CTM = form_matrix; |
| 1012 m_pParser->GetCurStates()->m_ParentMatrix = form_matrix; | 1012 m_pParser->GetCurStates()->m_ParentMatrix = form_matrix; |
| 1013 if (ClipPath.NotNull()) { | 1013 if (ClipPath.NotNull()) { |
| 1014 m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDIN
G, true); | 1014 m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDIN
G, TRUE); |
| 1015 } | 1015 } |
| 1016 if (pForm->m_Transparency & PDFTRANS_GROUP) { | 1016 if (pForm->m_Transparency & PDFTRANS_GROUP) { |
| 1017 CPDF_GeneralStateData* pData = m_pParser->GetCurStates()->m_GeneralState
.GetModify(); | 1017 CPDF_GeneralStateData* pData = m_pParser->GetCurStates()->m_GeneralState
.GetModify(); |
| 1018 pData->m_BlendType = FXDIB_BLEND_NORMAL; | 1018 pData->m_BlendType = FXDIB_BLEND_NORMAL; |
| 1019 pData->m_StrokeAlpha = 1.0f; | 1019 pData->m_StrokeAlpha = 1.0f; |
| 1020 pData->m_FillAlpha = 1.0f; | 1020 pData->m_FillAlpha = 1.0f; |
| 1021 pData->m_pSoftMask = NULL; | 1021 pData->m_pSoftMask = NULL; |
| 1022 } | 1022 } |
| 1023 m_nStreams = 0; | 1023 m_nStreams = 0; |
| 1024 m_pSingleStream = new CPDF_StreamAcc; | 1024 m_pSingleStream = new CPDF_StreamAcc; |
| 1025 if (pForm->m_pDocument) { | 1025 if (pForm->m_pDocument) { |
| 1026 m_pSingleStream->LoadAllData(pForm->m_pFormStream, false); | 1026 m_pSingleStream->LoadAllData(pForm->m_pFormStream, FALSE); |
| 1027 } else { | 1027 } else { |
| 1028 m_pSingleStream->LoadAllData(pForm->m_pFormStream, false); | 1028 m_pSingleStream->LoadAllData(pForm->m_pFormStream, FALSE); |
| 1029 } | 1029 } |
| 1030 m_pData = (uint8_t*)m_pSingleStream->GetData(); | 1030 m_pData = (uint8_t*)m_pSingleStream->GetData(); |
| 1031 m_Size = m_pSingleStream->GetSize(); | 1031 m_Size = m_pSingleStream->GetSize(); |
| 1032 m_Status = ToBeContinued; | 1032 m_Status = ToBeContinued; |
| 1033 m_InternalStage = PAGEPARSE_STAGE_PARSE; | 1033 m_InternalStage = PAGEPARSE_STAGE_PARSE; |
| 1034 m_CurrentOffset = 0; | 1034 m_CurrentOffset = 0; |
| 1035 } | 1035 } |
| 1036 void CPDF_ContentParser::Continue(IFX_Pause* pPause) | 1036 void CPDF_ContentParser::Continue(IFX_Pause* pPause) |
| 1037 { | 1037 { |
| 1038 int steps = 0; | 1038 int steps = 0; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1063 } else { | 1063 } else { |
| 1064 m_pData = (uint8_t*)m_pSingleStream->GetData(); | 1064 m_pData = (uint8_t*)m_pSingleStream->GetData(); |
| 1065 m_Size = m_pSingleStream->GetSize(); | 1065 m_Size = m_pSingleStream->GetSize(); |
| 1066 } | 1066 } |
| 1067 m_InternalStage = PAGEPARSE_STAGE_PARSE; | 1067 m_InternalStage = PAGEPARSE_STAGE_PARSE; |
| 1068 m_CurrentOffset = 0; | 1068 m_CurrentOffset = 0; |
| 1069 } else { | 1069 } else { |
| 1070 CPDF_Array* pContent = m_pObjects->m_pFormDict->GetArray(FX_BSTR
C("Contents")); | 1070 CPDF_Array* pContent = m_pObjects->m_pFormDict->GetArray(FX_BSTR
C("Contents")); |
| 1071 m_pStreamArray[m_CurrentOffset] = new CPDF_StreamAcc; | 1071 m_pStreamArray[m_CurrentOffset] = new CPDF_StreamAcc; |
| 1072 CPDF_Stream* pStreamObj = (CPDF_Stream*)(pContent ? pContent->Ge
tElementValue(m_CurrentOffset) : NULL); | 1072 CPDF_Stream* pStreamObj = (CPDF_Stream*)(pContent ? pContent->Ge
tElementValue(m_CurrentOffset) : NULL); |
| 1073 m_pStreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, false); | 1073 m_pStreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, FALSE); |
| 1074 m_CurrentOffset ++; | 1074 m_CurrentOffset ++; |
| 1075 } | 1075 } |
| 1076 } | 1076 } |
| 1077 if (m_InternalStage == PAGEPARSE_STAGE_PARSE) { | 1077 if (m_InternalStage == PAGEPARSE_STAGE_PARSE) { |
| 1078 if (!m_pParser) { | 1078 if (!m_pParser) { |
| 1079 m_pParser = new CPDF_StreamContentParser( | 1079 m_pParser = new CPDF_StreamContentParser( |
| 1080 m_pObjects->m_pDocument, m_pObjects->m_pPageResources, | 1080 m_pObjects->m_pDocument, m_pObjects->m_pPageResources, |
| 1081 nullptr, nullptr, m_pObjects, m_pObjects->m_pResources, | 1081 nullptr, nullptr, m_pObjects, m_pObjects->m_pResources, |
| 1082 &m_pObjects->m_BBox, &m_Options, nullptr, 0); | 1082 &m_pObjects->m_BBox, &m_Options, nullptr, 0); |
| 1083 m_pParser->GetCurStates()->m_ColorState.GetModify()->Default(); | 1083 m_pParser->GetCurStates()->m_ColorState.GetModify()->Default(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 return 100; | 1142 return 100; |
| 1143 } | 1143 } |
| 1144 if (m_InternalStage == PAGEPARSE_STAGE_GETCONTENT) { | 1144 if (m_InternalStage == PAGEPARSE_STAGE_GETCONTENT) { |
| 1145 return 10; | 1145 return 10; |
| 1146 } | 1146 } |
| 1147 if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) { | 1147 if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) { |
| 1148 return 90; | 1148 return 90; |
| 1149 } | 1149 } |
| 1150 return 10 + 80 * m_CurrentOffset / m_Size; | 1150 return 10 + 80 * m_CurrentOffset / m_Size; |
| 1151 } | 1151 } |
| OLD | NEW |