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" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 return m_ParamStartPos; | 107 return m_ParamStartPos; |
108 } | 108 } |
109 int index = m_ParamStartPos + m_ParamCount; | 109 int index = m_ParamStartPos + m_ParamCount; |
110 if (index >= PARAM_BUF_SIZE) { | 110 if (index >= PARAM_BUF_SIZE) { |
111 index -= PARAM_BUF_SIZE; | 111 index -= PARAM_BUF_SIZE; |
112 } | 112 } |
113 m_ParamCount ++; | 113 m_ParamCount ++; |
114 return index; | 114 return index; |
115 } | 115 } |
116 void CPDF_StreamContentParser::AddNameParam(FX_LPCSTR name, int len) | 116 void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) |
117 { | 117 { |
118 int index = GetNextParamPos(); | 118 int index = GetNextParamPos(); |
119 if (len > 32) { | 119 if (len > 32) { |
120 m_ParamBuf1[index].m_Type = 0; | 120 m_ParamBuf1[index].m_Type = 0; |
121 m_ParamBuf1[index].m_pObject = CPDF_Name::Create(PDF_NameDecode(CFX_Byte
StringC(name, len))); | 121 m_ParamBuf1[index].m_pObject = CPDF_Name::Create(PDF_NameDecode(CFX_Byte
StringC(name, len))); |
122 } else { | 122 } else { |
123 m_ParamBuf1[index].m_Type = PDFOBJ_NAME; | 123 m_ParamBuf1[index].m_Type = PDFOBJ_NAME; |
124 if (FXSYS_memchr(name, '#', len) == NULL) { | 124 if (FXSYS_memchr(name, '#', len) == NULL) { |
125 FXSYS_memcpy32(m_ParamBuf1[index].m_Name.m_Buffer, name, len); | 125 FXSYS_memcpy32(m_ParamBuf1[index].m_Name.m_Buffer, name, len); |
126 m_ParamBuf1[index].m_Name.m_Len = len; | 126 m_ParamBuf1[index].m_Name.m_Len = len; |
127 } else { | 127 } else { |
128 CFX_ByteString str = PDF_NameDecode(CFX_ByteStringC(name, len)); | 128 CFX_ByteString str = PDF_NameDecode(CFX_ByteStringC(name, len)); |
129 FXSYS_memcpy32(m_ParamBuf1[index].m_Name.m_Buffer, str.c_str(), str.
GetLength()); | 129 FXSYS_memcpy32(m_ParamBuf1[index].m_Name.m_Buffer, str.c_str(), str.
GetLength()); |
130 m_ParamBuf1[index].m_Name.m_Len = str.GetLength(); | 130 m_ParamBuf1[index].m_Name.m_Len = str.GetLength(); |
131 } | 131 } |
132 } | 132 } |
133 } | 133 } |
134 void CPDF_StreamContentParser::AddNumberParam(FX_LPCSTR str, int len) | 134 void CPDF_StreamContentParser::AddNumberParam(const FX_CHAR* str, int len) |
135 { | 135 { |
136 int index = GetNextParamPos(); | 136 int index = GetNextParamPos(); |
137 m_ParamBuf1[index].m_Type = PDFOBJ_NUMBER; | 137 m_ParamBuf1[index].m_Type = PDFOBJ_NUMBER; |
138 FX_atonum(CFX_ByteStringC(str, len), m_ParamBuf1[index].m_Number.m_bInteger, | 138 FX_atonum(CFX_ByteStringC(str, len), m_ParamBuf1[index].m_Number.m_bInteger, |
139 &m_ParamBuf1[index].m_Number.m_Integer); | 139 &m_ParamBuf1[index].m_Number.m_Integer); |
140 } | 140 } |
141 void CPDF_StreamContentParser::AddObjectParam(CPDF_Object* pObj) | 141 void CPDF_StreamContentParser::AddObjectParam(CPDF_Object* pObj) |
142 { | 142 { |
143 int index = GetNextParamPos(); | 143 int index = GetNextParamPos(); |
144 m_ParamBuf1[index].m_Type = 0; | 144 m_ParamBuf1[index].m_Type = 0; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 {FXBSTR_ID('r', 'g', 0, 0), &CPDF_StreamContentParser::Handle_SetRGBColor_Fi
ll}, | 314 {FXBSTR_ID('r', 'g', 0, 0), &CPDF_StreamContentParser::Handle_SetRGBColor_Fi
ll}, |
315 {FXBSTR_ID('r', 'i', 0, 0), &CPDF_StreamContentParser::Handle_SetRenderInten
t}, | 315 {FXBSTR_ID('r', 'i', 0, 0), &CPDF_StreamContentParser::Handle_SetRenderInten
t}, |
316 {FXBSTR_ID('s', 0, 0, 0), &CPDF_StreamContentParser::Handle_CloseS
trokePath}, | 316 {FXBSTR_ID('s', 0, 0, 0), &CPDF_StreamContentParser::Handle_CloseS
trokePath}, |
317 {FXBSTR_ID('s', 'c', 0, 0), &CPDF_StreamContentParser::Handle_SetColor_Fill}
, | 317 {FXBSTR_ID('s', 'c', 0, 0), &CPDF_StreamContentParser::Handle_SetColor_Fill}
, |
318 {FXBSTR_ID('s', 'c', 'n', 0), &CPDF_StreamContentParser::Handle_SetCol
orPS_Fill}, | 318 {FXBSTR_ID('s', 'c', 'n', 0), &CPDF_StreamContentParser::Handle_SetCol
orPS_Fill}, |
319 {FXBSTR_ID('s', 'h', 0, 0), &CPDF_StreamContentParser::Handle_ShadeFill}, | 319 {FXBSTR_ID('s', 'h', 0, 0), &CPDF_StreamContentParser::Handle_ShadeFill}, |
320 {FXBSTR_ID('v', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveT
o_23}, | 320 {FXBSTR_ID('v', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveT
o_23}, |
321 {FXBSTR_ID('w', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLin
eWidth}, | 321 {FXBSTR_ID('w', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLin
eWidth}, |
322 {FXBSTR_ID('y', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveT
o_13}, | 322 {FXBSTR_ID('y', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveT
o_13}, |
323 }; | 323 }; |
324 FX_BOOL CPDF_StreamContentParser::OnOperator(FX_LPCSTR op) | 324 FX_BOOL CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) |
325 { | 325 { |
326 int i = 0; | 326 int i = 0; |
327 FX_DWORD opid = 0; | 327 FX_DWORD opid = 0; |
328 while (i < 4 && op[i]) { | 328 while (i < 4 && op[i]) { |
329 opid = (opid << 8) + op[i]; | 329 opid = (opid << 8) + op[i]; |
330 i ++; | 330 i ++; |
331 } | 331 } |
332 while (i < 4) { | 332 while (i < 4) { |
333 opid <<= 8; | 333 opid <<= 8; |
334 i ++; | 334 i ++; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 403 } |
404 void CPDF_StreamContentParser::Handle_BeginMarkedContent() | 404 void CPDF_StreamContentParser::Handle_BeginMarkedContent() |
405 { | 405 { |
406 if (!m_Options.m_bMarkedContent) { | 406 if (!m_Options.m_bMarkedContent) { |
407 return; | 407 return; |
408 } | 408 } |
409 CFX_ByteString tag = GetString(0); | 409 CFX_ByteString tag = GetString(0); |
410 m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); | 410 m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); |
411 } | 411 } |
412 struct _FX_BSTR { | 412 struct _FX_BSTR { |
413 FX_LPCSTR» m_Ptr; | 413 const FX_CHAR*» m_Ptr; |
414 int m_Size; | 414 int m_Size; |
415 }; | 415 }; |
416 #define _FX_BSTRC(str) {str, sizeof(str)-1} | 416 #define _FX_BSTRC(str) {str, sizeof(str)-1} |
417 const _FX_BSTR _PDF_InlineKeyAbbr[] = { | 417 const _FX_BSTR _PDF_InlineKeyAbbr[] = { |
418 _FX_BSTRC("BitsPerComponent"), _FX_BSTRC("BPC"), | 418 _FX_BSTRC("BitsPerComponent"), _FX_BSTRC("BPC"), |
419 _FX_BSTRC("ColorSpace"), _FX_BSTRC("CS"), | 419 _FX_BSTRC("ColorSpace"), _FX_BSTRC("CS"), |
420 _FX_BSTRC("Decode"), _FX_BSTRC("D"), | 420 _FX_BSTRC("Decode"), _FX_BSTRC("D"), |
421 _FX_BSTRC("DecodeParms"), _FX_BSTRC("DP"), | 421 _FX_BSTRC("DecodeParms"), _FX_BSTRC("DP"), |
422 _FX_BSTRC("Filter"), _FX_BSTRC("F"), | 422 _FX_BSTRC("Filter"), _FX_BSTRC("F"), |
423 _FX_BSTRC("Height"), _FX_BSTRC("H"), | 423 _FX_BSTRC("Height"), _FX_BSTRC("H"), |
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 matrix.SetIdentity(); | 1543 matrix.SetIdentity(); |
1544 } | 1544 } |
1545 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); | 1545 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); |
1546 } | 1546 } |
1547 } | 1547 } |
1548 CFX_ByteString _FPDF_ByteStringFromHex(CFX_BinaryBuf& src_buf) | 1548 CFX_ByteString _FPDF_ByteStringFromHex(CFX_BinaryBuf& src_buf) |
1549 { | 1549 { |
1550 CFX_ByteTextBuf buf; | 1550 CFX_ByteTextBuf buf; |
1551 FX_BOOL bFirst = TRUE; | 1551 FX_BOOL bFirst = TRUE; |
1552 int code = 0; | 1552 int code = 0; |
1553 FX_LPCBYTE str = src_buf.GetBuffer(); | 1553 const uint8_t* str = src_buf.GetBuffer(); |
1554 FX_DWORD size = src_buf.GetSize(); | 1554 FX_DWORD size = src_buf.GetSize(); |
1555 for (FX_DWORD i = 0; i < size; i ++) { | 1555 for (FX_DWORD i = 0; i < size; i ++) { |
1556 uint8_t ch = str[i]; | 1556 uint8_t ch = str[i]; |
1557 if (ch >= '0' && ch <= '9') { | 1557 if (ch >= '0' && ch <= '9') { |
1558 if (bFirst) { | 1558 if (bFirst) { |
1559 code = (ch - '0') * 16; | 1559 code = (ch - '0') * 16; |
1560 } else { | 1560 } else { |
1561 code += ch - '0'; | 1561 code += ch - '0'; |
1562 buf.AppendChar((char)code); | 1562 buf.AppendChar((char)code); |
1563 } | 1563 } |
(...skipping 14 matching lines...) Expand all Loading... |
1578 buf.AppendChar((char)code); | 1578 buf.AppendChar((char)code); |
1579 } | 1579 } |
1580 bFirst = !bFirst; | 1580 bFirst = !bFirst; |
1581 } | 1581 } |
1582 } | 1582 } |
1583 if (!bFirst) { | 1583 if (!bFirst) { |
1584 buf.AppendChar((char)code); | 1584 buf.AppendChar((char)code); |
1585 } | 1585 } |
1586 return buf.GetByteString(); | 1586 return buf.GetByteString(); |
1587 } | 1587 } |
OLD | NEW |