| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/pdfwindow/PWL_Edit.h" | 7 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 CPWL_Edit::~CPWL_Edit() { | 31 CPWL_Edit::~CPWL_Edit() { |
| 32 ASSERT(m_bFocus == FALSE); | 32 ASSERT(m_bFocus == FALSE); |
| 33 } | 33 } |
| 34 | 34 |
| 35 CFX_ByteString CPWL_Edit::GetClassName() const { | 35 CFX_ByteString CPWL_Edit::GetClassName() const { |
| 36 return PWL_CLASSNAME_EDIT; | 36 return PWL_CLASSNAME_EDIT; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void CPWL_Edit::OnDestroy() {} | 39 void CPWL_Edit::OnDestroy() {} |
| 40 | 40 |
| 41 void CPWL_Edit::SetText(const FX_WCHAR* csText) { | 41 void CPWL_Edit::SetText(const CFX_WideString& csText) { |
| 42 CFX_WideString swText = csText; | 42 CFX_WideString swText = csText; |
| 43 | |
| 44 if (HasFlag(PES_RICH)) { | 43 if (HasFlag(PES_RICH)) { |
| 45 CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText); | 44 CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText); |
| 46 | |
| 47 if (CXML_Element* pXML = | 45 if (CXML_Element* pXML = |
| 48 CXML_Element::Parse(sValue.c_str(), sValue.GetLength())) { | 46 CXML_Element::Parse(sValue.c_str(), sValue.GetLength())) { |
| 49 int32_t nCount = pXML->CountChildren(); | 47 int32_t nCount = pXML->CountChildren(); |
| 50 FX_BOOL bFirst = TRUE; | 48 FX_BOOL bFirst = TRUE; |
| 51 | 49 |
| 52 swText.clear(); | 50 swText.clear(); |
| 53 | 51 |
| 54 for (int32_t i = 0; i < nCount; i++) { | 52 for (int32_t i = 0; i < nCount; i++) { |
| 55 if (CXML_Element* pSubElement = pXML->GetElement(i)) { | 53 if (CXML_Element* pSubElement = pXML->GetElement(i)) { |
| 56 CFX_ByteString tag = pSubElement->GetTagName(); | 54 CFX_ByteString tag = pSubElement->GetTagName(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 67 swText += FWL_VKEY_Return; | 65 swText += FWL_VKEY_Return; |
| 68 swText += swSection; | 66 swText += swSection; |
| 69 } | 67 } |
| 70 } | 68 } |
| 71 } | 69 } |
| 72 | 70 |
| 73 delete pXML; | 71 delete pXML; |
| 74 } | 72 } |
| 75 } | 73 } |
| 76 | 74 |
| 77 m_pEdit->SetText(swText.c_str()); | 75 m_pEdit->SetText(swText); |
| 78 } | 76 } |
| 79 | 77 |
| 80 void CPWL_Edit::RePosChildWnd() { | 78 void CPWL_Edit::RePosChildWnd() { |
| 81 if (CPWL_ScrollBar* pVSB = GetVScrollBar()) { | 79 if (CPWL_ScrollBar* pVSB = GetVScrollBar()) { |
| 82 CFX_FloatRect rcWindow = m_rcOldWindow; | 80 CFX_FloatRect rcWindow = m_rcOldWindow; |
| 83 CFX_FloatRect rcVScroll = | 81 CFX_FloatRect rcVScroll = |
| 84 CFX_FloatRect(rcWindow.right, rcWindow.bottom, | 82 CFX_FloatRect(rcWindow.right, rcWindow.bottom, |
| 85 rcWindow.right + PWL_SCROLLBAR_WIDTH, rcWindow.top); | 83 rcWindow.right + PWL_SCROLLBAR_WIDTH, rcWindow.top); |
| 86 pVSB->Move(rcVScroll, TRUE, FALSE); | 84 pVSB->Move(rcVScroll, TRUE, FALSE); |
| 87 } | 85 } |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 } | 562 } |
| 565 } | 563 } |
| 566 } | 564 } |
| 567 } | 565 } |
| 568 } | 566 } |
| 569 | 567 |
| 570 void CPWL_Edit::SetLimitChar(int32_t nLimitChar) { | 568 void CPWL_Edit::SetLimitChar(int32_t nLimitChar) { |
| 571 m_pEdit->SetLimitChar(nLimitChar); | 569 m_pEdit->SetLimitChar(nLimitChar); |
| 572 } | 570 } |
| 573 | 571 |
| 574 void CPWL_Edit::ReplaceSel(const FX_WCHAR* csText) { | 572 void CPWL_Edit::ReplaceSel(const CFX_WideString& wsText) { |
| 575 m_pEdit->Clear(); | 573 m_pEdit->Clear(); |
| 576 m_pEdit->InsertText(csText, DEFAULT_CHARSET); | 574 m_pEdit->InsertText(wsText, DEFAULT_CHARSET); |
| 577 } | 575 } |
| 578 | 576 |
| 579 CFX_FloatRect CPWL_Edit::GetFocusRect() const { | 577 CFX_FloatRect CPWL_Edit::GetFocusRect() const { |
| 580 return CFX_FloatRect(); | 578 return CFX_FloatRect(); |
| 581 } | 579 } |
| 582 | 580 |
| 583 void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow) { | 581 void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow) { |
| 584 if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { | 582 if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { |
| 585 if (bShow) { | 583 if (bShow) { |
| 586 if (!pScroll->IsVisible()) { | 584 if (!pScroll->IsVisible()) { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 } | 891 } |
| 894 | 892 |
| 895 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, | 893 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, |
| 896 const CFX_FloatPoint& ptOffset) { | 894 const CFX_FloatPoint& ptOffset) { |
| 897 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 895 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
| 898 CFX_Edit::GeneratePageObjects( | 896 CFX_Edit::GeneratePageObjects( |
| 899 pObjectHolder, m_pEdit.get(), ptOffset, nullptr, | 897 pObjectHolder, m_pEdit.get(), ptOffset, nullptr, |
| 900 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 898 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 901 ObjArray); | 899 ObjArray); |
| 902 } | 900 } |
| OLD | NEW |