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

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

Issue 984773002: Make conversion between CPDF_Action and its dictionary explicit (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Tabs Created 5 years, 9 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/fsdk_actionhandler.cpp ('k') | fpdfsdk/src/fsdk_baseform.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/fsdk_baseannot.h" 9 #include "../include/fsdk_baseannot.h"
10 10
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 return TRUE; 1083 return TRUE;
1084 } 1084 }
1085 FX_BOOL CPDFSDK_Annot::IsVisible() const 1085 FX_BOOL CPDFSDK_Annot::IsVisible() const
1086 { 1086 {
1087 int nFlags = GetFlags(); 1087 int nFlags = GetFlags();
1088 return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) | | (nFlags & ANNOTFLAG_NOVIEW)); 1088 return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) | | (nFlags & ANNOTFLAG_NOVIEW));
1089 } 1089 }
1090 1090
1091 CPDF_Action CPDFSDK_Annot::GetAction() const 1091 CPDF_Action CPDFSDK_Annot::GetAction() const
1092 { 1092 {
1093 » ASSERT(m_pAnnot != NULL); 1093 » return CPDF_Action(m_pAnnot->m_pAnnotDict->GetDict("A"));
1094 » ASSERT(m_pAnnot->m_pAnnotDict != NULL);
1095 »
1096 » return m_pAnnot->m_pAnnotDict->GetDict("A");
1097 } 1094 }
1098 1095
1099 void CPDFSDK_Annot::SetAction(const CPDF_Action& action) 1096 void CPDFSDK_Annot::SetAction(const CPDF_Action& action)
1100 { 1097 {
1101 » ASSERT(m_pAnnot != NULL); 1098 » ASSERT(action);
1102 » ASSERT(m_pAnnot->m_pAnnotDict != NULL); 1099 » if ((CPDF_Action&)action != CPDF_Action(m_pAnnot->m_pAnnotDict->GetDict( "A")))
1103 »
1104 » ASSERT(action != NULL);
1105 »
1106 » if ((CPDF_Action&)action != m_pAnnot->m_pAnnotDict->GetDict("A"))
1107 { 1100 {
1108 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 1101 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
1109 » » ASSERT(pDoc != NULL); 1102 » » CPDF_Dictionary* pDict = action.GetDict();
1110 » » 1103 » » if (pDict && pDict->GetObjNum() == 0) {
1111 » » if (action.m_pDict && (action.m_pDict->GetObjNum() == 0)) 1104 » » » pDoc->AddIndirectObject(pDict);
1112 » » » pDoc->AddIndirectObject(action.m_pDict); 1105 » » }
1113 » » m_pAnnot->m_pAnnotDict->SetAtReference("A", pDoc, action.m_pDict ->GetObjNum()); 1106 » » m_pAnnot->m_pAnnotDict->SetAtReference("A", pDoc, pDict->GetObjN um());
1114 } 1107 }
1115 } 1108 }
1116 1109
1117 void CPDFSDK_Annot::RemoveAction() 1110 void CPDFSDK_Annot::RemoveAction()
1118 { 1111 {
1119 ASSERT(m_pAnnot != NULL);
1120 ASSERT(m_pAnnot->m_pAnnotDict != NULL);
1121
1122 m_pAnnot->m_pAnnotDict->RemoveAt("A"); 1112 m_pAnnot->m_pAnnotDict->RemoveAt("A");
1123 } 1113 }
1124 1114
1125 CPDF_AAction CPDFSDK_Annot::GetAAction() const 1115 CPDF_AAction CPDFSDK_Annot::GetAAction() const
1126 { 1116 {
1127 ASSERT(m_pAnnot != NULL);
1128 ASSERT(m_pAnnot->m_pAnnotDict != NULL);
1129
1130 return m_pAnnot->m_pAnnotDict->GetDict("AA"); 1117 return m_pAnnot->m_pAnnotDict->GetDict("AA");
1131 } 1118 }
1132 1119
1133 void CPDFSDK_Annot::SetAAction(const CPDF_AAction& aa) 1120 void CPDFSDK_Annot::SetAAction(const CPDF_AAction& aa)
1134 { 1121 {
1135 ASSERT(m_pAnnot != NULL); 1122 ASSERT(m_pAnnot != NULL);
1136 ASSERT(m_pAnnot->m_pAnnotDict != NULL); 1123 ASSERT(m_pAnnot->m_pAnnotDict != NULL);
1137 ASSERT(aa != NULL); 1124 ASSERT(aa != NULL);
1138 1125
1139 if ((CPDF_AAction&)aa != m_pAnnot->m_pAnnotDict->GetDict("AA")) 1126 if ((CPDF_AAction&)aa != m_pAnnot->m_pAnnotDict->GetDict("AA"))
1140 m_pAnnot->m_pAnnotDict->SetAt("AA", (CPDF_AAction&)aa); 1127 m_pAnnot->m_pAnnotDict->SetAt("AA", (CPDF_AAction&)aa);
1141 } 1128 }
1142 1129
1143 void CPDFSDK_Annot::RemoveAAction() 1130 void CPDFSDK_Annot::RemoveAAction()
1144 { 1131 {
1145 ASSERT(m_pAnnot != NULL); 1132 ASSERT(m_pAnnot != NULL);
1146 ASSERT(m_pAnnot->m_pAnnotDict != NULL); 1133 ASSERT(m_pAnnot->m_pAnnotDict != NULL);
1147 1134
1148 m_pAnnot->m_pAnnotDict->RemoveAt("AA"); 1135 m_pAnnot->m_pAnnotDict->RemoveAt("AA");
1149 } 1136 }
1150 1137
1151 CPDF_Action CPDFSDK_Annot::GetAAction(CPDF_AAction::AActionType eAAT) 1138 CPDF_Action CPDFSDK_Annot::GetAAction(CPDF_AAction::AActionType eAAT)
1152 { 1139 {
1153 CPDF_AAction AAction = GetAAction(); 1140 CPDF_AAction AAction = GetAAction();
1154 » 1141
1155 if (AAction.ActionExist(eAAT)) 1142 if (AAction.ActionExist(eAAT))
1156 {
1157 return AAction.GetAction(eAAT); 1143 return AAction.GetAction(eAAT);
1158 » } 1144
1159 » else if (eAAT == CPDF_AAction::ButtonUp) 1145 » if (eAAT == CPDF_AAction::ButtonUp)
1160 » {
1161 return GetAction(); 1146 return GetAction();
1162 » } 1147
1163 » 1148 » return CPDF_Action();
1164 » return NULL;
1165 } 1149 }
1166 1150
1167 void CPDFSDK_Annot::Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2 Device, CPDF_RenderOptions* pOptions) 1151 void CPDFSDK_Annot::Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2 Device, CPDF_RenderOptions* pOptions)
1168 { 1152 {
1169 1153
1170 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); 1154 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal);
1171 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Devic e, CPDF_Annot::Normal, NULL); 1155 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Devic e, CPDF_Annot::Normal, NULL);
1172 1156
1173 return ; 1157 return ;
1174 } 1158 }
1175 1159
1176 CPDF_Page* CPDFSDK_Annot::GetPDFPage() 1160 CPDF_Page* CPDFSDK_Annot::GetPDFPage()
1177 { 1161 {
1178 if(m_pPageView) 1162 if(m_pPageView)
1179 return m_pPageView->GetPDFPage(); 1163 return m_pPageView->GetPDFPage();
1180 return NULL; 1164 return NULL;
1181 } 1165 }
1182 1166
OLDNEW
« no previous file with comments | « fpdfsdk/src/fsdk_actionhandler.cpp ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698