From 448c4337f2be2523727451b265311d48e9550ee5 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 2 Aug 2016 12:07:35 -0700 Subject: Splitting fpdfdoc/doc_* part II. This splits the doc_ocg, doc_vt and doc_basic files into individual class files. Review-Url: https://codereview.chromium.org/2187073005 --- fpdfsdk/fxedit/fxet_edit.cpp | 46 +++++++++++++++++++------------------- fpdfsdk/fxedit/fxet_list.cpp | 18 +++++++-------- fpdfsdk/fxedit/include/fxet_edit.h | 17 +++++--------- 3 files changed, 37 insertions(+), 44 deletions(-) (limited to 'fpdfsdk/fxedit') diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index bafe3d0db5..f31c60a721 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -841,7 +841,7 @@ CFX_ByteString CFX_Edit::GetEditAppearanceStream(CFX_Edit* pEdit, } FX_FLOAT fCharSpace = pEdit->GetCharSpace(); - if (!FX_EDIT_IsFloatZero(fCharSpace)) { + if (!IsFloatZero(fCharSpace)) { sAppStream << fCharSpace << " Tc\n"; } @@ -1909,7 +1909,7 @@ void CFX_Edit::SetScrollPosX(FX_FLOAT fx) { return; if (m_pVT->IsValid()) { - if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x, fx)) { + if (!IsFloatEqual(m_ptScrollPos.x, fx)) { m_ptScrollPos.x = fx; Refresh(); } @@ -1921,7 +1921,7 @@ void CFX_Edit::SetScrollPosY(FX_FLOAT fy) { return; if (m_pVT->IsValid()) { - if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { + if (!IsFloatEqual(m_ptScrollPos.y, fy)) { m_ptScrollPos.y = fy; Refresh(); @@ -1955,10 +1955,10 @@ void CFX_Edit::SetScrollLimit() { if (rcPlate.Width() > rcContent.Width()) { SetScrollPosX(rcPlate.left); } else { - if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.x, rcContent.left)) { + if (IsFloatSmaller(m_ptScrollPos.x, rcContent.left)) { SetScrollPosX(rcContent.left); - } else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.x, - rcContent.right - rcPlate.Width())) { + } else if (IsFloatBigger(m_ptScrollPos.x, + rcContent.right - rcPlate.Width())) { SetScrollPosX(rcContent.right - rcPlate.Width()); } } @@ -1966,10 +1966,10 @@ void CFX_Edit::SetScrollLimit() { if (rcPlate.Height() > rcContent.Height()) { SetScrollPosY(rcPlate.top); } else { - if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.y, - rcContent.bottom + rcPlate.Height())) { + if (IsFloatSmaller(m_ptScrollPos.y, + rcContent.bottom + rcPlate.Height())) { SetScrollPosY(rcContent.bottom + rcPlate.Height()); - } else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.y, rcContent.top)) { + } else if (IsFloatBigger(m_ptScrollPos.y, rcContent.top)) { SetScrollPosY(rcContent.top); } } @@ -2007,23 +2007,23 @@ void CFX_Edit::ScrollToCaret() { CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); - if (!FX_EDIT_IsFloatEqual(rcPlate.left, rcPlate.right)) { - if (FX_EDIT_IsFloatSmaller(ptHeadEdit.x, rcPlate.left) || - FX_EDIT_IsFloatEqual(ptHeadEdit.x, rcPlate.left)) { + if (!IsFloatEqual(rcPlate.left, rcPlate.right)) { + if (IsFloatSmaller(ptHeadEdit.x, rcPlate.left) || + IsFloatEqual(ptHeadEdit.x, rcPlate.left)) { SetScrollPosX(ptHead.x); - } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.x, rcPlate.right)) { + } else if (IsFloatBigger(ptHeadEdit.x, rcPlate.right)) { SetScrollPosX(ptHead.x - rcPlate.Width()); } } - if (!FX_EDIT_IsFloatEqual(rcPlate.top, rcPlate.bottom)) { - if (FX_EDIT_IsFloatSmaller(ptFootEdit.y, rcPlate.bottom) || - FX_EDIT_IsFloatEqual(ptFootEdit.y, rcPlate.bottom)) { - if (FX_EDIT_IsFloatSmaller(ptHeadEdit.y, rcPlate.top)) { + if (!IsFloatEqual(rcPlate.top, rcPlate.bottom)) { + if (IsFloatSmaller(ptFootEdit.y, rcPlate.bottom) || + IsFloatEqual(ptFootEdit.y, rcPlate.bottom)) { + if (IsFloatSmaller(ptHeadEdit.y, rcPlate.top)) { SetScrollPosY(ptFoot.y + rcPlate.Height()); } - } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top)) { - if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.bottom)) { + } else if (IsFloatBigger(ptHeadEdit.y, rcPlate.top)) { + if (IsFloatBigger(ptFootEdit.y, rcPlate.bottom)) { SetScrollPosY(ptHead.y); } } @@ -2788,12 +2788,12 @@ FX_BOOL CFX_Edit::IsTextOverflow() const { CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); CFX_FloatRect rcContent = m_pVT->GetContentRect(); - if (m_pVT->IsMultiLine() && GetTotalLines() > 1) { - if (FX_EDIT_IsFloatBigger(rcContent.Height(), rcPlate.Height())) - return TRUE; + if (m_pVT->IsMultiLine() && GetTotalLines() > 1 && + IsFloatBigger(rcContent.Height(), rcPlate.Height())) { + return TRUE; } - if (FX_EDIT_IsFloatBigger(rcContent.Width(), rcPlate.Width())) + if (IsFloatBigger(rcContent.Width(), rcPlate.Width())) return TRUE; } diff --git a/fpdfsdk/fxedit/fxet_list.cpp b/fpdfsdk/fxedit/fxet_list.cpp index 77484e6a8a..96fb60dcaa 100644 --- a/fpdfsdk/fxedit/fxet_list.cpp +++ b/fpdfsdk/fxedit/fxet_list.cpp @@ -517,12 +517,12 @@ void CFX_ListCtrl::ScrollToListItem(int32_t nItemIndex) { CFX_FloatRect rcItem = GetItemRectInternal(nItemIndex); CFX_FloatRect rcItemCtrl = GetItemRect(nItemIndex); - if (FX_EDIT_IsFloatSmaller(rcItemCtrl.bottom, rcPlate.bottom)) { - if (FX_EDIT_IsFloatSmaller(rcItemCtrl.top, rcPlate.top)) { + if (IsFloatSmaller(rcItemCtrl.bottom, rcPlate.bottom)) { + if (IsFloatSmaller(rcItemCtrl.top, rcPlate.top)) { SetScrollPosY(rcItem.bottom + rcPlate.Height()); } - } else if (FX_EDIT_IsFloatBigger(rcItemCtrl.top, rcPlate.top)) { - if (FX_EDIT_IsFloatBigger(rcItemCtrl.bottom, rcPlate.bottom)) { + } else if (IsFloatBigger(rcItemCtrl.top, rcPlate.top)) { + if (IsFloatBigger(rcItemCtrl.bottom, rcPlate.bottom)) { SetScrollPosY(rcItem.top); } } @@ -548,16 +548,16 @@ void CFX_ListCtrl::SetScrollPos(const CFX_FloatPoint& point) { } void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy) { - if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { + if (!IsFloatEqual(m_ptScrollPos.y, fy)) { CFX_FloatRect rcPlate = GetPlateRect(); CFX_FloatRect rcContent = GetContentRectInternal(); if (rcPlate.Height() > rcContent.Height()) { fy = rcPlate.top; } else { - if (FX_EDIT_IsFloatSmaller(fy - rcPlate.Height(), rcContent.bottom)) { + if (IsFloatSmaller(fy - rcPlate.Height(), rcContent.bottom)) { fy = rcContent.bottom + rcPlate.Height(); - } else if (FX_EDIT_IsFloatBigger(fy, rcContent.top)) { + } else if (IsFloatBigger(fy, rcContent.top)) { fy = rcContent.top; } } @@ -641,11 +641,11 @@ int32_t CFX_ListCtrl::GetItemIndex(const CFX_FloatPoint& point) const { if (CFX_ListItem* pListItem = m_aListItems.GetAt(i)) { CLST_Rect rcListItem = pListItem->GetRect(); - if (FX_EDIT_IsFloatBigger(pt.y, rcListItem.top)) { + if (IsFloatBigger(pt.y, rcListItem.top)) { bFirst = FALSE; } - if (FX_EDIT_IsFloatSmaller(pt.y, rcListItem.bottom)) { + if (IsFloatSmaller(pt.y, rcListItem.bottom)) { bLast = FALSE; } diff --git a/fpdfsdk/fxedit/include/fxet_edit.h b/fpdfsdk/fxedit/include/fxet_edit.h index bf8828696b..9adf17271b 100644 --- a/fpdfsdk/fxedit/include/fxet_edit.h +++ b/fpdfsdk/fxedit/include/fxet_edit.h @@ -24,12 +24,6 @@ class CFX_RenderDevice; class CFX_SystemHandler; class IFX_Edit_UndoItem; -#define FX_EDIT_IsFloatZero(f) (f < 0.0001 && f > -0.0001) -#define FX_EDIT_IsFloatEqual(fa, fb) FX_EDIT_IsFloatZero(fa - fb) -#define FX_EDIT_IsFloatBigger(fa, fb) (fa > fb && !FX_EDIT_IsFloatEqual(fa, fb)) -#define FX_EDIT_IsFloatSmaller(fa, fb) \ - (fa < fb && !FX_EDIT_IsFloatEqual(fa, fb)) - enum EDIT_PROPS_E { EP_LINELEADING, EP_LINEINDENT, @@ -55,21 +49,20 @@ struct CFX_Edit_LineRect { } FX_BOOL IsSameHeight(const CFX_Edit_LineRect& linerect) const { - return FX_EDIT_IsFloatZero( - (m_rcLine.top - m_rcLine.bottom) - - (linerect.m_rcLine.top - linerect.m_rcLine.bottom)); + return IsFloatZero((m_rcLine.top - m_rcLine.bottom) - + (linerect.m_rcLine.top - linerect.m_rcLine.bottom)); } FX_BOOL IsSameTop(const CFX_Edit_LineRect& linerect) const { - return FX_EDIT_IsFloatZero(m_rcLine.top - linerect.m_rcLine.top); + return IsFloatZero(m_rcLine.top - linerect.m_rcLine.top); } FX_BOOL IsSameLeft(const CFX_Edit_LineRect& linerect) const { - return FX_EDIT_IsFloatZero(m_rcLine.left - linerect.m_rcLine.left); + return IsFloatZero(m_rcLine.left - linerect.m_rcLine.left); } FX_BOOL IsSameRight(const CFX_Edit_LineRect& linerect) const { - return FX_EDIT_IsFloatZero(m_rcLine.right - linerect.m_rcLine.right); + return IsFloatZero(m_rcLine.right - linerect.m_rcLine.right); } CPVT_WordRange m_wrLine; -- cgit v1.2.3