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_annotlist.h" | 7 #include "core/fpdfdoc/include/cpdf_annotlist.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" | 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" |
12 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" | 12 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" |
13 #include "core/fpdfdoc/cpvt_generateap.h" | 13 #include "core/fpdfdoc/cpvt_generateap.h" |
14 #include "core/fpdfdoc/include/cpdf_annot.h" | 14 #include "core/fpdfdoc/include/cpdf_annot.h" |
15 #include "core/fpdfdoc/include/cpdf_interform.h" | 15 #include "core/fpdfdoc/include/cpdf_interform.h" |
16 #include "core/fpdfdoc/include/cpdf_occontext.h" | 16 #include "core/fpdfdoc/include/cpdf_occontext.h" |
17 #include "core/fxge/include/cfx_renderdevice.h" | 17 #include "core/fxge/include/cfx_renderdevice.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 std::unique_ptr<CPDF_Annot> CreatePopupAnnot(CPDF_Annot* pAnnot, | 21 std::unique_ptr<CPDF_Annot> CreatePopupAnnot(CPDF_Annot* pAnnot, |
22 CPDF_Document* pDocument) { | 22 CPDF_Document* pDocument) { |
23 CPDF_Dictionary* pParentDict = pAnnot->GetAnnotDict(); | 23 CPDF_Dictionary* pParentDict = pAnnot->GetAnnotDict(); |
24 if (!pParentDict) | 24 if (!pParentDict) |
25 return std::unique_ptr<CPDF_Annot>(); | 25 return std::unique_ptr<CPDF_Annot>(); |
26 | 26 |
27 CFX_ByteString sContents = pParentDict->GetStringBy("Contents"); | 27 // TODO(jaepark): We shouldn't strip BOM for some strings and not for others. |
| 28 // See pdfium:593. |
| 29 CFX_WideString sContents = pParentDict->GetUnicodeTextBy("Contents"); |
28 if (sContents.IsEmpty()) | 30 if (sContents.IsEmpty()) |
29 return std::unique_ptr<CPDF_Annot>(); | 31 return std::unique_ptr<CPDF_Annot>(); |
30 | 32 |
31 CPDF_Dictionary* pAnnotDict = new CPDF_Dictionary; | 33 CPDF_Dictionary* pAnnotDict = new CPDF_Dictionary; |
32 pAnnotDict->SetAtName("Type", "Annot"); | 34 pAnnotDict->SetAtName("Type", "Annot"); |
33 pAnnotDict->SetAtName("Subtype", "Popup"); | 35 pAnnotDict->SetAtName("Subtype", "Popup"); |
34 pAnnotDict->SetAtString("T", pParentDict->GetStringBy("T")); | 36 pAnnotDict->SetAtString("T", pParentDict->GetStringBy("T")); |
35 pAnnotDict->SetAtString("Contents", sContents); | 37 pAnnotDict->SetAtString("Contents", sContents.UTF8Encode()); |
36 | 38 |
37 CFX_FloatRect rect = pParentDict->GetRectBy("Rect"); | 39 CFX_FloatRect rect = pParentDict->GetRectBy("Rect"); |
38 rect.Normalize(); | 40 rect.Normalize(); |
39 CFX_FloatRect popupRect(0, 0, 200, 200); | 41 CFX_FloatRect popupRect(0, 0, 200, 200); |
40 popupRect.Translate(rect.left, rect.bottom - popupRect.Height()); | 42 popupRect.Translate(rect.left, rect.bottom - popupRect.Height()); |
41 | 43 |
42 pAnnotDict->SetAtRect("Rect", popupRect); | 44 pAnnotDict->SetAtRect("Rect", popupRect); |
43 pAnnotDict->SetAtInteger("F", 0); | 45 pAnnotDict->SetAtInteger("F", 0); |
44 | 46 |
45 std::unique_ptr<CPDF_Annot> pPopupAnnot( | 47 std::unique_ptr<CPDF_Annot> pPopupAnnot( |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 CPDF_RenderContext* pContext, | 175 CPDF_RenderContext* pContext, |
174 FX_BOOL bPrinting, | 176 FX_BOOL bPrinting, |
175 CFX_Matrix* pMatrix, | 177 CFX_Matrix* pMatrix, |
176 FX_BOOL bShowWidget, | 178 FX_BOOL bShowWidget, |
177 CPDF_RenderOptions* pOptions) { | 179 CPDF_RenderOptions* pOptions) { |
178 uint32_t dwAnnotFlags = bShowWidget ? ANNOTFLAG_INVISIBLE | ANNOTFLAG_HIDDEN | 180 uint32_t dwAnnotFlags = bShowWidget ? ANNOTFLAG_INVISIBLE | ANNOTFLAG_HIDDEN |
179 : ANNOTFLAG_INVISIBLE; | 181 : ANNOTFLAG_INVISIBLE; |
180 DisplayAnnots(pPage, nullptr, pContext, bPrinting, pMatrix, dwAnnotFlags, | 182 DisplayAnnots(pPage, nullptr, pContext, bPrinting, pMatrix, dwAnnotFlags, |
181 pOptions, nullptr); | 183 pOptions, nullptr); |
182 } | 184 } |
OLD | NEW |