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/include/formfiller/FFL_CBA_Fontmap.h" | 7 #include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" |
8 #include "fpdfsdk/include/formfiller/FFL_ComboBox.h" | 8 #include "fpdfsdk/include/formfiller/FFL_ComboBox.h" |
9 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 9 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
10 #include "fpdfsdk/include/formfiller/FFL_IFormFiller.h" | 10 #include "fpdfsdk/include/formfiller/FFL_IFormFiller.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 m_pWidget->GetPDFPage(); | 130 m_pWidget->GetPDFPage(); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 void CFFL_ComboBox::GetActionData(CPDFSDK_PageView* pPageView, | 134 void CFFL_ComboBox::GetActionData(CPDFSDK_PageView* pPageView, |
135 CPDF_AAction::AActionType type, | 135 CPDF_AAction::AActionType type, |
136 PDFSDK_FieldAction& fa) { | 136 PDFSDK_FieldAction& fa) { |
137 switch (type) { | 137 switch (type) { |
138 case CPDF_AAction::KeyStroke: | 138 case CPDF_AAction::KeyStroke: |
139 if (CPWL_ComboBox* pComboBox = | 139 if (CPWL_ComboBox* pComboBox = |
140 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { | 140 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) { |
141 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { | 141 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) { |
142 fa.bFieldFull = pEdit->IsTextFull(); | 142 fa.bFieldFull = pEdit->IsTextFull(); |
143 int nSelStart = 0; | 143 int nSelStart = 0; |
144 int nSelEnd = 0; | 144 int nSelEnd = 0; |
145 pEdit->GetSel(nSelStart, nSelEnd); | 145 pEdit->GetSel(nSelStart, nSelEnd); |
146 fa.nSelEnd = nSelEnd; | 146 fa.nSelEnd = nSelEnd; |
147 fa.nSelStart = nSelStart; | 147 fa.nSelStart = nSelStart; |
148 fa.sValue = pEdit->GetText(); | 148 fa.sValue = pEdit->GetText(); |
149 fa.sChangeEx = GetSelectExportText(); | 149 fa.sChangeEx = GetSelectExportText(); |
150 | 150 |
151 if (fa.bFieldFull) { | 151 if (fa.bFieldFull) { |
152 fa.sChange = L""; | 152 fa.sChange = L""; |
153 fa.sChangeEx = L""; | 153 fa.sChangeEx = L""; |
154 } | 154 } |
155 } | 155 } |
156 } | 156 } |
157 break; | 157 break; |
158 case CPDF_AAction::Validate: | 158 case CPDF_AAction::Validate: |
159 if (CPWL_ComboBox* pComboBox = | 159 if (CPWL_ComboBox* pComboBox = |
160 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { | 160 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) { |
161 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { | 161 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) { |
162 fa.sValue = pEdit->GetText(); | 162 fa.sValue = pEdit->GetText(); |
163 } | 163 } |
164 } | 164 } |
165 break; | 165 break; |
166 case CPDF_AAction::LoseFocus: | 166 case CPDF_AAction::LoseFocus: |
167 case CPDF_AAction::GetFocus: | 167 case CPDF_AAction::GetFocus: |
168 ASSERT(m_pWidget != NULL); | 168 ASSERT(m_pWidget != NULL); |
169 fa.sValue = m_pWidget->GetValue(); | 169 fa.sValue = m_pWidget->GetValue(); |
170 break; | 170 break; |
171 default: | 171 default: |
172 break; | 172 break; |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, | 176 void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, |
177 CPDF_AAction::AActionType type, | 177 CPDF_AAction::AActionType type, |
178 const PDFSDK_FieldAction& fa) { | 178 const PDFSDK_FieldAction& fa) { |
179 switch (type) { | 179 switch (type) { |
180 case CPDF_AAction::KeyStroke: | 180 case CPDF_AAction::KeyStroke: |
181 if (CPWL_ComboBox* pComboBox = | 181 if (CPWL_ComboBox* pComboBox = |
182 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { | 182 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) { |
183 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { | 183 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) { |
184 pEdit->SetSel(fa.nSelStart, fa.nSelEnd); | 184 pEdit->SetSel(fa.nSelStart, fa.nSelEnd); |
185 pEdit->ReplaceSel(fa.sChange.c_str()); | 185 pEdit->ReplaceSel(fa.sChange.c_str()); |
186 } | 186 } |
187 } | 187 } |
188 break; | 188 break; |
189 default: | 189 default: |
190 break; | 190 break; |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 FX_BOOL CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, | 194 FX_BOOL CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, |
195 const PDFSDK_FieldAction& faOld, | 195 const PDFSDK_FieldAction& faOld, |
196 const PDFSDK_FieldAction& faNew) { | 196 const PDFSDK_FieldAction& faNew) { |
197 switch (type) { | 197 switch (type) { |
198 case CPDF_AAction::KeyStroke: | 198 case CPDF_AAction::KeyStroke: |
199 return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || | 199 return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || |
200 faOld.nSelStart != faNew.nSelStart || | 200 faOld.nSelStart != faNew.nSelStart || |
201 faOld.sChange != faNew.sChange; | 201 faOld.sChange != faNew.sChange; |
202 default: | 202 default: |
203 break; | 203 break; |
204 } | 204 } |
205 | 205 |
206 return FALSE; | 206 return FALSE; |
207 } | 207 } |
208 | 208 |
209 void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView) { | 209 void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView) { |
210 ASSERT(pPageView != NULL); | 210 ASSERT(pPageView != NULL); |
211 | 211 |
212 if (CPWL_ComboBox* pComboBox = | 212 if (CPWL_ComboBox* pComboBox = |
213 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { | 213 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) { |
214 m_State.nIndex = pComboBox->GetSelect(); | 214 m_State.nIndex = pComboBox->GetSelect(); |
215 | 215 |
216 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { | 216 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) { |
217 pEdit->GetSel(m_State.nStart, m_State.nEnd); | 217 pEdit->GetSel(m_State.nStart, m_State.nEnd); |
218 m_State.sValue = pEdit->GetText(); | 218 m_State.sValue = pEdit->GetText(); |
219 } | 219 } |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) { | 223 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) { |
224 ASSERT(pPageView != NULL); | 224 ASSERT(pPageView != NULL); |
225 | 225 |
226 if (CPWL_ComboBox* pComboBox = | 226 if (CPWL_ComboBox* pComboBox = |
227 (CPWL_ComboBox*)GetPDFWindow(pPageView, TRUE)) { | 227 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, TRUE))) { |
228 if (m_State.nIndex >= 0) | 228 if (m_State.nIndex >= 0) |
229 pComboBox->SetSelect(m_State.nIndex); | 229 pComboBox->SetSelect(m_State.nIndex); |
230 else { | 230 else { |
231 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { | 231 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) { |
232 pEdit->SetText(m_State.sValue.c_str()); | 232 pEdit->SetText(m_State.sValue.c_str()); |
233 pEdit->SetSel(m_State.nStart, m_State.nEnd); | 233 pEdit->SetSel(m_State.nStart, m_State.nEnd); |
234 } | 234 } |
235 } | 235 } |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, | 239 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, |
240 FX_BOOL bRestoreValue) { | 240 FX_BOOL bRestoreValue) { |
241 if (bRestoreValue) | 241 if (bRestoreValue) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 if (nExport >= 0) { | 299 if (nExport >= 0) { |
300 if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) { | 300 if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) { |
301 swRet = pFormField->GetOptionValue(nExport); | 301 swRet = pFormField->GetOptionValue(nExport); |
302 if (swRet.IsEmpty()) | 302 if (swRet.IsEmpty()) |
303 swRet = pFormField->GetOptionLabel(nExport); | 303 swRet = pFormField->GetOptionLabel(nExport); |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 return swRet; | 307 return swRet; |
308 } | 308 } |
OLD | NEW |