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

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

Issue 1410343003: [Merge to XFA] Revert "Revert "Add type cast definitions for CPDF_Dictionary."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Rebase to origin/xfa 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 = CPDF_Reference::Create(m_pDocument, dwObjNum); 33 CPDF_Reference* pAction = CPDF_Reference::Create(m_pDocument, dwObjNum);
34 if (pAction == NULL) { 34 if (pAction == NULL) {
35 break; 35 break;
36 } 36 }
37 pAnnots->InsertAt(i, pAction); 37 pAnnots->InsertAt(i, pAction);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (!pAP->KeyExist(ap_entry)) { 198 if (!pAP->KeyExist(ap_entry)) {
199 ap_entry = "N"; 199 ap_entry = "N";
200 } 200 }
201 CPDF_Object* psub = pAP->GetElementValue(ap_entry); 201 CPDF_Object* psub = pAP->GetElementValue(ap_entry);
202 if (psub == NULL) { 202 if (psub == NULL) {
203 return NULL; 203 return NULL;
204 } 204 }
205 CPDF_Stream* pStream = NULL; 205 CPDF_Stream* pStream = NULL;
206 if (psub->GetType() == PDFOBJ_STREAM) { 206 if (psub->GetType() == PDFOBJ_STREAM) {
207 pStream = (CPDF_Stream*)psub; 207 pStream = (CPDF_Stream*)psub;
208 } else if (psub->GetType() == PDFOBJ_DICTIONARY) { 208 } else if (CPDF_Dictionary* pDict = psub->AsDictionary()) {
209 CFX_ByteString as = pAnnotDict->GetString("AS"); 209 CFX_ByteString as = pAnnotDict->GetString("AS");
210 if (as.IsEmpty()) { 210 if (as.IsEmpty()) {
211 CFX_ByteString value = pAnnotDict->GetString(FX_BSTRC("V")); 211 CFX_ByteString value = pAnnotDict->GetString(FX_BSTRC("V"));
212 if (value.IsEmpty()) { 212 if (value.IsEmpty()) {
213 CPDF_Dictionary* pDict = pAnnotDict->GetDict(FX_BSTRC("Parent")); 213 CPDF_Dictionary* pDict = pAnnotDict->GetDict(FX_BSTRC("Parent"));
214 value = pDict ? pDict->GetString(FX_BSTRC("V")) : CFX_ByteString(); 214 value = pDict ? pDict->GetString(FX_BSTRC("V")) : CFX_ByteString();
215 } 215 }
216 if (value.IsEmpty() || !((CPDF_Dictionary*)psub)->KeyExist(value)) { 216 if (value.IsEmpty() || !pDict->KeyExist(value)) {
217 as = FX_BSTRC("Off"); 217 as = FX_BSTRC("Off");
218 } else { 218 } else {
219 as = value; 219 as = value;
220 } 220 }
221 } 221 }
222 pStream = ((CPDF_Dictionary*)psub)->GetStream(as); 222 pStream = pDict->GetStream(as);
223 } 223 }
224 return pStream; 224 return pStream;
225 } 225 }
226 CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) { 226 CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) {
227 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pAnnotDict, mode); 227 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pAnnotDict, mode);
228 if (pStream == NULL) { 228 if (pStream == NULL) {
229 return NULL; 229 return NULL;
230 } 230 }
231 CPDF_Form* pForm; 231 CPDF_Form* pForm;
232 if (m_APMap.Lookup(pStream, (void*&)pForm)) { 232 if (m_APMap.Lookup(pStream, (void*&)pForm)) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 CPDF_PathData path; 377 CPDF_PathData path;
378 width /= 2; 378 width /= 2;
379 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, 379 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width,
380 rect.top - width); 380 rect.top - width);
381 int fill_type = 0; 381 int fill_type = 0;
382 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { 382 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) {
383 fill_type |= FXFILL_NOPATHSMOOTH; 383 fill_type |= FXFILL_NOPATHSMOOTH;
384 } 384 }
385 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); 385 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type);
386 } 386 }
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