From d103b96635a27abf93cb1a9a476c9263603bd203 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 5 Oct 2017 15:48:39 -0400 Subject: 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 Commit-Queue: Ryan Harrison Reviewed-by: Ryan Harrison --- BUILD.gn | 2 -- core/fpdfdoc/cpdf_variabletext.cpp | 67 ++++++++++++++------------------------ core/fpdfdoc/cpdf_variabletext.h | 6 +--- core/fpdfdoc/cpvt_sectioninfo.cpp | 22 ------------- core/fpdfdoc/cpvt_sectioninfo.h | 24 -------------- core/fpdfdoc/csection.cpp | 2 +- core/fpdfdoc/csection.h | 3 +- 7 files changed, 28 insertions(+), 98 deletions(-) delete mode 100644 core/fpdfdoc/cpvt_sectioninfo.cpp delete mode 100644 core/fpdfdoc/cpvt_sectioninfo.h diff --git a/BUILD.gn b/BUILD.gn index 451af01ffc..3e3f22fdde 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -363,8 +363,6 @@ static_library("fpdfdoc") { "core/fpdfdoc/cpvt_generateap.h", "core/fpdfdoc/cpvt_line.h", "core/fpdfdoc/cpvt_lineinfo.h", - "core/fpdfdoc/cpvt_sectioninfo.cpp", - "core/fpdfdoc/cpvt_sectioninfo.h", "core/fpdfdoc/cpvt_word.h", "core/fpdfdoc/cpvt_wordinfo.cpp", "core/fpdfdoc/cpvt_wordinfo.h", 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(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(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(m_SectionArray)); auto pSection = pdfium::MakeUnique(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 - -#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 #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> m_LineArray; std::vector> m_WordArray; -- cgit v1.2.3