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

Unified Diff: core/fpdfdoc/cpdf_annot.cpp

Issue 2163133002: Move CPDF_Annot and CPDF_AnnotList to their own header. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Move CPDF_Annot and CPDF_AnnotList to their own headers. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/cpdf_annot.h ('k') | core/fpdfdoc/cpdf_annotlist.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpdf_annot.cpp
diff --git a/core/fpdfdoc/doc_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
similarity index 66%
rename from core/fpdfdoc/doc_annot.cpp
rename to core/fpdfdoc/cpdf_annot.cpp
index e1a976005b9cb6fc0c7948a396f9186fee410d23..dcdd89c3f4ade2211d928f00173838fddd250433 100644
--- a/core/fpdfdoc/doc_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -1,126 +1,19 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/fpdfdoc/cpdf_annot.h"
+
#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
-#include "core/fpdfdoc/cpvt_generateap.h"
-#include "core/fpdfdoc/include/fpdf_doc.h"
#include "core/fxge/include/fx_ge.h"
-CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
- : m_pDocument(pPage->m_pDocument) {
- if (!pPage->m_pFormDict)
- return;
-
- CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayBy("Annots");
- if (!pAnnots)
- return;
-
- CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
- CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
- FX_BOOL bRegenerateAP =
- pAcroForm && pAcroForm->GetBooleanBy("NeedAppearances");
- for (size_t i = 0; i < pAnnots->GetCount(); ++i) {
- CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetDirectObjectAt(i));
- if (!pDict)
- continue;
-
- uint32_t dwObjNum = pDict->GetObjNum();
- if (dwObjNum == 0) {
- dwObjNum = m_pDocument->AddIndirectObject(pDict);
- CPDF_Reference* pAction = new CPDF_Reference(m_pDocument, dwObjNum);
- pAnnots->InsertAt(i, pAction);
- pAnnots->RemoveAt(i + 1);
- pDict = pAnnots->GetDictAt(i);
- }
- m_AnnotList.push_back(
- std::unique_ptr<CPDF_Annot>(new CPDF_Annot(pDict, m_pDocument)));
- if (bRegenerateAP && pDict->GetStringBy("Subtype") == "Widget" &&
- CPDF_InterForm::IsUpdateAPEnabled()) {
- FPDF_GenerateAP(m_pDocument, pDict);
- }
- }
-}
-
-CPDF_AnnotList::~CPDF_AnnotList() {}
-
-void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage,
- CFX_RenderDevice* pDevice,
- CPDF_RenderContext* pContext,
- FX_BOOL bPrinting,
- CFX_Matrix* pMatrix,
- FX_BOOL bWidgetPass,
- CPDF_RenderOptions* pOptions,
- FX_RECT* clip_rect) {
- for (const auto& pAnnot : m_AnnotList) {
- bool bWidget = pAnnot->GetSubType() == "Widget";
- if ((bWidgetPass && !bWidget) || (!bWidgetPass && bWidget))
- continue;
-
- uint32_t annot_flags = pAnnot->GetFlags();
- if (annot_flags & ANNOTFLAG_HIDDEN)
- continue;
-
- if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0)
- continue;
-
- if (!bPrinting && (annot_flags & ANNOTFLAG_NOVIEW))
- continue;
-
- if (pOptions) {
- CPDF_OCContext* pOCContext = pOptions->m_pOCContext;
- CPDF_Dictionary* pAnnotDict = pAnnot->GetAnnotDict();
- if (pOCContext && pAnnotDict &&
- !pOCContext->CheckOCGVisible(pAnnotDict->GetDictBy("OC"))) {
- continue;
- }
- }
- CFX_FloatRect annot_rect_f;
- pAnnot->GetRect(annot_rect_f);
- CFX_Matrix matrix = *pMatrix;
- if (clip_rect) {
- annot_rect_f.Transform(&matrix);
- FX_RECT annot_rect = annot_rect_f.GetOutterRect();
- annot_rect.Intersect(*clip_rect);
- if (annot_rect.IsEmpty()) {
- continue;
- }
- }
- if (pContext) {
- pAnnot->DrawInContext(pPage, pContext, &matrix, CPDF_Annot::Normal);
- } else if (!pAnnot->DrawAppearance(pPage, pDevice, &matrix,
- CPDF_Annot::Normal, pOptions)) {
- pAnnot->DrawBorder(pDevice, &matrix, pOptions);
- }
- }
-}
-
-void CPDF_AnnotList::DisplayAnnots(CPDF_Page* pPage,
- CFX_RenderDevice* pDevice,
- CPDF_RenderContext* pContext,
- FX_BOOL bPrinting,
- CFX_Matrix* pUser2Device,
- uint32_t dwAnnotFlags,
- CPDF_RenderOptions* pOptions,
- FX_RECT* pClipRect) {
- if (dwAnnotFlags & 0x01) {
- DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, FALSE,
- pOptions, pClipRect);
- }
- if (dwAnnotFlags & 0x02) {
- DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, TRUE,
- pOptions, pClipRect);
- }
-}
-
CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument)
: m_pAnnotDict(pDict),
m_pDocument(pDocument),
« no previous file with comments | « core/fpdfdoc/cpdf_annot.h ('k') | core/fpdfdoc/cpdf_annotlist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698