diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/formfiller/cffl_interactiveformfiller.cpp | 17 | ||||
-rw-r--r-- | fpdfsdk/fpdf_transformpage.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/fpdfeditpath.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Caret.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_ComboBox.cpp | 10 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Edit.cpp | 19 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_ScrollBar.cpp | 20 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Utils.cpp | 114 |
8 files changed, 88 insertions, 119 deletions
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp index a8368f4352..7778408531 100644 --- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp @@ -70,15 +70,14 @@ void CFFL_InteractiveFormFiller::OnDraw(CPDFSDK_PageView* pPageView, CFX_FloatRect rcFocus = pFormFiller->GetFocusBox(pPageView); if (!rcFocus.IsEmpty()) { CFX_PathData path; - path.SetPointCount(5); - path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_TYPE::MoveTo, false); - path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_TYPE::LineTo, - false); - path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_TYPE::LineTo, - false); - path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_TYPE::LineTo, - false); - path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_TYPE::LineTo, false); + path.AppendPoint(rcFocus.left, rcFocus.top, FXPT_TYPE::MoveTo, false); + path.AppendPoint(rcFocus.left, rcFocus.bottom, FXPT_TYPE::LineTo, + false); + path.AppendPoint(rcFocus.right, rcFocus.bottom, FXPT_TYPE::LineTo, + false); + path.AppendPoint(rcFocus.right, rcFocus.top, FXPT_TYPE::LineTo, + false); + path.AppendPoint(rcFocus.left, rcFocus.top, FXPT_TYPE::LineTo, false); CFX_GraphStateData gsd; gsd.SetDashCount(1); diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp index 6d19a6b430..7e19505c26 100644 --- a/fpdfsdk/fpdf_transformpage.cpp +++ b/fpdfsdk/fpdf_transformpage.cpp @@ -6,6 +6,8 @@ #include "public/fpdf_transformpage.h" +#include <vector> + #include "core/fpdfapi/page/cpdf_clippath.h" #include "core/fpdfapi/page/cpdf_page.h" #include "core/fpdfapi/page/cpdf_pageobject.h" @@ -235,8 +237,7 @@ void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) { if (!pPathData) return; - FX_PATHPOINT* pPoints = pPathData->GetPoints(); - + const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints(); if (path.IsRect()) { buf << (pPoints[0].m_PointX) << " " << (pPoints[0].m_PointY) << " " << (pPoints[2].m_PointX - pPoints[0].m_PointX) << " " @@ -245,7 +246,7 @@ void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) { } CFX_ByteString temp; - for (int i = 0; i < pPathData->GetPointCount(); i++) { + for (size_t i = 0; i < pPoints.size(); i++) { buf << (pPoints[i].m_PointX) << " " << (pPoints[i].m_PointY); FXPT_TYPE point_type = pPoints[i].m_Type; if (point_type == FXPT_TYPE::MoveTo) { @@ -288,7 +289,7 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, for (i = 0; i < pClipPath->GetPathCount(); i++) { CPDF_Path path = pClipPath->GetPath(i); int iClipType = pClipPath->GetClipType(i); - if (path.GetPointCount() == 0) { + if (path.GetPoints().empty()) { // Empty clipping (totally clipped out) strClip << "0 0 m W n "; } else { diff --git a/fpdfsdk/fpdfeditpath.cpp b/fpdfsdk/fpdfeditpath.cpp index f6e103c047..63a887dc85 100644 --- a/fpdfsdk/fpdfeditpath.cpp +++ b/fpdfsdk/fpdfeditpath.cpp @@ -106,15 +106,10 @@ DLLEXPORT FPDF_BOOL FPDFPath_Close(FPDF_PAGEOBJECT path) { return false; auto pPathObj = reinterpret_cast<CPDF_PathObject*>(path); - int numPoints = pPathObj->m_Path.GetPointCount(); - if (numPoints == 0) + if (pPathObj->m_Path.GetPoints().empty()) return false; - FX_PATHPOINT* pPoints = pPathObj->m_Path.GetMutablePoints(); - if (pPoints[numPoints - 1].m_CloseFigure) - return true; - - pPoints[numPoints - 1].m_CloseFigure = true; + pPathObj->m_Path.ClosePath(); return true; } diff --git a/fpdfsdk/pdfwindow/PWL_Caret.cpp b/fpdfsdk/pdfwindow/PWL_Caret.cpp index 06c8e31ce7..e263a79065 100644 --- a/fpdfsdk/pdfwindow/PWL_Caret.cpp +++ b/fpdfsdk/pdfwindow/PWL_Caret.cpp @@ -34,7 +34,6 @@ void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_FloatRect rcRect = GetCaretRect(); CFX_FloatRect rcClip = GetClipRect(); CFX_PathData path; - path.SetPointCount(2); FX_FLOAT fCaretX = rcRect.left + m_fWidth * 0.5f; FX_FLOAT fCaretTop = rcRect.top; @@ -44,14 +43,14 @@ void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice, if (!rcRect.IsEmpty()) { fCaretTop = rcRect.top; fCaretBottom = rcRect.bottom; - path.SetPoint(0, fCaretX, fCaretBottom, FXPT_TYPE::MoveTo, false); - path.SetPoint(1, fCaretX, fCaretTop, FXPT_TYPE::LineTo, false); + path.AppendPoint(fCaretX, fCaretBottom, FXPT_TYPE::MoveTo, false); + path.AppendPoint(fCaretX, fCaretTop, FXPT_TYPE::LineTo, false); } else { return; } } else { - path.SetPoint(0, fCaretX, fCaretBottom, FXPT_TYPE::MoveTo, false); - path.SetPoint(1, fCaretX, fCaretTop, FXPT_TYPE::LineTo, false); + path.AppendPoint(fCaretX, fCaretBottom, FXPT_TYPE::MoveTo, false); + path.AppendPoint(fCaretX, fCaretTop, FXPT_TYPE::LineTo, false); } CFX_GraphStateData gsd; diff --git a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp index 1bf1adfbcf..adab4e7998 100644 --- a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp +++ b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp @@ -147,12 +147,10 @@ void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, IsFloatBigger(rectWnd.top - rectWnd.bottom, PWL_CBBUTTON_TRIANGLE_HALFLEN)) { CFX_PathData path; - - path.SetPointCount(4); - path.SetPoint(0, pt1.x, pt1.y, FXPT_TYPE::MoveTo, false); - path.SetPoint(1, pt2.x, pt2.y, FXPT_TYPE::LineTo, false); - path.SetPoint(2, pt3.x, pt3.y, FXPT_TYPE::LineTo, false); - path.SetPoint(3, pt1.x, pt1.y, FXPT_TYPE::LineTo, false); + path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::MoveTo, false); + path.AppendPoint(pt2.x, pt2.y, FXPT_TYPE::LineTo, false); + path.AppendPoint(pt3.x, pt3.y, FXPT_TYPE::LineTo, false); + path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::LineTo, false); pDevice->DrawPath(&path, pUser2Device, nullptr, CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR, diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp index 5d9c314a56..5c22d21940 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp @@ -323,21 +323,18 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); CFX_PathData path; - path.SetPointCount(nCharArraySafe.ValueOrDie()); for (int32_t i = 0; i < nCharArray - 1; i++) { - path.SetPoint( - i * 2, + path.AppendPoint( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom, FXPT_TYPE::MoveTo, false); - path.SetPoint( - i * 2 + 1, + path.AppendPoint( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_TYPE::LineTo, false); } - if (path.GetPointCount() > 0) { + if (!path.GetPoints().empty()) { pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), @@ -355,21 +352,17 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase; CFX_PathData path; - path.SetPointCount(nCharArraySafe.ValueOrDie()); - for (int32_t i = 0; i < nCharArray - 1; i++) { - path.SetPoint( - i * 2, + path.AppendPoint( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom, FXPT_TYPE::MoveTo, false); - path.SetPoint( - i * 2 + 1, + path.AppendPoint( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_TYPE::LineTo, false); } - if (path.GetPointCount() > 0) { + if (!path.GetPoints().empty()) { pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), diff --git a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp index 2aa2c7e35f..a202513b92 100644 --- a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp +++ b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp @@ -257,12 +257,10 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 && rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) { CFX_PathData path; - - path.SetPointCount(4); - path.SetPoint(0, pt1.x, pt1.y, FXPT_TYPE::MoveTo, false); - path.SetPoint(1, pt2.x, pt2.y, FXPT_TYPE::LineTo, false); - path.SetPoint(2, pt3.x, pt3.y, FXPT_TYPE::LineTo, false); - path.SetPoint(3, pt1.x, pt1.y, FXPT_TYPE::LineTo, false); + path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::MoveTo, false); + path.AppendPoint(pt2.x, pt2.y, FXPT_TYPE::LineTo, false); + path.AppendPoint(pt3.x, pt3.y, FXPT_TYPE::LineTo, false); + path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::LineTo, false); pDevice->DrawPath(&path, pUser2Device, nullptr, CPWL_Utils::PWLColorToFXColor( @@ -280,12 +278,10 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 && rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) { CFX_PathData path; - - path.SetPointCount(4); - path.SetPoint(0, pt1.x, pt1.y, FXPT_TYPE::MoveTo, false); - path.SetPoint(1, pt2.x, pt2.y, FXPT_TYPE::LineTo, false); - path.SetPoint(2, pt3.x, pt3.y, FXPT_TYPE::LineTo, false); - path.SetPoint(3, pt1.x, pt1.y, FXPT_TYPE::LineTo, false); + path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::MoveTo, false); + path.AppendPoint(pt2.x, pt2.y, FXPT_TYPE::LineTo, false); + path.AppendPoint(pt3.x, pt3.y, FXPT_TYPE::LineTo, false); + path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::LineTo, false); pDevice->DrawPath(&path, pUser2Device, nullptr, CPWL_Utils::PWLColorToFXColor( diff --git a/fpdfsdk/pdfwindow/PWL_Utils.cpp b/fpdfsdk/pdfwindow/PWL_Utils.cpp index 8b2813d3e6..9f5e31f6fd 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.cpp +++ b/fpdfsdk/pdfwindow/PWL_Utils.cpp @@ -48,21 +48,19 @@ CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData, void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path, const CPWL_PathData* pPathData, int32_t nCount) { - path.SetPointCount(nCount); - for (int32_t i = 0; i < nCount; i++) { switch (pPathData[i].type) { case PWLPT_MOVETO: - path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, - FXPT_TYPE::MoveTo, false); + path.AppendPoint(pPathData[i].point.x, pPathData[i].point.y, + FXPT_TYPE::MoveTo, false); break; case PWLPT_LINETO: - path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, - FXPT_TYPE::LineTo, false); + path.AppendPoint(pPathData[i].point.x, pPathData[i].point.y, + FXPT_TYPE::LineTo, false); break; case PWLPT_BEZIERTO: - path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, - FXPT_TYPE::BezierTo, false); + path.AppendPoint(pPathData[i].point.x, pPathData[i].point.y, + FXPT_TYPE::BezierTo, false); break; default: break; @@ -1234,11 +1232,9 @@ void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice, int32_t nCount, const FX_COLORREF& color) { CFX_PathData path; - path.SetPointCount(nCount); - - path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_TYPE::MoveTo, false); + path.AppendPoint(pPts[0].x, pPts[0].y, FXPT_TYPE::MoveTo, false); for (int32_t i = 1; i < nCount; i++) - path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_TYPE::LineTo, false); + path.AppendPoint(pPts[i].x, pPts[i].y, FXPT_TYPE::LineTo, false); pDevice->DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_ALTERNATE); } @@ -1265,9 +1261,8 @@ void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice, const FX_COLORREF& color, FX_FLOAT fWidth) { CFX_PathData path; - path.SetPointCount(2); - path.SetPoint(0, ptMoveTo.x, ptMoveTo.y, FXPT_TYPE::MoveTo, false); - path.SetPoint(1, ptLineTo.x, ptLineTo.y, FXPT_TYPE::LineTo, false); + path.AppendPoint(ptMoveTo.x, ptMoveTo.y, FXPT_TYPE::MoveTo, false); + path.AppendPoint(ptLineTo.x, ptLineTo.y, FXPT_TYPE::LineTo, false); CFX_GraphStateData gsd; gsd.m_LineWidth = fWidth; @@ -1350,18 +1345,16 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, } case BorderStyle::DASH: { CFX_PathData path; - - path.SetPointCount(5); - path.SetPoint(0, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, - FXPT_TYPE::MoveTo, false); - path.SetPoint(1, fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f, - FXPT_TYPE::LineTo, false); - path.SetPoint(2, fRight - fWidth / 2.0f, fTop - fWidth / 2.0f, - FXPT_TYPE::LineTo, false); - path.SetPoint(3, fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f, - FXPT_TYPE::LineTo, false); - path.SetPoint(4, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, - FXPT_TYPE::LineTo, false); + path.AppendPoint(fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, + FXPT_TYPE::MoveTo, false); + path.AppendPoint(fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f, + FXPT_TYPE::LineTo, false); + path.AppendPoint(fRight - fWidth / 2.0f, fTop - fWidth / 2.0f, + FXPT_TYPE::LineTo, false); + path.AppendPoint(fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f, + FXPT_TYPE::LineTo, false); + path.AppendPoint(fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, + FXPT_TYPE::LineTo, false); CFX_GraphStateData gsd; gsd.SetDashCount(2); @@ -1382,43 +1375,40 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, CFX_PathData pathLT; - pathLT.SetPointCount(7); - pathLT.SetPoint(0, fLeft + fHalfWidth, fBottom + fHalfWidth, - FXPT_TYPE::MoveTo, false); - pathLT.SetPoint(1, fLeft + fHalfWidth, fTop - fHalfWidth, - FXPT_TYPE::LineTo, false); - pathLT.SetPoint(2, fRight - fHalfWidth, fTop - fHalfWidth, - FXPT_TYPE::LineTo, false); - pathLT.SetPoint(3, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathLT.SetPoint(4, fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathLT.SetPoint(5, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathLT.SetPoint(6, fLeft + fHalfWidth, fBottom + fHalfWidth, - FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fLeft + fHalfWidth, fBottom + fHalfWidth, + FXPT_TYPE::MoveTo, false); + pathLT.AppendPoint(fLeft + fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fRight - fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fLeft + fHalfWidth, fBottom + fHalfWidth, + FXPT_TYPE::LineTo, false); pDevice->DrawPath(&pathLT, pUser2Device, &gsd, PWLColorToFXColor(crLeftTop, nTransparancy), 0, FXFILL_ALTERNATE); CFX_PathData pathRB; - - pathRB.SetPointCount(7); - pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth, - FXPT_TYPE::MoveTo, false); - pathRB.SetPoint(1, fRight - fHalfWidth, fBottom + fHalfWidth, - FXPT_TYPE::LineTo, false); - pathRB.SetPoint(2, fLeft + fHalfWidth, fBottom + fHalfWidth, - FXPT_TYPE::LineTo, false); - pathRB.SetPoint(3, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathRB.SetPoint(4, fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathRB.SetPoint(5, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth, - FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fRight - fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::MoveTo, false); + pathRB.AppendPoint(fRight - fHalfWidth, fBottom + fHalfWidth, + FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fLeft + fHalfWidth, fBottom + fHalfWidth, + FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fRight - fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::LineTo, false); pDevice->DrawPath(&pathRB, pUser2Device, &gsd, PWLColorToFXColor(crRightBottom, nTransparancy), 0, @@ -1437,11 +1427,9 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, } case BorderStyle::UNDERLINE: { CFX_PathData path; - - path.SetPointCount(2); - path.SetPoint(0, fLeft, fBottom + fWidth / 2, FXPT_TYPE::MoveTo, false); - path.SetPoint(1, fRight, fBottom + fWidth / 2, FXPT_TYPE::LineTo, - false); + path.AppendPoint(fLeft, fBottom + fWidth / 2, FXPT_TYPE::MoveTo, false); + path.AppendPoint(fRight, fBottom + fWidth / 2, FXPT_TYPE::LineTo, + false); CFX_GraphStateData gsd; gsd.m_LineWidth = fWidth; |