Cleanup: Get this rid of "this->" in fpdfsdk/
[pdfium.git] / fpdfsdk / src / pdfwindow / PWL_Edit.cpp
index f704a67..856adcf 100644 (file)
@@ -4,15 +4,15 @@
  
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
+#include "../../../core/include/fxcrt/fx_safe_types.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 "../../../core/src/fxcrt/fx_safe_types.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
 
 /* ---------------------------- CPWL_Edit ------------------------------ */
 
@@ -37,7 +37,7 @@ void CPWL_Edit::OnDestroy()
 {
 }
 
-void CPWL_Edit::SetText(FX_LPCWSTR csText)
+void CPWL_Edit::SetText(const FX_WCHAR* csText)
 {
        CFX_WideString swText = csText;
 
@@ -47,12 +47,12 @@ void CPWL_Edit::SetText(FX_LPCWSTR csText)
                
                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))
                                {
@@ -61,7 +61,7 @@ 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);
                                                }
@@ -83,18 +83,14 @@ void CPWL_Edit::SetText(FX_LPCWSTR csText)
 
 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
@@ -106,7 +102,7 @@ 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())
                {
@@ -119,12 +115,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
@@ -298,7 +294,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)
        {
@@ -309,7 +305,7 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
                                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"
@@ -328,7 +324,7 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
                                        << 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"
@@ -391,7 +387,7 @@ 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))
@@ -411,7 +407,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;
@@ -426,17 +422,15 @@ 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,  
                                                CPWL_Utils::PWLColorToFXColor(GetBorderColor(),255), FXFILL_ALTERNATE);
@@ -453,19 +447,17 @@ 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;
@@ -483,14 +475,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);
        }
 }
 
@@ -501,7 +493,7 @@ 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;            
                SetCapture();
@@ -544,7 +536,7 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
        IFX_SystemHandler* pSH = GetSystemHandler();
        if (!pSH) return FALSE;
 
-       this->SetFocus();
+       SetFocus();
 
        CPVT_WordRange wrLatin = GetLatinWordsRange(point);
        CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin);
@@ -567,9 +559,9 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
                                {                                               
                                        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());
                                        }
@@ -583,7 +575,7 @@ 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))
        {
@@ -608,7 +600,7 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
        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);
 
@@ -647,11 +639,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());
@@ -666,19 +658,19 @@ 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));
@@ -740,7 +732,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);
 }
@@ -765,8 +757,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);
 
@@ -825,7 +817,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())
        {
@@ -842,7 +834,7 @@ 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)
        {
@@ -851,7 +843,7 @@ void CPWL_Edit::SetCharArray(FX_INT32 nCharArray)
 
                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)
@@ -864,12 +856,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);
@@ -1020,7 +1012,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;
@@ -1052,8 +1044,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);
@@ -1081,13 +1073,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;
        }