summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-23 23:52:53 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-23 23:52:53 +0000
commit367ed462b51799c008795b19e886ccbed221b9be (patch)
tree3c94f25900ec5617954dbfd3e615e6a4751ddfcd /core/fpdfdoc
parentc1dde5d9b3da2af6e6f81df09ed41ab9c34bbde4 (diff)
downloadpdfium-367ed462b51799c008795b19e886ccbed221b9be.tar.xz
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 <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/cpdf_metadata_unittest.cpp16
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp4
2 files changed, 10 insertions, 10 deletions
diff --git a/core/fpdfdoc/cpdf_metadata_unittest.cpp b/core/fpdfdoc/cpdf_metadata_unittest.cpp
index 1a39948461..ed97b4f5bf 100644
--- a/core/fpdfdoc/cpdf_metadata_unittest.cpp
+++ b/core/fpdfdoc/cpdf_metadata_unittest.cpp
@@ -17,7 +17,7 @@ TEST(CPDF_MetadataTest, CheckSharedFormEmailAtTopLevel) {
"</node>";
CPDF_Stream stream;
- stream.SetData(reinterpret_cast<const uint8_t*>(data), strlen(data));
+ stream.SetData(ByteStringView(data).span());
CPDF_Metadata metadata(&stream);
auto results = metadata.CheckForSharedForm();
@@ -34,7 +34,7 @@ TEST(CPDF_MetadataTest, CheckSharedFormAcrobatAtTopLevel) {
"</node>";
CPDF_Stream stream;
- stream.SetData(reinterpret_cast<const uint8_t*>(data), strlen(data));
+ stream.SetData(ByteStringView(data).span());
CPDF_Metadata metadata(&stream);
auto results = metadata.CheckForSharedForm();
@@ -51,7 +51,7 @@ TEST(CPDF_MetadataTest, CheckSharedFormFilesystemAtTopLevel) {
"</node>";
CPDF_Stream stream;
- stream.SetData(reinterpret_cast<const uint8_t*>(data), strlen(data));
+ stream.SetData(ByteStringView(data).span());
CPDF_Metadata metadata(&stream);
auto results = metadata.CheckForSharedForm();
@@ -68,7 +68,7 @@ TEST(CPDF_MetadataTest, CheckSharedFormWithoutWorkflow) {
"</node>";
CPDF_Stream stream;
- stream.SetData(reinterpret_cast<const uint8_t*>(data), strlen(data));
+ stream.SetData(ByteStringView(data).span());
CPDF_Metadata metadata(&stream);
auto results = metadata.CheckForSharedForm();
@@ -86,7 +86,7 @@ TEST(CPDF_MetadataTest, CheckSharedFormAsChild) {
"</parent></grandparent>";
CPDF_Stream stream;
- stream.SetData(reinterpret_cast<const uint8_t*>(data), strlen(data));
+ stream.SetData(ByteStringView(data).span());
CPDF_Metadata metadata(&stream);
auto results = metadata.CheckForSharedForm();
@@ -100,7 +100,7 @@ TEST(CPDF_MetadataTest, CheckSharedFormAsNoAdhoc) {
"<node></node>";
CPDF_Stream stream;
- stream.SetData(reinterpret_cast<const uint8_t*>(data), strlen(data));
+ stream.SetData(ByteStringView(data).span());
CPDF_Metadata metadata(&stream);
auto results = metadata.CheckForSharedForm();
@@ -116,7 +116,7 @@ TEST(CPDF_MetadataTest, CheckSharedFormWrongNamespace) {
"</node>";
CPDF_Stream stream;
- stream.SetData(reinterpret_cast<const uint8_t*>(data), strlen(data));
+ stream.SetData(ByteStringView(data).span());
CPDF_Metadata metadata(&stream);
auto results = metadata.CheckForSharedForm();
@@ -146,7 +146,7 @@ TEST(CPDF_MetadataTest, CheckSharedFormMultipleErrors) {
"</grandparent>";
CPDF_Stream stream;
- stream.SetData(reinterpret_cast<const uint8_t*>(data), strlen(data));
+ stream.SetData(ByteStringView(data).span());
CPDF_Metadata metadata(&stream);
auto results = metadata.CheckForSharedForm();
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 7faa4bfeca..dc2f22d0e6 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -504,7 +504,7 @@ void GenerateAndSetAPDict(CPDF_Document* pDoc,
std::unique_ptr<CPDF_Dictionary> pResourceDict,
bool bIsTextMarkupAnnotation) {
CPDF_Stream* pNormalStream = pDoc->NewIndirect<CPDF_Stream>();
- pNormalStream->SetData(psAppStream);
+ pNormalStream->SetDataFromStringstream(psAppStream);
CPDF_Dictionary* pAPDict = pAnnotDict->GetDictFor("AP");
if (!pAPDict)
@@ -1300,7 +1300,7 @@ void CPVT_GenerateAP::GenerateFormAP(Type type,
}
if (pNormalStream) {
- pNormalStream->SetDataAndRemoveFilter(&sAppStream);
+ pNormalStream->SetDataFromStringstreamAndRemoveFilter(&sAppStream);
pStreamDict = pNormalStream->GetDict();
if (pStreamDict) {
pStreamDict->SetMatrixFor("Matrix", matrix);