Revert "Fix else-after-returns throughout pdfium."
[pdfium.git] / fpdfsdk / src / pdfwindow / PWL_Edit.cpp
index dfdbf64..58d8a79 100644 (file)
@@ -1,21 +1,23 @@
 // Copyright 2014 PDFium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
+
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
+#include "../../../core/include/fxcrt/fx_safe_types.h"
+#include "../../../core/include/fxcrt/fx_xml.h"
 #include "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_EditCtrl.h"
+#include "../../include/pdfwindow/PWL_Caret.h"
 #include "../../include/pdfwindow/PWL_Edit.h"
+#include "../../include/pdfwindow/PWL_EditCtrl.h"
+#include "../../include/pdfwindow/PWL_FontMap.h"
 #include "../../include/pdfwindow/PWL_ScrollBar.h"
 #include "../../include/pdfwindow/PWL_Utils.h"
-#include "../../include/pdfwindow/PWL_Caret.h"
-#include "../../include/pdfwindow/PWL_FontMap.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
 
 /* ---------------------------- CPWL_Edit ------------------------------ */
 
-CPWL_Edit::CPWL_Edit() : m_pFillerNotify(NULL), 
+CPWL_Edit::CPWL_Edit() : m_pFillerNotify(NULL),
        m_pSpellCheck(NULL),
        m_bFocus(FALSE)
 {
@@ -36,22 +38,22 @@ void CPWL_Edit::OnDestroy()
 {
 }
 
-void CPWL_Edit::SetText(FX_LPCWSTR csText)
+void CPWL_Edit::SetText(const FX_WCHAR* csText)
 {
        CFX_WideString swText = csText;
 
        if (HasFlag(PES_RICH))
-       {               
+       {
                CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText);
-               
-               if (CXML_Element * pXML = CXML_Element::Parse((FX_LPCSTR)sValue,sValue.GetLength()))
+
+               if (CXML_Element * pXML = CXML_Element::Parse(sValue.c_str(), sValue.GetLength()))
                {
-                       FX_INT32 nCount = pXML->CountChildren();
+                       int32_t nCount = pXML->CountChildren();
                        FX_BOOL bFirst = TRUE;
 
                        swText.Empty();
 
-                       for (FX_INT32 i=0; i<nCount; i++)
+                       for (int32_t i=0; i<nCount; i++)
                        {
                                if (CXML_Element * pSubElement = pXML->GetElement(i))
                                {
@@ -60,11 +62,11 @@ void CPWL_Edit::SetText(FX_LPCWSTR csText)
                                        {
                                                int nChild = pSubElement->CountChildren();
                                                CFX_WideString swSection;
-                                               for(FX_INT32 j=0; j<nChild; j++)
+                                               for(int32_t j=0; j<nChild; j++)
                                                {
                                                        swSection += pSubElement->GetContent(j);
                                                }
-                                               
+
                                                if (bFirst)bFirst = FALSE;
                                                else
                                                        swText += FWL_VKEY_Return;
@@ -75,25 +77,21 @@ void CPWL_Edit::SetText(FX_LPCWSTR csText)
 
                        delete pXML;
                }
-       }       
+       }
 
-       m_pEdit->SetText(swText);
+       m_pEdit->SetText(swText.c_str());
 }
 
 void CPWL_Edit::RePosChildWnd()
 {
-       if (CPWL_ScrollBar * pVSB = this->GetVScrollBar())
-       {
-               //if (pVSB->IsVisible())
-               {
-                       CPDF_Rect rcWindow = m_rcOldWindow;             
-                       CPDF_Rect rcVScroll = CPDF_Rect(rcWindow.right,
-                                                               rcWindow.bottom,
-                                                               rcWindow.right + PWL_SCROLLBAR_WIDTH,
-                                                               rcWindow.top);
-                       pVSB->Move(rcVScroll, TRUE, FALSE);
-               }
-       }
+    if (CPWL_ScrollBar * pVSB = GetVScrollBar()) {
+        CPDF_Rect rcWindow = m_rcOldWindow;
+        CPDF_Rect rcVScroll = CPDF_Rect(rcWindow.right,
+                                        rcWindow.bottom,
+                                        rcWindow.right + PWL_SCROLLBAR_WIDTH,
+                                        rcWindow.top);
+        pVSB->Move(rcVScroll, TRUE, FALSE);
+    }
 
        if (m_pEditCaret && !HasFlag(PES_TEXTOVERFLOW))
                m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect(GetClientRect(),1.0f)); //+1 for caret beside border
@@ -104,8 +102,8 @@ void CPWL_Edit::RePosChildWnd()
 CPDF_Rect CPWL_Edit::GetClientRect() const
 {
        CPDF_Rect rcClient = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
-       
-       if (CPWL_ScrollBar * pVSB = this->GetVScrollBar())
+
+       if (CPWL_ScrollBar * pVSB = GetVScrollBar())
        {
                if (pVSB->IsVisible())
                {
@@ -118,12 +116,12 @@ CPDF_Rect CPWL_Edit::GetClientRect() const
 
 void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat, FX_BOOL bPaint/* = TRUE*/)
 {
-       m_pEdit->SetAlignmentH((FX_INT32)nFormat, bPaint);
+       m_pEdit->SetAlignmentH((int32_t)nFormat, bPaint);
 }
 
 void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat, FX_BOOL bPaint/* = TRUE*/)
 {
-       m_pEdit->SetAlignmentV((FX_INT32)nFormat, bPaint);
+       m_pEdit->SetAlignmentV((int32_t)nFormat, bPaint);
 }
 
 FX_BOOL        CPWL_Edit::CanSelectAll() const
@@ -191,7 +189,7 @@ void CPWL_Edit::PasteText()
        if (swClipboard.GetLength() > 0)
        {
                Clear();
-               InsertText(swClipboard);
+               InsertText(swClipboard.c_str());
        }
 
        if (m_pFillerNotify)
@@ -233,7 +231,7 @@ void CPWL_Edit::OnCreated()
 }
 
 void CPWL_Edit::SetParamByFlag()
-{      
+{
        if (HasFlag(PES_RIGHT))
        {
                m_pEdit->SetAlignmentH(2, FALSE);
@@ -297,7 +295,7 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
        CPDF_Rect rcClient = GetClientRect();
        CFX_ByteTextBuf sLine;
 
-       FX_INT32 nCharArray = m_pEdit->GetCharArray();
+       int32_t nCharArray = m_pEdit->GetCharArray();
 
        if (nCharArray > 0)
        {
@@ -305,40 +303,40 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
                {
                case PBS_SOLID:
                        {
-                               sLine << "q\n" << GetBorderWidth() << " w\n" 
-                                       << CPWL_Utils::GetColorAppStream(GetBorderColor(),FALSE) << " 2 J 0 j\n";                                       
+                               sLine << "q\n" << GetBorderWidth() << " w\n"
+                                       << CPWL_Utils::GetColorAppStream(GetBorderColor(),FALSE) << " 2 J 0 j\n";
 
-                               for (FX_INT32 i=1;i<nCharArray;i++)
+                               for (int32_t i=1;i<nCharArray;i++)
                                {
                                        sLine << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
                                                << rcClient.bottom << " m\n"
                                                << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
-                                               << rcClient.top << " l S\n";                                            
+                                               << rcClient.top << " l S\n";
                                }
 
-                               sLine << "Q\n";                                 
+                               sLine << "Q\n";
                        }
-                       break; 
+                       break;
                case PBS_DASH:
                        {
-                               sLine << "q\n" << GetBorderWidth() << " w\n" 
+                               sLine << "q\n" << GetBorderWidth() << " w\n"
                                        << CPWL_Utils::GetColorAppStream(GetBorderColor(),FALSE) << " 2 J 0 j\n"
-                                       << "[" << GetBorderDash().nDash << " " 
-                                       << GetBorderDash().nGap << "] " 
+                                       << "[" << GetBorderDash().nDash << " "
+                                       << GetBorderDash().nGap << "] "
                                        << GetBorderDash().nPhase << " d\n";
 
-                               for (FX_INT32 i=1;i<nCharArray;i++)                                     
+                               for (int32_t i=1;i<nCharArray;i++)
                                {
                                        sLine << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
                                                << rcClient.bottom << " m\n"
                                                << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
-                                               << rcClient.top << " l S\n";    
+                                               << rcClient.top << " l S\n";
                                }
 
                                sLine << "Q\n";
                        }
                        break;
-               }               
+               }
        }
 
        sAppStream << sLine;
@@ -361,22 +359,22 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
                sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR) << sEditSel ;
 
        wrTemp = CPWL_Utils::OverlapWordRange(wrVisible,wrSelBefore);
-       CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset,  
-                       &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar());                  
+       CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset,
+                       &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar());
 
        if (sEditBefore.GetLength() > 0)
                sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEditBefore << "ET\n";
 
        wrTemp = CPWL_Utils::OverlapWordRange(wrVisible,wrSelect);
-       CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset, 
-                       &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar());                  
+       CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset,
+                       &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar());
 
        if (sEditMid.GetLength() > 0)
                sText << "BT\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY,1)) << sEditMid << "ET\n";
 
        wrTemp = CPWL_Utils::OverlapWordRange(wrVisible,wrSelAfter);
