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

Side by Side Diff: core/src/fpdfdoc/doc_annot.cpp

Issue 1420583003: Revert "Revert "Add type cast definitions for CPDF_Dictionary."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 2 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 | « core/src/fpdfdoc/doc_action.cpp ('k') | core/src/fpdfdoc/doc_basic.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 "../../../third_party/base/nonstd_unique_ptr.h" 7 #include "../../../third_party/base/nonstd_unique_ptr.h"
8 #include "../../include/fpdfdoc/fpdf_doc.h" 8 #include "../../include/fpdfdoc/fpdf_doc.h"
9 #include "../../include/fpdfapi/fpdf_pageobj.h" 9 #include "../../include/fpdfapi/fpdf_pageobj.h"
10 10
11 CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) { 11 CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) {
12 ASSERT(pPage != NULL); 12 ASSERT(pPage != NULL);
13 m_pPageDict = pPage->m_pFormDict; 13 m_pPageDict = pPage->m_pFormDict;
14 if (m_pPageDict == NULL) { 14 if (m_pPageDict == NULL) {
15 return; 15 return;
16 } 16 }
17 m_pDocument = pPage->m_pDocument; 17 m_pDocument = pPage->m_pDocument;
18 CPDF_Array* pAnnots = m_pPageDict->GetArray("Annots"); 18 CPDF_Array* pAnnots = m_pPageDict->GetArray("Annots");
19 if (pAnnots == NULL) { 19 if (pAnnots == NULL) {
20 return; 20 return;
21 } 21 }
22 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); 22 CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
23 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); 23 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");
24 FX_BOOL bRegenerateAP = pAcroForm && pAcroForm->GetBoolean("NeedAppearances"); 24 FX_BOOL bRegenerateAP = pAcroForm && pAcroForm->GetBoolean("NeedAppearances");
25 for (FX_DWORD i = 0; i < pAnnots->GetCount(); ++i) { 25 for (FX_DWORD i = 0; i < pAnnots->GetCount(); ++i) {
26 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i); 26 CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetElementValue(i));
27 if (pDict == NULL || pDict->GetType() != PDFOBJ_DICTIONARY) { 27 if (!pDict) {
28 continue; 28 continue;
29 } 29 }
30 FX_DWORD dwObjNum = pDict->GetObjNum(); 30 FX_DWORD dwObjNum = pDict->GetObjNum();
31 if (dwObjNum == 0) { 31 if (dwObjNum == 0) {
32 dwObjNum = m_pDocument->AddIndirectObject(pDict); 32 dwObjNum = m_pDocument->AddIndirectObject(pDict);
33 CPDF_Reference* pAction = new CPDF_Reference(m_pDocument, dwObjNum); 33 CPDF_Reference* pAction = new CPDF_Reference(m_pDocument, dwObjNum);
34 pAnnots->InsertAt(i, pAction); 34 pAnnots->InsertAt(i, pAction);
35 pAnnots->RemoveAt(i + 1); 35 pAnnots->RemoveAt(i + 1);
36 pDict = pAnnots->GetDict(i); 36 pDict = pAnnots->GetDict(i);
37 } 37 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 if (!pAP->KeyExist(ap_entry)) { 195 if (!pAP->KeyExist(ap_entry)) {
196 ap_entry = "N"; 196 ap_entry = "N";
197 } 197 }
198 CPDF_Object* psub = pAP->GetElementValue(ap_entry); 198 CPDF_Object* psub = pAP->GetElementValue(ap_entry);
199 if (psub == NULL) { 199 if (psub == NULL) {
200 return NULL; 200 return NULL;
201 } 201 }
202 CPDF_Stream* pStream = NULL; 202 CPDF_Stream* pStream = NULL;
203 if (psub->GetType() == PDFOBJ_STREAM) { 203 if (psub->GetType() == PDFOBJ_STREAM) {
204 pStream = (CPDF_Stream*)psub; 204 pStream = (CPDF_Stream*)psub;
205 } else if (psub->GetType() == PDFOBJ_DICTIONARY) { 205 } else if (CPDF_Dictionary* pDict = psub->AsDictionary()) {
206 CFX_ByteString as = pAnnotDict->GetString("AS"); 206 CFX_ByteString as = pAnnotDict->GetString("AS");
207 if (as.IsEmpty()) { 207 if (as.IsEmpty()) {
208 CFX_ByteString value = pAnnotDict->GetString(FX_BSTRC("V")); 208 CFX_ByteString value = pAnnotDict->GetString(FX_BSTRC("V"));
209 if (value.IsEmpty()) { 209 if (value.IsEmpty()) {
210 CPDF_Dictionary* pDict = pAnnotDict->GetDict(FX_BSTRC("Parent")); 210 CPDF_Dictionary* pDict = pAnnotDict->GetDict(FX_BSTRC("Parent"));
211 value = pDict ? pDict->GetString(FX_BSTRC("V")) : CFX_ByteString(); 211 value = pDict ? pDict->GetString(FX_BSTRC("V")) : CFX_ByteString();
212 } 212 }
213 if (value.IsEmpty() || !((CPDF_Dictionary*)psub)->KeyExist(value)) { 213 if (value.IsEmpty() || !pDict->KeyExist(value)) {
214 as = FX_BSTRC("Off"); 214 as = FX_BSTRC("Off");
215 } else { 215 } else {
216 as = value; 216 as = value;
217 } 217 }
218 } 218 }
219 pStream = ((CPDF_Dictionary*)psub)->GetStream(as); 219 pStream = pDict->GetStream(as);
220 } 220 }
221 return pStream; 221 return pStream;
222 } 222 }
223 CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) { 223 CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) {
224 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pAnnotDict, mode); 224 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pAnnotDict, mode);
225 if (pStream == NULL) { 225 if (pStream == NULL) {
226 return NULL; 226 return NULL;
227 } 227 }
228 CPDF_Form* pForm; 228 CPDF_Form* pForm;
229 if (m_APMap.Lookup(pStream, (void*&)pForm)) { 229 if (m_APMap.Lookup(pStream, (void*&)pForm)) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 CPDF_PathData path; 374 CPDF_PathData path;
375 width /= 2; 375 width /= 2;
376 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, 376 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width,
377 rect.top - width); 377 rect.top - width);
378 int fill_type = 0; 378 int fill_type = 0;
379 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { 379 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) {
380 fill_type |= FXFILL_NOPATHSMOOTH; 380 fill_type |= FXFILL_NOPATHSMOOTH;
381 } 381 }
382 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); 382 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type);
383 } 383 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_action.cpp ('k') | core/src/fpdfdoc/doc_basic.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698