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

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

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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 "../../../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/fpdfapi/fpdf_serial.h" 9 #include "../../../include/fpdfapi/fpdf_serial.h"
10 #include "pageint.h" 10 #include "pageint.h"
11 11
12 #define REQUIRE_PARAMS(count) if (m_ParamCount != count) { m_bAbort = TRUE; retu rn; } 12 #define REQUIRE_PARAMS(count) if (m_ParamCount != count) { m_bAbort = true; retu rn; }
13 13
14 CPDF_StreamContentParser::CPDF_StreamContentParser( 14 CPDF_StreamContentParser::CPDF_StreamContentParser(
15 CPDF_Document* pDocument, 15 CPDF_Document* pDocument,
16 CPDF_Dictionary* pPageResources, 16 CPDF_Dictionary* pPageResources,
17 CPDF_Dictionary* pParentResources, 17 CPDF_Dictionary* pParentResources,
18 CFX_AffineMatrix* pmtContentToUser, 18 CFX_AffineMatrix* pmtContentToUser,
19 CPDF_PageObjects* pObjList, 19 CPDF_PageObjects* pObjList,
20 CPDF_Dictionary* pResources, 20 CPDF_Dictionary* pResources,
21 CPDF_Rect* pBBox, 21 CPDF_Rect* pBBox,
22 CPDF_ParseOptions* pOptions, 22 CPDF_ParseOptions* pOptions,
23 CPDF_AllStates* pStates, 23 CPDF_AllStates* pStates,
24 int level) 24 int level)
25 : m_pDocument(pDocument), 25 : m_pDocument(pDocument),
26 m_pPageResources(pPageResources), 26 m_pPageResources(pPageResources),
27 m_pParentResources(pParentResources), 27 m_pParentResources(pParentResources),
28 m_pResources(pResources), 28 m_pResources(pResources),
29 m_pObjectList(pObjList), 29 m_pObjectList(pObjList),
30 m_Level(level), 30 m_Level(level),
31 m_ParamStartPos(0), 31 m_ParamStartPos(0),
32 m_ParamCount(0), 32 m_ParamCount(0),
33 m_bAbort(FALSE), 33 m_bAbort(false),
34 m_pCurStates(new CPDF_AllStates), 34 m_pCurStates(new CPDF_AllStates),
35 m_pLastTextObject(nullptr), 35 m_pLastTextObject(nullptr),
36 m_DefFontSize(0), 36 m_DefFontSize(0),
37 m_pPathPoints(nullptr), 37 m_pPathPoints(nullptr),
38 m_PathPointCount(0), 38 m_PathPointCount(0),
39 m_PathAllocSize(0), 39 m_PathAllocSize(0),
40 m_PathCurrentX(0.0f), 40 m_PathCurrentX(0.0f),
41 m_PathCurrentY(0.0f), 41 m_PathCurrentY(0.0f),
42 m_PathClipType(0), 42 m_PathClipType(0),
43 m_pLastImage(nullptr), 43 m_pLastImage(nullptr),
44 m_pLastImageDict(nullptr), 44 m_pLastImageDict(nullptr),
45 m_pLastCloneImageDict(nullptr), 45 m_pLastCloneImageDict(nullptr),
46 m_bReleaseLastDict(TRUE), 46 m_bReleaseLastDict(true),
47 m_bColored(FALSE), 47 m_bColored(false),
48 m_bResourceMissing(FALSE) 48 m_bResourceMissing(false)
49 { 49 {
50 if (pmtContentToUser) { 50 if (pmtContentToUser) {
51 m_mtContentToUser = *pmtContentToUser; 51 m_mtContentToUser = *pmtContentToUser;
52 } 52 }
53 if (pOptions) { 53 if (pOptions) {
54 m_Options = *pOptions; 54 m_Options = *pOptions;
55 } 55 }
56 if (!m_pResources) { 56 if (!m_pResources) {
57 m_pResources = m_pParentResources; 57 m_pResources = m_pParentResources;
58 } 58 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 if (param.m_Type == PDFOBJ_NAME) { 177 if (param.m_Type == PDFOBJ_NAME) {
178 CPDF_Name* pName = CPDF_Name::Create(CFX_ByteString(param.m_Name.m_Buffe r, param.m_Name.m_Len)); 178 CPDF_Name* pName = CPDF_Name::Create(CFX_ByteString(param.m_Name.m_Buffe r, param.m_Name.m_Len));
179 param.m_Type = 0; 179 param.m_Type = 0;
180 param.m_pObject = pName; 180 param.m_pObject = pName;
181 return pName; 181 return pName;
182 } 182 }
183 if (param.m_Type == 0) { 183 if (param.m_Type == 0) {
184 return param.m_pObject; 184 return param.m_pObject;
185 } 185 }
186 ASSERT(FALSE); 186 ASSERT(false);
187 return NULL; 187 return NULL;
188 } 188 }
189 CFX_ByteString CPDF_StreamContentParser::GetString(FX_DWORD index) 189 CFX_ByteString CPDF_StreamContentParser::GetString(FX_DWORD index)
190 { 190 {
191 if (index >= m_ParamCount) { 191 if (index >= m_ParamCount) {
192 return CFX_ByteString(); 192 return CFX_ByteString();
193 } 193 }
194 int real_index = m_ParamStartPos + m_ParamCount - index - 1; 194 int real_index = m_ParamStartPos + m_ParamCount - index - 1;
195 if (real_index >= PARAM_BUF_SIZE) { 195 if (real_index >= PARAM_BUF_SIZE) {
196 real_index -= PARAM_BUF_SIZE; 196 real_index -= PARAM_BUF_SIZE;
(...skipping 22 matching lines...) Expand all
219 } 219 }
220 if (param.m_Type == 0 && param.m_pObject) { 220 if (param.m_Type == 0 && param.m_pObject) {
221 return param.m_pObject->GetNumber(); 221 return param.m_pObject->GetNumber();
222 } 222 }
223 return 0; 223 return 0;
224 } 224 }
225 FX_FLOAT CPDF_StreamContentParser::GetNumber16(FX_DWORD index) 225 FX_FLOAT CPDF_StreamContentParser::GetNumber16(FX_DWORD index)
226 { 226 {
227 return GetNumber(index); 227 return GetNumber(index);
228 } 228 }
229 void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj, FX_BOOL b Color, FX_BOOL bText, FX_BOOL bGraph) 229 void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj, bool bCol or, bool bText, bool bGraph)
230 { 230 {
231 pObj->m_GeneralState = m_pCurStates->m_GeneralState; 231 pObj->m_GeneralState = m_pCurStates->m_GeneralState;
232 pObj->m_ClipPath = m_pCurStates->m_ClipPath; 232 pObj->m_ClipPath = m_pCurStates->m_ClipPath;
233 pObj->m_ContentMark = m_CurContentMark; 233 pObj->m_ContentMark = m_CurContentMark;
234 if (bColor) { 234 if (bColor) {
235 pObj->m_ColorState = m_pCurStates->m_ColorState; 235 pObj->m_ColorState = m_pCurStates->m_ColorState;
236 } 236 }
237 if (bGraph) { 237 if (bGraph) {
238 pObj->m_GraphState = m_pCurStates->m_GraphState; 238 pObj->m_GraphState = m_pCurStates->m_GraphState;
239 } 239 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 {FXBSTR_ID('r', 'g', 0, 0), &CPDF_StreamContentParser::Handle_SetRGBColor_Fi ll}, 311 {FXBSTR_ID('r', 'g', 0, 0), &CPDF_StreamContentParser::Handle_SetRGBColor_Fi ll},
312 {FXBSTR_ID('r', 'i', 0, 0), &CPDF_StreamContentParser::Handle_SetRenderInten t}, 312 {FXBSTR_ID('r', 'i', 0, 0), &CPDF_StreamContentParser::Handle_SetRenderInten t},
313 {FXBSTR_ID('s', 0, 0, 0), &CPDF_StreamContentParser::Handle_CloseS trokePath}, 313 {FXBSTR_ID('s', 0, 0, 0), &CPDF_StreamContentParser::Handle_CloseS trokePath},
314 {FXBSTR_ID('s', 'c', 0, 0), &CPDF_StreamContentParser::Handle_SetColor_Fill} , 314 {FXBSTR_ID('s', 'c', 0, 0), &CPDF_StreamContentParser::Handle_SetColor_Fill} ,
315 {FXBSTR_ID('s', 'c', 'n', 0), &CPDF_StreamContentParser::Handle_SetCol orPS_Fill}, 315 {FXBSTR_ID('s', 'c', 'n', 0), &CPDF_StreamContentParser::Handle_SetCol orPS_Fill},
316 {FXBSTR_ID('s', 'h', 0, 0), &CPDF_StreamContentParser::Handle_ShadeFill}, 316 {FXBSTR_ID('s', 'h', 0, 0), &CPDF_StreamContentParser::Handle_ShadeFill},
317 {FXBSTR_ID('v', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveT o_23}, 317 {FXBSTR_ID('v', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveT o_23},
318 {FXBSTR_ID('w', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLin eWidth}, 318 {FXBSTR_ID('w', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLin eWidth},
319 {FXBSTR_ID('y', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveT o_13}, 319 {FXBSTR_ID('y', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveT o_13},
320 }; 320 };
321 FX_BOOL CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) 321 bool CPDF_StreamContentParser::OnOperator(const FX_CHAR* op)
322 { 322 {
323 int i = 0; 323 int i = 0;
324 FX_DWORD opid = 0; 324 FX_DWORD opid = 0;
325 while (i < 4 && op[i]) { 325 while (i < 4 && op[i]) {
326 opid = (opid << 8) + op[i]; 326 opid = (opid << 8) + op[i];
327 i ++; 327 i ++;
328 } 328 }
329 while (i < 4) { 329 while (i < 4) {
330 opid <<= 8; 330 opid <<= 8;
331 i ++; 331 i ++;
332 }; 332 };
333 int low = 0, high = sizeof g_OpCodes / sizeof(OpCode) - 1; 333 int low = 0, high = sizeof g_OpCodes / sizeof(OpCode) - 1;
334 while (low <= high) { 334 while (low <= high) {
335 int middle = (low + high) / 2; 335 int middle = (low + high) / 2;
336 int compare = opid - g_OpCodes[middle].m_OpId; 336 int compare = opid - g_OpCodes[middle].m_OpId;
337 if (compare == 0) { 337 if (compare == 0) {
338 (this->*g_OpCodes[middle].m_OpHandler)(); 338 (this->*g_OpCodes[middle].m_OpHandler)();
339 return TRUE; 339 return true;
340 } else if (compare < 0) { 340 } else if (compare < 0) {
341 high = middle - 1; 341 high = middle - 1;
342 } else { 342 } else {
343 low = middle + 1; 343 low = middle + 1;
344 } 344 }
345 } 345 }
346 return m_CompatCount != 0; 346 return m_CompatCount != 0;
347 } 347 }
348 void CPDF_StreamContentParser::Handle_CloseFillStrokePath() 348 void CPDF_StreamContentParser::Handle_CloseFillStrokePath()
349 { 349 {
350 if (m_Options.m_bTextOnly) { 350 if (m_Options.m_bTextOnly) {
351 return; 351 return;
352 } 352 }
353 Handle_ClosePath(); 353 Handle_ClosePath();
354 AddPathObject(FXFILL_WINDING, TRUE); 354 AddPathObject(FXFILL_WINDING, true);
355 } 355 }
356 void CPDF_StreamContentParser::Handle_FillStrokePath() 356 void CPDF_StreamContentParser::Handle_FillStrokePath()
357 { 357 {
358 if (m_Options.m_bTextOnly) { 358 if (m_Options.m_bTextOnly) {
359 return; 359 return;
360 } 360 }
361 AddPathObject(FXFILL_WINDING, TRUE); 361 AddPathObject(FXFILL_WINDING, true);
362 } 362 }
363 void CPDF_StreamContentParser::Handle_CloseEOFillStrokePath() 363 void CPDF_StreamContentParser::Handle_CloseEOFillStrokePath()
364 { 364 {
365 if (m_Options.m_bTextOnly) { 365 if (m_Options.m_bTextOnly) {
366 return; 366 return;
367 } 367 }
368 AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE); 368 AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE);
369 AddPathObject(FXFILL_ALTERNATE, TRUE); 369 AddPathObject(FXFILL_ALTERNATE, true);
370 } 370 }
371 void CPDF_StreamContentParser::Handle_EOFillStrokePath() 371 void CPDF_StreamContentParser::Handle_EOFillStrokePath()
372 { 372 {
373 if (m_Options.m_bTextOnly) { 373 if (m_Options.m_bTextOnly) {
374 return; 374 return;
375 } 375 }
376 AddPathObject(FXFILL_ALTERNATE, TRUE); 376 AddPathObject(FXFILL_ALTERNATE, true);
377 } 377 }
378 void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() 378 void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary()
379 { 379 {
380 if (!m_Options.m_bMarkedContent) { 380 if (!m_Options.m_bMarkedContent) {
381 return; 381 return;
382 } 382 }
383 CFX_ByteString tag = GetString(1); 383 CFX_ByteString tag = GetString(1);
384 CPDF_Object* pProperty = GetObject(0); 384 CPDF_Object* pProperty = GetObject(0);
385 if (pProperty == NULL) { 385 if (pProperty == NULL) {
386 return; 386 return;
387 } 387 }
388 FX_BOOL bDirect = TRUE; 388 bool bDirect = true;
389 if (pProperty->GetType() == PDFOBJ_NAME) { 389 if (pProperty->GetType() == PDFOBJ_NAME) {
390 pProperty = FindResourceObj(FX_BSTRC("Properties"), pProperty->GetString ()); 390 pProperty = FindResourceObj(FX_BSTRC("Properties"), pProperty->GetString ());
391 if (pProperty == NULL) { 391 if (pProperty == NULL) {
392 return; 392 return;
393 } 393 }
394 bDirect = FALSE; 394 bDirect = false;
395 } 395 }
396 if (pProperty->GetType() != PDFOBJ_DICTIONARY) { 396 if (pProperty->GetType() != PDFOBJ_DICTIONARY) {
397 return; 397 return;
398 } 398 }
399 m_CurContentMark.GetModify()->AddMark(tag, (CPDF_Dictionary*)pProperty, bDir ect); 399 m_CurContentMark.GetModify()->AddMark(tag, (CPDF_Dictionary*)pProperty, bDir ect);
400 } 400 }
401 void CPDF_StreamContentParser::Handle_BeginMarkedContent() 401 void CPDF_StreamContentParser::Handle_BeginMarkedContent()
402 { 402 {
403 if (!m_Options.m_bMarkedContent) { 403 if (!m_Options.m_bMarkedContent) {
404 return; 404 return;
405 } 405 }
406 CFX_ByteString tag = GetString(0); 406 CFX_ByteString tag = GetString(0);
407 m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); 407 m_CurContentMark.GetModify()->AddMark(tag, NULL, false);
408 } 408 }
409 struct _FX_BSTR { 409 struct _FX_BSTR {
410 const FX_CHAR* m_Ptr; 410 const FX_CHAR* m_Ptr;
411 int m_Size; 411 int m_Size;
412 }; 412 };
413 #define _FX_BSTRC(str) {str, sizeof(str)-1} 413 #define _FX_BSTRC(str) {str, sizeof(str)-1}
414 const _FX_BSTR _PDF_InlineKeyAbbr[] = { 414 const _FX_BSTR _PDF_InlineKeyAbbr[] = {
415 _FX_BSTRC("BitsPerComponent"), _FX_BSTRC("BPC"), 415 _FX_BSTRC("BitsPerComponent"), _FX_BSTRC("BPC"),
416 _FX_BSTRC("ColorSpace"), _FX_BSTRC("CS"), 416 _FX_BSTRC("ColorSpace"), _FX_BSTRC("CS"),
417 _FX_BSTRC("Decode"), _FX_BSTRC("D"), 417 _FX_BSTRC("Decode"), _FX_BSTRC("D"),
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : NULL; 614 CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : NULL;
615 if (pArray == NULL) { 615 if (pArray == NULL) {
616 return; 616 return;
617 } 617 }
618 m_pCurStates->SetLineDash(pArray, GetNumber(0), 1.0f); 618 m_pCurStates->SetLineDash(pArray, GetNumber(0), 1.0f);
619 } 619 }
620 void CPDF_StreamContentParser::Handle_SetCharWidth() 620 void CPDF_StreamContentParser::Handle_SetCharWidth()
621 { 621 {
622 m_Type3Data[0] = GetNumber(1); 622 m_Type3Data[0] = GetNumber(1);
623 m_Type3Data[1] = GetNumber(0); 623 m_Type3Data[1] = GetNumber(0);
624 m_bColored = TRUE; 624 m_bColored = true;
625 } 625 }
626 void CPDF_StreamContentParser::Handle_SetCachedDevice() 626 void CPDF_StreamContentParser::Handle_SetCachedDevice()
627 { 627 {
628 for (int i = 0; i < 6; i ++) { 628 for (int i = 0; i < 6; i ++) {
629 m_Type3Data[i] = GetNumber(5 - i); 629 m_Type3Data[i] = GetNumber(5 - i);
630 } 630 }
631 m_bColored = FALSE; 631 m_bColored = false;
632 } 632 }
633 void CPDF_StreamContentParser::Handle_ExecuteXObject() 633 void CPDF_StreamContentParser::Handle_ExecuteXObject()
634 { 634 {
635 CFX_ByteString name = GetString(0); 635 CFX_ByteString name = GetString(0);
636 if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() && m_pLastImage->GetStream()->GetObjNum()) { 636 if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() && m_pLastImage->GetStream()->GetObjNum()) {
637 AddImage(NULL, m_pLastImage, FALSE); 637 AddImage(NULL, m_pLastImage, false);
638 return; 638 return;
639 } 639 }
640 if (m_Options.m_bTextOnly) { 640 if (m_Options.m_bTextOnly) {
641 CPDF_Object* pRes = NULL; 641 CPDF_Object* pRes = NULL;
642 if (m_pResources == NULL) { 642 if (m_pResources == NULL) {
643 return; 643 return;
644 } 644 }
645 if (m_pResources == m_pPageResources) { 645 if (m_pResources == m_pPageResources) {
646 CPDF_Dictionary* pList = m_pResources->GetDict(FX_BSTRC("XObject")); 646 CPDF_Dictionary* pList = m_pResources->GetDict(FX_BSTRC("XObject"));
647 if (pList == NULL) { 647 if (pList == NULL) {
(...skipping 17 matching lines...) Expand all
665 if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { 665 if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) {
666 return; 666 return;
667 } 667 }
668 } else { 668 } else {
669 pRes = pList->GetElement(name); 669 pRes = pList->GetElement(name);
670 if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { 670 if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) {
671 return; 671 return;
672 } 672 }
673 } 673 }
674 } 674 }
675 FX_BOOL bForm; 675 bool bForm;
676 if (m_pDocument->IsFormStream(((CPDF_Reference*)pRes)->GetRefObjNum(), b Form) && !bForm) { 676 if (m_pDocument->IsFormStream(((CPDF_Reference*)pRes)->GetRefObjNum(), b Form) && !bForm) {
677 return; 677 return;
678 } 678 }
679 } 679 }
680 CPDF_Stream* pXObject = (CPDF_Stream*)FindResourceObj(FX_BSTRC("XObject"), n ame); 680 CPDF_Stream* pXObject = (CPDF_Stream*)FindResourceObj(FX_BSTRC("XObject"), n ame);
681 if (pXObject == NULL || pXObject->GetType() != PDFOBJ_STREAM) { 681 if (pXObject == NULL || pXObject->GetType() != PDFOBJ_STREAM) {
682 m_bResourceMissing = TRUE; 682 m_bResourceMissing = true;
683 return; 683 return;
684 } 684 }
685 CFX_ByteStringC type = pXObject->GetDict() ? pXObject->GetDict()->GetConstSt ring(FX_BSTRC("Subtype")) : CFX_ByteStringC(); 685 CFX_ByteStringC type = pXObject->GetDict() ? pXObject->GetDict()->GetConstSt ring(FX_BSTRC("Subtype")) : CFX_ByteStringC();
686 if (type == FX_BSTRC("Image")) { 686 if (type == FX_BSTRC("Image")) {
687 if (m_Options.m_bTextOnly) { 687 if (m_Options.m_bTextOnly) {
688 return; 688 return;
689 } 689 }
690 CPDF_ImageObject* pObj = AddImage(pXObject, NULL, FALSE); 690 CPDF_ImageObject* pObj = AddImage(pXObject, NULL, false);
691 m_LastImageName = name; 691 m_LastImageName = name;
692 m_pLastImage = pObj->m_pImage; 692 m_pLastImage = pObj->m_pImage;
693 } else if (type == FX_BSTRC("Form")) { 693 } else if (type == FX_BSTRC("Form")) {
694 AddForm(pXObject); 694 AddForm(pXObject);
695 } else { 695 } else {
696 return; 696 return;
697 } 697 }
698 } 698 }
699 void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) 699 void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream)
700 { 700 {
(...skipping 10 matching lines...) Expand all
711 ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.righ t, form_bbox.top); 711 ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.righ t, form_bbox.top);
712 ClipPath.Transform(&form_matrix); 712 ClipPath.Transform(&form_matrix);
713 form_bbox.Transform(&form_matrix); 713 form_bbox.Transform(&form_matrix);
714 } 714 }
715 CPDF_StreamContentParser parser( 715 CPDF_StreamContentParser parser(
716 m_pDocument, m_pPageResources, m_pResources, &m_mtContentToUser, 716 m_pDocument, m_pPageResources, m_pResources, &m_mtContentToUser,
717 m_pObjectList, pResources, &form_bbox, &m_Options, 717 m_pObjectList, pResources, &form_bbox, &m_Options,
718 m_pCurStates.get(), m_Level + 1); 718 m_pCurStates.get(), m_Level + 1);
719 parser.m_pCurStates->m_CTM = form_matrix; 719 parser.m_pCurStates->m_CTM = form_matrix;
720 if (ClipPath.NotNull()) { 720 if (ClipPath.NotNull()) {
721 parser.m_pCurStates->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, TRUE); 721 parser.m_pCurStates->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, true);
722 } 722 }
723 CPDF_StreamAcc stream; 723 CPDF_StreamAcc stream;
724 stream.LoadAllData(pStream, FALSE); 724 stream.LoadAllData(pStream, false);
725 if (stream.GetSize() == 0) { 725 if (stream.GetSize() == 0) {
726 return; 726 return;
727 } 727 }
728 parser.Parse(stream.GetData(), stream.GetSize(), 0); 728 parser.Parse(stream.GetData(), stream.GetSize(), 0);
729 return; 729 return;
730 } 730 }
731 CPDF_FormObject* pFormObj = new CPDF_FormObject; 731 CPDF_FormObject* pFormObj = new CPDF_FormObject;
732 pFormObj->m_pForm = new CPDF_Form(m_pDocument, m_pPageResources, pStream, m_ pResources); 732 pFormObj->m_pForm = new CPDF_Form(m_pDocument, m_pPageResources, pStream, m_ pResources);
733 pFormObj->m_FormMatrix = m_pCurStates->m_CTM; 733 pFormObj->m_FormMatrix = m_pCurStates->m_CTM;
734 pFormObj->m_FormMatrix.Concat(m_mtContentToUser); 734 pFormObj->m_FormMatrix.Concat(m_mtContentToUser);
735 CPDF_AllStates status; 735 CPDF_AllStates status;
736 status.m_GeneralState = m_pCurStates->m_GeneralState; 736 status.m_GeneralState = m_pCurStates->m_GeneralState;
737 status.m_GraphState = m_pCurStates->m_GraphState; 737 status.m_GraphState = m_pCurStates->m_GraphState;
738 status.m_ColorState = m_pCurStates->m_ColorState; 738 status.m_ColorState = m_pCurStates->m_ColorState;
739 status.m_TextState = m_pCurStates->m_TextState; 739 status.m_TextState = m_pCurStates->m_TextState;
740 pFormObj->m_pForm->ParseContent(&status, NULL, NULL, &m_Options, m_Level + 1 ); 740 pFormObj->m_pForm->ParseContent(&status, NULL, NULL, &m_Options, m_Level + 1 );
741 if (!m_pObjectList->m_bBackgroundAlphaNeeded && pFormObj->m_pForm->m_bBackgr oundAlphaNeeded) { 741 if (!m_pObjectList->m_bBackgroundAlphaNeeded && pFormObj->m_pForm->m_bBackgr oundAlphaNeeded) {
742 m_pObjectList->m_bBackgroundAlphaNeeded = TRUE; 742 m_pObjectList->m_bBackgroundAlphaNeeded = true;
743 } 743 }
744 pFormObj->CalcBoundingBox(); 744 pFormObj->CalcBoundingBox();
745 SetGraphicStates(pFormObj, TRUE, TRUE, TRUE); 745 SetGraphicStates(pFormObj, true, true, true);
746 m_pObjectList->m_ObjectList.AddTail(pFormObj); 746 m_pObjectList->m_ObjectList.AddTail(pFormObj);
747 } 747 }
748 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, CPDF_ Image* pImage, FX_BOOL bInline) 748 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, CPDF_ Image* pImage, bool bInline)
749 { 749 {
750 if (pStream == NULL && pImage == NULL) { 750 if (pStream == NULL && pImage == NULL) {
751 return NULL; 751 return NULL;
752 } 752 }
753 CFX_AffineMatrix ImageMatrix; 753 CFX_AffineMatrix ImageMatrix;
754 ImageMatrix.Copy(m_pCurStates->m_CTM); 754 ImageMatrix.Copy(m_pCurStates->m_CTM);
755 ImageMatrix.Concat(m_mtContentToUser); 755 ImageMatrix.Concat(m_mtContentToUser);
756 CPDF_ImageObject* pImageObj = new CPDF_ImageObject; 756 CPDF_ImageObject* pImageObj = new CPDF_ImageObject;
757 if (pImage) { 757 if (pImage) {
758 pImageObj->m_pImage = m_pDocument->GetPageData()->GetImage(pImage->GetSt ream()); 758 pImageObj->m_pImage = m_pDocument->GetPageData()->GetImage(pImage->GetSt ream());
759 } else if (pStream->GetObjNum()) { 759 } else if (pStream->GetObjNum()) {
760 pImageObj->m_pImage = m_pDocument->LoadImageF(pStream); 760 pImageObj->m_pImage = m_pDocument->LoadImageF(pStream);
761 } else { 761 } else {
762 pImageObj->m_pImage = new CPDF_Image(m_pDocument); 762 pImageObj->m_pImage = new CPDF_Image(m_pDocument);
763 pImageObj->m_pImage->LoadImageF(pStream, bInline); 763 pImageObj->m_pImage->LoadImageF(pStream, bInline);
764 } 764 }
765 SetGraphicStates(pImageObj, pImageObj->m_pImage->IsMask(), FALSE, FALSE); 765 SetGraphicStates(pImageObj, pImageObj->m_pImage->IsMask(), false, false);
766 pImageObj->m_Matrix = ImageMatrix; 766 pImageObj->m_Matrix = ImageMatrix;
767 pImageObj->CalcBoundingBox(); 767 pImageObj->CalcBoundingBox();
768 m_pObjectList->m_ObjectList.AddTail(pImageObj); 768 m_pObjectList->m_ObjectList.AddTail(pImageObj);
769 return pImageObj; 769 return pImageObj;
770 } 770 }
771 void CPDF_StreamContentParser::Handle_MarkPlace_Dictionary() 771 void CPDF_StreamContentParser::Handle_MarkPlace_Dictionary()
772 { 772 {
773 } 773 }
774 void CPDF_StreamContentParser::Handle_EndImage() 774 void CPDF_StreamContentParser::Handle_EndImage()
775 { 775 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 { 809 {
810 if (m_CompatCount) { 810 if (m_CompatCount) {
811 m_CompatCount --; 811 m_CompatCount --;
812 } 812 }
813 } 813 }
814 void CPDF_StreamContentParser::Handle_FillPath() 814 void CPDF_StreamContentParser::Handle_FillPath()
815 { 815 {
816 if (m_Options.m_bTextOnly) { 816 if (m_Options.m_bTextOnly) {
817 return; 817 return;
818 } 818 }
819 AddPathObject(FXFILL_WINDING, FALSE); 819 AddPathObject(FXFILL_WINDING, false);
820 } 820 }
821 void CPDF_StreamContentParser::Handle_FillPathOld() 821 void CPDF_StreamContentParser::Handle_FillPathOld()
822 { 822 {
823 if (m_Options.m_bTextOnly) { 823 if (m_Options.m_bTextOnly) {
824 return; 824 return;
825 } 825 }
826 AddPathObject(FXFILL_WINDING, FALSE); 826 AddPathObject(FXFILL_WINDING, false);
827 } 827 }
828 void CPDF_StreamContentParser::Handle_EOFillPath() 828 void CPDF_StreamContentParser::Handle_EOFillPath()
829 { 829 {
830 if (m_Options.m_bTextOnly) { 830 if (m_Options.m_bTextOnly) {
831 return; 831 return;
832 } 832 }
833 AddPathObject(FXFILL_ALTERNATE, FALSE); 833 AddPathObject(FXFILL_ALTERNATE, false);
834 } 834 }
835 void CPDF_StreamContentParser::Handle_SetGray_Fill() 835 void CPDF_StreamContentParser::Handle_SetGray_Fill()
836 { 836 {
837 FX_FLOAT value = GetNumber(0); 837 FX_FLOAT value = GetNumber(0);
838 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY); 838 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY);
839 m_pCurStates->m_ColorState.SetFillColor(pCS, &value, 1); 839 m_pCurStates->m_ColorState.SetFillColor(pCS, &value, 1);
840 } 840 }
841 void CPDF_StreamContentParser::Handle_SetGray_Stroke() 841 void CPDF_StreamContentParser::Handle_SetGray_Stroke()
842 { 842 {
843 FX_FLOAT value = GetNumber(0); 843 FX_FLOAT value = GetNumber(0);
844 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY); 844 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY);
845 m_pCurStates->m_ColorState.SetStrokeColor(pCS, &value, 1); 845 m_pCurStates->m_ColorState.SetStrokeColor(pCS, &value, 1);
846 } 846 }
847 void CPDF_StreamContentParser::Handle_SetExtendGraphState() 847 void CPDF_StreamContentParser::Handle_SetExtendGraphState()
848 { 848 {
849 CFX_ByteString name = GetString(0); 849 CFX_ByteString name = GetString(0);
850 CPDF_Dictionary* pGS = (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("ExtGState "), name); 850 CPDF_Dictionary* pGS = (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("ExtGState "), name);
851 if (pGS == NULL || pGS->GetType() != PDFOBJ_DICTIONARY) { 851 if (pGS == NULL || pGS->GetType() != PDFOBJ_DICTIONARY) {
852 m_bResourceMissing = TRUE; 852 m_bResourceMissing = true;
853 return; 853 return;
854 } 854 }
855 m_pCurStates->ProcessExtGS(pGS, this); 855 m_pCurStates->ProcessExtGS(pGS, this);
856 } 856 }
857 void CPDF_StreamContentParser::Handle_ClosePath() 857 void CPDF_StreamContentParser::Handle_ClosePath()
858 { 858 {
859 if (m_Options.m_bTextOnly) { 859 if (m_Options.m_bTextOnly) {
860 return; 860 return;
861 } 861 }
862 if (m_PathPointCount == 0) { 862 if (m_PathPointCount == 0) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 m_pCurStates->m_GraphState.GetModify()->m_MiterLimit = GetNumber(0); 926 m_pCurStates->m_GraphState.GetModify()->m_MiterLimit = GetNumber(0);
927 } 927 }
928 void CPDF_StreamContentParser::Handle_MarkPlace() 928 void CPDF_StreamContentParser::Handle_MarkPlace()
929 { 929 {
930 } 930 }
931 void CPDF_StreamContentParser::Handle_EndPath() 931 void CPDF_StreamContentParser::Handle_EndPath()
932 { 932 {
933 if (m_Options.m_bTextOnly) { 933 if (m_Options.m_bTextOnly) {
934 return; 934 return;
935 } 935 }
936 AddPathObject(0, FALSE); 936 AddPathObject(0, false);
937 } 937 }
938 void CPDF_StreamContentParser::Handle_SaveGraphState() 938 void CPDF_StreamContentParser::Handle_SaveGraphState()
939 { 939 {
940 CPDF_AllStates* pStates = new CPDF_AllStates; 940 CPDF_AllStates* pStates = new CPDF_AllStates;
941 pStates->Copy(*m_pCurStates); 941 pStates->Copy(*m_pCurStates);
942 m_StateStack.Add(pStates); 942 m_StateStack.Add(pStates);
943 } 943 }
944 void CPDF_StreamContentParser::Handle_RestoreGraphState() 944 void CPDF_StreamContentParser::Handle_RestoreGraphState()
945 { 945 {
946 int size = m_StateStack.GetSize(); 946 int size = m_StateStack.GetSize();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 } 991 }
992 void CPDF_StreamContentParser::Handle_SetRenderIntent() 992 void CPDF_StreamContentParser::Handle_SetRenderIntent()
993 { 993 {
994 } 994 }
995 void CPDF_StreamContentParser::Handle_CloseStrokePath() 995 void CPDF_StreamContentParser::Handle_CloseStrokePath()
996 { 996 {
997 if (m_Options.m_bTextOnly) { 997 if (m_Options.m_bTextOnly) {
998 return; 998 return;
999 } 999 }
1000 Handle_ClosePath(); 1000 Handle_ClosePath();
1001 AddPathObject(0, TRUE); 1001 AddPathObject(0, true);
1002 } 1002 }
1003 void CPDF_StreamContentParser::Handle_StrokePath() 1003 void CPDF_StreamContentParser::Handle_StrokePath()
1004 { 1004 {
1005 if (m_Options.m_bTextOnly) { 1005 if (m_Options.m_bTextOnly) {
1006 return; 1006 return;
1007 } 1007 }
1008 AddPathObject(0, TRUE); 1008 AddPathObject(0, true);
1009 } 1009 }
1010 void CPDF_StreamContentParser::Handle_SetColor_Fill() 1010 void CPDF_StreamContentParser::Handle_SetColor_Fill()
1011 { 1011 {
1012 if (m_Options.m_bTextOnly) { 1012 if (m_Options.m_bTextOnly) {
1013 return; 1013 return;
1014 } 1014 }
1015 FX_FLOAT values[4]; 1015 FX_FLOAT values[4];
1016 int nargs = m_ParamCount; 1016 int nargs = m_ParamCount;
1017 if (nargs > 4) { 1017 if (nargs > 4) {
1018 nargs = 4; 1018 nargs = 4;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 nvalues --; 1052 nvalues --;
1053 } 1053 }
1054 FX_FLOAT* values = NULL; 1054 FX_FLOAT* values = NULL;
1055 if (nvalues) { 1055 if (nvalues) {
1056 values = FX_Alloc(FX_FLOAT, nvalues); 1056 values = FX_Alloc(FX_FLOAT, nvalues);
1057 for (int i = 0; i < nvalues; i ++) { 1057 for (int i = 0; i < nvalues; i ++) {
1058 values[i] = GetNumber(nargs - i - 1); 1058 values[i] = GetNumber(nargs - i - 1);
1059 } 1059 }
1060 } 1060 }
1061 if (nvalues != nargs) { 1061 if (nvalues != nargs) {
1062 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE); 1062 CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
1063 if (pPattern) { 1063 if (pPattern) {
1064 m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues) ; 1064 m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues) ;
1065 } 1065 }
1066 } else { 1066 } else {
1067 m_pCurStates->m_ColorState.SetFillColor(NULL, values, nvalues); 1067 m_pCurStates->m_ColorState.SetFillColor(NULL, values, nvalues);
1068 } 1068 }
1069 if (values) { 1069 if (values) {
1070 FX_Free(values); 1070 FX_Free(values);
1071 } 1071 }
1072 } 1072 }
(...skipping 12 matching lines...) Expand all
1085 nvalues --; 1085 nvalues --;
1086 } 1086 }
1087 FX_FLOAT* values = NULL; 1087 FX_FLOAT* values = NULL;
1088 if (nvalues) { 1088 if (nvalues) {
1089 values = FX_Alloc(FX_FLOAT, nvalues); 1089 values = FX_Alloc(FX_FLOAT, nvalues);
1090 for (int i = 0; i < nvalues; i ++) { 1090 for (int i = 0; i < nvalues; i ++) {
1091 values[i] = GetNumber(nargs - i - 1); 1091 values[i] = GetNumber(nargs - i - 1);
1092 } 1092 }
1093 } 1093 }
1094 if (nvalues != nargs) { 1094 if (nvalues != nargs) {
1095 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE); 1095 CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
1096 if (pPattern) { 1096 if (pPattern) {
1097 m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalue s); 1097 m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalue s);
1098 } 1098 }
1099 } else { 1099 } else {
1100 m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nvalues); 1100 m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nvalues);
1101 } 1101 }
1102 if (values) { 1102 if (values) {
1103 FX_Free(values); 1103 FX_Free(values);
1104 } 1104 }
1105 } 1105 }
1106 CFX_FloatRect _GetShadingBBox(CPDF_Stream* pStream, int type, const CFX_AffineMa trix* pMatrix, 1106 CFX_FloatRect _GetShadingBBox(CPDF_Stream* pStream, int type, const CFX_AffineMa trix* pMatrix,
1107 CPDF_Function** pFuncs, int nFuncs, CPDF_ColorSpac e* pCS); 1107 CPDF_Function** pFuncs, int nFuncs, CPDF_ColorSpac e* pCS);
1108 void CPDF_StreamContentParser::Handle_ShadeFill() 1108 void CPDF_StreamContentParser::Handle_ShadeFill()
1109 { 1109 {
1110 if (m_Options.m_bTextOnly) { 1110 if (m_Options.m_bTextOnly) {
1111 return; 1111 return;
1112 } 1112 }
1113 CPDF_Pattern* pPattern = FindPattern(GetString(0), TRUE); 1113 CPDF_Pattern* pPattern = FindPattern(GetString(0), true);
1114 if (pPattern == NULL) { 1114 if (pPattern == NULL) {
1115 return; 1115 return;
1116 } 1116 }
1117 if (pPattern->m_PatternType != PATTERN_SHADING) { 1117 if (pPattern->m_PatternType != PATTERN_SHADING) {
1118 return; 1118 return;
1119 } 1119 }
1120 CPDF_ShadingPattern* pShading = (CPDF_ShadingPattern*)pPattern; 1120 CPDF_ShadingPattern* pShading = (CPDF_ShadingPattern*)pPattern;
1121 if (!pShading->m_bShadingObj) { 1121 if (!pShading->m_bShadingObj) {
1122 return; 1122 return;
1123 } 1123 }
1124 if (!pShading->Load()) { 1124 if (!pShading->Load()) {
1125 return; 1125 return;
1126 } 1126 }
1127 CPDF_ShadingObject* pObj = new CPDF_ShadingObject; 1127 CPDF_ShadingObject* pObj = new CPDF_ShadingObject;
1128 pObj->m_pShading = pShading; 1128 pObj->m_pShading = pShading;
1129 SetGraphicStates(pObj, FALSE, FALSE, FALSE); 1129 SetGraphicStates(pObj, false, false, false);
1130 pObj->m_Matrix = m_pCurStates->m_CTM; 1130 pObj->m_Matrix = m_pCurStates->m_CTM;
1131 pObj->m_Matrix.Concat(m_mtContentToUser); 1131 pObj->m_Matrix.Concat(m_mtContentToUser);
1132 CFX_FloatRect bbox; 1132 CFX_FloatRect bbox;
1133 if (!pObj->m_ClipPath.IsNull()) { 1133 if (!pObj->m_ClipPath.IsNull()) {
1134 bbox = pObj->m_ClipPath.GetClipBox(); 1134 bbox = pObj->m_ClipPath.GetClipBox();
1135 } else { 1135 } else {
1136 bbox = m_BBox; 1136 bbox = m_BBox;
1137 } 1137 }
1138 if (pShading->m_ShadingType >= 4) { 1138 if (pShading->m_ShadingType >= 4) {
1139 bbox.Intersect(_GetShadingBBox((CPDF_Stream*)pShading->m_pShadingObj, pS hading->m_ShadingType, &pObj->m_Matrix, 1139 bbox.Intersect(_GetShadingBBox((CPDF_Stream*)pShading->m_pShadingObj, pS hading->m_ShadingType, &pObj->m_Matrix,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 CPDF_Object* pRes = pList->GetElementValue(name); 1198 CPDF_Object* pRes = pList->GetElementValue(name);
1199 return pRes; 1199 return pRes;
1200 } 1200 }
1201 CPDF_Object* pRes = pList->GetElementValue(name); 1201 CPDF_Object* pRes = pList->GetElementValue(name);
1202 return pRes; 1202 return pRes;
1203 } 1203 }
1204 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) 1204 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name)
1205 { 1205 {
1206 CPDF_Dictionary* pFontDict = (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("Fon t"), name); 1206 CPDF_Dictionary* pFontDict = (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("Fon t"), name);
1207 if (pFontDict == NULL || pFontDict->GetType() != PDFOBJ_DICTIONARY) { 1207 if (pFontDict == NULL || pFontDict->GetType() != PDFOBJ_DICTIONARY) {
1208 m_bResourceMissing = TRUE; 1208 m_bResourceMissing = true;
1209 return CPDF_Font::GetStockFont(m_pDocument, FX_BSTRC("Helvetica")); 1209 return CPDF_Font::GetStockFont(m_pDocument, FX_BSTRC("Helvetica"));
1210 } 1210 }
1211 CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict); 1211 CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict);
1212 if (pFont && pFont->GetType3Font()) { 1212 if (pFont && pFont->GetType3Font()) {
1213 pFont->GetType3Font()->SetPageResources(m_pResources); 1213 pFont->GetType3Font()->SetPageResources(m_pResources);
1214 pFont->GetType3Font()->CheckType3FontMetrics(); 1214 pFont->GetType3Font()->CheckType3FontMetrics();
1215 } 1215 }
1216 return pFont; 1216 return pFont;
1217 } 1217 }
1218 CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(const CFX_ByteString& name) 1218 CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(const CFX_ByteString& name)
(...skipping 11 matching lines...) Expand all
1230 } 1230 }
1231 if (name == FX_BSTRC("DeviceRGB")) { 1231 if (name == FX_BSTRC("DeviceRGB")) {
1232 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); 1232 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB);
1233 } 1233 }
1234 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); 1234 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK);
1235 } 1235 }
1236 return m_pDocument->LoadColorSpace(pDefObj); 1236 return m_pDocument->LoadColorSpace(pDefObj);
1237 } 1237 }
1238 CPDF_Object* pCSObj = FindResourceObj(FX_BSTRC("ColorSpace"), name); 1238 CPDF_Object* pCSObj = FindResourceObj(FX_BSTRC("ColorSpace"), name);
1239 if (pCSObj == NULL) { 1239 if (pCSObj == NULL) {
1240 m_bResourceMissing = TRUE; 1240 m_bResourceMissing = true;
1241 return NULL; 1241 return NULL;
1242 } 1242 }
1243 return m_pDocument->LoadColorSpace(pCSObj); 1243 return m_pDocument->LoadColorSpace(pCSObj);
1244 } 1244 }
1245 CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name, FX_BOOL bShading) 1245 CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name, bool bShading)
1246 { 1246 {
1247 CPDF_Object* pPattern = FindResourceObj(bShading ? FX_BSTRC("Shading") : FX_ BSTRC("Pattern"), name); 1247 CPDF_Object* pPattern = FindResourceObj(bShading ? FX_BSTRC("Shading") : FX_ BSTRC("Pattern"), name);
1248 if (pPattern == NULL || (pPattern->GetType() != PDFOBJ_DICTIONARY && 1248 if (pPattern == NULL || (pPattern->GetType() != PDFOBJ_DICTIONARY &&
1249 pPattern->GetType() != PDFOBJ_STREAM)) { 1249 pPattern->GetType() != PDFOBJ_STREAM)) {
1250 m_bResourceMissing = TRUE; 1250 m_bResourceMissing = true;
1251 return NULL; 1251 return NULL;
1252 } 1252 }
1253 return m_pDocument->LoadPattern(pPattern, bShading, &m_pCurStates->m_ParentM atrix); 1253 return m_pDocument->LoadPattern(pPattern, bShading, &m_pCurStates->m_ParentM atrix);
1254 } 1254 }
1255 void CPDF_StreamContentParser::ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y) 1255 void CPDF_StreamContentParser::ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y)
1256 { 1256 {
1257 m_pCurStates->m_TextMatrix.Transform(x, y, x, y); 1257 m_pCurStates->m_TextMatrix.Transform(x, y, x, y);
1258 ConvertUserSpace(x, y); 1258 ConvertUserSpace(x, y);
1259 } 1259 }
1260 void CPDF_StreamContentParser::ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y) 1260 void CPDF_StreamContentParser::ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y)
(...skipping 18 matching lines...) Expand all
1279 return; 1279 return;
1280 } 1280 }
1281 int textmode; 1281 int textmode;
1282 if (pFont->GetFontType() == PDFFONT_TYPE3) { 1282 if (pFont->GetFontType() == PDFFONT_TYPE3) {
1283 textmode = 0; 1283 textmode = 0;
1284 } else { 1284 } else {
1285 textmode = m_pCurStates->m_TextState.GetObject()->m_TextMode; 1285 textmode = m_pCurStates->m_TextState.GetObject()->m_TextMode;
1286 } 1286 }
1287 CPDF_TextObject* pText = new CPDF_TextObject; 1287 CPDF_TextObject* pText = new CPDF_TextObject;
1288 m_pLastTextObject = pText; 1288 m_pLastTextObject = pText;
1289 SetGraphicStates(pText, TRUE, TRUE, TRUE); 1289 SetGraphicStates(pText, true, true, true);
1290 if (textmode && textmode != 3 && textmode != 4 && textmode != 7) { 1290 if (textmode && textmode != 3 && textmode != 4 && textmode != 7) {
1291 FX_FLOAT* pCTM = pText->m_TextState.GetModify()->m_CTM; 1291 FX_FLOAT* pCTM = pText->m_TextState.GetModify()->m_CTM;
1292 pCTM[0] = m_pCurStates->m_CTM.a; 1292 pCTM[0] = m_pCurStates->m_CTM.a;
1293 pCTM[1] = m_pCurStates->m_CTM.c; 1293 pCTM[1] = m_pCurStates->m_CTM.c;
1294 pCTM[2] = m_pCurStates->m_CTM.b; 1294 pCTM[2] = m_pCurStates->m_CTM.b;
1295 pCTM[3] = m_pCurStates->m_CTM.d; 1295 pCTM[3] = m_pCurStates->m_CTM.d;
1296 } 1296 }
1297 pText->SetSegments(pStrs, pKerning, nsegs); 1297 pText->SetSegments(pStrs, pKerning, nsegs);
1298 pText->m_PosX = m_pCurStates->m_TextX; 1298 pText->m_PosX = m_pCurStates->m_TextX;
1299 pText->m_PosY = m_pCurStates->m_TextY + m_pCurStates->m_TextRise; 1299 pText->m_PosY = m_pCurStates->m_TextY + m_pCurStates->m_TextRise;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 FXSYS_memcpy(pNewPoints, m_pPathPoints, m_PathAllocSize * sizeof(FX_ PATHPOINT)); 1493 FXSYS_memcpy(pNewPoints, m_pPathPoints, m_PathAllocSize * sizeof(FX_ PATHPOINT));
1494 FX_Free(m_pPathPoints); 1494 FX_Free(m_pPathPoints);
1495 } 1495 }
1496 m_pPathPoints = pNewPoints; 1496 m_pPathPoints = pNewPoints;
1497 m_PathAllocSize = newsize; 1497 m_PathAllocSize = newsize;
1498 } 1498 }
1499 m_pPathPoints[m_PathPointCount - 1].m_Flag = flag; 1499 m_pPathPoints[m_PathPointCount - 1].m_Flag = flag;
1500 m_pPathPoints[m_PathPointCount - 1].m_PointX = x; 1500 m_pPathPoints[m_PathPointCount - 1].m_PointX = x;
1501 m_pPathPoints[m_PathPointCount - 1].m_PointY = y; 1501 m_pPathPoints[m_PathPointCount - 1].m_PointY = y;
1502 } 1502 }
1503 void CPDF_StreamContentParser::AddPathObject(int FillType, FX_BOOL bStroke) 1503 void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke)
1504 { 1504 {
1505 int PathPointCount = m_PathPointCount, PathClipType = m_PathClipType; 1505 int PathPointCount = m_PathPointCount, PathClipType = m_PathClipType;
1506 m_PathPointCount = 0; 1506 m_PathPointCount = 0;
1507 m_PathClipType = 0; 1507 m_PathClipType = 0;
1508 if (PathPointCount <= 1) { 1508 if (PathPointCount <= 1) {
1509 if (PathPointCount && PathClipType) { 1509 if (PathPointCount && PathClipType) {
1510 CPDF_Path path; 1510 CPDF_Path path;
1511 path.New()->AppendRect(0, 0, 0, 0); 1511 path.New()->AppendRect(0, 0, 0, 0);
1512 m_pCurStates->m_ClipPath.AppendPath(path, FXFILL_WINDING, TRUE); 1512 m_pCurStates->m_ClipPath.AppendPath(path, FXFILL_WINDING, true);
1513 } 1513 }
1514 return; 1514 return;
1515 } 1515 }
1516 if (PathPointCount && m_pPathPoints[PathPointCount - 1].m_Flag == FXPT_MOVET O) { 1516 if (PathPointCount && m_pPathPoints[PathPointCount - 1].m_Flag == FXPT_MOVET O) {
1517 PathPointCount --; 1517 PathPointCount --;
1518 } 1518 }
1519 CPDF_Path Path; 1519 CPDF_Path Path;
1520 CFX_PathData* pPathData = Path.New(); 1520 CFX_PathData* pPathData = Path.New();
1521 pPathData->SetPointCount(PathPointCount); 1521 pPathData->SetPointCount(PathPointCount);
1522 FXSYS_memcpy(pPathData->GetPoints(), m_pPathPoints, sizeof(FX_PATHPOINT) * P athPointCount); 1522 FXSYS_memcpy(pPathData->GetPoints(), m_pPathPoints, sizeof(FX_PATHPOINT) * P athPointCount);
1523 CFX_AffineMatrix matrix = m_pCurStates->m_CTM; 1523 CFX_AffineMatrix matrix = m_pCurStates->m_CTM;
1524 matrix.Concat(m_mtContentToUser); 1524 matrix.Concat(m_mtContentToUser);
1525 if (bStroke || FillType) { 1525 if (bStroke || FillType) {
1526 CPDF_PathObject* pPathObj = new CPDF_PathObject; 1526 CPDF_PathObject* pPathObj = new CPDF_PathObject;
1527 pPathObj->m_bStroke = bStroke; 1527 pPathObj->m_bStroke = bStroke;
1528 pPathObj->m_FillType = FillType; 1528 pPathObj->m_FillType = FillType;
1529 pPathObj->m_Path = Path; 1529 pPathObj->m_Path = Path;
1530 pPathObj->m_Matrix = matrix; 1530 pPathObj->m_Matrix = matrix;
1531 SetGraphicStates(pPathObj, TRUE, FALSE, TRUE); 1531 SetGraphicStates(pPathObj, true, false, true);
1532 pPathObj->CalcBoundingBox(); 1532 pPathObj->CalcBoundingBox();
1533 m_pObjectList->m_ObjectList.AddTail(pPathObj); 1533 m_pObjectList->m_ObjectList.AddTail(pPathObj);
1534 } 1534 }
1535 if (PathClipType) { 1535 if (PathClipType) {
1536 if (!matrix.IsIdentity()) { 1536 if (!matrix.IsIdentity()) {
1537 Path.Transform(&matrix); 1537 Path.Transform(&matrix);
1538 matrix.SetIdentity(); 1538 matrix.SetIdentity();
1539 } 1539 }
1540 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); 1540 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, true);
1541 } 1541 }
1542 } 1542 }
1543 CFX_ByteString _FPDF_ByteStringFromHex(CFX_BinaryBuf& src_buf) 1543 CFX_ByteString _FPDF_ByteStringFromHex(CFX_BinaryBuf& src_buf)
1544 { 1544 {
1545 CFX_ByteTextBuf buf; 1545 CFX_ByteTextBuf buf;
1546 FX_BOOL bFirst = TRUE; 1546 bool bFirst = true;
1547 int code = 0; 1547 int code = 0;
1548 const uint8_t* str = src_buf.GetBuffer(); 1548 const uint8_t* str = src_buf.GetBuffer();
1549 FX_DWORD size = src_buf.GetSize(); 1549 FX_DWORD size = src_buf.GetSize();
1550 for (FX_DWORD i = 0; i < size; i ++) { 1550 for (FX_DWORD i = 0; i < size; i ++) {
1551 uint8_t ch = str[i]; 1551 uint8_t ch = str[i];
1552 if (ch >= '0' && ch <= '9') { 1552 if (ch >= '0' && ch <= '9') {
1553 if (bFirst) { 1553 if (bFirst) {
1554 code = (ch - '0') * 16; 1554 code = (ch - '0') * 16;
1555 } else { 1555 } else {
1556 code += ch - '0'; 1556 code += ch - '0';
(...skipping 16 matching lines...) Expand all
1573 buf.AppendChar((char)code); 1573 buf.AppendChar((char)code);
1574 } 1574 }
1575 bFirst = !bFirst; 1575 bFirst = !bFirst;
1576 } 1576 }
1577 } 1577 }
1578 if (!bFirst) { 1578 if (!bFirst) {
1579 buf.AppendChar((char)code); 1579 buf.AppendChar((char)code);
1580 } 1580 }
1581 return buf.GetByteString(); 1581 return buf.GetByteString();
1582 } 1582 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698