OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfdoc/cpdf_annot.h" | 7 #include "core/fpdfdoc/cpdf_annot.h" |
8 | 8 |
| 9 #include <utility> |
| 10 |
9 #include "core/fpdfapi/page/cpdf_form.h" | 11 #include "core/fpdfapi/page/cpdf_form.h" |
10 #include "core/fpdfapi/page/cpdf_page.h" | 12 #include "core/fpdfapi/page/cpdf_page.h" |
11 #include "core/fpdfapi/parser/cpdf_array.h" | 13 #include "core/fpdfapi/parser/cpdf_array.h" |
12 #include "core/fpdfapi/parser/cpdf_boolean.h" | 14 #include "core/fpdfapi/parser/cpdf_boolean.h" |
13 #include "core/fpdfapi/parser/cpdf_document.h" | 15 #include "core/fpdfapi/parser/cpdf_document.h" |
14 #include "core/fpdfapi/render/cpdf_rendercontext.h" | 16 #include "core/fpdfapi/render/cpdf_rendercontext.h" |
15 #include "core/fpdfapi/render/cpdf_renderoptions.h" | 17 #include "core/fpdfapi/render/cpdf_renderoptions.h" |
16 #include "core/fpdfdoc/cpvt_generateap.h" | 18 #include "core/fpdfdoc/cpvt_generateap.h" |
17 #include "core/fxcrt/fx_memory.h" | 19 #include "core/fxcrt/fx_memory.h" |
18 #include "core/fxge/cfx_graphstatedata.h" | 20 #include "core/fxge/cfx_graphstatedata.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 200 |
199 CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) { | 201 CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) { |
200 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pAnnotDict, mode); | 202 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pAnnotDict, mode); |
201 if (!pStream) | 203 if (!pStream) |
202 return nullptr; | 204 return nullptr; |
203 | 205 |
204 auto it = m_APMap.find(pStream); | 206 auto it = m_APMap.find(pStream); |
205 if (it != m_APMap.end()) | 207 if (it != m_APMap.end()) |
206 return it->second.get(); | 208 return it->second.get(); |
207 | 209 |
208 CPDF_Form* pNewForm = | 210 auto pNewForm = |
209 new CPDF_Form(m_pDocument, pPage->m_pResources, pStream); | 211 pdfium::MakeUnique<CPDF_Form>(m_pDocument, pPage->m_pResources, pStream); |
210 pNewForm->ParseContent(nullptr, nullptr, nullptr); | 212 pNewForm->ParseContent(nullptr, nullptr, nullptr); |
211 m_APMap[pStream] = pdfium::WrapUnique(pNewForm); | 213 |
212 return pNewForm; | 214 CPDF_Form* pResult = pNewForm.get(); |
| 215 m_APMap[pStream] = std::move(pNewForm); |
| 216 return pResult; |
213 } | 217 } |
214 | 218 |
215 // Static. | 219 // Static. |
216 CFX_FloatRect CPDF_Annot::RectFromQuadPoints(CPDF_Dictionary* pAnnotDict) { | 220 CFX_FloatRect CPDF_Annot::RectFromQuadPoints(CPDF_Dictionary* pAnnotDict) { |
217 CPDF_Array* pArray = pAnnotDict->GetArrayFor("QuadPoints"); | 221 CPDF_Array* pArray = pAnnotDict->GetArrayFor("QuadPoints"); |
218 if (!pArray) | 222 if (!pArray) |
219 return CFX_FloatRect(); | 223 return CFX_FloatRect(); |
220 | 224 |
221 // QuadPoints are defined with 4 pairs of numbers | 225 // QuadPoints are defined with 4 pairs of numbers |
222 // ([ pair0, pair1, pair2, pair3 ]), where | 226 // ([ pair0, pair1, pair2, pair3 ]), where |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 CFX_PathData path; | 501 CFX_PathData path; |
498 width /= 2; | 502 width /= 2; |
499 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, | 503 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, |
500 rect.top - width); | 504 rect.top - width); |
501 int fill_type = 0; | 505 int fill_type = 0; |
502 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { | 506 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { |
503 fill_type |= FXFILL_NOPATHSMOOTH; | 507 fill_type |= FXFILL_NOPATHSMOOTH; |
504 } | 508 } |
505 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); | 509 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); |
506 } | 510 } |
OLD | NEW |