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, CPDF_Document* pDocument) |
22 : m_pAnnotDict(pDict), | 22 : m_pAnnotDict(pDict), |
23 m_pDocument(pDocument), | 23 m_pDocument(pDocument), |
24 m_sSubtype(m_pAnnotDict->GetStringBy("Subtype")) { | 24 m_sSubtype(m_pAnnotDict->GetStringBy("Subtype")), |
| 25 m_bOpenState(false), |
| 26 m_pPopupAnnot(nullptr) { |
25 GenerateAPIfNeeded(); | 27 GenerateAPIfNeeded(); |
26 } | 28 } |
27 | 29 |
28 CPDF_Annot::~CPDF_Annot() { | 30 CPDF_Annot::~CPDF_Annot() { |
29 ClearCachedAP(); | 31 ClearCachedAP(); |
30 } | 32 } |
31 | 33 |
32 void CPDF_Annot::GenerateAPIfNeeded() { | 34 void CPDF_Annot::GenerateAPIfNeeded() { |
33 if (m_sSubtype == "Circle") | 35 if (m_sSubtype == "Circle") |
34 CPVT_GenerateAP::GenerateCircleAP(m_pDocument, m_pAnnotDict); | 36 CPVT_GenerateAP::GenerateCircleAP(m_pDocument, m_pAnnotDict); |
35 else if (m_sSubtype == "Highlight") | 37 else if (m_sSubtype == "Highlight") |
36 CPVT_GenerateAP::GenerateHighlightAP(m_pDocument, m_pAnnotDict); | 38 CPVT_GenerateAP::GenerateHighlightAP(m_pDocument, m_pAnnotDict); |
37 else if (m_sSubtype == "Ink") | 39 else if (m_sSubtype == "Ink") |
38 CPVT_GenerateAP::GenerateInkAP(m_pDocument, m_pAnnotDict); | 40 CPVT_GenerateAP::GenerateInkAP(m_pDocument, m_pAnnotDict); |
| 41 else if (m_sSubtype == "Popup") |
| 42 CPVT_GenerateAP::GeneratePopupAP(m_pDocument, m_pAnnotDict); |
39 else if (m_sSubtype == "Square") | 43 else if (m_sSubtype == "Square") |
40 CPVT_GenerateAP::GenerateSquareAP(m_pDocument, m_pAnnotDict); | 44 CPVT_GenerateAP::GenerateSquareAP(m_pDocument, m_pAnnotDict); |
41 else if (m_sSubtype == "Squiggly") | 45 else if (m_sSubtype == "Squiggly") |
42 CPVT_GenerateAP::GenerateSquigglyAP(m_pDocument, m_pAnnotDict); | 46 CPVT_GenerateAP::GenerateSquigglyAP(m_pDocument, m_pAnnotDict); |
43 else if (m_sSubtype == "StrikeOut") | 47 else if (m_sSubtype == "StrikeOut") |
44 CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument, m_pAnnotDict); | 48 CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument, m_pAnnotDict); |
45 else if (m_sSubtype == "Text") | 49 else if (m_sSubtype == "Text") |
46 CPVT_GenerateAP::GenerateTextAP(m_pDocument, m_pAnnotDict); | 50 CPVT_GenerateAP::GenerateTextAP(m_pDocument, m_pAnnotDict); |
47 else if (m_sSubtype == "Underline") | 51 else if (m_sSubtype == "Underline") |
48 CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, m_pAnnotDict); | 52 CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, m_pAnnotDict); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } | 149 } |
146 | 150 |
147 FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage, | 151 FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage, |
148 CFX_RenderDevice* pDevice, | 152 CFX_RenderDevice* pDevice, |
149 const CFX_Matrix* pUser2Device, | 153 const CFX_Matrix* pUser2Device, |
150 AppearanceMode mode, | 154 AppearanceMode mode, |
151 const CPDF_RenderOptions* pOptions) { | 155 const CPDF_RenderOptions* pOptions) { |
152 if (IsAnnotationHidden(m_pAnnotDict)) | 156 if (IsAnnotationHidden(m_pAnnotDict)) |
153 return FALSE; | 157 return FALSE; |
154 | 158 |
| 159 if (m_sSubtype == "Popup" && !m_bOpenState) |
| 160 return FALSE; |
| 161 |
155 // It might happen that by the time this annotation instance was created, | 162 // It might happen that by the time this annotation instance was created, |
156 // it was flagged as "hidden" (e.g. /F 2), and hence CPVT_GenerateAP decided | 163 // it was flagged as "hidden" (e.g. /F 2), and hence CPVT_GenerateAP decided |
157 // to not "generate" its AP. | 164 // to not "generate" its AP. |
158 // If for a reason the object is no longer hidden, but still does not have | 165 // If for a reason the object is no longer hidden, but still does not have |
159 // its "AP" generated, generate it now. | 166 // its "AP" generated, generate it now. |
160 GenerateAPIfNeeded(); | 167 GenerateAPIfNeeded(); |
161 | 168 |
162 CFX_Matrix matrix; | 169 CFX_Matrix matrix; |
163 CPDF_Form* pForm = | 170 CPDF_Form* pForm = |
164 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); | 171 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 CFX_PathData path; | 282 CFX_PathData path; |
276 width /= 2; | 283 width /= 2; |
277 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, | 284 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, |
278 rect.top - width); | 285 rect.top - width); |
279 int fill_type = 0; | 286 int fill_type = 0; |
280 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { | 287 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { |
281 fill_type |= FXFILL_NOPATHSMOOTH; | 288 fill_type |= FXFILL_NOPATHSMOOTH; |
282 } | 289 } |
283 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); | 290 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); |
284 } | 291 } |
OLD | NEW |