-       CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset, 
-                       &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar());                  
+       CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset,
+                       &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar());
 
        if (sEditAfter.GetLength() > 0)
                sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEditAfter<< "ET\n";
@@ -390,9 +388,9 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
 
        if (sText.GetLength() > 0)
        {
-               CPDF_Rect rcClient = this->GetClientRect();
+               CPDF_Rect rcClient = GetClientRect();
                sAppStream << "q\n/Tx BMC\n";
-               
+
                if (!HasFlag(PES_TEXTOVERFLOW))
                        sAppStream << rcClient.left << " " << rcClient.bottom << " "
                                << rcClient.right - rcClient.left << " " << rcClient.top - rcClient.bottom << " re W n\n";
@@ -410,7 +408,7 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser
        CPDF_Rect rcClient = GetClientRect();
        CFX_ByteTextBuf sLine;
 
-       FX_INT32 nCharArray = m_pEdit->GetCharArray();
+       int32_t nCharArray = m_pEdit->GetCharArray();
        FX_SAFE_INT32 nCharArraySafe = nCharArray;
        nCharArraySafe -= 1;
        nCharArraySafe *= 2;
@@ -425,22 +423,20 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser
                                gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
 
                                CFX_PathData path;
-                               if (!path.SetPointCount(nCharArraySafe.ValueOrDie())) {
-                                       return;
-                               }
-                               
-                               for (FX_INT32 i=0; i<nCharArray-1; i++)
-                               {                                       
-                                       path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1), 
+                               path.SetPointCount(nCharArraySafe.ValueOrDie());
+
+                               for (int32_t i=0; i<nCharArray-1; i++)
+                               {
+                                       path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
                                                rcClient.bottom, FXPT_MOVETO);
                                        path.SetPoint(i*2+1, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
-                                               rcClient.top, FXPT_LINETO);                                                                                     
-                               }                       
+                                               rcClient.top, FXPT_LINETO);
+                               }
                                if (path.GetPointCount() > 0)
