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 "core/fpdfapi/fpdf_page/pageint.h" | 7 #include "core/fpdfapi/fpdf_page/pageint.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 } | 274 } |
275 m_ParamCount++; | 275 m_ParamCount++; |
276 return index; | 276 return index; |
277 } | 277 } |
278 | 278 |
279 void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) { | 279 void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) { |
280 CFX_ByteStringC bsName(name, len); | 280 CFX_ByteStringC bsName(name, len); |
281 ContentParam& param = m_ParamBuf[GetNextParamPos()]; | 281 ContentParam& param = m_ParamBuf[GetNextParamPos()]; |
282 if (len > 32) { | 282 if (len > 32) { |
283 param.m_Type = ContentParam::OBJECT; | 283 param.m_Type = ContentParam::OBJECT; |
284 param.m_pObject = new CPDF_Name(PDF_NameDecode(bsName)); | 284 param.m_pObject = new CPDF_Name( |
| 285 m_pDocument->GetByteStringPool()->Intern(PDF_NameDecode(bsName))); |
285 } else { | 286 } else { |
286 param.m_Type = ContentParam::NAME; | 287 param.m_Type = ContentParam::NAME; |
287 if (bsName.Find('#') == -1) { | 288 if (bsName.Find('#') == -1) { |
288 FXSYS_memcpy(param.m_Name.m_Buffer, name, len); | 289 FXSYS_memcpy(param.m_Name.m_Buffer, name, len); |
289 param.m_Name.m_Len = len; | 290 param.m_Name.m_Len = len; |
290 } else { | 291 } else { |
291 CFX_ByteString str = PDF_NameDecode(bsName); | 292 CFX_ByteString str = PDF_NameDecode(bsName); |
292 FXSYS_memcpy(param.m_Name.m_Buffer, str.c_str(), str.GetLength()); | 293 FXSYS_memcpy(param.m_Name.m_Buffer, str.c_str(), str.GetLength()); |
293 param.m_Name.m_Len = str.GetLength(); | 294 param.m_Name.m_Len = str.GetLength(); |
294 } | 295 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 if (param.m_Type == ContentParam::NUMBER) { | 337 if (param.m_Type == ContentParam::NUMBER) { |
337 CPDF_Number* pNumber = param.m_Number.m_bInteger | 338 CPDF_Number* pNumber = param.m_Number.m_bInteger |
338 ? new CPDF_Number(param.m_Number.m_Integer) | 339 ? new CPDF_Number(param.m_Number.m_Integer) |
339 : new CPDF_Number(param.m_Number.m_Float); | 340 : new CPDF_Number(param.m_Number.m_Float); |
340 | 341 |
341 param.m_Type = ContentParam::OBJECT; | 342 param.m_Type = ContentParam::OBJECT; |
342 param.m_pObject = pNumber; | 343 param.m_pObject = pNumber; |
343 return pNumber; | 344 return pNumber; |
344 } | 345 } |
345 if (param.m_Type == ContentParam::NAME) { | 346 if (param.m_Type == ContentParam::NAME) { |
346 CPDF_Name* pName = new CPDF_Name( | 347 CPDF_Name* pName = new CPDF_Name(m_pDocument->GetByteStringPool()->Intern( |
347 CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len)); | 348 CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len))); |
348 param.m_Type = ContentParam::OBJECT; | 349 param.m_Type = ContentParam::OBJECT; |
349 param.m_pObject = pName; | 350 param.m_pObject = pName; |
350 return pName; | 351 return pName; |
351 } | 352 } |
352 if (param.m_Type == ContentParam::OBJECT) { | 353 if (param.m_Type == ContentParam::OBJECT) { |
353 return param.m_pObject; | 354 return param.m_pObject; |
354 } | 355 } |
355 ASSERT(FALSE); | 356 ASSERT(FALSE); |
356 return nullptr; | 357 return nullptr; |
357 } | 358 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 return; | 583 return; |
583 bDirect = FALSE; | 584 bDirect = FALSE; |
584 } | 585 } |
585 if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) { | 586 if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) { |
586 m_CurContentMark.AddMark(tag, pDict, bDirect); | 587 m_CurContentMark.AddMark(tag, pDict, bDirect); |
587 } | 588 } |
588 } | 589 } |
589 | 590 |
590 void CPDF_StreamContentParser::Handle_BeginImage() { | 591 void CPDF_StreamContentParser::Handle_BeginImage() { |
591 FX_FILESIZE savePos = m_pSyntax->GetPos(); | 592 FX_FILESIZE savePos = m_pSyntax->GetPos(); |
592 CPDF_Dictionary* pDict = new CPDF_Dictionary; | 593 CPDF_Dictionary* pDict = |
| 594 new CPDF_Dictionary(m_pDocument->GetByteStringPool()); |
593 while (1) { | 595 while (1) { |
594 CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement(); | 596 CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement(); |
595 if (type == CPDF_StreamParser::Keyword) { | 597 if (type == CPDF_StreamParser::Keyword) { |
596 CFX_ByteString bsKeyword(m_pSyntax->GetWordBuf(), | 598 CFX_ByteString bsKeyword(m_pSyntax->GetWordBuf(), |
597 m_pSyntax->GetWordSize()); | 599 m_pSyntax->GetWordSize()); |
598 if (bsKeyword != "ID") { | 600 if (bsKeyword != "ID") { |
599 m_pSyntax->SetPos(savePos); | 601 m_pSyntax->SetPos(savePos); |
600 pDict->Release(); | 602 pDict->Release(); |
601 return; | 603 return; |
602 } | 604 } |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1492 } | 1494 } |
1493 } | 1495 } |
1494 | 1496 |
1495 uint32_t CPDF_StreamContentParser::Parse(const uint8_t* pData, | 1497 uint32_t CPDF_StreamContentParser::Parse(const uint8_t* pData, |
1496 uint32_t dwSize, | 1498 uint32_t dwSize, |
1497 uint32_t max_cost) { | 1499 uint32_t max_cost) { |
1498 if (m_Level > _FPDF_MAX_FORM_LEVEL_) { | 1500 if (m_Level > _FPDF_MAX_FORM_LEVEL_) { |
1499 return dwSize; | 1501 return dwSize; |
1500 } | 1502 } |
1501 uint32_t InitObjCount = m_pObjectHolder->GetPageObjectList()->size(); | 1503 uint32_t InitObjCount = m_pObjectHolder->GetPageObjectList()->size(); |
1502 CPDF_StreamParser syntax(pData, dwSize); | 1504 CPDF_StreamParser syntax(pData, dwSize, m_pDocument->GetByteStringPool()); |
1503 CPDF_StreamParserAutoClearer auto_clearer(&m_pSyntax, &syntax); | 1505 CPDF_StreamParserAutoClearer auto_clearer(&m_pSyntax, &syntax); |
1504 while (1) { | 1506 while (1) { |
1505 uint32_t cost = m_pObjectHolder->GetPageObjectList()->size() - InitObjCount; | 1507 uint32_t cost = m_pObjectHolder->GetPageObjectList()->size() - InitObjCount; |
1506 if (max_cost && cost >= max_cost) { | 1508 if (max_cost && cost >= max_cost) { |
1507 break; | 1509 break; |
1508 } | 1510 } |
1509 switch (syntax.ParseNextElement()) { | 1511 switch (syntax.ParseNextElement()) { |
1510 case CPDF_StreamParser::EndOfData: | 1512 case CPDF_StreamParser::EndOfData: |
1511 return m_pSyntax->GetPos(); | 1513 return m_pSyntax->GetPos(); |
1512 case CPDF_StreamParser::Keyword: | 1514 case CPDF_StreamParser::Keyword: |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 } else { | 1673 } else { |
1672 PDF_ReplaceAbbr(pElement); | 1674 PDF_ReplaceAbbr(pElement); |
1673 } | 1675 } |
1674 } | 1676 } |
1675 break; | 1677 break; |
1676 } | 1678 } |
1677 default: | 1679 default: |
1678 break; | 1680 break; |
1679 } | 1681 } |
1680 } | 1682 } |
OLD | NEW |