diff options
author | thestig <thestig@chromium.org> | 2016-04-13 13:18:21 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-13 13:18:21 -0700 |
commit | 9f3dbbc54c6981f069b57e6714393ac6c0c64231 (patch) | |
tree | 9f76b6cee117e34a737bd46f146356931786d3cc /xfa | |
parent | f063abf4d50ab466080714df584660854ceb8709 (diff) | |
download | pdfium-9f3dbbc54c6981f069b57e6714393ac6c0c64231.tar.xz |
Cleanup CPDFXFA_Page.
- Use std::unique_ptr.
- Make dtor protected.
- Simplify logic.
- Remove unused bits from CXFA_FFPageView as well.
Review URL: https://codereview.chromium.org/1878963004
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/app/xfa_ffdocview.cpp | 3 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffpageview.cpp | 62 | ||||
-rw-r--r-- | xfa/fxfa/include/xfa_ffpageview.h | 18 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_doclayout.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_layout_imp.cpp | 4 |
5 files changed, 25 insertions, 64 deletions
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index 79bba442ad..9c627ea3c1 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -530,6 +530,7 @@ CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName( } return NULL; } + void CXFA_FFDocView::OnPageEvent(CXFA_ContainerLayoutItem* pSender, XFA_PAGEEVENT eEvent, int32_t iPageIndex) { @@ -541,8 +542,8 @@ void CXFA_FFDocView::OnPageEvent(CXFA_ContainerLayoutItem* pSender, } m_pDoc->GetDocProvider()->PageViewEvent(pFFPageView, XFA_PAGEVIEWEVENT_PostAdded); - pFFPageView->LoadPageView(); } + void CXFA_FFDocView::LockUpdate() { m_iLock++; } diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/app/xfa_ffpageview.cpp index 62474b3e38..a480737281 100644 --- a/xfa/fxfa/app/xfa_ffpageview.cpp +++ b/xfa/fxfa/app/xfa_ffpageview.cpp @@ -19,72 +19,33 @@ #include "xfa/fxfa/include/xfa_ffwidget.h" CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) - : CXFA_ContainerLayoutItem(pPageArea), - m_pDocView(pDocView), - m_bLoaded(FALSE) {} + : CXFA_ContainerLayoutItem(pPageArea), m_pDocView(pDocView) {} + CXFA_FFPageView::~CXFA_FFPageView() {} -CXFA_FFDocView* CXFA_FFPageView::GetDocView() { + +CXFA_FFDocView* CXFA_FFPageView::GetDocView() const { return m_pDocView; } -int32_t CXFA_FFPageView::GetPageViewIndex() { + +int32_t CXFA_FFPageView::GetPageViewIndex() const { return GetPageIndex(); } -void CXFA_FFPageView::GetPageViewRect(CFX_RectF& rtPage) { + +void CXFA_FFPageView::GetPageViewRect(CFX_RectF& rtPage) const { CFX_SizeF sz; GetPageSize(sz); rtPage.Set(0, 0, sz); } void CXFA_FFPageView::GetDisplayMatrix(CFX_Matrix& mt, const CFX_Rect& rtDisp, - int32_t iRotate) { + int32_t iRotate) const { CFX_SizeF sz; GetPageSize(sz); CFX_RectF fdePage; fdePage.Set(0, 0, sz.x, sz.y); FDE_GetPageMatrix(mt, fdePage, rtDisp, iRotate, 0); } -int32_t CXFA_FFPageView::LoadPageView(IFX_Pause* pPause) { - if (m_bLoaded) { - return 100; - } - m_bLoaded = TRUE; - return 100; -} -void CXFA_FFPageView::UnloadPageView() { - if (!m_bLoaded) { - return; - } -} -FX_BOOL CXFA_FFPageView::IsPageViewLoaded() { - return m_bLoaded; -} -CXFA_FFWidget* CXFA_FFPageView::GetWidgetByPos(FX_FLOAT fx, FX_FLOAT fy) { - if (!m_bLoaded) { - return nullptr; - } - IXFA_WidgetIterator* pIterator = CreateWidgetIterator(); - CXFA_FFWidget* pWidget = nullptr; - while ((pWidget = static_cast<CXFA_FFWidget*>(pIterator->MoveToNext()))) { - if (!(pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) { - continue; - } - CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); - int32_t type = pAcc->GetClassID(); - if (type != XFA_ELEMENT_Field && type != XFA_ELEMENT_Draw) { - continue; - } - FX_FLOAT fWidgetx = fx; - FX_FLOAT fWidgety = fy; - pWidget->Rotate2Normal(fWidgetx, fWidgety); - uint32_t dwFlag = pWidget->OnHitTest(fWidgetx, fWidgety); - if ((FWL_WGTHITTEST_Client == dwFlag || - FWL_WGTHITTEST_HyperLink == dwFlag)) { - break; - } - } - pIterator->Release(); - return pWidget; -} + IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator( uint32_t dwTraverseWay, uint32_t dwWidgetFilter) { @@ -94,8 +55,9 @@ IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator( case XFA_TRAVERSEWAY_Form: return new CXFA_FFPageWidgetIterator(this, dwWidgetFilter); } - return NULL; + return nullptr; } + static FX_BOOL XFA_PageWidgetFilter(CXFA_FFWidget* pWidget, uint32_t dwFilter, FX_BOOL bTraversal, diff --git a/xfa/fxfa/include/xfa_ffpageview.h b/xfa/fxfa/include/xfa_ffpageview.h index 56d1a7312c..dcac3f1106 100644 --- a/xfa/fxfa/include/xfa_ffpageview.h +++ b/xfa/fxfa/include/xfa_ffpageview.h @@ -11,32 +11,28 @@ class CXFA_FFWidget; class CXFA_FFDocView; + class CXFA_FFPageView : public CXFA_ContainerLayoutItem { public: CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea); ~CXFA_FFPageView() override; - CXFA_FFDocView* GetDocView(); - int32_t GetPageViewIndex(); - void GetPageViewRect(CFX_RectF& rtPage); + CXFA_FFDocView* GetDocView() const; + int32_t GetPageViewIndex() const; + void GetPageViewRect(CFX_RectF& rtPage) const; void GetDisplayMatrix(CFX_Matrix& mt, const CFX_Rect& rtDisp, - int32_t iRotate); - int32_t LoadPageView(IFX_Pause* pPause = NULL); - void UnloadPageView(); - CXFA_FFWidget* GetWidgetByPos(FX_FLOAT fx, FX_FLOAT fy); + int32_t iRotate) const; IXFA_WidgetIterator* CreateWidgetIterator( uint32_t dwTraverseWay = XFA_TRAVERSEWAY_Form, uint32_t dwWidgetFilter = XFA_WIDGETFILTER_Visible | XFA_WIDGETFILTER_Viewable | XFA_WIDGETFILTER_AllType); - FX_BOOL IsPageViewLoaded(); - protected: - CXFA_FFDocView* m_pDocView; - FX_BOOL m_bLoaded; + CXFA_FFDocView* const m_pDocView; }; + typedef CXFA_NodeIteratorTemplate<CXFA_LayoutItem, CXFA_TraverseStrategy_LayoutItem> CXFA_LayoutItemIterator; diff --git a/xfa/fxfa/parser/xfa_doclayout.h b/xfa/fxfa/parser/xfa_doclayout.h index 0bae0184ec..267f79980b 100644 --- a/xfa/fxfa/parser/xfa_doclayout.h +++ b/xfa/fxfa/parser/xfa_doclayout.h @@ -57,7 +57,7 @@ class CXFA_ContainerLayoutItem : public CXFA_LayoutItem { CXFA_LayoutProcessor* GetLayout() const; int32_t GetPageIndex() const; - void GetPageSize(CFX_SizeF& size); + void GetPageSize(CFX_SizeF& size) const; CXFA_Node* GetMasterPage() const; CXFA_Node* m_pOldSubform; diff --git a/xfa/fxfa/parser/xfa_document_layout_imp.cpp b/xfa/fxfa/parser/xfa_document_layout_imp.cpp index 79037d7ec7..eea99ece88 100644 --- a/xfa/fxfa/parser/xfa_document_layout_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_layout_imp.cpp @@ -180,7 +180,8 @@ int32_t CXFA_ContainerLayoutItem::GetPageIndex() const { ->GetLayoutPageMgr() ->GetPageIndex(this); } -void CXFA_ContainerLayoutItem::GetPageSize(CFX_SizeF& size) { + +void CXFA_ContainerLayoutItem::GetPageSize(CFX_SizeF& size) const { size.clear(); CXFA_Node* pMedium = m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Medium); if (!pMedium) @@ -193,6 +194,7 @@ void CXFA_ContainerLayoutItem::GetPageSize(CFX_SizeF& size) { size = CFX_SizeF(size.y, size.x); } } + CXFA_Node* CXFA_ContainerLayoutItem::GetMasterPage() const { return m_pFormNode; } |