summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_ppo.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-02-09 22:28:49 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-09 22:28:49 +0000
commit257900b6dae0fe8d82d48ecc91d92e5dbb3a28bf (patch)
treee3b53963f47cb34166baafb5eb17b07d1c66c9fe /fpdfsdk/fpdf_ppo.cpp
parentbc5dd9e7901ee56e0db66e76bf2e4903ab3d3fcd (diff)
downloadpdfium-257900b6dae0fe8d82d48ecc91d92e5dbb3a28bf.tar.xz
Use CPDF_Dictionary::SetRectFor() when appropriate.
Change-Id: I4ced221fb5691927485deceb7002dac880c2c210 Reviewed-on: https://pdfium-review.googlesource.com/26110 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_ppo.cpp')
-rw-r--r--fpdfsdk/fpdf_ppo.cpp24
1 files changed, 5 insertions, 19 deletions
diff --git a/fpdfsdk/fpdf_ppo.cpp b/fpdfsdk/fpdf_ppo.cpp
index 5499ecc222..ac60a3af3a 100644
--- a/fpdfsdk/fpdf_ppo.cpp
+++ b/fpdfsdk/fpdf_ppo.cpp
@@ -490,11 +490,8 @@ bool CPDF_PageExporter::ExportPage(const std::vector<uint32_t>& pageNums,
pCurPageDict->SetFor("MediaBox", pInheritable->Clone());
} else {
// Make the default size letter size (8.5"x11")
- CPDF_Array* pArray = pCurPageDict->SetNewFor<CPDF_Array>("MediaBox");
- pArray->AddNew<CPDF_Number>(0);
- pArray->AddNew<CPDF_Number>(0);
- pArray->AddNew<CPDF_Number>(612);
- pArray->AddNew<CPDF_Number>(792);
+ static const CFX_FloatRect kDefaultLetterRect(0, 0, 612, 792);
+ pCurPageDict->SetRectFor("MediaBox", kDefaultLetterRect);
}
}
@@ -547,9 +544,6 @@ class CPDF_NPageToOneExporter : public CPDF_PageOrganizer {
// Map XObject's object name to it's object number.
using XObjectNameNumberMap = std::map<ByteString, uint32_t>;
- static void SetMediaBox(CPDF_Dictionary* pDestPageDict,
- const CFX_SizeF& pagesize);
-
// Creates a xobject from the source page dictionary, and appends the
// bsContent string with the xobject reference surrounded by the
// transformation matrix.
@@ -602,6 +596,8 @@ bool CPDF_NPageToOneExporter::ExportNPagesToOne(
NupState nupState(destPageSize, numPagesOnXAxis, numPagesOnYAxis);
size_t curpage = 0;
+ const CFX_FloatRect destPageRect(0, 0, destPageSize.width,
+ destPageSize.height);
for (size_t outerPage = 0; outerPage < pageNums.size();
outerPage += numPagesPerSheet) {
// Create a new page
@@ -609,7 +605,7 @@ bool CPDF_NPageToOneExporter::ExportNPagesToOne(
if (!pCurPageDict)
return false;
- SetMediaBox(pCurPageDict, destPageSize);
+ pCurPageDict->SetRectFor("MediaBox", destPageRect);
ByteString bsContent;
size_t innerPageMax =
std::min(outerPage + numPagesPerSheet, pageNums.size());
@@ -635,16 +631,6 @@ bool CPDF_NPageToOneExporter::ExportNPagesToOne(
return true;
}
-// static
-void CPDF_NPageToOneExporter::SetMediaBox(CPDF_Dictionary* pDestPageDict,
- const CFX_SizeF& pagesize) {
- CPDF_Array* pArray = pDestPageDict->SetNewFor<CPDF_Array>("MediaBox");
- pArray->AddNew<CPDF_Number>(0);
- pArray->AddNew<CPDF_Number>(0);
- pArray->AddNew<CPDF_Number>(pagesize.width);
- pArray->AddNew<CPDF_Number>(pagesize.height);
-}
-
void CPDF_NPageToOneExporter::AddSubPage(
CPDF_Dictionary* pPageDict,
const NupPageSettings& settings,