diff options
Diffstat (limited to 'fpdfsdk')
24 files changed, 65 insertions, 82 deletions
diff --git a/fpdfsdk/cba_annotiterator.cpp b/fpdfsdk/cba_annotiterator.cpp index 773fe610cd..b99fabfabe 100644 --- a/fpdfsdk/cba_annotiterator.cpp +++ b/fpdfsdk/cba_annotiterator.cpp @@ -23,10 +23,10 @@ bool CBA_AnnotIterator::CompareByTopDescending(const CPDFSDK_Annot* p1, } CBA_AnnotIterator::CBA_AnnotIterator(CPDFSDK_PageView* pPageView, - const CFX_ByteString& sAnnotSubtype) + CPDF_Annot::Subtype nAnnotSubtype) : m_eTabOrder(STRUCTURE), m_pPageView(pPageView), - m_sAnnotSubtype(sAnnotSubtype) { + m_nAnnotSubtype(nAnnotSubtype) { CPDF_Page* pPDFPage = m_pPageView->GetPDFPage(); CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetStringBy("Tabs"); if (sTabs == "R") @@ -71,7 +71,7 @@ void CBA_AnnotIterator::GenerateResults() { case STRUCTURE: { for (size_t i = 0; i < m_pPageView->CountAnnots(); ++i) { CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); - if (pAnnot->GetAnnotSubtype() == m_sAnnotSubtype && + if (pAnnot->GetAnnotSubtype() == m_nAnnotSubtype && !pAnnot->IsSignatureWidget()) m_Annots.push_back(pAnnot); } @@ -81,7 +81,7 @@ void CBA_AnnotIterator::GenerateResults() { std::vector<CPDFSDK_Annot*> sa; for (size_t i = 0; i < m_pPageView->CountAnnots(); ++i) { CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); - if (pAnnot->GetAnnotSubtype() == m_sAnnotSubtype && + if (pAnnot->GetAnnotSubtype() == m_nAnnotSubtype && !pAnnot->IsSignatureWidget()) sa.push_back(pAnnot); } @@ -123,7 +123,7 @@ void CBA_AnnotIterator::GenerateResults() { std::vector<CPDFSDK_Annot*> sa; for (size_t i = 0; i < m_pPageView->CountAnnots(); ++i) { CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); - if (pAnnot->GetAnnotSubtype() == m_sAnnotSubtype && + if (pAnnot->GetAnnotSubtype() == m_nAnnotSubtype && !pAnnot->IsSignatureWidget()) sa.push_back(pAnnot); } diff --git a/fpdfsdk/cpdfsdk_annot.cpp b/fpdfsdk/cpdfsdk_annot.cpp index 5ca439d8f7..59d8f24e82 100644 --- a/fpdfsdk/cpdfsdk_annot.cpp +++ b/fpdfsdk/cpdfsdk_annot.cpp @@ -58,8 +58,8 @@ CPDF_Annot* CPDFSDK_Annot::GetPDFAnnot() const { return nullptr; } -CFX_ByteString CPDFSDK_Annot::GetAnnotSubtype() const { - return ""; +CPDF_Annot::Subtype CPDFSDK_Annot::GetAnnotSubtype() const { + return CPDF_Annot::Subtype::UNKNOWN; } bool CPDFSDK_Annot::IsSignatureWidget() const { diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp index 9f5a545d65..d909f5bc0d 100644 --- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp +++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp @@ -46,7 +46,8 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CXFA_FFWidget* pAnnot, ASSERT(pAnnot); ASSERT(pPageView); - return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)->NewAnnot(pAnnot, pPageView); + return GetAnnotHandler(CPDF_Annot::Subtype::XFAWIDGET) + ->NewAnnot(pAnnot, pPageView); } #endif // PDF_ENABLE_XFA @@ -77,12 +78,12 @@ IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( } IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( - const CFX_ByteString& sType) const { - if (sType == "Widget") + CPDF_Annot::Subtype nAnnotSubtype) const { + if (nAnnotSubtype == CPDF_Annot::Subtype::WIDGET) return m_pWidgetHandler.get(); #ifdef PDF_ENABLE_XFA - if (sType == FSDK_XFAWIDGET_TYPENAME) + if (nAnnotSubtype == CPDF_Annot::Subtype::XFAWIDGET) return m_pXFAWidgetHandler.get(); #endif // PDF_ENABLE_XFA @@ -242,7 +243,7 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus( if (bXFA) { if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = - GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) + GetAnnotHandler(CPDF_Annot::Subtype::XFAWIDGET)) return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); } @@ -299,7 +300,7 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, return pPageView->GetAnnotByXFAWidget(hNextFocus); #else // PDF_ENABLE_XFA - CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget"); + CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), CPDF_Annot::Subtype::WIDGET); return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); #endif // PDF_ENABLE_XFA } diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp index 5e3e14572c..a2fd7c79bb 100644 --- a/fpdfsdk/cpdfsdk_baannot.cpp +++ b/fpdfsdk/cpdfsdk_baannot.cpp @@ -42,7 +42,7 @@ CFX_FloatRect CPDFSDK_BAAnnot::GetRect() const { return m_pAnnot->GetRect(); } -CFX_ByteString CPDFSDK_BAAnnot::GetAnnotSubtype() const { +CPDF_Annot::Subtype CPDFSDK_BAAnnot::GetAnnotSubtype() const { return m_pAnnot->GetSubtype(); } diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp index 2fe3623099..4422dc4ee9 100644 --- a/fpdfsdk/cpdfsdk_baannothandler.cpp +++ b/fpdfsdk/cpdfsdk_baannothandler.cpp @@ -37,10 +37,6 @@ 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; } diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 1346deb2bc..345487ad49 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -71,8 +71,8 @@ FX_BOOL CPDFSDK_InterForm::HighlightWidgets() { CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const { - std::unique_ptr<CBA_AnnotIterator> pIterator( - new CBA_AnnotIterator(pWidget->GetPageView(), "Widget")); + std::unique_ptr<CBA_AnnotIterator> pIterator(new CBA_AnnotIterator( + pWidget->GetPageView(), CPDF_Annot::Subtype::WIDGET)); if (bNext) return static_cast<CPDFSDK_Widget*>(pIterator->GetNextAnnot(pWidget)); diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp index 0fb64dfaec..77e14f0404 100644 --- a/fpdfsdk/cpdfsdk_widgethandler.cpp +++ b/fpdfsdk/cpdfsdk_widgethandler.cpp @@ -27,12 +27,8 @@ CPDFSDK_WidgetHandler::CPDFSDK_WidgetHandler(CPDFDoc_Environment* pApp) CPDFSDK_WidgetHandler::~CPDFSDK_WidgetHandler() {} -CFX_ByteString CPDFSDK_WidgetHandler::GetType() { - return CFX_ByteString("Widget"); -} - FX_BOOL CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { - ASSERT(pAnnot->GetAnnotSubtype() == "Widget"); + ASSERT(pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET); if (pAnnot->IsSignatureWidget()) return FALSE; diff --git a/fpdfsdk/cpdfsdk_xfawidget.cpp b/fpdfsdk/cpdfsdk_xfawidget.cpp index 445abc53cb..b5e26d660a 100644 --- a/fpdfsdk/cpdfsdk_xfawidget.cpp +++ b/fpdfsdk/cpdfsdk_xfawidget.cpp @@ -24,8 +24,8 @@ CXFA_FFWidget* CPDFSDK_XFAWidget::GetXFAWidget() const { return m_hXFAWidget; } -CFX_ByteString CPDFSDK_XFAWidget::GetAnnotSubtype() const { - return FSDK_XFAWIDGET_TYPENAME; +CPDF_Annot::Subtype CPDFSDK_XFAWidget::GetAnnotSubtype() const { + return CPDF_Annot::Subtype::XFAWIDGET; } CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const { diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp index 9a9a7a8a4a..59fa5c7241 100644 --- a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp +++ b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp @@ -25,10 +25,6 @@ CPDFSDK_XFAWidgetHandler::CPDFSDK_XFAWidgetHandler(CPDFDoc_Environment* pApp) CPDFSDK_XFAWidgetHandler::~CPDFSDK_XFAWidgetHandler() {} -CFX_ByteString CPDFSDK_XFAWidgetHandler::GetType() { - return FSDK_XFAWIDGET_TYPENAME; -} - FX_BOOL CPDFSDK_XFAWidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { return !!pAnnot->GetXFAWidget(); } diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index 90b83d6e46..6a8ec5da33 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -85,7 +85,7 @@ void CFFL_FormFiller::OnDraw(CPDFSDK_PageView* pPageView, CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device, uint32_t dwFlags) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { CFX_Matrix mt = GetCurMatrix(); diff --git a/fpdfsdk/formfiller/cffl_iformfiller.cpp b/fpdfsdk/formfiller/cffl_iformfiller.cpp index 0f5ed89fb2..111294726c 100644 --- a/fpdfsdk/formfiller/cffl_iformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_iformfiller.cpp @@ -124,7 +124,7 @@ void CFFL_IFormFiller::OnDelete(CPDFSDK_Annot* pAnnot) { void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (!m_bNotifying) { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; @@ -160,7 +160,7 @@ void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (!m_bNotifying) { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; @@ -197,7 +197,7 @@ FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CFX_FloatPoint& point) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (!m_bNotifying) { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; @@ -239,7 +239,7 @@ FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CFX_FloatPoint& point) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument(); @@ -319,7 +319,7 @@ FX_BOOL CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CFX_FloatPoint& point) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); @@ -332,7 +332,7 @@ FX_BOOL CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CFX_FloatPoint& point) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); // change cursor if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) { @@ -347,7 +347,7 @@ FX_BOOL CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, FX_UINT nFlags, short zDelta, const CFX_FloatPoint& point) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point); @@ -360,7 +360,7 @@ FX_BOOL CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CFX_FloatPoint& point) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); @@ -373,7 +373,7 @@ FX_BOOL CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CFX_FloatPoint& point) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); @@ -385,7 +385,7 @@ FX_BOOL CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); @@ -397,7 +397,7 @@ FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags) { - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (nChar == FWL_VKEY_Tab) return TRUE; @@ -411,7 +411,7 @@ FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { if (!pAnnot) return FALSE; - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (!m_bNotifying) { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; @@ -454,7 +454,7 @@ FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { if (!pAnnot) return FALSE; - ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget"); + ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { pFormFiller->KillFocusForAnnot(pAnnot, nFlag); diff --git a/fpdfsdk/fpdf_ext.cpp b/fpdfsdk/fpdf_ext.cpp index d03b4383ca..46bc7e57a4 100644 --- a/fpdfsdk/fpdf_ext.cpp +++ b/fpdfsdk/fpdf_ext.cpp @@ -46,33 +46,31 @@ FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info) { } void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot) { - CFX_ByteString cbSubType = pPDFAnnot->GetSubtype(); - if (cbSubType.Compare("3D") == 0) { + CPDF_Annot::Subtype nAnnotSubtype = pPDFAnnot->GetSubtype(); + if (nAnnotSubtype == CPDF_Annot::Subtype::THREED) { FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT); - } else if (cbSubType.Compare("Screen") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::SCREEN) { const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); CFX_ByteString cbString; if (pAnnotDict->KeyExist("IT")) cbString = pAnnotDict->GetStringBy("IT"); if (cbString.Compare("Img") != 0) FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_MEDIA); - } else if (cbSubType.Compare("Movie") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::MOVIE) { FPDF_UnSupportError(FPDF_UNSP_ANNOT_MOVIE); - } else if (cbSubType.Compare("Sound") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::SOUND) { FPDF_UnSupportError(FPDF_UNSP_ANNOT_SOUND); - } else if (cbSubType.Compare("RichMedia") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::RICHMEDIA) { FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA); - } else if (cbSubType.Compare("FileAttachment") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::FILEATTACHMENT) { FPDF_UnSupportError(FPDF_UNSP_ANNOT_ATTACHMENT); - } else if (cbSubType.Compare("Widget") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::WIDGET) { const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); CFX_ByteString cbString; - if (pAnnotDict->KeyExist("FT")) { + if (pAnnotDict->KeyExist("FT")) cbString = pAnnotDict->GetStringBy("FT"); - } - if (cbString.Compare("Sig") == 0) { + if (cbString.Compare("Sig") == 0) FPDF_UnSupportError(FPDF_UNSP_ANNOT_SIG); - } } } diff --git a/fpdfsdk/fsdk_baseform_embeddertest.cpp b/fpdfsdk/fsdk_baseform_embeddertest.cpp index c87073d38b..53611ae698 100644 --- a/fpdfsdk/fsdk_baseform_embeddertest.cpp +++ b/fpdfsdk/fsdk_baseform_embeddertest.cpp @@ -42,7 +42,8 @@ TEST_F(FSDKBaseFormEmbeddertest, CBA_AnnotIterator) { CPDFSDK_Document::FromFPDFFormHandle(form_handle()); { // Page 0 specifies "row order". - CBA_AnnotIterator iter(pSDKDoc->GetPageView(0), "Widget"); + CBA_AnnotIterator iter(pSDKDoc->GetPageView(0), + CPDF_Annot::Subtype::WIDGET); CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); CheckRect(pAnnot->GetRect(), RightTop); pAnnot = iter.GetNextAnnot(pAnnot); @@ -67,7 +68,8 @@ TEST_F(FSDKBaseFormEmbeddertest, CBA_AnnotIterator) { } { // Page 1 specifies "column order" - CBA_AnnotIterator iter(pSDKDoc->GetPageView(1), "Widget"); + CBA_AnnotIterator iter(pSDKDoc->GetPageView(1), + CPDF_Annot::Subtype::WIDGET); CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); CheckRect(pAnnot->GetRect(), RightTop); pAnnot = iter.GetNextAnnot(pAnnot); @@ -92,7 +94,8 @@ TEST_F(FSDKBaseFormEmbeddertest, CBA_AnnotIterator) { } { // Page 2 specifies "struct order" - CBA_AnnotIterator iter(pSDKDoc->GetPageView(2), "Widget"); + CBA_AnnotIterator iter(pSDKDoc->GetPageView(2), + CPDF_Annot::Subtype::WIDGET); CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); CheckRect(pAnnot->GetRect(), LeftBottom); pAnnot = iter.GetNextAnnot(pAnnot); diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp index fda00e0e6e..4ca2e6cc50 100644 --- a/fpdfsdk/fsdk_mgr.cpp +++ b/fpdfsdk/fsdk_mgr.cpp @@ -442,7 +442,7 @@ FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) { #endif // PDF_ENABLE_XFA if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { - if (pFocusAnnot->GetAnnotSubtype() == "Widget") { + if (pFocusAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET) { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; int nFieldType = pWidget->GetFieldType(); if (FIELDTYPE_TEXTFIELD == nFieldType || @@ -586,7 +586,7 @@ const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, const CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY) { for (const auto& pAnnot : m_pAnnotList->All()) { - if (pAnnot->GetSubtype() == "Widget") { + if (pAnnot->GetSubtype() == CPDF_Annot::Subtype::WIDGET) { CFX_FloatRect annotRect = pAnnot->GetRect(); if (annotRect.Contains(pageX, pageY)) return pAnnot.get(); @@ -602,7 +602,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, CPDFSDK_AnnotIterator annotIterator(this, false); while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); - if (pSDKAnnot->GetAnnotSubtype() == "Popup") + if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) continue; if (rc.Contains(pageX, pageY)) return pSDKAnnot; @@ -617,10 +617,10 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); CPDFSDK_AnnotIterator annotIterator(this, false); while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { - bool bHitTest = pSDKAnnot->GetAnnotSubtype() == "Widget"; + bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET; #ifdef PDF_ENABLE_XFA - bHitTest = - bHitTest || pSDKAnnot->GetAnnotSubtype() == FSDK_XFAWIDGET_TYPENAME; + bHitTest = bHitTest || + pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET; #endif // PDF_ENABLE_XFA if (bHitTest) { pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); diff --git a/fpdfsdk/include/cba_annotiterator.h b/fpdfsdk/include/cba_annotiterator.h index 0cf6e6a0ef..aa0ad2d72b 100644 --- a/fpdfsdk/include/cba_annotiterator.h +++ b/fpdfsdk/include/cba_annotiterator.h @@ -9,6 +9,7 @@ #include <vector> +#include "core/fpdfdoc/include/cpdf_annot.h" #include "core/fxcrt/include/fx_coordinates.h" #include "core/fxcrt/include/fx_string.h" @@ -20,7 +21,7 @@ class CBA_AnnotIterator { enum TabOrder { STRUCTURE = 0, ROW, COLUMN }; CBA_AnnotIterator(CPDFSDK_PageView* pPageView, - const CFX_ByteString& sAnnotSubtype); + CPDF_Annot::Subtype nAnnotSubtype); ~CBA_AnnotIterator(); CPDFSDK_Annot* GetFirstAnnot(); @@ -40,7 +41,7 @@ class CBA_AnnotIterator { TabOrder m_eTabOrder; CPDFSDK_PageView* m_pPageView; - CFX_ByteString m_sAnnotSubtype; + CPDF_Annot::Subtype m_nAnnotSubtype; std::vector<CPDFSDK_Annot*> m_Annots; }; diff --git a/fpdfsdk/include/cpdfsdk_annot.h b/fpdfsdk/include/cpdfsdk_annot.h index 9501037cd6..967226e9db 100644 --- a/fpdfsdk/include/cpdfsdk_annot.h +++ b/fpdfsdk/include/cpdfsdk_annot.h @@ -35,7 +35,7 @@ class CPDFSDK_Annot { virtual FX_FLOAT GetMinHeight() const; virtual int GetLayoutOrder() const; virtual CPDF_Annot* GetPDFAnnot() const; - virtual CFX_ByteString GetAnnotSubtype() const; + virtual CPDF_Annot::Subtype GetAnnotSubtype() const; virtual bool IsSignatureWidget() const; virtual CFX_FloatRect GetRect() const; diff --git a/fpdfsdk/include/cpdfsdk_annothandlermgr.h b/fpdfsdk/include/cpdfsdk_annothandlermgr.h index 016135c0d0..3c36692bb5 100644 --- a/fpdfsdk/include/cpdfsdk_annothandlermgr.h +++ b/fpdfsdk/include/cpdfsdk_annothandlermgr.h @@ -10,12 +10,12 @@ #include <map> #include <memory> +#include "core/fpdfdoc/include/cpdf_annot.h" #include "core/fxcrt/include/fx_basic.h" #include "core/fxcrt/include/fx_coordinates.h" class CFX_Matrix; class CFX_RenderDevice; -class CPDF_Annot; class CPDFDoc_Environment; class CPDFSDK_Annot; class CPDFSDK_BAAnnotHandler; @@ -109,7 +109,7 @@ class CPDFSDK_AnnotHandlerMgr { const CFX_FloatPoint& point); private: - IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const; + IPDFSDK_AnnotHandler* GetAnnotHandler(CPDF_Annot::Subtype nSubtype) const; CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, FX_BOOL bNext); std::unique_ptr<CPDFSDK_BAAnnotHandler> m_pBAAnnotHandler; diff --git a/fpdfsdk/include/cpdfsdk_baannot.h b/fpdfsdk/include/cpdfsdk_baannot.h index 0f417383c2..4575bfe087 100644 --- a/fpdfsdk/include/cpdfsdk_baannot.h +++ b/fpdfsdk/include/cpdfsdk_baannot.h @@ -28,7 +28,7 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot { ~CPDFSDK_BAAnnot() override; // CPDFSDK_Annot - CFX_ByteString GetAnnotSubtype() const override; + CPDF_Annot::Subtype GetAnnotSubtype() const override; void SetRect(const CFX_FloatRect& rect) override; CFX_FloatRect GetRect() const override; CPDF_Annot* GetPDFAnnot() const override; diff --git a/fpdfsdk/include/cpdfsdk_baannothandler.h b/fpdfsdk/include/cpdfsdk_baannothandler.h index c1936a798e..ac93a597cc 100644 --- a/fpdfsdk/include/cpdfsdk_baannothandler.h +++ b/fpdfsdk/include/cpdfsdk_baannothandler.h @@ -28,7 +28,6 @@ class CPDFSDK_BAAnnotHandler : public IPDFSDK_AnnotHandler { CPDFSDK_BAAnnotHandler(); ~CPDFSDK_BAAnnotHandler() override; - CFX_ByteString GetType() override; FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override; #ifdef PDF_ENABLE_XFA diff --git a/fpdfsdk/include/cpdfsdk_widgethandler.h b/fpdfsdk/include/cpdfsdk_widgethandler.h index 0155967f3a..042fc2b316 100644 --- a/fpdfsdk/include/cpdfsdk_widgethandler.h +++ b/fpdfsdk/include/cpdfsdk_widgethandler.h @@ -28,7 +28,6 @@ class CPDFSDK_WidgetHandler : public IPDFSDK_AnnotHandler { explicit CPDFSDK_WidgetHandler(CPDFDoc_Environment* pApp); ~CPDFSDK_WidgetHandler() override; - CFX_ByteString GetType() override; FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override; #ifdef PDF_ENABLE_XFA diff --git a/fpdfsdk/include/cpdfsdk_xfawidget.h b/fpdfsdk/include/cpdfsdk_xfawidget.h index 00cc01249c..311c22587b 100644 --- a/fpdfsdk/include/cpdfsdk_xfawidget.h +++ b/fpdfsdk/include/cpdfsdk_xfawidget.h @@ -24,7 +24,7 @@ class CPDFSDK_XFAWidget : public CPDFSDK_Annot { FX_BOOL IsXFAField() override; CXFA_FFWidget* GetXFAWidget() const override; - CFX_ByteString GetAnnotSubtype() const override; + CPDF_Annot::Subtype GetAnnotSubtype() const override; CFX_FloatRect GetRect() const override; CPDFSDK_InterForm* GetInterForm() { return m_pInterForm; } diff --git a/fpdfsdk/include/cpdfsdk_xfawidgethandler.h b/fpdfsdk/include/cpdfsdk_xfawidgethandler.h index 84e74b4a73..269b416544 100644 --- a/fpdfsdk/include/cpdfsdk_xfawidgethandler.h +++ b/fpdfsdk/include/cpdfsdk_xfawidgethandler.h @@ -25,7 +25,6 @@ class CPDFSDK_XFAWidgetHandler : public IPDFSDK_AnnotHandler { explicit CPDFSDK_XFAWidgetHandler(CPDFDoc_Environment* pApp); ~CPDFSDK_XFAWidgetHandler() override; - CFX_ByteString GetType() override; FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override; CPDFSDK_Annot* NewAnnot(CXFA_FFWidget* pAnnot, diff --git a/fpdfsdk/include/ipdfsdk_annothandler.h b/fpdfsdk/include/ipdfsdk_annothandler.h index 0dd1a93cc8..1a6ba8699c 100644 --- a/fpdfsdk/include/ipdfsdk_annothandler.h +++ b/fpdfsdk/include/ipdfsdk_annothandler.h @@ -10,10 +10,6 @@ #include "core/fxcrt/include/fx_basic.h" #include "core/fxcrt/include/fx_coordinates.h" -#ifdef PDF_ENABLE_XFA -#define FSDK_XFAWIDGET_TYPENAME "XFAWidget" -#endif // PDF_ENABLE_XFA - class CFX_Matrix; class CFX_RenderDevice; class CPDF_Annot; @@ -28,7 +24,6 @@ class IPDFSDK_AnnotHandler { public: virtual ~IPDFSDK_AnnotHandler() {} - virtual CFX_ByteString GetType() = 0; virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) = 0; virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) = 0; diff --git a/fpdfsdk/javascript/Annot.cpp b/fpdfsdk/javascript/Annot.cpp index 9945217198..a23d42f72a 100644 --- a/fpdfsdk/javascript/Annot.cpp +++ b/fpdfsdk/javascript/Annot.cpp @@ -80,7 +80,7 @@ FX_BOOL Annot::type(IJS_Context* cc, return FALSE; } - vp << m_BAAnnot->GetAnnotSubtype(); + vp << CPDF_Annot::AnnotSubtypeToString(m_BAAnnot->GetAnnotSubtype()); return TRUE; } |