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

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

Issue 1422513004: Merge to XFA: Add type cast definitions for CPDF_Stream. (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
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
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 return m_pAnnotDict; 183 return m_pAnnotDict;
184 } 184 }
185 185
186 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, 186 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
187 CPDF_Annot::AppearanceMode mode) { 187 CPDF_Annot::AppearanceMode mode) {
188 CPDF_Dictionary* pAP = pAnnotDict->GetDict("AP"); 188 CPDF_Dictionary* pAP = pAnnotDict->GetDict("AP");
189 if (pAP == NULL) { 189 if (pAP == NULL) {
190 return NULL; 190 return NULL;
191 } 191 }
192 const FX_CHAR* ap_entry = "N"; 192 const FX_CHAR* ap_entry = "N";
193 if (mode == CPDF_Annot::Down) { 193 if (mode == CPDF_Annot::Down)
194 ap_entry = "D"; 194 ap_entry = "D";
195 } else if (mode == CPDF_Annot::Rollover) { 195 else if (mode == CPDF_Annot::Rollover)
196 ap_entry = "R"; 196 ap_entry = "R";
197 } 197 if (!pAP->KeyExist(ap_entry))
198 if (!pAP->KeyExist(ap_entry)) {
199 ap_entry = "N"; 198 ap_entry = "N";
200 } 199
201 CPDF_Object* psub = pAP->GetElementValue(ap_entry); 200 CPDF_Object* psub = pAP->GetElementValue(ap_entry);
202 if (psub == NULL) { 201 if (!psub)
203 return NULL; 202 return nullptr;
204 } 203 if (CPDF_Stream* pStream = psub->AsStream())
205 CPDF_Stream* pStream = NULL; 204 return pStream;
206 if (psub->GetType() == PDFOBJ_STREAM) { 205
207 pStream = (CPDF_Stream*)psub; 206 if (CPDF_Dictionary* pDict = psub->AsDictionary()) {
208 } else if (CPDF_Dictionary* pDict = psub->AsDictionary()) {
209 CFX_ByteString as = pAnnotDict->GetString("AS"); 207 CFX_ByteString as = pAnnotDict->GetString("AS");
210 if (as.IsEmpty()) { 208 if (as.IsEmpty()) {
211 CFX_ByteString value = pAnnotDict->GetString(FX_BSTRC("V")); 209 CFX_ByteString value = pAnnotDict->GetString(FX_BSTRC("V"));
212 if (value.IsEmpty()) { 210 if (value.IsEmpty()) {
213 CPDF_Dictionary* pDict = pAnnotDict->GetDict(FX_BSTRC("Parent")); 211 CPDF_Dictionary* pDict = pAnnotDict->GetDict(FX_BSTRC("Parent"));
214 value = pDict ? pDict->GetString(FX_BSTRC("V")) : CFX_ByteString(); 212 value = pDict ? pDict->GetString(FX_BSTRC("V")) : CFX_ByteString();
215 } 213 }
216 if (value.IsEmpty() || !pDict->KeyExist(value)) { 214 if (value.IsEmpty() || !pDict->KeyExist(value))
217 as = FX_BSTRC("Off"); 215 as = FX_BSTRC("Off");
218 } else { 216 else
219 as = value; 217 as = value;
220 }
221 } 218 }
222 pStream = pDict->GetStream(as); 219 return pDict->GetStream(as);
223 } 220 }
224 return pStream; 221 return nullptr;
225 } 222 }
226 CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) { 223 CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) {
227 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pAnnotDict, mode); 224 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pAnnotDict, mode);
228 if (pStream == NULL) { 225 if (pStream == NULL) {
229 return NULL; 226 return NULL;
230 } 227 }
231 CPDF_Form* pForm; 228 CPDF_Form* pForm;
232 if (m_APMap.Lookup(pStream, (void*&)pForm)) { 229 if (m_APMap.Lookup(pStream, (void*&)pForm)) {
233 return pForm; 230 return pForm;
234 } 231 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 CPDF_PathData path; 374 CPDF_PathData path;
378 width /= 2; 375 width /= 2;
379 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, 376 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width,
380 rect.top - width); 377 rect.top - width);
381 int fill_type = 0; 378 int fill_type = 0;
382 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { 379 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) {
383 fill_type |= FXFILL_NOPATHSMOOTH; 380 fill_type |= FXFILL_NOPATHSMOOTH;
384 } 381 }
385 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); 382 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type);
386 } 383 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698