summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
Diffstat (limited to 'samples')
-rw-r--r--samples/pdfium_test.cc19
-rw-r--r--samples/pdfium_test_dump_helper.cc5
-rw-r--r--samples/pdfium_test_write_helper.cc10
3 files changed, 14 insertions, 20 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 292673f1de..c2c217ddae 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -18,7 +18,7 @@
#define _SKIA_SUPPORT_
#endif
-#include "public/cpp/fpdf_deleters.h"
+#include "public/cpp/fpdf_scopers.h"
#include "public/fpdf_annot.h"
#include "public/fpdf_attachment.h"
#include "public/fpdf_dataavail.h"
@@ -136,7 +136,7 @@ Optional<std::string> ExpandDirectoryPath(const std::string& path) {
struct FPDF_FORMFILLINFO_PDFiumTest : public FPDF_FORMFILLINFO {
// Hold a map of the currently loaded pages in order to avoid them
// to get loaded twice.
- std::map<int, std::unique_ptr<void, FPDFPageDeleter>> loaded_pages;
+ std::map<int, ScopedFPDFPage> loaded_pages;
// Hold a pointer of FPDF_FORMHANDLE so that PDFium app hooks can
// make use of it.
@@ -473,7 +473,7 @@ FPDF_PAGE GetPageForIndex(FPDF_FORMFILLINFO* param,
if (iter != loaded_pages.end())
return iter->second.get();
- std::unique_ptr<void, FPDFPageDeleter> page(FPDF_LoadPage(doc, index));
+ ScopedFPDFPage page(FPDF_LoadPage(doc, index));
if (!page)
return nullptr;
@@ -513,8 +513,7 @@ bool RenderPage(const std::string& name,
return true;
}
- std::unique_ptr<void, FPDFTextPageDeleter> text_page(FPDFText_LoadPage(page));
-
+ ScopedFPDFTextPage text_page(FPDFText_LoadPage(page));
double scale = 1.0;
if (!options.scale_factor_as_string.empty())
std::stringstream(options.scale_factor_as_string) >> scale;
@@ -522,8 +521,7 @@ bool RenderPage(const std::string& name,
auto width = static_cast<int>(FPDF_GetPageWidth(page) * scale);
auto height = static_cast<int>(FPDF_GetPageHeight(page) * scale);
int alpha = FPDFPage_HasTransparency(page) ? 1 : 0;
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap(
- FPDFBitmap_Create(width, height, alpha));
+ ScopedFPDFBitmap bitmap(FPDFBitmap_Create(width, height, alpha));
if (bitmap) {
FPDF_DWORD fill_color = alpha ? 0x00000000 : 0xFFFFFFFF;
@@ -637,11 +635,10 @@ void RenderPdf(const std::string& name,
hints.AddSegment = Add_Segment;
// The pdf_avail must outlive doc.
- std::unique_ptr<void, FPDFAvailDeleter> pdf_avail(
- FPDFAvail_Create(&file_avail, &file_access));
+ ScopedFPDFAvail pdf_avail(FPDFAvail_Create(&file_avail, &file_access));
// The document must outlive |form_callbacks.loaded_pages|.
- std::unique_ptr<void, FPDFDocumentDeleter> doc;
+ ScopedFPDFDocument doc;
int nRet = PDF_DATA_NOTAVAIL;
bool bIsLinearized = false;
@@ -701,7 +698,7 @@ void RenderPdf(const std::string& name,
form_callbacks.m_pJsPlatform = &platform_callbacks;
#endif // PDF_ENABLE_V8
- std::unique_ptr<void, FPDFFormHandleDeleter> form(
+ ScopedFPDFFormHandle form(
FPDFDOC_InitFormFillEnvironment(doc.get(), &form_callbacks));
form_callbacks.form_handle = form.get();
diff --git a/samples/pdfium_test_dump_helper.cc b/samples/pdfium_test_dump_helper.cc
index 729a4cd152..2b422a93fb 100644
--- a/samples/pdfium_test_dump_helper.cc
+++ b/samples/pdfium_test_dump_helper.cc
@@ -11,7 +11,7 @@
#include <string>
#include <utility>
-#include "public/cpp/fpdf_deleters.h"
+#include "public/cpp/fpdf_scopers.h"
#include "testing/test_support.h"
namespace {
@@ -55,8 +55,7 @@ void DumpChildStructure(FPDF_STRUCTELEMENT child, int indent) {
}
void DumpPageStructure(FPDF_PAGE page, const int page_idx) {
- std::unique_ptr<void, FPDFStructTreeDeleter> tree(
- FPDF_StructTree_GetForPage(page));
+ ScopedFPDFStructTree tree(FPDF_StructTree_GetForPage(page));
if (!tree) {
fprintf(stderr, "Failed to load struct tree for page %d\n", page_idx);
return;
diff --git a/samples/pdfium_test_write_helper.cc b/samples/pdfium_test_write_helper.cc
index d061252e07..c436c97fbe 100644
--- a/samples/pdfium_test_write_helper.cc
+++ b/samples/pdfium_test_write_helper.cc
@@ -9,7 +9,7 @@
#include <memory>
#include <vector>
-#include "public/cpp/fpdf_deleters.h"
+#include "public/cpp/fpdf_scopers.h"
#include "public/fpdf_annot.h"
#include "public/fpdf_attachment.h"
#include "public/fpdf_edit.h"
@@ -215,7 +215,7 @@ void WriteText(FPDF_PAGE page, const char* pdf_name, int num) {
return;
}
- std::unique_ptr<void, FPDFTextPageDeleter> textpage(FPDFText_LoadPage(page));
+ ScopedFPDFTextPage textpage(FPDFText_LoadPage(page));
for (int i = 0; i < FPDFText_CountChars(textpage.get()); i++) {
uint32_t c = FPDFText_GetUnicode(textpage.get(), i);
if (fwrite(&c, sizeof(c), 1, fp) != 1) {
@@ -250,8 +250,7 @@ void WriteAnnot(FPDF_PAGE page, const char* pdf_name, int num) {
for (int i = 0; i < annot_count; ++i) {
// Retrieve the annotation object and its subtype.
fprintf(fp, "Annotation #%d:\n", i + 1);
- std::unique_ptr<void, FPDFAnnotationDeleter> annot(
- FPDFPage_GetAnnot(page, i));
+ ScopedFPDFAnnotation annot(FPDFPage_GetAnnot(page, i));
if (!annot) {
fprintf(fp, "Failed to retrieve annotation!\n\n");
continue;
@@ -579,8 +578,7 @@ void WriteImages(FPDF_PAGE page, const char* pdf_name, int page_num) {
if (FPDFPageObj_GetType(obj) != FPDF_PAGEOBJ_IMAGE)
continue;
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap(
- FPDFImageObj_GetBitmap(obj));
+ ScopedFPDFBitmap bitmap(FPDFImageObj_GetBitmap(obj));
if (!bitmap) {
fprintf(stderr, "Image object #%d on page #%d has an empty bitmap.\n",
i + 1, page_num + 1);