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

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

Issue 1415933007: Merge to XFA: Cleanup after syncing CPDFSDK_BAAnnot (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
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/fpdfxfa/fpdfxfa_doc.h" 8 #include "../include/fpdfxfa/fpdfxfa_doc.h"
9 #include "../include/fsdk_mgr.h" 9 #include "../include/fsdk_mgr.h"
10 #include "../include/fsdk_baseannot.h" 10 #include "../include/fsdk_baseannot.h"
11 11
12 //---------------------------------------------------------------------------
13 // CPDFSDK_DateTime
14 //---------------------------------------------------------------------------
15 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) { 12 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) {
16 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60); 13 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60);
17 } 14 }
18 15
19 FX_BOOL _gAfxIsLeapYear(int16_t year) { 16 FX_BOOL _gAfxIsLeapYear(int16_t year) {
20 return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))); 17 return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)));
21 } 18 }
22 19
23 FX_WORD _gAfxGetYearDays(int16_t year) { 20 FX_WORD _gAfxGetYearDays(int16_t year) {
24 return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365); 21 return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365);
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 dt.hour %= 24; 493 dt.hour %= 24;
497 n %= 3600; 494 n %= 3600;
498 dt.minute = (uint8_t)(n / 60); 495 dt.minute = (uint8_t)(n / 60);
499 dt.second = (uint8_t)(n % 60); 496 dt.second = (uint8_t)(n % 60);
500 if (days != 0) 497 if (days != 0)
501 AddDays(days); 498 AddDays(days);
502 499
503 return *this; 500 return *this;
504 } 501 }
505 502
506 //---------------------------------------------------------------------------
507 // CPDFSDK_Annot
508 //---------------------------------------------------------------------------
509 CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView) 503 CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView)
510 : m_pPageView(pPageView), m_bSelected(FALSE), m_nTabOrder(-1) {} 504 : m_pPageView(pPageView), m_bSelected(FALSE), m_nTabOrder(-1) {
505 }
511 506
512 // CPDFSDK_BAAnnot
513 CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, 507 CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot,
514 CPDFSDK_PageView* pPageView) 508 CPDFSDK_PageView* pPageView)
515 : CPDFSDK_Annot(pPageView), m_pAnnot(pAnnot) {} 509 : CPDFSDK_Annot(pPageView), m_pAnnot(pAnnot) {
516
517 CPDFSDK_BAAnnot::~CPDFSDK_BAAnnot() {
518 m_pAnnot = NULL;
519 } 510 }
520 511
521 CPDF_Annot* CPDFSDK_BAAnnot::GetPDFAnnot() const { 512 CPDF_Annot* CPDFSDK_BAAnnot::GetPDFAnnot() const {
522 return m_pAnnot; 513 return m_pAnnot;
523 } 514 }
524 515
525 FX_BOOL CPDFSDK_Annot::IsSelected() { 516 FX_BOOL CPDFSDK_Annot::IsSelected() {
526 return m_bSelected; 517 return m_bSelected;
527 } 518 }
528 519
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 const CPDF_Matrix& matrix, 851 const CPDF_Matrix& matrix,
861 const CFX_ByteString& sContents, 852 const CFX_ByteString& sContents,
862 const CFX_ByteString& sAPState) { 853 const CFX_ByteString& sAPState) {
863 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); 854 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP");
864 855
865 if (!pAPDict) { 856 if (!pAPDict) {
866 pAPDict = new CPDF_Dictionary; 857 pAPDict = new CPDF_Dictionary;
867 m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict); 858 m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict);
868 } 859 }
869 860
870 CPDF_Stream* pStream = NULL; 861 CPDF_Stream* pStream = nullptr;
871 CPDF_Dictionary* pParentDict = NULL; 862 CPDF_Dictionary* pParentDict = nullptr;
872 863
873 if (sAPState.IsEmpty()) { 864 if (sAPState.IsEmpty()) {
874 pParentDict = pAPDict; 865 pParentDict = pAPDict;
875 pStream = pAPDict->GetStream(sAPType); 866 pStream = pAPDict->GetStream(sAPType);
876 } else { 867 } else {
877 CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType); 868 CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType);
878 if (!pAPTypeDict) { 869 if (!pAPTypeDict) {
879 pAPTypeDict = new CPDF_Dictionary; 870 pAPTypeDict = new CPDF_Dictionary;
880 pAPDict->SetAt(sAPType, pAPTypeDict); 871 pAPDict->SetAt(sAPType, pAPTypeDict);
881 } 872 }
882 873
883 pParentDict = pAPTypeDict; 874 pParentDict = pAPTypeDict;
884 pStream = pAPTypeDict->GetStream(sAPState); 875 pStream = pAPTypeDict->GetStream(sAPState);
885 } 876 }
886 877
887 if (!pStream) { 878 if (!pStream) {
888 ASSERT(m_pPageView != NULL); 879 pStream = new CPDF_Stream(nullptr, 0, nullptr);
880
889 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 881 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
890 ASSERT(pDoc != NULL);
891
892 pStream = new CPDF_Stream(NULL, 0, NULL);
893 int32_t objnum = pDoc->AddIndirectObject(pStream); 882 int32_t objnum = pDoc->AddIndirectObject(pStream);
894 // pAPDict->SetAtReference(sAPType, pDoc, objnum); 883 // pAPDict->SetAtReference(sAPType, pDoc, objnum);
895 ASSERT(pParentDict != NULL); 884 ASSERT(pParentDict != NULL);
896 pParentDict->SetAtReference(sAPType, pDoc, objnum); 885 pParentDict->SetAtReference(sAPType, pDoc, objnum);
897 } 886 }
898 887
899 CPDF_Dictionary* pStreamDict = pStream->GetDict(); 888 CPDF_Dictionary* pStreamDict = pStream->GetDict();
900
901 if (!pStreamDict) { 889 if (!pStreamDict) {
902 pStreamDict = new CPDF_Dictionary; 890 pStreamDict = new CPDF_Dictionary;
903 pStreamDict->SetAtName("Type", "XObject"); 891 pStreamDict->SetAtName("Type", "XObject");
904 pStreamDict->SetAtName("Subtype", "Form"); 892 pStreamDict->SetAtName("Subtype", "Form");
905 pStreamDict->SetAtInteger("FormType", 1); 893 pStreamDict->SetAtInteger("FormType", 1);
906 pStream->InitStream(NULL, 0, pStreamDict); 894 pStream->InitStream(nullptr, 0, pStreamDict);
907 } 895 }
908 896
909 if (pStreamDict) { 897 if (pStreamDict) {
910 pStreamDict->SetAtMatrix("Matrix", matrix); 898 pStreamDict->SetAtMatrix("Matrix", matrix);
911 pStreamDict->SetAtRect("BBox", rcBBox); 899 pStreamDict->SetAtRect("BBox", rcBBox);
912 } 900 }
913 901
914 pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE, 902 pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE,
915 FALSE); 903 FALSE);
916 } 904 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 if (m_pPageView) 989 if (m_pPageView)
1002 return m_pPageView->GetPDFPage(); 990 return m_pPageView->GetPDFPage();
1003 return NULL; 991 return NULL;
1004 } 992 }
1005 993
1006 CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() { 994 CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() {
1007 if (m_pPageView) 995 if (m_pPageView)
1008 return m_pPageView->GetPDFXFAPage(); 996 return m_pPageView->GetPDFXFAPage();
1009 return NULL; 997 return NULL;
1010 } 998 }
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