From e6f11a7b95e26affba59a7057776a787056af8df Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 27 Apr 2015 11:47:29 -0700 Subject: Reduce usage of operator LPCWSTR from CFX_WideString(). This involves adding some explicit c_str() calls. Doing so flagged PDF_EncodeText() and FindOptionValue() as having suboptimal signatures, in that we are often throwing away a perfectly fine length and recomputing it. There are still some platform-specific code that needs the operator. R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/1101933003 --- core/include/fpdfapi/fpdf_parser.h | 7 +- core/include/fpdfdoc/fpdf_doc.h | 2 +- .../src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 4 - core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp | 6 +- .../fpdfapi/fpdf_parser/fpdf_parser_objects.cpp | 2 +- core/src/fpdfdoc/doc_ap.cpp | 6 +- core/src/fpdfdoc/doc_basic.cpp | 2 +- core/src/fpdfdoc/doc_form.cpp | 5 +- core/src/fpdfdoc/doc_formfield.cpp | 8 +- core/src/fpdftext/fpdf_text_int.cpp | 4 +- core/src/fxcrt/fx_basic_wstring.cpp | 4 +- fpdfsdk/src/formfiller/FFL_ComboBox.cpp | 17 ++-- fpdfsdk/src/formfiller/FFL_IFormFiller.cpp | 2 +- fpdfsdk/src/formfiller/FFL_ListBox.cpp | 6 +- fpdfsdk/src/formfiller/FFL_TextField.cpp | 9 +- fpdfsdk/src/fpdfdoc.cpp | 2 +- fpdfsdk/src/fsdk_annothandler.cpp | 11 +-- fpdfsdk/src/fsdk_baseform.cpp | 2 +- fpdfsdk/src/fxedit/fxet_edit.cpp | 4 +- fpdfsdk/src/javascript/Document.cpp | 28 +++---- fpdfsdk/src/javascript/Field.cpp | 28 +++---- fpdfsdk/src/javascript/JS_Context.cpp | 4 +- fpdfsdk/src/javascript/JS_GlobalData.cpp | 5 +- fpdfsdk/src/javascript/JS_Value.cpp | 4 +- fpdfsdk/src/javascript/PublicMethods.cpp | 98 +++++++++++----------- fpdfsdk/src/javascript/app.cpp | 22 +++-- fpdfsdk/src/javascript/global.cpp | 24 +++--- fpdfsdk/src/javascript/util.cpp | 16 ++-- fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp | 4 +- fpdfsdk/src/pdfwindow/PWL_Edit.cpp | 16 ++-- fpdfsdk/src/pdfwindow/PWL_IconList.cpp | 2 +- fpdfsdk/src/pdfwindow/PWL_Note.cpp | 19 ++--- fpdfsdk/src/pdfwindow/PWL_Utils.cpp | 15 ++-- 33 files changed, 183 insertions(+), 205 deletions(-) diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h index c72acc834f..20766702e2 100644 --- a/core/include/fpdfapi/fpdf_parser.h +++ b/core/include/fpdfapi/fpdf_parser.h @@ -793,9 +793,14 @@ CFX_ByteString PDF_NameDecode(FX_BSTR orig); CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig); CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig); CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex = FALSE); -CFX_WideString PDF_DecodeText(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL); CFX_WideString PDF_DecodeText(FX_LPCBYTE pData, FX_DWORD size, CFX_CharMap* pCharMap = NULL); +inline CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr, CFX_CharMap* pCharMap = NULL) { + return PDF_DecodeText((FX_LPCBYTE)bstr.c_str(), bstr.GetLength(), pCharMap); +} CFX_ByteString PDF_EncodeText(FX_LPCWSTR pString, int len = -1, CFX_CharMap* pCharMap = NULL); +inline CFX_ByteString PDF_EncodeText(const CFX_WideString& str, CFX_CharMap* pCharMap = NULL) { + return PDF_EncodeText(str.c_str(), str.GetLength(), pCharMap); +} FX_FLOAT PDF_ClipFloat(FX_FLOAT f); class CFDF_Document : public CPDF_IndirectObjects { diff --git a/core/include/fpdfdoc/fpdf_doc.h b/core/include/fpdfdoc/fpdf_doc.h index 40d57236cd..31480f90bc 100644 --- a/core/include/fpdfdoc/fpdf_doc.h +++ b/core/include/fpdfdoc/fpdf_doc.h @@ -1162,7 +1162,7 @@ public: int FindOption(CFX_WideString csOptLabel); - int FindOptionValue(FX_LPCWSTR csOptValue, int iStartIndex = 0); + int FindOptionValue(const CFX_WideString& csOptValue, int iStartIndex = 0); diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 9514065eeb..0bb66da209 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -436,10 +436,6 @@ CFX_WideString PDF_DecodeText(FX_LPCBYTE src_data, FX_DWORD src_len, CFX_CharMap } return result; } -CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr, CFX_CharMap* pCharMap) -{ - return PDF_DecodeText((FX_LPCBYTE)bstr.c_str(), bstr.GetLength(), pCharMap); -} CFX_ByteString PDF_EncodeText(FX_LPCWSTR pString, int len, CFX_CharMap* pCharMap) { if (len == -1) { diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp index db4d0dba43..5bacfd7393 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp @@ -141,7 +141,7 @@ void FPDF_FileSpec_SetWin32Path(CPDF_Object* pFileSpec, const CFX_WideString& fi } else if (filepath.GetLength() > 1 && filepath[0] == '\\' && filepath[1] == '\\') { result = ChangeSlash(filepath.c_str() + 1); } else { - result = ChangeSlash(filepath); + result = ChangeSlash(filepath.c_str()); } if (pFileSpec->GetType() == PDFOBJ_STRING) { pFileSpec->SetString(CFX_ByteString::FromUnicode(result)); @@ -173,7 +173,7 @@ CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec) wsFileName = CFX_WideString::FromLocal(pFileSpec->GetString()); } if (wsFileName[0] != '/') { - return ChangeSlash(wsFileName); + return ChangeSlash(wsFileName.c_str()); } if (wsFileName[2] == '/') { CFX_WideString result; @@ -184,7 +184,7 @@ CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec) } else { CFX_WideString result; result += '\\'; - result += ChangeSlash(wsFileName); + result += ChangeSlash(wsFileName.c_str()); return result; } } diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp index 912af297f5..008349c61c 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp @@ -375,7 +375,7 @@ void CPDF_Number::SetNumber(FX_FLOAT value) m_Float = value; } CPDF_String::CPDF_String(const CFX_WideString& str) : CPDF_Object(PDFOBJ_STRING), m_bHex(FALSE) { - m_String = PDF_EncodeText(str, str.GetLength()); + m_String = PDF_EncodeText(str); } CPDF_Array::~CPDF_Array() { diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp index ccc800aa1a..8a195a747d 100644 --- a/core/src/fpdfdoc/doc_ap.cpp +++ b/core/src/fpdfdoc/doc_ap.cpp @@ -464,7 +464,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict vt.SetLimitChar(dwMaxLen); } vt.Initialize(); - vt.SetText(swValue); + vt.SetText(swValue.c_str()); vt.RearrangeAll(); CPDF_Rect rcContent = vt.GetContentRect(); CPDF_Point ptOffset(0.0f, 0.0f); @@ -502,7 +502,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict vt.SetFontSize(fFontSize); } vt.Initialize(); - vt.SetText(swValue); + vt.SetText(swValue.c_str()); vt.RearrangeAll(); CPDF_Rect rcContent = vt.GetContentRect(); CPDF_Point ptOffset = CPDF_Point(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); @@ -573,7 +573,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict vt.SetFontSize(fFontSize); } vt.Initialize(); - vt.SetText(swItem); + vt.SetText(swItem.c_str()); vt.RearrangeAll(); FX_FLOAT fItemHeight = vt.GetContentRect().Height(); if (bSelected) { diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp index 496ed86122..48f3ccae98 100644 --- a/core/src/fpdfdoc/doc_basic.cpp +++ b/core/src/fpdfdoc/doc_basic.cpp @@ -567,6 +567,6 @@ FX_INT32 CPDF_PageLabel::GetPageByLabel(FX_BSTR bsLabel) const } FX_INT32 CPDF_PageLabel::GetPageByLabel(FX_WSTR wsLabel) const { - CFX_ByteString bsLabel = PDF_EncodeText((CFX_WideString)wsLabel); + CFX_ByteString bsLabel = PDF_EncodeText(wsLabel.GetPtr()); return GetPageByLabel(bsLabel); } diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp index 47f4a9139c..db56adc58d 100644 --- a/core/src/fpdfdoc/doc_form.cpp +++ b/core/src/fpdfdoc/doc_form.cpp @@ -34,7 +34,7 @@ class _CFieldNameExtractor public: _CFieldNameExtractor(const CFX_WideString& full_name) { - m_pStart = full_name; + m_pStart = full_name.c_str(); m_pEnd = m_pStart + full_name.GetLength(); m_pCur = m_pStart; } @@ -733,7 +733,8 @@ int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte } int CPDF_InterForm::CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2) { - FX_LPCWSTR ptr1 = name1, ptr2 = name2; + FX_LPCWSTR ptr1 = name1.c_str(); + FX_LPCWSTR ptr2 = name2.c_str(); if (name1.GetLength() != name2.GetLength()) { int i = 0; while (ptr1[i] == ptr2[i]) { diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp index a2f0fbd297..6de46de08a 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -646,7 +646,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL b if (m_Type == ListBox) { SelectOption(index, TRUE); if (!(m_Flags & FORMLIST_MULTISELECT)) { - m_pDict->SetAtString("V", PDF_EncodeText(opt_value, opt_value.GetLength())); + m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); } else { CPDF_Array* pArray = CPDF_Array::Create(); if (pArray == NULL) { @@ -668,7 +668,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL b m_pDict->SetAt("V", pArray); } } else if (m_Type == ComboBox) { - m_pDict->SetAtString("V", PDF_EncodeText(opt_value, opt_value.GetLength())); + m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); CPDF_Array* pI = CPDF_Array::Create(); if (pI == NULL) { return FALSE; @@ -783,7 +783,7 @@ int CPDF_FormField::FindOption(CFX_WideString csOptLabel) } return -1; } -int CPDF_FormField::FindOptionValue(FX_LPCWSTR csOptValue, int iStartIndex) +int CPDF_FormField::FindOptionValue(const CFX_WideString& csOptValue, int iStartIndex) { if (iStartIndex < 0) { iStartIndex = 0; @@ -811,7 +811,7 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex, FX_BOOL bChecked, FX_BOO if (bNotify && m_pForm->m_pFormNotify != NULL) { SaveCheckedFieldStatus(this, statusArray); } - CFX_WideString csWExport = pControl->GetExportValue(); + CFX_WideString csWExport = pControl->GetExportValue(); CFX_ByteString csBExport = PDF_EncodeText(csWExport); int iCount = CountControls(); FX_BOOL bUnison = PDF_FormField_IsUnison(this); diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp index 2b9a079006..be92c86d60 100644 --- a/core/src/fpdftext/fpdf_text_int.cpp +++ b/core/src/fpdftext/fpdf_text_int.cpp @@ -2379,7 +2379,7 @@ FX_BOOL CPDF_TextPageFind::FindNext() continue; } int endIndex; - nResultPos = m_strText.Find(csWord, nStartPos); + nResultPos = m_strText.Find(csWord.c_str(), nStartPos); if (nResultPos == -1) { m_IsFind = FALSE; return m_IsFind; @@ -2496,7 +2496,7 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) int index = 0; while(1) { CFX_WideString csWord = TEXT_EMPTY; - int ret = ExtractSubString(csWord, findwhat, index, TEXT_BLANK_CHAR); + int ret = ExtractSubString(csWord, findwhat.c_str(), index, TEXT_BLANK_CHAR); if(csWord.IsEmpty()) { if(ret) { m_csFindWhatArray.Add(CFX_WideString(L"")); diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp index dfdbef8bd6..e255aa0779 100644 --- a/core/src/fxcrt/fx_basic_wstring.cpp +++ b/core/src/fxcrt/fx_basic_wstring.cpp @@ -1062,13 +1062,13 @@ static CFX_ByteString _DefMap_GetByteString(CFX_CharMap* pCharMap, const CFX_Wid { int src_len = widestr.GetLength(); int codepage = pCharMap->m_GetCodePage ? pCharMap->m_GetCodePage() : 0; - int dest_len = FXSYS_WideCharToMultiByte(codepage, 0, widestr, src_len, NULL, 0, NULL, NULL); + int dest_len = FXSYS_WideCharToMultiByte(codepage, 0, widestr.c_str(), src_len, NULL, 0, NULL, NULL); if (dest_len == 0) { return CFX_ByteString(); } CFX_ByteString bytestr; FX_LPSTR dest_buf = bytestr.GetBuffer(dest_len); - FXSYS_WideCharToMultiByte(codepage, 0, widestr, src_len, dest_buf, dest_len, NULL, NULL); + FXSYS_WideCharToMultiByte(codepage, 0, widestr.c_str(), src_len, dest_buf, dest_len, NULL, NULL); bytestr.ReleaseBuffer(dest_len); return bytestr; } diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp index 9e58c952aa..012ed4a730 100644 --- a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp +++ b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp @@ -77,28 +77,23 @@ CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageVie pWnd->AttachFFLData(this); pWnd->Create(cp); - ASSERT(m_pApp != NULL); CFFL_IFormFiller* pFormFiller = m_pApp->GetIFormFiller(); pWnd->SetFillerNotify(pFormFiller); - ASSERT(m_pWidget != NULL); FX_INT32 nCurSel = m_pWidget->GetSelectedIndex(0); - CFX_WideString swText; - if (nCurSel < 0) swText = m_pWidget->GetValue(); else swText = m_pWidget->GetOptionLabel(nCurSel); - + for (FX_INT32 i=0,sz=m_pWidget->CountOptions(); iAddString(m_pWidget->GetOptionLabel(i)); + pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str()); } - + pWnd->SetSelect(nCurSel); - pWnd->SetText(swText); - + pWnd->SetText(swText.c_str()); return pWnd; } @@ -245,7 +240,7 @@ void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AAc if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { pEdit->SetSel(fa.nSelStart, fa.nSelEnd); - pEdit->ReplaceSel(fa.sChange); + pEdit->ReplaceSel(fa.sChange.c_str()); } } break; @@ -297,7 +292,7 @@ void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) { if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { - pEdit->SetText(m_State.sValue); + pEdit->SetText(m_State.sValue.c_str()); pEdit->SetSel(m_State.nStart, m_State.nEnd); } } diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp index 2b21e13cfc..1656ba5c5d 100644 --- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp +++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp @@ -973,7 +973,7 @@ void CFFL_IFormFiller::OnFormat(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPage if (bFormated) { - pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue, TRUE); + pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue.c_str(), TRUE); pInterForm->UpdateField(pWidget->GetFormField()); } diff --git a/fpdfsdk/src/formfiller/FFL_ListBox.cpp b/fpdfsdk/src/formfiller/FFL_ListBox.cpp index 87ae552a66..dffd17538f 100644 --- a/fpdfsdk/src/formfiller/FFL_ListBox.cpp +++ b/fpdfsdk/src/formfiller/FFL_ListBox.cpp @@ -76,11 +76,9 @@ CPWL_Wnd* CFFL_ListBox::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); pWnd->SetFillerNotify(pIFormFiller); - ASSERT(m_pWidget != NULL); - for (FX_INT32 i=0,sz=m_pWidget->CountOptions(); iAddString(m_pWidget->GetOptionLabel(i)); - + pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str()); + if (pWnd->HasFlag(PLBS_MULTIPLESEL)) { m_OriginSelections.RemoveAll(); diff --git a/fpdfsdk/src/formfiller/FFL_TextField.cpp b/fpdfsdk/src/formfiller/FFL_TextField.cpp index f45d95364d..f488fac6ae 100644 --- a/fpdfsdk/src/formfiller/FFL_TextField.cpp +++ b/fpdfsdk/src/formfiller/FFL_TextField.cpp @@ -129,9 +129,8 @@ CPWL_Wnd* CFFL_TextField::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageVi pWnd->SetLimitChar(nMaxLen); } } - - pWnd->SetText(swValue); - + + pWnd->SetText(swValue.c_str()); return pWnd; } @@ -251,7 +250,7 @@ void CFFL_TextField::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AA { pEdit->SetFocus(); pEdit->SetSel(fa.nSelStart, fa.nSelEnd); - pEdit->ReplaceSel(fa.sChange); + pEdit->ReplaceSel(fa.sChange.c_str()); } break; default: @@ -292,7 +291,7 @@ void CFFL_TextField::RestoreState(CPDFSDK_PageView* pPageView) if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, TRUE)) { - pWnd->SetText(m_State.sValue); + pWnd->SetText(m_State.sValue.c_str()); pWnd->SetSel(m_State.nStart, m_State.nEnd); } } diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp index 6f36674e68..52d88b276e 100644 --- a/fpdfsdk/src/fpdfdoc.cpp +++ b/fpdfsdk/src/fpdfdoc.cpp @@ -11,7 +11,7 @@ static int THISMODULE = 0; static CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, CPDF_Bookmark bookmark, const CFX_WideString& title) { - if (bookmark && bookmark.GetTitle().CompareNoCase(title) == 0) { + if (bookmark && bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) { // First check this item return bookmark; } diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp index 9f208d34e2..bc0f047897 100644 --- a/fpdfsdk/src/fsdk_annothandler.cpp +++ b/fpdfsdk/src/fsdk_annothandler.cpp @@ -668,27 +668,22 @@ void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) else { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; - - if (!pWidget->IsAppearanceValid()) + if (!pWidget->IsAppearanceValid()) pWidget->ResetAppearance(NULL, FALSE); - + int nFieldType = pWidget->GetFieldType(); - if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { FX_BOOL bFormated = FALSE; CFX_WideString sValue = pWidget->OnFormat(0, bFormated); - if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) { - pWidget->ResetAppearance(sValue, FALSE); + pWidget->ResetAppearance(sValue.c_str(), FALSE); } } - if (m_pFormFiller) m_pFormFiller->OnLoad(pAnnot); - } } diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp index 0c0492d723..123af9f714 100644 --- a/fpdfsdk/src/fsdk_baseform.cpp +++ b/fpdfsdk/src/fsdk_baseform.cpp @@ -2529,7 +2529,7 @@ int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) FX_BOOL bFormated = FALSE; CFX_WideString sValue = this->OnFormat(pFormField, 0, bFormated); if (bFormated) - this->ResetFieldAppearance(pFormField, sValue, TRUE); + this->ResetFieldAppearance(pFormField, sValue.c_str(), TRUE); else this->ResetFieldAppearance(pFormField, NULL, TRUE); this->UpdateField(pFormField); diff --git a/fpdfsdk/src/fxedit/fxet_edit.cpp b/fpdfsdk/src/fxedit/fxet_edit.cpp index c7f7ce5b04..0015c0f4ed 100644 --- a/fpdfsdk/src/fxedit/fxet_edit.cpp +++ b/fpdfsdk/src/fxedit/fxet_edit.cpp @@ -745,7 +745,7 @@ void CFXEU_Clear::Undo() { m_pEdit->SelectNone(); m_pEdit->SetCaret(m_wrSel.BeginPos); - m_pEdit->InsertText(m_swText, DEFAULT_CHARSET, NULL,NULL,FALSE,TRUE); + m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, NULL, NULL, FALSE, TRUE); m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos); } } @@ -833,7 +833,7 @@ void CFXEU_InsertText::Redo() { m_pEdit->SelectNone(); m_pEdit->SetCaret(m_wpOld); - m_pEdit->InsertText(m_swText, m_nCharset,&m_SecProps, &m_WordProps,FALSE,TRUE); + m_pEdit->InsertText(m_swText.c_str(), m_nCharset, &m_SecProps, &m_WordProps, FALSE, TRUE); } } diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index 624cad7eb2..be568e10cc 100644 --- a/fpdfsdk/src/javascript/Document.cpp +++ b/fpdfsdk/src/javascript/Document.cpp @@ -370,7 +370,7 @@ FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& param if (!pField) return FALSE; - vRet = pField->GetFullName(); + vRet = pField->GetFullName().c_str(); return TRUE; } @@ -878,15 +878,15 @@ FX_BOOL Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, -1); - JS_PutObjectString(isolate,pObj, L"Author", cwAuthor); - JS_PutObjectString(isolate,pObj, L"Title", cwTitle); - JS_PutObjectString(isolate,pObj, L"Subject", cwSubject); - JS_PutObjectString(isolate,pObj, L"Keywords", cwKeywords); - JS_PutObjectString(isolate,pObj, L"Creator", cwCreator); - JS_PutObjectString(isolate,pObj, L"Producer", cwProducer); - JS_PutObjectString(isolate,pObj, L"CreationDate", cwCreationDate); - JS_PutObjectString(isolate,pObj, L"ModDate", cwModDate); - JS_PutObjectString(isolate,pObj, L"Trapped", cwTrapped); + JS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str()); + JS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str()); + JS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str()); + JS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str()); + JS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str()); + JS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str()); + JS_PutObjectString(isolate, pObj, L"CreationDate", cwCreationDate.c_str()); + JS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str()); + JS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str()); // It's to be compatible to non-standard info dictionary. FX_POSITION pos = pDictionary->GetStartPos(); @@ -896,11 +896,11 @@ FX_BOOL Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr CPDF_Object* pValueObj = pDictionary->GetNextElement(pos, bsKey); CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLength()); if((pValueObj->GetType()==PDFOBJ_STRING) || (pValueObj->GetType()==PDFOBJ_NAME) ) - JS_PutObjectString(isolate,pObj, wsKey, pValueObj->GetUnicodeText()); + JS_PutObjectString(isolate, pObj, wsKey.c_str(), pValueObj->GetUnicodeText().c_str()); if(pValueObj->GetType()==PDFOBJ_NUMBER) - JS_PutObjectNumber(isolate,pObj, wsKey, (float)pValueObj->GetNumber()); + JS_PutObjectNumber(isolate,pObj, wsKey.c_str(), (float)pValueObj->GetNumber()); if(pValueObj->GetType()==PDFOBJ_BOOLEAN) - JS_PutObjectBoolean(isolate,pObj, wsKey, (bool)pValueObj->GetInteger()); + JS_PutObjectBoolean(isolate,pObj, wsKey.c_str(), (bool)pValueObj->GetInteger()); } vp << pObj; @@ -1672,7 +1672,7 @@ FX_BOOL Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params swRet.TrimRight(); } - vRet = swRet; + vRet = swRet.c_str(); return TRUE; } diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp index e5572da3e6..7476fa5728 100644 --- a/fpdfsdk/src/javascript/Field.cpp +++ b/fpdfsdk/src/javascript/Field.cpp @@ -11,7 +11,6 @@ #include "../../include/javascript/JS_Value.h" #include "../../include/javascript/Field.h" #include "../../include/javascript/JS_EventHandler.h" -//#include "../include/JS_ResMgr.h" #include "../../include/javascript/JS_Context.h" #include "../../include/javascript/JS_Runtime.h" #include "../../include/javascript/Document.h" @@ -259,7 +258,7 @@ void Field::UpdateFormField(CPDFSDK_Document* pDocument, CPDF_FormField* pFormFi FX_BOOL bFormated = FALSE; CFX_WideString sValue = pWidget->OnFormat(0, bFormated); if (bFormated) - pWidget->ResetAppearance(sValue, FALSE); + pWidget->ResetAppearance(sValue.c_str(), FALSE); else pWidget->ResetAppearance(NULL, FALSE); } @@ -316,7 +315,7 @@ void Field::UpdateFormControl(CPDFSDK_Document* pDocument, CPDF_FormControl* pFo FX_BOOL bFormated = FALSE; CFX_WideString sValue = pWidget->OnFormat(0, bFormated); if (bFormated) - pWidget->ResetAppearance(sValue, FALSE); + pWidget->ResetAppearance(sValue.c_str(), FALSE); else pWidget->ResetAppearance(NULL, FALSE); } @@ -3127,7 +3126,7 @@ FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro double dRet; FX_BOOL bDot; - if (CJS_PublicMethods::ConvertStringToNumber(swValue,dRet,bDot)) + if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot)) { if (bDot) vp << dRet; @@ -3148,9 +3147,9 @@ FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { iIndex = pFormField->GetSelectedIndex(i); - ElementValue = pFormField->GetOptionValue(iIndex); + ElementValue = pFormField->GetOptionValue(iIndex).c_str(); if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0) - ElementValue = pFormField->GetOptionLabel(iIndex); + ElementValue = pFormField->GetOptionLabel(iIndex).c_str(); ValueArray.SetElement(i, ElementValue); } vp << ValueArray; @@ -3161,7 +3160,7 @@ FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro double dRet; FX_BOOL bDot; - if (CJS_PublicMethods::ConvertStringToNumber(swValue,dRet,bDot)) + if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot)) { if (bDot) vp << dRet; @@ -3182,10 +3181,9 @@ FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro if (pFormField->GetControl(i)->IsChecked()) { CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue(); - double dRet; FX_BOOL bDot; - if (CJS_PublicMethods::ConvertStringToNumber(swValue,dRet,bDot)) + if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot)) { if (bDot) vp << dRet; @@ -3391,11 +3389,11 @@ FX_BOOL Field::buttonGetCaption(IFXJS_Context* cc, const CJS_Parameters& params, if (!pFormControl)return FALSE; if (nface == 0) - vRet = pFormControl->GetNormalCaption(); + vRet = pFormControl->GetNormalCaption().c_str(); else if (nface == 1) - vRet = pFormControl->GetDownCaption(); + vRet = pFormControl->GetDownCaption().c_str(); else if (nface == 2) - vRet = pFormControl->GetRolloverCaption(); + vRet = pFormControl->GetRolloverCaption().c_str(); else return FALSE; @@ -3685,12 +3683,12 @@ FX_BOOL Field::getItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va { CFX_WideString strval = pFormField->GetOptionValue(nIdx); if (strval.IsEmpty()) - vRet = pFormField->GetOptionLabel(nIdx); + vRet = pFormField->GetOptionLabel(nIdx).c_str(); else - vRet = strval; + vRet = strval.c_str(); } else - vRet = pFormField->GetOptionLabel(nIdx); + vRet = pFormField->GetOptionLabel(nIdx).c_str(); } else return FALSE; diff --git a/fpdfsdk/src/javascript/JS_Context.cpp b/fpdfsdk/src/javascript/JS_Context.cpp index bdcb1ac542..277abc08e5 100644 --- a/fpdfsdk/src/javascript/JS_Context.cpp +++ b/fpdfsdk/src/javascript/JS_Context.cpp @@ -72,11 +72,11 @@ FX_BOOL CJS_Context::DoJob(int nMode, const CFX_WideString& script, CFX_WideStri { if (nMode == 0) { - nRet = JS_Execute(*m_pRuntime, this, script, script.GetLength(), &error); + nRet = JS_Execute(*m_pRuntime, this, script.c_str(), script.GetLength(), &error); } else { - nRet = JS_Parse(*m_pRuntime, this, script, script.GetLength(), &error); + nRet = JS_Parse(*m_pRuntime, this, script.c_str(), script.GetLength(), &error); } } diff --git a/fpdfsdk/src/javascript/JS_GlobalData.cpp b/fpdfsdk/src/javascript/JS_GlobalData.cpp index 83771dfe57..b4e4a5b108 100644 --- a/fpdfsdk/src/javascript/JS_GlobalData.cpp +++ b/fpdfsdk/src/javascript/JS_GlobalData.cpp @@ -353,8 +353,7 @@ void CJS_GlobalData::LoadGlobalPersistentVariables() FX_LPBYTE pBuffer = NULL; FX_INT32 nLength = 0; - LoadFileBuffer(m_sFilePath, pBuffer, nLength); - + LoadFileBuffer(m_sFilePath.c_str(), pBuffer, nLength); CRYPT_ArcFourCryptBlock(pBuffer, nLength, JS_RC4KEY, sizeof(JS_RC4KEY)); if (pBuffer) @@ -509,7 +508,7 @@ void CJS_GlobalData::SaveGlobalPersisitentVariables() sFile.AppendBlock(sData.GetBuffer(), sData.GetSize()); CRYPT_ArcFourCryptBlock(sFile.GetBuffer(), sFile.GetSize(), JS_RC4KEY, sizeof(JS_RC4KEY)); - WriteFileBuffer(m_sFilePath, (FX_LPCSTR)sFile.GetBuffer(), sFile.GetSize()); + WriteFileBuffer(m_sFilePath.c_str(), (FX_LPCSTR)sFile.GetBuffer(), sFile.GetSize()); } void CJS_GlobalData::LoadFileBuffer(FX_LPCWSTR sFilePath, FX_LPBYTE& pBuffer, FX_INT32& nLength) diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp index be374895e4..1b36f314ca 100644 --- a/fpdfsdk/src/javascript/JS_Value.cpp +++ b/fpdfsdk/src/javascript/JS_Value.cpp @@ -216,7 +216,7 @@ void CJS_Value::SetNull() void CJS_Value::operator = (FX_LPCSTR pStr) { - operator = (CFX_WideString::FromLocal(pStr)); + operator = (CFX_WideString::FromLocal(pStr).c_str()); } void CJS_Value::operator = (CJS_Array & array) @@ -433,7 +433,7 @@ void CJS_PropValue::operator >>(CFX_WideString &wide_string) const void CJS_PropValue::operator <<(CFX_WideString wide_string) { ASSERT(!m_bIsSetting); - CJS_Value::operator = (wide_string); + CJS_Value::operator = (wide_string.c_str()); } void CJS_PropValue::operator >>(CJS_Array &array) const diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp index 6a9839ebf5..539d7c780a 100644 --- a/fpdfsdk/src/javascript/PublicMethods.cpp +++ b/fpdfsdk/src/javascript/PublicMethods.cpp @@ -104,7 +104,7 @@ static FX_LPCWSTR fullmonths[] = FX_BOOL CJS_PublicMethods::IsNumber(FX_LPCWSTR string) { CFX_WideString sTrim = StrTrim(string); - FX_LPCWSTR pTrim = sTrim; + FX_LPCWSTR pTrim = sTrim.c_str(); FX_LPCWSTR p = pTrim; @@ -231,7 +231,7 @@ CFX_WideString CJS_PublicMethods::StrRTrim(FX_LPCWSTR pStr) CFX_WideString CJS_PublicMethods::StrTrim(FX_LPCWSTR pStr) { - return StrRTrim(StrLTrim(pStr)); + return StrRTrim(StrLTrim(pStr).c_str()); } CFX_ByteString CJS_PublicMethods::StrLTrim(FX_LPCSTR pStr) @@ -591,7 +591,7 @@ double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, FX_BOOL& CFX_WideString swTemp; swTemp.Format(L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,nMin,nSec); - return JS_DateParse(swTemp); + return JS_DateParse(swTemp.c_str()); } double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CFX_WideString & format, FX_BOOL& bWrongFormat) @@ -796,7 +796,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF CFX_WideString sFullMonths = fullmonths[m]; sFullMonths.MakeLower(); - if (sFullMonths.Find(sMonth, 0) != -1) + if (sFullMonths.Find(sMonth.c_str(), 0) != -1) { nMonth = m + 1; i += 4; @@ -888,7 +888,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF if (JS_PortIsNan(dRet)) { - dRet = JS_DateParse(value); + dRet = JS_DateParse(value.c_str()); } } @@ -1075,7 +1075,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Paramete int iSepStyle = params[1].ToInt(); int iNegStyle = params[2].ToInt(); // params[3] is iCurrStyle, it's not used. - std::wstring wstrCurrency(params[4].ToCFXWideString()); + std::wstring wstrCurrency(params[4].ToCFXWideString().c_str()); FX_BOOL bCurrencyPrepend = params[5].ToBool(); if (iDec < 0) iDec = -iDec; @@ -1169,8 +1169,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Paramete //for processing currency string Value = CFX_WideString::FromLocal(strValue); - - std::wstring strValue2(Value); + std::wstring strValue2 = Value.c_str(); if (bCurrencyPrepend) strValue2 = wstrCurrency + strValue2; @@ -1281,25 +1280,24 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param if (pEvent->WillCommit()) { CFX_WideString wstrChange = w_strChange; - CFX_WideString wstrValue = StrLTrim(w_strValue); + CFX_WideString wstrValue = StrLTrim(w_strValue.c_str()); if (wstrValue.IsEmpty()) return TRUE; CFX_WideString swTemp = wstrValue; swTemp.Replace(L",", L"."); - if (!IsNumber(swTemp)) //!(IsNumber(wstrChange) && + if (!IsNumber(swTemp.c_str())) { pEvent->Rc() = FALSE; sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); - Alert(pContext, sError); + Alert(pContext, sError.c_str()); return TRUE; } return TRUE; // it happens after the last keystroke and before validating, } - - std::wstring w_strValue2 (w_strValue); - std::wstring w_strChange2(w_strChange); - + + std::wstring w_strValue2 = w_strValue.c_str(); + std::wstring w_strChange2 = w_strChange.c_str(); std::wstring w_strSelected; if(-1 != pEvent->SelStart()) w_strSelected = w_strValue2.substr(pEvent->SelStart(),(pEvent->SelEnd() - pEvent->SelStart())); @@ -1544,8 +1542,8 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Paramete if (JS_PortIsNan(dDate)) { CFX_WideString swMsg; - swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), sFormat.c_str()); - Alert(pContext, swMsg); + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str()); + Alert(pContext, swMsg.c_str()); return FALSE; } @@ -1597,17 +1595,17 @@ double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue) if(sTemp.Compare(L"Nov") == 0) nMonth = 11; if(sTemp.Compare(L"Dec") == 0) nMonth = 12; - nDay = (int)ParseStringToNumber(wsArray[2]); - nHour = (int)ParseStringToNumber(wsArray[3]); - nMin = (int)ParseStringToNumber(wsArray[4]); - nSec = (int)ParseStringToNumber(wsArray[5]); - nYear = (int)ParseStringToNumber(wsArray[7]); + nDay = (int)ParseStringToNumber(wsArray[2].c_str()); + nHour = (int)ParseStringToNumber(wsArray[3].c_str()); + nMin = (int)ParseStringToNumber(wsArray[4].c_str()); + nSec = (int)ParseStringToNumber(wsArray[5].c_str()); + nYear = (int)ParseStringToNumber(wsArray[7].c_str()); double dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime(nHour, nMin, nSec, 0)); if (JS_PortIsNan(dRet)) { - dRet = JS_DateParse(strValue); + dRet = JS_DateParse(strValue.c_str()); } return dRet; @@ -1641,8 +1639,8 @@ FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Param if (bWrongFormat || JS_PortIsNan(dRet)) { CFX_WideString swMsg; - swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), sFormat.c_str()); - Alert(pContext, swMsg); + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str()); + Alert(pContext, swMsg.c_str()); pEvent->Rc() = FALSE; return TRUE; } @@ -1851,7 +1849,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa if (wstrMask.IsEmpty()) return TRUE; - std::wstring wstrValue(valEvent); + std::wstring wstrValue = valEvent.c_str(); if (pEvent->WillCommit()) { @@ -1868,14 +1866,14 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa if (iIndexMask != wstrMask.GetLength() || (iIndexMask != wstrValue.size() && wstrMask.GetLength() != 0)) { - Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE)); + Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str()); pEvent->Rc() = FALSE; } return TRUE; } CFX_WideString &wideChange = pEvent->Change(); - std::wstring wChange(wideChange); + std::wstring wChange = wideChange.c_str(); if (wChange.empty()) return TRUE; @@ -1883,14 +1881,14 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange.length() > (FX_DWORD)wstrMask.GetLength()) { - Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG)); + Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str()); pEvent->Rc() = FALSE; return TRUE; } if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty())) { - Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG)); + Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str()); pEvent->Rc() = FALSE; return TRUE; } @@ -1899,7 +1897,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa { if (iIndexMask >= wstrMask.GetLength()) { - Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG)); + Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str()); pEvent->Rc() = FALSE; return TRUE; } @@ -1946,8 +1944,8 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Para //CJS_Value val = pEvent->Value(); CFX_WideString& val = pEvent->Value(); std::string strSrc = CFX_ByteString::FromUnicode(val).c_str(); - std::wstring wstrChange(pEvent->Change()); - + std::wstring wstrChange = pEvent->Change().c_str(); + switch (iIndex) { case 0: @@ -2001,7 +1999,7 @@ FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters if (pEventHandler->WillCommit()) { - vRet = swValue; + vRet = swValue.c_str(); return TRUE; } @@ -2017,7 +2015,7 @@ FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters postfix = swValue.Mid(pEventHandler->SelEnd(), swValue.GetLength() - pEventHandler->SelEnd()); else postfix = L""; - vRet = prefix + pEventHandler->Change() + postfix; + vRet = (prefix + pEventHandler->Change() + postfix).c_str(); return TRUE; } @@ -2042,8 +2040,8 @@ FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters if (JS_PortIsNan(dDate)) { CFX_WideString swMsg; - swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), sFormat.c_str()); - Alert((CJS_Context *)cc, swMsg); + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str()); + Alert((CJS_Context *)cc, swMsg.c_str()); return FALSE; } @@ -2062,7 +2060,7 @@ FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& par return FALSE; } - vRet = (double)AF_Simple(params[0].ToCFXWideString(), params[1].ToDouble(), params[2].ToDouble()); + vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), params[1].ToDouble(), params[2].ToDouble()); return TRUE; } @@ -2076,7 +2074,7 @@ FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters& sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); return FALSE; } - vRet = ParseStringToNumber(params[0].ToCFXWideString()); + vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str()); return TRUE; } @@ -2112,7 +2110,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param double dValue; CFX_WideString sFunction = params[0].ToCFXWideString(); - if (wcscmp(sFunction, L"PRD") == 0) + if (wcscmp(sFunction.c_str(), L"PRD") == 0) dValue = 1.0; else dValue = 0.0; @@ -2138,7 +2136,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param case FIELDTYPE_TEXTFIELD: case FIELDTYPE_COMBOBOX: { - dTemp = ParseStringToNumber(pFormField->GetValue()); + dTemp = ParseStringToNumber(pFormField->GetValue().c_str()); break; } case FIELDTYPE_PUSHBUTTON: @@ -2156,7 +2154,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param { if (pFormCtrl->IsChecked()) { - dTemp += ParseStringToNumber(pFormCtrl->GetExportValue()); + dTemp += ParseStringToNumber(pFormCtrl->GetExportValue().c_str()); break; } else @@ -2172,7 +2170,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param break; else { - dTemp = ParseStringToNumber(pFormField->GetValue()); + dTemp = ParseStringToNumber(pFormField->GetValue().c_str()); break; } } @@ -2180,17 +2178,17 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param break; } - if (i == 0 && j == 0 && (wcscmp(sFunction,L"MIN") == 0 || wcscmp(sFunction, L"MAX") == 0)) + if (i == 0 && j == 0 && (wcscmp(sFunction.c_str(), L"MIN") == 0 || wcscmp(sFunction.c_str(), L"MAX") == 0)) dValue = dTemp; - dValue = AF_Simple(sFunction, dValue, dTemp); + dValue = AF_Simple(sFunction.c_str(), dValue, dTemp); nFieldsCount++; } } } - if (wcscmp(sFunction, L"AVG") == 0 && nFieldsCount > 0) + if (wcscmp(sFunction.c_str(), L"AVG") == 0 && nFieldsCount > 0) dValue /= nFieldsCount; dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49) / FXSYS_pow((double)10,(double)6); @@ -2231,26 +2229,26 @@ FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Paramet if (bGreaterThan && bLessThan) { if (dEentValue < dGreaterThan || dEentValue > dLessThan) - swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE1), + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE1).c_str(), params[1].ToCFXWideString().c_str(), params[3].ToCFXWideString().c_str()); } else if (bGreaterThan) { if (dEentValue < dGreaterThan) - swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE2), + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE2).c_str(), params[1].ToCFXWideString().c_str()); } else if (bLessThan) { if (dEentValue > dLessThan) - swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE3), + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE3).c_str(), params[3].ToCFXWideString().c_str()); } if (!swMsg.IsEmpty()) { - Alert(pContext, swMsg); + Alert(pContext, swMsg.c_str()); pEvent->Rc() = FALSE; } return TRUE; diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp index 2cb7f67f27..552d26854d 100644 --- a/fpdfsdk/src/javascript/app.cpp +++ b/fpdfsdk/src/javascript/app.cpp @@ -416,7 +416,7 @@ FX_BOOL app::alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& v CJS_Runtime* pRuntime = pContext->GetJSRuntime(); ASSERT(pRuntime != NULL); pRuntime->BeginBlock(); - vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc),swMsg,swTitle,iType,iIcon); + vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc), swMsg.c_str(), swTitle.c_str(), iType, iIcon); pRuntime->EndBlock(); return TRUE; @@ -455,24 +455,21 @@ FX_BOOL app::fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) FX_BOOL app::setInterval(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { + CJS_Context* pContext = (CJS_Context*)cc; if (params.size() > 2 || params.size() == 0) { - sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); + sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); return FALSE; } - CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); - CJS_Runtime* pRuntime = pContext->GetJSRuntime(); - ASSERT(pRuntime != NULL); - - CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCFXWideString()) : L""; + CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString() : L""; if (script.IsEmpty()) { - sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMBER_KEYSTROKE); + sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); return TRUE; } + CJS_Runtime* pRuntime = pContext->GetJSRuntime(); FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); @@ -515,7 +512,7 @@ FX_BOOL app::setTimeOut(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val CJS_Runtime* pRuntime = pContext->GetJSRuntime(); ASSERT(pRuntime != NULL); - CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCFXWideString()) : L""; + CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString() : L""; if (script.IsEmpty()) { sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMBER_KEYSTROKE); @@ -903,7 +900,8 @@ FX_BOOL app::response(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value return FALSE; memset(pBuff, 0, MAX_INPUT_BYTES + 2); - int nLengthBytes = pApp->JS_appResponse(swQuestion, swTitle, swDefault, swLabel, bPassWord, pBuff, MAX_INPUT_BYTES); + int nLengthBytes = pApp->JS_appResponse(swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), + swLabel.c_str(), bPassWord, pBuff, MAX_INPUT_BYTES); if (nLengthBytes <= 0) { vRet.SetNull(); @@ -913,7 +911,7 @@ FX_BOOL app::response(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value if (nLengthBytes > MAX_INPUT_BYTES) nLengthBytes = MAX_INPUT_BYTES; - vRet = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLengthBytes / sizeof(unsigned short)); + vRet = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLengthBytes / sizeof(unsigned short)).c_str(); delete[] pBuff; return TRUE; } diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp index c3d11b0a84..418508f89e 100644 --- a/fpdfsdk/src/javascript/global.cpp +++ b/fpdfsdk/src/javascript/global.cpp @@ -297,18 +297,18 @@ void global_alternate::UpdateGlobalPersistentVariables() case JS_GLOBALDATA_TYPE_NUMBER: this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NUMBER, pData->data.dData, false, "", v8::Handle(), pData->bPersistent == 1); JS_PutObjectNumber(NULL,(JSFXObject)(*m_pJSObject), - pData->data.sKey.UTF8Decode(), pData->data.dData); + pData->data.sKey.UTF8Decode().c_str(), pData->data.dData); break; case JS_GLOBALDATA_TYPE_BOOLEAN: this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_BOOLEAN, 0, (bool)(pData->data.bData == 1), "", v8::Handle(), pData->bPersistent == 1); JS_PutObjectBoolean(NULL,(JSFXObject)(*m_pJSObject), - pData->data.sKey.UTF8Decode(), (bool)(pData->data.bData == 1)); + pData->data.sKey.UTF8Decode().c_str(), (bool)(pData->data.bData == 1)); break; case JS_GLOBALDATA_TYPE_STRING: this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_STRING, 0, false, pData->data.sData, v8::Handle(), pData->bPersistent == 1); - JS_PutObjectString(NULL,(JSFXObject)(*m_pJSObject), - pData->data.sKey.UTF8Decode(), - pData->data.sData.UTF8Decode()); + JS_PutObjectString(NULL, (JSFXObject)(*m_pJSObject), + pData->data.sKey.UTF8Decode().c_str(), + pData->data.sData.UTF8Decode().c_str()); break; case JS_GLOBALDATA_TYPE_OBJECT: { @@ -320,13 +320,13 @@ void global_alternate::UpdateGlobalPersistentVariables() this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_OBJECT, 0, false, "", (JSObject)pObj, pData->bPersistent == 1); JS_PutObjectObject(NULL,(JSFXObject)(*m_pJSObject), - pData->data.sKey.UTF8Decode(), (JSObject)pObj); + pData->data.sKey.UTF8Decode().c_str(), (JSObject)pObj); } break; case JS_GLOBALDATA_TYPE_NULL: this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Handle(), pData->bPersistent == 1); JS_PutObjectNull(NULL,(JSFXObject)(*m_pJSObject), - pData->data.sKey.UTF8Decode()); + pData->data.sKey.UTF8Decode().c_str()); break; } } @@ -466,24 +466,24 @@ void global_alternate::PutObjectProperty(v8::Handle pObj, CJS_KeyVal switch (pObjData->nType) { case JS_GLOBALDATA_TYPE_NUMBER: - JS_PutObjectNumber(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode(), pObjData->dData); + JS_PutObjectNumber(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), pObjData->dData); break; case JS_GLOBALDATA_TYPE_BOOLEAN: - JS_PutObjectBoolean(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode(), (bool)(pObjData->bData == 1)); + JS_PutObjectBoolean(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), (bool)(pObjData->bData == 1)); break; case JS_GLOBALDATA_TYPE_STRING: - JS_PutObjectString(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode(), pObjData->sData.UTF8Decode()); + JS_PutObjectString(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), pObjData->sData.UTF8Decode().c_str()); break; case JS_GLOBALDATA_TYPE_OBJECT: { IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject)); v8::Handle pNewObj = JS_NewFxDynamicObj(pRuntime, NULL, -1); PutObjectProperty(pNewObj, pObjData); - JS_PutObjectObject(NULL, (JSObject)pObj, pObjData->sKey.UTF8Decode(), (JSObject)pNewObj); + JS_PutObjectObject(NULL, (JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), (JSObject)pNewObj); } break; case JS_GLOBALDATA_TYPE_NULL: - JS_PutObjectNull(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode()); + JS_PutObjectNull(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str()); break; } } diff --git a/fpdfsdk/src/javascript/util.cpp b/fpdfsdk/src/javascript/util.cpp index f7e97acb1f..26c59a32ad 100644 --- a/fpdfsdk/src/javascript/util.cpp +++ b/fpdfsdk/src/javascript/util.cpp @@ -265,7 +265,7 @@ FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& return FALSE; } - vRet = swResult; + vRet = swResult.c_str(); return TRUE; } else if (p1.GetType() == VT_string) @@ -288,9 +288,9 @@ FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& { int iStart = 0; int iEnd; - while((iEnd = cFormat.find((CFX_WideString)fcTable[iIndex].lpszJSMark, iStart)) != -1) + while((iEnd = cFormat.find(fcTable[iIndex].lpszJSMark, iStart)) != -1) { - cFormat.replace(iEnd, FXSYS_wcslen(fcTable[iIndex].lpszJSMark), (CFX_WideString)fcTable[iIndex].lpszCppMark); + cFormat.replace(iEnd, FXSYS_wcslen(fcTable[iIndex].lpszJSMark), fcTable[iIndex].lpszCppMark); iStart = iEnd; } } @@ -342,7 +342,7 @@ FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& //strFormat.Format(strFormat,cTableAd[iIndex].iValue); int iStart = 0; int iEnd; - while((iEnd = cFormat.find((CFX_WideString)cTableAd[iIndex].lpszJSMark,iStart)) != -1) + while((iEnd = cFormat.find(cTableAd[iIndex].lpszJSMark, iStart)) != -1) { if (iEnd > 0) { @@ -384,9 +384,9 @@ void util::printd(const std::wstring &cFormat2, CJS_Date jsDate, bool bXFAPictur { int iStart = 0; int iEnd; - while((iEnd = cFormat.find((CFX_WideString)fcTable[iIndex].lpszJSMark,iStart)) != -1) + while((iEnd = cFormat.find(fcTable[iIndex].lpszJSMark, iStart)) != -1) { - cFormat.replace(iEnd,FXSYS_wcslen(fcTable[iIndex].lpszJSMark), (CFX_WideString)fcTable[iIndex].lpszCppMark); + cFormat.replace(iEnd,FXSYS_wcslen(fcTable[iIndex].lpszJSMark), fcTable[iIndex].lpszCppMark); iStart = iEnd; } } @@ -438,7 +438,7 @@ void util::printd(const std::wstring &cFormat2, CJS_Date jsDate, bool bXFAPictur //strFormat.Format(strFormat,cTableAd[iIndex].iValue); int iStart = 0; int iEnd; - while((iEnd = cFormat.find((CFX_WideString)cTableAd[iIndex].lpszJSMark,iStart)) != -1) + while((iEnd = cFormat.find(cTableAd[iIndex].lpszJSMark, iStart)) != -1) { if (iEnd > 0) { @@ -640,6 +640,6 @@ FX_BOOL util::byteToChar(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va unsigned char cByte = (unsigned char)nByte; CFX_WideString csValue; csValue.Format(L"%c", cByte); - vRet = csValue; + vRet = csValue.c_str(); return TRUE; } diff --git a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp index 01810ffd7a..6627189bd7 100644 --- a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp @@ -266,7 +266,7 @@ void CPWL_ComboBox::SetSelect(FX_INT32 nItemIndex) if (m_pList) m_pList->Select(nItemIndex); - m_pEdit->SetText(m_pList->GetText()); + m_pEdit->SetText(m_pList->GetText().c_str()); m_nSelectItem = nItemIndex; } @@ -638,7 +638,7 @@ void CPWL_ComboBox::SetSelectText() { CFX_WideString swText = m_pList->GetText(); m_pEdit->SelectAll(); - m_pEdit->ReplaceSel(m_pList->GetText()); + m_pEdit->ReplaceSel(m_pList->GetText().c_str()); m_pEdit->SelectAll(); m_nSelectItem = m_pList->GetCurSel(); diff --git a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp index 1cbbf9a17e..f704a67731 100644 --- a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp @@ -78,7 +78,7 @@ void CPWL_Edit::SetText(FX_LPCWSTR csText) } } - m_pEdit->SetText(swText); + m_pEdit->SetText(swText.c_str()); } void CPWL_Edit::RePosChildWnd() @@ -192,7 +192,7 @@ void CPWL_Edit::PasteText() if (swClipboard.GetLength() > 0) { Clear(); - InsertText(swClipboard); + InsertText(swClipboard.c_str()); } if (m_pFillerNotify) @@ -682,23 +682,23 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag) break; case WM_PWLEDIT_SUGGEST + 0: SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); - ReplaceSel(sSuggestWords[0].UTF8Decode()); + ReplaceSel(sSuggestWords[0].UTF8Decode().c_str()); break; case WM_PWLEDIT_SUGGEST + 1: SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); - ReplaceSel(sSuggestWords[1].UTF8Decode()); + ReplaceSel(sSuggestWords[1].UTF8Decode().c_str()); break; case WM_PWLEDIT_SUGGEST + 2: SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); - ReplaceSel(sSuggestWords[2].UTF8Decode()); + ReplaceSel(sSuggestWords[2].UTF8Decode().c_str()); break; case WM_PWLEDIT_SUGGEST + 3: SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); - ReplaceSel(sSuggestWords[3].UTF8Decode()); + ReplaceSel(sSuggestWords[3].UTF8Decode().c_str()); break; - case WM_PWLEDIT_SUGGEST + 4: + case WM_PWLEDIT_SUGGEST + 4: SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); - ReplaceSel(sSuggestWords[4].UTF8Decode()); + ReplaceSel(sSuggestWords[4].UTF8Decode().c_str()); break; default: break; diff --git a/fpdfsdk/src/pdfwindow/PWL_IconList.cpp b/fpdfsdk/src/pdfwindow/PWL_IconList.cpp index 1d58a90111..990f8b893f 100644 --- a/fpdfsdk/src/pdfwindow/PWL_IconList.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_IconList.cpp @@ -107,7 +107,7 @@ void CPWL_IconList_Item::SetIcon(FX_INT32 nIconIndex) void CPWL_IconList_Item::SetText(const CFX_WideString& str) { - m_pText->SetText(str); + m_pText->SetText(str.c_str()); } CFX_WideString CPWL_IconList_Item::GetText() const diff --git a/fpdfsdk/src/pdfwindow/PWL_Note.cpp b/fpdfsdk/src/pdfwindow/PWL_Note.cpp index 7bc8fad395..33d1b3b009 100644 --- a/fpdfsdk/src/pdfwindow/PWL_Note.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_Note.cpp @@ -82,7 +82,7 @@ void CPWL_Note_Options::CreateChildWnd(const PWL_CREATEPARAM & cp) void CPWL_Note_Options::SetText(const CFX_WideString& sText) { - m_pText->SetText(sText); + m_pText->SetText(sText.c_str()); } void CPWL_Note_Options::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device) @@ -443,9 +443,9 @@ void CPWL_Note_Contents::SetText(const CFX_WideString& sText) if (m_pEdit) { m_pEdit->EnableNotify(FALSE); - m_pEdit->SetText(sText); + m_pEdit->SetText(sText.c_str()); m_pEdit->EnableNotify(TRUE); - OnNotify(m_pEdit, PNM_NOTEEDITCHANGED, 0, 0); + OnNotify(m_pEdit, PNM_NOTEEDITCHANGED, 0, 0); } } @@ -811,7 +811,7 @@ void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName) { if (m_pSubject) { - m_pSubject->SetText(sName); + m_pSubject->SetText(sName.c_str()); } if (IPWL_NoteNotify* pNotify = GetNoteNotify()) @@ -848,11 +848,10 @@ void CPWL_NoteItem::ResetSubjectName(FX_INT32 nItemIndex) ASSERT(pNote != NULL); CFX_WideString sSubject; - sSubject.Format(pNote->GetReplyString(), nItemIndex); + sSubject.Format(pNote->GetReplyString().c_str(), nItemIndex); if (!m_sAuthor.IsEmpty()) { - sSubject += L" - "; sSubject += m_sAuthor; } @@ -863,12 +862,12 @@ void CPWL_NoteItem::ResetSubjectName(FX_INT32 nItemIndex) void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time) { m_dtNote = time; - + CFX_WideString swTime; swTime.Format(L"%04d-%02d-%02d %02d:%02d:%02d", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond); if (m_pDateTime) { - m_pDateTime->SetText(swTime); + m_pDateTime->SetText(swTime.c_str()); } this->RePosChildWnd(); @@ -1528,14 +1527,14 @@ void CPWL_Note::SetAuthorName(const CFX_WideString& sName) { if (m_pAuthor) { - m_pAuthor->SetText(sName); + m_pAuthor->SetText(sName.c_str()); RePosChildWnd(); } if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { pNotify->OnSetAuthorName(this); - } + } } CFX_WideString CPWL_Note::GetAuthorName() const diff --git a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp index 1de6b56d5e..b57f8e019d 100644 --- a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp @@ -641,9 +641,8 @@ CFX_ByteString CPWL_Utils::GetTextAppStream(const CPDF_Rect & rcBBox,IFX_Edit_Fo CFX_ByteTextBuf sRet; if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) - { + { pEdit->SetFontMap(pFontMap); - pEdit->SetPlateRect(rcBBox); pEdit->SetAlignmentH(nAlignmentH); pEdit->SetAlignmentV(nAlignmentV); @@ -653,16 +652,15 @@ CFX_ByteString CPWL_Utils::GetTextAppStream(const CPDF_Rect & rcBBox,IFX_Edit_Fo pEdit->SetAutoFontSize(TRUE); else pEdit->SetFontSize(fFontSize); + pEdit->Initialize(); + pEdit->SetText(sText.c_str()); - pEdit->SetText(sText); - CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(0.0f,0.0f)); if (sEdit.GetLength() > 0) { sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"; } - IFX_Edit::DelEdit(pEdit); } @@ -681,9 +679,8 @@ CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CPDF_Rect & rcBBox, const FX_FLOAT fAutoFontScale = 1.0f / 3.0f; if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) - { + { pEdit->SetFontMap(pFontMap); - pEdit->SetAlignmentH(1); pEdit->SetAlignmentV(1); pEdit->SetMultiLine(FALSE); @@ -692,11 +689,11 @@ CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CPDF_Rect & rcBBox, pEdit->SetAutoFontSize(TRUE); else pEdit->SetFontSize(fFontSize); + pEdit->Initialize(); - pEdit->SetText(sLabel); + pEdit->SetText(sLabel.c_str()); CPDF_Rect rcLabelContent = pEdit->GetContentRect(); - CPWL_Icon Icon; PWL_CREATEPARAM cp; cp.dwFlags = PWS_VISIBLE; -- cgit v1.2.3