From ce813f82c914ad560e429a0685553b1e3e8797ac Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 5 Oct 2017 15:12:58 -0400 Subject: Remove CPVT_WordProps Only one of the props was being used and that prop always had the same value. This CL removes CPVT_WordProps. Change-Id: I8cf64f0e9b80c5af18b8fc40ef7b602ffeec7f93 Reviewed-on: https://pdfium-review.googlesource.com/15672 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- BUILD.gn | 1 - core/fpdfdoc/cpdf_variabletext.cpp | 30 +------------------- core/fpdfdoc/cpdf_variabletext.h | 3 -- core/fpdfdoc/cpvt_section.h | 2 -- core/fpdfdoc/cpvt_sectioninfo.cpp | 4 --- core/fpdfdoc/cpvt_sectioninfo.h | 2 -- core/fpdfdoc/cpvt_word.h | 2 -- core/fpdfdoc/cpvt_wordinfo.cpp | 9 +----- core/fpdfdoc/cpvt_wordinfo.h | 7 +---- core/fpdfdoc/cpvt_wordprops.h | 58 -------------------------------------- core/fpdfdoc/csection.cpp | 1 + core/fpdfdoc/csection.h | 2 ++ core/fpdfdoc/ctypeset.cpp | 19 ++----------- fpdfsdk/pwl/cpwl_edit_impl.h | 3 +- fpdfsdk/pwl/cpwl_list_box.h | 1 - 15 files changed, 11 insertions(+), 133 deletions(-) delete mode 100644 core/fpdfdoc/cpvt_wordprops.h diff --git a/BUILD.gn b/BUILD.gn index 1cbc47608d..3324de76fb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -370,7 +370,6 @@ static_library("fpdfdoc") { "core/fpdfdoc/cpvt_wordinfo.cpp", "core/fpdfdoc/cpvt_wordinfo.h", "core/fpdfdoc/cpvt_wordplace.h", - "core/fpdfdoc/cpvt_wordprops.h", "core/fpdfdoc/cpvt_wordrange.h", "core/fpdfdoc/csection.cpp", "core/fpdfdoc/csection.h", diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index e22e954f12..8e5a74e171 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -188,27 +188,11 @@ bool CPDF_VariableText::Iterator::GetWord(CPVT_Word& word) const { pWord->fWordY + pSection->m_SecInfo.rcSection.top)); word.fAscent = m_pVT->GetWordAscent(*pWord); word.fDescent = m_pVT->GetWordDescent(*pWord); - if (pWord->pWordProps) - word.WordProps = *pWord->pWordProps; word.nFontIndex = m_pVT->GetWordFontIndex(*pWord); word.fFontSize = m_pVT->GetWordFontSize(); return true; } -bool CPDF_VariableText::Iterator::SetWord(const CPVT_Word& word) { - if (!pdfium::IndexInBounds(m_pVT->m_SectionArray, m_CurPos.nSecIndex)) - return false; - - CSection* pSection = m_pVT->m_SectionArray[m_CurPos.nSecIndex].get(); - if (!pdfium::IndexInBounds(pSection->m_WordArray, m_CurPos.nWordIndex)) - return false; - - CPVT_WordInfo* pWord = pSection->m_WordArray[m_CurPos.nWordIndex].get(); - if (pWord->pWordProps) - *pWord->pWordProps = word.WordProps; - return true; -} - bool CPDF_VariableText::Iterator::GetLine(CPVT_Line& line) const { ASSERT(m_pVT); line.lineplace = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex, -1); @@ -237,18 +221,6 @@ bool CPDF_VariableText::Iterator::GetSection(CPVT_Section& section) const { CSection* pSection = m_pVT->m_SectionArray[m_CurPos.nSecIndex].get(); section.rcSection = m_pVT->InToOut(pSection->m_SecInfo.rcSection); - if (pSection->m_SecInfo.pWordProps) - section.WordProps = *pSection->m_SecInfo.pWordProps; - return true; -} - -bool CPDF_VariableText::Iterator::SetSection(const CPVT_Section& section) { - if (!pdfium::IndexInBounds(m_pVT->m_SectionArray, m_CurPos.nSecIndex)) - return false; - - CSection* pSection = m_pVT->m_SectionArray[m_CurPos.nSecIndex].get(); - if (pSection->m_SecInfo.pWordProps) - *pSection->m_SecInfo.pWordProps = section.WordProps; return true; } @@ -310,7 +282,7 @@ CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace& place, int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordFontIndex(word, charset, GetDefaultFontIndex()); - return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, nullptr)); + return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex)); } CPVT_WordPlace CPDF_VariableText::InsertSection(const CPVT_WordPlace& place) { diff --git a/core/fpdfdoc/cpdf_variabletext.h b/core/fpdfdoc/cpdf_variabletext.h index f714102223..ee68f023fa 100644 --- a/core/fpdfdoc/cpdf_variabletext.h +++ b/core/fpdfdoc/cpdf_variabletext.h @@ -27,7 +27,6 @@ struct CPVT_Section; struct CPVT_SectionInfo; struct CPVT_WordInfo; -struct CPVT_WordProps; #define VARIABLETEXT_HALF 0.5f @@ -46,11 +45,9 @@ class CPDF_VariableText { bool PrevLine(); bool NextSection(); bool PrevSection(); - bool SetWord(const CPVT_Word& word); bool GetWord(CPVT_Word& word) const; bool GetLine(CPVT_Line& line) const; bool GetSection(CPVT_Section& section) const; - bool SetSection(const CPVT_Section& section); void SetAt(int32_t nWordIndex); void SetAt(const CPVT_WordPlace& place); const CPVT_WordPlace& GetAt() const { return m_CurPos; } diff --git a/core/fpdfdoc/cpvt_section.h b/core/fpdfdoc/cpvt_section.h index ce8928cee2..6b2ae075bf 100644 --- a/core/fpdfdoc/cpvt_section.h +++ b/core/fpdfdoc/cpvt_section.h @@ -8,13 +8,11 @@ #define CORE_FPDFDOC_CPVT_SECTION_H_ #include "core/fpdfdoc/cpvt_wordplace.h" -#include "core/fpdfdoc/cpvt_wordprops.h" #include "core/fxcrt/fx_coordinates.h" struct CPVT_Section { CPVT_WordPlace secplace; CFX_FloatRect rcSection; - CPVT_WordProps WordProps; }; #endif // CORE_FPDFDOC_CPVT_SECTION_H_ diff --git a/core/fpdfdoc/cpvt_sectioninfo.cpp b/core/fpdfdoc/cpvt_sectioninfo.cpp index 96ce37da8b..a23d3e45da 100644 --- a/core/fpdfdoc/cpvt_sectioninfo.cpp +++ b/core/fpdfdoc/cpvt_sectioninfo.cpp @@ -21,8 +21,4 @@ void CPVT_SectionInfo::operator=(const CPVT_SectionInfo& other) { rcSection = other.rcSection; nTotalLine = other.nTotalLine; - if (other.pWordProps) - pWordProps = pdfium::MakeUnique(*other.pWordProps); - else - pWordProps.reset(); } diff --git a/core/fpdfdoc/cpvt_sectioninfo.h b/core/fpdfdoc/cpvt_sectioninfo.h index 7ebe06cc81..9483a856a1 100644 --- a/core/fpdfdoc/cpvt_sectioninfo.h +++ b/core/fpdfdoc/cpvt_sectioninfo.h @@ -10,7 +10,6 @@ #include #include "core/fpdfdoc/cpvt_floatrect.h" -#include "core/fpdfdoc/cpvt_wordprops.h" struct CPVT_SectionInfo { CPVT_SectionInfo(); @@ -21,7 +20,6 @@ struct CPVT_SectionInfo { CPVT_FloatRect rcSection; int32_t nTotalLine; - std::unique_ptr pWordProps; }; #endif // CORE_FPDFDOC_CPVT_SECTIONINFO_H_ diff --git a/core/fpdfdoc/cpvt_word.h b/core/fpdfdoc/cpvt_word.h index 28e192467b..ad0ba744cc 100644 --- a/core/fpdfdoc/cpvt_word.h +++ b/core/fpdfdoc/cpvt_word.h @@ -8,7 +8,6 @@ #define CORE_FPDFDOC_CPVT_WORD_H_ #include "core/fpdfdoc/cpvt_wordplace.h" -#include "core/fpdfdoc/cpvt_wordprops.h" #include "core/fxcrt/fx_system.h" class CPVT_Word { @@ -24,7 +23,6 @@ class CPVT_Word { float fWidth; int32_t nFontIndex; float fFontSize; - CPVT_WordProps WordProps; }; inline CPVT_Word::CPVT_Word() diff --git a/core/fpdfdoc/cpvt_wordinfo.cpp b/core/fpdfdoc/cpvt_wordinfo.cpp index 36859c2309..24ad4b8965 100644 --- a/core/fpdfdoc/cpvt_wordinfo.cpp +++ b/core/fpdfdoc/cpvt_wordinfo.cpp @@ -16,10 +16,7 @@ CPVT_WordInfo::CPVT_WordInfo() fWordTail(0.0f), nFontIndex(-1) {} -CPVT_WordInfo::CPVT_WordInfo(uint16_t word, - int32_t charset, - int32_t fontIndex, - CPVT_WordProps* pProps) +CPVT_WordInfo::CPVT_WordInfo(uint16_t word, int32_t charset, int32_t fontIndex) : Word(word), nCharset(charset), fWordX(0.0f), @@ -49,8 +46,4 @@ void CPVT_WordInfo::operator=(const CPVT_WordInfo& word) { fWordX = word.fWordX; fWordY = word.fWordY; fWordTail = word.fWordTail; - if (word.pWordProps) - pWordProps = pdfium::MakeUnique(*word.pWordProps); - else - pWordProps.reset(); } diff --git a/core/fpdfdoc/cpvt_wordinfo.h b/core/fpdfdoc/cpvt_wordinfo.h index 00f5a45e70..9b2ec8a1e5 100644 --- a/core/fpdfdoc/cpvt_wordinfo.h +++ b/core/fpdfdoc/cpvt_wordinfo.h @@ -9,15 +9,11 @@ #include -#include "core/fpdfdoc/cpvt_wordprops.h" #include "core/fxcrt/fx_system.h" struct CPVT_WordInfo { CPVT_WordInfo(); - CPVT_WordInfo(uint16_t word, - int32_t charset, - int32_t fontIndex, - CPVT_WordProps* pProps); + CPVT_WordInfo(uint16_t word, int32_t charset, int32_t fontIndex); CPVT_WordInfo(const CPVT_WordInfo& word); ~CPVT_WordInfo(); @@ -29,7 +25,6 @@ struct CPVT_WordInfo { float fWordY; float fWordTail; int32_t nFontIndex; - std::unique_ptr pWordProps; }; #endif // CORE_FPDFDOC_CPVT_WORDINFO_H_ diff --git a/core/fpdfdoc/cpvt_wordprops.h b/core/fpdfdoc/cpvt_wordprops.h deleted file mode 100644 index 2d0e5d51b3..0000000000 --- a/core/fpdfdoc/cpvt_wordprops.h +++ /dev/null @@ -1,58 +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_WORDPROPS_H_ -#define CORE_FPDFDOC_CPVT_WORDPROPS_H_ - -#include "core/fpdfdoc/cpdf_variabletext.h" -#include "core/fxcrt/fx_system.h" -#include "core/fxge/fx_dib.h" - -struct CPVT_WordProps { - CPVT_WordProps() - : nFontIndex(-1), - fFontSize(0.0f), - dwWordColor(0), - nScriptType(CPDF_VariableText::ScriptType::Normal), - nWordStyle(0), - fCharSpace(0.0f), - nHorzScale(0) {} - - CPVT_WordProps(int32_t fontIndex, - float fontSize, - FX_COLORREF wordColor = 0, - CPDF_VariableText::ScriptType scriptType = - CPDF_VariableText::ScriptType::Normal, - int32_t wordStyle = 0, - float charSpace = 0, - int32_t horzScale = 100) - : nFontIndex(fontIndex), - fFontSize(fontSize), - dwWordColor(wordColor), - nScriptType(scriptType), - nWordStyle(wordStyle), - fCharSpace(charSpace), - nHorzScale(horzScale) {} - - CPVT_WordProps(const CPVT_WordProps& other) - : nFontIndex(other.nFontIndex), - fFontSize(other.fFontSize), - dwWordColor(other.dwWordColor), - nScriptType(other.nScriptType), - nWordStyle(other.nWordStyle), - fCharSpace(other.fCharSpace), - nHorzScale(other.nHorzScale) {} - - int32_t nFontIndex; - float fFontSize; - FX_COLORREF dwWordColor; - CPDF_VariableText::ScriptType nScriptType; - int32_t nWordStyle; - float fCharSpace; - int32_t nHorzScale; -}; - -#endif // CORE_FPDFDOC_CPVT_WORDPROPS_H_ diff --git a/core/fpdfdoc/csection.cpp b/core/fpdfdoc/csection.cpp index 1f2bef43c3..f8b658af8c 100644 --- a/core/fpdfdoc/csection.cpp +++ b/core/fpdfdoc/csection.cpp @@ -9,6 +9,7 @@ #include #include "core/fpdfdoc/cline.h" +#include "core/fpdfdoc/cpdf_variabletext.h" #include "core/fpdfdoc/cpvt_wordinfo.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" diff --git a/core/fpdfdoc/csection.h b/core/fpdfdoc/csection.h index 7c2b70b7dc..d516c45e6f 100644 --- a/core/fpdfdoc/csection.h +++ b/core/fpdfdoc/csection.h @@ -12,6 +12,8 @@ #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" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" diff --git a/core/fpdfdoc/ctypeset.cpp b/core/fpdfdoc/ctypeset.cpp index 856377e598..090985e436 100644 --- a/core/fpdfdoc/ctypeset.cpp +++ b/core/fpdfdoc/ctypeset.cpp @@ -9,6 +9,7 @@ #include #include "core/fpdfdoc/cline.h" +#include "core/fpdfdoc/cpdf_variabletext.h" #include "core/fpdfdoc/cpvt_wordinfo.h" #include "core/fpdfdoc/csection.h" #include "third_party/base/stl_util.h" @@ -470,22 +471,8 @@ void CTypeset::OutputLines() { if (pdfium::IndexInBounds(m_pSection->m_WordArray, w)) { CPVT_WordInfo* pWord = m_pSection->m_WordArray[w].get(); pWord->fWordX = fPosX - fMinX; - if (pWord->pWordProps) { - switch (pWord->pWordProps->nScriptType) { - default: - case CPDF_VariableText::ScriptType::Normal: - pWord->fWordY = fPosY - fMinY; - break; - case CPDF_VariableText::ScriptType::Super: - pWord->fWordY = fPosY - m_pVT->GetWordAscent(*pWord) - fMinY; - break; - case CPDF_VariableText::ScriptType::Sub: - pWord->fWordY = fPosY - m_pVT->GetWordDescent(*pWord) - fMinY; - break; - } - } else { - pWord->fWordY = fPosY - fMinY; - } + pWord->fWordY = fPosY - fMinY; + fPosX += m_pVT->GetWordWidth(*pWord); } } diff --git a/fpdfsdk/pwl/cpwl_edit_impl.h b/fpdfsdk/pwl/cpwl_edit_impl.h index b7dc0327c5..11edae6180 100644 --- a/fpdfsdk/pwl/cpwl_edit_impl.h +++ b/fpdfsdk/pwl/cpwl_edit_impl.h @@ -11,7 +11,8 @@ #include #include -#include "core/fpdfdoc/cpvt_wordprops.h" +#include "core/fpdfdoc/cpdf_variabletext.h" +#include "core/fpdfdoc/cpvt_wordrange.h" #include "core/fxcrt/unowned_ptr.h" #define FX_EDIT_ISLATINWORD(u) \ diff --git a/fpdfsdk/pwl/cpwl_list_box.h b/fpdfsdk/pwl/cpwl_list_box.h index 885969cc59..9a725d14e3 100644 --- a/fpdfsdk/pwl/cpwl_list_box.h +++ b/fpdfsdk/pwl/cpwl_list_box.h @@ -17,7 +17,6 @@ class CPWL_List_Notify; class CPWL_ListBox; class IPWL_Filler_Notify; struct CPVT_WordPlace; -struct CPVT_WordProps; class CPWL_List_Notify { public: -- cgit v1.2.3