summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfapi/fpdf_pageobj.h153
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp176
2 files changed, 194 insertions, 135 deletions
diff --git a/core/include/fpdfapi/fpdf_pageobj.h b/core/include/fpdfapi/fpdf_pageobj.h
index 3414d36fbf..af186ad03b 100644
--- a/core/include/fpdfapi/fpdf_pageobj.h
+++ b/core/include/fpdfapi/fpdf_pageobj.h
@@ -31,13 +31,10 @@ class CPDF_ShadingObject;
class CPDF_FormObject;
class CPDF_InlineImages;
typedef CFX_PathData CPDF_PathData;
+
class CPDF_Path : public CFX_CountRef<CFX_PathData>
{
public:
-
-
-
-
int GetPointCount()
{
return m_pObject->m_PointCount;
@@ -435,7 +432,6 @@ public:
class CPDF_GraphicStates
{
public:
-
void CopyStates(const CPDF_GraphicStates& src);
void DefaultStates();
@@ -450,6 +446,7 @@ public:
CPDF_GeneralState m_GeneralState;
};
+
class CPDF_PageObject : public CPDF_GraphicStates
{
public:
@@ -460,9 +457,7 @@ public:
void Copy(const CPDF_PageObject* pSrcObject);
- virtual void Transform(const CFX_AffineMatrix& matrix) = 0;
-
-
+ virtual void Transform(const CFX_AffineMatrix& matrix) = 0;
void RemoveClipPath();
@@ -474,7 +469,6 @@ public:
void TransformGeneralState(CFX_AffineMatrix& matrix);
-
void SetColorState(CPDF_ColorState state)
{
m_ColorState = state;
@@ -493,91 +487,91 @@ public:
FX_FLOAT m_Bottom;
CPDF_ContentMark m_ContentMark;
-protected:
- virtual void CopyData(const CPDF_PageObject* pSrcObject) {}
+protected:
+ virtual void CopyData(const CPDF_PageObject* pSrcObject) = 0;
void RecalcBBox();
CPDF_PageObject() {}
};
-struct CPDF_TextObjectItem {
-
- FX_DWORD m_CharCode;
-
- FX_FLOAT m_OriginX;
- FX_FLOAT m_OriginY;
+struct CPDF_TextObjectItem {
+ FX_DWORD m_CharCode;
+ FX_FLOAT m_OriginX;
+ FX_FLOAT m_OriginY;
};
+
class CPDF_TextObject : public CPDF_PageObject
{
public:
-
CPDF_TextObject();
+ ~CPDF_TextObject() override;
- virtual ~CPDF_TextObject();
-
- int CountItems() const
+ int CountItems() const
{
return m_nChars;
}
- void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const;
-
- int CountChars() const;
+ void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const;
- void GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerning) const;
- void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const;
+ int CountChars() const;
- void GetCharRect(int index, CFX_FloatRect& rect) const;
+ void GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerning) const;
+ void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const;
+ void GetCharRect(int index, CFX_FloatRect& rect) const;
- FX_FLOAT GetCharWidth(FX_DWORD charcode) const;
- FX_FLOAT GetSpaceCharWidth() const;
+ FX_FLOAT GetCharWidth(FX_DWORD charcode) const;
+ FX_FLOAT GetSpaceCharWidth() const;
- FX_FLOAT GetPosX() const
+ FX_FLOAT GetPosX() const
{
return m_PosX;
}
- FX_FLOAT GetPosY() const
+ FX_FLOAT GetPosY() const
{
return m_PosY;
}
- void GetTextMatrix(CFX_AffineMatrix* pMatrix) const;
+ void GetTextMatrix(CFX_AffineMatrix* pMatrix) const;
- CPDF_Font* GetFont() const
+ CPDF_Font* GetFont() const
{
return m_TextState.GetFont();
}
- FX_FLOAT GetFontSize() const
+ FX_FLOAT GetFontSize() const
{
return m_TextState.GetFontSize();
}
- void SetEmpty();
-
- void SetText(const CFX_ByteString& text);
+ void SetEmpty();
- void SetText(CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);
+ void SetText(const CFX_ByteString& text);
- void SetText(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pKernings);
+ void SetText(CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);
- void SetPosition(FX_FLOAT x, FX_FLOAT y);
+ void SetText(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pKernings);
- void SetTextState(CPDF_TextState TextState);
- virtual void Transform(const CFX_AffineMatrix& matrix);
+ void SetPosition(FX_FLOAT x, FX_FLOAT y);
- void CalcCharPos(FX_FLOAT* pPosArray) const;
+ void SetTextState(CPDF_TextState TextState);
+ // CPDF_PageObject:
+ void Transform(const CFX_AffineMatrix& matrix) override;
+ void CalcCharPos(FX_FLOAT* pPosArray) const;
- void SetData(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos, FX_FLOAT x, FX_FLOAT y);
+ void SetData(int nChars,
+ FX_DWORD* pCharCodes,
+ FX_FLOAT* pCharPos,
+ FX_FLOAT x,
+ FX_FLOAT y);
- void GetData(int& nChars, FX_DWORD*& pCharCodes, FX_FLOAT*& pCharPos)
+ void GetData(int& nChars, FX_DWORD*& pCharCodes, FX_FLOAT*& pCharPos)
{
nChars = m_nChars;
pCharCodes = m_pCharCodes;
@@ -585,44 +579,49 @@ public:
}
- void RecalcPositionData()
+ void RecalcPositionData()
{
- CalcPositionData(NULL, NULL, 1);
+ CalcPositionData(nullptr, nullptr, 1);
}
+
protected:
- virtual void CopyData(const CPDF_PageObject* pSrcObject);
+ friend class CPDF_RenderStatus;
+ friend class CPDF_StreamContentParser;
+ friend class CPDF_TextRenderer;
+ friend class CTextPage;
- FX_FLOAT m_PosX;
+ // CPDF_PageObject:
+ void CopyData(const CPDF_PageObject* pSrcObject) override;
- FX_FLOAT m_PosY;
+ void SetSegments(const CFX_ByteString* pStrs,
+ FX_FLOAT* pKerning,
+ int nSegs);
- int m_nChars;
+ void CalcPositionData(FX_FLOAT* pTextAdvanceX,
+ FX_FLOAT* pTextAdvanceY,
+ FX_FLOAT horz_scale,
+ int level = 0);
- FX_DWORD* m_pCharCodes;
+ FX_FLOAT m_PosX;
+ FX_FLOAT m_PosY;
- FX_FLOAT* m_pCharPos;
+ int m_nChars;
- void SetSegments(const CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);
+ FX_DWORD* m_pCharCodes;
- void CalcPositionData(FX_FLOAT* pTextAdvanceX, FX_FLOAT* pTextAdvanceY, FX_FLOAT horz_scale, int level = 0);
- friend class CPDF_StreamContentParser;
- friend class CPDF_RenderStatus;
- friend class CPDF_QuickDrawer;
- friend class CPDF_TextRenderer;
- friend class CTextPage;
- friend class CPDF_ContentGenerator;
+ FX_FLOAT* m_pCharPos;
};
+
class CPDF_PathObject : public CPDF_PageObject
{
public:
-
CPDF_PathObject()
{
m_Type = PDFPAGE_PATH;
}
virtual ~CPDF_PathObject() {}
- virtual void Transform(const CFX_AffineMatrix& maxtrix);
+ void Transform(const CFX_AffineMatrix& maxtrix) override;
void SetGraphState(CPDF_GraphState GraphState);
@@ -636,30 +635,32 @@ public:
void CalcBoundingBox();
+
protected:
- virtual void CopyData(const CPDF_PageObject* pSrcObjet);
+ void CopyData(const CPDF_PageObject* pSrcObject) override;
};
+
class CPDF_ImageObject : public CPDF_PageObject
{
public:
-
CPDF_ImageObject();
virtual ~CPDF_ImageObject();
- virtual void Transform(const CFX_AffineMatrix& matrix);
+ void Transform(const CFX_AffineMatrix& matrix) override;
CPDF_Image* m_pImage;
CFX_AffineMatrix m_Matrix;
void CalcBoundingBox();
+
private:
- virtual void CopyData(const CPDF_PageObject* pSrcObjet);
+ void CopyData(const CPDF_PageObject* pSrcObject) override;
};
+
class CPDF_ShadingObject : public CPDF_PageObject
{
public:
-
CPDF_ShadingObject();
virtual ~CPDF_ShadingObject();
@@ -669,16 +670,17 @@ public:
CFX_AffineMatrix m_Matrix;
CPDF_Page* m_pPage;
- virtual void Transform(const CFX_AffineMatrix& matrix);
+ void Transform(const CFX_AffineMatrix& matrix) override;
void CalcBoundingBox();
+
protected:
- virtual void CopyData(const CPDF_PageObject* pSrcObjet);
+ void CopyData(const CPDF_PageObject* pSrcObject) override;
};
+
class CPDF_FormObject : public CPDF_PageObject
{
public:
-
CPDF_FormObject()
{
m_Type = PDFPAGE_FORM;
@@ -686,16 +688,18 @@ public:
}
virtual ~CPDF_FormObject();
- virtual void Transform(const CFX_AffineMatrix& matrix);
+ void Transform(const CFX_AffineMatrix& matrix) override;
CPDF_Form* m_pForm;
CFX_AffineMatrix m_FormMatrix;
void CalcBoundingBox();
+
protected:
- virtual void CopyData(const CPDF_PageObject* pSrcObjet);
+ void CopyData(const CPDF_PageObject* pSrcObject) override;
};
+
class CPDF_InlineImages : public CPDF_PageObject
{
public:
@@ -712,8 +716,7 @@ public:
void AddMatrix(CFX_AffineMatrix& matrix);
protected:
- virtual void Transform(const CFX_AffineMatrix& matrix) {}
- virtual void CopyData(const CPDF_PageObject* pSrcObjet) {}
+ void Transform(const CFX_AffineMatrix& matrix) override {}
};
#endif // CORE_INCLUDE_FPDFAPI_FPDF_PAGEOBJ_H_
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index 97b28574fc..85c785fd22 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -94,14 +94,17 @@ FX_RECT CPDF_PageObject::GetBBox(const CFX_AffineMatrix* pMatrix) const
}
return rect.GetOutterRect();
}
+
CPDF_TextObject::CPDF_TextObject()
+ : m_PosX(0),
+ m_PosY(0),
+ m_nChars(0),
+ m_pCharCodes(nullptr),
+ m_pCharPos(nullptr)
{
m_Type = PDFPAGE_TEXT;
- m_pCharCodes = NULL;
- m_pCharPos = NULL;
- m_nChars = 0;
- m_PosX = m_PosY = 0;
}
+
CPDF_TextObject::~CPDF_TextObject()
{
if (m_nChars > 1 && m_pCharCodes) {
@@ -111,9 +114,11 @@ CPDF_TextObject::~CPDF_TextObject()
FX_Free(m_pCharPos);
}
}
+
void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const
{
- pInfo->m_CharCode = m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[index];
+ pInfo->m_CharCode =
+ m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[index];
pInfo->m_OriginX = index ? m_pCharPos[index - 1] : 0;
pInfo->m_OriginY = 0;
if (pInfo->m_CharCode == -1) {
@@ -135,19 +140,23 @@ void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const
pInfo->m_OriginX -= fontsize * vx / 1000;
pInfo->m_OriginY -= fontsize * vy / 1000;
}
+
int CPDF_TextObject::CountChars() const
{
if (m_nChars == 1) {
return 1;
}
int count = 0;
- for (int i = 0; i < m_nChars; i ++)
+ for (int i = 0; i < m_nChars; ++i)
if (m_pCharCodes[i] != (FX_DWORD) - 1) {
- count ++;
+ ++count;
}
return count;
}
-void CPDF_TextObject::GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerning) const
+
+void CPDF_TextObject::GetCharInfo(int index,
+ FX_DWORD& charcode,
+ FX_FLOAT& kerning) const
{
if (m_nChars == 1) {
charcode = (FX_DWORD)(uintptr_t)m_pCharCodes;
@@ -155,21 +164,23 @@ void CPDF_TextObject::GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerni
return;
}
int count = 0;
- for (int i = 0; i < m_nChars; i ++) {
+ for (int i = 0; i < m_nChars; ++i) {
if (m_pCharCodes[i] != (FX_DWORD) - 1) {
if (count == index) {
charcode = m_pCharCodes[i];
- if (i == m_nChars - 1 || m_pCharCodes[i + 1] != (FX_DWORD) - 1) {
+ if (i == m_nChars - 1 ||
+ m_pCharCodes[i + 1] != (FX_DWORD) - 1) {
kerning = 0;
} else {
kerning = m_pCharPos[i];
}
return;
}
- count ++;
+ ++count;
}
}
}
+
void CPDF_TextObject::GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const
{
if (m_nChars == 1) {
@@ -177,7 +188,7 @@ void CPDF_TextObject::GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const
return;
}
int count = 0;
- for (int i = 0; i < m_nChars; i ++) {
+ for (int i = 0; i < m_nChars; ++i) {
FX_DWORD charcode = m_pCharCodes[i];
if (charcode == (FX_DWORD) - 1) {
continue;
@@ -186,28 +197,29 @@ void CPDF_TextObject::GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const
GetItemInfo(i, pInfo);
break;
}
- count ++;
+ ++count;
}
}
+
void CPDF_TextObject::CopyData(const CPDF_PageObject* pSrc)
{
const CPDF_TextObject* pSrcObj = (const CPDF_TextObject*)pSrc;
if (m_nChars > 1 && m_pCharCodes) {
FX_Free(m_pCharCodes);
- m_pCharCodes = NULL;
+ m_pCharCodes = nullptr;
}
if (m_pCharPos) {
FX_Free(m_pCharPos);
- m_pCharPos = NULL;
+ m_pCharPos = nullptr;
}
m_nChars = pSrcObj->m_nChars;
if (m_nChars > 1) {
m_pCharCodes = FX_Alloc(FX_DWORD, m_nChars);
m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1);
- for (int i = 0; i < m_nChars; i ++) {
+ for (int i = 0; i < m_nChars; ++i) {
m_pCharCodes[i] = pSrcObj->m_pCharCodes[i];
}
- for (int i = 0; i < m_nChars - 1; i ++) {
+ for (int i = 0; i < m_nChars - 1; ++i) {
m_pCharPos[i] = pSrcObj->m_pCharPos[i];
}
} else {
@@ -216,24 +228,33 @@ void CPDF_TextObject::CopyData(const CPDF_PageObject* pSrc)
m_PosX = pSrcObj->m_PosX;
m_PosY = pSrcObj->m_PosY;
}
+
void CPDF_TextObject::GetTextMatrix(CFX_AffineMatrix* pMatrix) const
{
FX_FLOAT* pTextMatrix = m_TextState.GetMatrix();
- pMatrix->Set(pTextMatrix[0], pTextMatrix[2], pTextMatrix[1], pTextMatrix[3], m_PosX, m_PosY);
+ pMatrix->Set(pTextMatrix[0],
+ pTextMatrix[2],
+ pTextMatrix[1],
+ pTextMatrix[3],
+ m_PosX,
+ m_PosY);
}
-void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nsegs)
+
+void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs,
+ FX_FLOAT* pKerning,
+ int nsegs)
{
if (m_nChars > 1 && m_pCharCodes) {
FX_Free(m_pCharCodes);
- m_pCharCodes = NULL;
+ m_pCharCodes = nullptr;
}
if (m_pCharPos) {
FX_Free(m_pCharPos);
- m_pCharPos = NULL;
+ m_pCharPos = nullptr;
}
CPDF_Font* pFont = m_TextState.GetFont();
m_nChars = 0;
- for (int i = 0; i < nsegs; i ++) {
+ for (int i = 0; i < nsegs; ++i) {
m_nChars += pFont->CountChar(pStrs[i], pStrs[i].GetLength());
}
m_nChars += nsegs - 1;
@@ -241,27 +262,33 @@ void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs, FX_FLOAT* pKernin
m_pCharCodes = FX_Alloc(FX_DWORD, m_nChars);
m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1);
int index = 0;
- for (int i = 0; i < nsegs; i ++) {
+ for (int i = 0; i < nsegs; ++i) {
const FX_CHAR* segment = pStrs[i];
int offset = 0, len = pStrs[i].GetLength();
while (offset < len) {
- m_pCharCodes[index++] = pFont->GetNextChar(segment, len, offset);
+ m_pCharCodes[index++] =
+ pFont->GetNextChar(segment, len, offset);
}
if (i != nsegs - 1) {
m_pCharPos[index - 1] = pKerning[i];
- m_pCharCodes[index ++] = (FX_DWORD) - 1;
+ m_pCharCodes[index++] = (FX_DWORD) - 1;
}
}
} else {
int offset = 0;
- m_pCharCodes = (FX_DWORD*)(uintptr_t)pFont->GetNextChar(pStrs[0], pStrs[0].GetLength(), offset);
+ m_pCharCodes =
+ (FX_DWORD*)(uintptr_t)pFont->GetNextChar(pStrs[0],
+ pStrs[0].GetLength(),
+ offset);
}
}
+
void CPDF_TextObject::SetText(const CFX_ByteString& str)
{
- SetSegments(&str, NULL, 1);
+ SetSegments(&str, nullptr, 1);
RecalcPositionData();
}
+
void CPDF_TextObject::SetEmpty()
{
if (m_nChars > 1 && m_pCharCodes) {
@@ -271,43 +298,49 @@ void CPDF_TextObject::SetEmpty()
FX_Free(m_pCharPos);
}
m_nChars = 0;
- m_pCharCodes = NULL;
- m_pCharPos = NULL;
+ m_pCharCodes = nullptr;
+ m_pCharPos = nullptr;
m_Left = m_Right = m_PosX;
m_Top = m_Bottom = m_PosY;
}
-void CPDF_TextObject::SetText(CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs)
+
+void CPDF_TextObject::SetText(CFX_ByteString* pStrs,
+ FX_FLOAT* pKerning,
+ int nSegs)
{
SetSegments(pStrs, pKerning, nSegs);
RecalcPositionData();
}
-void CPDF_TextObject::SetText(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pKernings)
+
+void CPDF_TextObject::SetText(int nChars,
+ FX_DWORD* pCharCodes,
+ FX_FLOAT* pKernings)
{
if (m_nChars > 1 && m_pCharCodes) {
FX_Free(m_pCharCodes);
- m_pCharCodes = NULL;
+ m_pCharCodes = nullptr;
}
if (m_pCharPos) {
FX_Free(m_pCharPos);
- m_pCharPos = NULL;
+ m_pCharPos = nullptr;
}
int nKernings = 0;
int i;
- for (i = 0; i < nChars - 1; i ++)
+ for (i = 0; i < nChars - 1; ++i) {
if (pKernings[i] != 0) {
- nKernings ++;
+ ++nKernings;
}
+ }
m_nChars = nChars + nKernings;
if (m_nChars > 1) {
m_pCharCodes = FX_Alloc(FX_DWORD, m_nChars);
m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1);
- int index = 0;
- for (int i = 0; i < nChars; i ++) {
+ for (int i = 0, index = 0; i < nChars; ++i) {
m_pCharCodes[index++] = pCharCodes[i];
if (pKernings[i] != 0 && i != nChars - 1) {
m_pCharCodes[index] = (FX_DWORD) - 1;
m_pCharPos[index - 1] = pKernings[i];
- index ++;
+ ++index;
}
}
} else {
@@ -315,6 +348,7 @@ void CPDF_TextObject::SetText(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pKerni
}
RecalcPositionData();
}
+
FX_FLOAT CPDF_TextObject::GetCharWidth(FX_DWORD charcode) const
{
FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000;
@@ -324,13 +358,13 @@ FX_FLOAT CPDF_TextObject::GetCharWidth(FX_DWORD charcode) const
if (pCIDFont) {
bVertWriting = pCIDFont->IsVertWriting();
}
- if (!bVertWriting) {
+ if (!bVertWriting)
return pFont->GetCharWidthF(charcode, 0) * fontsize;
- } else {
- FX_WORD CID = pCIDFont->CIDFromCharCode(charcode);
- return pCIDFont->GetVertWidth(CID) * fontsize;
- }
+
+ FX_WORD CID = pCIDFont->CIDFromCharCode(charcode);
+ return pCIDFont->GetVertWidth(CID) * fontsize;
}
+
FX_FLOAT CPDF_TextObject::GetSpaceCharWidth() const
{
CPDF_Font* pFont = m_TextState.GetFont();
@@ -346,9 +380,11 @@ FX_FLOAT CPDF_TextObject::GetSpaceCharWidth() const
}
FX_RECT fontRect;
pFont->GetFontBBox(fontRect);
- fontSize *= bVertWriting ? (FX_FLOAT)fontRect.Height() : (FX_FLOAT)fontRect.Width();
+ fontSize *= bVertWriting ?
+ (FX_FLOAT)fontRect.Height() : (FX_FLOAT)fontRect.Width();
return fontSize;
}
+
void CPDF_TextObject::GetCharRect(int index, CFX_FloatRect& rect) const
{
CPDF_Font* pFont = m_TextState.GetFont();
@@ -359,13 +395,14 @@ void CPDF_TextObject::GetCharRect(int index, CFX_FloatRect& rect) const
}
FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000;
int count = 0;
- for (int i = 0; i < m_nChars; i ++) {
- FX_DWORD charcode = m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
+ for (int i = 0; i < m_nChars; ++i) {
+ FX_DWORD charcode = m_nChars == 1 ?
+ (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
if (charcode == (FX_DWORD) - 1) {
continue;
}
- if( count != index) {
- count++;
+ if (count != index) {
+ ++count;
continue;
}
FX_FLOAT curpos = i > 0 ? m_pCharPos[i - 1] : 0;
@@ -392,10 +429,17 @@ void CPDF_TextObject::GetCharRect(int index, CFX_FloatRect& rect) const
return;
}
}
-void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, FX_FLOAT* pTextAdvanceY, FX_FLOAT horz_scale, int level)
+
+void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX,
+ FX_FLOAT* pTextAdvanceY,
+ FX_FLOAT horz_scale,
+ int level)
{
FX_FLOAT curpos = 0;
- FX_FLOAT min_x = 10000 * 1.0f, max_x = -10000 * 1.0f, min_y = 10000 * 1.0f, max_y = -10000 * 1.0f;
+ FX_FLOAT min_x = 10000 * 1.0f;
+ FX_FLOAT max_x = -10000 * 1.0f;
+ FX_FLOAT min_y = 10000 * 1.0f;
+ FX_FLOAT max_y = -10000 * 1.0f;
CPDF_Font* pFont = m_TextState.GetFont();
FX_BOOL bVertWriting = FALSE;
CPDF_CIDFont* pCIDFont = pFont->GetCIDFont();
@@ -403,8 +447,9 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, FX_FLOAT* pTextA
bVertWriting = pCIDFont->IsVertWriting();
}
FX_FLOAT fontsize = m_TextState.GetFontSize();
- for (int i = 0; i < m_nChars; i ++) {
- FX_DWORD charcode = m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
+ for (int i = 0; i < m_nChars; ++i) {
+ FX_DWORD charcode = m_nChars == 1 ?
+ (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
if (charcode == (FX_DWORD) - 1) {
curpos -= FXSYS_Mul(m_pCharPos[i - 1], fontsize) / 1000;
continue;
@@ -445,7 +490,8 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, FX_FLOAT* pTextA
charwidth = pFont->GetCharWidthF(charcode, level) * fontsize / 1000;
} else {
FX_WORD CID = pCIDFont->CIDFromCharCode(charcode);
- short vx, vy;
+ short vx;
+ short vy;
pCIDFont->GetVertOrigin(CID, vx, vy);
char_rect.left -= vx;
char_rect.right -= vx;
@@ -480,7 +526,7 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, FX_FLOAT* pTextA
charwidth = pCIDFont->GetVertWidth(CID) * fontsize / 1000;
}
curpos += charwidth;
- if (charcode == ' ' && (pCIDFont == NULL || pCIDFont->GetCharSize(32) == 1)) {
+ if (charcode == ' ' && (!pCIDFont || pCIDFont->GetCharSize(32) == 1)) {
curpos += m_TextState.GetObject()->m_WordSpace;
}
curpos += m_TextState.GetObject()->m_CharSpace;
@@ -520,6 +566,7 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, FX_FLOAT* pTextA
m_Bottom -= half_width;
}
}
+
void CPDF_TextObject::CalcCharPos(FX_FLOAT* pPosArray) const
{
CPDF_Font* pFont = m_TextState.GetFont();
@@ -529,9 +576,9 @@ void CPDF_TextObject::CalcCharPos(FX_FLOAT* pPosArray) const
bVertWriting = pCIDFont->IsVertWriting();
}
FX_FLOAT fontsize = m_TextState.GetFontSize();
- int index = 0;
- for (int i = 0; i < m_nChars; i ++) {
- FX_DWORD charcode = m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
+ for (int i = 0, index = 0; i < m_nChars; ++i) {
+ FX_DWORD charcode = m_nChars == 1 ?
+ (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
if (charcode == (FX_DWORD) - 1) {
continue;
}
@@ -547,6 +594,7 @@ void CPDF_TextObject::CalcCharPos(FX_FLOAT* pPosArray) const
index++;
}
}
+
void CPDF_TextObject::Transform(const CFX_AffineMatrix& matrix)
{
m_TextState.GetModify();
@@ -560,8 +608,9 @@ void CPDF_TextObject::Transform(const CFX_AffineMatrix& matrix)
pTextMatrix[3] = text_matrix.GetD();
m_PosX = text_matrix.GetE();
m_PosY = text_matrix.GetF();
- CalcPositionData(NULL, NULL, 0);
+ CalcPositionData(nullptr, nullptr, 0);
}
+
void CPDF_TextObject::SetPosition(FX_FLOAT x, FX_FLOAT y)
{
FX_FLOAT dx = x - m_PosX;
@@ -573,7 +622,12 @@ void CPDF_TextObject::SetPosition(FX_FLOAT x, FX_FLOAT y)
m_Top += dy;
m_Bottom += dy;
}
-void CPDF_TextObject::SetData(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos, FX_FLOAT x, FX_FLOAT y)
+
+void CPDF_TextObject::SetData(int nChars,
+ FX_DWORD* pCharCodes,
+ FX_FLOAT* pCharPos,
+ FX_FLOAT x,
+ FX_FLOAT y)
{
ASSERT(m_nChars == 0);
m_nChars = nChars;
@@ -592,11 +646,13 @@ void CPDF_TextObject::SetData(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharP
}
RecalcPositionData();
}
+
void CPDF_TextObject::SetTextState(CPDF_TextState TextState)
{
m_TextState = TextState;
- CalcPositionData(NULL, NULL, 0);
+ CalcPositionData(nullptr, nullptr, 0);
}
+
CPDF_ShadingObject::CPDF_ShadingObject()
{
m_pShading = NULL;