-                                       pDevice->DrawPath(&path, pUser2Device, &gsd,0,  
+                                       pDevice->DrawPath(&path, pUser2Device, &gsd,0,
                                                CPWL_Utils::PWLColorToFXColor(GetBorderColor(),255), FXFILL_ALTERNATE);
                        }
-                       break; 
+                       break;
                case PBS_DASH:
                        {
                                CFX_GraphStateData gsd;
@@ -452,23 +448,21 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser
                                gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase;
 
                                CFX_PathData path;
-                               if (!path.SetPointCount(nCharArraySafe.ValueOrDie())) {
-                                       return;
-                               }
-                               
-                               for (FX_INT32 i=0; i<nCharArray-1; i++)
-                               {                                       
-                                       path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1), 
+                               path.SetPointCount(nCharArraySafe.ValueOrDie());
+
+                               for (int32_t i=0; i<nCharArray-1; i++)
+                               {
+                                       path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
                                                rcClient.bottom, FXPT_MOVETO);
                                        path.SetPoint(i*2+1, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
-                                               rcClient.top, FXPT_LINETO);                                                                                     
-                               }               
+                                               rcClient.top, FXPT_LINETO);
+                               }
                                if (path.GetPointCount() > 0)
-                                       pDevice->DrawPath(&path, pUser2Device, &gsd,0,  
+                                       pDevice->DrawPath(&path, pUser2Device, &gsd,0,
                                                CPWL_Utils::PWLColorToFXColor(GetBorderColor(),255), FXFILL_ALTERNATE);
                        }
                        break;
