From 367ed462b51799c008795b19e886ccbed221b9be Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 23 Aug 2018 23:52:53 +0000 Subject: Use pdfium::span<> in CPDF_Stream::SetData(). Conversion to span makes this more elegant in a number of places, owing to std::vector directly converting to span, and the bytestring's ToRawSpan(). Disambiguate single-argument forms to allow passing {} as an argument. Change-Id: Ibd5eaadca8d8cbbd589338f375c7ee8439fd3eb2 Reviewed-on: https://pdfium-review.googlesource.com/41272 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- fpdfsdk/fpdf_flatten.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'fpdfsdk/fpdf_flatten.cpp') diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp index b9e29be8b4..7ea49cfddf 100644 --- a/fpdfsdk/fpdf_flatten.cpp +++ b/fpdfsdk/fpdf_flatten.cpp @@ -176,7 +176,7 @@ CPDF_Object* NewIndirectContentsStream(const ByteString& key, pdfium::MakeUnique(pDocument->GetByteStringPool())); ByteString sStream = ByteString::Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); - pNewContents->SetData(sStream.raw_str(), sStream.GetLength()); + pNewContents->SetData(sStream.AsRawSpan()); return pNewContents; } @@ -205,8 +205,7 @@ void SetPageContents(const ByteString& key, ByteString sStream = "q\n"; ByteString sBody = ByteString(pAcc->GetData(), pAcc->GetSize()); sStream = sStream + sBody + "\nQ"; - pContentsStream->SetDataAndRemoveFilter(sStream.raw_str(), - sStream.GetLength()); + pContentsStream->SetDataAndRemoveFilter(sStream.AsRawSpan()); pContentsArray->Add(pContentsStream->MakeReference(pDocument)); pPage->SetFor(pdfium::page_object::kContents, pContentsArray->MakeReference(pDocument)); @@ -394,7 +393,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { CFX_Matrix m = GetMatrix(rcAnnot, rcStream, matrix); sStream += ByteString::Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f, sFormName.c_str()); - pNewXObject->SetDataAndRemoveFilter(sStream.raw_str(), sStream.GetLength()); + pNewXObject->SetDataAndRemoveFilter(sStream.AsRawSpan()); } pPageDict->RemoveFor("Annots"); return FLATTEN_SUCCESS; -- cgit v1.2.3