diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-06 00:32:16 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-06 00:32:16 +0000 |
commit | d9826495fe0e279c6e2d587a656c7452cc2dc71f (patch) | |
tree | 0256f8903da70445c5f8e21b62c01d2d70385201 /core/fpdftext | |
parent | a0032a2a2c53794bbf0ccb412a5c70ce66f052fb (diff) | |
download | pdfium-d9826495fe0e279c6e2d587a656c7452cc2dc71f.tar.xz |
Encapsulate CPDF_PageObject's rect member.
At the same time, change it from 4 floats to a CFX_FloatRect.
Change-Id: I00ded941723d6a264b7a17c73fd337e66b449308
Reviewed-on: https://pdfium-review.googlesource.com/c/43570
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdftext')
-rw-r--r-- | core/fpdftext/cpdf_textpage.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 411ba398ae..77eae4de75 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -551,11 +551,13 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::FindTextlineFlowOrientation() if (!pPageObj->IsText()) continue; - int32_t minH = std::max(static_cast<int32_t>(pPageObj->m_Left), 0); + int32_t minH = std::max(static_cast<int32_t>(pPageObj->GetRect().left), 0); int32_t maxH = - std::min(static_cast<int32_t>(pPageObj->m_Right), nPageWidth); - int32_t minV = std::max(static_cast<int32_t>(pPageObj->m_Bottom), 0); - int32_t maxV = std::min(static_cast<int32_t>(pPageObj->m_Top), nPageHeight); + std::min(static_cast<int32_t>(pPageObj->GetRect().right), nPageWidth); + int32_t minV = + std::max(static_cast<int32_t>(pPageObj->GetRect().bottom), 0); + int32_t maxV = + std::min(static_cast<int32_t>(pPageObj->GetRect().top), nPageHeight); if (minH >= maxH || minV >= maxV) continue; @@ -570,7 +572,7 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::FindTextlineFlowOrientation() nEndV = std::max(nEndV, maxV); if (fLineHeight <= 0.0f) - fLineHeight = pPageObj->m_Top - pPageObj->m_Bottom; + fLineHeight = pPageObj->GetRect().Height(); } const int32_t nDoubleLineHeight = 2 * fLineHeight; if ((nEndV - nStartV) < nDoubleLineHeight) @@ -751,7 +753,7 @@ void CPDF_TextPage::ProcessTextObject( const CFX_Matrix& formMatrix, const CPDF_PageObjectList* pObjList, CPDF_PageObjectList::const_iterator ObjPos) { - if (fabs(pTextObj->m_Right - pTextObj->m_Left) < kSizeEpsilon) + if (fabs(pTextObj->GetRect().Width()) < kSizeEpsilon) return; size_t count = m_LineObj.size(); @@ -943,7 +945,7 @@ void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend, void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { CPDF_TextObject* pTextObj = Obj.m_pTextObj.Get(); - if (fabs(pTextObj->m_Right - pTextObj->m_Left) < kSizeEpsilon) + if (fabs(pTextObj->GetRect().Width()) < kSizeEpsilon) return; CFX_Matrix formMatrix = Obj.m_formMatrix; CPDF_Font* pFont = pTextObj->GetFont(); @@ -1244,8 +1246,8 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( CPDF_TextObjectItem item; pObj->GetItemInfo(0, &item); - CFX_FloatRect this_rect = pObj->GetRect(); - CFX_FloatRect prev_rect = m_pPreTextObj->GetRect(); + const CFX_FloatRect& this_rect = pObj->GetRect(); + const CFX_FloatRect& prev_rect = m_pPreTextObj->GetRect(); WideString wstrItem = pObj->GetFont()->UnicodeFromCharCode(item.m_CharCode); if (wstrItem.IsEmpty()) @@ -1299,14 +1301,16 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( m_DisplayMatrix.a > 0.9 && m_DisplayMatrix.b < 0.1 && m_DisplayMatrix.c < 0.1 && m_DisplayMatrix.d < -0.9 && m.b < 0.1 && m.c < 0.1) { - CFX_FloatRect re(0, m_pPreTextObj->m_Bottom, 1000, - m_pPreTextObj->m_Top); + CFX_FloatRect re(0, m_pPreTextObj->GetRect().bottom, 1000, + m_pPreTextObj->GetRect().top); if (re.Contains(pObj->GetPos())) { bNewline = false; } else { - if (CFX_FloatRect(0, pObj->m_Bottom, 1000, pObj->m_Top) - .Contains(m_pPreTextObj->GetPos())) + if (CFX_FloatRect(0, pObj->GetRect().bottom, 1000, + pObj->GetRect().top) + .Contains(m_pPreTextObj->GetPos())) { bNewline = false; + } } } } @@ -1356,7 +1360,7 @@ bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, return false; CFX_FloatRect rcPreObj = pTextObj2->GetRect(); - CFX_FloatRect rcCurObj = pTextObj1->GetRect(); + const CFX_FloatRect& rcCurObj = pTextObj1->GetRect(); if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty()) { float dbXdif = fabs(rcPreObj.left - rcCurObj.left); size_t nCount = m_CharList.size(); |