-               }               
+               }
        }
 
        CPDF_Rect rcClip;
@@ -482,14 +476,14 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser
        }
 IFX_SystemHandler* pSysHandler = GetSystemHandler();
        IFX_Edit::DrawEdit(pDevice,pUser2Device,m_pEdit,
-               CPWL_Utils::PWLColorToFXColor(GetTextColor(),this->GetTransparency()),
-               CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(),this->GetTransparency()),
+               CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
+               CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()),
                rcClip,CPDF_Point(0.0f,0.0f),pRange, pSysHandler, m_pFormFiller);
 
        if (HasFlag(PES_SPELLCHECK))
        {
                CPWL_Utils::DrawEditSpellCheck(pDevice,pUser2Device,m_pEdit,rcClip,
-                       CPDF_Point(0.0f,0.0f),pRange, this->GetCreationParam().pSpellCheck);
+                       CPDF_Point(0.0f,0.0f),pRange, GetCreationParam().pSpellCheck);
        }
 }
 
@@ -500,9 +494,9 @@ FX_BOOL CPWL_Edit::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
        if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point))
        {
                if (m_bMouseDown)
-                       this->InvalidateRect();
+                       InvalidateRect();
 
-               m_bMouseDown = TRUE;            
+               m_bMouseDown = TRUE;
                SetCapture();
 
                m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
@@ -537,13 +531,13 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
        if (m_bMouseDown) return FALSE;
 
        CPWL_Wnd::OnRButtonUp(point, nFlag);
-       
+
        if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point)) return TRUE;
 
        IFX_SystemHandler* pSH = GetSystemHandler();
        if (!pSH) return FALSE;
 
-       this->SetFocus();
+       SetFocus();
 
        CPVT_WordRange wrLatin = GetLatinWordsRange(point);
        CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin);
@@ -563,13 +557,13 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
                                CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin);
 
                                if (!m_pSpellCheck->CheckWord(sLatin))
-                               {                                               
+                               {
                                        m_pSpellCheck->SuggestWords(sLatin,sSuggestWords);
 
-                                       FX_INT32 nSuggest = sSuggestWords.GetSize();
+                                       int32_t nSuggest = sSuggestWords.GetSize();
 
-                                       for (FX_INT32 nWord=0; nWord<nSuggest; nWord++)
-                                       {       
+                                       for (int32_t nWord=0; nWord<nSuggest; nWord++)
+                                       {
                                                pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST+nWord, sSuggestWords[nWord].UTF8Decode());
                                        }
 
@@ -582,11 +576,11 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
                }
        }
 
