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

Side by Side Diff: fpdfsdk/fpdfview.cpp

Issue 2539203002: Convert loose FX_Create* functions into static methods (Closed)
Patch Set: last batch Created 4 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/fpdfview.h" 7 #include "public/fpdfview.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 DLLEXPORT void STDCALL FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi) { 386 DLLEXPORT void STDCALL FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi) {
387 g_pdfium_print_text_with_gdi = !!use_gdi; 387 g_pdfium_print_text_with_gdi = !!use_gdi;
388 } 388 }
389 #endif 389 #endif
390 390
391 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, 391 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
392 FPDF_BYTESTRING password) { 392 FPDF_BYTESTRING password) {
393 // NOTE: the creation of the file needs to be by the embedder on the 393 // NOTE: the creation of the file needs to be by the embedder on the
394 // other side of this API. 394 // other side of this API.
395 IFX_SeekableReadStream* pFileAccess = 395 IFX_SeekableReadStream* pFileAccess =
396 FX_CreateFileRead((const FX_CHAR*)file_path); 396 IFX_SeekableReadStream::CreateFromFilename((const FX_CHAR*)file_path);
397 if (!pFileAccess) { 397 if (!pFileAccess)
398 return nullptr; 398 return nullptr;
399 }
400 399
401 std::unique_ptr<CPDF_Parser> pParser(new CPDF_Parser); 400 auto pParser = pdfium::MakeUnique<CPDF_Parser>();
402 pParser->SetPassword(password); 401 pParser->SetPassword(password);
403 402
404 std::unique_ptr<CPDF_Document> pDocument( 403 auto pDocument = pdfium::MakeUnique<CPDF_Document>(std::move(pParser));
405 new CPDF_Document(std::move(pParser)));
406 CPDF_Parser::Error error = 404 CPDF_Parser::Error error =
407 pDocument->GetParser()->StartParse(pFileAccess, pDocument.get()); 405 pDocument->GetParser()->StartParse(pFileAccess, pDocument.get());
408 if (error != CPDF_Parser::SUCCESS) { 406 if (error != CPDF_Parser::SUCCESS) {
409 ProcessParseError(error); 407 ProcessParseError(error);
410 return nullptr; 408 return nullptr;
411 } 409 }
412 return FPDFDocumentFromCPDFDocument(pDocument.release()); 410 return FPDFDocumentFromCPDFDocument(pDocument.release());
413 } 411 }
414 412
415 #ifdef PDF_ENABLE_XFA 413 #ifdef PDF_ENABLE_XFA
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 if (!buffer) { 1169 if (!buffer) {
1172 *buflen = len; 1170 *buflen = len;
1173 } else if (len <= *buflen) { 1171 } else if (len <= *buflen) {
1174 memcpy(buffer, utf16Name.c_str(), len); 1172 memcpy(buffer, utf16Name.c_str(), len);
1175 *buflen = len; 1173 *buflen = len;
1176 } else { 1174 } else {
1177 *buflen = -1; 1175 *buflen = -1;
1178 } 1176 }
1179 return (FPDF_DEST)pDestObj; 1177 return (FPDF_DEST)pDestObj;
1180 } 1178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698