| 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_combobox.h" | 7 #include "fpdfsdk/formfiller/cffl_combobox.h" |
| 8 | 8 |
| 9 #include "fpdfsdk/formfiller/cba_fontmap.h" | 9 #include "fpdfsdk/formfiller/cba_fontmap.h" |
| 10 #include "fpdfsdk/formfiller/cffl_formfiller.h" | 10 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 return cp; | 48 return cp; |
| 49 } | 49 } |
| 50 | 50 |
| 51 CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp, | 51 CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp, |
| 52 CPDFSDK_PageView* pPageView) { | 52 CPDFSDK_PageView* pPageView) { |
| 53 CPWL_ComboBox* pWnd = new CPWL_ComboBox(); | 53 CPWL_ComboBox* pWnd = new CPWL_ComboBox(); |
| 54 pWnd->AttachFFLData(this); | 54 pWnd->AttachFFLData(this); |
| 55 pWnd->Create(cp); | 55 pWnd->Create(cp); |
| 56 | 56 |
| 57 CFFL_IFormFiller* pFormFiller = m_pApp->GetIFormFiller(); | 57 CFFL_IFormFiller* pFormFiller = m_pEnv->GetIFormFiller(); |
| 58 pWnd->SetFillerNotify(pFormFiller); | 58 pWnd->SetFillerNotify(pFormFiller); |
| 59 | 59 |
| 60 int32_t nCurSel = m_pWidget->GetSelectedIndex(0); | 60 int32_t nCurSel = m_pWidget->GetSelectedIndex(0); |
| 61 CFX_WideString swText; | 61 CFX_WideString swText; |
| 62 if (nCurSel < 0) | 62 if (nCurSel < 0) |
| 63 swText = m_pWidget->GetValue(); | 63 swText = m_pWidget->GetValue(); |
| 64 else | 64 else |
| 65 swText = m_pWidget->GetOptionLabel(nCurSel); | 65 swText = m_pWidget->GetOptionLabel(nCurSel); |
| 66 | 66 |
| 67 for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) { | 67 for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 if (CPWL_ComboBox* pComboBox = | 252 if (CPWL_ComboBox* pComboBox = |
| 253 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) { | 253 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) { |
| 254 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) | 254 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) |
| 255 return pEdit->IsTextFull(); | 255 return pEdit->IsTextFull(); |
| 256 } | 256 } |
| 257 return FALSE; | 257 return FALSE; |
| 258 } | 258 } |
| 259 #endif // PDF_ENABLE_XFA | 259 #endif // PDF_ENABLE_XFA |
| 260 | 260 |
| 261 void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) { | 261 void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) { |
| 262 ASSERT(m_pApp); | 262 ASSERT(m_pEnv); |
| 263 | 263 |
| 264 if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) { | 264 if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) { |
| 265 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; | 265 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; |
| 266 pEdit->SetCharSet(FXFONT_GB2312_CHARSET); | 266 pEdit->SetCharSet(FXFONT_GB2312_CHARSET); |
| 267 pEdit->SetCodePage(936); | 267 pEdit->SetCodePage(936); |
| 268 | 268 |
| 269 pEdit->SetReadyToInput(); | 269 pEdit->SetReadyToInput(); |
| 270 CFX_WideString wsText = pEdit->GetText(); | 270 CFX_WideString wsText = pEdit->GetText(); |
| 271 int nCharacters = wsText.GetLength(); | 271 int nCharacters = wsText.GetLength(); |
| 272 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); | 272 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); |
| 273 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); | 273 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); |
| 274 m_pApp->OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, | 274 m_pEnv->OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, |
| 275 nCharacters, TRUE); | 275 nCharacters, TRUE); |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 | 278 |
| 279 CFX_WideString CFFL_ComboBox::GetSelectExportText() { | 279 CFX_WideString CFFL_ComboBox::GetSelectExportText() { |
| 280 CFX_WideString swRet; | 280 CFX_WideString swRet; |
| 281 | 281 |
| 282 int nExport = -1; | 282 int nExport = -1; |
| 283 CPDFSDK_PageView* pPageView = GetCurPageView(true); | 283 CPDFSDK_PageView* pPageView = GetCurPageView(true); |
| 284 if (CPWL_ComboBox* pComboBox = | 284 if (CPWL_ComboBox* pComboBox = |
| 285 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { | 285 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { |
| 286 nExport = pComboBox->GetSelect(); | 286 nExport = pComboBox->GetSelect(); |
| 287 } | 287 } |
| 288 | 288 |
| 289 if (nExport >= 0) { | 289 if (nExport >= 0) { |
| 290 if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) { | 290 if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) { |
| 291 swRet = pFormField->GetOptionValue(nExport); | 291 swRet = pFormField->GetOptionValue(nExport); |
| 292 if (swRet.IsEmpty()) | 292 if (swRet.IsEmpty()) |
| 293 swRet = pFormField->GetOptionLabel(nExport); | 293 swRet = pFormField->GetOptionLabel(nExport); |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 | 296 |
| 297 return swRet; | 297 return swRet; |
| 298 } | 298 } |
| OLD | NEW |