-       IPWL_Provider* pProvider = this->GetProvider();
+       IPWL_Provider* pProvider = GetProvider();
 
        if (HasFlag(PES_UNDO))
        {
-               pSH->AppendMenuItem(hPopup, WM_PWLEDIT_UNDO, 
+               pSH->AppendMenuItem(hPopup, WM_PWLEDIT_UNDO,
                        pProvider ? pProvider->LoadPopupMenuString(0) : L"&Undo");
                pSH->AppendMenuItem(hPopup, WM_PWLEDIT_REDO,
                        pProvider ? pProvider->LoadPopupMenuString(1) : L"&Redo");
@@ -598,16 +592,16 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
                        pSH->EnableMenuItem(hPopup, WM_PWLEDIT_REDO, FALSE);
        }
 
-       pSH->AppendMenuItem(hPopup, WM_PWLEDIT_CUT, 
+       pSH->AppendMenuItem(hPopup, WM_PWLEDIT_CUT,
                pProvider ? pProvider->LoadPopupMenuString(2) : L"Cu&t");
-       pSH->AppendMenuItem(hPopup, WM_PWLEDIT_COPY, 
+       pSH->AppendMenuItem(hPopup, WM_PWLEDIT_COPY,
                pProvider ? pProvider->LoadPopupMenuString(3) : L"&Copy");
-       pSH->AppendMenuItem(hPopup, WM_PWLEDIT_PASTE, 
+       pSH->AppendMenuItem(hPopup, WM_PWLEDIT_PASTE,
                pProvider ? pProvider->LoadPopupMenuString(4) : L"&Paste");
-       pSH->AppendMenuItem(hPopup, WM_PWLEDIT_DELETE, 
+       pSH->AppendMenuItem(hPopup, WM_PWLEDIT_DELETE,
                pProvider ? pProvider->LoadPopupMenuString(5) : L"&Delete");
 
-       CFX_WideString swText = pSH->GetClipboardText(this->GetAttachedHWnd());
+       CFX_WideString swText = pSH->GetClipboardText(GetAttachedHWnd());
        if (swText.IsEmpty())
                pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
 
@@ -622,7 +616,7 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
        {
                pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
                pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
-               pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);                   
+               pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
        }
 
        if (HasFlag(PES_PASSWORD))
@@ -646,11 +640,11 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
                pSH->EnableMenuItem(hPopup, WM_PWLEDIT_SELECTALL, FALSE);
        }
 
-       FX_INT32 x, y;
+       int32_t x, y;
        PWLtoWnd(ptPopup, x, y);
        pSH->ClientToScreen(GetAttachedHWnd(), x, y);
        pSH->SetCursor(FXCT_ARROW);
-       FX_INT32 nCmd = pSH->TrackPopupMenu(hPopup,
+       int32_t nCmd = pSH->TrackPopupMenu(hPopup,
                                         x,
                                         y,
                                         GetAttachedHWnd());
@@ -665,39 +659,39 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
                Redo();
                break;
        case WM_PWLEDIT_CUT:
-               this->CutText();
+               CutText();
                break;
        case WM_PWLEDIT_COPY:
-               this->CopyText();
+               CopyText();
                break;
        case WM_PWLEDIT_PASTE:
-               this->PasteText();
+               PasteText();
                break;
        case WM_PWLEDIT_DELETE:
-               this->Clear();
+               Clear();
                break;
        case WM_PWLEDIT_SELECTALL:
-               this->SelectAll();
+               SelectAll();
                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;
@@ -724,10 +718,10 @@ void CPWL_Edit::OnSetFocus()
 void CPWL_Edit::OnKillFocus()
 {
        ShowVScrollBar(FALSE);
-       
+
        m_pEdit->SelectNone();
        SetCaret(FALSE, CPDF_Point(0.0f,0.0f), CPDF_Point(0.0f,0.0f));
-       
+
        SetCharSet(0);
 
        if (!IsReadOnly())
@@ -739,7 +733,7 @@ void CPWL_Edit::OnKillFocus()
        m_bFocus = FALSE;
 }
 
-void CPWL_Edit::SetHorzScale(FX_INT32 nHorzScale, FX_BOOL bPaint/* = TRUE*/)
+void CPWL_Edit::SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint/* = TRUE*/)
 {
        m_pEdit->SetHorzScale(nHorzScale, bPaint);
 }
@@ -764,8 +758,8 @@ CPVT_WordRange CPWL_Edit::GetSelectWordRange() const
 {
        if (m_pEdit->IsSelected())
        {
-               FX_INT32 nStart = -1;
-               FX_INT32 nEnd = -1;
+               int32_t nStart = -1;
+               int32_t nEnd = -1;
 
                m_pEdit->GetSel(nStart, nEnd);
 
@@ -782,7 +776,7 @@ CFX_ByteString CPWL_Edit::GetTextAppearanceStream(const CPDF_Point & ptOffset) c
 {
        CFX_ByteTextBuf sRet;
        CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit,ptOffset);
-       
+
        if (sEdit.GetLength() > 0)
        {
                sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit << "ET\n";
@@ -824,7 +818,7 @@ FX_BOOL     CPWL_Edit::IsTextFull() const
        return m_pEdit->IsTextFull();
 }
 
-FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, const CPDF_Rect& rcPlate, FX_INT32 nCharArray)
+FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, const CPDF_Rect& rcPlate, int32_t nCharArray)
 {
        if (pFont && !pFont->IsStandardFont())
        {
@@ -841,16 +835,16 @@ FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, const CPDF_Rect&
        return 0.0f;
 }
 
-void CPWL_Edit::SetCharArray(FX_INT32 nCharArray)
+void CPWL_Edit::SetCharArray(int32_t nCharArray)
 {
        if (HasFlag(PES_CHARARRAY) && nCharArray > 0)
        {
-               m_pEdit->SetCharArray(nCharArray);      
+               m_pEdit->SetCharArray(nCharArray);
                m_pEdit->SetTextOverflow(TRUE);
 
                if (HasFlag(PWS_AUTOFONTSIZE))
                {
-                       if (IFX_Edit_FontMap* pFontMap = this->GetFontMap())
+                       if (IFX_Edit_FontMap* pFontMap = GetFontMap())
                        {
                                FX_FLOAT fFontSize = GetCharArrayAutoFontSize(pFontMap->GetPDFFont(0), GetClientRect(), nCharArray);
                                if (fFontSize > 0.0f)
@@ -863,12 +857,12 @@ void CPWL_Edit::SetCharArray(FX_INT32 nCharArray)
        }
 }
 
-void CPWL_Edit::SetLimitChar(FX_INT32 nLimitChar)
+void CPWL_Edit::SetLimitChar(int32_t nLimitChar)
 {
        m_pEdit->SetLimitChar(nLimitChar);
 }
 
-void CPWL_Edit::ReplaceSel(FX_LPCWSTR csText)
+void CPWL_Edit::ReplaceSel(const FX_WCHAR* csText)
 {
        m_pEdit->Clear();
        m_pEdit->InsertText(csText);
@@ -890,7 +884,7 @@ void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow)
                                pScroll->SetVisible(TRUE);
                                CPDF_Rect rcWindow = GetWindowRect();
                                m_rcOldWindow = rcWindow;
-                               rcWindow.right += PWL_SCROLLBAR_WIDTH;                  
+                               rcWindow.right += PWL_SCROLLBAR_WIDTH;
                                Move(rcWindow, TRUE, TRUE);
                        }
                }
@@ -900,7 +894,7 @@ void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow)
                        {
                                pScroll->SetVisible(FALSE);
                                Move(m_rcOldWindow, TRUE, TRUE);
-                       }       
+                       }
                }
        }
 }
