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

Side by Side Diff: fpdfsdk/javascript/Field.cpp

Issue 2311343003: Make Observers into a templated class (Closed)
Patch Set: Make Annot is-a CPDFSDK_Annot::Observer Created 4 years, 3 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/javascript/Annot.cpp ('k') | no next file » | 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/javascript/Field.h" 7 #include "fpdfsdk/javascript/Field.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 FX_BOOL bRefresh) { 262 FX_BOOL bRefresh) {
263 std::vector<CPDFSDK_Widget*> widgets; 263 std::vector<CPDFSDK_Widget*> widgets;
264 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 264 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
265 pInterForm->GetWidgets(pFormField, &widgets); 265 pInterForm->GetWidgets(pFormField, &widgets);
266 266
267 if (bResetAP) { 267 if (bResetAP) {
268 int nFieldType = pFormField->GetFieldType(); 268 int nFieldType = pFormField->GetFieldType();
269 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { 269 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) {
270 for (CPDFSDK_Annot* pAnnot : widgets) { 270 for (CPDFSDK_Annot* pAnnot : widgets) {
271 FX_BOOL bFormatted = FALSE; 271 FX_BOOL bFormatted = FALSE;
272 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); 272 CPDFSDK_Annot::Observer observer(&pAnnot);
273 CPDFSDK_Widget::Observer observer(&pAnnot); 273 CFX_WideString sValue =
274 CFX_WideString sValue = pWidget->OnFormat(bFormatted); 274 static_cast<CPDFSDK_Widget*>(pAnnot)->OnFormat(bFormatted);
275 if (pAnnot) { 275 if (pAnnot) {
Lei Zhang 2016/09/07 21:01:29 Isn't this always true?
Tom Sepez 2016/09/07 21:10:28 No, that's the whole point of the observer. If we
276 pWidget->ResetAppearance(bFormatted ? sValue.c_str() : nullptr, 276 static_cast<CPDFSDK_Widget*>(pAnnot)->ResetAppearance(
277 FALSE); 277 bFormatted ? sValue.c_str() : nullptr, FALSE);
278 } 278 }
279 } 279 }
280 } else { 280 } else {
281 for (CPDFSDK_Widget* pWidget : widgets) { 281 for (CPDFSDK_Widget* pWidget : widgets) {
282 pWidget->ResetAppearance(nullptr, FALSE); 282 pWidget->ResetAppearance(nullptr, FALSE);
283 } 283 }
284 } 284 }
285 } 285 }
286 286
287 if (bRefresh) { 287 if (bRefresh) {
(...skipping 3183 matching lines...) Expand 10 before | Expand all | Expand 10 after
3471 } 3471 }
3472 } 3472 }
3473 3473
3474 void Field::AddField(CPDFSDK_Document* pDocument, 3474 void Field::AddField(CPDFSDK_Document* pDocument,
3475 int nPageIndex, 3475 int nPageIndex,
3476 int nFieldType, 3476 int nFieldType,
3477 const CFX_WideString& sName, 3477 const CFX_WideString& sName,
3478 const CFX_FloatRect& rcCoords) { 3478 const CFX_FloatRect& rcCoords) {
3479 // Not supported. 3479 // Not supported.
3480 } 3480 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/Annot.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698