summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-02-09 09:17:20 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-09 15:04:51 +0000
commit1b08df18300bbc67dabd12fb35ab6ce1732a1024 (patch)
tree9773931c8d18709860c9fbc1177e290e7713044e /fpdfsdk
parentac2e04797b258115b2dc768a56377d7e78038f42 (diff)
downloadpdfium-1b08df18300bbc67dabd12fb35ab6ce1732a1024.tar.xz
Convert Get methods to return instead of using out params.
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 <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cpdfsdk_xfawidgethandler.cpp4
-rw-r--r--fpdfsdk/fpdfformfill.cpp8
-rw-r--r--fpdfsdk/fpdfview.cpp37
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.cpp83
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.h11
5 files changed, 69 insertions, 74 deletions
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<CFX_FxgeDevice> 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<FX_FLOAT>(device_x),
+ static_cast<FX_FLOAT>(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<FX_FLOAT>(page_x),
+ static_cast<FX_FLOAT>(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<FX_FLOAT>(device_x),
+ static_cast<FX_FLOAT>(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<FX_FLOAT>(page_x),
+ static_cast<FX_FLOAT>(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.