summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-04 15:10:04 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-04 19:21:26 +0000
commit985e86f297e8319dbf3fd37247613f66e9f11216 (patch)
tree87a75673476fbf846a9eab9096e003638d8ea862 /core/fpdfapi
parent75a205f03fb755f4766ea674e470ff8de5d905b7 (diff)
downloadpdfium-985e86f297e8319dbf3fd37247613f66e9f11216.tar.xz
Remove friends from CPDF_TextObjectchromium/3233
This CL removes the friends from CPDF_TextObject and adds accessor methods as needed. Change-Id: I68d18297640b46113df79f58bea50b77dac89d39 Reviewed-on: https://pdfium-review.googlesource.com/15455 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp9
-rw-r--r--core/fpdfapi/page/cpdf_textobject.h10
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp30
4 files changed, 26 insertions, 25 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index fc7e97fc79..593680e7ff 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -388,7 +388,7 @@ void CPDF_PageContentGenerator::ProcessText(std::ostringstream* buf,
*buf << "/" << PDF_NameEncode(dictName) << " " << pTextObj->GetFontSize()
<< " Tf ";
ByteString text;
- for (uint32_t charcode : pTextObj->m_CharCodes) {
+ for (uint32_t charcode : pTextObj->GetCharCodes()) {
if (charcode != CPDF_Font::kInvalidCharCode)
pFont->AppendChar(&text, charcode);
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 47aa20938a..4ba1d2a44e 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -1262,10 +1262,11 @@ void CPDF_StreamContentParser::AddTextObject(ByteString* pStrs,
pCTM[3] = m_pCurStates->m_CTM.d;
}
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_TextPos.x,
- m_pCurStates->m_TextPos.y + m_pCurStates->m_TextRise))));
+ pText->SetPosition(
+ m_mtContentToUser.Transform(m_pCurStates->m_CTM.Transform(
+ m_pCurStates->m_TextMatrix.Transform(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);
diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h
index 5cffbd1434..02653dc2aa 100644
--- a/core/fpdfapi/page/cpdf_textobject.h
+++ b/core/fpdfapi/page/cpdf_textobject.h
@@ -48,20 +48,18 @@ class CPDF_TextObject : public CPDF_PageObject {
float GetFontSize() const;
void SetText(const ByteString& text);
+ void SetPosition(CFX_PointF pos) { m_Pos = pos; }
void SetPosition(float x, float y);
void RecalcPositionData();
- private:
- friend class CPDF_RenderStatus;
- friend class CPDF_StreamContentParser;
- friend class CPDF_TextRenderer;
- friend class CPDF_PageContentGenerator;
+ const std::vector<uint32_t>& GetCharCodes() const { return m_CharCodes; }
+ const std::vector<float>& GetCharPositions() const { return m_CharPos; }
void SetSegments(const ByteString* pStrs, const float* pKerning, int nSegs);
-
CFX_PointF CalcPositionData(float horz_scale);
+ private:
CFX_PointF m_Pos;
std::vector<uint32_t> m_CharCodes;
std::vector<float> m_CharPos;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index b49394993a..906143048d 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1590,7 +1590,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
CFX_Matrix text_matrix = textobj->GetTextMatrix();
CPDF_TextRenderer::DrawTextPath(
- &text_device, textobj->m_CharCodes, textobj->m_CharPos,
+ &text_device, textobj->GetCharCodes(), textobj->GetCharPositions(),
textobj->m_TextState.GetFont(), textobj->m_TextState.GetFontSize(),
&text_matrix, &new_matrix, textobj->m_GraphState.GetObject(),
(FX_ARGB)-1, 0, nullptr, 0);
@@ -1712,7 +1712,7 @@ void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const {
bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj,
const CFX_Matrix* pObj2Device,
CFX_PathData* pClippingPath) {
- if (textobj->m_CharCodes.empty())
+ if (textobj->GetCharCodes().empty())
return true;
const TextRenderingMode text_render_mode = textobj->m_TextState.GetTextMode();
@@ -1805,14 +1805,15 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj,
if (m_Options.m_Flags & RENDER_NOTEXTSMOOTH)
flag |= FXFILL_NOPATHSMOOTH;
return CPDF_TextRenderer::DrawTextPath(
- m_pDevice, textobj->m_CharCodes, textobj->m_CharPos, pFont, font_size,
- &text_matrix, pDeviceMatrix, textobj->m_GraphState.GetObject(),
- fill_argb, stroke_argb, pClippingPath, flag);
+ m_pDevice, textobj->GetCharCodes(), textobj->GetCharPositions(), pFont,
+ font_size, &text_matrix, pDeviceMatrix,
+ textobj->m_GraphState.GetObject(), fill_argb, stroke_argb,
+ pClippingPath, flag);
}
text_matrix.Concat(*pObj2Device);
- return CPDF_TextRenderer::DrawNormalText(m_pDevice, textobj->m_CharCodes,
- textobj->m_CharPos, pFont, font_size,
- &text_matrix, fill_argb, &m_Options);
+ return CPDF_TextRenderer::DrawNormalText(
+ m_pDevice, textobj->GetCharCodes(), textobj->GetCharPositions(), pFont,
+ font_size, &text_matrix, fill_argb, &m_Options);
}
RetainPtr<CPDF_Type3Cache> CPDF_RenderStatus::GetCachedType3(
@@ -1844,14 +1845,14 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
int device_class = m_pDevice->GetDeviceClass();
std::vector<FXTEXT_GLYPHPOS> glyphs;
if (device_class == FXDC_DISPLAY)
- glyphs.resize(textobj->m_CharCodes.size());
+ glyphs.resize(textobj->GetCharCodes().size());
else if (fill_alpha < 255)
return false;
CPDF_RefType3Cache refTypeCache(pType3Font);
- for (int iChar = 0; iChar < pdfium::CollectionSize<int>(textobj->m_CharCodes);
- iChar++) {
- uint32_t charcode = textobj->m_CharCodes[iChar];
+ for (int iChar = 0;
+ iChar < pdfium::CollectionSize<int>(textobj->GetCharCodes()); iChar++) {
+ uint32_t charcode = textobj->GetCharCodes()[iChar];
if (charcode == static_cast<uint32_t>(-1))
continue;
@@ -1860,7 +1861,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
continue;
CFX_Matrix matrix = char_matrix;
- matrix.e += iChar ? textobj->m_CharPos[iChar - 1] : 0;
+ matrix.e += iChar ? textobj->GetCharPositions()[iChar - 1] : 0;
matrix.Concat(text_matrix);
matrix.Concat(*pObj2Device);
if (!pType3Char->LoadBitmap(m_pContext.Get())) {
@@ -2014,7 +2015,8 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
return;
}
CPDF_CharPosList CharPosList;
- CharPosList.Load(textobj->m_CharCodes, textobj->m_CharPos, pFont, font_size);
+ CharPosList.Load(textobj->GetCharCodes(), textobj->GetCharPositions(), pFont,
+ font_size);
for (uint32_t i = 0; i < CharPosList.m_nChars; i++) {
FXTEXT_CHARPOS& charpos = CharPosList.m_pCharPos[i];
auto* font = charpos.m_FallbackFontPosition == -1