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/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 Loading... |
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 Loading... |
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, bool bCol
or, bool bText, bool bGraph) | 229 void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj, FX_BOOL b
Color, FX_BOOL bText, FX_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 Loading... |
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 bool CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) | 321 FX_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 } | 340 } |
341 if (compare < 0) { | 341 if (compare < 0) { |
342 high = middle - 1; | 342 high = middle - 1; |
343 } else { | 343 } else { |
344 low = middle + 1; | 344 low = middle + 1; |
345 } | 345 } |
346 } | 346 } |
347 return m_CompatCount != 0; | 347 return m_CompatCount != 0; |
348 } | 348 } |
349 void CPDF_StreamContentParser::Handle_CloseFillStrokePath() | 349 void CPDF_StreamContentParser::Handle_CloseFillStrokePath() |
350 { | 350 { |
351 if (m_Options.m_bTextOnly) { | 351 if (m_Options.m_bTextOnly) { |
352 return; | 352 return; |
353 } | 353 } |
354 Handle_ClosePath(); | 354 Handle_ClosePath(); |
355 AddPathObject(FXFILL_WINDING, true); | 355 AddPathObject(FXFILL_WINDING, TRUE); |
356 } | 356 } |
357 void CPDF_StreamContentParser::Handle_FillStrokePath() | 357 void CPDF_StreamContentParser::Handle_FillStrokePath() |
358 { | 358 { |
359 if (m_Options.m_bTextOnly) { | 359 if (m_Options.m_bTextOnly) { |
360 return; | 360 return; |
361 } | 361 } |
362 AddPathObject(FXFILL_WINDING, true); | 362 AddPathObject(FXFILL_WINDING, TRUE); |
363 } | 363 } |
364 void CPDF_StreamContentParser::Handle_CloseEOFillStrokePath() | 364 void CPDF_StreamContentParser::Handle_CloseEOFillStrokePath() |
365 { | 365 { |
366 if (m_Options.m_bTextOnly) { | 366 if (m_Options.m_bTextOnly) { |
367 return; | 367 return; |
368 } | 368 } |
369 AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE); | 369 AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE); |
370 AddPathObject(FXFILL_ALTERNATE, true); | 370 AddPathObject(FXFILL_ALTERNATE, TRUE); |
371 } | 371 } |
372 void CPDF_StreamContentParser::Handle_EOFillStrokePath() | 372 void CPDF_StreamContentParser::Handle_EOFillStrokePath() |
373 { | 373 { |
374 if (m_Options.m_bTextOnly) { | 374 if (m_Options.m_bTextOnly) { |
375 return; | 375 return; |
376 } | 376 } |
377 AddPathObject(FXFILL_ALTERNATE, true); | 377 AddPathObject(FXFILL_ALTERNATE, TRUE); |
378 } | 378 } |
379 void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() | 379 void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() |
380 { | 380 { |
381 if (!m_Options.m_bMarkedContent) { | 381 if (!m_Options.m_bMarkedContent) { |
382 return; | 382 return; |
383 } | 383 } |
384 CFX_ByteString tag = GetString(1); | 384 CFX_ByteString tag = GetString(1); |
385 CPDF_Object* pProperty = GetObject(0); | 385 CPDF_Object* pProperty = GetObject(0); |
386 if (pProperty == NULL) { | 386 if (pProperty == NULL) { |
387 return; | 387 return; |
388 } | 388 } |
389 bool bDirect = true; | 389 FX_BOOL bDirect = TRUE; |
390 if (pProperty->GetType() == PDFOBJ_NAME) { | 390 if (pProperty->GetType() == PDFOBJ_NAME) { |
391 pProperty = FindResourceObj(FX_BSTRC("Properties"), pProperty->GetString
()); | 391 pProperty = FindResourceObj(FX_BSTRC("Properties"), pProperty->GetString
()); |
392 if (pProperty == NULL) { | 392 if (pProperty == NULL) { |
393 return; | 393 return; |
394 } | 394 } |
395 bDirect = false; | 395 bDirect = FALSE; |
396 } | 396 } |
397 if (pProperty->GetType() != PDFOBJ_DICTIONARY) { | 397 if (pProperty->GetType() != PDFOBJ_DICTIONARY) { |
398 return; | 398 return; |
399 } | 399 } |
400 m_CurContentMark.GetModify()->AddMark(tag, (CPDF_Dictionary*)pProperty, bDir
ect); | 400 m_CurContentMark.GetModify()->AddMark(tag, (CPDF_Dictionary*)pProperty, bDir
ect); |
401 } | 401 } |
402 void CPDF_StreamContentParser::Handle_BeginMarkedContent() | 402 void CPDF_StreamContentParser::Handle_BeginMarkedContent() |
403 { | 403 { |
404 if (!m_Options.m_bMarkedContent) { | 404 if (!m_Options.m_bMarkedContent) { |
405 return; | 405 return; |
406 } | 406 } |
407 CFX_ByteString tag = GetString(0); | 407 CFX_ByteString tag = GetString(0); |
408 m_CurContentMark.GetModify()->AddMark(tag, NULL, false); | 408 m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); |
409 } | 409 } |
410 struct _FX_BSTR { | 410 struct _FX_BSTR { |
411 const FX_CHAR* m_Ptr; | 411 const FX_CHAR* m_Ptr; |
412 int m_Size; | 412 int m_Size; |
413 }; | 413 }; |
414 #define _FX_BSTRC(str) {str, sizeof(str)-1} | 414 #define _FX_BSTRC(str) {str, sizeof(str)-1} |
415 const _FX_BSTR _PDF_InlineKeyAbbr[] = { | 415 const _FX_BSTR _PDF_InlineKeyAbbr[] = { |
416 _FX_BSTRC("BitsPerComponent"), _FX_BSTRC("BPC"), | 416 _FX_BSTRC("BitsPerComponent"), _FX_BSTRC("BPC"), |
417 _FX_BSTRC("ColorSpace"), _FX_BSTRC("CS"), | 417 _FX_BSTRC("ColorSpace"), _FX_BSTRC("CS"), |
418 _FX_BSTRC("Decode"), _FX_BSTRC("D"), | 418 _FX_BSTRC("Decode"), _FX_BSTRC("D"), |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : NULL; | 615 CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : NULL; |
616 if (pArray == NULL) { | 616 if (pArray == NULL) { |
617 return; | 617 return; |
618 } | 618 } |
619 m_pCurStates->SetLineDash(pArray, GetNumber(0), 1.0f); | 619 m_pCurStates->SetLineDash(pArray, GetNumber(0), 1.0f); |
620 } | 620 } |
621 void CPDF_StreamContentParser::Handle_SetCharWidth() | 621 void CPDF_StreamContentParser::Handle_SetCharWidth() |
622 { | 622 { |
623 m_Type3Data[0] = GetNumber(1); | 623 m_Type3Data[0] = GetNumber(1); |
624 m_Type3Data[1] = GetNumber(0); | 624 m_Type3Data[1] = GetNumber(0); |
625 m_bColored = true; | 625 m_bColored = TRUE; |
626 } | 626 } |
627 void CPDF_StreamContentParser::Handle_SetCachedDevice() | 627 void CPDF_StreamContentParser::Handle_SetCachedDevice() |
628 { | 628 { |
629 for (int i = 0; i < 6; i ++) { | 629 for (int i = 0; i < 6; i ++) { |
630 m_Type3Data[i] = GetNumber(5 - i); | 630 m_Type3Data[i] = GetNumber(5 - i); |
631 } | 631 } |
632 m_bColored = false; | 632 m_bColored = FALSE; |
633 } | 633 } |
634 void CPDF_StreamContentParser::Handle_ExecuteXObject() | 634 void CPDF_StreamContentParser::Handle_ExecuteXObject() |
635 { | 635 { |
636 CFX_ByteString name = GetString(0); | 636 CFX_ByteString name = GetString(0); |
637 if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() &&
m_pLastImage->GetStream()->GetObjNum()) { | 637 if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() &&
m_pLastImage->GetStream()->GetObjNum()) { |
638 AddImage(NULL, m_pLastImage, false); | 638 AddImage(NULL, m_pLastImage, FALSE); |
639 return; | 639 return; |
640 } | 640 } |
641 if (m_Options.m_bTextOnly) { | 641 if (m_Options.m_bTextOnly) { |
642 CPDF_Object* pRes = NULL; | 642 CPDF_Object* pRes = NULL; |
643 if (m_pResources == NULL) { | 643 if (m_pResources == NULL) { |
644 return; | 644 return; |
645 } | 645 } |
646 if (m_pResources == m_pPageResources) { | 646 if (m_pResources == m_pPageResources) { |
647 CPDF_Dictionary* pList = m_pResources->GetDict(FX_BSTRC("XObject")); | 647 CPDF_Dictionary* pList = m_pResources->GetDict(FX_BSTRC("XObject")); |
648 if (pList == NULL) { | 648 if (pList == NULL) { |
(...skipping 17 matching lines...) Expand all Loading... |
666 if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { | 666 if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { |
667 return; | 667 return; |
668 } | 668 } |
669 } else { | 669 } else { |
670 pRes = pList->GetElement(name); | 670 pRes = pList->GetElement(name); |
671 if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { | 671 if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { |
672 return; | 672 return; |
673 } | 673 } |
674 } | 674 } |
675 } | 675 } |
676 bool bForm; | 676 FX_BOOL bForm; |
677 if (m_pDocument->IsFormStream(((CPDF_Reference*)pRes)->GetRefObjNum(), b
Form) && !bForm) { | 677 if (m_pDocument->IsFormStream(((CPDF_Reference*)pRes)->GetRefObjNum(), b
Form) && !bForm) { |
678 return; | 678 return; |
679 } | 679 } |
680 } | 680 } |
681 CPDF_Stream* pXObject = (CPDF_Stream*)FindResourceObj(FX_BSTRC("XObject"), n
ame); | 681 CPDF_Stream* pXObject = (CPDF_Stream*)FindResourceObj(FX_BSTRC("XObject"), n
ame); |
682 if (pXObject == NULL || pXObject->GetType() != PDFOBJ_STREAM) { | 682 if (pXObject == NULL || pXObject->GetType() != PDFOBJ_STREAM) { |
683 m_bResourceMissing = true; | 683 m_bResourceMissing = TRUE; |
684 return; | 684 return; |
685 } | 685 } |
686 CFX_ByteStringC type = pXObject->GetDict() ? pXObject->GetDict()->GetConstSt
ring(FX_BSTRC("Subtype")) : CFX_ByteStringC(); | 686 CFX_ByteStringC type = pXObject->GetDict() ? pXObject->GetDict()->GetConstSt
ring(FX_BSTRC("Subtype")) : CFX_ByteStringC(); |
687 if (type == FX_BSTRC("Image")) { | 687 if (type == FX_BSTRC("Image")) { |
688 if (m_Options.m_bTextOnly) { | 688 if (m_Options.m_bTextOnly) { |
689 return; | 689 return; |
690 } | 690 } |
691 CPDF_ImageObject* pObj = AddImage(pXObject, NULL, false); | 691 CPDF_ImageObject* pObj = AddImage(pXObject, NULL, FALSE); |
692 m_LastImageName = name; | 692 m_LastImageName = name; |
693 m_pLastImage = pObj->m_pImage; | 693 m_pLastImage = pObj->m_pImage; |
694 } else if (type == FX_BSTRC("Form")) { | 694 } else if (type == FX_BSTRC("Form")) { |
695 AddForm(pXObject); | 695 AddForm(pXObject); |
696 } else { | 696 } else { |
697 return; | 697 return; |
698 } | 698 } |
699 } | 699 } |
700 void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) | 700 void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) |
701 { | 701 { |
(...skipping 10 matching lines...) Expand all Loading... |
712 ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.righ
t, form_bbox.top); | 712 ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.righ
t, form_bbox.top); |
713 ClipPath.Transform(&form_matrix); | 713 ClipPath.Transform(&form_matrix); |
714 form_bbox.Transform(&form_matrix); | 714 form_bbox.Transform(&form_matrix); |
715 } | 715 } |
716 CPDF_StreamContentParser parser( | 716 CPDF_StreamContentParser parser( |
717 m_pDocument, m_pPageResources, m_pResources, &m_mtContentToUser, | 717 m_pDocument, m_pPageResources, m_pResources, &m_mtContentToUser, |
718 m_pObjectList, pResources, &form_bbox, &m_Options, | 718 m_pObjectList, pResources, &form_bbox, &m_Options, |
719 m_pCurStates.get(), m_Level + 1); | 719 m_pCurStates.get(), m_Level + 1); |
720 parser.m_pCurStates->m_CTM = form_matrix; | 720 parser.m_pCurStates->m_CTM = form_matrix; |
721 if (ClipPath.NotNull()) { | 721 if (ClipPath.NotNull()) { |
722 parser.m_pCurStates->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING,
true); | 722 parser.m_pCurStates->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING,
TRUE); |
723 } | 723 } |
724 CPDF_StreamAcc stream; | 724 CPDF_StreamAcc stream; |
725 stream.LoadAllData(pStream, false); | 725 stream.LoadAllData(pStream, FALSE); |
726 if (stream.GetSize() == 0) { | 726 if (stream.GetSize() == 0) { |
727 return; | 727 return; |
728 } | 728 } |
729 parser.Parse(stream.GetData(), stream.GetSize(), 0); | 729 parser.Parse(stream.GetData(), stream.GetSize(), 0); |
730 return; | 730 return; |
731 } | 731 } |
732 CPDF_FormObject* pFormObj = new CPDF_FormObject; | 732 CPDF_FormObject* pFormObj = new CPDF_FormObject; |
733 pFormObj->m_pForm = new CPDF_Form(m_pDocument, m_pPageResources, pStream, m_
pResources); | 733 pFormObj->m_pForm = new CPDF_Form(m_pDocument, m_pPageResources, pStream, m_
pResources); |
734 pFormObj->m_FormMatrix = m_pCurStates->m_CTM; | 734 pFormObj->m_FormMatrix = m_pCurStates->m_CTM; |
735 pFormObj->m_FormMatrix.Concat(m_mtContentToUser); | 735 pFormObj->m_FormMatrix.Concat(m_mtContentToUser); |
736 CPDF_AllStates status; | 736 CPDF_AllStates status; |
737 status.m_GeneralState = m_pCurStates->m_GeneralState; | 737 status.m_GeneralState = m_pCurStates->m_GeneralState; |
738 status.m_GraphState = m_pCurStates->m_GraphState; | 738 status.m_GraphState = m_pCurStates->m_GraphState; |
739 status.m_ColorState = m_pCurStates->m_ColorState; | 739 status.m_ColorState = m_pCurStates->m_ColorState; |
740 status.m_TextState = m_pCurStates->m_TextState; | 740 status.m_TextState = m_pCurStates->m_TextState; |
741 pFormObj->m_pForm->ParseContent(&status, NULL, NULL, &m_Options, m_Level + 1
); | 741 pFormObj->m_pForm->ParseContent(&status, NULL, NULL, &m_Options, m_Level + 1
); |
742 if (!m_pObjectList->m_bBackgroundAlphaNeeded && pFormObj->m_pForm->m_bBackgr
oundAlphaNeeded) { | 742 if (!m_pObjectList->m_bBackgroundAlphaNeeded && pFormObj->m_pForm->m_bBackgr
oundAlphaNeeded) { |
743 m_pObjectList->m_bBackgroundAlphaNeeded = true; | 743 m_pObjectList->m_bBackgroundAlphaNeeded = TRUE; |
744 } | 744 } |
745 pFormObj->CalcBoundingBox(); | 745 pFormObj->CalcBoundingBox(); |
746 SetGraphicStates(pFormObj, true, true, true); | 746 SetGraphicStates(pFormObj, TRUE, TRUE, TRUE); |
747 m_pObjectList->m_ObjectList.AddTail(pFormObj); | 747 m_pObjectList->m_ObjectList.AddTail(pFormObj); |
748 } | 748 } |
749 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, CPDF_
Image* pImage, bool bInline) | 749 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, CPDF_
Image* pImage, FX_BOOL bInline) |
750 { | 750 { |
751 if (pStream == NULL && pImage == NULL) { | 751 if (pStream == NULL && pImage == NULL) { |
752 return NULL; | 752 return NULL; |
753 } | 753 } |
754 CFX_AffineMatrix ImageMatrix; | 754 CFX_AffineMatrix ImageMatrix; |
755 ImageMatrix.Copy(m_pCurStates->m_CTM); | 755 ImageMatrix.Copy(m_pCurStates->m_CTM); |
756 ImageMatrix.Concat(m_mtContentToUser); | 756 ImageMatrix.Concat(m_mtContentToUser); |
757 CPDF_ImageObject* pImageObj = new CPDF_ImageObject; | 757 CPDF_ImageObject* pImageObj = new CPDF_ImageObject; |
758 if (pImage) { | 758 if (pImage) { |
759 pImageObj->m_pImage = m_pDocument->GetPageData()->GetImage(pImage->GetSt
ream()); | 759 pImageObj->m_pImage = m_pDocument->GetPageData()->GetImage(pImage->GetSt
ream()); |
760 } else if (pStream->GetObjNum()) { | 760 } else if (pStream->GetObjNum()) { |
761 pImageObj->m_pImage = m_pDocument->LoadImageF(pStream); | 761 pImageObj->m_pImage = m_pDocument->LoadImageF(pStream); |
762 } else { | 762 } else { |
763 pImageObj->m_pImage = new CPDF_Image(m_pDocument); | 763 pImageObj->m_pImage = new CPDF_Image(m_pDocument); |
764 pImageObj->m_pImage->LoadImageF(pStream, bInline); | 764 pImageObj->m_pImage->LoadImageF(pStream, bInline); |
765 } | 765 } |
766 SetGraphicStates(pImageObj, pImageObj->m_pImage->IsMask(), false, false); | 766 SetGraphicStates(pImageObj, pImageObj->m_pImage->IsMask(), FALSE, FALSE); |
767 pImageObj->m_Matrix = ImageMatrix; | 767 pImageObj->m_Matrix = ImageMatrix; |
768 pImageObj->CalcBoundingBox(); | 768 pImageObj->CalcBoundingBox(); |
769 m_pObjectList->m_ObjectList.AddTail(pImageObj); | 769 m_pObjectList->m_ObjectList.AddTail(pImageObj); |
770 return pImageObj; | 770 return pImageObj; |
771 } | 771 } |
772 void CPDF_StreamContentParser::Handle_MarkPlace_Dictionary() | 772 void CPDF_StreamContentParser::Handle_MarkPlace_Dictionary() |
773 { | 773 { |
774 } | 774 } |
775 void CPDF_StreamContentParser::Handle_EndImage() | 775 void CPDF_StreamContentParser::Handle_EndImage() |
776 { | 776 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 { | 810 { |
811 if (m_CompatCount) { | 811 if (m_CompatCount) { |
812 m_CompatCount --; | 812 m_CompatCount --; |
813 } | 813 } |
814 } | 814 } |
815 void CPDF_StreamContentParser::Handle_FillPath() | 815 void CPDF_StreamContentParser::Handle_FillPath() |
816 { | 816 { |
817 if (m_Options.m_bTextOnly) { | 817 if (m_Options.m_bTextOnly) { |
818 return; | 818 return; |
819 } | 819 } |
820 AddPathObject(FXFILL_WINDING, false); | 820 AddPathObject(FXFILL_WINDING, FALSE); |
821 } | 821 } |
822 void CPDF_StreamContentParser::Handle_FillPathOld() | 822 void CPDF_StreamContentParser::Handle_FillPathOld() |
823 { | 823 { |
824 if (m_Options.m_bTextOnly) { | 824 if (m_Options.m_bTextOnly) { |
825 return; | 825 return; |
826 } | 826 } |
827 AddPathObject(FXFILL_WINDING, false); | 827 AddPathObject(FXFILL_WINDING, FALSE); |
828 } | 828 } |
829 void CPDF_StreamContentParser::Handle_EOFillPath() | 829 void CPDF_StreamContentParser::Handle_EOFillPath() |
830 { | 830 { |
831 if (m_Options.m_bTextOnly) { | 831 if (m_Options.m_bTextOnly) { |
832 return; | 832 return; |
833 } | 833 } |
834 AddPathObject(FXFILL_ALTERNATE, false); | 834 AddPathObject(FXFILL_ALTERNATE, FALSE); |
835 } | 835 } |
836 void CPDF_StreamContentParser::Handle_SetGray_Fill() | 836 void CPDF_StreamContentParser::Handle_SetGray_Fill() |
837 { | 837 { |
838 FX_FLOAT value = GetNumber(0); | 838 FX_FLOAT value = GetNumber(0); |
839 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY); | 839 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY); |
840 m_pCurStates->m_ColorState.SetFillColor(pCS, &value, 1); | 840 m_pCurStates->m_ColorState.SetFillColor(pCS, &value, 1); |
841 } | 841 } |
842 void CPDF_StreamContentParser::Handle_SetGray_Stroke() | 842 void CPDF_StreamContentParser::Handle_SetGray_Stroke() |
843 { | 843 { |
844 FX_FLOAT value = GetNumber(0); | 844 FX_FLOAT value = GetNumber(0); |
845 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY); | 845 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY); |
846 m_pCurStates->m_ColorState.SetStrokeColor(pCS, &value, 1); | 846 m_pCurStates->m_ColorState.SetStrokeColor(pCS, &value, 1); |
847 } | 847 } |
848 void CPDF_StreamContentParser::Handle_SetExtendGraphState() | 848 void CPDF_StreamContentParser::Handle_SetExtendGraphState() |
849 { | 849 { |
850 CFX_ByteString name = GetString(0); | 850 CFX_ByteString name = GetString(0); |
851 CPDF_Dictionary* pGS = (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("ExtGState
"), name); | 851 CPDF_Dictionary* pGS = (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("ExtGState
"), name); |
852 if (pGS == NULL || pGS->GetType() != PDFOBJ_DICTIONARY) { | 852 if (pGS == NULL || pGS->GetType() != PDFOBJ_DICTIONARY) { |
853 m_bResourceMissing = true; | 853 m_bResourceMissing = TRUE; |
854 return; | 854 return; |
855 } | 855 } |
856 m_pCurStates->ProcessExtGS(pGS, this); | 856 m_pCurStates->ProcessExtGS(pGS, this); |
857 } | 857 } |
858 void CPDF_StreamContentParser::Handle_ClosePath() | 858 void CPDF_StreamContentParser::Handle_ClosePath() |
859 { | 859 { |
860 if (m_Options.m_bTextOnly) { | 860 if (m_Options.m_bTextOnly) { |
861 return; | 861 return; |
862 } | 862 } |
863 if (m_PathPointCount == 0) { | 863 if (m_PathPointCount == 0) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 m_pCurStates->m_GraphState.GetModify()->m_MiterLimit = GetNumber(0); | 927 m_pCurStates->m_GraphState.GetModify()->m_MiterLimit = GetNumber(0); |
928 } | 928 } |
929 void CPDF_StreamContentParser::Handle_MarkPlace() | 929 void CPDF_StreamContentParser::Handle_MarkPlace() |
930 { | 930 { |
931 } | 931 } |
932 void CPDF_StreamContentParser::Handle_EndPath() | 932 void CPDF_StreamContentParser::Handle_EndPath() |
933 { | 933 { |
934 if (m_Options.m_bTextOnly) { | 934 if (m_Options.m_bTextOnly) { |
935 return; | 935 return; |
936 } | 936 } |
937 AddPathObject(0, false); | 937 AddPathObject(0, FALSE); |
938 } | 938 } |
939 void CPDF_StreamContentParser::Handle_SaveGraphState() | 939 void CPDF_StreamContentParser::Handle_SaveGraphState() |
940 { | 940 { |
941 CPDF_AllStates* pStates = new CPDF_AllStates; | 941 CPDF_AllStates* pStates = new CPDF_AllStates; |
942 pStates->Copy(*m_pCurStates); | 942 pStates->Copy(*m_pCurStates); |
943 m_StateStack.Add(pStates); | 943 m_StateStack.Add(pStates); |
944 } | 944 } |
945 void CPDF_StreamContentParser::Handle_RestoreGraphState() | 945 void CPDF_StreamContentParser::Handle_RestoreGraphState() |
946 { | 946 { |
947 int size = m_StateStack.GetSize(); | 947 int size = m_StateStack.GetSize(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 } | 992 } |
993 void CPDF_StreamContentParser::Handle_SetRenderIntent() | 993 void CPDF_StreamContentParser::Handle_SetRenderIntent() |
994 { | 994 { |
995 } | 995 } |
996 void CPDF_StreamContentParser::Handle_CloseStrokePath() | 996 void CPDF_StreamContentParser::Handle_CloseStrokePath() |
997 { | 997 { |
998 if (m_Options.m_bTextOnly) { | 998 if (m_Options.m_bTextOnly) { |
999 return; | 999 return; |
1000 } | 1000 } |
1001 Handle_ClosePath(); | 1001 Handle_ClosePath(); |
1002 AddPathObject(0, true); | 1002 AddPathObject(0, TRUE); |
1003 } | 1003 } |
1004 void CPDF_StreamContentParser::Handle_StrokePath() | 1004 void CPDF_StreamContentParser::Handle_StrokePath() |
1005 { | 1005 { |
1006 if (m_Options.m_bTextOnly) { | 1006 if (m_Options.m_bTextOnly) { |
1007 return; | 1007 return; |
1008 } | 1008 } |
1009 AddPathObject(0, true); | 1009 AddPathObject(0, TRUE); |
1010 } | 1010 } |
1011 void CPDF_StreamContentParser::Handle_SetColor_Fill() | 1011 void CPDF_StreamContentParser::Handle_SetColor_Fill() |
1012 { | 1012 { |
1013 if (m_Options.m_bTextOnly) { | 1013 if (m_Options.m_bTextOnly) { |
1014 return; | 1014 return; |
1015 } | 1015 } |
1016 FX_FLOAT values[4]; | 1016 FX_FLOAT values[4]; |
1017 int nargs = m_ParamCount; | 1017 int nargs = m_ParamCount; |
1018 if (nargs > 4) { | 1018 if (nargs > 4) { |
1019 nargs = 4; | 1019 nargs = 4; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 nvalues --; | 1053 nvalues --; |
1054 } | 1054 } |
1055 FX_FLOAT* values = NULL; | 1055 FX_FLOAT* values = NULL; |
1056 if (nvalues) { | 1056 if (nvalues) { |
1057 values = FX_Alloc(FX_FLOAT, nvalues); | 1057 values = FX_Alloc(FX_FLOAT, nvalues); |
1058 for (int i = 0; i < nvalues; i ++) { | 1058 for (int i = 0; i < nvalues; i ++) { |
1059 values[i] = GetNumber(nargs - i - 1); | 1059 values[i] = GetNumber(nargs - i - 1); |
1060 } | 1060 } |
1061 } | 1061 } |
1062 if (nvalues != nargs) { | 1062 if (nvalues != nargs) { |
1063 CPDF_Pattern* pPattern = FindPattern(GetString(0), false); | 1063 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE); |
1064 if (pPattern) { | 1064 if (pPattern) { |
1065 m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues)
; | 1065 m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues)
; |
1066 } | 1066 } |
1067 } else { | 1067 } else { |
1068 m_pCurStates->m_ColorState.SetFillColor(NULL, values, nvalues); | 1068 m_pCurStates->m_ColorState.SetFillColor(NULL, values, nvalues); |
1069 } | 1069 } |
1070 if (values) { | 1070 if (values) { |
1071 FX_Free(values); | 1071 FX_Free(values); |
1072 } | 1072 } |
1073 } | 1073 } |
(...skipping 12 matching lines...) Expand all Loading... |
1086 nvalues --; | 1086 nvalues --; |
1087 } | 1087 } |
1088 FX_FLOAT* values = NULL; | 1088 FX_FLOAT* values = NULL; |
1089 if (nvalues) { | 1089 if (nvalues) { |
1090 values = FX_Alloc(FX_FLOAT, nvalues); | 1090 values = FX_Alloc(FX_FLOAT, nvalues); |
1091 for (int i = 0; i < nvalues; i ++) { | 1091 for (int i = 0; i < nvalues; i ++) { |
1092 values[i] = GetNumber(nargs - i - 1); | 1092 values[i] = GetNumber(nargs - i - 1); |
1093 } | 1093 } |
1094 } | 1094 } |
1095 if (nvalues != nargs) { | 1095 if (nvalues != nargs) { |
1096 CPDF_Pattern* pPattern = FindPattern(GetString(0), false); | 1096 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE); |
1097 if (pPattern) { | 1097 if (pPattern) { |
1098 m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalue
s); | 1098 m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalue
s); |
1099 } | 1099 } |
1100 } else { | 1100 } else { |
1101 m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nvalues); | 1101 m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nvalues); |
1102 } | 1102 } |
1103 if (values) { | 1103 if (values) { |
1104 FX_Free(values); | 1104 FX_Free(values); |
1105 } | 1105 } |
1106 } | 1106 } |
1107 CFX_FloatRect _GetShadingBBox(CPDF_Stream* pStream, int type, const CFX_AffineMa
trix* pMatrix, | 1107 CFX_FloatRect _GetShadingBBox(CPDF_Stream* pStream, int type, const CFX_AffineMa
trix* pMatrix, |
1108 CPDF_Function** pFuncs, int nFuncs, CPDF_ColorSpac
e* pCS); | 1108 CPDF_Function** pFuncs, int nFuncs, CPDF_ColorSpac
e* pCS); |
1109 void CPDF_StreamContentParser::Handle_ShadeFill() | 1109 void CPDF_StreamContentParser::Handle_ShadeFill() |
1110 { | 1110 { |
1111 if (m_Options.m_bTextOnly) { | 1111 if (m_Options.m_bTextOnly) { |
1112 return; | 1112 return; |
1113 } | 1113 } |
1114 CPDF_Pattern* pPattern = FindPattern(GetString(0), true); | 1114 CPDF_Pattern* pPattern = FindPattern(GetString(0), TRUE); |
1115 if (pPattern == NULL) { | 1115 if (pPattern == NULL) { |
1116 return; | 1116 return; |
1117 } | 1117 } |
1118 if (pPattern->m_PatternType != PATTERN_SHADING) { | 1118 if (pPattern->m_PatternType != PATTERN_SHADING) { |
1119 return; | 1119 return; |
1120 } | 1120 } |
1121 CPDF_ShadingPattern* pShading = (CPDF_ShadingPattern*)pPattern; | 1121 CPDF_ShadingPattern* pShading = (CPDF_ShadingPattern*)pPattern; |
1122 if (!pShading->m_bShadingObj) { | 1122 if (!pShading->m_bShadingObj) { |
1123 return; | 1123 return; |
1124 } | 1124 } |
1125 if (!pShading->Load()) { | 1125 if (!pShading->Load()) { |
1126 return; | 1126 return; |
1127 } | 1127 } |
1128 CPDF_ShadingObject* pObj = new CPDF_ShadingObject; | 1128 CPDF_ShadingObject* pObj = new CPDF_ShadingObject; |
1129 pObj->m_pShading = pShading; | 1129 pObj->m_pShading = pShading; |
1130 SetGraphicStates(pObj, false, false, false); | 1130 SetGraphicStates(pObj, FALSE, FALSE, FALSE); |
1131 pObj->m_Matrix = m_pCurStates->m_CTM; | 1131 pObj->m_Matrix = m_pCurStates->m_CTM; |
1132 pObj->m_Matrix.Concat(m_mtContentToUser); | 1132 pObj->m_Matrix.Concat(m_mtContentToUser); |
1133 CFX_FloatRect bbox; | 1133 CFX_FloatRect bbox; |
1134 if (!pObj->m_ClipPath.IsNull()) { | 1134 if (!pObj->m_ClipPath.IsNull()) { |
1135 bbox = pObj->m_ClipPath.GetClipBox(); | 1135 bbox = pObj->m_ClipPath.GetClipBox(); |
1136 } else { | 1136 } else { |
1137 bbox = m_BBox; | 1137 bbox = m_BBox; |
1138 } | 1138 } |
1139 if (pShading->m_ShadingType >= 4) { | 1139 if (pShading->m_ShadingType >= 4) { |
1140 bbox.Intersect(_GetShadingBBox((CPDF_Stream*)pShading->m_pShadingObj, pS
hading->m_ShadingType, &pObj->m_Matrix, | 1140 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 Loading... |
1199 CPDF_Object* pRes = pList->GetElementValue(name); | 1199 CPDF_Object* pRes = pList->GetElementValue(name); |
1200 return pRes; | 1200 return pRes; |
1201 } | 1201 } |
1202 CPDF_Object* pRes = pList->GetElementValue(name); | 1202 CPDF_Object* pRes = pList->GetElementValue(name); |
1203 return pRes; | 1203 return pRes; |
1204 } | 1204 } |
1205 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) | 1205 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) |
1206 { | 1206 { |
1207 CPDF_Dictionary* pFontDict = (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("Fon
t"), name); | 1207 CPDF_Dictionary* pFontDict = (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("Fon
t"), name); |
1208 if (pFontDict == NULL || pFontDict->GetType() != PDFOBJ_DICTIONARY) { | 1208 if (pFontDict == NULL || pFontDict->GetType() != PDFOBJ_DICTIONARY) { |
1209 m_bResourceMissing = true; | 1209 m_bResourceMissing = TRUE; |
1210 return CPDF_Font::GetStockFont(m_pDocument, FX_BSTRC("Helvetica")); | 1210 return CPDF_Font::GetStockFont(m_pDocument, FX_BSTRC("Helvetica")); |
1211 } | 1211 } |
1212 CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict); | 1212 CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict); |
1213 if (pFont && pFont->GetType3Font()) { | 1213 if (pFont && pFont->GetType3Font()) { |
1214 pFont->GetType3Font()->SetPageResources(m_pResources); | 1214 pFont->GetType3Font()->SetPageResources(m_pResources); |
1215 pFont->GetType3Font()->CheckType3FontMetrics(); | 1215 pFont->GetType3Font()->CheckType3FontMetrics(); |
1216 } | 1216 } |
1217 return pFont; | 1217 return pFont; |
1218 } | 1218 } |
1219 CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(const CFX_ByteString&
name) | 1219 CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(const CFX_ByteString&
name) |
(...skipping 11 matching lines...) Expand all Loading... |
1231 } | 1231 } |
1232 if (name == FX_BSTRC("DeviceRGB")) { | 1232 if (name == FX_BSTRC("DeviceRGB")) { |
1233 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); | 1233 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); |
1234 } | 1234 } |
1235 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); | 1235 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); |
1236 } | 1236 } |
1237 return m_pDocument->LoadColorSpace(pDefObj); | 1237 return m_pDocument->LoadColorSpace(pDefObj); |
1238 } | 1238 } |
1239 CPDF_Object* pCSObj = FindResourceObj(FX_BSTRC("ColorSpace"), name); | 1239 CPDF_Object* pCSObj = FindResourceObj(FX_BSTRC("ColorSpace"), name); |
1240 if (pCSObj == NULL) { | 1240 if (pCSObj == NULL) { |
1241 m_bResourceMissing = true; | 1241 m_bResourceMissing = TRUE; |
1242 return NULL; | 1242 return NULL; |
1243 } | 1243 } |
1244 return m_pDocument->LoadColorSpace(pCSObj); | 1244 return m_pDocument->LoadColorSpace(pCSObj); |
1245 } | 1245 } |
1246 CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name,
bool bShading) | 1246 CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name,
FX_BOOL bShading) |
1247 { | 1247 { |
1248 CPDF_Object* pPattern = FindResourceObj(bShading ? FX_BSTRC("Shading") : FX_
BSTRC("Pattern"), name); | 1248 CPDF_Object* pPattern = FindResourceObj(bShading ? FX_BSTRC("Shading") : FX_
BSTRC("Pattern"), name); |
1249 if (pPattern == NULL || (pPattern->GetType() != PDFOBJ_DICTIONARY && | 1249 if (pPattern == NULL || (pPattern->GetType() != PDFOBJ_DICTIONARY && |
1250 pPattern->GetType() != PDFOBJ_STREAM)) { | 1250 pPattern->GetType() != PDFOBJ_STREAM)) { |
1251 m_bResourceMissing = true; | 1251 m_bResourceMissing = TRUE; |
1252 return NULL; | 1252 return NULL; |
1253 } | 1253 } |
1254 return m_pDocument->LoadPattern(pPattern, bShading, &m_pCurStates->m_ParentM
atrix); | 1254 return m_pDocument->LoadPattern(pPattern, bShading, &m_pCurStates->m_ParentM
atrix); |
1255 } | 1255 } |
1256 void CPDF_StreamContentParser::ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y) | 1256 void CPDF_StreamContentParser::ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y) |
1257 { | 1257 { |
1258 m_pCurStates->m_TextMatrix.Transform(x, y, x, y); | 1258 m_pCurStates->m_TextMatrix.Transform(x, y, x, y); |
1259 ConvertUserSpace(x, y); | 1259 ConvertUserSpace(x, y); |
1260 } | 1260 } |
1261 void CPDF_StreamContentParser::ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y) | 1261 void CPDF_StreamContentParser::ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y) |
(...skipping 18 matching lines...) Expand all Loading... |
1280 return; | 1280 return; |
1281 } | 1281 } |
1282 int textmode; | 1282 int textmode; |
1283 if (pFont->GetFontType() == PDFFONT_TYPE3) { | 1283 if (pFont->GetFontType() == PDFFONT_TYPE3) { |
1284 textmode = 0; | 1284 textmode = 0; |
1285 } else { | 1285 } else { |
1286 textmode = m_pCurStates->m_TextState.GetObject()->m_TextMode; | 1286 textmode = m_pCurStates->m_TextState.GetObject()->m_TextMode; |
1287 } | 1287 } |
1288 CPDF_TextObject* pText = new CPDF_TextObject; | 1288 CPDF_TextObject* pText = new CPDF_TextObject; |
1289 m_pLastTextObject = pText; | 1289 m_pLastTextObject = pText; |
1290 SetGraphicStates(pText, true, true, true); | 1290 SetGraphicStates(pText, TRUE, TRUE, TRUE); |
1291 if (textmode && textmode != 3 && textmode != 4 && textmode != 7) { | 1291 if (textmode && textmode != 3 && textmode != 4 && textmode != 7) { |
1292 FX_FLOAT* pCTM = pText->m_TextState.GetModify()->m_CTM; | 1292 FX_FLOAT* pCTM = pText->m_TextState.GetModify()->m_CTM; |
1293 pCTM[0] = m_pCurStates->m_CTM.a; | 1293 pCTM[0] = m_pCurStates->m_CTM.a; |
1294 pCTM[1] = m_pCurStates->m_CTM.c; | 1294 pCTM[1] = m_pCurStates->m_CTM.c; |
1295 pCTM[2] = m_pCurStates->m_CTM.b; | 1295 pCTM[2] = m_pCurStates->m_CTM.b; |
1296 pCTM[3] = m_pCurStates->m_CTM.d; | 1296 pCTM[3] = m_pCurStates->m_CTM.d; |
1297 } | 1297 } |
1298 pText->SetSegments(pStrs, pKerning, nsegs); | 1298 pText->SetSegments(pStrs, pKerning, nsegs); |
1299 pText->m_PosX = m_pCurStates->m_TextX; | 1299 pText->m_PosX = m_pCurStates->m_TextX; |
1300 pText->m_PosY = m_pCurStates->m_TextY + m_pCurStates->m_TextRise; | 1300 pText->m_PosY = m_pCurStates->m_TextY + m_pCurStates->m_TextRise; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 FXSYS_memcpy(pNewPoints, m_pPathPoints, m_PathAllocSize * sizeof(FX_
PATHPOINT)); | 1494 FXSYS_memcpy(pNewPoints, m_pPathPoints, m_PathAllocSize * sizeof(FX_
PATHPOINT)); |
1495 FX_Free(m_pPathPoints); | 1495 FX_Free(m_pPathPoints); |
1496 } | 1496 } |
1497 m_pPathPoints = pNewPoints; | 1497 m_pPathPoints = pNewPoints; |
1498 m_PathAllocSize = newsize; | 1498 m_PathAllocSize = newsize; |
1499 } | 1499 } |
1500 m_pPathPoints[m_PathPointCount - 1].m_Flag = flag; | 1500 m_pPathPoints[m_PathPointCount - 1].m_Flag = flag; |
1501 m_pPathPoints[m_PathPointCount - 1].m_PointX = x; | 1501 m_pPathPoints[m_PathPointCount - 1].m_PointX = x; |
1502 m_pPathPoints[m_PathPointCount - 1].m_PointY = y; | 1502 m_pPathPoints[m_PathPointCount - 1].m_PointY = y; |
1503 } | 1503 } |
1504 void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) | 1504 void CPDF_StreamContentParser::AddPathObject(int FillType, FX_BOOL bStroke) |
1505 { | 1505 { |
1506 int PathPointCount = m_PathPointCount, PathClipType = m_PathClipType; | 1506 int PathPointCount = m_PathPointCount, PathClipType = m_PathClipType; |
1507 m_PathPointCount = 0; | 1507 m_PathPointCount = 0; |
1508 m_PathClipType = 0; | 1508 m_PathClipType = 0; |
1509 if (PathPointCount <= 1) { | 1509 if (PathPointCount <= 1) { |
1510 if (PathPointCount && PathClipType) { | 1510 if (PathPointCount && PathClipType) { |
1511 CPDF_Path path; | 1511 CPDF_Path path; |
1512 path.New()->AppendRect(0, 0, 0, 0); | 1512 path.New()->AppendRect(0, 0, 0, 0); |
1513 m_pCurStates->m_ClipPath.AppendPath(path, FXFILL_WINDING, true); | 1513 m_pCurStates->m_ClipPath.AppendPath(path, FXFILL_WINDING, TRUE); |
1514 } | 1514 } |
1515 return; | 1515 return; |
1516 } | 1516 } |
1517 if (PathPointCount && m_pPathPoints[PathPointCount - 1].m_Flag == FXPT_MOVET
O) { | 1517 if (PathPointCount && m_pPathPoints[PathPointCount - 1].m_Flag == FXPT_MOVET
O) { |
1518 PathPointCount --; | 1518 PathPointCount --; |
1519 } | 1519 } |
1520 CPDF_Path Path; | 1520 CPDF_Path Path; |
1521 CFX_PathData* pPathData = Path.New(); | 1521 CFX_PathData* pPathData = Path.New(); |
1522 pPathData->SetPointCount(PathPointCount); | 1522 pPathData->SetPointCount(PathPointCount); |
1523 FXSYS_memcpy(pPathData->GetPoints(), m_pPathPoints, sizeof(FX_PATHPOINT) * P
athPointCount); | 1523 FXSYS_memcpy(pPathData->GetPoints(), m_pPathPoints, sizeof(FX_PATHPOINT) * P
athPointCount); |
1524 CFX_AffineMatrix matrix = m_pCurStates->m_CTM; | 1524 CFX_AffineMatrix matrix = m_pCurStates->m_CTM; |
1525 matrix.Concat(m_mtContentToUser); | 1525 matrix.Concat(m_mtContentToUser); |
1526 if (bStroke || FillType) { | 1526 if (bStroke || FillType) { |
1527 CPDF_PathObject* pPathObj = new CPDF_PathObject; | 1527 CPDF_PathObject* pPathObj = new CPDF_PathObject; |
1528 pPathObj->m_bStroke = bStroke; | 1528 pPathObj->m_bStroke = bStroke; |
1529 pPathObj->m_FillType = FillType; | 1529 pPathObj->m_FillType = FillType; |
1530 pPathObj->m_Path = Path; | 1530 pPathObj->m_Path = Path; |
1531 pPathObj->m_Matrix = matrix; | 1531 pPathObj->m_Matrix = matrix; |
1532 SetGraphicStates(pPathObj, true, false, true); | 1532 SetGraphicStates(pPathObj, TRUE, FALSE, TRUE); |
1533 pPathObj->CalcBoundingBox(); | 1533 pPathObj->CalcBoundingBox(); |
1534 m_pObjectList->m_ObjectList.AddTail(pPathObj); | 1534 m_pObjectList->m_ObjectList.AddTail(pPathObj); |
1535 } | 1535 } |
1536 if (PathClipType) { | 1536 if (PathClipType) { |
1537 if (!matrix.IsIdentity()) { | 1537 if (!matrix.IsIdentity()) { |
1538 Path.Transform(&matrix); | 1538 Path.Transform(&matrix); |
1539 matrix.SetIdentity(); | 1539 matrix.SetIdentity(); |
1540 } | 1540 } |
1541 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, true); | 1541 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); |
1542 } | 1542 } |
1543 } | 1543 } |
1544 CFX_ByteString _FPDF_ByteStringFromHex(CFX_BinaryBuf& src_buf) | 1544 CFX_ByteString _FPDF_ByteStringFromHex(CFX_BinaryBuf& src_buf) |
1545 { | 1545 { |
1546 CFX_ByteTextBuf buf; | 1546 CFX_ByteTextBuf buf; |
1547 bool bFirst = true; | 1547 FX_BOOL bFirst = TRUE; |
1548 int code = 0; | 1548 int code = 0; |
1549 const uint8_t* str = src_buf.GetBuffer(); | 1549 const uint8_t* str = src_buf.GetBuffer(); |
1550 FX_DWORD size = src_buf.GetSize(); | 1550 FX_DWORD size = src_buf.GetSize(); |
1551 for (FX_DWORD i = 0; i < size; i ++) { | 1551 for (FX_DWORD i = 0; i < size; i ++) { |
1552 uint8_t ch = str[i]; | 1552 uint8_t ch = str[i]; |
1553 if (ch >= '0' && ch <= '9') { | 1553 if (ch >= '0' && ch <= '9') { |
1554 if (bFirst) { | 1554 if (bFirst) { |
1555 code = (ch - '0') * 16; | 1555 code = (ch - '0') * 16; |
1556 } else { | 1556 } else { |
1557 code += ch - '0'; | 1557 code += ch - '0'; |
(...skipping 16 matching lines...) Expand all Loading... |
1574 buf.AppendChar((char)code); | 1574 buf.AppendChar((char)code); |
1575 } | 1575 } |
1576 bFirst = !bFirst; | 1576 bFirst = !bFirst; |
1577 } | 1577 } |
1578 } | 1578 } |
1579 if (!bFirst) { | 1579 if (!bFirst) { |
1580 buf.AppendChar((char)code); | 1580 buf.AppendChar((char)code); |
1581 } | 1581 } |
1582 return buf.GetByteString(); | 1582 return buf.GetByteString(); |
1583 } | 1583 } |
OLD | NEW |