summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_streamcontentparser.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-02-21 17:18:27 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-21 22:59:45 +0000
commitc54c07eac0531b6d9fcd591c3e44c5e27817d076 (patch)
tree8bf27d5ec965a4a1e00cd9907d2b0b98022a49a8 /core/fpdfapi/page/cpdf_streamcontentparser.cpp
parent892d7510db7015b1835d8e057a716518881f126d (diff)
downloadpdfium-c54c07eac0531b6d9fcd591c3e44c5e27817d076.tar.xz
Convert text positions from x,y to CFX_PointF
This Cl converts the AllStates to use CFX_PointF and changes the advance code to return a CFX_PointF instead of accepting two out floats. Change-Id: Idb5e295b92e8a16ead535773de066f4b7ea2bdd9 Reviewed-on: https://pdfium-review.googlesource.com/2813 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_streamcontentparser.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp47
1 files changed, 18 insertions, 29 deletions
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 8015a8df45..b8c9c4c6af 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -675,10 +675,8 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
void CPDF_StreamContentParser::Handle_BeginText() {
m_pCurStates->m_TextMatrix = CFX_Matrix();
OnChangeTextMatrix();
- m_pCurStates->m_TextX = 0;
- m_pCurStates->m_TextY = 0;
- m_pCurStates->m_TextLineX = 0;
- m_pCurStates->m_TextLineY = 0;
+ m_pCurStates->m_TextPos = CFX_PointF();
+ m_pCurStates->m_TextLinePos = CFX_PointF();
}
void CPDF_StreamContentParser::Handle_CurveTo_123() {
@@ -1136,10 +1134,8 @@ void CPDF_StreamContentParser::Handle_SetCharSpace() {
}
void CPDF_StreamContentParser::Handle_MoveTextPoint() {
- m_pCurStates->m_TextLineX += GetNumber(1);
- m_pCurStates->m_TextLineY += GetNumber(0);
- m_pCurStates->m_TextX = m_pCurStates->m_TextLineX;
- m_pCurStates->m_TextY = m_pCurStates->m_TextLineY;
+ m_pCurStates->m_TextLinePos += CFX_PointF(GetNumber(1), GetNumber(0));
+ m_pCurStates->m_TextPos = m_pCurStates->m_TextLinePos;
}
void CPDF_StreamContentParser::Handle_MoveTextPoint_SetLeading() {
@@ -1239,12 +1235,12 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
}
if (fInitKerning != 0) {
if (!pFont->IsVertWriting()) {
- m_pCurStates->m_TextX -=
+ m_pCurStates->m_TextPos.x -=
(fInitKerning * m_pCurStates->m_TextState.GetFontSize() *
m_pCurStates->m_TextHorzScale) /
1000;
} else {
- m_pCurStates->m_TextY -=
+ m_pCurStates->m_TextPos.y -=
(fInitKerning * m_pCurStates->m_TextState.GetFontSize()) / 1000;
}
}
@@ -1268,15 +1264,11 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
pText->SetSegments(pStrs, pKerning, nsegs);
pText->m_Pos = m_mtContentToUser.Transform(
m_pCurStates->m_CTM.Transform(m_pCurStates->m_TextMatrix.Transform(
- CFX_PointF(m_pCurStates->m_TextX,
- m_pCurStates->m_TextY + m_pCurStates->m_TextRise))));
-
- FX_FLOAT x_advance;
- FX_FLOAT y_advance;
- pText->CalcPositionData(&x_advance, &y_advance,
- m_pCurStates->m_TextHorzScale);
- m_pCurStates->m_TextX += x_advance;
- m_pCurStates->m_TextY += y_advance;
+ CFX_PointF(m_pCurStates->m_TextPos.x,
+ m_pCurStates->m_TextPos.y + m_pCurStates->m_TextRise))));
+
+ m_pCurStates->m_TextPos +=
+ pText->CalcPositionData(m_pCurStates->m_TextHorzScale);
if (TextRenderingModeIsClipMode(text_mode)) {
m_ClipTextList.push_back(
std::unique_ptr<CPDF_TextObject>(pText->Clone()));
@@ -1285,12 +1277,12 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
}
if (pKerning && pKerning[nsegs - 1] != 0) {
if (!pFont->IsVertWriting()) {
- m_pCurStates->m_TextX -=
+ m_pCurStates->m_TextPos.x -=
(pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize() *
m_pCurStates->m_TextHorzScale) /
1000;
} else {
- m_pCurStates->m_TextY -=
+ m_pCurStates->m_TextPos.y -=
(pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize()) /
1000;
}
@@ -1318,7 +1310,7 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
}
if (nsegs == 0) {
for (size_t i = 0; i < n; i++) {
- m_pCurStates->m_TextX -=
+ m_pCurStates->m_TextPos.x -=
(pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize() *
m_pCurStates->m_TextHorzScale) /
1000;
@@ -1361,10 +1353,8 @@ void CPDF_StreamContentParser::Handle_SetTextMatrix() {
CFX_Matrix(GetNumber(5), GetNumber(4), GetNumber(3), GetNumber(2),
GetNumber(1), GetNumber(0));
OnChangeTextMatrix();
- m_pCurStates->m_TextX = 0;
- m_pCurStates->m_TextY = 0;
- m_pCurStates->m_TextLineX = 0;
- m_pCurStates->m_TextLineY = 0;
+ m_pCurStates->m_TextPos = CFX_PointF();
+ m_pCurStates->m_TextLinePos = CFX_PointF();
}
void CPDF_StreamContentParser::OnChangeTextMatrix() {
@@ -1403,9 +1393,8 @@ void CPDF_StreamContentParser::Handle_SetHorzScale() {
}
void CPDF_StreamContentParser::Handle_MoveToNextLine() {
- m_pCurStates->m_TextLineY -= m_pCurStates->m_TextLeading;
- m_pCurStates->m_TextX = m_pCurStates->m_TextLineX;
- m_pCurStates->m_TextY = m_pCurStates->m_TextLineY;
+ m_pCurStates->m_TextLinePos.y -= m_pCurStates->m_TextLeading;
+ m_pCurStates->m_TextPos = m_pCurStates->m_TextLinePos;
}
void CPDF_StreamContentParser::Handle_CurveTo_23() {