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

Side by Side Diff: fpdfsdk/src/fpdftext.cpp

Issue 1528763003: Merge to XFA: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: 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 "public/fpdf_text.h" 7 #include "public/fpdf_text.h"
8 8
9 #include "core/include/fpdfdoc/fpdf_doc.h" 9 #include "core/include/fpdfdoc/fpdf_doc.h"
10 #include "core/include/fpdftext/fpdf_text.h" 10 #include "core/include/fpdftext/fpdf_text.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 double bottom, 159 double bottom,
160 unsigned short* buffer, 160 unsigned short* buffer,
161 int buflen) { 161 int buflen) {
162 if (!text_page) 162 if (!text_page)
163 return 0; 163 return 0;
164 IPDF_TextPage* textpage = (IPDF_TextPage*)text_page; 164 IPDF_TextPage* textpage = (IPDF_TextPage*)text_page;
165 CFX_FloatRect rect((FX_FLOAT)left, (FX_FLOAT)bottom, (FX_FLOAT)right, 165 CFX_FloatRect rect((FX_FLOAT)left, (FX_FLOAT)bottom, (FX_FLOAT)right,
166 (FX_FLOAT)top); 166 (FX_FLOAT)top);
167 CFX_WideString str = textpage->GetTextByRect(rect); 167 CFX_WideString str = textpage->GetTextByRect(rect);
168 168
169 if (buflen <= 0 || buffer == NULL) { 169 if (buflen <= 0 || !buffer) {
170 return str.GetLength(); 170 return str.GetLength();
171 } 171 }
172 172
173 CFX_ByteString cbUTF16Str = str.UTF16LE_Encode(); 173 CFX_ByteString cbUTF16Str = str.UTF16LE_Encode();
174 int len = cbUTF16Str.GetLength() / sizeof(unsigned short); 174 int len = cbUTF16Str.GetLength() / sizeof(unsigned short);
175 int size = buflen > len ? len : buflen; 175 int size = buflen > len ? len : buflen;
176 FXSYS_memcpy(buffer, cbUTF16Str.GetBuffer(size * sizeof(unsigned short)), 176 FXSYS_memcpy(buffer, cbUTF16Str.GetBuffer(size * sizeof(unsigned short)),
177 size * sizeof(unsigned short)); 177 size * sizeof(unsigned short));
178 cbUTF16Str.ReleaseBuffer(size * sizeof(unsigned short)); 178 cbUTF16Str.ReleaseBuffer(size * sizeof(unsigned short));
179 179
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 int link_index, 246 int link_index,
247 unsigned short* buffer, 247 unsigned short* buffer,
248 int buflen) { 248 int buflen) {
249 if (!link_page) 249 if (!link_page)
250 return 0; 250 return 0;
251 IPDF_LinkExtract* pageLink = (IPDF_LinkExtract*)link_page; 251 IPDF_LinkExtract* pageLink = (IPDF_LinkExtract*)link_page;
252 CFX_WideString url = pageLink->GetURL(link_index); 252 CFX_WideString url = pageLink->GetURL(link_index);
253 253
254 CFX_ByteString cbUTF16URL = url.UTF16LE_Encode(); 254 CFX_ByteString cbUTF16URL = url.UTF16LE_Encode();
255 int len = cbUTF16URL.GetLength() / sizeof(unsigned short); 255 int len = cbUTF16URL.GetLength() / sizeof(unsigned short);
256 if (buffer == NULL || buflen <= 0) 256 if (!buffer || buflen <= 0)
257 return len; 257 return len;
258 int size = len < buflen ? len : buflen; 258 int size = len < buflen ? len : buflen;
259 if (size > 0) { 259 if (size > 0) {
260 FXSYS_memcpy(buffer, cbUTF16URL.GetBuffer(size * sizeof(unsigned short)), 260 FXSYS_memcpy(buffer, cbUTF16URL.GetBuffer(size * sizeof(unsigned short)),
261 size * sizeof(unsigned short)); 261 size * sizeof(unsigned short));
262 cbUTF16URL.ReleaseBuffer(size * sizeof(unsigned short)); 262 cbUTF16URL.ReleaseBuffer(size * sizeof(unsigned short));
263 } 263 }
264 return size; 264 return size;
265 } 265 }
266 DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page, 266 DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page,
(...skipping 21 matching lines...) Expand all
288 CFX_FloatRect rect = rectArray.GetAt(rect_index); 288 CFX_FloatRect rect = rectArray.GetAt(rect_index);
289 *left = rect.left; 289 *left = rect.left;
290 *right = rect.right; 290 *right = rect.right;
291 *top = rect.top; 291 *top = rect.top;
292 *bottom = rect.bottom; 292 *bottom = rect.bottom;
293 } 293 }
294 } 294 }
295 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page) { 295 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page) {
296 delete (IPDF_LinkExtract*)link_page; 296 delete (IPDF_LinkExtract*)link_page;
297 } 297 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698