diff options
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 54 |
1 files changed, 16 insertions, 38 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index c9087e8a0b..1b503b3fca 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -404,8 +404,7 @@ void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, WideString& wsTitle) { return; ByteString csTitle = pInfoDict->GetStringFor("Title"); - wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength())); - csTitle.ReleaseBuffer(csTitle.GetLength()); + wsTitle = WideString::FromLocal(csTitle.c_str()); } void CPDFXFA_DocEnvironment::SetTitle(CXFA_FFDoc* hDoc, @@ -442,11 +441,8 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, WideString filepath = pFormFillEnv->JS_fieldBrowse(); bs = filepath.UTF16LE_Encode(); } - int len = bs.GetLength(); - FPDF_FILEHANDLER* pFileHandler = - pFormFillEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, - (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); - bs.ReleaseBuffer(len); + FPDF_FILEHANDLER* pFileHandler = pFormFillEnv->OpenFile( + bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, AsFPDFWideString(&bs), "wb"); if (!pFileHandler) return; @@ -662,16 +658,14 @@ bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() { WideString ws = WideString::FromLocal(IDS_XFA_Validate_Input); ByteString bs = ws.UTF16LE_Encode(); - int len = bs.GetLength(); - pFormFillEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), - (FPDF_WIDESTRING)L"", 0, 1); - bs.ReleaseBuffer(len); + pFormFillEnv->Alert(AsFPDFWideString(&bs), + reinterpret_cast<FPDF_WIDESTRING>(L""), 0, 1); return false; } pNode = it->MoveToNext(); } - docView->UpdateDocView(); + docView->UpdateDocView(); return true; } @@ -719,10 +713,8 @@ RetainPtr<IFX_SeekableReadStream> CPDFXFA_DocEnvironment::OpenLinkedFile( return nullptr; ByteString bs = wsLink.UTF16LE_Encode(); - int len = bs.GetLength(); FPDF_FILEHANDLER* pFileHandler = - pFormFillEnv->OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); - bs.ReleaseBuffer(len); + pFormFillEnv->OpenFile(0, AsFPDFWideString(&bs), "rb"); if (!pFileHandler) return nullptr; @@ -919,10 +911,8 @@ bool CPDFXFA_DocEnvironment::SubmitInternal(CXFA_FFDoc* hDoc, if (csURL.IsEmpty()) { WideString ws = WideString::FromLocal("Submit cancelled."); ByteString bs = ws.UTF16LE_Encode(); - int len = bs.GetLength(); - pFormFillEnv->Alert(reinterpret_cast<FPDF_WIDESTRING>(bs.GetBuffer(len)), + pFormFillEnv->Alert(AsFPDFWideString(&bs), reinterpret_cast<FPDF_WIDESTRING>(L""), 0, 4); - bs.ReleaseBuffer(len); return false; } @@ -978,27 +968,15 @@ bool CPDFXFA_DocEnvironment::SubmitInternal(CXFA_FFDoc* hDoc, ByteString bsBcc = WideString(csBCCAddress).UTF16LE_Encode(); ByteString bsSubject = WideString(csSubject).UTF16LE_Encode(); ByteString bsMsg = WideString(csMsg).UTF16LE_Encode(); - FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); - FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); - FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); - FPDF_WIDESTRING pSubject = - (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); - FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); - pFormFillEnv->EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg); - bsTo.ReleaseBuffer(bsTo.GetStringLength()); - bsCC.ReleaseBuffer(bsCC.GetStringLength()); - bsBcc.ReleaseBuffer(bsBcc.GetStringLength()); - bsSubject.ReleaseBuffer(bsSubject.GetStringLength()); - bsMsg.ReleaseBuffer(bsMsg.GetStringLength()); - } else { - // HTTP or FTP - WideString ws; - ByteString bs = csURL.UTF16LE_Encode(); - int len = bs.GetLength(); - pFormFillEnv->UploadTo(pFileHandler, fileFlag, - (FPDF_WIDESTRING)bs.GetBuffer(len)); - bs.ReleaseBuffer(len); + pFormFillEnv->EmailTo(pFileHandler, AsFPDFWideString(&bsTo), + AsFPDFWideString(&bsSubject), AsFPDFWideString(&bsCC), + AsFPDFWideString(&bsBcc), AsFPDFWideString(&bsMsg)); + return true; } + + // HTTP or FTP + ByteString bs = csURL.UTF16LE_Encode(); + pFormFillEnv->UploadTo(pFileHandler, fileFlag, AsFPDFWideString(&bs)); return true; } |