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

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

Issue 1418043007: Cleanup after syncing CPDFSDK_BAAnnot (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 1 month 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/fsdk_annothandler.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 "../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/fsdk_baseannot.h" 9 #include "../include/fsdk_baseannot.h"
10 10
11 //---------------------------------------------------------------------------
12 // CPDFSDK_DateTime
13 //---------------------------------------------------------------------------
14 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) { 11 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) {
15 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60); 12 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60);
16 } 13 }
17 14
18 FX_BOOL _gAfxIsLeapYear(int16_t year) { 15 FX_BOOL _gAfxIsLeapYear(int16_t year) {
19 return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))); 16 return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)));
20 } 17 }
21 18
22 FX_WORD _gAfxGetYearDays(int16_t year) { 19 FX_WORD _gAfxGetYearDays(int16_t year) {
23 return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365); 20 return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365);
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 dt.hour %= 24; 492 dt.hour %= 24;
496 n %= 3600; 493 n %= 3600;
497 dt.minute = (uint8_t)(n / 60); 494 dt.minute = (uint8_t)(n / 60);
498 dt.second = (uint8_t)(n % 60); 495 dt.second = (uint8_t)(n % 60);
499 if (days != 0) 496 if (days != 0)
500 AddDays(days); 497 AddDays(days);
501 498
502 return *this; 499 return *this;
503 } 500 }
504 501
505 //---------------------------------------------------------------------------
506 // CPDFSDK_Annot
507 //---------------------------------------------------------------------------
508 CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView) 502 CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView)
509 : m_pPageView(pPageView), m_bSelected(FALSE), m_nTabOrder(-1) { 503 : m_pPageView(pPageView), m_bSelected(FALSE), m_nTabOrder(-1) {
510 } 504 }
511 505
512 // CPDFSDK_BAAnnot
513 CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, 506 CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot,
514 CPDFSDK_PageView* pPageView) 507 CPDFSDK_PageView* pPageView)
515 : CPDFSDK_Annot(pPageView), m_pAnnot(pAnnot) { 508 : CPDFSDK_Annot(pPageView), m_pAnnot(pAnnot) {
516 } 509 }
517 510
518 CPDFSDK_BAAnnot::~CPDFSDK_BAAnnot() {
519 m_pAnnot = NULL;
520 }
521
522 CPDF_Annot* CPDFSDK_BAAnnot::GetPDFAnnot() const { 511 CPDF_Annot* CPDFSDK_BAAnnot::GetPDFAnnot() const {
523 return m_pAnnot; 512 return m_pAnnot;
524 } 513 }
525 514
526 FX_BOOL CPDFSDK_Annot::IsSelected() { 515 FX_BOOL CPDFSDK_Annot::IsSelected() {
527 return m_bSelected; 516 return m_bSelected;
528 } 517 }
529 518
530 void CPDFSDK_Annot::SetSelected(FX_BOOL bSelected) { 519 void CPDFSDK_Annot::SetSelected(FX_BOOL bSelected) {
531 m_bSelected = bSelected; 520 m_bSelected = bSelected;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 const CPDF_Matrix& matrix, 850 const CPDF_Matrix& matrix,
862 const CFX_ByteString& sContents, 851 const CFX_ByteString& sContents,
863 const CFX_ByteString& sAPState) { 852 const CFX_ByteString& sAPState) {
864 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); 853 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP");
865 854
866 if (!pAPDict) { 855 if (!pAPDict) {
867 pAPDict = new CPDF_Dictionary; 856 pAPDict = new CPDF_Dictionary;
868 m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict); 857 m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict);
869 } 858 }
870 859
871 CPDF_Stream* pStream = NULL; 860 CPDF_Stream* pStream = nullptr;
872 CPDF_Dictionary* pParentDict = NULL; 861 CPDF_Dictionary* pParentDict = nullptr;
873 862
874 if (sAPState.IsEmpty()) { 863 if (sAPState.IsEmpty()) {
875 pParentDict = pAPDict; 864 pParentDict = pAPDict;
876 pStream = pAPDict->GetStream(sAPType); 865 pStream = pAPDict->GetStream(sAPType);
877 } else { 866 } else {
878 CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType); 867 CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType);
879 if (!pAPTypeDict) { 868 if (!pAPTypeDict) {
880 pAPTypeDict = new CPDF_Dictionary; 869 pAPTypeDict = new CPDF_Dictionary;
881 pAPDict->SetAt(sAPType, pAPTypeDict); 870 pAPDict->SetAt(sAPType, pAPTypeDict);
882 } 871 }
883 872
884 pParentDict = pAPTypeDict; 873 pParentDict = pAPTypeDict;
885 pStream = pAPTypeDict->GetStream(sAPState); 874 pStream = pAPTypeDict->GetStream(sAPState);
886 } 875 }
887 876
888 if (!pStream) { 877 if (!pStream) {
889 ASSERT(m_pPageView != NULL); 878 pStream = new CPDF_Stream(nullptr, 0, nullptr);
879
890 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 880 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
891 ASSERT(pDoc != NULL);
892
893 pStream = new CPDF_Stream(NULL, 0, NULL);
894 int32_t objnum = pDoc->AddIndirectObject(pStream); 881 int32_t objnum = pDoc->AddIndirectObject(pStream);
895 pParentDict->SetAtReference(sAPType, pDoc, objnum); 882 pParentDict->SetAtReference(sAPType, pDoc, objnum);
896 } 883 }
897 884
898 CPDF_Dictionary* pStreamDict = pStream->GetDict(); 885 CPDF_Dictionary* pStreamDict = pStream->GetDict();
899
900 if (!pStreamDict) { 886 if (!pStreamDict) {
901 pStreamDict = new CPDF_Dictionary; 887 pStreamDict = new CPDF_Dictionary;
902 pStreamDict->SetAtName("Type", "XObject"); 888 pStreamDict->SetAtName("Type", "XObject");
903 pStreamDict->SetAtName("Subtype", "Form"); 889 pStreamDict->SetAtName("Subtype", "Form");
904 pStreamDict->SetAtInteger("FormType", 1); 890 pStreamDict->SetAtInteger("FormType", 1);
905 pStream->InitStream(NULL, 0, pStreamDict); 891 pStream->InitStream(nullptr, 0, pStreamDict);
906 } 892 }
907 893
908 if (pStreamDict) { 894 if (pStreamDict) {
909 pStreamDict->SetAtMatrix("Matrix", matrix); 895 pStreamDict->SetAtMatrix("Matrix", matrix);
910 pStreamDict->SetAtRect("BBox", rcBBox); 896 pStreamDict->SetAtRect("BBox", rcBBox);
911 } 897 }
912 898
913 pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE, 899 pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE,
914 FALSE); 900 FALSE);
915 } 901 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 CPDF_Annot::Normal, NULL); 976 CPDF_Annot::Normal, NULL);
991 977
992 return; 978 return;
993 } 979 }
994 980
995 CPDF_Page* CPDFSDK_Annot::GetPDFPage() { 981 CPDF_Page* CPDFSDK_Annot::GetPDFPage() {
996 if (m_pPageView) 982 if (m_pPageView)
997 return m_pPageView->GetPDFPage(); 983 return m_pPageView->GetPDFPage();
998 return NULL; 984 return NULL;
999 } 985 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fsdk_annothandler.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698