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/cpdfsdk_widget.h" | 10 #include "fpdfsdk/include/cpdfsdk_widget.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 if (nMaxLen > 0) { | 93 if (nMaxLen > 0) { |
94 if (pWnd->HasFlag(PES_CHARARRAY)) { | 94 if (pWnd->HasFlag(PES_CHARARRAY)) { |
95 pWnd->SetCharArray(nMaxLen); | 95 pWnd->SetCharArray(nMaxLen); |
96 pWnd->SetAlignFormatV(PEAV_CENTER); | 96 pWnd->SetAlignFormatV(PEAV_CENTER); |
97 } else { | 97 } else { |
98 pWnd->SetLimitChar(nMaxLen); | 98 pWnd->SetLimitChar(nMaxLen); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 pWnd->SetText(swValue.c_str()); | 102 pWnd->SetText(swValue); |
103 return pWnd; | 103 return pWnd; |
104 } | 104 } |
105 | 105 |
106 FX_BOOL CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot, | 106 FX_BOOL CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot, |
107 FX_UINT nChar, | 107 FX_UINT nChar, |
108 FX_UINT nFlags) { | 108 FX_UINT nFlags) { |
109 switch (nChar) { | 109 switch (nChar) { |
110 case FWL_VKEY_Return: | 110 case FWL_VKEY_Return: |
111 if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_MULTILINE)) { | 111 if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_MULTILINE)) { |
112 CPDFSDK_PageView* pPageView = GetCurPageView(true); | 112 CPDFSDK_PageView* pPageView = GetCurPageView(true); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 189 } |
190 | 190 |
191 void CFFL_TextField::SetActionData(CPDFSDK_PageView* pPageView, | 191 void CFFL_TextField::SetActionData(CPDFSDK_PageView* pPageView, |
192 CPDF_AAction::AActionType type, | 192 CPDF_AAction::AActionType type, |
193 const PDFSDK_FieldAction& fa) { | 193 const PDFSDK_FieldAction& fa) { |
194 switch (type) { | 194 switch (type) { |
195 case CPDF_AAction::KeyStroke: | 195 case CPDF_AAction::KeyStroke: |
196 if (CPWL_Edit* pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) { | 196 if (CPWL_Edit* pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) { |
197 pEdit->SetFocus(); | 197 pEdit->SetFocus(); |
198 pEdit->SetSel(fa.nSelStart, fa.nSelEnd); | 198 pEdit->SetSel(fa.nSelStart, fa.nSelEnd); |
199 pEdit->ReplaceSel(fa.sChange.c_str()); | 199 pEdit->ReplaceSel(fa.sChange); |
200 } | 200 } |
201 break; | 201 break; |
202 default: | 202 default: |
203 break; | 203 break; |
204 } | 204 } |
205 } | 205 } |
206 | 206 |
207 FX_BOOL CFFL_TextField::IsActionDataChanged(CPDF_AAction::AActionType type, | 207 FX_BOOL CFFL_TextField::IsActionDataChanged(CPDF_AAction::AActionType type, |
208 const PDFSDK_FieldAction& faOld, | 208 const PDFSDK_FieldAction& faOld, |
209 const PDFSDK_FieldAction& faNew) { | 209 const PDFSDK_FieldAction& faNew) { |
(...skipping 15 matching lines...) Expand all Loading... |
225 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) { | 225 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) { |
226 pWnd->GetSel(m_State.nStart, m_State.nEnd); | 226 pWnd->GetSel(m_State.nStart, m_State.nEnd); |
227 m_State.sValue = pWnd->GetText(); | 227 m_State.sValue = pWnd->GetText(); |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 void CFFL_TextField::RestoreState(CPDFSDK_PageView* pPageView) { | 231 void CFFL_TextField::RestoreState(CPDFSDK_PageView* pPageView) { |
232 ASSERT(pPageView); | 232 ASSERT(pPageView); |
233 | 233 |
234 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, TRUE)) { | 234 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, TRUE)) { |
235 pWnd->SetText(m_State.sValue.c_str()); | 235 pWnd->SetText(m_State.sValue); |
236 pWnd->SetSel(m_State.nStart, m_State.nEnd); | 236 pWnd->SetSel(m_State.nStart, m_State.nEnd); |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 CPWL_Wnd* CFFL_TextField::ResetPDFWindow(CPDFSDK_PageView* pPageView, | 240 CPWL_Wnd* CFFL_TextField::ResetPDFWindow(CPDFSDK_PageView* pPageView, |
241 FX_BOOL bRestoreValue) { | 241 FX_BOOL bRestoreValue) { |
242 if (bRestoreValue) | 242 if (bRestoreValue) |
243 SaveState(pPageView); | 243 SaveState(pPageView); |
244 | 244 |
245 DestroyPDFWindow(pPageView); | 245 DestroyPDFWindow(pPageView); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 pEdit->SetReadyToInput(); | 278 pEdit->SetReadyToInput(); |
279 CFX_WideString wsText = pEdit->GetText(); | 279 CFX_WideString wsText = pEdit->GetText(); |
280 int nCharacters = wsText.GetLength(); | 280 int nCharacters = wsText.GetLength(); |
281 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); | 281 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); |
282 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); | 282 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); |
283 m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, | 283 m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, |
284 nCharacters, TRUE); | 284 nCharacters, TRUE); |
285 } | 285 } |
286 } | 286 } |
OLD | NEW |