diff options
author | Lei Zhang <thestig@chromium.org> | 2018-04-17 15:12:58 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-17 15:12:58 +0000 |
commit | a4c7ac479d291fc3373b9c2f8f25302ecd53b0d5 (patch) | |
tree | 6403f92adcae02ef51897ad932ffc585c2422655 /fpdfsdk/fpdf_formfill.cpp | |
parent | 3900ddb64f30f36fd6696bd2927cf8f151e6ede9 (diff) | |
download | pdfium-a4c7ac479d291fc3373b9c2f8f25302ecd53b0d5.tar.xz |
Implement FORM_GetFocusedText() API.
If there is a focused form field, get its text.
BUG=chromium:753216
Change-Id: I05294f14d05c1c86769055f6c9eaf9177787d9fd
Reviewed-on: https://pdfium-review.googlesource.com/12072
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_formfill.cpp')
-rw-r--r-- | fpdfsdk/fpdf_formfill.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp index 912db878f8..7676463edc 100644 --- a/fpdfsdk/fpdf_formfill.cpp +++ b/fpdfsdk/fpdf_formfill.cpp @@ -427,6 +427,19 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnChar(FPDF_FORMHANDLE hHandle, } FPDF_EXPORT unsigned long FPDF_CALLCONV +FORM_GetFocusedText(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + void* buffer, + unsigned long buflen) { + CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); + if (!pPageView) + return 0; + + return Utf16EncodeMaybeCopyAndReturnLength(pPageView->GetFocusedFormText(), + buffer, buflen); +} + +FPDF_EXPORT unsigned long FPDF_CALLCONV FORM_GetSelectedText(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, void* buffer, @@ -435,14 +448,8 @@ FORM_GetSelectedText(FPDF_FORMHANDLE hHandle, if (!pPageView) return 0; - WideString wide_str_form_text = pPageView->GetSelectedText(); - ByteString encoded_form_text = wide_str_form_text.UTF16LE_Encode(); - unsigned long form_text_len = encoded_form_text.GetLength(); - - if (buffer && buflen >= form_text_len) - memcpy(buffer, encoded_form_text.c_str(), form_text_len); - - return form_text_len; + return Utf16EncodeMaybeCopyAndReturnLength(pPageView->GetSelectedText(), + buffer, buflen); } FPDF_EXPORT void FPDF_CALLCONV FORM_ReplaceSelection(FPDF_FORMHANDLE hHandle, |