summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_flatten.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-09-21 19:10:19 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-21 19:10:19 -0700
commitbb577af2f17467a55c04fbff21a8f0ec1016601a (patch)
tree5a5321b1aff1bcc6ee6dc19928aa729a4ddc9a3d /fpdfsdk/fpdf_flatten.cpp
parent7149abce42b211ad3c0eaa39a340825acd41a1ec (diff)
downloadpdfium-bb577af2f17467a55c04fbff21a8f0ec1016601a.tar.xz
Remove some objnum locals with AddIndirectObject
Also, it's idempotent, so simplify some logic in callers to not care if objnum is zero. The alternate forms are rarely used, using the objnum form makes it clear that SetReferenceFor() can't possibly register the object as a side-effect. Review-Url: https://codereview.chromium.org/2361713002
Diffstat (limited to 'fpdfsdk/fpdf_flatten.cpp')
-rw-r--r--fpdfsdk/fpdf_flatten.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp
index aa21b280ed..5ee485855b 100644
--- a/fpdfsdk/fpdf_flatten.cpp
+++ b/fpdfsdk/fpdf_flatten.cpp
@@ -195,12 +195,11 @@ void SetPageContents(CFX_ByteString key,
if (!key.IsEmpty()) {
CPDF_Stream* pNewContents =
new CPDF_Stream(nullptr, 0, new CPDF_Dictionary);
- pPage->SetReferenceFor("Contents", pDocument,
- pDocument->AddIndirectObject(pNewContents));
-
CFX_ByteString sStream;
sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str());
pNewContents->SetData(sStream.raw_str(), sStream.GetLength());
+ pPage->SetReferenceFor("Contents", pDocument,
+ pDocument->AddIndirectObject(pNewContents));
}
return;
}
@@ -234,18 +233,17 @@ void SetPageContents(CFX_ByteString key,
if (!pContentsArray)
return;
- uint32_t dwObjNum = pDocument->AddIndirectObject(pContentsArray);
- pPage->SetReferenceFor("Contents", pDocument, dwObjNum);
+ pPage->SetReferenceFor("Contents", pDocument,
+ pDocument->AddIndirectObject(pContentsArray));
if (!key.IsEmpty()) {
CPDF_Stream* pNewContents =
new CPDF_Stream(nullptr, 0, new CPDF_Dictionary);
- dwObjNum = pDocument->AddIndirectObject(pNewContents);
- pContentsArray->AddReference(pDocument, dwObjNum);
-
CFX_ByteString sStream;
sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str());
pNewContents->SetData(sStream.raw_str(), sStream.GetLength());
+ pContentsArray->AddReference(pDocument,
+ pDocument->AddIndirectObject(pNewContents));
}
}
@@ -482,15 +480,14 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
CFX_ByteString sFormName;
sFormName.Format("F%d", i);
- uint32_t dwStreamObjNum = pDocument->AddIndirectObject(pObj);
- pXObject->SetReferenceFor(sFormName, pDocument, dwStreamObjNum);
+ pXObject->SetReferenceFor(sFormName, pDocument,
+ pDocument->AddIndirectObject(pObj));
CPDF_StreamAcc acc;
acc.LoadAllData(pNewXObject);
const uint8_t* pData = acc.GetData();
CFX_ByteString sStream(pData, acc.GetSize());
- CFX_ByteString sTemp;
if (matrix.IsIdentity()) {
matrix.a = 1.0f;
@@ -501,6 +498,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
matrix.f = 0.0f;
}
+ CFX_ByteString sTemp;
CFX_Matrix m = GetMatrix(rcAnnot, rcStream, matrix);
sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f,
sFormName.c_str());