From 1b08df18300bbc67dabd12fb35ab6ce1732a1024 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 9 Feb 2017 09:17:20 -0500 Subject: Convert Get methods to return instead of using out params. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This Cl changes several Get methods to return their values instead of using out parameters. Change-Id: Ie9a930a5c2d0e809f2d7181ca033d801945c1cf9 Reviewed-on: https://pdfium-review.googlesource.com/2556 Commit-Queue: dsinclair Reviewed-by: Nicolás Peña --- fpdfsdk/cpdfsdk_xfawidgethandler.cpp | 4 +- fpdfsdk/fpdfformfill.cpp | 8 ++-- fpdfsdk/fpdfview.cpp | 37 ++++++++-------- fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | 83 +++++++++++++++++------------------- fpdfsdk/fpdfxfa/cpdfxfa_page.h | 11 +++-- 5 files changed, 69 insertions(+), 74 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp index 8d511fcc96..0259be3995 100644 --- a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp +++ b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp @@ -84,9 +84,9 @@ CFX_FloatRect CPDFSDK_XFAWidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView, CFX_RectF rcBBox; XFA_Element eType = pAnnot->GetXFAWidget()->GetDataAcc()->GetUIType(); if (eType == XFA_Element::Signature) - pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_Visible, true); + rcBBox = pAnnot->GetXFAWidget()->GetBBox(XFA_WidgetStatus_Visible, true); else - pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_None); + rcBBox = pAnnot->GetXFAWidget()->GetBBox(XFA_WidgetStatus_None); CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top + rcBBox.height); diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index beebe65dbb..37ecce509d 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -98,9 +98,8 @@ void FFLCommon(FPDF_FORMHANDLE hHandle, return; #endif // PDF_ENABLE_XFA - CFX_Matrix matrix; - pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); - + CFX_Matrix matrix = + pPage->GetDisplayMatrix(start_x, start_y, size_x, size_y, rotate); FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y); std::unique_ptr pDevice(new CFX_FxgeDevice); @@ -190,8 +189,7 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, CXFA_FFWidget* pXFAAnnot = pWidgetIterator->MoveToNext(); while (pXFAAnnot) { - CFX_RectF rcBBox; - pXFAAnnot->GetBBox(rcBBox, 0); + CFX_RectF rcBBox = pXFAAnnot->GetBBox(0); CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top + rcBBox.height); rcWidget.left -= 1.0f; diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 8aa6ec0fb9..2c2f25ab0b 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -850,16 +850,17 @@ DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, pPage->DeviceToPage(start_x, start_y, size_x, size_y, rotate, device_x, device_y, page_x, page_y); #else // PDF_ENABLE_XFA - CFX_Matrix page2device; - pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, - rotate); + CFX_Matrix page2device = + pPage->GetDisplayMatrix(start_x, start_y, size_x, size_y, rotate); CFX_Matrix device2page; device2page.SetReverse(page2device); - FX_FLOAT page_x_f, page_y_f; - device2page.Transform((FX_FLOAT)(device_x), (FX_FLOAT)(device_y), page_x_f, - page_y_f); - *page_x = (page_x_f); - *page_y = (page_y_f); + + FX_FLOAT page_x_f; + FX_FLOAT page_y_f; + device2page.Transform(static_cast(device_x), + static_cast(device_y), page_x_f, page_y_f); + *page_x = page_x_f; + *page_y = page_y_f; #endif // PDF_ENABLE_XFA } @@ -882,12 +883,12 @@ DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, pPage->PageToDevice(start_x, start_y, size_x, size_y, rotate, page_x, page_y, device_x, device_y); #else // PDF_ENABLE_XFA - CFX_Matrix page2device; - pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, - rotate); - FX_FLOAT device_x_f, device_y_f; - page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f, - device_y_f); + CFX_Matrix page2device = + pPage->GetDisplayMatrix(start_x, start_y, size_x, size_y, rotate); + FX_FLOAT device_x_f; + FX_FLOAT device_y_f; + page2device.Transform(static_cast(page_x), + static_cast(page_y), device_x_f, device_y_f); *device_x = FXSYS_round(device_x_f); *device_y = FXSYS_round(device_y_f); #endif // PDF_ENABLE_XFA @@ -982,10 +983,10 @@ void FPDF_RenderPage_Retail(CPDF_PageRenderContext* pContext, if (!pPage) return; - CFX_Matrix matrix; - pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); - FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y); - RenderPageImpl(pContext, pPage, matrix, rect, flags, bNeedToRestore, pause); + RenderPageImpl(pContext, pPage, pPage->GetDisplayMatrix( + start_x, start_y, size_x, size_y, rotate), + FX_RECT(start_x, start_y, start_x + size_x, start_y + size_y), + flags, bNeedToRestore, pause); } DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp index 8011295f96..f39a01078e 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp @@ -101,17 +101,16 @@ FX_FLOAT CPDFXFA_Page::GetPageWidth() const { int nDocType = m_pContext->GetDocType(); switch (nDocType) { case DOCTYPE_DYNAMIC_XFA: { - if (m_pXFAPageView) { - CFX_RectF rect; - m_pXFAPageView->GetPageViewRect(rect); - return rect.width; - } - } break; + if (m_pXFAPageView) + return m_pXFAPageView->GetPageViewRect().width; + break; + } case DOCTYPE_STATIC_XFA: case DOCTYPE_PDF: { if (m_pPDFPage) return m_pPDFPage->GetPageWidth(); - } break; + break; + } default: return 0.0f; } @@ -129,14 +128,13 @@ FX_FLOAT CPDFXFA_Page::GetPageHeight() const { case DOCTYPE_STATIC_XFA: { if (m_pPDFPage) return m_pPDFPage->GetPageHeight(); - } break; + break; + } case DOCTYPE_DYNAMIC_XFA: { - if (m_pXFAPageView) { - CFX_RectF rect; - m_pXFAPageView->GetPageViewRect(rect); - return rect.height; - } - } break; + if (m_pXFAPageView) + return m_pXFAPageView->GetPageViewRect().height; + break; + } default: return 0.0f; } @@ -158,16 +156,14 @@ void CPDFXFA_Page::DeviceToPage(int start_x, FX_FLOAT page_x_f, page_y_f; - CFX_Matrix page2device; - GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, rotate); - CFX_Matrix device2page; - device2page.SetReverse(page2device); - device2page.Transform((FX_FLOAT)(device_x), (FX_FLOAT)(device_y), page_x_f, - page_y_f); + device2page.SetReverse( + GetDisplayMatrix(start_x, start_y, size_x, size_y, rotate)); + device2page.Transform(static_cast(device_x), + static_cast(device_y), page_x_f, page_y_f); - *page_x = (page_x_f); - *page_y = (page_y_f); + *page_x = page_x_f; + *page_y = page_y_f; } void CPDFXFA_Page::PageToDevice(int start_x, @@ -182,42 +178,43 @@ void CPDFXFA_Page::PageToDevice(int start_x, if (!m_pPDFPage && !m_pXFAPageView) return; - FX_FLOAT device_x_f, device_y_f; - - CFX_Matrix page2device; - GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, rotate); + FX_FLOAT device_x_f; + FX_FLOAT device_y_f; - page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f, - device_y_f); + CFX_Matrix page2device = + GetDisplayMatrix(start_x, start_y, size_x, size_y, rotate); + page2device.Transform(static_cast(page_x), + static_cast(page_y), device_x_f, device_y_f); *device_x = FXSYS_round(device_x_f); *device_y = FXSYS_round(device_y_f); } -void CPDFXFA_Page::GetDisplayMatrix(CFX_Matrix& matrix, - int xPos, - int yPos, - int xSize, - int ySize, - int iRotate) const { +CFX_Matrix CPDFXFA_Page::GetDisplayMatrix(int xPos, + int yPos, + int xSize, + int ySize, + int iRotate) const { if (!m_pPDFPage && !m_pXFAPageView) - return; + return CFX_Matrix(); int nDocType = m_pContext->GetDocType(); switch (nDocType) { case DOCTYPE_DYNAMIC_XFA: { if (m_pXFAPageView) { - CFX_Rect rect(xPos, yPos, xSize, ySize); - m_pXFAPageView->GetDisplayMatrix(matrix, rect, iRotate); + return m_pXFAPageView->GetDisplayMatrix( + CFX_Rect(xPos, yPos, xSize, ySize), iRotate); } - } break; + break; + } case DOCTYPE_PDF: case DOCTYPE_STATIC_XFA: { - if (m_pPDFPage) { - m_pPDFPage->GetDisplayMatrix(matrix, xPos, yPos, xSize, ySize, iRotate); - } - } break; + if (m_pPDFPage) + return m_pPDFPage->GetDisplayMatrix(xPos, yPos, xSize, ySize, iRotate); + break; + } default: - return; + return CFX_Matrix(); } + return CFX_Matrix(); } diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.h b/fpdfsdk/fpdfxfa/cpdfxfa_page.h index 79158f4ea7..993885d59e 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.h @@ -60,12 +60,11 @@ class CPDFXFA_Page { int* device_x, int* device_y); - void GetDisplayMatrix(CFX_Matrix& matrix, - int xPos, - int yPos, - int xSize, - int ySize, - int iRotate) const; + CFX_Matrix GetDisplayMatrix(int xPos, + int yPos, + int xSize, + int ySize, + int iRotate) const; protected: // Refcounted class. -- cgit v1.2.3