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" |
11 #include "fpdfsdk/include/fsdk_mgr.h" | 11 #include "fpdfsdk/include/fsdk_mgr.h" |
12 | 12 |
13 CFFL_TextField::CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) | 13 CFFL_TextField::CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) |
14 : CFFL_FormFiller(pApp, pAnnot), m_pFontMap(nullptr) { | 14 : CFFL_FormFiller(pApp, pAnnot) {} |
15 m_State.nStart = m_State.nEnd = 0; | |
16 } | |
17 | 15 |
18 CFFL_TextField::~CFFL_TextField() { | 16 CFFL_TextField::~CFFL_TextField() { |
19 for (const auto& it : m_Maps) | 17 for (const auto& it : m_Maps) |
20 it.second->InvalidateFocusHandler(this); | 18 it.second->InvalidateFocusHandler(this); |
21 delete m_pFontMap; | |
22 } | 19 } |
23 | 20 |
24 PWL_CREATEPARAM CFFL_TextField::GetCreateParam() { | 21 PWL_CREATEPARAM CFFL_TextField::GetCreateParam() { |
25 PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam(); | 22 PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam(); |
26 | 23 |
27 int nFlags = m_pWidget->GetFieldFlags(); | 24 int nFlags = m_pWidget->GetFieldFlags(); |
28 | 25 |
29 if (nFlags & FIELDFLAG_PASSWORD) { | 26 if (nFlags & FIELDFLAG_PASSWORD) { |
30 cp.dwFlags |= PES_PASSWORD; | 27 cp.dwFlags |= PES_PASSWORD; |
31 } | 28 } |
(...skipping 29 matching lines...) Expand all Loading... |
61 break; | 58 break; |
62 case BF_ALIGN_MIDDLE: | 59 case BF_ALIGN_MIDDLE: |
63 cp.dwFlags |= PES_MIDDLE; | 60 cp.dwFlags |= PES_MIDDLE; |
64 break; | 61 break; |
65 case BF_ALIGN_RIGHT: | 62 case BF_ALIGN_RIGHT: |
66 cp.dwFlags |= PES_RIGHT; | 63 cp.dwFlags |= PES_RIGHT; |
67 break; | 64 break; |
68 } | 65 } |
69 | 66 |
70 if (!m_pFontMap) | 67 if (!m_pFontMap) |
71 m_pFontMap = new CBA_FontMap(m_pWidget, m_pApp->GetSysHandler()); | 68 m_pFontMap.reset(new CBA_FontMap(m_pWidget, m_pApp->GetSysHandler())); |
72 cp.pFontMap = m_pFontMap; | 69 cp.pFontMap = m_pFontMap.get(); |
73 cp.pFocusHandler = this; | 70 cp.pFocusHandler = this; |
74 | 71 |
75 return cp; | 72 return cp; |
76 } | 73 } |
77 | 74 |
78 CPWL_Wnd* CFFL_TextField::NewPDFWindow(const PWL_CREATEPARAM& cp, | 75 CPWL_Wnd* CFFL_TextField::NewPDFWindow(const PWL_CREATEPARAM& cp, |
79 CPDFSDK_PageView* pPageView) { | 76 CPDFSDK_PageView* pPageView) { |
80 CPWL_Edit* pWnd = new CPWL_Edit(); | 77 CPWL_Edit* pWnd = new CPWL_Edit(); |
81 pWnd->AttachFFLData(this); | 78 pWnd->AttachFFLData(this); |
82 pWnd->Create(cp); | 79 pWnd->Create(cp); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 271 |
275 pEdit->SetReadyToInput(); | 272 pEdit->SetReadyToInput(); |
276 CFX_WideString wsText = pEdit->GetText(); | 273 CFX_WideString wsText = pEdit->GetText(); |
277 int nCharacters = wsText.GetLength(); | 274 int nCharacters = wsText.GetLength(); |
278 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); | 275 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); |
279 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); | 276 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); |
280 m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, | 277 m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, |
281 nCharacters, TRUE); | 278 nCharacters, TRUE); |
282 } | 279 } |
283 } | 280 } |
OLD | NEW |