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/include/cpdf_annot.h" | 7 #include "core/fpdfdoc/include/cpdf_annot.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" |
10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
13 #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" | 13 #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" |
14 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" | 14 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" |
15 #include "core/fpdfdoc/cpvt_generateap.h" | 15 #include "core/fpdfdoc/cpvt_generateap.h" |
16 #include "core/fxcrt/include/fx_memory.h" | 16 #include "core/fxcrt/include/fx_memory.h" |
17 #include "core/fxge/include/cfx_graphstatedata.h" | 17 #include "core/fxge/include/cfx_graphstatedata.h" |
18 #include "core/fxge/include/cfx_pathdata.h" | 18 #include "core/fxge/include/cfx_pathdata.h" |
19 #include "core/fxge/include/cfx_renderdevice.h" | 19 #include "core/fxge/include/cfx_renderdevice.h" |
20 | 20 |
21 CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument) | 21 CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, |
22 : m_pAnnotDict(pDict), | 22 CPDF_Document* pDocument, |
| 23 bool bToOwnDict) |
| 24 : m_bOwnedAnnotDict(bToOwnDict), |
| 25 m_pAnnotDict(pDict), |
23 m_pDocument(pDocument), | 26 m_pDocument(pDocument), |
24 m_bOpenState(false), | 27 m_bOpenState(false), |
25 m_pPopupAnnot(nullptr) { | 28 m_pPopupAnnot(nullptr) { |
26 m_nSubtype = StringToAnnotSubtype(m_pAnnotDict->GetStringBy("Subtype")); | 29 m_nSubtype = StringToAnnotSubtype(m_pAnnotDict->GetStringBy("Subtype")); |
27 GenerateAPIfNeeded(); | 30 GenerateAPIfNeeded(); |
28 } | 31 } |
29 | 32 |
30 CPDF_Annot::~CPDF_Annot() { | 33 CPDF_Annot::~CPDF_Annot() { |
| 34 if (m_bOwnedAnnotDict) |
| 35 m_pAnnotDict->Release(); |
31 ClearCachedAP(); | 36 ClearCachedAP(); |
32 } | 37 } |
33 | 38 |
34 void CPDF_Annot::GenerateAPIfNeeded() { | 39 void CPDF_Annot::GenerateAPIfNeeded() { |
35 if (m_nSubtype == CPDF_Annot::Subtype::CIRCLE) | 40 if (m_nSubtype == CPDF_Annot::Subtype::CIRCLE) |
36 CPVT_GenerateAP::GenerateCircleAP(m_pDocument, m_pAnnotDict); | 41 CPVT_GenerateAP::GenerateCircleAP(m_pDocument, m_pAnnotDict); |
37 else if (m_nSubtype == CPDF_Annot::Subtype::HIGHLIGHT) | 42 else if (m_nSubtype == CPDF_Annot::Subtype::HIGHLIGHT) |
38 CPVT_GenerateAP::GenerateHighlightAP(m_pDocument, m_pAnnotDict); | 43 CPVT_GenerateAP::GenerateHighlightAP(m_pDocument, m_pAnnotDict); |
39 else if (m_nSubtype == CPDF_Annot::Subtype::INK) | 44 else if (m_nSubtype == CPDF_Annot::Subtype::INK) |
40 CPVT_GenerateAP::GenerateInkAP(m_pDocument, m_pAnnotDict); | 45 CPVT_GenerateAP::GenerateInkAP(m_pDocument, m_pAnnotDict); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 CFX_PathData path; | 407 CFX_PathData path; |
403 width /= 2; | 408 width /= 2; |
404 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, | 409 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, |
405 rect.top - width); | 410 rect.top - width); |
406 int fill_type = 0; | 411 int fill_type = 0; |
407 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { | 412 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { |
408 fill_type |= FXFILL_NOPATHSMOOTH; | 413 fill_type |= FXFILL_NOPATHSMOOTH; |
409 } | 414 } |
410 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); | 415 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); |
411 } | 416 } |
OLD | NEW |