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