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/formfiller/cffl_textfield.h" | 7 #include "fpdfsdk/formfiller/cffl_textfield.h" |
8 | 8 |
9 #include "fpdfsdk/formfiller/cba_fontmap.h" | 9 #include "fpdfsdk/formfiller/cba_fontmap.h" |
10 #include "fpdfsdk/include/fsdk_common.h" | 10 #include "fpdfsdk/include/fsdk_common.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 pWnd->SetText(swValue.c_str()); | 99 pWnd->SetText(swValue.c_str()); |
100 return pWnd; | 100 return pWnd; |
101 } | 101 } |
102 | 102 |
103 FX_BOOL CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot, | 103 FX_BOOL CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot, |
104 FX_UINT nChar, | 104 FX_UINT nChar, |
105 FX_UINT nFlags) { | 105 FX_UINT nFlags) { |
106 switch (nChar) { | 106 switch (nChar) { |
107 case FWL_VKEY_Return: | 107 case FWL_VKEY_Return: |
108 if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_MULTILINE)) { | 108 if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_MULTILINE)) { |
109 CPDFSDK_PageView* pPageView = GetCurPageView(); | 109 CPDFSDK_PageView* pPageView = GetCurPageView(true); |
110 ASSERT(pPageView); | 110 ASSERT(pPageView); |
111 m_bValid = !m_bValid; | 111 m_bValid = !m_bValid; |
112 CFX_FloatRect rcAnnot = pAnnot->GetRect(); | 112 CFX_FloatRect rcAnnot = pAnnot->GetRect(); |
113 m_pApp->FFI_Invalidate(pAnnot->GetUnderlyingPage(), rcAnnot.left, | 113 m_pApp->FFI_Invalidate(pAnnot->GetUnderlyingPage(), rcAnnot.left, |
114 rcAnnot.top, rcAnnot.right, rcAnnot.bottom); | 114 rcAnnot.top, rcAnnot.right, rcAnnot.bottom); |
115 | 115 |
116 if (m_bValid) { | 116 if (m_bValid) { |
117 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) | 117 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) |
118 pWnd->SetFocus(); | 118 pWnd->SetFocus(); |
119 } else { | 119 } else { |
120 if (CommitData(pPageView, nFlags)) { | 120 if (CommitData(pPageView, nFlags)) { |
121 DestroyPDFWindow(pPageView); | 121 DestroyPDFWindow(pPageView); |
122 return TRUE; | 122 return TRUE; |
123 } | 123 } |
124 return FALSE; | 124 return FALSE; |
125 } | 125 } |
126 } | 126 } |
127 break; | 127 break; |
128 case FWL_VKEY_Escape: { | 128 case FWL_VKEY_Escape: { |
129 CPDFSDK_PageView* pPageView = GetCurPageView(); | 129 CPDFSDK_PageView* pPageView = GetCurPageView(true); |
130 ASSERT(pPageView); | 130 ASSERT(pPageView); |
131 EscapeFiller(pPageView, TRUE); | 131 EscapeFiller(pPageView, TRUE); |
132 return TRUE; | 132 return TRUE; |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); | 136 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); |
137 } | 137 } |
138 | 138 |
139 FX_BOOL CFFL_TextField::IsDataChanged(CPDFSDK_PageView* pPageView) { | 139 FX_BOOL CFFL_TextField::IsDataChanged(CPDFSDK_PageView* pPageView) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 274 |
275 pEdit->SetReadyToInput(); | 275 pEdit->SetReadyToInput(); |
276 CFX_WideString wsText = pEdit->GetText(); | 276 CFX_WideString wsText = pEdit->GetText(); |
277 int nCharacters = wsText.GetLength(); | 277 int nCharacters = wsText.GetLength(); |
278 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); | 278 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); |
279 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); | 279 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); |
280 m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, | 280 m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, |
281 nCharacters, TRUE); | 281 nCharacters, TRUE); |
282 } | 282 } |
283 } | 283 } |
OLD | NEW |