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

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

Issue 453133004: clang-format all code (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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
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 "../../include/formfiller/FormFiller.h" 7 #include "../../include/formfiller/FormFiller.h"
8 #include "../../include/formfiller/FFL_FormFiller.h" 8 #include "../../include/formfiller/FFL_FormFiller.h"
9 #include "../../include/formfiller/FFL_IFormFiller.h" 9 #include "../../include/formfiller/FFL_IFormFiller.h"
10 #include "../../include/formfiller/FFL_CBA_Fontmap.h" 10 #include "../../include/formfiller/FFL_CBA_Fontmap.h"
11 #include "../../include/formfiller/FFL_ComboBox.h" 11 #include "../../include/formfiller/FFL_ComboBox.h"
12 12
13 13 /* ------------------------------- CFFL_ComboBox -------------------------------
14 /* ------------------------------- CFFL_ComboBox ------------------------------- */ 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 { 18 // m_pFontMap = new CBA_FontMap( pAnnot, GetSystemHandler() );
19 //m_pFontMap = new CBA_FontMap( pAnnot, GetSystemHandler() ); 19 m_State.nIndex = 0;
20 m_State.nIndex = 0; 20 m_State.nStart = 0;
21 m_State.nStart = 0; 21 m_State.nEnd = 0;
22 m_State.nEnd = 0; 22 }
23 } 23
24 24 CFFL_ComboBox::~CFFL_ComboBox() {
25 CFFL_ComboBox::~CFFL_ComboBox() 25 if (m_pFontMap) {
26 { 26 delete m_pFontMap;
27 if (m_pFontMap) 27 m_pFontMap = NULL;
28 { 28 }
29 delete m_pFontMap; 29
30 m_pFontMap = NULL; 30 // for (int i=0,sz=m_IMBox.GetSize(); i<sz; i++)
31 } 31 // {
32 32 // delete m_IMBox.GetAt(i);
33 // for (int i=0,sz=m_IMBox.GetSize(); i<sz; i++) 33 // }
34 // { 34 //
35 // delete m_IMBox.GetAt(i); 35 // m_IMBox.RemoveAll();
36 // } 36 }
37 // 37
38 // m_IMBox.RemoveAll(); 38 PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() {
39 } 39 PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
40 40
41 PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() 41 ASSERT(m_pWidget != NULL);
42 { 42
43 PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam(); 43 int nFlags = m_pWidget->GetFieldFlags();
44 44
45 ASSERT(m_pWidget != NULL); 45 if (nFlags & FIELDFLAG_EDIT) {
46 46 cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
47 int nFlags = m_pWidget->GetFieldFlags(); 47 }
48 48
49 if (nFlags & FIELDFLAG_EDIT) 49 /*
50 { 50 if (nFlags & FIELDFLAG_COMMITONSELCHANGE)
51 cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT; 51 {
52 } 52 m_bCommitOnSelectChange = TRUE;
53 53 }
54 /* 54 */
55 if (nFlags & FIELDFLAG_COMMITONSELCHANGE) 55
56 { 56 if (!m_pFontMap) {
57 m_bCommitOnSelectChange = TRUE; 57 ASSERT(this->m_pApp != NULL);
58 } 58 m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler());
59 */ 59 m_pFontMap->Initial();
60 60 }
61 if (!m_pFontMap) 61
62 { 62 cp.pFontMap = m_pFontMap;
63 ASSERT(this->m_pApp != NULL); 63 cp.pFocusHandler = this;
64 m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler()); 64
65 m_pFontMap->Initial(); 65 return cp;
66 } 66 }
67 67
68 cp.pFontMap = m_pFontMap; 68 CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp,
69 cp.pFocusHandler = this; 69 CPDFSDK_PageView* pPageView) {
70 70 CPWL_ComboBox* pWnd = new CPWL_ComboBox();
71 return cp; 71 pWnd->AttachFFLData(this);
72 } 72 pWnd->Create(cp);
73 73
74 CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageVie w* pPageView) 74 ASSERT(m_pApp != NULL);
75 { 75 CFFL_IFormFiller* pFormFiller = m_pApp->GetIFormFiller();
76 CPWL_ComboBox * pWnd = new CPWL_ComboBox(); 76 pWnd->SetFillerNotify(pFormFiller);
77 pWnd->AttachFFLData(this); 77
78 pWnd->Create(cp); 78 ASSERT(m_pWidget != NULL);
79 79 FX_INT32 nCurSel = m_pWidget->GetSelectedIndex(0);
80 ASSERT(m_pApp != NULL); 80
81 CFFL_IFormFiller* pFormFiller = m_pApp->GetIFormFiller(); 81 CFX_WideString swText;
82 pWnd->SetFillerNotify(pFormFiller); 82
83 83 if (nCurSel < 0)
84 ASSERT(m_pWidget != NULL); 84 swText = m_pWidget->GetValue();
85 FX_INT32 nCurSel = m_pWidget->GetSelectedIndex(0); 85 else
86 86 swText = m_pWidget->GetOptionLabel(nCurSel);
87 CFX_WideString swText; 87
88 88 for (FX_INT32 i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) {
89 if (nCurSel < 0) 89 pWnd->AddString(m_pWidget->GetOptionLabel(i));
90 swText = m_pWidget->GetValue(); 90 }
91 else 91
92 swText = m_pWidget->GetOptionLabel(nCurSel); 92 pWnd->SetSelect(nCurSel);
93 93 pWnd->SetText(swText);
94 for (FX_INT32 i=0,sz=m_pWidget->CountOptions(); i<sz; i++) 94
95 { 95 return pWnd;
96 pWnd->AddString(m_pWidget->GetOptionLabel(i)); 96 }
97 } 97
98 98 FX_BOOL CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot,
99 pWnd->SetSelect(nCurSel); 99 FX_UINT nChar,
100 pWnd->SetText(swText); 100 FX_UINT nFlags) {
101 101 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
102 return pWnd; 102 }
103 } 103
104 104 FX_BOOL CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView) {
105 105 if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
106 FX_BOOL CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFla gs) 106 FX_INT32 nCurSel = pWnd->GetSelect();
107 { 107
108 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); 108 ASSERT(m_pWidget != NULL);
109 } 109
110 110 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT) {
111 FX_BOOL CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView) 111 if (nCurSel >= 0) {
112 { 112 return nCurSel != m_pWidget->GetSelectedIndex(0);
113 if (CPWL_ComboBox * pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE )) 113 } else {
114 { 114 return pWnd->GetText() != m_pWidget->GetValue();
115 FX_INT32 nCurSel = pWnd->GetSelect(); 115 }
116 116 } else {
117 ASSERT(m_pWidget != NULL); 117 return nCurSel != m_pWidget->GetSelectedIndex(0);
118 118 }
119 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT) 119 }
120 { 120
121 if (nCurSel >= 0) 121 return FALSE;
122 { 122 }
123 return nCurSel != m_pWidget->GetSelectedIndex(0) ; 123
124 } 124 void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView) {
125 else 125 ASSERT(m_pWidget != NULL);
126 { 126
127 return pWnd->GetText() != m_pWidget->GetValue(); 127 if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
128 } 128 CFX_WideString swText = pWnd->GetText();
129 } 129 FX_INT32 nCurSel = pWnd->GetSelect();
130 else 130
131 { 131 // mantis:0004157
132 return nCurSel != m_pWidget->GetSelectedIndex(0); 132 FX_BOOL bSetValue = TRUE;
133 } 133
134 } 134 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT) {
135 135 if (nCurSel >= 0) {
136 return FALSE; 136 if (swText != m_pWidget->GetOptionLabel(nCurSel))
137 } 137 bSetValue = TRUE;
138 138 else
139 void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView) 139 bSetValue = FALSE;
140 { 140 } else
141 ASSERT(m_pWidget != NULL); 141 bSetValue = TRUE;
142 142 } else
143 if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE) ) 143 bSetValue = FALSE;
144 { 144
145 CFX_WideString swText = pWnd->GetText(); 145 CFX_WideString sOldValue;
146 FX_INT32 nCurSel = pWnd->GetSelect(); 146
147 147 if (bSetValue) {
148 //mantis:0004157 148 sOldValue = m_pWidget->GetValue();
149 FX_BOOL bSetValue = TRUE; 149 m_pWidget->SetValue(swText, FALSE);
150 150 } else {
151 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT) 151 m_pWidget->GetSelectedIndex(0);
152 { 152 m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE);
153 if (nCurSel >= 0) 153 }
154 { 154
155 if (swText != m_pWidget->GetOptionLabel(nCurSel) ) 155 m_pWidget->ResetFieldAppearance(TRUE);
156 bSetValue = TRUE; 156 m_pWidget->UpdateField();
157 else 157 SetChangeMark();
158 bSetValue = FALSE; 158
159 } 159 m_pWidget->GetPDFPage();
160 else 160 }
161 bSetValue = TRUE; 161 }
162 } 162
163 else 163 void CFFL_ComboBox::GetActionData(CPDFSDK_PageView* pPageView,
164 bSetValue = FALSE; 164 CPDF_AAction::AActionType type,
165 165 PDFSDK_FieldAction& fa) {
166 CFX_WideString sOldValue; 166 switch (type) {
167 167 case CPDF_AAction::KeyStroke:
168 168 if (CPWL_ComboBox* pComboBox =
169 if (bSetValue) 169 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
170 { 170 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) {
171 sOldValue = m_pWidget->GetValue(); 171 fa.bFieldFull = pEdit->IsTextFull();
172 m_pWidget->SetValue(swText, FALSE); 172 int nSelStart = 0;
173 } 173 int nSelEnd = 0;
174 else 174 pEdit->GetSel(nSelStart, nSelEnd);
175 { 175 fa.nSelEnd = nSelEnd;
176 m_pWidget->GetSelectedIndex(0); 176 fa.nSelStart = nSelStart;
177 m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE); 177 fa.sValue = pEdit->GetText();
178 } 178 fa.sChangeEx = GetSelectExportText();
179 179
180 m_pWidget->ResetFieldAppearance(TRUE); 180 if (fa.bFieldFull) {
181 m_pWidget->UpdateField(); 181 fa.sChange = L"";
182 SetChangeMark(); 182 fa.sChangeEx = L"";
183 183 }
184 m_pWidget->GetPDFPage(); 184 }
185 185 }
186 186 break;
187 } 187 case CPDF_AAction::Validate:
188 } 188 if (CPWL_ComboBox* pComboBox =
189 189 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
190 void CFFL_ComboBox::GetActionData( CPDFSDK_PageView* pPageView, CPDF_AAction::A ActionType type, PDFSDK_FieldAction& fa) 190 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) {
191 { 191 fa.sValue = pEdit->GetText();
192 switch (type) 192 }
193 { 193 }
194 case CPDF_AAction::KeyStroke: 194 break;
195 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPag eView, FALSE)) 195 case CPDF_AAction::LoseFocus:
196 { 196 case CPDF_AAction::GetFocus:
197 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) 197 ASSERT(m_pWidget != NULL);
198 { 198 fa.sValue = m_pWidget->GetValue();
199 fa.bFieldFull = pEdit->IsTextFull(); 199 break;
200 int nSelStart = 0; 200 default:
201 int nSelEnd = 0; 201 break;
202 pEdit->GetSel(nSelStart, nSelEnd); 202 }
203 fa.nSelEnd = nSelEnd; 203 }
204 fa.nSelStart = nSelStart; 204
205 fa.sValue = pEdit->GetText(); 205 void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView,
206 fa.sChangeEx = GetSelectExportText(); 206 CPDF_AAction::AActionType type,
207 207 const PDFSDK_FieldAction& fa) {
208 if (fa.bFieldFull) 208 switch (type) {
209 { 209 case CPDF_AAction::KeyStroke:
210 fa.sChange = L""; 210 if (CPWL_ComboBox* pComboBox =
211 fa.sChangeEx = L""; 211 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
212 } 212 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) {
213 } 213 pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
214 } 214 pEdit->ReplaceSel(fa.sChange);
215 break; 215 }
216 case CPDF_AAction::Validate: 216 }
217 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPag eView, FALSE)) 217 break;
218 { 218 default:
219 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) 219 break;
220 { 220 }
221 fa.sValue = pEdit->GetText(); 221 }
222 } 222
223 } 223 FX_BOOL CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type,
224 break; 224 const PDFSDK_FieldAction& faOld,
225 case CPDF_AAction::LoseFocus: 225 const PDFSDK_FieldAction& faNew) {
226 case CPDF_AAction::GetFocus: 226 switch (type) {
227 ASSERT(m_pWidget != NULL); 227 case CPDF_AAction::KeyStroke:
228 fa.sValue = m_pWidget->GetValue(); 228 return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) ||
229 break; 229 faOld.nSelStart != faNew.nSelStart ||
230 default: 230 faOld.sChange != faNew.sChange;
231 break; 231 default:
232 } 232 break;
233 } 233 }
234 234
235 235 return FALSE;
236 236 }
237 void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AAc tionType type, 237
238 const PD FSDK_FieldAction& fa) 238 void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView) {
239 { 239 ASSERT(pPageView != NULL);
240 switch (type) 240
241 { 241 if (CPWL_ComboBox* pComboBox =
242 case CPDF_AAction::KeyStroke: 242 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
243 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPag eView, FALSE)) 243 m_State.nIndex = pComboBox->GetSelect();
244 { 244
245 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) 245 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) {
246 { 246 pEdit->GetSel(m_State.nStart, m_State.nEnd);
247 pEdit->SetSel(fa.nSelStart, fa.nSelEnd); 247 m_State.sValue = pEdit->GetText();
248 pEdit->ReplaceSel(fa.sChange); 248 }
249 } 249 }
250 } 250 }
251 break; 251
252 default: 252 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) {
253 break; 253 ASSERT(pPageView != NULL);
254 } 254
255 } 255 if (CPWL_ComboBox* pComboBox =
256 256 (CPWL_ComboBox*)GetPDFWindow(pPageView, TRUE)) {
257 FX_BOOL CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld, 257 if (m_State.nIndex >= 0)
258 const PD FSDK_FieldAction& faNew) 258 pComboBox->SetSelect(m_State.nIndex);
259 { 259 else {
260 switch (type) 260 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) {
261 { 261 pEdit->SetText(m_State.sValue);
262 case CPDF_AAction::KeyStroke: 262 pEdit->SetSel(m_State.nStart, m_State.nEnd);
263 return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || faOld.nSelStart != faNew.nSelStart || 263 }
264 faOld.sChange != faNew.sChange; 264 }
265 default: 265 }
266 break; 266 }
267 } 267
268 268 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView,
269 return FALSE; 269 FX_BOOL bRestoreValue) {
270 } 270 if (bRestoreValue)
271 271 SaveState(pPageView);
272 void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView) 272
273 { 273 DestroyPDFWindow(pPageView);
274 ASSERT(pPageView != NULL); 274
275 275 CPWL_Wnd* pRet = NULL;
276 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, F ALSE)) 276
277 { 277 if (bRestoreValue) {
278 m_State.nIndex = pComboBox->GetSelect(); 278 RestoreState(pPageView);
279 279 pRet = this->GetPDFWindow(pPageView, FALSE);
280 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) 280 } else
281 { 281 pRet = this->GetPDFWindow(pPageView, TRUE);
282 pEdit->GetSel(m_State.nStart, m_State.nEnd); 282
283 m_State.sValue = pEdit->GetText(); 283 m_pWidget->UpdateField();
284 } 284
285 } 285 return pRet;
286 } 286 }
287 287
288 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) 288 void CFFL_ComboBox::OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag) {
289 { 289 ASSERT(m_pWidget != NULL);
290 ASSERT(pPageView != NULL); 290
291 291 int nFlags = m_pWidget->GetFieldFlags();
292 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, T RUE)) 292
293 { 293 if (nFlags & FIELDFLAG_COMMITONSELCHANGE) {
294 if (m_State.nIndex >= 0) 294 if (m_bValid) {
295 pComboBox->SetSelect(m_State.nIndex); 295 CPDFSDK_PageView* pPageView = this->GetCurPageView();
296 else 296 ASSERT(pPageView != NULL);
297 { 297
298 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) 298 if (CommitData(pPageView, nFlag)) {
299 { 299 DestroyPDFWindow(pPageView);
300 pEdit->SetText(m_State.sValue); 300 m_bValid = FALSE;
301 pEdit->SetSel(m_State.nStart, m_State.nEnd); 301 }
302 } 302 }
303 } 303 }
304 } 304 }
305 } 305
306 306 void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) {
307 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRe storeValue) 307 ASSERT(m_pApp != NULL);
308 { 308
309 if (bRestoreValue) 309 ASSERT(pWnd != NULL);
310 SaveState(pPageView); 310
311 311 if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) {
312 DestroyPDFWindow(pPageView); 312 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
313 313 pEdit->SetCharSet(134);
314 CPWL_Wnd* pRet = NULL; 314 pEdit->SetCodePage(936);
315 315
316 if (bRestoreValue) 316 pEdit->SetReadyToInput();
317 { 317 CFX_WideString wsText = pEdit->GetText();
318 RestoreState(pPageView); 318 int nCharacters = wsText.GetLength();
319 pRet = this->GetPDFWindow(pPageView, FALSE); 319 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode();
320 } 320 unsigned short* pBuffer = (unsigned short*)(FX_LPCSTR) bsUTFText;
321 else 321 m_pApp->FFI_OnSetFieldInputFocus(
322 pRet = this->GetPDFWindow(pPageView, TRUE); 322 m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE);
323 323
324 m_pWidget->UpdateField(); 324 pEdit->SetEditNotify(this);
325 325 }
326 return pRet; 326 }
327 } 327
328 328 void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd) {
329 void CFFL_ComboBox::OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag) 329 ASSERT(m_pApp != NULL);
330 { 330 }
331 ASSERT(m_pWidget != NULL); 331
332 332 FX_BOOL CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument) {
333 int nFlags = m_pWidget->GetFieldFlags(); 333 ASSERT(pDocument != NULL);
334 334
335 if (nFlags & FIELDFLAG_COMMITONSELCHANGE) 335 return FALSE;
336 { 336 }
337 if (m_bValid) 337
338 { 338 FX_BOOL CFFL_ComboBox::CanCut(CPDFSDK_Document* pDocument) {
339 CPDFSDK_PageView* pPageView = this->GetCurPageView(); 339 ASSERT(pDocument != NULL);
340 ASSERT(pPageView != NULL); 340
341 341 return FALSE;
342 if (CommitData(pPageView, nFlag)) 342 }
343 { 343
344 DestroyPDFWindow(pPageView); 344 FX_BOOL CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument) {
345 m_bValid = FALSE; 345 ASSERT(pDocument != NULL);
346 } 346
347 } 347 return FALSE;
348 } 348 }
349 } 349
350 350 void CFFL_ComboBox::DoCopy(CPDFSDK_Document* pDocument) {
351 void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) 351 ASSERT(pDocument != NULL);
352 { 352 }
353 ASSERT(m_pApp != NULL); 353
354 354 void CFFL_ComboBox::DoCut(CPDFSDK_Document* pDocument) {
355 ASSERT(pWnd != NULL); 355 ASSERT(pDocument != NULL);
356 356 }
357 if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) 357
358 { 358 void CFFL_ComboBox::DoPaste(CPDFSDK_Document* pDocument) {
359 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; 359 ASSERT(pDocument != NULL);
360 pEdit->SetCharSet(134); 360 }
361 pEdit->SetCodePage(936); 361
362 362 void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit) {
363 pEdit->SetReadyToInput(); 363 ASSERT(pEdit != NULL);
364 CFX_WideString wsText = pEdit->GetText(); 364 }
365 int nCharacters = wsText.GetLength(); 365
366 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); 366 CFX_WideString CFFL_ComboBox::GetSelectExportText() {
367 unsigned short* pBuffer = (unsigned short*)(FX_LPCSTR)bsUTFText; 367 CFX_WideString swRet;
368 m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuf fer, nCharacters, TRUE); 368
369 369 int nExport = -1;
370 pEdit->SetEditNotify(this); 370 CPDFSDK_PageView* pPageView = GetCurPageView();
371 } 371 if (CPWL_ComboBox* pComboBox =
372 } 372 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
373 373 nExport = pComboBox->GetSelect();
374 void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd) 374 }
375 { 375
376 ASSERT(m_pApp != NULL); 376 if (nExport >= 0) {
377 } 377 if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) {
378 378 swRet = pFormField->GetOptionValue(nExport);
379 FX_BOOL CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument) 379 if (swRet.IsEmpty())
380 { 380 swRet = pFormField->GetOptionLabel(nExport);
381 ASSERT(pDocument != NULL); 381 }
382 382 }
383 return FALSE; 383
384 } 384 return swRet;
385 385 }
386 FX_BOOL CFFL_ComboBox::CanCut(CPDFSDK_Document* pDocument)
387 {
388 ASSERT(pDocument != NULL);
389
390 return FALSE;
391 }
392
393 FX_BOOL CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument)
394 {
395 ASSERT(pDocument != NULL);
396
397 return FALSE;
398 }
399
400 void CFFL_ComboBox::DoCopy(CPDFSDK_Document* pDocument)
401 {
402 ASSERT(pDocument != NULL);
403 }
404
405 void CFFL_ComboBox::DoCut(CPDFSDK_Document* pDocument)
406 {
407 ASSERT(pDocument != NULL);
408 }
409
410 void CFFL_ComboBox::DoPaste(CPDFSDK_Document* pDocument)
411 {
412 ASSERT(pDocument != NULL);
413 }
414
415 void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit)
416 {
417 ASSERT(pEdit != NULL);
418 }
419
420 CFX_WideString CFFL_ComboBox::GetSelectExportText()
421 {
422 CFX_WideString swRet;
423
424 int nExport = -1;
425 CPDFSDK_PageView *pPageView = GetCurPageView();
426 if (CPWL_ComboBox * pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
427 {
428 nExport = pComboBox->GetSelect();
429 }
430
431 if (nExport >= 0)
432 {
433 if (CPDF_FormField * pFormField = m_pWidget->GetFormField())
434 {
435 swRet = pFormField->GetOptionValue(nExport);
436 if (swRet.IsEmpty())
437 swRet = pFormField->GetOptionLabel(nExport);
438 }
439 }
440
441 return swRet;
442 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698