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

Side by Side Diff: xfa/fxfa/app/xfa_ffnotify.cpp

Issue 2089443002: Convert XFA_ELEMENT to an enum class (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: More unknown checks Created 4 years, 6 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 | « xfa/fxfa/app/xfa_fffield.cpp ('k') | xfa/fxfa/app/xfa_ffpageview.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 "xfa/fxfa/app/xfa_ffnotify.h" 7 #include "xfa/fxfa/app/xfa_ffnotify.h"
8 8
9 #include "fxjse/include/cfxjse_value.h" 9 #include "fxjse/include/cfxjse_value.h"
10 #include "xfa/fxfa/app/xfa_ffbarcode.h" 10 #include "xfa/fxfa/app/xfa_ffbarcode.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout()); 46 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout());
47 if (pDocView) 47 if (pDocView)
48 pDocView->OnPageEvent(pSender, dwEvent); 48 pDocView->OnPageEvent(pSender, dwEvent);
49 } 49 }
50 50
51 void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetData* pSender, 51 void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetData* pSender,
52 const FX_WCHAR* pLabel, 52 const FX_WCHAR* pLabel,
53 const FX_WCHAR* pValue, 53 const FX_WCHAR* pValue,
54 int32_t iIndex) { 54 int32_t iIndex) {
55 CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender); 55 CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender);
56 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) 56 if (pWidgetAcc->GetUIType() != XFA_Element::ChoiceList)
57 return; 57 return;
58 58
59 CXFA_FFWidget* pWidget = nullptr; 59 CXFA_FFWidget* pWidget = nullptr;
60 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { 60 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) {
61 if (pWidget->IsLoaded()) { 61 if (pWidget->IsLoaded()) {
62 if (pWidgetAcc->IsListBox()) { 62 if (pWidgetAcc->IsListBox()) {
63 static_cast<CXFA_FFListBox*>(pWidget)->InsertItem(pLabel, iIndex); 63 static_cast<CXFA_FFListBox*>(pWidget)->InsertItem(pLabel, iIndex);
64 } else { 64 } else {
65 static_cast<CXFA_FFComboBox*>(pWidget)->InsertItem(pLabel, iIndex); 65 static_cast<CXFA_FFComboBox*>(pWidget)->InsertItem(pLabel, iIndex);
66 } 66 }
67 } 67 }
68 } 68 }
69 } 69 }
70 70
71 void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetData* pSender, 71 void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetData* pSender,
72 int32_t iIndex) { 72 int32_t iIndex) {
73 CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender); 73 CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender);
74 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) 74 if (pWidgetAcc->GetUIType() != XFA_Element::ChoiceList)
75 return; 75 return;
76 76
77 CXFA_FFWidget* pWidget = nullptr; 77 CXFA_FFWidget* pWidget = nullptr;
78 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { 78 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) {
79 if (pWidget->IsLoaded()) { 79 if (pWidget->IsLoaded()) {
80 if (pWidgetAcc->IsListBox()) { 80 if (pWidgetAcc->IsListBox()) {
81 static_cast<CXFA_FFListBox*>(pWidget)->DeleteItem(iIndex); 81 static_cast<CXFA_FFListBox*>(pWidget)->DeleteItem(iIndex);
82 } else { 82 } else {
83 static_cast<CXFA_FFComboBox*>(pWidget)->DeleteItem(iIndex); 83 static_cast<CXFA_FFComboBox*>(pWidget)->DeleteItem(iIndex);
84 } 84 }
85 } 85 }
86 } 86 }
87 } 87 }
88 88
89 CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { 89 CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) {
90 CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); 90 CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout();
91 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); 91 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
92 XFA_ELEMENT eType = pNode->GetClassID(); 92 XFA_Element eType = pNode->GetClassID();
93 if (eType == XFA_ELEMENT_PageArea) 93 if (eType == XFA_Element::PageArea)
94 return new CXFA_FFPageView(pDocView, pNode); 94 return new CXFA_FFPageView(pDocView, pNode);
95 95
96 if (eType == XFA_ELEMENT_ContentArea) 96 if (eType == XFA_Element::ContentArea)
97 return new CXFA_ContainerLayoutItem(pNode); 97 return new CXFA_ContainerLayoutItem(pNode);
98 98
99 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); 99 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData());
100 if (!pAcc) 100 if (!pAcc)
101 return new CXFA_ContentLayoutItem(pNode); 101 return new CXFA_ContentLayoutItem(pNode);
102 102
103 CXFA_FFWidget* pWidget; 103 CXFA_FFWidget* pWidget;
104 switch (pAcc->GetUIType()) { 104 switch (pAcc->GetUIType()) {
105 case XFA_ELEMENT_Barcode: 105 case XFA_Element::Barcode:
106 pWidget = new CXFA_FFBarcode(nullptr, pAcc); 106 pWidget = new CXFA_FFBarcode(nullptr, pAcc);
107 break; 107 break;
108 case XFA_ELEMENT_Button: 108 case XFA_Element::Button:
109 pWidget = new CXFA_FFPushButton(nullptr, pAcc); 109 pWidget = new CXFA_FFPushButton(nullptr, pAcc);
110 break; 110 break;
111 case XFA_ELEMENT_CheckButton: 111 case XFA_Element::CheckButton:
112 pWidget = new CXFA_FFCheckButton(nullptr, pAcc); 112 pWidget = new CXFA_FFCheckButton(nullptr, pAcc);
113 break; 113 break;
114 case XFA_ELEMENT_ChoiceList: { 114 case XFA_Element::ChoiceList: {
115 if (pAcc->IsListBox()) { 115 if (pAcc->IsListBox()) {
116 pWidget = new CXFA_FFListBox(nullptr, pAcc); 116 pWidget = new CXFA_FFListBox(nullptr, pAcc);
117 } else { 117 } else {
118 pWidget = new CXFA_FFComboBox(nullptr, pAcc); 118 pWidget = new CXFA_FFComboBox(nullptr, pAcc);
119 } 119 }
120 } break; 120 } break;
121 case XFA_ELEMENT_DateTimeEdit: 121 case XFA_Element::DateTimeEdit:
122 pWidget = new CXFA_FFDateTimeEdit(nullptr, pAcc); 122 pWidget = new CXFA_FFDateTimeEdit(nullptr, pAcc);
123 break; 123 break;
124 case XFA_ELEMENT_ImageEdit: 124 case XFA_Element::ImageEdit:
125 pWidget = new CXFA_FFImageEdit(nullptr, pAcc); 125 pWidget = new CXFA_FFImageEdit(nullptr, pAcc);
126 break; 126 break;
127 case XFA_ELEMENT_NumericEdit: 127 case XFA_Element::NumericEdit:
128 pWidget = new CXFA_FFNumericEdit(nullptr, pAcc); 128 pWidget = new CXFA_FFNumericEdit(nullptr, pAcc);
129 break; 129 break;
130 case XFA_ELEMENT_PasswordEdit: 130 case XFA_Element::PasswordEdit:
131 pWidget = new CXFA_FFPasswordEdit(nullptr, pAcc); 131 pWidget = new CXFA_FFPasswordEdit(nullptr, pAcc);
132 break; 132 break;
133 case XFA_ELEMENT_Signature: 133 case XFA_Element::Signature:
134 pWidget = new CXFA_FFSignature(nullptr, pAcc); 134 pWidget = new CXFA_FFSignature(nullptr, pAcc);
135 break; 135 break;
136 case XFA_ELEMENT_TextEdit: 136 case XFA_Element::TextEdit:
137 pWidget = new CXFA_FFTextEdit(nullptr, pAcc); 137 pWidget = new CXFA_FFTextEdit(nullptr, pAcc);
138 break; 138 break;
139 case XFA_ELEMENT_Arc: 139 case XFA_Element::Arc:
140 pWidget = new CXFA_FFArc(nullptr, pAcc); 140 pWidget = new CXFA_FFArc(nullptr, pAcc);
141 break; 141 break;
142 case XFA_ELEMENT_Line: 142 case XFA_Element::Line:
143 pWidget = new CXFA_FFLine(nullptr, pAcc); 143 pWidget = new CXFA_FFLine(nullptr, pAcc);
144 break; 144 break;
145 case XFA_ELEMENT_Rectangle: 145 case XFA_Element::Rectangle:
146 pWidget = new CXFA_FFRectangle(nullptr, pAcc); 146 pWidget = new CXFA_FFRectangle(nullptr, pAcc);
147 break; 147 break;
148 case XFA_ELEMENT_Text: 148 case XFA_Element::Text:
149 pWidget = new CXFA_FFText(nullptr, pAcc); 149 pWidget = new CXFA_FFText(nullptr, pAcc);
150 break; 150 break;
151 case XFA_ELEMENT_Image: 151 case XFA_Element::Image:
152 pWidget = new CXFA_FFImage(nullptr, pAcc); 152 pWidget = new CXFA_FFImage(nullptr, pAcc);
153 break; 153 break;
154 case XFA_ELEMENT_Draw: 154 case XFA_Element::Draw:
155 pWidget = new CXFA_FFDraw(nullptr, pAcc); 155 pWidget = new CXFA_FFDraw(nullptr, pAcc);
156 break; 156 break;
157 case XFA_ELEMENT_Subform: 157 case XFA_Element::Subform:
158 pWidget = new CXFA_FFSubForm(nullptr, pAcc); 158 pWidget = new CXFA_FFSubForm(nullptr, pAcc);
159 break; 159 break;
160 case XFA_ELEMENT_ExclGroup: 160 case XFA_Element::ExclGroup:
161 pWidget = new CXFA_FFExclGroup(nullptr, pAcc); 161 pWidget = new CXFA_FFExclGroup(nullptr, pAcc);
162 break; 162 break;
163 case XFA_ELEMENT_DefaultUi: 163 case XFA_Element::DefaultUi:
164 default: 164 default:
165 pWidget = nullptr; 165 pWidget = nullptr;
166 break; 166 break;
167 } 167 }
168 168
169 if (pWidget) 169 if (pWidget)
170 pWidget->SetDocView(pDocView); 170 pWidget->SetDocView(pDocView);
171 return pWidget; 171 return pWidget;
172 } 172 }
173 173
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return m_pDoc->GetApp()->GetAppProvider(); 247 return m_pDoc->GetApp()->GetAppProvider();
248 } 248 }
249 CXFA_FFWidgetHandler* CXFA_FFNotify::GetWidgetHandler() { 249 CXFA_FFWidgetHandler* CXFA_FFNotify::GetWidgetHandler() {
250 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); 250 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
251 return pDocView ? pDocView->GetWidgetHandler() : NULL; 251 return pDocView ? pDocView->GetWidgetHandler() : NULL;
252 } 252 }
253 CXFA_FFWidget* CXFA_FFNotify::GetHWidget(CXFA_LayoutItem* pLayoutItem) { 253 CXFA_FFWidget* CXFA_FFNotify::GetHWidget(CXFA_LayoutItem* pLayoutItem) {
254 return XFA_GetWidgetFromLayoutItem(pLayoutItem); 254 return XFA_GetWidgetFromLayoutItem(pLayoutItem);
255 } 255 }
256 void CXFA_FFNotify::OpenDropDownList(CXFA_FFWidget* hWidget) { 256 void CXFA_FFNotify::OpenDropDownList(CXFA_FFWidget* hWidget) {
257 if (hWidget->GetDataAcc()->GetUIType() != XFA_ELEMENT_ChoiceList) { 257 if (hWidget->GetDataAcc()->GetUIType() != XFA_Element::ChoiceList) {
258 return; 258 return;
259 } 259 }
260 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); 260 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
261 pDocView->LockUpdate(); 261 pDocView->LockUpdate();
262 static_cast<CXFA_FFComboBox*>(hWidget)->OpenDropDownList(); 262 static_cast<CXFA_FFComboBox*>(hWidget)->OpenDropDownList();
263 pDocView->UnlockUpdate(); 263 pDocView->UnlockUpdate();
264 pDocView->UpdateDocView(); 264 pDocView->UpdateDocView();
265 } 265 }
266 CFX_WideString CXFA_FFNotify::GetCurrentDateTime() { 266 CFX_WideString CXFA_FFNotify::GetCurrentDateTime() {
267 CFX_Unitime dataTime; 267 CFX_Unitime dataTime;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 if (!pDocView) { 310 if (!pDocView) {
311 return; 311 return;
312 } 312 }
313 CXFA_WidgetAcc* pAcc = 313 CXFA_WidgetAcc* pAcc =
314 pNode ? static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()) : nullptr; 314 pNode ? static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()) : nullptr;
315 pDocView->SetFocusWidgetAcc(pAcc); 315 pDocView->SetFocusWidgetAcc(pAcc);
316 } 316 }
317 317
318 void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { 318 void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) {
319 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); 319 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
320 if (!pDocView) { 320 if (!pDocView)
321 return; 321 return;
322 } 322
323 XFA_ELEMENT iType = pNode->GetClassID(); 323 XFA_Element iType = pNode->GetClassID();
324 if (XFA_IsCreateWidget(iType)) { 324 if (XFA_IsCreateWidget(iType)) {
325 CXFA_WidgetAcc* pAcc = new CXFA_WidgetAcc(pDocView, pNode); 325 CXFA_WidgetAcc* pAcc = new CXFA_WidgetAcc(pDocView, pNode);
326 pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc); 326 pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc);
327 return; 327 return;
328 } 328 }
329 switch (iType) { 329 switch (iType) {
330 case XFA_ELEMENT_BindItems: 330 case XFA_Element::BindItems:
331 pDocView->m_BindItems.Add(pNode); 331 pDocView->m_BindItems.Add(pNode);
332 break; 332 break;
333 case XFA_ELEMENT_Validate: { 333 case XFA_Element::Validate: {
334 pNode->SetFlag(XFA_NodeFlag_NeedsInitApp, false); 334 pNode->SetFlag(XFA_NodeFlag_NeedsInitApp, false);
335 } break; 335 } break;
336 default: 336 default:
337 break; 337 break;
338 } 338 }
339 } 339 }
340 340
341 void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr) { 341 void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr) {
342 if (eAttr != XFA_ATTRIBUTE_Presence) 342 if (eAttr != XFA_ATTRIBUTE_Presence)
343 return; 343 return;
(...skipping 30 matching lines...) Expand all
374 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); 374 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
375 if (!pDocView) 375 if (!pDocView)
376 return; 376 return;
377 377
378 if (!(pSender->GetPacketID() & XFA_XDPPACKET_Form)) { 378 if (!(pSender->GetPacketID() & XFA_XDPPACKET_Form)) {
379 if (eAttr == XFA_ATTRIBUTE_Value) 379 if (eAttr == XFA_ATTRIBUTE_Value)
380 pDocView->AddCalculateNodeNotify(pSender); 380 pDocView->AddCalculateNodeNotify(pSender);
381 return; 381 return;
382 } 382 }
383 383
384 XFA_ELEMENT ePType = pParentNode->GetClassID(); 384 XFA_Element ePType = pParentNode->GetClassID();
385 FX_BOOL bIsContainerNode = pParentNode->IsContainerNode(); 385 FX_BOOL bIsContainerNode = pParentNode->IsContainerNode();
386 CXFA_WidgetAcc* pWidgetAcc = 386 CXFA_WidgetAcc* pWidgetAcc =
387 static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData()); 387 static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData());
388 if (!pWidgetAcc) 388 if (!pWidgetAcc)
389 return; 389 return;
390 390
391 bool bUpdateProperty = false; 391 bool bUpdateProperty = false;
392 pDocView->SetChangeMark(); 392 pDocView->SetChangeMark();
393 switch (ePType) { 393 switch (ePType) {
394 case XFA_ELEMENT_Caption: { 394 case XFA_Element::Caption: {
395 CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout(); 395 CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout();
396 if (!pCapOut) 396 if (!pCapOut)
397 return; 397 return;
398 398
399 pCapOut->Unload(); 399 pCapOut->Unload();
400 } break; 400 } break;
401 case XFA_ELEMENT_Ui: 401 case XFA_Element::Ui:
402 case XFA_ELEMENT_Para: 402 case XFA_Element::Para:
403 bUpdateProperty = true; 403 bUpdateProperty = true;
404 break; 404 break;
405 default: 405 default:
406 break; 406 break;
407 } 407 }
408 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) 408 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access)
409 bUpdateProperty = true; 409 bUpdateProperty = true;
410 410
411 if (eAttr == XFA_ATTRIBUTE_Value) { 411 if (eAttr == XFA_ATTRIBUTE_Value) {
412 pDocView->AddCalculateNodeNotify(pSender); 412 pDocView->AddCalculateNodeNotify(pSender);
413 if (ePType == XFA_ELEMENT_Value || bIsContainerNode) { 413 if (ePType == XFA_Element::Value || bIsContainerNode) {
414 if (bIsContainerNode) { 414 if (bIsContainerNode) {
415 pWidgetAcc->UpdateUIDisplay(); 415 pWidgetAcc->UpdateUIDisplay();
416 pDocView->AddCalculateWidgetAcc(pWidgetAcc); 416 pDocView->AddCalculateWidgetAcc(pWidgetAcc);
417 pDocView->AddValidateWidget(pWidgetAcc); 417 pDocView->AddValidateWidget(pWidgetAcc);
418 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent)->GetClassID() == 418 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent)->GetClassID() ==
419 XFA_ELEMENT_ExclGroup) { 419 XFA_Element::ExclGroup) {
420 pWidgetAcc->UpdateUIDisplay(); 420 pWidgetAcc->UpdateUIDisplay();
421 } 421 }
422 return; 422 return;
423 } 423 }
424 } 424 }
425 CXFA_FFWidget* pWidget = nullptr; 425 CXFA_FFWidget* pWidget = nullptr;
426 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { 426 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) {
427 if (!pWidget->IsLoaded()) 427 if (!pWidget->IsLoaded())
428 continue; 428 continue;
429 429
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 return; 506 return;
507 507
508 CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); 508 CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender);
509 if (!pWidget) 509 if (!pWidget)
510 return; 510 return;
511 511
512 pDocView->DeleteLayoutItem(pWidget); 512 pDocView->DeleteLayoutItem(pWidget);
513 m_pDoc->GetDocProvider()->WidgetPreRemove(pWidget, pWidget->GetDataAcc()); 513 m_pDoc->GetDocProvider()->WidgetPreRemove(pWidget, pWidget->GetDataAcc());
514 pWidget->AddInvalidateRect(nullptr); 514 pWidget->AddInvalidateRect(nullptr);
515 } 515 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_fffield.cpp ('k') | xfa/fxfa/app/xfa_ffpageview.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698