summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-05-16 15:33:20 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-16 23:26:47 +0000
commitfe91c6c8211cec39f871d9202556e1957bf81983 (patch)
treeb7e763f7affe4c71de67393fbd320c1fed477e0f
parent365333552cf67b7c97c4093177e7ed7b43f540ab (diff)
downloadpdfium-fe91c6c8211cec39f871d9202556e1957bf81983.tar.xz
Be skeptical of bare |new|s.
In particular, prefer an explicit .release() call when handing ownership of an object to a caller across a C-API. Change-Id: Ic3784e9d0b2d378a08d388989eaea7c9166bacd1 Reviewed-on: https://pdfium-review.googlesource.com/5470 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
-rw-r--r--core/fxge/apple/fx_mac_imp.cpp6
-rw-r--r--fpdfsdk/cpdfsdk_annothandlermgr.cpp8
-rw-r--r--fpdfsdk/cpdfsdk_formfillenvironment.cpp7
-rw-r--r--fpdfsdk/formfiller/cffl_combobox.cpp14
-rw-r--r--fpdfsdk/formfiller/cffl_combobox.h4
-rw-r--r--fpdfsdk/fpdf_dataavail.cpp7
-rw-r--r--fpdfsdk/fpdf_sysfontinfo.cpp4
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp8
-rw-r--r--fpdfsdk/fpdfdoc.cpp3
-rw-r--r--fpdfsdk/fpdfeditpage.cpp23
-rw-r--r--fpdfsdk/fpdfeditpath.cpp13
-rw-r--r--fpdfsdk/fpdfedittext.cpp4
-rw-r--r--fpdfsdk/fpdfformfill.cpp20
-rw-r--r--public/fpdf_formfill.h9
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp7
-rw-r--r--xfa/fxfa/cxfa_ffwidget.h9
16 files changed, 78 insertions, 68 deletions
diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp
index 0b32083126..ced08d2776 100644
--- a/core/fxge/apple/fx_mac_imp.cpp
+++ b/core/fxge/apple/fx_mac_imp.cpp
@@ -5,12 +5,14 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include <memory>
+#include <utility>
#include "core/fxcrt/fx_codepage.h"
#include "core/fxge/apple/apple_int.h"
#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/ge/cfx_folderfontinfo.h"
#include "core/fxge/ifx_systemfontinfo.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -122,11 +124,11 @@ void* CFX_MacFontInfo::MapFont(int weight,
std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault(
const char** pUnused) {
- CFX_MacFontInfo* pInfo(new CFX_MacFontInfo);
+ auto pInfo = pdfium::MakeUnique<CFX_MacFontInfo>();
pInfo->AddPath("~/Library/Fonts");
pInfo->AddPath("/Library/Fonts");
pInfo->AddPath("/System/Library/Fonts");
- return std::unique_ptr<CFX_MacFontInfo>(pInfo);
+ return std::move(pInfo);
}
void CFX_GEModule::InitPlatform() {
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
index 287ee11a4d..7ea301c0e4 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
@@ -17,6 +17,7 @@
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_pageview.h"
#include "fpdfsdk/cpdfsdk_widgethandler.h"
+#include "third_party/base/ptr_util.h"
#ifdef PDF_ENABLE_XFA
#include "fpdfsdk/cpdfsdk_xfawidgethandler.h"
@@ -27,10 +28,11 @@
CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(
CPDFSDK_FormFillEnvironment* pFormFillEnv)
- : m_pBAAnnotHandler(new CPDFSDK_BAAnnotHandler()),
- m_pWidgetHandler(new CPDFSDK_WidgetHandler(pFormFillEnv)),
+ : m_pBAAnnotHandler(pdfium::MakeUnique<CPDFSDK_BAAnnotHandler>()),
+ m_pWidgetHandler(pdfium::MakeUnique<CPDFSDK_WidgetHandler>(pFormFillEnv)),
#ifdef PDF_ENABLE_XFA
- m_pXFAWidgetHandler(new CPDFSDK_XFAWidgetHandler(pFormFillEnv)),
+ m_pXFAWidgetHandler(
+ pdfium::MakeUnique<CPDFSDK_XFAWidgetHandler>(pFormFillEnv)),
#endif // PDF_ENABLE_XFA
m_pFormFillEnv(pFormFillEnv) {
m_pWidgetHandler->SetFormFiller(m_pFormFillEnv->GetInteractiveFormFiller());
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index e1b34ce51a..f17d28b9b6 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -7,6 +7,7 @@
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include <memory>
+#include <utility>
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfdoc/cpdf_docjsactions.h"
@@ -568,8 +569,10 @@ CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetPageView(
if (!renew)
return nullptr;
- CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pUnderlyingPage);
- m_PageMap[pUnderlyingPage].reset(pPageView);
+ auto pNew = pdfium::MakeUnique<CPDFSDK_PageView>(this, pUnderlyingPage);
+ CPDFSDK_PageView* pPageView = pNew.get();
+ m_PageMap[pUnderlyingPage] = std::move(pNew);
+
// Delay to load all the annotations, to avoid endless loop.
pPageView->LoadFXAnnots();
return pPageView;
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index ef05a883c9..1f2491fe95 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -13,10 +13,11 @@
#include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
#include "fpdfsdk/fsdk_common.h"
#include "fpdfsdk/pdfwindow/PWL_ComboBox.h"
+#include "third_party/base/ptr_util.h"
CFFL_ComboBox::CFFL_ComboBox(CPDFSDK_FormFillEnvironment* pApp,
CPDFSDK_Annot* pAnnot)
- : CFFL_FormFiller(pApp, pAnnot), m_pFontMap(nullptr) {
+ : CFFL_FormFiller(pApp, pAnnot) {
m_State.nIndex = 0;
m_State.nStart = 0;
m_State.nEnd = 0;
@@ -30,22 +31,17 @@ CFFL_ComboBox::~CFFL_ComboBox() {
// The font map should be stored somewhere more appropriate so it will live
// until the PWL_Edit is done with it. pdfium:566
DestroyWindows();
- delete m_pFontMap;
}
PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() {
PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
-
- int nFlags = m_pWidget->GetFieldFlags();
- if (nFlags & FIELDFLAG_EDIT) {
+ if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
- }
if (!m_pFontMap)
- m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler());
- cp.pFontMap = m_pFontMap;
+ m_pFontMap = pdfium::MakeUnique<CBA_FontMap>(m_pWidget, GetSystemHandler());
+ cp.pFontMap = m_pFontMap.get();
cp.pFocusHandler = this;
-
return cp;
}
diff --git a/fpdfsdk/formfiller/cffl_combobox.h b/fpdfsdk/formfiller/cffl_combobox.h
index aab10b90e1..e61e2b73c3 100644
--- a/fpdfsdk/formfiller/cffl_combobox.h
+++ b/fpdfsdk/formfiller/cffl_combobox.h
@@ -7,6 +7,8 @@
#ifndef FPDFSDK_FORMFILLER_CFFL_COMBOBOX_H_
#define FPDFSDK_FORMFILLER_CFFL_COMBOBOX_H_
+#include <memory>
+
#include "core/fxcrt/fx_string.h"
#include "fpdfsdk/formfiller/cffl_formfiller.h"
@@ -56,7 +58,7 @@ class CFFL_ComboBox : public CFFL_FormFiller, public IPWL_FocusHandler {
private:
CFX_WideString GetSelectExportText();
- CBA_FontMap* m_pFontMap;
+ std::unique_ptr<CBA_FontMap> m_pFontMap;
FFL_ComboBoxState m_State;
};
diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp
index f2358d2e5c..2511441af5 100644
--- a/fpdfsdk/fpdf_dataavail.cpp
+++ b/fpdfsdk/fpdf_dataavail.cpp
@@ -118,16 +118,17 @@ CFPDF_DataAvail* CFPDFDataAvailFromFPDFAvail(FPDF_AVAIL avail) {
DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail,
FPDF_FILEACCESS* file) {
- CFPDF_DataAvail* pAvail = new CFPDF_DataAvail;
+ auto pAvail = pdfium::MakeUnique<CFPDF_DataAvail>();
pAvail->m_FileAvail->Set(file_avail);
pAvail->m_FileRead->Set(file);
pAvail->m_pDataAvail = pdfium::MakeUnique<CPDF_DataAvail>(
pAvail->m_FileAvail.get(), pAvail->m_FileRead, true);
- return pAvail;
+ return pAvail.release(); // Caller takes ownership.
}
DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) {
- delete (CFPDF_DataAvail*)avail;
+ // Take ownership back from caller and destroy.
+ std::unique_ptr<CFPDF_DataAvail>(static_cast<CFPDF_DataAvail*>(avail));
}
DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail,
diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp
index 32e573611b..1b98b94358 100644
--- a/fpdfsdk/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/fpdf_sysfontinfo.cpp
@@ -15,6 +15,7 @@
#include "core/fxge/ifx_systemfontinfo.h"
#include "fpdfsdk/fsdk_define.h"
#include "fpdfsdk/pdfwindow/PWL_FontMap.h"
+#include "third_party/base/ptr_util.h"
static_assert(FXFONT_ANSI_CHARSET == FX_CHARSET_ANSI, "Charset must match");
static_assert(FXFONT_DEFAULT_CHARSET == FX_CHARSET_Default,
@@ -114,8 +115,7 @@ DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfoExt) {
return;
CFX_GEModule::Get()->GetFontMgr()->SetSystemFontInfo(
- std::unique_ptr<IFX_SystemFontInfo>(
- new CFX_ExternalFontInfo(pFontInfoExt)));
+ pdfium::MakeUnique<CFX_ExternalFontInfo>(pFontInfoExt));
}
DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap() {
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 32ba3a7525..cc5239b802 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -6,6 +6,7 @@
#include "public/fpdf_transformpage.h"
+#include <memory>
#include <vector>
#include "core/fpdfapi/page/cpdf_clippath.h"
@@ -222,13 +223,14 @@ DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left,
CPDF_Path Path;
Path.AppendRect(left, bottom, right, top);
- CPDF_ClipPath* pNewClipPath = new CPDF_ClipPath();
+ auto pNewClipPath = pdfium::MakeUnique<CPDF_ClipPath>();
pNewClipPath->AppendPath(Path, FXFILL_ALTERNATE, false);
- return pNewClipPath;
+ return pNewClipPath.release(); // Caller takes ownership.
}
DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath) {
- delete (CPDF_ClipPath*)clipPath;
+ // Take ownership back from caller and destroy.
+ std::unique_ptr<CPDF_ClipPath>(static_cast<CPDF_ClipPath*>(clipPath));
}
void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) {
diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp
index 0c8e26ceac..70a27a5011 100644
--- a/fpdfsdk/fpdfdoc.cpp
+++ b/fpdfsdk/fpdfdoc.cpp
@@ -230,8 +230,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFDest_GetLocationInPage(FPDF_DEST pDict,
if (!pDict)
return false;
- std::unique_ptr<CPDF_Dest> dest(
- new CPDF_Dest(static_cast<CPDF_Object*>(pDict)));
+ auto dest = pdfium::MakeUnique<CPDF_Dest>(static_cast<CPDF_Object*>(pDict));
// FPDF_BOOL is an int, GetXYZ expects bools.
bool bHasX;
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index 66ff028141..df752d4029 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -63,14 +63,13 @@ bool IsPageObject(CPDF_Page* pPage) {
} // namespace
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() {
- CPDF_Document* pDoc = new CPDF_Document(nullptr);
+ auto pDoc = pdfium::MakeUnique<CPDF_Document>(nullptr);
pDoc->CreateNewDoc();
- time_t currentTime;
+ time_t currentTime;
CFX_ByteString DateStr;
-
if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) {
- if (-1 != time(&currentTime)) {
+ if (time(&currentTime) != -1) {
tm* pTM = localtime(&currentTime);
if (pTM) {
DateStr.Format("D:%04d%02d%02d%02d%02d%02d", pTM->tm_year + 1900,
@@ -80,15 +79,15 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() {
}
}
- CPDF_Dictionary* pInfoDict = nullptr;
- pInfoDict = pDoc->GetInfo();
+ CPDF_Dictionary* pInfoDict = pDoc->GetInfo();
if (pInfoDict) {
if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
pInfoDict->SetNewFor<CPDF_String>("CreationDate", DateStr, false);
pInfoDict->SetNewFor<CPDF_String>("Creator", L"PDFium");
}
- return FPDFDocumentFromCPDFDocument(pDoc);
+ // Caller takes ownership of pDoc.
+ return FPDFDocumentFromCPDFDocument(pDoc.release());
}
DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) {
@@ -121,19 +120,17 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
auto pXFAPage = pdfium::MakeRetain<CPDFXFA_Page>(
static_cast<CPDFXFA_Context*>(document), page_index);
pXFAPage->LoadPDFPage(pPageDict);
- return pXFAPage.Leak();
+ return pXFAPage.Leak(); // Caller takes ownership.
#else // PDF_ENABLE_XFA
- CPDF_Page* pPage = new CPDF_Page(pDoc, pPageDict, true);
+ auto pPage = pdfium::MakeUnique<CPDF_Page>(pDoc, pPageDict, true);
pPage->ParseContent();
- return pPage;
+ return pPage.release(); // Caller takes ownership.
#endif // PDF_ENABLE_XFA
}
DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
- if (!IsPageObject(pPage))
- return -1;
- return pPage->GetPageRotation();
+ return IsPageObject(pPage) ? pPage->GetPageRotation() : -1;
}
DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
diff --git a/fpdfsdk/fpdfeditpath.cpp b/fpdfsdk/fpdfeditpath.cpp
index 155dda5c7d..a26ca5186e 100644
--- a/fpdfsdk/fpdfeditpath.cpp
+++ b/fpdfsdk/fpdfeditpath.cpp
@@ -7,22 +7,23 @@
#include "core/fpdfapi/page/cpdf_path.h"
#include "core/fpdfapi/page/cpdf_pathobject.h"
#include "core/fxcrt/fx_system.h"
+#include "third_party/base/ptr_util.h"
DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_CreateNewPath(float x, float y) {
- CPDF_PathObject* pPathObj = new CPDF_PathObject;
+ auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>();
pPathObj->m_Path.AppendPoint(CFX_PointF(x, y), FXPT_TYPE::MoveTo, false);
pPathObj->DefaultStates();
- return pPathObj;
+ return pPathObj.release(); // Caller takes ownership.
}
DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_CreateNewRect(float x,
float y,
float w,
float h) {
- CPDF_PathObject* pPathObj = new CPDF_PathObject;
+ auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>();
pPathObj->m_Path.AppendRect(x, y, x + w, y + h);
pPathObj->DefaultStates();
- return pPathObj;
+ return pPathObj.release(); // Caller takes ownership.
}
DLLEXPORT FPDF_BOOL FPDFPath_SetStrokeColor(FPDF_PAGEOBJECT path,
@@ -33,9 +34,9 @@ DLLEXPORT FPDF_BOOL FPDFPath_SetStrokeColor(FPDF_PAGEOBJECT path,
if (!path || R > 255 || G > 255 || B > 255 || A > 255)
return false;
+ float rgb[3] = {R / 255.f, G / 255.f, B / 255.f};
auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
pPathObj->m_GeneralState.SetStrokeAlpha(A / 255.f);
- float rgb[3] = {R / 255.f, G / 255.f, B / 255.f};
pPathObj->m_ColorState.SetStrokeColor(
CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
return true;
@@ -58,9 +59,9 @@ DLLEXPORT FPDF_BOOL FPDFPath_SetFillColor(FPDF_PAGEOBJECT path,
if (!path || R > 255 || G > 255 || B > 255 || A > 255)
return false;
+ float rgb[3] = {R / 255.f, G / 255.f, B / 255.f};
auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
pPathObj->m_GeneralState.SetFillAlpha(A / 255.f);
- float rgb[3] = {R / 255.f, G / 255.f, B / 255.f};
pPathObj->m_ColorState.SetFillColor(
CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
return true;
diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp
index 54388ef701..c2f2df9778 100644
--- a/fpdfsdk/fpdfedittext.cpp
+++ b/fpdfsdk/fpdfedittext.cpp
@@ -388,11 +388,11 @@ DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewTextObj(FPDF_DOCUMENT document,
if (!pFont)
return nullptr;
- CPDF_TextObject* pTextObj = new CPDF_TextObject;
+ auto pTextObj = pdfium::MakeUnique<CPDF_TextObject>();
pTextObj->m_TextState.SetFont(pFont);
pTextObj->m_TextState.SetFontSize(font_size);
pTextObj->DefaultStates();
- return pTextObj;
+ return pTextObj.release(); // Caller takes ownership.
}
DLLEXPORT FPDF_BOOL STDCALL FPDFText_SetText(FPDF_PAGEOBJECT text_object,
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index de200cf7bb..a466e73abb 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -263,14 +263,14 @@ FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
return pDocument->GetFormFillEnv();
#endif
- CPDFSDK_FormFillEnvironment* pFormFillEnv =
- new CPDFSDK_FormFillEnvironment(pDocument, formInfo);
+ auto pFormFillEnv =
+ pdfium::MakeUnique<CPDFSDK_FormFillEnvironment>(pDocument, formInfo);
#ifdef PDF_ENABLE_XFA
- pDocument->SetFormFillEnv(pFormFillEnv);
+ pDocument->SetFormFillEnv(pFormFillEnv.get());
#endif // PDF_ENABLE_XFA
- return pFormFillEnv;
+ return pFormFillEnv.release(); // Caller takes ownership.
}
DLLEXPORT void STDCALL
@@ -575,18 +575,20 @@ FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document,
if (!hWidget || !document)
return;
- CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document);
+ auto* pContext = static_cast<CPDFXFA_Context*>(document);
if (pContext->GetDocType() != XFA_DocType::Dynamic &&
pContext->GetDocType() != XFA_DocType::Static)
return;
- std::vector<CFX_ByteString>* sSuggestWords = new std::vector<CFX_ByteString>;
CFX_PointF ptPopup;
ptPopup.x = x;
ptPopup.y = y;
- static_cast<CXFA_FFWidget*>(hWidget)
- ->GetSuggestWords(ptPopup, *sSuggestWords);
- *stringHandle = ToFPDFStringHandle(sSuggestWords);
+ auto sSuggestWords = pdfium::MakeUnique<std::vector<CFX_ByteString>>();
+ static_cast<CXFA_FFWidget*>(hWidget)->GetSuggestWords(ptPopup,
+ sSuggestWords.get());
+
+ // Caller takes ownership.
+ *stringHandle = ToFPDFStringHandle(sSuggestWords.release());
}
DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE sHandle) {
diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h
index 09b80eaf90..65be850b36 100644
--- a/public/fpdf_formfill.h
+++ b/public/fpdf_formfill.h
@@ -1687,15 +1687,16 @@ FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document,
/**
* Function: FPDF_Widget_GetSpellCheckWords
* This method will implement the spell check feature for the specified
- *xfa field.
+ * xfa field.
* Parameters:
- * document - Handle to document. Returned by
- *FPDF_LoadDocument function.
+ * document - Handle to document as returned by
+ * FPDF_LoadDocument function.
* hWidget - Handle to the xfa field.
* x - The x value of the specified point.
* y - The y value of the specified point.
* stringHandle - Pointer to FPDF_STRINGHANDLE to receive the
- *speck check text buffer, in UTF-16LE format.
+ * speck check text buffer, in UTF-16LE format.
+ * Caller must free using FPDF_StringHandleRelease.
* Return Value:
* None.
**/
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 69aabe38be..7bbb8c8265 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -333,10 +333,11 @@ void CXFA_FFWidget::Delete() {}
void CXFA_FFWidget::DeSelect() {}
-bool CXFA_FFWidget::GetSuggestWords(CFX_PointF pointf,
- std::vector<CFX_ByteString>& sSuggest) {
- return false;
+void CXFA_FFWidget::GetSuggestWords(CFX_PointF pointf,
+ std::vector<CFX_ByteString>* pWords) {
+ pWords->clear();
}
+
bool CXFA_FFWidget::ReplaceSpellCheckWord(CFX_PointF pointf,
const CFX_ByteStringC& bsReplace) {
return false;
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index 35a36002c7..2ca27c1303 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -136,10 +136,11 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem {
virtual void SelectAll();
virtual void Delete();
virtual void DeSelect();
- virtual bool GetSuggestWords(CFX_PointF pointf,
- std::vector<CFX_ByteString>& sSuggest);
- virtual bool ReplaceSpellCheckWord(CFX_PointF pointf,
- const CFX_ByteStringC& bsReplace);
+
+ // TODO(tsepez): Implement or remove.
+ void GetSuggestWords(CFX_PointF pointf, std::vector<CFX_ByteString>* pWords);
+ bool ReplaceSpellCheckWord(CFX_PointF pointf,
+ const CFX_ByteStringC& bsReplace);
CXFA_FFPageView* GetPageView() const { return m_pPageView; }
void SetPageView(CXFA_FFPageView* pPageView) { m_pPageView = pPageView; }