summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfformfill.cpp
diff options
context:
space:
mode:
authorDiana Gage <drgage@google.com>2017-07-28 17:07:39 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-07-31 21:43:06 +0000
commitab3909796cf2e9fa192040bcd7cb9da7bb3328a5 (patch)
treec4b3d336aa8d3539794ec0a9740cb9d78a7b0af8 /fpdfsdk/fpdfformfill.cpp
parent47c9e6d1a151c7c8b0649712a91e04f12177b7b9 (diff)
downloadpdfium-ab3909796cf2e9fa192040bcd7cb9da7bb3328a5.tar.xz
Add FORM_ReplaceSelection() and embedder tests.
This method replaces the selected text in a user-editable form text area with another text string (which can be empty or non-empty). If there is no selected text, FORM_ReplaceSelection() will append the replacement text after the current caret position. BUG=chromium:59266 Change-Id: I76448ef757d107888c33ebd5656457ebac93b952 Reviewed-on: https://pdfium-review.googlesource.com/8812 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Diana Gage <drgage@google.com>
Diffstat (limited to 'fpdfsdk/fpdfformfill.cpp')
-rw-r--r--fpdfsdk/fpdfformfill.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index e541b81cc3..7f4e3dfd69 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -383,12 +383,17 @@ DLLEXPORT unsigned long STDCALL FORM_GetSelectedText(FPDF_FORMHANDLE hHandle,
return form_text_len;
}
-DLLEXPORT void STDCALL FORM_DeleteSelectedText(FPDF_FORMHANDLE hHandle,
- FPDF_PAGE page) {
+DLLEXPORT void STDCALL FORM_ReplaceSelection(FPDF_FORMHANDLE hHandle,
+ FPDF_PAGE page,
+ FPDF_WIDESTRING wsText) {
CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
if (!pPageView)
return;
- pPageView->DeleteSelectedText();
+
+ FX_STRSIZE len = CFX_WideString::WStringLength(wsText);
+ CFX_WideString wide_str_text = CFX_WideString::FromUTF16LE(wsText, len);
+
+ pPageView->ReplaceSelection(wide_str_text);
}
DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) {