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

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

Issue 1529553003: Merge to XFA: Get rid of most instance of 'foo != NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years 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 "core/include/fxcrt/fx_ext.h" 7 #include "core/include/fxcrt/fx_ext.h"
8 #include "fpdfsdk/include/fsdk_baseannot.h" 8 #include "fpdfsdk/include/fsdk_baseannot.h"
9 #include "fpdfsdk/include/fsdk_define.h" 9 #include "fpdfsdk/include/fsdk_define.h"
10 #include "fpdfsdk/include/fsdk_mgr.h" 10 #include "fpdfsdk/include/fsdk_mgr.h"
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 // Tab Order 525 // Tab Order
526 int CPDFSDK_Annot::GetTabOrder() { 526 int CPDFSDK_Annot::GetTabOrder() {
527 return m_nTabOrder; 527 return m_nTabOrder;
528 } 528 }
529 529
530 void CPDFSDK_Annot::SetTabOrder(int iTabOrder) { 530 void CPDFSDK_Annot::SetTabOrder(int iTabOrder) {
531 m_nTabOrder = iTabOrder; 531 m_nTabOrder = iTabOrder;
532 } 532 }
533 533
534 CPDF_Dictionary* CPDFSDK_BAAnnot::GetAnnotDict() const { 534 CPDF_Dictionary* CPDFSDK_BAAnnot::GetAnnotDict() const {
535 ASSERT(m_pAnnot != NULL);
536
537 return m_pAnnot->GetAnnotDict(); 535 return m_pAnnot->GetAnnotDict();
538 } 536 }
539 537
540 void CPDFSDK_BAAnnot::SetRect(const CPDF_Rect& rect) { 538 void CPDFSDK_BAAnnot::SetRect(const CPDF_Rect& rect) {
541 ASSERT(rect.right - rect.left >= GetMinWidth()); 539 ASSERT(rect.right - rect.left >= GetMinWidth());
542 ASSERT(rect.top - rect.bottom >= GetMinHeight()); 540 ASSERT(rect.top - rect.bottom >= GetMinHeight());
543 541
544 m_pAnnot->GetAnnotDict()->SetAtRect("Rect", rect); 542 m_pAnnot->GetAnnotDict()->SetAtRect("Rect", rect);
545 } 543 }
546 544
547 CPDF_Rect CPDFSDK_BAAnnot::GetRect() const { 545 CPDF_Rect CPDFSDK_BAAnnot::GetRect() const {
548 ASSERT(m_pAnnot != NULL);
549
550 CPDF_Rect rect; 546 CPDF_Rect rect;
551 m_pAnnot->GetRect(rect); 547 m_pAnnot->GetRect(rect);
552
553 return rect; 548 return rect;
554 } 549 }
555 550
556 CFX_ByteString CPDFSDK_BAAnnot::GetType() const { 551 CFX_ByteString CPDFSDK_BAAnnot::GetType() const {
557 ASSERT(m_pAnnot != NULL);
558
559 return m_pAnnot->GetSubType(); 552 return m_pAnnot->GetSubType();
560 } 553 }
561 554
562 CFX_ByteString CPDFSDK_BAAnnot::GetSubType() const { 555 CFX_ByteString CPDFSDK_BAAnnot::GetSubType() const {
563 return ""; 556 return "";
564 } 557 }
565 558
566 void CPDFSDK_BAAnnot::DrawAppearance(CFX_RenderDevice* pDevice, 559 void CPDFSDK_BAAnnot::DrawAppearance(CFX_RenderDevice* pDevice,
567 const CFX_Matrix* pUser2Device, 560 const CFX_Matrix* pUser2Device,
568 CPDF_Annot::AppearanceMode mode, 561 CPDF_Annot::AppearanceMode mode,
569 const CPDF_RenderOptions* pOptions) { 562 const CPDF_RenderOptions* pOptions) {
570 ASSERT(m_pPageView != NULL);
571 ASSERT(m_pAnnot != NULL);
572
573 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, 563 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device,
574 mode, pOptions); 564 mode, pOptions);
575 } 565 }
576 566
577 FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid() { 567 FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid() {
578 return m_pAnnot->GetAnnotDict()->GetDict("AP") != NULL; 568 return m_pAnnot->GetAnnotDict()->GetDict("AP") != NULL;
579 } 569 }
580 570
581 FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) { 571 FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) {
582 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); 572 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
(...skipping 13 matching lines...) Expand all
596 CPDF_Object* psub = pAP->GetElementValue(ap_entry); 586 CPDF_Object* psub = pAP->GetElementValue(ap_entry);
597 if (psub == NULL) 587 if (psub == NULL)
598 return FALSE; 588 return FALSE;
599 589
600 return TRUE; 590 return TRUE;
601 } 591 }
602 592
603 void CPDFSDK_BAAnnot::DrawBorder(CFX_RenderDevice* pDevice, 593 void CPDFSDK_BAAnnot::DrawBorder(CFX_RenderDevice* pDevice,
604 const CFX_Matrix* pUser2Device, 594 const CFX_Matrix* pUser2Device,
605 const CPDF_RenderOptions* pOptions) { 595 const CPDF_RenderOptions* pOptions) {
606 ASSERT(m_pAnnot != NULL);
607 m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions); 596 m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions);
608 } 597 }
609 598
610 void CPDFSDK_BAAnnot::ClearCachedAP() { 599 void CPDFSDK_BAAnnot::ClearCachedAP() {
611 ASSERT(m_pAnnot != NULL);
612 m_pAnnot->ClearCachedAP(); 600 m_pAnnot->ClearCachedAP();
613 } 601 }
614 602
615 void CPDFSDK_BAAnnot::SetContents(const CFX_WideString& sContents) { 603 void CPDFSDK_BAAnnot::SetContents(const CFX_WideString& sContents) {
616 if (sContents.IsEmpty()) 604 if (sContents.IsEmpty())
617 m_pAnnot->GetAnnotDict()->RemoveAt("Contents"); 605 m_pAnnot->GetAnnotDict()->RemoveAt("Contents");
618 else 606 else
619 m_pAnnot->GetAnnotDict()->SetAtString("Contents", 607 m_pAnnot->GetAnnotDict()->SetAtString("Contents",
620 PDF_EncodeText(sContents)); 608 PDF_EncodeText(sContents));
621 } 609 }
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 929
942 void CPDFSDK_BAAnnot::RemoveAction() { 930 void CPDFSDK_BAAnnot::RemoveAction() {
943 m_pAnnot->GetAnnotDict()->RemoveAt("A"); 931 m_pAnnot->GetAnnotDict()->RemoveAt("A");
944 } 932 }
945 933
946 CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const { 934 CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const {
947 return m_pAnnot->GetAnnotDict()->GetDict("AA"); 935 return m_pAnnot->GetAnnotDict()->GetDict("AA");
948 } 936 }
949 937
950 void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa) { 938 void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa) {
951 ASSERT(aa != NULL);
952
953 if ((CPDF_AAction&)aa != m_pAnnot->GetAnnotDict()->GetDict("AA")) 939 if ((CPDF_AAction&)aa != m_pAnnot->GetAnnotDict()->GetDict("AA"))
954 m_pAnnot->GetAnnotDict()->SetAt("AA", (CPDF_AAction&)aa); 940 m_pAnnot->GetAnnotDict()->SetAt("AA", (CPDF_AAction&)aa);
955 } 941 }
956 942
957 void CPDFSDK_BAAnnot::RemoveAAction() { 943 void CPDFSDK_BAAnnot::RemoveAAction() {
958 m_pAnnot->GetAnnotDict()->RemoveAt("AA"); 944 m_pAnnot->GetAnnotDict()->RemoveAt("AA");
959 } 945 }
960 946
961 CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) { 947 CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) {
962 CPDF_AAction AAction = GetAAction(); 948 CPDF_AAction AAction = GetAAction();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 return NULL; 984 return NULL;
999 } 985 }
1000 986
1001 #ifdef PDF_ENABLE_XFA 987 #ifdef PDF_ENABLE_XFA
1002 CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() { 988 CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() {
1003 if (m_pPageView) 989 if (m_pPageView)
1004 return m_pPageView->GetPDFXFAPage(); 990 return m_pPageView->GetPDFXFAPage();
1005 return NULL; 991 return NULL;
1006 } 992 }
1007 #endif // PDF_ENABLE_XFA 993 #endif // PDF_ENABLE_XFA
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698