@@ -943,7 +937,7 @@ FX_BOOL CPWL_Edit::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag)
                        if (nSelStart == nSelEnd)
                                nSelEnd = nSelStart + 1;
                        m_pFillerNotify->OnBeforeKeyStroke(TRUE, GetAttachedData(), FWL_VKEY_Delete, strChange, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, nFlag);
-                       if (!bRC) return FALSE;                         
+                       if (!bRC) return FALSE;
                        if (bExit) return FALSE;
                }
        }
@@ -968,7 +962,7 @@ FX_BOOL CPWL_Edit::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag)
 }
 
 /**
-*In case of implementation swallow the OnKeyDown event. 
+*In case of implementation swallow the OnKeyDown event.
 *If the event is swallowed, implementation may do other unexpected things, which is not the control means to do.
 */
 FX_BOOL CPWL_Edit::IsProceedtoOnChar(FX_WORD nKeyCode, FX_DWORD nFlag)
@@ -978,7 +972,7 @@ FX_BOOL CPWL_Edit::IsProceedtoOnChar(FX_WORD nKeyCode, FX_DWORD nFlag)
        FX_BOOL bAlt = IsALTpressed(nFlag);
        if(bCtrl && !bAlt)
        {
-       //hot keys for edit control.    
+       //hot keys for edit control.
                switch(nKeyCode)
                {
                case 'C':
@@ -1019,7 +1013,7 @@ FX_BOOL CPWL_Edit::OnChar(FX_WORD nChar, FX_DWORD nFlag)
                if (m_pFillerNotify)
                {
                        CFX_WideString swChange;
-                       FX_INT32 nKeyCode;
+                       int32_t nKeyCode;
 
                        int nSelStart = 0;
                        int nSelEnd = 0;
@@ -1040,7 +1034,7 @@ FX_BOOL CPWL_Edit::OnChar(FX_WORD nChar, FX_DWORD nFlag)
                                swChange += nChar;
                                break;
                        }
-               
+
                        CFX_WideString strChangeEx;
                        m_pFillerNotify->OnBeforeKeyStroke(TRUE, GetAttachedData(), nKeyCode, swChange, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, nFlag);
                }
@@ -1051,8 +1045,8 @@ FX_BOOL CPWL_Edit::OnChar(FX_WORD nChar, FX_DWORD nFlag)
 
        if (IFX_Edit_FontMap * pFontMap = GetFontMap())
        {
-               FX_INT32 nOldCharSet = GetCharSet();
-               FX_INT32 nNewCharSet = pFontMap->CharSetFromUnicode(nChar, DEFAULT_CHARSET);
+               int32_t nOldCharSet = GetCharSet();
+               int32_t nNewCharSet = pFontMap->CharSetFromUnicode(nChar, DEFAULT_CHARSET);
                if(nOldCharSet != nNewCharSet)
                {
                        SetCharSet(nNewCharSet);
@@ -1080,13 +1074,13 @@ FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD
 
                if (zDelta > 0)
                {
-                       ptScroll.y += this->GetFontSize();
+                       ptScroll.y += GetFontSize();
                }
                else
                {
-                       ptScroll.y -= this->GetFontSize();
+                       ptScroll.y -= GetFontSize();
                }
-               this->SetScrollPos(ptScroll);
+               SetScrollPos(ptScroll);
 
                return TRUE;
        }
@@ -1232,10 +1226,10 @@ CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace & place, FX_BOO
 
        if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator())
        {
-               CPVT_Word wordinfo;     
-               CPVT_WordPlace wpStart(place),wpEnd(place);                     
-               pIterator->SetAt(place);                        
-               
+               CPVT_Word wordinfo;
+               CPVT_WordPlace wpStart(place),wpEnd(place);
+               pIterator->SetAt(place);
+
                if (bLatin)
                {
                        while (pIterator->NextWord())
@@ -1245,7 +1239,7 @@ CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace & place, FX_BOO
                                        wpEnd = pIterator->GetAt();
                                        continue;
                                }
-                               else 
+                               else
                                        break;
                        };
                }
