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_annotlist.h" | 7 #include "core/fpdfdoc/cpdf_annotlist.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "core/fpdfapi/page/cpdf_page.h" | 12 #include "core/fpdfapi/page/cpdf_page.h" |
13 #include "core/fpdfapi/parser/cpdf_document.h" | 13 #include "core/fpdfapi/parser/cpdf_document.h" |
14 #include "core/fpdfapi/parser/cpdf_reference.h" | 14 #include "core/fpdfapi/parser/cpdf_reference.h" |
15 #include "core/fpdfapi/render/cpdf_renderoptions.h" | 15 #include "core/fpdfapi/render/cpdf_renderoptions.h" |
16 #include "core/fpdfdoc/cpdf_annot.h" | 16 #include "core/fpdfdoc/cpdf_annot.h" |
17 #include "core/fpdfdoc/cpdf_interform.h" | 17 #include "core/fpdfdoc/cpdf_interform.h" |
18 #include "core/fpdfdoc/cpdf_occontext.h" | 18 #include "core/fpdfdoc/cpdf_occontext.h" |
19 #include "core/fpdfdoc/cpvt_generateap.h" | 19 #include "core/fpdfdoc/cpvt_generateap.h" |
20 #include "core/fxge/cfx_renderdevice.h" | 20 #include "core/fxge/cfx_renderdevice.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 std::unique_ptr<CPDF_Annot> CreatePopupAnnot(CPDF_Annot* pAnnot, | 24 std::unique_ptr<CPDF_Annot> CreatePopupAnnot(CPDF_Annot* pAnnot, |
25 CPDF_Document* pDocument) { | 25 CPDF_Document* pDocument) { |
26 CPDF_Dictionary* pParentDict = pAnnot->GetAnnotDict(); | 26 CPDF_Dictionary* pParentDict = pAnnot->GetAnnotDict(); |
27 if (!pParentDict) | 27 if (!pParentDict) |
28 return std::unique_ptr<CPDF_Annot>(); | 28 return nullptr; |
29 | 29 |
30 // TODO(jaepark): We shouldn't strip BOM for some strings and not for others. | 30 // TODO(jaepark): We shouldn't strip BOM for some strings and not for others. |
31 // See pdfium:593. | 31 // See pdfium:593. |
32 CFX_WideString sContents = pParentDict->GetUnicodeTextFor("Contents"); | 32 CFX_WideString sContents = pParentDict->GetUnicodeTextFor("Contents"); |
33 if (sContents.IsEmpty()) | 33 if (sContents.IsEmpty()) |
34 return std::unique_ptr<CPDF_Annot>(); | 34 return nullptr; |
35 | 35 |
36 CPDF_Dictionary* pAnnotDict = | 36 CPDF_Dictionary* pAnnotDict = |
37 new CPDF_Dictionary(pDocument->GetByteStringPool()); | 37 new CPDF_Dictionary(pDocument->GetByteStringPool()); |
38 pAnnotDict->SetNameFor("Type", "Annot"); | 38 pAnnotDict->SetNameFor("Type", "Annot"); |
39 pAnnotDict->SetNameFor("Subtype", "Popup"); | 39 pAnnotDict->SetNameFor("Subtype", "Popup"); |
40 pAnnotDict->SetStringFor("T", pParentDict->GetStringFor("T")); | 40 pAnnotDict->SetStringFor("T", pParentDict->GetStringFor("T")); |
41 pAnnotDict->SetStringFor("Contents", sContents.UTF8Encode()); | 41 pAnnotDict->SetStringFor("Contents", sContents.UTF8Encode()); |
42 | 42 |
43 CFX_FloatRect rect = pParentDict->GetRectFor("Rect"); | 43 CFX_FloatRect rect = pParentDict->GetRectFor("Rect"); |
44 rect.Normalize(); | 44 rect.Normalize(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 CPDF_RenderContext* pContext, | 170 CPDF_RenderContext* pContext, |
171 FX_BOOL bPrinting, | 171 FX_BOOL bPrinting, |
172 CFX_Matrix* pMatrix, | 172 CFX_Matrix* pMatrix, |
173 FX_BOOL bShowWidget, | 173 FX_BOOL bShowWidget, |
174 CPDF_RenderOptions* pOptions) { | 174 CPDF_RenderOptions* pOptions) { |
175 uint32_t dwAnnotFlags = bShowWidget ? ANNOTFLAG_INVISIBLE | ANNOTFLAG_HIDDEN | 175 uint32_t dwAnnotFlags = bShowWidget ? ANNOTFLAG_INVISIBLE | ANNOTFLAG_HIDDEN |
176 : ANNOTFLAG_INVISIBLE; | 176 : ANNOTFLAG_INVISIBLE; |
177 DisplayAnnots(pPage, nullptr, pContext, bPrinting, pMatrix, dwAnnotFlags, | 177 DisplayAnnots(pPage, nullptr, pContext, bPrinting, pMatrix, dwAnnotFlags, |
178 pOptions, nullptr); | 178 pOptions, nullptr); |
179 } | 179 } |
OLD | NEW |