#include "core/fpdfdoc/cpvt_variabletext.h"
#include <algorithm>
#include <array>
#include <utility>
#include "core/fpdfapi/font/cpdf_font.h"
#include "core/fpdfdoc/cpvt_section.h"
#include "core/fpdfdoc/cpvt_word.h"
#include "core/fpdfdoc/cpvt_wordinfo.h"
#include "core/fpdfdoc/ipvt_fontmap.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/stl_util.h"
namespace {
constexpr float kFontScale = …;
constexpr uint8_t kReturnLength = …;
constexpr auto kFontSizeSteps = …;
}
CPVT_VariableText::Provider::Provider(IPVT_FontMap* pFontMap)
: … { … }
CPVT_VariableText::Provider::~Provider() = default;
int CPVT_VariableText::Provider::GetCharWidth(int32_t nFontIndex,
uint16_t word) { … }
int32_t CPVT_VariableText::Provider::GetTypeAscent(int32_t nFontIndex) { … }
int32_t CPVT_VariableText::Provider::GetTypeDescent(int32_t nFontIndex) { … }
int32_t CPVT_VariableText::Provider::GetWordFontIndex(uint16_t word,
FX_Charset charset,
int32_t nFontIndex) { … }
int32_t CPVT_VariableText::Provider::GetDefaultFontIndex() { … }
CPVT_VariableText::Iterator::Iterator(CPVT_VariableText* pVT) : … { … }
CPVT_VariableText::Iterator::~Iterator() = default;
void CPVT_VariableText::Iterator::SetAt(int32_t nWordIndex) { … }
void CPVT_VariableText::Iterator::SetAt(const CPVT_WordPlace& place) { … }
bool CPVT_VariableText::Iterator::NextWord() { … }
bool CPVT_VariableText::Iterator::NextLine() { … }
bool CPVT_VariableText::Iterator::GetWord(CPVT_Word& word) const { … }
bool CPVT_VariableText::Iterator::GetLine(CPVT_Line& line) const { … }
CPVT_VariableText::CPVT_VariableText(Provider* pProvider)
: … { … }
CPVT_VariableText::~CPVT_VariableText() = default;
void CPVT_VariableText::Initialize() { … }
CPVT_WordPlace CPVT_VariableText::InsertWord(const CPVT_WordPlace& place,
uint16_t word,
FX_Charset charset) { … }
CPVT_WordPlace CPVT_VariableText::InsertSection(const CPVT_WordPlace& place) { … }
CPVT_WordPlace CPVT_VariableText::DeleteWords(
const CPVT_WordRange& PlaceRange) { … }
CPVT_WordPlace CPVT_VariableText::DeleteWord(const CPVT_WordPlace& place) { … }
CPVT_WordPlace CPVT_VariableText::BackSpaceWord(const CPVT_WordPlace& place) { … }
void CPVT_VariableText::SetText(const WideString& swText) { … }
void CPVT_VariableText::UpdateWordPlace(CPVT_WordPlace& place) const { … }
int32_t CPVT_VariableText::WordPlaceToWordIndex(
const CPVT_WordPlace& place) const { … }
CPVT_WordPlace CPVT_VariableText::WordIndexToWordPlace(int32_t index) const { … }
CPVT_WordPlace CPVT_VariableText::GetBeginWordPlace() const { … }
CPVT_WordPlace CPVT_VariableText::GetEndWordPlace() const { … }
CPVT_WordPlace CPVT_VariableText::GetPrevWordPlace(
const CPVT_WordPlace& place) const { … }
CPVT_WordPlace CPVT_VariableText::GetNextWordPlace(
const CPVT_WordPlace& place) const { … }
CPVT_WordPlace CPVT_VariableText::SearchWordPlace(
const CFX_PointF& point) const { … }
CPVT_WordPlace CPVT_VariableText::GetUpWordPlace(
const CPVT_WordPlace& place,
const CFX_PointF& point) const { … }
CPVT_WordPlace CPVT_VariableText::GetDownWordPlace(
const CPVT_WordPlace& place,
const CFX_PointF& point) const { … }
CPVT_WordPlace CPVT_VariableText::GetLineBeginPlace(
const CPVT_WordPlace& place) const { … }
CPVT_WordPlace CPVT_VariableText::GetLineEndPlace(
const CPVT_WordPlace& place) const { … }
CPVT_WordPlace CPVT_VariableText::GetSectionBeginPlace(
const CPVT_WordPlace& place) const { … }
CPVT_WordPlace CPVT_VariableText::GetSectionEndPlace(
const CPVT_WordPlace& place) const { … }
int32_t CPVT_VariableText::GetTotalWords() const { … }
CPVT_WordPlace CPVT_VariableText::AddSection(const CPVT_WordPlace& place) { … }
CPVT_WordPlace CPVT_VariableText::AddLine(const CPVT_WordPlace& place,
const CPVT_LineInfo& lineinfo) { … }
CPVT_WordPlace CPVT_VariableText::AddWord(const CPVT_WordPlace& place,
const CPVT_WordInfo& wordinfo) { … }
void CPVT_VariableText::SetPlateRect(const CFX_FloatRect& rect) { … }
CFX_FloatRect CPVT_VariableText::GetContentRect() const { … }
const CFX_FloatRect& CPVT_VariableText::GetPlateRect() const { … }
float CPVT_VariableText::GetWordFontSize() const { … }
float CPVT_VariableText::GetWordWidth(int32_t nFontIndex,
uint16_t Word,
uint16_t SubWord,
float fFontSize,
float fWordTail) const { … }
float CPVT_VariableText::GetWordWidth(const CPVT_WordInfo& WordInfo) const { … }
float CPVT_VariableText::GetLineAscent() { … }
float CPVT_VariableText::GetLineDescent() { … }
float CPVT_VariableText::GetFontAscent(int32_t nFontIndex,
float fFontSize) const { … }
float CPVT_VariableText::GetFontDescent(int32_t nFontIndex,
float fFontSize) const { … }
float CPVT_VariableText::GetWordAscent(const CPVT_WordInfo& WordInfo,
float fFontSize) const { … }
float CPVT_VariableText::GetWordDescent(const CPVT_WordInfo& WordInfo,
float fFontSize) const { … }
float CPVT_VariableText::GetWordAscent(const CPVT_WordInfo& WordInfo) const { … }
float CPVT_VariableText::GetWordDescent(const CPVT_WordInfo& WordInfo) const { … }
float CPVT_VariableText::GetLineLeading() { … }
float CPVT_VariableText::GetLineIndent() { … }
void CPVT_VariableText::ClearSectionRightWords(const CPVT_WordPlace& place) { … }
CPVT_WordPlace CPVT_VariableText::PrevLineHeaderPlace(
const CPVT_WordPlace& place) const { … }
CPVT_WordPlace CPVT_VariableText::NextLineHeaderPlace(
const CPVT_WordPlace& place) const { … }
bool CPVT_VariableText::ClearEmptySection(const CPVT_WordPlace& place) { … }
void CPVT_VariableText::ClearEmptySections(const CPVT_WordRange& PlaceRange) { … }
void CPVT_VariableText::LinkLatterSection(const CPVT_WordPlace& place) { … }
void CPVT_VariableText::ClearWords(const CPVT_WordRange& PlaceRange) { … }
CPVT_WordPlace CPVT_VariableText::ClearLeftWord(const CPVT_WordPlace& place) { … }
CPVT_WordPlace CPVT_VariableText::ClearRightWord(const CPVT_WordPlace& place) { … }
void CPVT_VariableText::RearrangeAll() { … }
void CPVT_VariableText::RearrangePart(const CPVT_WordRange& PlaceRange) { … }
void CPVT_VariableText::Rearrange(const CPVT_WordRange& PlaceRange) { … }
float CPVT_VariableText::GetAutoFontSize() { … }
bool CPVT_VariableText::IsBigger(float fFontSize) const { … }
CPVT_FloatRect CPVT_VariableText::RearrangeSections(
const CPVT_WordRange& PlaceRange) { … }
int CPVT_VariableText::GetCharWidth(int32_t nFontIndex,
uint16_t Word,
uint16_t SubWord) const { … }
int32_t CPVT_VariableText::GetWordFontIndex(uint16_t word,
FX_Charset charset,
int32_t nFontIndex) { … }
int32_t CPVT_VariableText::GetDefaultFontIndex() { … }
CPVT_VariableText::Iterator* CPVT_VariableText::GetIterator() { … }
void CPVT_VariableText::SetProvider(Provider* pProvider) { … }
CFX_PointF CPVT_VariableText::GetBTPoint() const { … }
CFX_PointF CPVT_VariableText::GetETPoint() const { … }
CFX_PointF CPVT_VariableText::InToOut(const CFX_PointF& point) const { … }
CFX_PointF CPVT_VariableText::OutToIn(const CFX_PointF& point) const { … }
CFX_FloatRect CPVT_VariableText::InToOut(const CPVT_FloatRect& rect) const { … }