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

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

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase Created 5 years 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 "pageint.h" 7 #include "pageint.h"
8 8
9 #include "core/include/fpdfapi/fpdf_module.h" 9 #include "core/include/fpdfapi/fpdf_module.h"
10 #include "core/include/fpdfapi/fpdf_page.h" 10 #include "core/include/fpdfapi/fpdf_page.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return index; 110 return index;
111 } 111 }
112 void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) { 112 void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) {
113 int index = GetNextParamPos(); 113 int index = GetNextParamPos();
114 if (len > 32) { 114 if (len > 32) {
115 m_ParamBuf1[index].m_Type = 0; 115 m_ParamBuf1[index].m_Type = 0;
116 m_ParamBuf1[index].m_pObject = 116 m_ParamBuf1[index].m_pObject =
117 CPDF_Name::Create(PDF_NameDecode(CFX_ByteStringC(name, len))); 117 CPDF_Name::Create(PDF_NameDecode(CFX_ByteStringC(name, len)));
118 } else { 118 } else {
119 m_ParamBuf1[index].m_Type = PDFOBJ_NAME; 119 m_ParamBuf1[index].m_Type = PDFOBJ_NAME;
120 if (FXSYS_memchr(name, '#', len) == NULL) { 120 if (!FXSYS_memchr(name, '#', len)) {
121 FXSYS_memcpy(m_ParamBuf1[index].m_Name.m_Buffer, name, len); 121 FXSYS_memcpy(m_ParamBuf1[index].m_Name.m_Buffer, name, len);
122 m_ParamBuf1[index].m_Name.m_Len = len; 122 m_ParamBuf1[index].m_Name.m_Len = len;
123 } else { 123 } else {
124 CFX_ByteString str = PDF_NameDecode(CFX_ByteStringC(name, len)); 124 CFX_ByteString str = PDF_NameDecode(CFX_ByteStringC(name, len));
125 FXSYS_memcpy(m_ParamBuf1[index].m_Name.m_Buffer, str.c_str(), 125 FXSYS_memcpy(m_ParamBuf1[index].m_Name.m_Buffer, str.c_str(),
126 str.GetLength()); 126 str.GetLength());
127 m_ParamBuf1[index].m_Name.m_Len = str.GetLength(); 127 m_ParamBuf1[index].m_Name.m_Len = str.GetLength();
128 } 128 }
129 } 129 }
130 } 130 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return; 403 return;
404 } 404 }
405 AddPathObject(FXFILL_ALTERNATE, TRUE); 405 AddPathObject(FXFILL_ALTERNATE, TRUE);
406 } 406 }
407 void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() { 407 void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
408 if (!m_Options.m_bMarkedContent) { 408 if (!m_Options.m_bMarkedContent) {
409 return; 409 return;
410 } 410 }
411 CFX_ByteString tag = GetString(1); 411 CFX_ByteString tag = GetString(1);
412 CPDF_Object* pProperty = GetObject(0); 412 CPDF_Object* pProperty = GetObject(0);
413 if (pProperty == NULL) { 413 if (!pProperty) {
414 return; 414 return;
415 } 415 }
416 FX_BOOL bDirect = TRUE; 416 FX_BOOL bDirect = TRUE;
417 if (pProperty->IsName()) { 417 if (pProperty->IsName()) {
418 pProperty = FindResourceObj("Properties", pProperty->GetString()); 418 pProperty = FindResourceObj("Properties", pProperty->GetString());
419 if (!pProperty) 419 if (!pProperty)
420 return; 420 return;
421 bDirect = FALSE; 421 bDirect = FALSE;
422 } 422 }
423 if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) { 423 if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 new_matrix.Concat(m_pCurStates->m_CTM); 624 new_matrix.Concat(m_pCurStates->m_CTM);
625 m_pCurStates->m_CTM = new_matrix; 625 m_pCurStates->m_CTM = new_matrix;
626 OnChangeTextMatrix(); 626 OnChangeTextMatrix();
627 } 627 }
628 void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() { 628 void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() {
629 if (m_Options.m_bTextOnly) { 629 if (m_Options.m_bTextOnly) {
630 return; 630 return;
631 } 631 }
632 CFX_ByteString csname = GetString(0); 632 CFX_ByteString csname = GetString(0);
633 CPDF_ColorSpace* pCS = FindColorSpace(csname); 633 CPDF_ColorSpace* pCS = FindColorSpace(csname);
634 if (pCS == NULL) { 634 if (!pCS) {
635 return; 635 return;
636 } 636 }
637 m_pCurStates->m_ColorState.GetModify()->m_FillColor.SetColorSpace(pCS); 637 m_pCurStates->m_ColorState.GetModify()->m_FillColor.SetColorSpace(pCS);
638 } 638 }
639 void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() { 639 void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
640 if (m_Options.m_bTextOnly) { 640 if (m_Options.m_bTextOnly) {
641 return; 641 return;
642 } 642 }
643 CFX_ByteString csname = GetString(0); 643 CFX_ByteString csname = GetString(0);
644 CPDF_ColorSpace* pCS = FindColorSpace(csname); 644 CPDF_ColorSpace* pCS = FindColorSpace(csname);
645 if (pCS == NULL) { 645 if (!pCS) {
646 return; 646 return;
647 } 647 }
648 m_pCurStates->m_ColorState.GetModify()->m_StrokeColor.SetColorSpace(pCS); 648 m_pCurStates->m_ColorState.GetModify()->m_StrokeColor.SetColorSpace(pCS);
649 } 649 }
650 void CPDF_StreamContentParser::Handle_SetDash() { 650 void CPDF_StreamContentParser::Handle_SetDash() {
651 if (m_Options.m_bTextOnly) { 651 if (m_Options.m_bTextOnly) {
652 return; 652 return;
653 } 653 }
654 CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : NULL; 654 CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : NULL;
655 if (pArray == NULL) { 655 if (!pArray) {
656 return; 656 return;
657 } 657 }
658 m_pCurStates->SetLineDash(pArray, GetNumber(0), 1.0f); 658 m_pCurStates->SetLineDash(pArray, GetNumber(0), 1.0f);
659 } 659 }
660 void CPDF_StreamContentParser::Handle_SetCharWidth() { 660 void CPDF_StreamContentParser::Handle_SetCharWidth() {
661 m_Type3Data[0] = GetNumber(1); 661 m_Type3Data[0] = GetNumber(1);
662 m_Type3Data[1] = GetNumber(0); 662 m_Type3Data[1] = GetNumber(0);
663 m_bColored = TRUE; 663 m_bColored = TRUE;
664 } 664 }
665 void CPDF_StreamContentParser::Handle_SetCachedDevice() { 665 void CPDF_StreamContentParser::Handle_SetCachedDevice() {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 pFormObj->m_pForm->m_bBackgroundAlphaNeeded) { 764 pFormObj->m_pForm->m_bBackgroundAlphaNeeded) {
765 m_pObjectList->m_bBackgroundAlphaNeeded = TRUE; 765 m_pObjectList->m_bBackgroundAlphaNeeded = TRUE;
766 } 766 }
767 pFormObj->CalcBoundingBox(); 767 pFormObj->CalcBoundingBox();
768 SetGraphicStates(pFormObj, TRUE, TRUE, TRUE); 768 SetGraphicStates(pFormObj, TRUE, TRUE, TRUE);
769 m_pObjectList->m_ObjectList.AddTail(pFormObj); 769 m_pObjectList->m_ObjectList.AddTail(pFormObj);
770 } 770 }
771 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, 771 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream,
772 CPDF_Image* pImage, 772 CPDF_Image* pImage,
773 FX_BOOL bInline) { 773 FX_BOOL bInline) {
774 if (pStream == NULL && pImage == NULL) { 774 if (!pStream && !pImage) {
775 return NULL; 775 return NULL;
776 } 776 }
777 CFX_Matrix ImageMatrix; 777 CFX_Matrix ImageMatrix;
778 ImageMatrix.Copy(m_pCurStates->m_CTM); 778 ImageMatrix.Copy(m_pCurStates->m_CTM);
779 ImageMatrix.Concat(m_mtContentToUser); 779 ImageMatrix.Concat(m_mtContentToUser);
780 CPDF_ImageObject* pImageObj = new CPDF_ImageObject; 780 CPDF_ImageObject* pImageObj = new CPDF_ImageObject;
781 if (pImage) { 781 if (pImage) {
782 pImageObj->m_pImage = 782 pImageObj->m_pImage =
783 m_pDocument->GetPageData()->GetImage(pImage->GetStream()); 783 m_pDocument->GetPageData()->GetImage(pImage->GetStream());
784 } else if (pStream->GetObjNum()) { 784 } else if (pStream->GetObjNum()) {
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 for (int i = 0; i < nargs; i++) { 1025 for (int i = 0; i < nargs; i++) {
1026 values[i] = GetNumber(nargs - i - 1); 1026 values[i] = GetNumber(nargs - i - 1);
1027 } 1027 }
1028 m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nargs); 1028 m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nargs);
1029 } 1029 }
1030 void CPDF_StreamContentParser::Handle_SetColorPS_Fill() { 1030 void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
1031 if (m_Options.m_bTextOnly) { 1031 if (m_Options.m_bTextOnly) {
1032 return; 1032 return;
1033 } 1033 }
1034 CPDF_Object* pLastParam = GetObject(0); 1034 CPDF_Object* pLastParam = GetObject(0);
1035 if (pLastParam == NULL) { 1035 if (!pLastParam) {
1036 return; 1036 return;
1037 } 1037 }
1038 int nargs = m_ParamCount; 1038 int nargs = m_ParamCount;
1039 int nvalues = nargs; 1039 int nvalues = nargs;
1040 if (pLastParam->IsName()) { 1040 if (pLastParam->IsName()) {
1041 nvalues--; 1041 nvalues--;
1042 } 1042 }
1043 FX_FLOAT* values = NULL; 1043 FX_FLOAT* values = NULL;
1044 if (nvalues) { 1044 if (nvalues) {
1045 values = FX_Alloc(FX_FLOAT, nvalues); 1045 values = FX_Alloc(FX_FLOAT, nvalues);
1046 for (int i = 0; i < nvalues; i++) { 1046 for (int i = 0; i < nvalues; i++) {
1047 values[i] = GetNumber(nargs - i - 1); 1047 values[i] = GetNumber(nargs - i - 1);
1048 } 1048 }
1049 } 1049 }
1050 if (nvalues != nargs) { 1050 if (nvalues != nargs) {
1051 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE); 1051 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE);
1052 if (pPattern) { 1052 if (pPattern) {
1053 m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues); 1053 m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues);
1054 } 1054 }
1055 } else { 1055 } else {
1056 m_pCurStates->m_ColorState.SetFillColor(NULL, values, nvalues); 1056 m_pCurStates->m_ColorState.SetFillColor(NULL, values, nvalues);
1057 } 1057 }
1058 FX_Free(values); 1058 FX_Free(values);
1059 } 1059 }
1060 void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() { 1060 void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() {
1061 if (m_Options.m_bTextOnly) { 1061 if (m_Options.m_bTextOnly) {
1062 return; 1062 return;
1063 } 1063 }
1064 CPDF_Object* pLastParam = GetObject(0); 1064 CPDF_Object* pLastParam = GetObject(0);
1065 if (pLastParam == NULL) { 1065 if (!pLastParam) {
1066 return; 1066 return;
1067 } 1067 }
1068 int nargs = m_ParamCount; 1068 int nargs = m_ParamCount;
1069 int nvalues = nargs; 1069 int nvalues = nargs;
1070 if (pLastParam->IsName()) 1070 if (pLastParam->IsName())
1071 nvalues--; 1071 nvalues--;
1072 1072
1073 FX_FLOAT* values = NULL; 1073 FX_FLOAT* values = NULL;
1074 if (nvalues) { 1074 if (nvalues) {
1075 values = FX_Alloc(FX_FLOAT, nvalues); 1075 values = FX_Alloc(FX_FLOAT, nvalues);
(...skipping 16 matching lines...) Expand all
1092 const CFX_Matrix* pMatrix, 1092 const CFX_Matrix* pMatrix,
1093 CPDF_Function** pFuncs, 1093 CPDF_Function** pFuncs,
1094 int nFuncs, 1094 int nFuncs,
1095 CPDF_ColorSpace* pCS); 1095 CPDF_ColorSpace* pCS);
1096 1096
1097 void CPDF_StreamContentParser::Handle_ShadeFill() { 1097 void CPDF_StreamContentParser::Handle_ShadeFill() {
1098 if (m_Options.m_bTextOnly) { 1098 if (m_Options.m_bTextOnly) {
1099 return; 1099 return;
1100 } 1100 }
1101 CPDF_Pattern* pPattern = FindPattern(GetString(0), TRUE); 1101 CPDF_Pattern* pPattern = FindPattern(GetString(0), TRUE);
1102 if (pPattern == NULL) { 1102 if (!pPattern) {
1103 return; 1103 return;
1104 } 1104 }
1105 if (pPattern->m_PatternType != PATTERN_SHADING) { 1105 if (pPattern->m_PatternType != PATTERN_SHADING) {
1106 return; 1106 return;
1107 } 1107 }
1108 CPDF_ShadingPattern* pShading = (CPDF_ShadingPattern*)pPattern; 1108 CPDF_ShadingPattern* pShading = (CPDF_ShadingPattern*)pPattern;
1109 if (!pShading->m_bShadingObj) { 1109 if (!pShading->m_bShadingObj) {
1110 return; 1110 return;
1111 } 1111 }
1112 if (!pShading->Load()) { 1112 if (!pShading->Load()) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 } 1155 }
1156 m_pCurStates->m_TextState.GetModify()->m_FontSize = fs; 1156 m_pCurStates->m_TextState.GetModify()->m_FontSize = fs;
1157 CPDF_Font* pFont = FindFont(GetString(1)); 1157 CPDF_Font* pFont = FindFont(GetString(1));
1158 if (pFont) { 1158 if (pFont) {
1159 m_pCurStates->m_TextState.SetFont(pFont); 1159 m_pCurStates->m_TextState.SetFont(pFont);
1160 } 1160 }
1161 } 1161 }
1162 CPDF_Object* CPDF_StreamContentParser::FindResourceObj( 1162 CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
1163 const CFX_ByteStringC& type, 1163 const CFX_ByteStringC& type,
1164 const CFX_ByteString& name) { 1164 const CFX_ByteString& name) {
1165 if (m_pResources == NULL) { 1165 if (!m_pResources) {
1166 return NULL; 1166 return NULL;
1167 } 1167 }
1168 if (m_pResources == m_pPageResources) { 1168 if (m_pResources == m_pPageResources) {
1169 CPDF_Dictionary* pList = m_pResources->GetDict(type); 1169 CPDF_Dictionary* pList = m_pResources->GetDict(type);
1170 if (pList == NULL) { 1170 if (!pList) {
1171 return NULL; 1171 return NULL;
1172 } 1172 }
1173 CPDF_Object* pRes = pList->GetElementValue(name); 1173 CPDF_Object* pRes = pList->GetElementValue(name);
1174 return pRes; 1174 return pRes;
1175 } 1175 }
1176 CPDF_Dictionary* pList = m_pResources->GetDict(type); 1176 CPDF_Dictionary* pList = m_pResources->GetDict(type);
1177 if (pList == NULL) { 1177 if (!pList) {
1178 if (m_pPageResources == NULL) { 1178 if (!m_pPageResources) {
1179 return NULL; 1179 return NULL;
1180 } 1180 }
1181 CPDF_Dictionary* pList = m_pPageResources->GetDict(type); 1181 CPDF_Dictionary* pList = m_pPageResources->GetDict(type);
1182 if (pList == NULL) { 1182 if (!pList) {
1183 return NULL; 1183 return NULL;
1184 } 1184 }
1185 CPDF_Object* pRes = pList->GetElementValue(name); 1185 CPDF_Object* pRes = pList->GetElementValue(name);
1186 return pRes; 1186 return pRes;
1187 } 1187 }
1188 CPDF_Object* pRes = pList->GetElementValue(name); 1188 CPDF_Object* pRes = pList->GetElementValue(name);
1189 return pRes; 1189 return pRes;
1190 } 1190 }
1191 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { 1191 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) {
1192 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name)); 1192 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name));
(...skipping 11 matching lines...) Expand all
1204 } 1204 }
1205 CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace( 1205 CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
1206 const CFX_ByteString& name) { 1206 const CFX_ByteString& name) {
1207 if (name == "Pattern") { 1207 if (name == "Pattern") {
1208 return CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN); 1208 return CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN);
1209 } 1209 }
1210 if (name == "DeviceGray" || name == "DeviceCMYK" || name == "DeviceRGB") { 1210 if (name == "DeviceGray" || name == "DeviceCMYK" || name == "DeviceRGB") {
1211 CFX_ByteString defname = "Default"; 1211 CFX_ByteString defname = "Default";
1212 defname += name.Mid(7); 1212 defname += name.Mid(7);
1213 CPDF_Object* pDefObj = FindResourceObj("ColorSpace", defname); 1213 CPDF_Object* pDefObj = FindResourceObj("ColorSpace", defname);
1214 if (pDefObj == NULL) { 1214 if (!pDefObj) {
1215 if (name == "DeviceGray") { 1215 if (name == "DeviceGray") {
1216 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY); 1216 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY);
1217 } 1217 }
1218 if (name == "DeviceRGB") { 1218 if (name == "DeviceRGB") {
1219 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); 1219 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB);
1220 } 1220 }
1221 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); 1221 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK);
1222 } 1222 }
1223 return m_pDocument->LoadColorSpace(pDefObj); 1223 return m_pDocument->LoadColorSpace(pDefObj);
1224 } 1224 }
1225 CPDF_Object* pCSObj = FindResourceObj("ColorSpace", name); 1225 CPDF_Object* pCSObj = FindResourceObj("ColorSpace", name);
1226 if (pCSObj == NULL) { 1226 if (!pCSObj) {
1227 m_bResourceMissing = TRUE; 1227 m_bResourceMissing = TRUE;
1228 return NULL; 1228 return NULL;
1229 } 1229 }
1230 return m_pDocument->LoadColorSpace(pCSObj); 1230 return m_pDocument->LoadColorSpace(pCSObj);
1231 } 1231 }
1232 CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name, 1232 CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name,
1233 FX_BOOL bShading) { 1233 FX_BOOL bShading) {
1234 CPDF_Object* pPattern = 1234 CPDF_Object* pPattern =
1235 FindResourceObj(bShading ? "Shading" : "Pattern", name); 1235 FindResourceObj(bShading ? "Shading" : "Pattern", name);
1236 if (!pPattern || (!pPattern->IsDictionary() && !pPattern->IsStream())) { 1236 if (!pPattern || (!pPattern->IsDictionary() && !pPattern->IsStream())) {
1237 m_bResourceMissing = TRUE; 1237 m_bResourceMissing = TRUE;
1238 return NULL; 1238 return NULL;
1239 } 1239 }
1240 return m_pDocument->LoadPattern(pPattern, bShading, 1240 return m_pDocument->LoadPattern(pPattern, bShading,
1241 &m_pCurStates->m_ParentMatrix); 1241 &m_pCurStates->m_ParentMatrix);
1242 } 1242 }
1243 void CPDF_StreamContentParser::ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y) { 1243 void CPDF_StreamContentParser::ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y) {
1244 m_pCurStates->m_TextMatrix.Transform(x, y, x, y); 1244 m_pCurStates->m_TextMatrix.Transform(x, y, x, y);
1245 ConvertUserSpace(x, y); 1245 ConvertUserSpace(x, y);
1246 } 1246 }
1247 void CPDF_StreamContentParser::ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y) { 1247 void CPDF_StreamContentParser::ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y) {
1248 m_pCurStates->m_CTM.Transform(x, y, x, y); 1248 m_pCurStates->m_CTM.Transform(x, y, x, y);
1249 m_mtContentToUser.Transform(x, y, x, y); 1249 m_mtContentToUser.Transform(x, y, x, y);
1250 } 1250 }
1251 void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs, 1251 void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
1252 FX_FLOAT fInitKerning, 1252 FX_FLOAT fInitKerning,
1253 FX_FLOAT* pKerning, 1253 FX_FLOAT* pKerning,
1254 int nsegs) { 1254 int nsegs) {
1255 CPDF_Font* pFont = m_pCurStates->m_TextState.GetFont(); 1255 CPDF_Font* pFont = m_pCurStates->m_TextState.GetFont();
1256 if (pFont == NULL) { 1256 if (!pFont) {
1257 return; 1257 return;
1258 } 1258 }
1259 if (fInitKerning != 0) { 1259 if (fInitKerning != 0) {
1260 if (!pFont->IsVertWriting()) { 1260 if (!pFont->IsVertWriting()) {
1261 m_pCurStates->m_TextX -= 1261 m_pCurStates->m_TextX -=
1262 FXSYS_Mul(fInitKerning, m_pCurStates->m_TextState.GetFontSize()) / 1262 FXSYS_Mul(fInitKerning, m_pCurStates->m_TextState.GetFontSize()) /
1263 1000; 1263 1000;
1264 } else { 1264 } else {
1265 m_pCurStates->m_TextY -= 1265 m_pCurStates->m_TextY -=
1266 FXSYS_Mul(fInitKerning, m_pCurStates->m_TextState.GetFontSize()) / 1266 FXSYS_Mul(fInitKerning, m_pCurStates->m_TextState.GetFontSize()) /
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 } 1317 }
1318 void CPDF_StreamContentParser::Handle_ShowText() { 1318 void CPDF_StreamContentParser::Handle_ShowText() {
1319 CFX_ByteString str = GetString(0); 1319 CFX_ByteString str = GetString(0);
1320 if (str.IsEmpty()) { 1320 if (str.IsEmpty()) {
1321 return; 1321 return;
1322 } 1322 }
1323 AddTextObject(&str, 0, NULL, 1); 1323 AddTextObject(&str, 0, NULL, 1);
1324 } 1324 }
1325 void CPDF_StreamContentParser::Handle_ShowText_Positioning() { 1325 void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
1326 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL; 1326 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL;
1327 if (pArray == NULL) { 1327 if (!pArray) {
1328 return; 1328 return;
1329 } 1329 }
1330 int n = pArray->GetCount(); 1330 int n = pArray->GetCount();
1331 int nsegs = 0; 1331 int nsegs = 0;
1332 for (int i = 0; i < n; i++) { 1332 for (int i = 0; i < n; i++) {
1333 if (pArray->GetElementValue(i)->IsString()) 1333 if (pArray->GetElementValue(i)->IsString())
1334 nsegs++; 1334 nsegs++;
1335 } 1335 }
1336 if (nsegs == 0) { 1336 if (nsegs == 0) {
1337 for (int i = 0; i < n; i++) { 1337 for (int i = 0; i < n; i++) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 m_pObjectList->m_ObjectList.AddTail(pPathObj); 1518 m_pObjectList->m_ObjectList.AddTail(pPathObj);
1519 } 1519 }
1520 if (PathClipType) { 1520 if (PathClipType) {
1521 if (!matrix.IsIdentity()) { 1521 if (!matrix.IsIdentity()) {
1522 Path.Transform(&matrix); 1522 Path.Transform(&matrix);
1523 matrix.SetIdentity(); 1523 matrix.SetIdentity();
1524 } 1524 }
1525 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); 1525 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE);
1526 } 1526 }
1527 } 1527 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.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