@@ -1258,7 +1252,7 @@ CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace & place, FX_BOO
                                        wpEnd = pIterator->GetAt();
                                        continue;
                                }
-                               else 
+                               else
                                        break;
                        };
                }
@@ -1270,7 +1264,7 @@ CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace & place, FX_BOO
                        do
                        {
                                if (pIterator->GetWord(wordinfo) && FX_EDIT_ISLATINWORD(wordinfo.Word))
-                               {                                       
+                               {
                                        continue;
                                }
                                else
@@ -1286,7 +1280,7 @@ CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace & place, FX_BOO
                        do
                        {
                                if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word))
-                               {                                       
+                               {
                                        continue;
                                }
                                else
@@ -1299,7 +1293,7 @@ CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace & place, FX_BOO
                }
 
                range.Set(wpStart,wpEnd);
-       }       
+       }
 
        return range;
 }
@@ -1308,13 +1302,13 @@ void CPWL_Edit::AjustArabicWords(const CPVT_WordRange& wr)
 {
 }
 
-void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, 
+void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects,
                                                                                const CPDF_Point& ptOffset, CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray)
 {
        IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPWL_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray);
 }
 
-void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, 
+void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects,
                                                                        const CPDF_Point& ptOffset)
 {
        CFX_ArrayTemplate<CPDF_TextObject*> ObjArray;