Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page_parser.cpp

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector> 9 #include <vector>
10 10
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 m_ParamBuf[index].m_Type = ContentParam::NUMBER; 248 m_ParamBuf[index].m_Type = ContentParam::NUMBER;
249 FX_atonum(CFX_ByteStringC(str, len), m_ParamBuf[index].m_Number.m_bInteger, 249 FX_atonum(CFX_ByteStringC(str, len), m_ParamBuf[index].m_Number.m_bInteger,
250 &m_ParamBuf[index].m_Number.m_Integer); 250 &m_ParamBuf[index].m_Number.m_Integer);
251 } 251 }
252 void CPDF_StreamContentParser::AddObjectParam(CPDF_Object* pObj) { 252 void CPDF_StreamContentParser::AddObjectParam(CPDF_Object* pObj) {
253 int index = GetNextParamPos(); 253 int index = GetNextParamPos();
254 m_ParamBuf[index].m_Type = ContentParam::OBJECT; 254 m_ParamBuf[index].m_Type = ContentParam::OBJECT;
255 m_ParamBuf[index].m_pObject = pObj; 255 m_ParamBuf[index].m_pObject = pObj;
256 } 256 }
257 void CPDF_StreamContentParser::ClearAllParams() { 257 void CPDF_StreamContentParser::ClearAllParams() {
258 FX_DWORD index = m_ParamStartPos; 258 uint32_t index = m_ParamStartPos;
259 for (FX_DWORD i = 0; i < m_ParamCount; i++) { 259 for (uint32_t i = 0; i < m_ParamCount; i++) {
260 if (m_ParamBuf[index].m_Type == 0) { 260 if (m_ParamBuf[index].m_Type == 0) {
261 if (CPDF_Object* pObject = m_ParamBuf[index].m_pObject) 261 if (CPDF_Object* pObject = m_ParamBuf[index].m_pObject)
262 pObject->Release(); 262 pObject->Release();
263 } 263 }
264 index++; 264 index++;
265 if (index == PARAM_BUF_SIZE) { 265 if (index == PARAM_BUF_SIZE) {
266 index = 0; 266 index = 0;
267 } 267 }
268 } 268 }
269 m_ParamStartPos = 0; 269 m_ParamStartPos = 0;
270 m_ParamCount = 0; 270 m_ParamCount = 0;
271 } 271 }
272 272
273 CPDF_Object* CPDF_StreamContentParser::GetObject(FX_DWORD index) { 273 CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) {
274 if (index >= m_ParamCount) { 274 if (index >= m_ParamCount) {
275 return NULL; 275 return NULL;
276 } 276 }
277 int real_index = m_ParamStartPos + m_ParamCount - index - 1; 277 int real_index = m_ParamStartPos + m_ParamCount - index - 1;
278 if (real_index >= PARAM_BUF_SIZE) { 278 if (real_index >= PARAM_BUF_SIZE) {
279 real_index -= PARAM_BUF_SIZE; 279 real_index -= PARAM_BUF_SIZE;
280 } 280 }
281 ContentParam& param = m_ParamBuf[real_index]; 281 ContentParam& param = m_ParamBuf[real_index];
282 if (param.m_Type == ContentParam::NUMBER) { 282 if (param.m_Type == ContentParam::NUMBER) {
283 CPDF_Number* pNumber = param.m_Number.m_bInteger 283 CPDF_Number* pNumber = param.m_Number.m_bInteger
(...skipping 11 matching lines...) Expand all
295 param.m_pObject = pName; 295 param.m_pObject = pName;
296 return pName; 296 return pName;
297 } 297 }
298 if (param.m_Type == ContentParam::OBJECT) { 298 if (param.m_Type == ContentParam::OBJECT) {
299 return param.m_pObject; 299 return param.m_pObject;
300 } 300 }
301 ASSERT(FALSE); 301 ASSERT(FALSE);
302 return NULL; 302 return NULL;
303 } 303 }
304 304
305 CFX_ByteString CPDF_StreamContentParser::GetString(FX_DWORD index) { 305 CFX_ByteString CPDF_StreamContentParser::GetString(uint32_t index) {
306 if (index >= m_ParamCount) { 306 if (index >= m_ParamCount) {
307 return CFX_ByteString(); 307 return CFX_ByteString();
308 } 308 }
309 int real_index = m_ParamStartPos + m_ParamCount - index - 1; 309 int real_index = m_ParamStartPos + m_ParamCount - index - 1;
310 if (real_index >= PARAM_BUF_SIZE) { 310 if (real_index >= PARAM_BUF_SIZE) {
311 real_index -= PARAM_BUF_SIZE; 311 real_index -= PARAM_BUF_SIZE;
312 } 312 }
313 ContentParam& param = m_ParamBuf[real_index]; 313 ContentParam& param = m_ParamBuf[real_index];
314 if (param.m_Type == ContentParam::NAME) { 314 if (param.m_Type == ContentParam::NAME) {
315 return CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len); 315 return CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len);
316 } 316 }
317 if (param.m_Type == 0 && param.m_pObject) { 317 if (param.m_Type == 0 && param.m_pObject) {
318 return param.m_pObject->GetString(); 318 return param.m_pObject->GetString();
319 } 319 }
320 return CFX_ByteString(); 320 return CFX_ByteString();
321 } 321 }
322 322
323 FX_FLOAT CPDF_StreamContentParser::GetNumber(FX_DWORD index) { 323 FX_FLOAT CPDF_StreamContentParser::GetNumber(uint32_t index) {
324 if (index >= m_ParamCount) { 324 if (index >= m_ParamCount) {
325 return 0; 325 return 0;
326 } 326 }
327 int real_index = m_ParamStartPos + m_ParamCount - index - 1; 327 int real_index = m_ParamStartPos + m_ParamCount - index - 1;
328 if (real_index >= PARAM_BUF_SIZE) { 328 if (real_index >= PARAM_BUF_SIZE) {
329 real_index -= PARAM_BUF_SIZE; 329 real_index -= PARAM_BUF_SIZE;
330 } 330 }
331 ContentParam& param = m_ParamBuf[real_index]; 331 ContentParam& param = m_ParamBuf[real_index];
332 if (param.m_Type == ContentParam::NUMBER) { 332 if (param.m_Type == ContentParam::NUMBER) {
333 return param.m_Number.m_bInteger ? (FX_FLOAT)param.m_Number.m_Integer 333 return param.m_Number.m_bInteger ? (FX_FLOAT)param.m_Number.m_Integer
334 : param.m_Number.m_Float; 334 : param.m_Number.m_Float;
335 } 335 }
336 if (param.m_Type == 0 && param.m_pObject) { 336 if (param.m_Type == 0 && param.m_pObject) {
337 return param.m_pObject->GetNumber(); 337 return param.m_pObject->GetNumber();
338 } 338 }
339 return 0; 339 return 0;
340 } 340 }
341 341
342 FX_FLOAT CPDF_StreamContentParser::GetNumber16(FX_DWORD index) { 342 FX_FLOAT CPDF_StreamContentParser::GetNumber16(uint32_t index) {
343 return GetNumber(index); 343 return GetNumber(index);
344 } 344 }
345 345
346 void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj, 346 void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj,
347 FX_BOOL bColor, 347 FX_BOOL bColor,
348 FX_BOOL bText, 348 FX_BOOL bText,
349 FX_BOOL bGraph) { 349 FX_BOOL bGraph) {
350 pObj->m_GeneralState = m_pCurStates->m_GeneralState; 350 pObj->m_GeneralState = m_pCurStates->m_GeneralState;
351 pObj->m_ClipPath = m_pCurStates->m_ClipPath; 351 pObj->m_ClipPath = m_pCurStates->m_ClipPath;
352 pObj->m_ContentMark = m_CurContentMark; 352 pObj->m_ContentMark = m_CurContentMark;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 &CPDF_StreamContentParser::Handle_SetColorPS_Fill}, 477 &CPDF_StreamContentParser::Handle_SetColorPS_Fill},
478 {FXBSTR_ID('s', 'h', 0, 0), &CPDF_StreamContentParser::Handle_ShadeFill}, 478 {FXBSTR_ID('s', 'h', 0, 0), &CPDF_StreamContentParser::Handle_ShadeFill},
479 {FXBSTR_ID('v', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveTo_23}, 479 {FXBSTR_ID('v', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveTo_23},
480 {FXBSTR_ID('w', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLineWidth}, 480 {FXBSTR_ID('w', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLineWidth},
481 {FXBSTR_ID('y', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveTo_13}, 481 {FXBSTR_ID('y', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveTo_13},
482 }); 482 });
483 } 483 }
484 484
485 void CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) { 485 void CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) {
486 int i = 0; 486 int i = 0;
487 FX_DWORD opid = 0; 487 uint32_t opid = 0;
488 while (i < 4 && op[i]) { 488 while (i < 4 && op[i]) {
489 opid = (opid << 8) + op[i]; 489 opid = (opid << 8) + op[i];
490 i++; 490 i++;
491 } 491 }
492 while (i < 4) { 492 while (i < 4) {
493 opid <<= 8; 493 opid <<= 8;
494 i++; 494 i++;
495 } 495 }
496 496
497 static const OpCodes s_OpCodes = InitializeOpCodes(); 497 static const OpCodes s_OpCodes = InitializeOpCodes();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 } 567 }
568 } 568 }
569 if (type != CPDF_StreamParser::Name) { 569 if (type != CPDF_StreamParser::Name) {
570 break; 570 break;
571 } 571 }
572 CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1, 572 CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1,
573 m_pSyntax->GetWordSize() - 1); 573 m_pSyntax->GetWordSize() - 1);
574 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( 574 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj(
575 m_pSyntax->ReadNextObject()); 575 m_pSyntax->ReadNextObject());
576 if (!key.IsEmpty()) { 576 if (!key.IsEmpty()) {
577 FX_DWORD dwObjNum = pObj ? pObj->GetObjNum() : 0; 577 uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
578 if (dwObjNum) 578 if (dwObjNum)
579 pDict->SetAtReference(key, m_pDocument, dwObjNum); 579 pDict->SetAtReference(key, m_pDocument, dwObjNum);
580 else 580 else
581 pDict->SetAt(key, pObj.release()); 581 pDict->SetAt(key, pObj.release());
582 } 582 }
583 } 583 }
584 PDF_ReplaceAbbr(pDict); 584 PDF_ReplaceAbbr(pDict);
585 CPDF_Object* pCSObj = NULL; 585 CPDF_Object* pCSObj = NULL;
586 if (pDict->KeyExist("ColorSpace")) { 586 if (pDict->KeyExist("ColorSpace")) {
587 pCSObj = pDict->GetElementValue("ColorSpace"); 587 pCSObj = pDict->GetElementValue("ColorSpace");
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 } 1638 }
1639 if (PathClipType) { 1639 if (PathClipType) {
1640 if (!matrix.IsIdentity()) { 1640 if (!matrix.IsIdentity()) {
1641 Path.Transform(&matrix); 1641 Path.Transform(&matrix);
1642 matrix.SetIdentity(); 1642 matrix.SetIdentity();
1643 } 1643 }
1644 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); 1644 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE);
1645 } 1645 }
1646 } 1646 }
1647 1647
1648 FX_DWORD CPDF_StreamContentParser::Parse(const uint8_t* pData, 1648 uint32_t CPDF_StreamContentParser::Parse(const uint8_t* pData,
1649 FX_DWORD dwSize, 1649 uint32_t dwSize,
1650 FX_DWORD max_cost) { 1650 uint32_t max_cost) {
1651 if (m_Level > _FPDF_MAX_FORM_LEVEL_) { 1651 if (m_Level > _FPDF_MAX_FORM_LEVEL_) {
1652 return dwSize; 1652 return dwSize;
1653 } 1653 }
1654 FX_DWORD InitObjCount = m_pObjectHolder->GetPageObjectList()->size(); 1654 uint32_t InitObjCount = m_pObjectHolder->GetPageObjectList()->size();
1655 CPDF_StreamParser syntax(pData, dwSize); 1655 CPDF_StreamParser syntax(pData, dwSize);
1656 CPDF_StreamParserAutoClearer auto_clearer(&m_pSyntax, &syntax); 1656 CPDF_StreamParserAutoClearer auto_clearer(&m_pSyntax, &syntax);
1657 while (1) { 1657 while (1) {
1658 FX_DWORD cost = m_pObjectHolder->GetPageObjectList()->size() - InitObjCount; 1658 uint32_t cost = m_pObjectHolder->GetPageObjectList()->size() - InitObjCount;
1659 if (max_cost && cost >= max_cost) { 1659 if (max_cost && cost >= max_cost) {
1660 break; 1660 break;
1661 } 1661 }
1662 switch (syntax.ParseNextElement()) { 1662 switch (syntax.ParseNextElement()) {
1663 case CPDF_StreamParser::EndOfData: 1663 case CPDF_StreamParser::EndOfData:
1664 return m_pSyntax->GetPos(); 1664 return m_pSyntax->GetPos();
1665 case CPDF_StreamParser::Keyword: 1665 case CPDF_StreamParser::Keyword:
1666 OnOperator((char*)syntax.GetWordBuf()); 1666 OnOperator((char*)syntax.GetWordBuf());
1667 ClearAllParams(); 1667 ClearAllParams();
1668 break; 1668 break;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 for (const auto& op : replacements) { 1803 for (const auto& op : replacements) {
1804 if (op.is_replace_key) 1804 if (op.is_replace_key)
1805 pDict->ReplaceKey(op.key, op.replacement); 1805 pDict->ReplaceKey(op.key, op.replacement);
1806 else 1806 else
1807 pDict->SetAtName(op.key, op.replacement); 1807 pDict->SetAtName(op.key, op.replacement);
1808 } 1808 }
1809 break; 1809 break;
1810 } 1810 }
1811 case CPDF_Object::ARRAY: { 1811 case CPDF_Object::ARRAY: {
1812 CPDF_Array* pArray = pObj->AsArray(); 1812 CPDF_Array* pArray = pObj->AsArray();
1813 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { 1813 for (uint32_t i = 0; i < pArray->GetCount(); i++) {
1814 CPDF_Object* pElement = pArray->GetElement(i); 1814 CPDF_Object* pElement = pArray->GetElement(i);
1815 if (pElement->IsName()) { 1815 if (pElement->IsName()) {
1816 CFX_ByteString name = pElement->GetString(); 1816 CFX_ByteString name = pElement->GetString();
1817 CFX_ByteStringC fullname = PDF_FindFullName( 1817 CFX_ByteStringC fullname = PDF_FindFullName(
1818 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name); 1818 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name);
1819 if (!fullname.IsEmpty()) { 1819 if (!fullname.IsEmpty()) {
1820 pArray->SetAt(i, new CPDF_Name(fullname)); 1820 pArray->SetAt(i, new CPDF_Name(fullname));
1821 } 1821 }
1822 } else { 1822 } else {
1823 PDF_ReplaceAbbr(pElement); 1823 PDF_ReplaceAbbr(pElement);
1824 } 1824 }
1825 } 1825 }
1826 break; 1826 break;
1827 } 1827 }
1828 default: 1828 default:
1829 break; 1829 break;
1830 } 1830 }
1831 } 1831 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/fpdf_page_func.cpp ('k') | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698