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