diff options
author | jaepark <jaepark@google.com> | 2016-08-29 17:15:08 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-29 17:15:08 -0700 |
commit | 35512aa7e4acc3ceb9c6aef5d61eebfb4ae802af (patch) | |
tree | 18ad1447ba8a7d06f304e1418616d919eadbbf8c /fpdfsdk/cpdfsdk_baannothandler.cpp | |
parent | 07f5fd57682700bcbba20f01d52a806676fd02ff (diff) | |
download | pdfium-35512aa7e4acc3ceb9c6aef5d61eebfb4ae802af.tar.xz |
Display content of the annotation when mouse hover.
Each annotation has its contents, and users should be able to see the
contents. In this patch, PDFium creates a Popup annotation for each
annotation and stores the author and the content. When a user mouse
hover on the annotation, PDFium draws the corresponding Popup annotation
and displays the content.
Also, roll DEPS for testing/corpus to 5867fa6.
BUG=62625
Review-Url: https://codereview.chromium.org/2273893002
Diffstat (limited to 'fpdfsdk/cpdfsdk_baannothandler.cpp')
-rw-r--r-- | fpdfsdk/cpdfsdk_baannothandler.cpp | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp new file mode 100644 index 0000000000..2fe3623099 --- /dev/null +++ b/fpdfsdk/cpdfsdk_baannothandler.cpp @@ -0,0 +1,219 @@ +// 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 "fpdfsdk/include/cpdfsdk_baannothandler.h" + +#include <memory> +#include <vector> + +#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "core/fpdfdoc/include/cpdf_interform.h" +#include "fpdfsdk/formfiller/cffl_formfiller.h" +#include "fpdfsdk/include/cpdfsdk_annot.h" +#include "fpdfsdk/include/cpdfsdk_baannot.h" +#include "fpdfsdk/include/fsdk_mgr.h" + +#ifdef PDF_ENABLE_XFA +#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" +#endif // PDF_ENABLE_XFA + +namespace { + +void UpdateAnnotRects(CPDFSDK_PageView* pPageView, CPDFSDK_BAAnnot* pBAAnnot) { + std::vector<CFX_FloatRect> rects; + rects.push_back(pBAAnnot->GetRect()); + if (CPDF_Annot* pPopupAnnot = pBAAnnot->GetPDFPopupAnnot()) + rects.push_back(pPopupAnnot->GetRect()); + pPageView->UpdateRects(rects); +} + +} // namespace + +CPDFSDK_BAAnnotHandler::CPDFSDK_BAAnnotHandler() {} + +CPDFSDK_BAAnnotHandler::~CPDFSDK_BAAnnotHandler() {} + +CFX_ByteString CPDFSDK_BAAnnotHandler::GetType() { + return CFX_ByteString(""); +} + +FX_BOOL CPDFSDK_BAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { + return FALSE; +} + +CPDFSDK_Annot* CPDFSDK_BAAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, + CPDFSDK_PageView* pPage) { + return new CPDFSDK_BAAnnot(pAnnot, pPage); +} + +#ifdef PDF_ENABLE_XFA +CPDFSDK_Annot* CPDFSDK_BAAnnotHandler::NewAnnot(CXFA_FFWidget* hWidget, + CPDFSDK_PageView* pPage) { + return nullptr; +} +#endif // PDF_ENABLE_XFA + +void CPDFSDK_BAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { + delete pAnnot; +} + +void CPDFSDK_BAAnnotHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {} + +void CPDFSDK_BAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + uint32_t dwFlags) { +#ifdef PDF_ENABLE_XFA + if (pAnnot->IsXFAField()) + return; +#endif // PDF_ENABLE_XFA + static_cast<CPDFSDK_BAAnnot*>(pAnnot)->DrawAppearance( + pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); +} + +void CPDFSDK_BAAnnotHandler::OnDrawSleep(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + const CFX_FloatRect& rcWindow, + uint32_t dwFlags) {} + +void CPDFSDK_BAAnnotHandler::OnDelete(CPDFSDK_Annot* pAnnot) {} + +void CPDFSDK_BAAnnotHandler::OnRelease(CPDFSDK_Annot* pAnnot) {} + +void CPDFSDK_BAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlag) { + CPDFSDK_BAAnnot* pBAAnnot = static_cast<CPDFSDK_BAAnnot*>(pAnnot); + pBAAnnot->SetOpenState(true); + UpdateAnnotRects(pPageView, pBAAnnot); +} + +void CPDFSDK_BAAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlag) { + CPDFSDK_BAAnnot* pBAAnnot = static_cast<CPDFSDK_BAAnnot*>(pAnnot); + pBAAnnot->SetOpenState(false); + UpdateAnnotRects(pPageView, pBAAnnot); +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + return FALSE; +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + return FALSE; +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + return FALSE; +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + return FALSE; +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + short zDelta, + const CFX_FloatPoint& point) { + return FALSE; +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + return FALSE; +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + return FALSE; +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + return FALSE; +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, + uint32_t nChar, + uint32_t nFlags) { + return FALSE; +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, + int nKeyCode, + int nFlag) { + return FALSE; +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, + int nKeyCode, + int nFlag) { + return FALSE; +} + +void CPDFSDK_BAAnnotHandler::OnDeSelected(CPDFSDK_Annot* pAnnot) {} + +void CPDFSDK_BAAnnotHandler::OnSelected(CPDFSDK_Annot* pAnnot) {} + +void CPDFSDK_BAAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) {} + +void CPDFSDK_BAAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, + uint32_t nFlag) { + return FALSE; +} + +FX_BOOL CPDFSDK_BAAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, + uint32_t nFlag) { + return FALSE; +} + +#ifdef PDF_ENABLE_XFA +FX_BOOL CPDFSDK_BAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, + CPDFSDK_Annot* pNewAnnot) { + return TRUE; +} +#endif // PDF_ENABLE_XFA + +CFX_FloatRect CPDFSDK_BAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot) { + return pAnnot->GetRect(); +} + +FX_BOOL CPDFSDK_BAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + const CFX_FloatPoint& point) { + ASSERT(pPageView); + ASSERT(pAnnot); + + CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot); + return rect.Contains(point.x, point.y); +} |