Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: core/fpdfdoc/cpdf_annotlist.cpp

Issue 2395693002: Fix some nits in cpdf_annotlist.cpp. (Closed)
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
10 #include <utility>
11
9 #include "core/fpdfapi/page/cpdf_page.h" 12 #include "core/fpdfapi/page/cpdf_page.h"
10 #include "core/fpdfapi/parser/cpdf_document.h" 13 #include "core/fpdfapi/parser/cpdf_document.h"
11 #include "core/fpdfapi/parser/cpdf_reference.h" 14 #include "core/fpdfapi/parser/cpdf_reference.h"
12 #include "core/fpdfapi/render/cpdf_renderoptions.h" 15 #include "core/fpdfapi/render/cpdf_renderoptions.h"
13 #include "core/fpdfdoc/cpdf_annot.h" 16 #include "core/fpdfdoc/cpdf_annot.h"
14 #include "core/fpdfdoc/cpdf_interform.h" 17 #include "core/fpdfdoc/cpdf_interform.h"
15 #include "core/fpdfdoc/cpdf_occontext.h" 18 #include "core/fpdfdoc/cpdf_occontext.h"
16 #include "core/fpdfdoc/cpvt_generateap.h" 19 #include "core/fpdfdoc/cpvt_generateap.h"
17 #include "core/fxge/cfx_renderdevice.h" 20 #include "core/fxge/cfx_renderdevice.h"
18 21
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 : m_pDocument(pPage->m_pDocument) { 60 : m_pDocument(pPage->m_pDocument) {
58 if (!pPage->m_pFormDict) 61 if (!pPage->m_pFormDict)
59 return; 62 return;
60 63
61 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayFor("Annots"); 64 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayFor("Annots");
62 if (!pAnnots) 65 if (!pAnnots)
63 return; 66 return;
64 67
65 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); 68 CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
66 CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); 69 CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm");
67 FX_BOOL bRegenerateAP = 70 bool bRegenerateAP = pAcroForm && pAcroForm->GetBooleanFor("NeedAppearances");
68 pAcroForm && pAcroForm->GetBooleanFor("NeedAppearances");
69 for (size_t i = 0; i < pAnnots->GetCount(); ++i) { 71 for (size_t i = 0; i < pAnnots->GetCount(); ++i) {
70 CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetDirectObjectAt(i)); 72 CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetDirectObjectAt(i));
71 if (!pDict || pDict->GetStringFor("Subtype") == "Popup") { 73 if (!pDict)
74 continue;
75 const CFX_ByteString subtype = pDict->GetStringFor("Subtype");
76 if (subtype == "Popup") {
72 // Skip creating Popup annotations in the PDF document since PDFium 77 // Skip creating Popup annotations in the PDF document since PDFium
73 // provides its own Popup annotations. 78 // provides its own Popup annotations.
74 continue; 79 continue;
75 } 80 }
76 pAnnots->ConvertToIndirectObjectAt(i, m_pDocument); 81 pAnnots->ConvertToIndirectObjectAt(i, m_pDocument);
77 m_AnnotList.push_back( 82 m_AnnotList.push_back(
78 std::unique_ptr<CPDF_Annot>(new CPDF_Annot(pDict, m_pDocument, false))); 83 std::unique_ptr<CPDF_Annot>(new CPDF_Annot(pDict, m_pDocument, false)));
79 if (bRegenerateAP && pDict->GetStringFor("Subtype") == "Widget" && 84 if (bRegenerateAP && subtype == "Widget" &&
80 CPDF_InterForm::IsUpdateAPEnabled()) { 85 CPDF_InterForm::IsUpdateAPEnabled()) {
81 FPDF_GenerateAP(m_pDocument, pDict); 86 FPDF_GenerateAP(m_pDocument, pDict);
82 } 87 }
83 } 88 }
84 89
85 size_t nAnnotListSize = m_AnnotList.size(); 90 size_t nAnnotListSize = m_AnnotList.size();
86 for (size_t i = 0; i < nAnnotListSize; ++i) { 91 for (size_t i = 0; i < nAnnotListSize; ++i) {
87 std::unique_ptr<CPDF_Annot> pPopupAnnot( 92 std::unique_ptr<CPDF_Annot> pPopupAnnot(
88 CreatePopupAnnot(m_AnnotList[i].get(), m_pDocument)); 93 CreatePopupAnnot(m_AnnotList[i].get(), m_pDocument));
89 if (pPopupAnnot) 94 if (pPopupAnnot)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 CPDF_RenderContext* pContext, 170 CPDF_RenderContext* pContext,
166 FX_BOOL bPrinting, 171 FX_BOOL bPrinting,
167 CFX_Matrix* pMatrix, 172 CFX_Matrix* pMatrix,
168 FX_BOOL bShowWidget, 173 FX_BOOL bShowWidget,
169 CPDF_RenderOptions* pOptions) { 174 CPDF_RenderOptions* pOptions) {
170 uint32_t dwAnnotFlags = bShowWidget ? ANNOTFLAG_INVISIBLE | ANNOTFLAG_HIDDEN 175 uint32_t dwAnnotFlags = bShowWidget ? ANNOTFLAG_INVISIBLE | ANNOTFLAG_HIDDEN
171 : ANNOTFLAG_INVISIBLE; 176 : ANNOTFLAG_INVISIBLE;
172 DisplayAnnots(pPage, nullptr, pContext, bPrinting, pMatrix, dwAnnotFlags, 177 DisplayAnnots(pPage, nullptr, pContext, bPrinting, pMatrix, dwAnnotFlags,
173 pOptions, nullptr); 178 pOptions, nullptr);
174 } 179 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698