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

Side by Side Diff: fpdfsdk/src/formfiller/FFL_CBA_Fontmap.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
« no previous file with comments | « core/src/fxge/win32/fx_win32_print.cpp ('k') | fpdfsdk/src/fpdf_dataavail.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" 7 #include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h"
8 #include "fpdfsdk/include/formfiller/FormFiller.h" 8 #include "fpdfsdk/include/formfiller/FormFiller.h"
9 9
10 CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot, 10 CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict, 115 CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict,
116 CFX_ByteString& sFontAlias, 116 CFX_ByteString& sFontAlias,
117 int32_t nCharset) { 117 int32_t nCharset) {
118 if (!pResDict) 118 if (!pResDict)
119 return NULL; 119 return NULL;
120 120
121 CPDF_Document* pDocument = GetDocument(); 121 CPDF_Document* pDocument = GetDocument();
122 ASSERT(pDocument != NULL); 122 ASSERT(pDocument != NULL);
123 123
124 CPDF_Dictionary* pFonts = pResDict->GetDict("Font"); 124 CPDF_Dictionary* pFonts = pResDict->GetDict("Font");
125 if (pFonts == NULL) 125 if (!pFonts)
126 return NULL; 126 return NULL;
127 127
128 CPDF_Font* pFind = NULL; 128 CPDF_Font* pFind = NULL;
129 129
130 FX_POSITION pos = pFonts->GetStartPos(); 130 FX_POSITION pos = pFonts->GetStartPos();
131 while (pos) { 131 while (pos) {
132 CPDF_Object* pObj = NULL; 132 CPDF_Object* pObj = NULL;
133 CFX_ByteString csKey; 133 CFX_ByteString csKey;
134 pObj = pFonts->GetNextElement(pos, csKey); 134 pObj = pFonts->GetNextElement(pos, csKey);
135 if (pObj == NULL) 135 if (!pObj)
136 continue; 136 continue;
137 137
138 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); 138 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
139 if (!pElement) 139 if (!pElement)
140 continue; 140 continue;
141 if (pElement->GetString("Type") != "Font") 141 if (pElement->GetString("Type") != "Font")
142 continue; 142 continue;
143 143
144 CPDF_Font* pFont = pDocument->LoadFont(pElement); 144 CPDF_Font* pFont = pDocument->LoadFont(pElement);
145 if (pFont == NULL) 145 if (!pFont)
146 continue; 146 continue;
147 const CFX_SubstFont* pSubst = pFont->GetSubstFont(); 147 const CFX_SubstFont* pSubst = pFont->GetSubstFont();
148 if (pSubst == NULL) 148 if (!pSubst)
149 continue; 149 continue;
150 if (pSubst->m_Charset == nCharset) { 150 if (pSubst->m_Charset == nCharset) {
151 sFontAlias = csKey; 151 sFontAlias = csKey;
152 pFind = pFont; 152 pFind = pFont;
153 } 153 }
154 } 154 }
155 return pFind; 155 return pFind;
156 } 156 }
157 157
158 void CBA_FontMap::AddedFont(CPDF_Font* pFont, 158 void CBA_FontMap::AddedFont(CPDF_Font* pFont,
159 const CFX_ByteString& sFontAlias) { 159 const CFX_ByteString& sFontAlias) {
160 AddFontToAnnotDict(pFont, sFontAlias); 160 AddFontToAnnotDict(pFont, sFontAlias);
161 } 161 }
162 162
163 void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, 163 void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
164 const CFX_ByteString& sAlias) { 164 const CFX_ByteString& sAlias) {
165 if (!pFont) 165 if (!pFont)
166 return; 166 return;
167 167
168 ASSERT(m_pAnnotDict != NULL); 168 ASSERT(m_pAnnotDict != NULL);
169 ASSERT(m_pDocument != NULL); 169 ASSERT(m_pDocument != NULL);
170 170
171 CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDict("AP"); 171 CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDict("AP");
172 172
173 if (pAPDict == NULL) { 173 if (!pAPDict) {
174 pAPDict = new CPDF_Dictionary; 174 pAPDict = new CPDF_Dictionary;
175 m_pAnnotDict->SetAt("AP", pAPDict); 175 m_pAnnotDict->SetAt("AP", pAPDict);
176 } 176 }
177 177
178 // to avoid checkbox and radiobutton 178 // to avoid checkbox and radiobutton
179 CPDF_Object* pObject = pAPDict->GetElement(m_sAPType); 179 CPDF_Object* pObject = pAPDict->GetElement(m_sAPType);
180 if (ToDictionary(pObject)) 180 if (ToDictionary(pObject))
181 return; 181 return;
182 182
183 CPDF_Stream* pStream = pAPDict->GetStream(m_sAPType); 183 CPDF_Stream* pStream = pAPDict->GetStream(m_sAPType);
184 if (pStream == NULL) { 184 if (!pStream) {
185 pStream = new CPDF_Stream(NULL, 0, NULL); 185 pStream = new CPDF_Stream(NULL, 0, NULL);
186 int32_t objnum = m_pDocument->AddIndirectObject(pStream); 186 int32_t objnum = m_pDocument->AddIndirectObject(pStream);
187 pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum); 187 pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum);
188 } 188 }
189 189
190 CPDF_Dictionary* pStreamDict = pStream->GetDict(); 190 CPDF_Dictionary* pStreamDict = pStream->GetDict();
191 191
192 if (!pStreamDict) { 192 if (!pStreamDict) {
193 pStreamDict = new CPDF_Dictionary; 193 pStreamDict = new CPDF_Dictionary;
194 pStream->InitStream(NULL, 0, pStreamDict); 194 pStream->InitStream(NULL, 0, pStreamDict);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 273
274 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; 274 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr;
275 } 275 }
276 276
277 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { 277 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) {
278 m_sAPType = sAPType; 278 m_sAPType = sAPType;
279 279
280 Reset(); 280 Reset();
281 Initial(); 281 Initial();
282 } 282 }
OLDNEW
« no previous file with comments | « core/src/fxge/win32/fx_win32_print.cpp ('k') | fpdfsdk/src/fpdf_dataavail.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698