diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-10-05 15:48:39 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-05 20:03:35 +0000 |
commit | d103b96635a27abf93cb1a9a476c9263603bd203 (patch) | |
tree | 5c0ce568bc870f7b9f3e55ce45c0c9574bbb537d /core | |
parent | b7f9d8ee6d9c1d9c0dfa2c64b7ad5fee4032d513 (diff) | |
download | pdfium-d103b96635a27abf93cb1a9a476c9263603bd203.tar.xz |
Remove CPVT_SectionInfo
The CPVT_SectionInfo class only contains a CPVT_FloatRect member. This
CL removes the usage of CPVT_SectionInfo and uses the CPVT_FloatRect
where needed instead.
Change-Id: Ica020466db03282cf2ad9a7051899d74f8aef076
Reviewed-on: https://pdfium-review.googlesource.com/15730
Commit-Queue: dsinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfdoc/cpdf_variabletext.cpp | 67 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_variabletext.h | 6 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_sectioninfo.cpp | 22 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_sectioninfo.h | 24 | ||||
-rw-r--r-- | core/fpdfdoc/csection.cpp | 2 | ||||
-rw-r--r-- | core/fpdfdoc/csection.h | 3 |
6 files changed, 28 insertions, 96 deletions
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index e12f9491a2..18aa95793f 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -146,9 +146,9 @@ bool CPDF_VariableText::Iterator::GetWord(CPVT_Word& word) const { word.Word = pWord->Word; word.nCharset = pWord->nCharset; word.fWidth = m_pVT->GetWordWidth(*pWord); - word.ptWord = m_pVT->InToOut( - CFX_PointF(pWord->fWordX + pSection->m_SecInfo.rcSection.left, - pWord->fWordY + pSection->m_SecInfo.rcSection.top)); + word.ptWord = + m_pVT->InToOut(CFX_PointF(pWord->fWordX + pSection->m_Rect.left, + pWord->fWordY + pSection->m_Rect.top)); word.fAscent = m_pVT->GetWordAscent(*pWord); word.fDescent = m_pVT->GetWordDescent(*pWord); word.nFontIndex = m_pVT->GetWordFontIndex(*pWord); @@ -168,8 +168,8 @@ bool CPDF_VariableText::Iterator::GetLine(CPVT_Line& line) const { CLine* pLine = pSection->m_LineArray[m_CurPos.nLineIndex].get(); line.ptLine = m_pVT->InToOut( - CFX_PointF(pLine->m_LineInfo.fLineX + pSection->m_SecInfo.rcSection.left, - pLine->m_LineInfo.fLineY + pSection->m_SecInfo.rcSection.top)); + CFX_PointF(pLine->m_LineInfo.fLineX + pSection->m_Rect.left, + pLine->m_LineInfo.fLineY + pSection->m_Rect.top)); line.fLineWidth = pLine->m_LineInfo.fLineWidth; line.fLineAscent = pLine->m_LineInfo.fLineAscent; line.fLineDescent = pLine->m_LineInfo.fLineDescent; @@ -200,10 +200,9 @@ void CPDF_VariableText::Initialize() { if (m_bInitialized) return; - CPVT_SectionInfo secinfo; CPVT_WordPlace place; place.nSecIndex = 0; - AddSection(place, secinfo); + AddSection(place); CPVT_LineInfo lineinfo; lineinfo.fLineAscent = GetFontAscent(GetDefaultFontIndex(), GetFontSize()); @@ -254,8 +253,7 @@ CPVT_WordPlace CPDF_VariableText::InsertSection(const CPVT_WordPlace& place) { CSection* pSection = m_SectionArray[wordplace.nSecIndex].get(); CPVT_WordPlace NewPlace(wordplace.nSecIndex + 1, 0, -1); - CPVT_SectionInfo secinfo; - AddSection(NewPlace, secinfo); + AddSection(NewPlace); CPVT_WordPlace result = NewPlace; if (pdfium::IndexInBounds(m_SectionArray, NewPlace.nSecIndex)) { CSection* pNewSection = m_SectionArray[NewPlace.nSecIndex].get(); @@ -332,9 +330,8 @@ CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) { void CPDF_VariableText::SetText(const WideString& swText) { DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); CPVT_WordPlace wp(0, 0, -1); - CPVT_SectionInfo secinfo; if (!m_SectionArray.empty()) - m_SectionArray.front()->m_SecInfo = secinfo; + m_SectionArray.front()->m_Rect = CPVT_FloatRect(); int32_t nCharCount = 0; for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) { @@ -350,7 +347,7 @@ void CPDF_VariableText::SetText(const WideString& swText) { if (i + 1 < sz && swText[i + 1] == 0x0A) i++; wp.AdvanceSection(); - AddSection(wp, secinfo); + AddSection(wp); } break; case 0x0A: @@ -358,7 +355,7 @@ void CPDF_VariableText::SetText(const WideString& swText) { if (i + 1 < sz && swText[i + 1] == 0x0D) i++; wp.AdvanceSection(); - AddSection(wp, secinfo); + AddSection(wp); } break; case 0x09: @@ -484,23 +481,22 @@ CPVT_WordPlace CPDF_VariableText::SearchWordPlace( if (!pdfium::IndexInBounds(m_SectionArray, nMid)) break; CSection* pSection = m_SectionArray[nMid].get(); - if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.top)) + if (IsFloatBigger(pt.y, pSection->m_Rect.top)) bUp = false; - if (IsFloatBigger(pSection->m_SecInfo.rcSection.bottom, pt.y)) + if (IsFloatBigger(pSection->m_Rect.bottom, pt.y)) bDown = false; - if (IsFloatSmaller(pt.y, pSection->m_SecInfo.rcSection.top)) { + if (IsFloatSmaller(pt.y, pSection->m_Rect.top)) { nRight = nMid - 1; nMid = (nLeft + nRight) / 2; continue; } - if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.bottom)) { + if (IsFloatBigger(pt.y, pSection->m_Rect.bottom)) { nLeft = nMid + 1; nMid = (nLeft + nRight) / 2; continue; } place = pSection->SearchWordPlace( - CFX_PointF(pt.x - pSection->m_SecInfo.rcSection.left, - pt.y - pSection->m_SecInfo.rcSection.top)); + CFX_PointF(pt.x - pSection->m_Rect.left, pt.y - pSection->m_Rect.top)); place.nSecIndex = nMid; return place; } @@ -521,16 +517,15 @@ CPVT_WordPlace CPDF_VariableText::GetUpWordPlace( CPVT_WordPlace temp = place; CFX_PointF pt = OutToIn(point); if (temp.nLineIndex-- > 0) { - return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, - temp); + return pSection->SearchWordPlace(pt.x - pSection->m_Rect.left, temp); } if (temp.nSecIndex-- > 0) { if (pdfium::IndexInBounds(m_SectionArray, temp.nSecIndex)) { CSection* pLastSection = m_SectionArray[temp.nSecIndex].get(); temp.nLineIndex = pdfium::CollectionSize<int32_t>(pLastSection->m_LineArray) - 1; - return pLastSection->SearchWordPlace( - pt.x - pLastSection->m_SecInfo.rcSection.left, temp); + return pLastSection->SearchWordPlace(pt.x - pLastSection->m_Rect.left, + temp); } } return place; @@ -547,15 +542,14 @@ CPVT_WordPlace CPDF_VariableText::GetDownWordPlace( CFX_PointF pt = OutToIn(point); if (temp.nLineIndex++ < pdfium::CollectionSize<int32_t>(pSection->m_LineArray) - 1) { - return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, - temp); + return pSection->SearchWordPlace(pt.x - pSection->m_Rect.left, temp); } temp.AdvanceSection(); if (!pdfium::IndexInBounds(m_SectionArray, temp.nSecIndex)) return place; return m_SectionArray[temp.nSecIndex]->SearchWordPlace( - pt.x - pSection->m_SecInfo.rcSection.left, temp); + pt.x - pSection->m_Rect.left, temp); } CPVT_WordPlace CPDF_VariableText::GetLineBeginPlace( @@ -597,8 +591,7 @@ int32_t CPDF_VariableText::GetTotalWords() const { return nTotal - kReturnLength; } -CPVT_WordPlace CPDF_VariableText::AddSection(const CPVT_WordPlace& place, - const CPVT_SectionInfo& secinfo) { +CPVT_WordPlace CPDF_VariableText::AddSection(const CPVT_WordPlace& place) { if (IsValid() && !m_bMultiLine) return place; @@ -606,7 +599,7 @@ CPVT_WordPlace CPDF_VariableText::AddSection(const CPVT_WordPlace& place, place.nSecIndex, 0, pdfium::CollectionSize<int32_t>(m_SectionArray)); auto pSection = pdfium::MakeUnique<CSection>(this); - pSection->m_SecInfo = secinfo; + pSection->m_Rect = CPVT_FloatRect(); pSection->SecPlace.nSecIndex = nSecIndex; m_SectionArray.insert(m_SectionArray.begin() + nSecIndex, std::move(pSection)); @@ -672,15 +665,6 @@ bool CPDF_VariableText::GetLineInfo(const CPVT_WordPlace& place, return true; } -bool CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace& place, - CPVT_SectionInfo& secinfo) { - if (!pdfium::IndexInBounds(m_SectionArray, place.nSecIndex)) - return false; - - secinfo = m_SectionArray[place.nSecIndex]->m_SecInfo; - return true; -} - void CPDF_VariableText::SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; } @@ -953,19 +937,18 @@ CPVT_FloatRect CPDF_VariableText::RearrangeSections( place.nSecIndex = s; CSection* pSection = m_SectionArray[s].get(); pSection->SecPlace = place; - CPVT_FloatRect rcSec = pSection->m_SecInfo.rcSection; + CPVT_FloatRect rcSec = pSection->m_Rect; if (s >= nSSecIndex) { if (s <= nESecIndex) { rcSec = pSection->Rearrange(); rcSec.top += fPosY; rcSec.bottom += fPosY; } else { - fOldHeight = pSection->m_SecInfo.rcSection.bottom - - pSection->m_SecInfo.rcSection.top; + fOldHeight = pSection->m_Rect.bottom - pSection->m_Rect.top; rcSec.top = fPosY; rcSec.bottom = fPosY + fOldHeight; } - pSection->m_SecInfo.rcSection = rcSec; + pSection->m_Rect = rcSec; pSection->ResetLinePlace(); } if (s == 0) { diff --git a/core/fpdfdoc/cpdf_variabletext.h b/core/fpdfdoc/cpdf_variabletext.h index 22ed09ad31..bdc95d47f9 100644 --- a/core/fpdfdoc/cpdf_variabletext.h +++ b/core/fpdfdoc/cpdf_variabletext.h @@ -23,8 +23,6 @@ class CPVT_Word; class CSection; class IPVT_FontMap; -struct CPVT_SectionInfo; - struct CPVT_WordInfo; #define VARIABLETEXT_HALF 0.5f @@ -178,8 +176,7 @@ class CPDF_VariableText { int32_t GetWordFontIndex(uint16_t word, int32_t charset, int32_t nFontIndex); bool IsLatinWord(uint16_t word); - CPVT_WordPlace AddSection(const CPVT_WordPlace& place, - const CPVT_SectionInfo& secinfo); + CPVT_WordPlace AddSection(const CPVT_WordPlace& place); CPVT_WordPlace AddLine(const CPVT_WordPlace& place, const CPVT_LineInfo& lineinfo); CPVT_WordPlace AddWord(const CPVT_WordPlace& place, @@ -187,7 +184,6 @@ class CPDF_VariableText { bool GetWordInfo(const CPVT_WordPlace& place, CPVT_WordInfo& wordinfo); bool SetWordInfo(const CPVT_WordPlace& place, const CPVT_WordInfo& wordinfo); bool GetLineInfo(const CPVT_WordPlace& place, CPVT_LineInfo& lineinfo); - bool GetSectionInfo(const CPVT_WordPlace& place, CPVT_SectionInfo& secinfo); float GetWordFontSize(); int32_t GetWordFontIndex(const CPVT_WordInfo& WordInfo); diff --git a/core/fpdfdoc/cpvt_sectioninfo.cpp b/core/fpdfdoc/cpvt_sectioninfo.cpp deleted file mode 100644 index cb1dc8907b..0000000000 --- a/core/fpdfdoc/cpvt_sectioninfo.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// 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 "core/fpdfdoc/cpvt_sectioninfo.h" -#include "third_party/base/ptr_util.h" - -CPVT_SectionInfo::CPVT_SectionInfo() : rcSection() {} - -CPVT_SectionInfo::~CPVT_SectionInfo() {} - -CPVT_SectionInfo::CPVT_SectionInfo(const CPVT_SectionInfo& other) { - operator=(other); -} - -void CPVT_SectionInfo::operator=(const CPVT_SectionInfo& other) { - if (this == &other) - return; - rcSection = other.rcSection; -} diff --git a/core/fpdfdoc/cpvt_sectioninfo.h b/core/fpdfdoc/cpvt_sectioninfo.h deleted file mode 100644 index b39cdc9128..0000000000 --- a/core/fpdfdoc/cpvt_sectioninfo.h +++ /dev/null @@ -1,24 +0,0 @@ -// 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 - -#ifndef CORE_FPDFDOC_CPVT_SECTIONINFO_H_ -#define CORE_FPDFDOC_CPVT_SECTIONINFO_H_ - -#include <memory> - -#include "core/fpdfdoc/cpvt_floatrect.h" - -struct CPVT_SectionInfo { - CPVT_SectionInfo(); - CPVT_SectionInfo(const CPVT_SectionInfo& other); - ~CPVT_SectionInfo(); - - void operator=(const CPVT_SectionInfo& other); - - CPVT_FloatRect rcSection; -}; - -#endif // CORE_FPDFDOC_CPVT_SECTIONINFO_H_ diff --git a/core/fpdfdoc/csection.cpp b/core/fpdfdoc/csection.cpp index f8b658af8c..45cbf6bdfc 100644 --- a/core/fpdfdoc/csection.cpp +++ b/core/fpdfdoc/csection.cpp @@ -172,7 +172,7 @@ CPVT_WordPlace CSection::SearchWordPlace( CLine* pLine = m_LineArray[lineplace.nLineIndex].get(); return SearchWordPlace( - fx - m_SecInfo.rcSection.left, + fx - m_Rect.left, CPVT_WordRange(pLine->GetNextWordPlace(pLine->GetBeginWordPlace()), pLine->GetEndWordPlace())); } diff --git a/core/fpdfdoc/csection.h b/core/fpdfdoc/csection.h index d516c45e6f..a8ade8624f 100644 --- a/core/fpdfdoc/csection.h +++ b/core/fpdfdoc/csection.h @@ -11,7 +11,6 @@ #include <vector> #include "core/fpdfdoc/cline.h" -#include "core/fpdfdoc/cpvt_sectioninfo.h" #include "core/fpdfdoc/cpvt_wordinfo.h" #include "core/fpdfdoc/cpvt_wordrange.h" #include "core/fpdfdoc/ctypeset.h" @@ -48,7 +47,7 @@ class CSection final { CPVT_WordPlace SearchWordPlace(float fx, const CPVT_WordRange& range) const; CPVT_WordPlace SecPlace; - CPVT_SectionInfo m_SecInfo; + CPVT_FloatRect m_Rect; std::vector<std::unique_ptr<CLine>> m_LineArray; std::vector<std::unique_ptr<CPVT_WordInfo>> m_WordArray; |