diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-02-13 15:44:23 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-13 22:09:20 +0000 |
commit | 4797c4240cb9e2d8cd36c583d46cd52ff94af95d (patch) | |
tree | 0c7e856a1c82812fcc3fa038e07ff4f22e424130 /core/fpdfdoc | |
parent | 58e4c5ac24a88f83d1ba8277dee87baf4cba36a0 (diff) | |
download | pdfium-4797c4240cb9e2d8cd36c583d46cd52ff94af95d.tar.xz |
Convert CFX_FloatPoint to CFX_PointF
The two classes store the same information, remove the CFX_FloatPoint variant.
Change-Id: Ie598c2ba5af04fb2bb3347dd48c30fd5e4845e62
Reviewed-on: https://pdfium-review.googlesource.com/2612
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r-- | core/fpdfdoc/cpdf_variabletext.cpp | 48 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_variabletext.h | 18 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_generateap.cpp | 37 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_generateap.h | 2 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_line.h | 10 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_lineinfo.h | 23 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_word.h | 5 | ||||
-rw-r--r-- | core/fpdfdoc/csection.cpp | 2 | ||||
-rw-r--r-- | core/fpdfdoc/csection.h | 5 |
9 files changed, 77 insertions, 73 deletions
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index 546bd9f740..94b3425a09 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -172,8 +172,8 @@ bool CPDF_VariableText::Iterator::GetWord(CPVT_Word& word) const { word.nCharset = pWord->nCharset; word.fWidth = m_pVT->GetWordWidth(*pWord); word.ptWord = m_pVT->InToOut( - CFX_FloatPoint(pWord->fWordX + pSection->m_SecInfo.rcSection.left, - pWord->fWordY + pSection->m_SecInfo.rcSection.top)); + CFX_PointF(pWord->fWordX + pSection->m_SecInfo.rcSection.left, + pWord->fWordY + pSection->m_SecInfo.rcSection.top)); word.fAscent = m_pVT->GetWordAscent(*pWord); word.fDescent = m_pVT->GetWordDescent(*pWord); if (pWord->pWordProps) @@ -205,7 +205,7 @@ bool CPDF_VariableText::Iterator::GetLine(CPVT_Line& line) const { line.lineplace = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex, -1); if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { if (CLine* pLine = pSection->m_LineArray.GetAt(m_CurPos.nLineIndex)) { - line.ptLine = m_pVT->InToOut(CFX_FloatPoint( + line.ptLine = m_pVT->InToOut(CFX_PointF( pLine->m_LineInfo.fLineX + pSection->m_SecInfo.rcSection.left, pLine->m_LineInfo.fLineY + pSection->m_SecInfo.rcSection.top)); line.fLineWidth = pLine->m_LineInfo.fLineWidth; @@ -548,8 +548,8 @@ CPVT_WordPlace CPDF_VariableText::GetNextWordPlace( } CPVT_WordPlace CPDF_VariableText::SearchWordPlace( - const CFX_FloatPoint& point) const { - CFX_FloatPoint pt = OutToIn(point); + const CFX_PointF& point) const { + CFX_PointF pt = OutToIn(point); CPVT_WordPlace place = GetBeginWordPlace(); int32_t nLeft = 0; int32_t nRight = m_SectionArray.GetSize() - 1; @@ -574,8 +574,8 @@ CPVT_WordPlace CPDF_VariableText::SearchWordPlace( continue; } else { place = pSection->SearchWordPlace( - CFX_FloatPoint(pt.x - pSection->m_SecInfo.rcSection.left, - pt.y - pSection->m_SecInfo.rcSection.top)); + CFX_PointF(pt.x - pSection->m_SecInfo.rcSection.left, + pt.y - pSection->m_SecInfo.rcSection.top)); place.nSecIndex = nMid; return place; } @@ -592,10 +592,10 @@ CPVT_WordPlace CPDF_VariableText::SearchWordPlace( CPVT_WordPlace CPDF_VariableText::GetUpWordPlace( const CPVT_WordPlace& place, - const CFX_FloatPoint& point) const { + const CFX_PointF& point) const { if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { CPVT_WordPlace temp = place; - CFX_FloatPoint pt = OutToIn(point); + CFX_PointF pt = OutToIn(point); if (temp.nLineIndex-- > 0) { return pSection->SearchWordPlace( pt.x - pSection->m_SecInfo.rcSection.left, temp); @@ -613,10 +613,10 @@ CPVT_WordPlace CPDF_VariableText::GetUpWordPlace( CPVT_WordPlace CPDF_VariableText::GetDownWordPlace( const CPVT_WordPlace& place, - const CFX_FloatPoint& point) const { + const CFX_PointF& point) const { if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { CPVT_WordPlace temp = place; - CFX_FloatPoint pt = OutToIn(point); + CFX_PointF pt = OutToIn(point); if (temp.nLineIndex++ < pSection->m_LineArray.GetSize() - 1) { return pSection->SearchWordPlace( pt.x - pSection->m_SecInfo.rcSection.left, temp); @@ -1109,34 +1109,32 @@ CFX_SizeF CPDF_VariableText::GetPlateSize() const { return CFX_SizeF(GetPlateWidth(), GetPlateHeight()); } -CFX_FloatPoint CPDF_VariableText::GetBTPoint() const { - return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); +CFX_PointF CPDF_VariableText::GetBTPoint() const { + return CFX_PointF(m_rcPlate.left, m_rcPlate.top); } -CFX_FloatPoint CPDF_VariableText::GetETPoint() const { - return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom); +CFX_PointF CPDF_VariableText::GetETPoint() const { + return CFX_PointF(m_rcPlate.right, m_rcPlate.bottom); } -CFX_FloatPoint CPDF_VariableText::InToOut(const CFX_FloatPoint& point) const { - return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y); +CFX_PointF CPDF_VariableText::InToOut(const CFX_PointF& point) const { + return CFX_PointF(point.x + GetBTPoint().x, GetBTPoint().y - point.y); } -CFX_FloatPoint CPDF_VariableText::OutToIn(const CFX_FloatPoint& point) const { - return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y); +CFX_PointF CPDF_VariableText::OutToIn(const CFX_PointF& point) const { + return CFX_PointF(point.x - GetBTPoint().x, GetBTPoint().y - point.y); } CFX_FloatRect CPDF_VariableText::InToOut(const CPVT_FloatRect& rect) const { - CFX_FloatPoint ptLeftTop = InToOut(CFX_FloatPoint(rect.left, rect.top)); - CFX_FloatPoint ptRightBottom = - InToOut(CFX_FloatPoint(rect.right, rect.bottom)); + CFX_PointF ptLeftTop = InToOut(CFX_PointF(rect.left, rect.top)); + CFX_PointF ptRightBottom = InToOut(CFX_PointF(rect.right, rect.bottom)); return CFX_FloatRect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, ptLeftTop.y); } CPVT_FloatRect CPDF_VariableText::OutToIn(const CFX_FloatRect& rect) const { - CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); - CFX_FloatPoint ptRightBottom = - OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); + CFX_PointF ptLeftTop = OutToIn(CFX_PointF(rect.left, rect.top)); + CFX_PointF ptRightBottom = OutToIn(CFX_PointF(rect.right, rect.bottom)); return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, ptRightBottom.y); } diff --git a/core/fpdfdoc/cpdf_variabletext.h b/core/fpdfdoc/cpdf_variabletext.h index 5983a2978b..8e7c0c964a 100644 --- a/core/fpdfdoc/cpdf_variabletext.h +++ b/core/fpdfdoc/cpdf_variabletext.h @@ -20,13 +20,13 @@ #include "core/fxcrt/fx_system.h" #include "core/fxge/fx_font.h" +class CPVT_Word; class CSection; class IPVT_FontMap; - struct CPVT_SecProps; struct CPVT_Section; struct CPVT_SectionInfo; -struct CPVT_Word; + struct CPVT_WordInfo; struct CPVT_WordProps; @@ -132,11 +132,11 @@ class CPDF_VariableText { CPVT_WordPlace GetEndWordPlace() const; CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; - CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const; + CPVT_WordPlace SearchWordPlace(const CFX_PointF& point) const; CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace& place, - const CFX_FloatPoint& point) const; + const CFX_PointF& point) const; CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace& place, - const CFX_FloatPoint& point) const; + const CFX_PointF& point) const; CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const; CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const; CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace& place) const; @@ -152,11 +152,11 @@ class CPDF_VariableText { FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; } FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; } CFX_SizeF GetPlateSize() const; - CFX_FloatPoint GetBTPoint() const; - CFX_FloatPoint GetETPoint() const; + CFX_PointF GetBTPoint() const; + CFX_PointF GetETPoint() const; - CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const; - CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const; + CFX_PointF InToOut(const CFX_PointF& point) const; + CFX_PointF OutToIn(const CFX_PointF& point) const; CFX_FloatRect InToOut(const CPVT_FloatRect& rect) const; CPVT_FloatRect OutToIn(const CFX_FloatRect& rect) const; diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index 4bb244f29e..15515151bc 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -246,10 +246,10 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, vt.SetText(swValue); vt.RearrangeAll(); CFX_FloatRect rcContent = vt.GetContentRect(); - CFX_FloatPoint ptOffset; + CFX_PointF ptOffset; if (!bMultiLine) { ptOffset = - CFX_FloatPoint(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f); + CFX_PointF(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f); } CFX_ByteString sBody = CPVT_GenerateAP::GenerateEditAP( &map, vt.GetIterator(), ptOffset, !bCharArray, subWord); @@ -296,8 +296,8 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, vt.SetText(swValue); vt.RearrangeAll(); CFX_FloatRect rcContent = vt.GetContentRect(); - CFX_FloatPoint ptOffset = - CFX_FloatPoint(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); + CFX_PointF ptOffset = + CFX_PointF(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP( &map, vt.GetIterator(), ptOffset, true, 0); if (sEdit.GetLength() > 0) { @@ -328,9 +328,8 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, if (sButtonBorder.GetLength() > 0) sAppStream << "q\n" << sButtonBorder << "Q\n"; - CFX_FloatPoint ptCenter = - CFX_FloatPoint((rcButton.left + rcButton.right) / 2, - (rcButton.top + rcButton.bottom) / 2); + CFX_PointF ptCenter = CFX_PointF((rcButton.left + rcButton.right) / 2, + (rcButton.top + rcButton.bottom) / 2); if (IsFloatBigger(rcButton.Width(), 6) && IsFloatBigger(rcButton.Height(), 6)) { sAppStream << "q\n" @@ -402,7 +401,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, CPVT_Color(CPVT_Color::kGray, 1), PaintOperation::FILL) << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), - CFX_FloatPoint(0.0f, fy), + CFX_PointF(0.0f, fy), true, 0) << "ET\n"; } else { @@ -410,7 +409,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, << CPVT_GenerateAP::GenerateColorAP(crText, PaintOperation::FILL) << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), - CFX_FloatPoint(0.0f, fy), + CFX_PointF(0.0f, fy), true, 0) << "ET\n"; } @@ -529,7 +528,7 @@ CFX_ByteString GetPopupContentsString(CPDF_Document* pDoc, vt.Initialize(); vt.SetText(swValue); vt.RearrangeAll(); - CFX_FloatPoint ptOffset(3.0f, -3.0f); + CFX_PointF ptOffset(3.0f, -3.0f); CFX_ByteString sContent = CPVT_GenerateAP::GenerateEditAP( &map, vt.GetIterator(), ptOffset, false, 0); @@ -1102,14 +1101,14 @@ bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, CFX_ByteString CPVT_GenerateAP::GenerateEditAP( IPVT_FontMap* pFontMap, CPDF_VariableText::Iterator* pIterator, - const CFX_FloatPoint& ptOffset, + const CFX_PointF& ptOffset, bool bContinuous, uint16_t SubWord) { CFX_ByteTextBuf sEditStream; CFX_ByteTextBuf sLineStream; CFX_ByteTextBuf sWords; - CFX_FloatPoint ptOld; - CFX_FloatPoint ptNew; + CFX_PointF ptOld; + CFX_PointF ptNew; int32_t nCurFontIndex = -1; CPVT_WordPlace oldplace; @@ -1126,13 +1125,13 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( } CPVT_Word word; if (pIterator->GetWord(word)) { - ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x, - word.ptWord.y + ptOffset.y); + ptNew = CFX_PointF(word.ptWord.x + ptOffset.x, + word.ptWord.y + ptOffset.y); } else { CPVT_Line line; pIterator->GetLine(line); - ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x, - line.ptLine.y + ptOffset.y); + ptNew = CFX_PointF(line.ptLine.x + ptOffset.x, + line.ptLine.y + ptOffset.y); } if (ptNew != ptOld) { sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y @@ -1157,8 +1156,8 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( } else { CPVT_Word word; if (pIterator->GetWord(word)) { - ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x, - word.ptWord.y + ptOffset.y); + ptNew = + CFX_PointF(word.ptWord.x + ptOffset.x, word.ptWord.y + ptOffset.y); if (ptNew != ptOld) { sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y << " Td\n"; diff --git a/core/fpdfdoc/cpvt_generateap.h b/core/fpdfdoc/cpvt_generateap.h index 16c939fe92..62a84531ee 100644 --- a/core/fpdfdoc/cpvt_generateap.h +++ b/core/fpdfdoc/cpvt_generateap.h @@ -48,7 +48,7 @@ class CPVT_GenerateAP { CPDF_Dictionary* pAnnotDict); static CFX_ByteString GenerateEditAP(IPVT_FontMap* pFontMap, CPDF_VariableText::Iterator* pIterator, - const CFX_FloatPoint& ptOffset, + const CFX_PointF& ptOffset, bool bContinuous, uint16_t SubWord); static CFX_ByteString GenerateBorderAP(const CFX_FloatRect& rect, diff --git a/core/fpdfdoc/cpvt_line.h b/core/fpdfdoc/cpvt_line.h index 25ae34af16..47c3e84d6a 100644 --- a/core/fpdfdoc/cpvt_line.h +++ b/core/fpdfdoc/cpvt_line.h @@ -11,15 +11,19 @@ #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" -struct CPVT_Line { - CPVT_Line() : fLineWidth(0.0f), fLineAscent(0.0f), fLineDescent(0.0f) {} +class CPVT_Line { + public: + CPVT_Line(); CPVT_WordPlace lineplace; CPVT_WordPlace lineEnd; - CFX_FloatPoint ptLine; + CFX_PointF ptLine; FX_FLOAT fLineWidth; FX_FLOAT fLineAscent; FX_FLOAT fLineDescent; }; +inline CPVT_Line::CPVT_Line() + : fLineWidth(0.0f), fLineAscent(0.0f), fLineDescent(0.0f) {} + #endif // CORE_FPDFDOC_CPVT_LINE_H_ diff --git a/core/fpdfdoc/cpvt_lineinfo.h b/core/fpdfdoc/cpvt_lineinfo.h index 2ebc51cb8e..8fb10de250 100644 --- a/core/fpdfdoc/cpvt_lineinfo.h +++ b/core/fpdfdoc/cpvt_lineinfo.h @@ -9,16 +9,9 @@ #include "core/fxcrt/fx_system.h" -struct CPVT_LineInfo { - CPVT_LineInfo() - : nTotalWord(0), - nBeginWordIndex(-1), - nEndWordIndex(-1), - fLineX(0.0f), - fLineY(0.0f), - fLineWidth(0.0f), - fLineAscent(0.0f), - fLineDescent(0.0f) {} +class CPVT_LineInfo { + public: + CPVT_LineInfo(); int32_t nTotalWord; int32_t nBeginWordIndex; @@ -30,4 +23,14 @@ struct CPVT_LineInfo { FX_FLOAT fLineDescent; }; +inline CPVT_LineInfo::CPVT_LineInfo() + : nTotalWord(0), + nBeginWordIndex(-1), + nEndWordIndex(-1), + fLineX(0.0f), + fLineY(0.0f), + fLineWidth(0.0f), + fLineAscent(0.0f), + fLineDescent(0.0f) {} + #endif // CORE_FPDFDOC_CPVT_LINEINFO_H_ diff --git a/core/fpdfdoc/cpvt_word.h b/core/fpdfdoc/cpvt_word.h index 92a4ce1e94..540f0416ad 100644 --- a/core/fpdfdoc/cpvt_word.h +++ b/core/fpdfdoc/cpvt_word.h @@ -11,13 +11,14 @@ #include "core/fpdfdoc/cpvt_wordprops.h" #include "core/fxcrt/fx_system.h" -struct CPVT_Word { +class CPVT_Word { + public: CPVT_Word(); uint16_t Word; int32_t nCharset; CPVT_WordPlace WordPlace; - CFX_FloatPoint ptWord; + CFX_PointF ptWord; FX_FLOAT fAscent; FX_FLOAT fDescent; FX_FLOAT fWidth; diff --git a/core/fpdfdoc/csection.cpp b/core/fpdfdoc/csection.cpp index 4964504175..490ef1b230 100644 --- a/core/fpdfdoc/csection.cpp +++ b/core/fpdfdoc/csection.cpp @@ -146,7 +146,7 @@ void CSection::UpdateWordPlace(CPVT_WordPlace& place) const { } } -CPVT_WordPlace CSection::SearchWordPlace(const CFX_FloatPoint& point) const { +CPVT_WordPlace CSection::SearchWordPlace(const CFX_PointF& point) const { ASSERT(m_pVT); CPVT_WordPlace place = GetBeginWordPlace(); bool bUp = true; diff --git a/core/fpdfdoc/csection.h b/core/fpdfdoc/csection.h index 706f5b67bb..a2ac43b102 100644 --- a/core/fpdfdoc/csection.h +++ b/core/fpdfdoc/csection.h @@ -14,8 +14,7 @@ #include "core/fxcrt/fx_system.h" class CPDF_VariableText; - -struct CPVT_LineInfo; +class CPVT_LineInfo; struct CPVT_WordLine; struct CPVT_WordPlace; @@ -40,7 +39,7 @@ class CSection final { CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; void UpdateWordPlace(CPVT_WordPlace& place) const; - CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const; + CPVT_WordPlace SearchWordPlace(const CFX_PointF& point) const; CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, const CPVT_WordPlace& lineplace) const; CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, |