From 3b8fdd34bdf57ec45291b77008a43249f838efcb Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 26 Feb 2016 13:09:42 -0800 Subject: Replace CPDF_Rect and CPDF_Point with CFX types. Too many rectangle types. Remove CPDF_Rect #define, and make an equivalent point type in CFX, but stop short of consolidating the N different forms of rectangles in CFX. Also banish PDF_ClipFloat to the one .cpp file that needs it, since it was in the vicinity of the .h file changes. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1740923003 . --- core/include/fpdfapi/fpdf_parser.h | 19 +----- core/include/fpdfdoc/fpdf_ap.h | 4 +- core/include/fpdfdoc/fpdf_vt.h | 21 +++--- core/include/fpdftext/fpdf_text.h | 2 +- core/include/fxcrt/fx_coordinates.h | 9 +++ .../fpdfapi/fpdf_page/fpdf_page_graph_state.cpp | 28 +++++--- core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 2 +- .../fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 10 --- core/src/fpdfdoc/doc_annot.cpp | 6 +- core/src/fpdfdoc/doc_ap.cpp | 76 +++++++++++----------- core/src/fpdfdoc/doc_link.cpp | 4 +- core/src/fpdfdoc/doc_vt.cpp | 26 ++++---- core/src/fpdfdoc/pdf_vt.h | 58 +++++++++-------- core/src/fpdftext/fpdf_text_int.cpp | 4 +- core/src/fpdftext/text_int.h | 2 +- 15 files changed, 134 insertions(+), 137 deletions(-) (limited to 'core') diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h index 9fa05c75ed..c57d9f20b9 100644 --- a/core/include/fpdfapi/fpdf_parser.h +++ b/core/include/fpdfapi/fpdf_parser.h @@ -672,26 +672,11 @@ class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler { FX_BOOL bEncrypt); uint8_t m_EncryptKey[32]; - int m_KeyLen; - int m_Cipher; - uint8_t* m_pAESContext; }; -class CPDF_Point { - public: - CPDF_Point(FX_FLOAT xx, FX_FLOAT yy) { - x = xx; - y = yy; - } - - FX_FLOAT x; - FX_FLOAT y; -}; - -#define CPDF_Rect CFX_FloatRect CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& orig); CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig); CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig); @@ -702,23 +687,21 @@ CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr); CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len = -1); CFX_ByteString PDF_EncodeText(const CFX_WideString& str); -FX_FLOAT PDF_ClipFloat(FX_FLOAT f); class CFDF_Document : public CPDF_IndirectObjectHolder { public: static CFDF_Document* CreateNewDoc(); static CFDF_Document* ParseFile(IFX_FileRead* pFile, FX_BOOL bOwnFile = FALSE); static CFDF_Document* ParseMemory(const uint8_t* pData, FX_DWORD size); - ~CFDF_Document(); FX_BOOL WriteBuf(CFX_ByteTextBuf& buf) const; - CPDF_Dictionary* GetRoot() const { return m_pRootDict; } protected: CFDF_Document(); void ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile); + CPDF_Dictionary* m_pRootDict; IFX_FileRead* m_pFile; FX_BOOL m_bOwnFile; diff --git a/core/include/fpdfdoc/fpdf_ap.h b/core/include/fpdfdoc/fpdf_ap.h index f9ade57d97..5f2a3005ea 100644 --- a/core/include/fpdfdoc/fpdf_ap.h +++ b/core/include/fpdfdoc/fpdf_ap.h @@ -81,12 +81,12 @@ class CPVT_GenerateAP { static CFX_ByteString GenerateEditAP(IPVT_FontMap* pFontMap, IPDF_VariableText_Iterator* pIterator, - const CPDF_Point& ptOffset, + const CFX_FloatPoint& ptOffset, FX_BOOL bContinuous, FX_WORD SubWord = 0, const CPVT_WordRange* pVisible = NULL); - static CFX_ByteString GenerateBorderAP(const CPDF_Rect& rect, + static CFX_ByteString GenerateBorderAP(const CFX_FloatRect& rect, FX_FLOAT fWidth, const CPVT_Color& color, const CPVT_Color& crLeftTop, diff --git a/core/include/fpdfdoc/fpdf_vt.h b/core/include/fpdfdoc/fpdf_vt.h index 91a93884e8..b2e64cd2ed 100644 --- a/core/include/fpdfdoc/fpdf_vt.h +++ b/core/include/fpdfdoc/fpdf_vt.h @@ -226,7 +226,7 @@ struct CPVT_Word { CPVT_WordPlace WordPlace; - CPDF_Point ptWord; + CFX_FloatPoint ptWord; FX_FLOAT fAscent; @@ -248,7 +248,7 @@ struct CPVT_Line { CPVT_WordPlace lineEnd; - CPDF_Point ptLine; + CFX_FloatPoint ptLine; FX_FLOAT fLineWidth; @@ -259,7 +259,7 @@ struct CPVT_Line { struct CPVT_Section { CPVT_WordPlace secplace; - CPDF_Rect rcSection; + CFX_FloatRect rcSection; CPVT_SecProps SecProps; @@ -328,7 +328,7 @@ class IPDF_VariableText { virtual IPDF_VariableText_Iterator* GetIterator() = 0; - virtual void SetPlateRect(const CPDF_Rect& rect) = 0; + virtual void SetPlateRect(const CFX_FloatRect& rect) = 0; virtual void SetAlignment(int32_t nFormat = 0) = 0; @@ -395,9 +395,9 @@ class IPDF_VariableText { virtual CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place) = 0; - virtual const CPDF_Rect& GetPlateRect() const = 0; + virtual const CFX_FloatRect& GetPlateRect() const = 0; - virtual CPDF_Rect GetContentRect() const = 0; + virtual CFX_FloatRect GetContentRect() const = 0; virtual int32_t GetTotalWords() const = 0; @@ -427,13 +427,14 @@ class IPDF_VariableText { virtual CPVT_WordPlace GetNextWordPlace( const CPVT_WordPlace& place) const = 0; - virtual CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const = 0; + virtual CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const = 0; virtual CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace& place, - const CPDF_Point& point) const = 0; + const CFX_FloatPoint& point) const = 0; - virtual CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace& place, - const CPDF_Point& point) const = 0; + virtual CPVT_WordPlace GetDownWordPlace( + const CPVT_WordPlace& place, + const CFX_FloatPoint& point) const = 0; virtual CPVT_WordPlace GetLineBeginPlace( const CPVT_WordPlace& place) const = 0; diff --git a/core/include/fpdftext/fpdf_text.h b/core/include/fpdftext/fpdf_text.h index 498b6235c3..7c1cde6051 100644 --- a/core/include/fpdftext/fpdf_text.h +++ b/core/include/fpdftext/fpdf_text.h @@ -58,7 +58,7 @@ class IPDF_TextPage { virtual void GetRectArray(int start, int nCount, CFX_RectArray& rectArray) const = 0; - virtual int GetIndexAtPos(CPDF_Point point, + virtual int GetIndexAtPos(CFX_FloatPoint point, FX_FLOAT xTolerance, FX_FLOAT yTolerance) const = 0; virtual int GetIndexAtPos(FX_FLOAT x, diff --git a/core/include/fxcrt/fx_coordinates.h b/core/include/fxcrt/fx_coordinates.h index 053d637689..4bafb63099 100644 --- a/core/include/fxcrt/fx_coordinates.h +++ b/core/include/fxcrt/fx_coordinates.h @@ -415,6 +415,15 @@ struct FX_SMALL_RECT { int16_t Bottom; }; + +class CFX_FloatPoint { + public: + CFX_FloatPoint(FX_FLOAT xx, FX_FLOAT yy) : x(xx), y(xx) {} + + FX_FLOAT x; + FX_FLOAT y; +}; + class CFX_FloatRect { public: CFX_FloatRect() { left = right = bottom = top = 0; } diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp index de3a6572f2..44492b1a54 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp @@ -6,6 +6,8 @@ #include "core/src/fpdfapi/fpdf_page/pageint.h" +#include + #include "core/include/fpdfapi/fpdf_module.h" #include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_pageobj.h" @@ -13,6 +15,14 @@ #include "core/src/fpdfapi/fpdf_render/render_int.h" #include "third_party/base/stl_util.h" +namespace { + +FX_FLOAT ClipFloat(FX_FLOAT f) { + return std::max(0.0f, std::min(1.0f, f)); +} + +} // namespace + void CPDF_GraphicStates::DefaultStates() { m_ColorState.New()->Default(); } @@ -85,21 +95,21 @@ void CPDF_ClipPathData::SetCount(int path_count, int text_count) { m_pTextList = FX_Alloc(CPDF_TextObject*, text_count); } } -CPDF_Rect CPDF_ClipPath::GetClipBox() const { - CPDF_Rect rect; +CFX_FloatRect CPDF_ClipPath::GetClipBox() const { + CFX_FloatRect rect; FX_BOOL bStarted = FALSE; int count = GetPathCount(); if (count) { rect = GetPath(0).GetBoundingBox(); for (int i = 1; i < count; i++) { - CPDF_Rect path_rect = GetPath(i).GetBoundingBox(); + CFX_FloatRect path_rect = GetPath(i).GetBoundingBox(); rect.Intersect(path_rect); } bStarted = TRUE; } count = GetTextCount(); if (count) { - CPDF_Rect layer_rect; + CFX_FloatRect layer_rect; FX_BOOL bLayerStarted = FALSE; for (int i = 0; i < count; i++) { CPDF_TextObject* pTextObj = GetText(i); @@ -128,9 +138,9 @@ void CPDF_ClipPath::AppendPath(CPDF_Path path, int type, FX_BOOL bAutoMerge) { if (pData->m_PathCount && bAutoMerge) { CPDF_Path old_path = pData->m_pPathList[pData->m_PathCount - 1]; if (old_path.IsRect()) { - CPDF_Rect old_rect(old_path.GetPointX(0), old_path.GetPointY(0), - old_path.GetPointX(2), old_path.GetPointY(2)); - CPDF_Rect new_rect = path.GetBoundingBox(); + CFX_FloatRect old_rect(old_path.GetPointX(0), old_path.GetPointY(0), + old_path.GetPointX(2), old_path.GetPointY(2)); + CFX_FloatRect new_rect = path.GetBoundingBox(); if (old_rect.Contains(new_rect)) { pData->m_PathCount--; pData->m_pPathList[pData->m_PathCount].SetNull(); @@ -534,10 +544,10 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, } break; case FXBSTR_ID('C', 'A', 0, 0): - pGeneralState->m_StrokeAlpha = PDF_ClipFloat(pObject->GetNumber()); + pGeneralState->m_StrokeAlpha = ClipFloat(pObject->GetNumber()); break; case FXBSTR_ID('c', 'a', 0, 0): - pGeneralState->m_FillAlpha = PDF_ClipFloat(pObject->GetNumber()); + pGeneralState->m_FillAlpha = ClipFloat(pObject->GetNumber()); break; case FXBSTR_ID('O', 'P', 0, 0): pGeneralState->m_StrokeOP = pObject->GetInteger(); diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp index c47fe8bd73..1df4f3db37 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -116,7 +116,7 @@ CPDF_StreamContentParser::CPDF_StreamContentParser( CFX_Matrix* pmtContentToUser, CPDF_PageObjectHolder* pObjHolder, CPDF_Dictionary* pResources, - CPDF_Rect* pBBox, + CFX_FloatRect* pBBox, CPDF_ParseOptions* pOptions, CPDF_AllStates* pStates, int level) diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index d1a7231d45..37b82dd564 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -363,16 +363,6 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) { return buf; } -FX_FLOAT PDF_ClipFloat(FX_FLOAT f) { - if (f < 0) { - return 0; - } - if (f > 1.0f) { - return 1.0f; - } - return f; -} - static CPDF_Object* SearchNumberNode(CPDF_Dictionary* pNode, int num) { CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); if (pLimits && diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp index 4b0b2b54bc..dcd21be66e 100644 --- a/core/src/fpdfdoc/doc_annot.cpp +++ b/core/src/fpdfdoc/doc_annot.cpp @@ -77,7 +77,7 @@ void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage, continue; } } - CPDF_Rect annot_rect_f; + CFX_FloatRect annot_rect_f; pAnnot->GetRect(annot_rect_f); CFX_Matrix matrix = *pMatrix; if (clip_rect) { @@ -132,7 +132,7 @@ CFX_ByteString CPDF_Annot::GetSubType() const { return m_sSubtype; } -void CPDF_Annot::GetRect(CPDF_Rect& rect) const { +void CPDF_Annot::GetRect(CFX_FloatRect& rect) const { if (!m_pAnnotDict) { return; } @@ -210,7 +210,7 @@ static CPDF_Form* FPDFDOC_Annot_GetMatrix(const CPDF_Page* pPage, CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRectBy("BBox"); CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixBy("Matrix"); form_matrix.TransformRect(form_bbox); - CPDF_Rect arect; + CFX_FloatRect arect; pAnnot->GetRect(arect); matrix.MatchRect(arect, form_bbox); matrix.Concat(*pUser2Device); diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp index 3ccf4c44d1..7fe06e2b5d 100644 --- a/core/src/fpdfdoc/doc_ap.cpp +++ b/core/src/fpdfdoc/doc_ap.cpp @@ -327,33 +327,33 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, if (!pDefFont) { return FALSE; } - CPDF_Rect rcAnnot = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rcAnnot = pAnnotDict->GetRectBy("Rect"); int32_t nRotate = 0; if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictBy("MK")) { nRotate = pMKDict->GetIntegerBy("R"); } - CPDF_Rect rcBBox; + CFX_FloatRect rcBBox; CFX_Matrix matrix; switch (nRotate % 360) { case 0: - rcBBox = CPDF_Rect(0, 0, rcAnnot.right - rcAnnot.left, - rcAnnot.top - rcAnnot.bottom); + rcBBox = CFX_FloatRect(0, 0, rcAnnot.right - rcAnnot.left, + rcAnnot.top - rcAnnot.bottom); break; case 90: matrix = CFX_Matrix(0, 1, -1, 0, rcAnnot.right - rcAnnot.left, 0); - rcBBox = CPDF_Rect(0, 0, rcAnnot.top - rcAnnot.bottom, - rcAnnot.right - rcAnnot.left); + rcBBox = CFX_FloatRect(0, 0, rcAnnot.top - rcAnnot.bottom, + rcAnnot.right - rcAnnot.left); break; case 180: matrix = CFX_Matrix(-1, 0, 0, -1, rcAnnot.right - rcAnnot.left, rcAnnot.top - rcAnnot.bottom); - rcBBox = CPDF_Rect(0, 0, rcAnnot.right - rcAnnot.left, - rcAnnot.top - rcAnnot.bottom); + rcBBox = CFX_FloatRect(0, 0, rcAnnot.right - rcAnnot.left, + rcAnnot.top - rcAnnot.bottom); break; case 270: matrix = CFX_Matrix(0, -1, 1, 0, 0, rcAnnot.top - rcAnnot.bottom); - rcBBox = CPDF_Rect(0, 0, rcAnnot.top - rcAnnot.bottom, - rcAnnot.right - rcAnnot.left); + rcBBox = CFX_FloatRect(0, 0, rcAnnot.top - rcAnnot.bottom, + rcAnnot.right - rcAnnot.left); break; } int32_t nBorderStyle = PBS_SOLID; @@ -414,9 +414,9 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, if (sBorderStream.GetLength() > 0) { sAppStream << "q\n" << sBorderStream << "Q\n"; } - CPDF_Rect rcBody = - CPDF_Rect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBorderWidth, - rcBBox.right - fBorderWidth, rcBBox.top - fBorderWidth); + CFX_FloatRect rcBody = + CFX_FloatRect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBorderWidth, + rcBBox.right - fBorderWidth, rcBBox.top - fBorderWidth); rcBody.Normalize(); CPDF_Dictionary* pAPDict = pAnnotDict->GetDictBy("AP"); if (!pAPDict) { @@ -496,11 +496,11 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, vt.Initialize(); vt.SetText(swValue.c_str()); vt.RearrangeAll(); - CPDF_Rect rcContent = vt.GetContentRect(); - CPDF_Point ptOffset(0.0f, 0.0f); + CFX_FloatRect rcContent = vt.GetContentRect(); + CFX_FloatPoint ptOffset(0.0f, 0.0f); if (!bMultiLine) { ptOffset = - CPDF_Point(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f); + CFX_FloatPoint(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f); } CFX_ByteString sBody = CPVT_GenerateAP::GenerateEditAP( &map, vt.GetIterator(), ptOffset, !bCharArray, subWord); @@ -529,10 +529,10 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPVT_Provider prd(&map); CPDF_VariableText vt; vt.SetProvider(&prd); - CPDF_Rect rcButton = rcBody; + CFX_FloatRect rcButton = rcBody; rcButton.left = rcButton.right - 13; rcButton.Normalize(); - CPDF_Rect rcEdit = rcBody; + CFX_FloatRect rcEdit = rcBody; rcEdit.right = rcButton.left; rcEdit.Normalize(); vt.SetPlateRect(rcEdit); @@ -544,9 +544,9 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, vt.Initialize(); vt.SetText(swValue.c_str()); vt.RearrangeAll(); - CPDF_Rect rcContent = vt.GetContentRect(); - CPDF_Point ptOffset = - CPDF_Point(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); + CFX_FloatRect rcContent = vt.GetContentRect(); + CFX_FloatPoint ptOffset = + CFX_FloatPoint(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP( &map, vt.GetIterator(), ptOffset, TRUE, 0); if (sEdit.GetLength() > 0) { @@ -575,8 +575,9 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, if (sButtonBorder.GetLength() > 0) { sAppStream << "q\n" << sButtonBorder << "Q\n"; } - CPDF_Point ptCenter = CPDF_Point((rcButton.left + rcButton.right) / 2, - (rcButton.top + rcButton.bottom) / 2); + CFX_FloatPoint ptCenter = + CFX_FloatPoint((rcButton.left + rcButton.right) / 2, + (rcButton.top + rcButton.bottom) / 2); if (IsFloatBigger(rcButton.Width(), 6) && IsFloatBigger(rcButton.Height(), 6)) { sAppStream << "q\n" @@ -628,7 +629,8 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, } CPDF_VariableText vt; vt.SetProvider(&prd); - vt.SetPlateRect(CPDF_Rect(rcBody.left, 0.0f, rcBody.right, 0.0f)); + vt.SetPlateRect( + CFX_FloatRect(rcBody.left, 0.0f, rcBody.right, 0.0f)); if (IsFloatZero(fFontSize)) { vt.SetFontSize(12.0f); } else { @@ -639,8 +641,8 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, vt.RearrangeAll(); FX_FLOAT fItemHeight = vt.GetContentRect().Height(); if (bSelected) { - CPDF_Rect rcItem = - CPDF_Rect(rcBody.left, fy - fItemHeight, rcBody.right, fy); + CFX_FloatRect rcItem = CFX_FloatRect( + rcBody.left, fy - fItemHeight, rcBody.right, fy); sBody << "q\n" << CPVT_GenerateAP::GenerateColorAP( CPVT_Color(CPVT_Color::kRGB, 0, 51.0f / 255.0f, 113.0f / 255.0f), @@ -651,13 +653,13 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP( CPVT_Color(CPVT_Color::kGray, 1), TRUE) << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), - CPDF_Point(0.0f, fy), + CFX_FloatPoint(0.0f, fy), TRUE, 0) << "ET\n"; } else { sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), - CPDF_Point(0.0f, fy), + CFX_FloatPoint(0.0f, fy), TRUE, 0) << "ET\n"; } @@ -714,12 +716,12 @@ FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, CFX_ByteString CPVT_GenerateAP::GenerateEditAP( IPVT_FontMap* pFontMap, IPDF_VariableText_Iterator* pIterator, - const CPDF_Point& ptOffset, + const CFX_FloatPoint& ptOffset, FX_BOOL bContinuous, FX_WORD SubWord, const CPVT_WordRange* pVisible) { CFX_ByteTextBuf sEditStream, sLineStream, sWords; - CPDF_Point ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); + CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); int32_t nCurFontIndex = -1; if (pIterator) { if (pVisible) { @@ -743,13 +745,13 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( } CPVT_Word word; if (pIterator->GetWord(word)) { - ptNew = CPDF_Point(word.ptWord.x + ptOffset.x, - word.ptWord.y + ptOffset.y); + ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x, + word.ptWord.y + ptOffset.y); } else { CPVT_Line line; pIterator->GetLine(line); - ptNew = CPDF_Point(line.ptLine.x + ptOffset.x, - line.ptLine.y + ptOffset.y); + ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x, + line.ptLine.y + ptOffset.y); } if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y @@ -775,8 +777,8 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( } else { CPVT_Word word; if (pIterator->GetWord(word)) { - ptNew = CPDF_Point(word.ptWord.x + ptOffset.x, - word.ptWord.y + ptOffset.y); + ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x, + word.ptWord.y + ptOffset.y); if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y << " Td\n"; @@ -801,7 +803,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( return sEditStream.GetByteString(); } CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( - const CPDF_Rect& rect, + const CFX_FloatRect& rect, FX_FLOAT fWidth, const CPVT_Color& color, const CPVT_Color& crLeftTop, diff --git a/core/src/fpdfdoc/doc_link.cpp b/core/src/fpdfdoc/doc_link.cpp index 6617e85cd4..7da29e0954 100644 --- a/core/src/fpdfdoc/doc_link.cpp +++ b/core/src/fpdfdoc/doc_link.cpp @@ -43,7 +43,7 @@ CPDF_Link CPDF_LinkList::GetLinkAtPoint(CPDF_Page* pPage, continue; CPDF_Link link(pAnnot); - CPDF_Rect rect = link.GetRect(); + CFX_FloatRect rect = link.GetRect(); if (!rect.Contains(pdf_x, pdf_y)) continue; @@ -68,7 +68,7 @@ void CPDF_LinkList::LoadPageLinks(CPDF_Page* pPage, } } -CPDF_Rect CPDF_Link::GetRect() { +CFX_FloatRect CPDF_Link::GetRect() { return m_pDict->GetRectBy("Rect"); } CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) { diff --git a/core/src/fpdfdoc/doc_vt.cpp b/core/src/fpdfdoc/doc_vt.cpp index 0f8a4e5320..477df25a14 100644 --- a/core/src/fpdfdoc/doc_vt.cpp +++ b/core/src/fpdfdoc/doc_vt.cpp @@ -166,7 +166,7 @@ void CSection::UpdateWordPlace(CPVT_WordPlace& place) const { } } } -CPVT_WordPlace CSection::SearchWordPlace(const CPDF_Point& point) const { +CPVT_WordPlace CSection::SearchWordPlace(const CFX_FloatPoint& point) const { ASSERT(m_pVT); CPVT_WordPlace place = GetBeginWordPlace(); FX_BOOL bUp = TRUE; @@ -1135,8 +1135,8 @@ CPVT_WordPlace CPDF_VariableText::GetNextWordPlace( return place; } CPVT_WordPlace CPDF_VariableText::SearchWordPlace( - const CPDF_Point& point) const { - CPDF_Point pt = OutToIn(point); + const CFX_FloatPoint& point) const { + CFX_FloatPoint pt = OutToIn(point); CPVT_WordPlace place = GetBeginWordPlace(); int32_t nLeft = 0; int32_t nRight = m_SectionArray.GetSize() - 1; @@ -1161,8 +1161,8 @@ CPVT_WordPlace CPDF_VariableText::SearchWordPlace( continue; } else { place = pSection->SearchWordPlace( - CPDF_Point(pt.x - pSection->m_SecInfo.rcSection.left, - pt.y - pSection->m_SecInfo.rcSection.top)); + CFX_FloatPoint(pt.x - pSection->m_SecInfo.rcSection.left, + pt.y - pSection->m_SecInfo.rcSection.top)); place.nSecIndex = nMid; return place; } @@ -1180,10 +1180,10 @@ CPVT_WordPlace CPDF_VariableText::SearchWordPlace( } CPVT_WordPlace CPDF_VariableText::GetUpWordPlace( const CPVT_WordPlace& place, - const CPDF_Point& point) const { + const CFX_FloatPoint& point) const { if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { CPVT_WordPlace temp = place; - CPDF_Point pt = OutToIn(point); + CFX_FloatPoint pt = OutToIn(point); if (temp.nLineIndex-- > 0) { return pSection->SearchWordPlace( pt.x - pSection->m_SecInfo.rcSection.left, temp); @@ -1200,10 +1200,10 @@ CPVT_WordPlace CPDF_VariableText::GetUpWordPlace( } CPVT_WordPlace CPDF_VariableText::GetDownWordPlace( const CPVT_WordPlace& place, - const CPDF_Point& point) const { + const CFX_FloatPoint& point) const { if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { CPVT_WordPlace temp = place; - CPDF_Point pt = OutToIn(point); + CFX_FloatPoint pt = OutToIn(point); if (temp.nLineIndex++ < pSection->m_LineArray.GetSize() - 1) { return pSection->SearchWordPlace( pt.x - pSection->m_SecInfo.rcSection.left, temp); @@ -1333,7 +1333,7 @@ FX_BOOL CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace& place, } return FALSE; } -CPDF_Rect CPDF_VariableText::GetContentRect() const { +CFX_FloatRect CPDF_VariableText::GetContentRect() const { return InToOut(CPVT_FloatRect(CPDF_EditContainer::GetContentRect())); } FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo& WordInfo, @@ -1753,8 +1753,8 @@ FX_BOOL CPDF_VariableText_Iterator::GetWord(CPVT_Word& word) const { word.nCharset = pWord->nCharset; word.fWidth = m_pVT->GetWordWidth(*pWord); word.ptWord = m_pVT->InToOut( - CPDF_Point(pWord->fWordX + pSection->m_SecInfo.rcSection.left, - pWord->fWordY + pSection->m_SecInfo.rcSection.top)); + CFX_FloatPoint(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) { @@ -1785,7 +1785,7 @@ FX_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(CPDF_Point( + line.ptLine = m_pVT->InToOut(CFX_FloatPoint( pLine->m_LineInfo.fLineX + pSection->m_SecInfo.rcSection.left, pLine->m_LineInfo.fLineY + pSection->m_SecInfo.rcSection.top)); line.fLineWidth = pLine->m_LineInfo.fLineWidth; diff --git a/core/src/fpdfdoc/pdf_vt.h b/core/src/fpdfdoc/pdf_vt.h index 286fad5772..13ec71a125 100644 --- a/core/src/fpdfdoc/pdf_vt.h +++ b/core/src/fpdfdoc/pdf_vt.h @@ -44,7 +44,7 @@ class CPVT_FloatRect : public CFX_FloatRect { right = other_right; bottom = other_bottom; } - explicit CPVT_FloatRect(const CPDF_Rect& rect) { + explicit CPVT_FloatRect(const CFX_FloatRect& rect) { left = rect.left; top = rect.top; right = rect.right; @@ -257,7 +257,7 @@ class CSection { 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 CPDF_Point& point) const; + CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const; CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, const CPVT_WordPlace& lineplace) const; CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, @@ -296,44 +296,46 @@ 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 CPDF_Rect& rect) { m_rcPlate = rect; } - virtual const CPDF_Rect& GetPlateRect() const { return m_rcPlate; } + 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) { m_rcContent = rect; } - virtual CPDF_Rect GetContentRect() const { return m_rcContent; } + 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()); } - CPDF_Point GetBTPoint() const { - return CPDF_Point(m_rcPlate.left, m_rcPlate.top); + CFX_FloatPoint GetBTPoint() const { + return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); } - CPDF_Point GetETPoint() const { - return CPDF_Point(m_rcPlate.right, m_rcPlate.bottom); + CFX_FloatPoint GetETPoint() const { + return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom); } - inline CPDF_Point InToOut(const CPDF_Point& point) const { - return CPDF_Point(point.x + GetBTPoint().x, GetBTPoint().y - point.y); + inline CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const { + return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y); } - inline CPDF_Point OutToIn(const CPDF_Point& point) const { - return CPDF_Point(point.x - GetBTPoint().x, GetBTPoint().y - point.y); + inline CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const { + return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y); } - inline CPDF_Rect InToOut(const CPVT_FloatRect& rect) const { - CPDF_Point ptLeftTop = InToOut(CPDF_Point(rect.left, rect.top)); - CPDF_Point ptRightBottom = InToOut(CPDF_Point(rect.right, rect.bottom)); - return CPDF_Rect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, - ptLeftTop.y); + inline CFX_FloatRect 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)); + return CFX_FloatRect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, + ptLeftTop.y); } - inline CPVT_FloatRect OutToIn(const CPDF_Rect& rect) const { - CPDF_Point ptLeftTop = OutToIn(CPDF_Point(rect.left, rect.top)); - CPDF_Point ptRightBottom = OutToIn(CPDF_Point(rect.right, rect.bottom)); + inline CPVT_FloatRect 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)); return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, ptRightBottom.y); } private: - CPDF_Rect m_rcPlate; + CFX_FloatRect m_rcPlate; CPVT_FloatRect m_rcContent; }; @@ -350,7 +352,7 @@ class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { IPDF_VariableText_Provider* SetProvider( IPDF_VariableText_Provider* pProvider) override; IPDF_VariableText_Iterator* GetIterator() override; - void SetPlateRect(const CPDF_Rect& rect) override { + void SetPlateRect(const CFX_FloatRect& rect) override { CPDF_EditContainer::SetPlateRect(rect); } void SetAlignment(int32_t nFormat = 0) override { m_nAlignment = nFormat; } @@ -407,10 +409,10 @@ class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange) override; CPVT_WordPlace DeleteWord(const CPVT_WordPlace& place) override; CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place) override; - const CPDF_Rect& GetPlateRect() const override { + const CFX_FloatRect& GetPlateRect() const override { return CPDF_EditContainer::GetPlateRect(); } - CPDF_Rect GetContentRect() const override; + CFX_FloatRect GetContentRect() const override; int32_t GetTotalWords() const override; FX_FLOAT GetFontSize() const override { return m_fFontSize; } int32_t GetAlignment() const override { return m_nAlignment; } @@ -424,11 +426,11 @@ class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { CPVT_WordPlace GetEndWordPlace() const override; CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const override; CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const override; - CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const override; + CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const override; CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace& place, - const CPDF_Point& point) const override; + const CFX_FloatPoint& point) const override; CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace& place, - const CPDF_Point& point) const override; + const CFX_FloatPoint& point) const override; CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const override; CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const override; CPVT_WordPlace GetSectionBeginPlace( diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp index 8e2eae1251..77b610a7e8 100644 --- a/core/src/fpdftext/fpdf_text_int.cpp +++ b/core/src/fpdftext/fpdf_text_int.cpp @@ -301,7 +301,7 @@ void CPDF_TextPage::GetRectArray(int start, rectArray.Add(rect); } -int CPDF_TextPage::GetIndexAtPos(CPDF_Point point, +int CPDF_TextPage::GetIndexAtPos(CFX_FloatPoint point, FX_FLOAT xTolerance, FX_FLOAT yTolerance) const { if (!m_bIsParsed) @@ -424,7 +424,7 @@ int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTolerance, FX_FLOAT yTolerance) const { - CPDF_Point point(x, y); + CFX_FloatPoint point(x, y); return GetIndexAtPos(point, xTolerance, yTolerance); } diff --git a/core/src/fpdftext/text_int.h b/core/src/fpdftext/text_int.h index 113e1d1ac8..ef742a38be 100644 --- a/core/src/fpdftext/text_int.h +++ b/core/src/fpdftext/text_int.h @@ -67,7 +67,7 @@ class CPDF_TextPage : public IPDF_TextPage { void GetRectArray(int start, int nCount, CFX_RectArray& rectArray) const override; - int GetIndexAtPos(CPDF_Point point, + int GetIndexAtPos(CFX_FloatPoint point, FX_FLOAT xTolerance, FX_FLOAT yTolerance) const override; int GetIndexAtPos(FX_FLOAT x, -- cgit v1.2.3