diff options
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, |