summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfdoc/cpdf_variabletext.cpp22
-rw-r--r--core/fpdfdoc/csection.h9
-rw-r--r--core/fpdfdoc/ctypeset.h9
-rw-r--r--core/fpdfdoc/doc_vt.cpp6
-rw-r--r--core/fpdfdoc/include/cpdf_variabletext.h2
-rw-r--r--core/fpdfdoc/pdf_vt.h32
6 files changed, 33 insertions, 47 deletions
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index 3c71ed8786..118efa6a10 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -4,10 +4,11 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/fpdfdoc/include/cpdf_variabletext.h"
+
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
#include "core/fpdfdoc/cpvt_wordinfo.h"
#include "core/fpdfdoc/csection.h"
-#include "core/fpdfdoc/include/cpdf_variabletext.h"
#include "core/fpdfdoc/include/cpvt_section.h"
#include "core/fpdfdoc/include/cpvt_word.h"
#include "core/fpdfdoc/include/ipvt_fontmap.h"
@@ -70,11 +71,8 @@ int32_t CPDF_VariableText::Provider::GetWordFontIndex(uint16_t word,
}
FX_BOOL CPDF_VariableText::Provider::IsLatinWord(uint16_t word) {
- if ((word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) ||
- word == 0x2D || word == 0x27) {
- return TRUE;
- }
- return FALSE;
+ return (word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) ||
+ word == 0x2D || word == 0x27;
}
int32_t CPDF_VariableText::Provider::GetDefaultFontIndex() {
@@ -1051,22 +1049,20 @@ FX_FLOAT CPDF_VariableText::GetAutoFontSize() {
return (FX_FLOAT)gFontSizeSteps[nMid];
}
-FX_BOOL CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) {
- FX_BOOL bBigger = FALSE;
- CPVT_Size szTotal;
+bool CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) const {
+ CFX_SizeF szTotal;
for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) {
if (CSection* pSection = m_SectionArray.GetAt(s)) {
- CPVT_Size size = pSection->GetSectionSize(fFontSize);
+ CFX_SizeF size = pSection->GetSectionSize(fFontSize);
szTotal.x = std::max(size.x, szTotal.x);
szTotal.y += size.y;
if (IsFloatBigger(szTotal.x, GetPlateWidth()) ||
IsFloatBigger(szTotal.y, GetPlateHeight())) {
- bBigger = TRUE;
- break;
+ return true;
}
}
}
- return bBigger;
+ return false;
}
CPVT_FloatRect CPDF_VariableText::RearrangeSections(
diff --git a/core/fpdfdoc/csection.h b/core/fpdfdoc/csection.h
index d8974cb020..4ac345c8df 100644
--- a/core/fpdfdoc/csection.h
+++ b/core/fpdfdoc/csection.h
@@ -18,10 +18,11 @@ struct CPVT_LineInfo;
struct CPVT_WordLine;
struct CPVT_WordPlace;
-class CSection {
+class CSection final {
public:
explicit CSection(CPDF_VariableText* pVT);
- virtual ~CSection();
+ ~CSection();
+
void ResetAll();
void ResetLineArray();
void ResetWordArray();
@@ -32,7 +33,7 @@ class CSection {
void ClearWords(const CPVT_WordRange& PlaceRange);
void ClearWord(const CPVT_WordPlace& place);
CPVT_FloatRect Rearrange();
- CPVT_Size GetSectionSize(FX_FLOAT fFontSize);
+ CFX_SizeF GetSectionSize(FX_FLOAT fFontSize);
CPVT_WordPlace GetBeginWordPlace() const;
CPVT_WordPlace GetEndWordPlace() const;
CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const;
@@ -56,7 +57,7 @@ class CSection {
void ClearRightWords(int32_t nWordIndex);
void ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex);
- CPDF_VariableText* m_pVT;
+ CPDF_VariableText* const m_pVT;
};
#endif // CORE_FPDFDOC_CSECTION_H_
diff --git a/core/fpdfdoc/ctypeset.h b/core/fpdfdoc/ctypeset.h
index 25bb31a801..1ead422f6b 100644
--- a/core/fpdfdoc/ctypeset.h
+++ b/core/fpdfdoc/ctypeset.h
@@ -13,11 +13,12 @@
class CPDF_VariableText;
class CSection;
-class CTypeset {
+class CTypeset final {
public:
explicit CTypeset(CSection* pSection);
- virtual ~CTypeset();
- CPVT_Size GetEditSize(FX_FLOAT fFontSize);
+ ~CTypeset();
+
+ CFX_SizeF GetEditSize(FX_FLOAT fFontSize);
CPVT_FloatRect Typeset();
CPVT_FloatRect CharArray();
@@ -26,7 +27,7 @@ class CTypeset {
void OutputLines();
CPVT_FloatRect m_rcRet;
- CPDF_VariableText* m_pVT;
+ CPDF_VariableText* const m_pVT;
CSection* const m_pSection;
};
diff --git a/core/fpdfdoc/doc_vt.cpp b/core/fpdfdoc/doc_vt.cpp
index 88a4636bbc..7ca279b41b 100644
--- a/core/fpdfdoc/doc_vt.cpp
+++ b/core/fpdfdoc/doc_vt.cpp
@@ -82,7 +82,7 @@ CPVT_FloatRect CSection::Rearrange() {
}
return CTypeset(this).Typeset();
}
-CPVT_Size CSection::GetSectionSize(FX_FLOAT fFontSize) {
+CFX_SizeF CSection::GetSectionSize(FX_FLOAT fFontSize) {
return CTypeset(this).GetEditSize(fFontSize);
}
CPVT_WordPlace CSection::GetBeginWordPlace() const {
@@ -376,11 +376,11 @@ CPVT_FloatRect CTypeset::CharArray() {
}
return m_rcRet = CPVT_FloatRect(0, 0, x, y);
}
-CPVT_Size CTypeset::GetEditSize(FX_FLOAT fFontSize) {
+CFX_SizeF CTypeset::GetEditSize(FX_FLOAT fFontSize) {
ASSERT(m_pSection);
ASSERT(m_pVT);
SplitLines(FALSE, fFontSize);
- return CPVT_Size(m_rcRet.Width(), m_rcRet.Height());
+ return CFX_SizeF(m_rcRet.Width(), m_rcRet.Height());
}
CPVT_FloatRect CTypeset::Typeset() {
ASSERT(m_pVT);
diff --git a/core/fpdfdoc/include/cpdf_variabletext.h b/core/fpdfdoc/include/cpdf_variabletext.h
index c9184bc7c0..30bff84811 100644
--- a/core/fpdfdoc/include/cpdf_variabletext.h
+++ b/core/fpdfdoc/include/cpdf_variabletext.h
@@ -228,7 +228,7 @@ class CPDF_VariableText : private CPDF_EditContainer {
CPVT_FloatRect Rearrange(const CPVT_WordRange& PlaceRange);
FX_FLOAT GetAutoFontSize();
- FX_BOOL IsBigger(FX_FLOAT fFontSize);
+ bool IsBigger(FX_FLOAT fFontSize) const;
CPVT_FloatRect RearrangeSections(const CPVT_WordRange& PlaceRange);
void ResetSectionArray();
diff --git a/core/fpdfdoc/pdf_vt.h b/core/fpdfdoc/pdf_vt.h
index a3b7883a9b..9026eeee9e 100644
--- a/core/fpdfdoc/pdf_vt.h
+++ b/core/fpdfdoc/pdf_vt.h
@@ -20,22 +20,6 @@ struct CPVT_WordInfo;
#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
-class CPVT_Size {
- public:
- CPVT_Size() : x(0.0f), y(0.0f) {}
- CPVT_Size(FX_FLOAT other_x, FX_FLOAT other_y) {
- x = other_x;
- y = other_y;
- }
- FX_FLOAT x, y;
-};
-
-struct CPVT_FloatRange {
- CPVT_FloatRange() : fMin(0.0f), fMax(0.0f) {}
- CPVT_FloatRange(FX_FLOAT min, FX_FLOAT max) : fMin(min), fMax(max) {}
- FX_FLOAT Range() const { return fMax - fMin; }
- FX_FLOAT fMin, fMax;
-};
template <class TYPE>
class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE> {
public:
@@ -52,10 +36,11 @@ class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE> {
}
}
};
-class CLine {
+class CLine final {
public:
CLine();
- virtual ~CLine();
+ ~CLine();
+
CPVT_WordPlace GetBeginWordPlace() const;
CPVT_WordPlace GetEndWordPlace() const;
CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const;
@@ -63,10 +48,12 @@ class CLine {
CPVT_WordPlace LinePlace;
CPVT_LineInfo m_LineInfo;
};
-class CLines {
+
+class CLines final {
public:
CLines() : m_nTotal(0) {}
- virtual ~CLines() { RemoveAll(); }
+ ~CLines() { RemoveAll(); }
+
int32_t GetSize() const { return m_Lines.GetSize(); }
CLine* GetAt(int32_t nIndex) const { return m_Lines.GetAt(nIndex); }
void Empty() { m_nTotal = 0; }
@@ -103,6 +90,7 @@ class CPDF_EditContainer {
public:
CPDF_EditContainer() : m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {}
virtual ~CPDF_EditContainer() {}
+
virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; }
virtual const CFX_FloatRect& GetPlateRect() const { return m_rcPlate; }
virtual void SetContentRect(const CPVT_FloatRect& rect) {
@@ -111,8 +99,8 @@ class CPDF_EditContainer {
virtual CFX_FloatRect GetContentRect() const { return m_rcContent; }
FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; }
FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; }
- CPVT_Size GetPlateSize() const {
- return CPVT_Size(GetPlateWidth(), GetPlateHeight());
+ CFX_SizeF GetPlateSize() const {
+ return CFX_SizeF(GetPlateWidth(), GetPlateHeight());
}
CFX_FloatPoint GetBTPoint() const {
return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top);