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

Side by Side Diff: fpdfsdk/src/fsdk_annothandler.cpp

Issue 1243953004: Re-land else-after-returns (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 5 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/fpdfsave.cpp ('k') | fpdfsdk/src/fsdk_baseannot.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 "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h" 8 #include "../include/fsdk_mgr.h"
9 #include "../include/formfiller/FFL_FormFiller.h" 9 #include "../include/formfiller/FFL_FormFiller.h"
10 #include "../include/fsdk_annothandler.h" 10 #include "../include/fsdk_annothandler.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) 282 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
283 { 283 {
284 ASSERT(pAnnot != NULL); 284 ASSERT(pAnnot != NULL);
285 285
286 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 286 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
287 { 287 {
288 if (pAnnotHandler->OnSetFocus(pAnnot, nFlag)) 288 if (pAnnotHandler->OnSetFocus(pAnnot, nFlag))
289 { 289 {
290 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); 290 CPDFSDK_PageView* pPage = pAnnot->GetPageView();
291 ASSERT(pPage != NULL);
292
293 pPage->GetSDKDocument(); 291 pPage->GetSDKDocument();
294 // pDocument->SetTopmostAnnot(pAnnot);
295
296 return TRUE; 292 return TRUE;
297 } 293 }
298 else
299 {
300 return FALSE;
301 }
302 } 294 }
303
304 return FALSE; 295 return FALSE;
305 } 296 }
306 297
307 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot , FX_DWORD nFlag) 298 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot , FX_DWORD nFlag)
308 { 299 {
309 ASSERT(pAnnot != NULL); 300 ASSERT(pAnnot);
310
311 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 301 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
312 { 302 return pAnnotHandler->OnKillFocus(pAnnot, nFlag);
313 if (pAnnotHandler->OnKillFocus(pAnnot, nFlag))
314 {
315 return TRUE;
316 }
317 else
318 return FALSE;
319 }
320 303
321 return FALSE; 304 return FALSE;
322 } 305 }
323 306
324 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *pPage View, CPDFSDK_Annot* pAnnot) 307 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *pPage View, CPDFSDK_Annot* pAnnot)
325 { 308 {
326 ASSERT(pAnnot); 309 ASSERT(pAnnot);
327 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 310 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
328 {
329 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); 311 return pAnnotHandler->GetViewBBox(pPageView, pAnnot);
330 } 312
331 return pAnnot->GetRect(); 313 return pAnnot->GetRect();
332 } 314 }
333 315
334 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CP DFSDK_Annot* pAnnot, const CPDF_Point& point) 316 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CP DFSDK_Annot* pAnnot, const CPDF_Point& point)
335 { 317 {
336 ASSERT(pAnnot); 318 ASSERT(pAnnot);
337 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 319 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
338 { 320 {
339 if(pAnnotHandler->CanAnswer(pAnnot)) 321 if (pAnnotHandler->CanAnswer(pAnnot))
340 return pAnnotHandler->HitTest(pPageView, pAnnot, point); 322 return pAnnotHandler->HitTest(pPageView, pAnnot, point);
341 } 323 }
342 return FALSE; 324 return FALSE;
343 } 325 }
344 326
345 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,F X_BOOL bNext) 327 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,F X_BOOL bNext)
346 { 328 {
347 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); 329 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", "");
348 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); 330 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot);
349 } 331 }
350 332
351 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) 333 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot)
352 { 334 {
353 ASSERT(pAnnot);
354 ASSERT(pAnnot->GetType() == "Widget"); 335 ASSERT(pAnnot->GetType() == "Widget");
355 CFX_ByteString sSubType = pAnnot->GetSubType(); 336 if (pAnnot->GetSubType() == BFFT_SIGNATURE)
337 return FALSE;
356 338
357 if (sSubType == BFFT_SIGNATURE) 339 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
358 { 340 if (!pWidget->IsVisible())
359 } 341 return FALSE;
360 else
361 {
362 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
363 if (!pWidget->IsVisible()) return FALSE;
364 342
365 int nFieldFlags = pWidget->GetFieldFlags(); 343 int nFieldFlags = pWidget->GetFieldFlags();
366 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) return FAL SE; 344 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
367 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) 345 return FALSE;
368 return TRUE;
369 else
370 {
371 CPDF_Page* pPage = pWidget->GetPDFPage();
372 ASSERT(pPage != NULL);
373 346
374 CPDF_Document* pDocument = pPage->m_pDocument; 347 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
375 ASSERT(pDocument != NULL); 348 return TRUE;
376 349
377 FX_DWORD dwPermissions = pDocument->GetUserPermissions(); 350 CPDF_Page* pPage = pWidget->GetPDFPage();
378 return (dwPermissions&FPDFPERM_FILL_FORM) || 351 CPDF_Document* pDocument = pPage->m_pDocument;
379 (dwPermissions&FPDFPERM_ANNOT_FORM) || 352 FX_DWORD dwPermissions = pDocument->GetUserPermissions();
380 (dwPermissions&FPDFPERM_ANNOT_FORM); 353 return (dwPermissions & FPDFPERM_FILL_FORM) ||
381 } 354 (dwPermissions & FPDFPERM_ANNOT_FORM);
382 }
383
384 return FALSE;
385 } 355 }
386 356
387 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_Page View* pPage) 357 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_Page View* pPage)
388 { 358 {
389 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); 359 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument();
390 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm(); 360 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm();
391 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl(pInterForm->GetInte rForm(), pAnnot->GetAnnotDict()); 361 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl(pInterForm->GetInte rForm(), pAnnot->GetAnnotDict());
392 if (!pCtrl) 362 if (!pCtrl)
393 return nullptr; 363 return nullptr;
394 364
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 arrayList[j + 1] = arrayList[j]; 836 arrayList[j + 1] = arrayList[j];
867 } while (--j >= 0 && pCompare(pTemp, (CPDFSDK_Annot*)arrayList[j]) < 0); 837 } while (--j >= 0 && pCompare(pTemp, (CPDFSDK_Annot*)arrayList[j]) < 0);
868 838
869 arrayList[j+1] = pTemp; 839 arrayList[j+1] = pTemp;
870 } 840 }
871 } 841 }
872 } 842 }
873 843
874 int LyOrderCompare(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) 844 int LyOrderCompare(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2)
875 { 845 {
876 if(p1->GetLayoutOrder() < p2->GetLayoutOrder()) 846 if (p1->GetLayoutOrder() < p2->GetLayoutOrder())
877 return -1; 847 return -1;
878 else if (p1->GetLayoutOrder() == p2->GetLayoutOrder()) 848 if (p1->GetLayoutOrder() > p2->GetLayoutOrder())
879 return 0;
880 else
881 return 1; 849 return 1;
850 return 0;
882 } 851 }
883 852
884 FX_BOOL CPDFSDK_AnnotIterator::InitIteratorAnnotList(CPDFSDK_PageView* pPageView ,CFX_PtrArray * pAnnotList) 853 FX_BOOL CPDFSDK_AnnotIterator::InitIteratorAnnotList(CPDFSDK_PageView* pPageView ,CFX_PtrArray * pAnnotList)
885 { 854 {
886 ASSERT(pPageView); 855 ASSERT(pPageView);
887 856
888 if(pAnnotList==NULL){ 857 if(pAnnotList==NULL){
889 pAnnotList=pPageView->GetAnnotList(); 858 pAnnotList=pPageView->GetAnnotList();
890 } 859 }
891 860
(...skipping 22 matching lines...) Expand all
914 { 883 {
915 m_pIteratorAnnotList.RemoveAt(i); 884 m_pIteratorAnnotList.RemoveAt(i);
916 m_pIteratorAnnotList.InsertAt(0, pReaderAnnot); 885 m_pIteratorAnnotList.InsertAt(0, pReaderAnnot);
917 break; 886 break;
918 } 887 }
919 } 888 }
920 } 889 }
921 890
922 return TRUE; 891 return TRUE;
923 } 892 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfsave.cpp ('k') | fpdfsdk/src/fsdk_baseannot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698