| 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_listbox.h" | 7 #include "fpdfsdk/formfiller/cffl_listbox.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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 ++nSelCount; | 104 ++nSelCount; |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 return nSelCount != m_OriginSelections.size(); | 108 return nSelCount != m_OriginSelections.size(); |
| 109 } | 109 } |
| 110 return pListBox->GetCurSel() != m_pWidget->GetSelectedIndex(0); | 110 return pListBox->GetCurSel() != m_pWidget->GetSelectedIndex(0); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void CFFL_ListBox::SaveData(CPDFSDK_PageView* pPageView) { | 113 void CFFL_ListBox::SaveData(CPDFSDK_PageView* pPageView) { |
| 114 ASSERT(m_pWidget); | 114 CPWL_ListBox* pListBox = |
| 115 static_cast<CPWL_ListBox*>(GetPDFWindow(pPageView, FALSE)); |
| 116 if (!pListBox) |
| 117 return; |
| 115 | 118 |
| 116 if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALSE)) { | 119 int32_t nNewTopIndex = pListBox->GetTopVisibleIndex(); |
| 117 CFX_IntArray aOldSelect, aNewSelect; | 120 m_pWidget->ClearSelection(FALSE); |
| 118 | 121 if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) { |
| 119 { | 122 for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; i++) { |
| 120 for (int i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) { | 123 if (pListBox->IsItemSelected(i)) |
| 121 if (m_pWidget->IsOptionSelected(i)) { | 124 m_pWidget->SetOptionSelection(i, TRUE, FALSE); |
| 122 aOldSelect.Add(i); | |
| 123 } | |
| 124 } | |
| 125 } | 125 } |
| 126 | 126 } else { |
| 127 int32_t nNewTopIndex = pListBox->GetTopVisibleIndex(); | 127 m_pWidget->SetOptionSelection(pListBox->GetCurSel(), TRUE, FALSE); |
| 128 | |
| 129 m_pWidget->ClearSelection(FALSE); | |
| 130 | |
| 131 if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) { | |
| 132 for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; i++) { | |
| 133 if (pListBox->IsItemSelected(i)) { | |
| 134 m_pWidget->SetOptionSelection(i, TRUE, FALSE); | |
| 135 aNewSelect.Add(i); | |
| 136 } | |
| 137 } | |
| 138 } else { | |
| 139 m_pWidget->SetOptionSelection(pListBox->GetCurSel(), TRUE, FALSE); | |
| 140 aNewSelect.Add(pListBox->GetCurSel()); | |
| 141 } | |
| 142 | |
| 143 m_pWidget->SetTopVisibleIndex(nNewTopIndex); | |
| 144 m_pWidget->ResetFieldAppearance(TRUE); | |
| 145 m_pWidget->UpdateField(); | |
| 146 SetChangeMark(); | |
| 147 } | 128 } |
| 129 m_pWidget->SetTopVisibleIndex(nNewTopIndex); |
| 130 m_pWidget->ResetFieldAppearance(TRUE); |
| 131 m_pWidget->UpdateField(); |
| 132 SetChangeMark(); |
| 148 } | 133 } |
| 149 | 134 |
| 150 void CFFL_ListBox::GetActionData(CPDFSDK_PageView* pPageView, | 135 void CFFL_ListBox::GetActionData(CPDFSDK_PageView* pPageView, |
| 151 CPDF_AAction::AActionType type, | 136 CPDF_AAction::AActionType type, |
| 152 PDFSDK_FieldAction& fa) { | 137 PDFSDK_FieldAction& fa) { |
| 153 switch (type) { | 138 switch (type) { |
| 154 case CPDF_AAction::Validate: | 139 case CPDF_AAction::Validate: |
| 155 if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) { | 140 if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) { |
| 156 fa.sValue = L""; | 141 fa.sValue = L""; |
| 157 } else { | 142 } else { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 RestoreState(pPageView); | 199 RestoreState(pPageView); |
| 215 pRet = GetPDFWindow(pPageView, FALSE); | 200 pRet = GetPDFWindow(pPageView, FALSE); |
| 216 } else { | 201 } else { |
| 217 pRet = GetPDFWindow(pPageView, TRUE); | 202 pRet = GetPDFWindow(pPageView, TRUE); |
| 218 } | 203 } |
| 219 | 204 |
| 220 m_pWidget->UpdateField(); | 205 m_pWidget->UpdateField(); |
| 221 | 206 |
| 222 return pRet; | 207 return pRet; |
| 223 } | 208 } |
| OLD | NEW |