Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: fpdfsdk/src/formfiller/FFL_ComboBox.cpp

Issue 1566583002: Merge to XFA: Remove header files that only have includes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Fix XFA Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_CheckBox.cpp ('k') | fpdfsdk/src/formfiller/FFL_FormFiller.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_ComboBox.h"
8
7 #include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" 9 #include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h"
8 #include "fpdfsdk/include/formfiller/FFL_ComboBox.h"
9 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" 10 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
10 #include "fpdfsdk/include/formfiller/FFL_IFormFiller.h" 11 #include "fpdfsdk/include/formfiller/FFL_IFormFiller.h"
11 #include "fpdfsdk/include/formfiller/FormFiller.h" 12 #include "fpdfsdk/include/fsdk_common.h"
12 13 #include "fpdfsdk/include/fsdk_mgr.h"
13 /* ------------------------------- CFFL_ComboBox ------------------------------- 14 #include "fpdfsdk/include/pdfwindow/PWL_ComboBox.h"
14 */
15 15
16 CFFL_ComboBox::CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) 16 CFFL_ComboBox::CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot)
17 : CFFL_FormFiller(pApp, pAnnot), m_pFontMap(NULL) { 17 : CFFL_FormFiller(pApp, pAnnot), m_pFontMap(NULL) {
18 m_State.nIndex = 0; 18 m_State.nIndex = 0;
19 m_State.nStart = 0; 19 m_State.nStart = 0;
20 m_State.nEnd = 0; 20 m_State.nEnd = 0;
21 } 21 }
22 22
23 CFFL_ComboBox::~CFFL_ComboBox() { 23 CFFL_ComboBox::~CFFL_ComboBox() {
24 delete m_pFontMap; 24 delete m_pFontMap;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)) 80 if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT))
81 return nCurSel != m_pWidget->GetSelectedIndex(0); 81 return nCurSel != m_pWidget->GetSelectedIndex(0);
82 82
83 if (nCurSel >= 0) 83 if (nCurSel >= 0)
84 return nCurSel != m_pWidget->GetSelectedIndex(0); 84 return nCurSel != m_pWidget->GetSelectedIndex(0);
85 85
86 return pWnd->GetText() != m_pWidget->GetValue(); 86 return pWnd->GetText() != m_pWidget->GetValue();
87 } 87 }
88 88
89 void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView) { 89 void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView) {
90 if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { 90 CPWL_ComboBox* pWnd =
91 CFX_WideString swText = pWnd->GetText(); 91 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE));
92 int32_t nCurSel = pWnd->GetSelect(); 92 if (!pWnd)
93 return;
93 94
94 // mantis:0004157 95 CFX_WideString swText = pWnd->GetText();
95 FX_BOOL bSetValue = TRUE; 96 int32_t nCurSel = pWnd->GetSelect();
96 97
97 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT) { 98 bool bSetValue = false;
98 if (nCurSel >= 0) {
99 if (swText != m_pWidget->GetOptionLabel(nCurSel))
100 bSetValue = TRUE;
101 else
102 bSetValue = FALSE;
103 } else
104 bSetValue = TRUE;
105 } else
106 bSetValue = FALSE;
107 99
108 CFX_WideString sOldValue; 100 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
101 bSetValue = (nCurSel < 0) || (swText != m_pWidget->GetOptionLabel(nCurSel));
109 102
110 if (bSetValue) { 103 if (bSetValue) {
111 sOldValue = m_pWidget->GetValue(); 104 m_pWidget->SetValue(swText, FALSE);
112 m_pWidget->SetValue(swText, FALSE); 105 } else {
113 } else { 106 m_pWidget->GetSelectedIndex(0);
114 m_pWidget->GetSelectedIndex(0); 107 m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE);
115 m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE); 108 }
116 }
117 109
118 m_pWidget->ResetFieldAppearance(TRUE); 110 m_pWidget->ResetFieldAppearance(TRUE);
119 m_pWidget->UpdateField(); 111 m_pWidget->UpdateField();
120 SetChangeMark(); 112 SetChangeMark();
121 113
122 m_pWidget->GetPDFPage(); 114 m_pWidget->GetPDFPage();
123 }
124 } 115 }
125 116
126 void CFFL_ComboBox::GetActionData(CPDFSDK_PageView* pPageView, 117 void CFFL_ComboBox::GetActionData(CPDFSDK_PageView* pPageView,
127 CPDF_AAction::AActionType type, 118 CPDF_AAction::AActionType type,
128 PDFSDK_FieldAction& fa) { 119 PDFSDK_FieldAction& fa) {
129 switch (type) { 120 switch (type) {
130 case CPDF_AAction::KeyStroke: 121 case CPDF_AAction::KeyStroke:
131 if (CPWL_ComboBox* pComboBox = 122 if (CPWL_ComboBox* pComboBox =
132 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) { 123 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
133 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) { 124 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 m_State.sValue = pEdit->GetText(); 200 m_State.sValue = pEdit->GetText();
210 } 201 }
211 } 202 }
212 } 203 }
213 204
214 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) { 205 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) {
215 ASSERT(pPageView); 206 ASSERT(pPageView);
216 207
217 if (CPWL_ComboBox* pComboBox = 208 if (CPWL_ComboBox* pComboBox =
218 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, TRUE))) { 209 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, TRUE))) {
219 if (m_State.nIndex >= 0) 210 if (m_State.nIndex >= 0) {
220 pComboBox->SetSelect(m_State.nIndex); 211 pComboBox->SetSelect(m_State.nIndex);
221 else { 212 } else {
222 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) { 213 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
223 pEdit->SetText(m_State.sValue.c_str()); 214 pEdit->SetText(m_State.sValue.c_str());
224 pEdit->SetSel(m_State.nStart, m_State.nEnd); 215 pEdit->SetSel(m_State.nStart, m_State.nEnd);
225 } 216 }
226 } 217 }
227 } 218 }
228 } 219 }
229 220
230 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, 221 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView,
231 FX_BOOL bRestoreValue) { 222 FX_BOOL bRestoreValue) {
232 if (bRestoreValue) 223 if (bRestoreValue)
233 SaveState(pPageView); 224 SaveState(pPageView);
234 225
235 DestroyPDFWindow(pPageView); 226 DestroyPDFWindow(pPageView);
236 227
237 CPWL_Wnd* pRet = NULL; 228 CPWL_Wnd* pRet = NULL;
238 229
239 if (bRestoreValue) { 230 if (bRestoreValue) {
240 RestoreState(pPageView); 231 RestoreState(pPageView);
241 pRet = GetPDFWindow(pPageView, FALSE); 232 pRet = GetPDFWindow(pPageView, FALSE);
242 } else 233 } else {
243 pRet = GetPDFWindow(pPageView, TRUE); 234 pRet = GetPDFWindow(pPageView, TRUE);
235 }
244 236
245 m_pWidget->UpdateField(); 237 m_pWidget->UpdateField();
246 238
247 return pRet; 239 return pRet;
248 } 240 }
249 241
250 #ifdef PDF_ENABLE_XFA 242 #ifdef PDF_ENABLE_XFA
251 FX_BOOL CFFL_ComboBox::IsFieldFull(CPDFSDK_PageView* pPageView) { 243 FX_BOOL CFFL_ComboBox::IsFieldFull(CPDFSDK_PageView* pPageView) {
252 if (CPWL_ComboBox* pComboBox = 244 if (CPWL_ComboBox* pComboBox =
253 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) { 245 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if (nExport >= 0) { 291 if (nExport >= 0) {
300 if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) { 292 if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) {
301 swRet = pFormField->GetOptionValue(nExport); 293 swRet = pFormField->GetOptionValue(nExport);
302 if (swRet.IsEmpty()) 294 if (swRet.IsEmpty())
303 swRet = pFormField->GetOptionLabel(nExport); 295 swRet = pFormField->GetOptionLabel(nExport);
304 } 296 }
305 } 297 }
306 298
307 return swRet; 299 return swRet;
308 } 300 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_CheckBox.cpp ('k') | fpdfsdk/src/formfiller/FFL_FormFiller.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698