Revert "Remove CFX_ByteTextBuf from cpdfsdk_interform.cpp and others."
This reverts commit aea80dcc0abc0c310316fa502f91a359bc684758.
Reason for revert: WriteBuf's behavior was altered
Original change's description:
> Remove CFX_ByteTextBuf from cpdfsdk_interform.cpp and others.
>
> Bug: pdfium:731
> Change-Id: I61d38ab3f2b0ac68b8479ade25bab50f3a73c27b
> Reviewed-on: https://pdfium-review.googlesource.com/9770
> Reviewed-by: Tom Sepez <tsepez@chromium.org>
> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
TBR=tsepez@chromium.org,hnakashima@chromium.org,rharrison@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: pdfium:731
Change-Id: Ic66a2641c259173fb3792f7a4206e19ee4707fc9
Reviewed-on: https://pdfium-review.googlesource.com/10150
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 77878a5..ba4b2ae 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -7,7 +7,6 @@
#include "fpdfsdk/javascript/Document.h"
#include <algorithm>
-#include <sstream>
#include <utility>
#include <vector>
@@ -383,21 +382,16 @@
iLength > 4 ? params[4].ToCFXWideString(pRuntime) : L"";
CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString(pRuntime) : L"";
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
- CFX_ByteString sTextBuf = pInterForm->ExportFormToFDFTextBuf();
- if (sTextBuf.GetLength() == 0)
+ CFX_ByteTextBuf textBuf;
+ if (!pInterForm->ExportFormToFDFTextBuf(textBuf))
return false;
- FX_STRSIZE nBufSize = sTextBuf.GetLength();
- char* pMutableBuf = FX_Alloc(char, nBufSize);
- memcpy(pMutableBuf, sTextBuf.c_str(), nBufSize);
-
pRuntime->BeginBlock();
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
- pFormFillEnv->JS_docmailForm(pMutableBuf, nBufSize, bUI, cTo.c_str(),
- cSubject.c_str(), cCc.c_str(), cBcc.c_str(),
- cMsg.c_str());
+ pFormFillEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI,
+ cTo.c_str(), cSubject.c_str(), cCc.c_str(),
+ cBcc.c_str(), cMsg.c_str());
pRuntime->EndBlock();
- FX_Free(pMutableBuf);
return true;
}