summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp11
-rw-r--r--testing/resources/hello_world_split_streams.in2
-rw-r--r--testing/resources/hello_world_split_streams.pdf6
3 files changed, 12 insertions, 7 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index ba31516f4a..88f14b2ce4 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -30,6 +30,7 @@
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
+#include "third_party/base/stl_util.h"
#include "third_party/skia_shared/SkFloatToDecimal.h"
namespace {
@@ -77,7 +78,7 @@ void CPDF_PageContentGenerator::GenerateContent() {
std::map<int32_t, std::unique_ptr<std::ostringstream>>
CPDF_PageContentGenerator::GenerateModifiedStreams() {
// Make sure default graphics are created.
- (void)GetOrCreateDefaultGraphics();
+ GetOrCreateDefaultGraphics();
// Figure out which streams are dirty.
std::set<int32_t> all_dirty_streams;
@@ -92,7 +93,7 @@ CPDF_PageContentGenerator::GenerateModifiedStreams() {
// Start regenerating dirty streams.
std::map<int32_t, std::unique_ptr<std::ostringstream>> streams;
- std::map<int32_t, bool> stream_is_empty;
+ std::set<int32_t> empty_streams;
for (int32_t dirty_stream : all_dirty_streams) {
std::unique_ptr<std::ostringstream> buf =
@@ -106,7 +107,7 @@ CPDF_PageContentGenerator::GenerateModifiedStreams() {
ProcessDefaultGraphics(buf.get());
streams[dirty_stream] = std::move(buf);
- stream_is_empty[dirty_stream] = true;
+ empty_streams.insert(dirty_stream);
}
// Process the page objects, write into each dirty stream.
@@ -117,14 +118,14 @@ CPDF_PageContentGenerator::GenerateModifiedStreams() {
continue;
std::ostringstream* buf = it->second.get();
- stream_is_empty[stream_index] = false;
+ empty_streams.erase(stream_index);
ProcessPageObject(buf, pPageObj.Get());
}
// Finish dirty streams.
for (int32_t dirty_stream : all_dirty_streams) {
std::ostringstream* buf = streams[dirty_stream].get();
- if (stream_is_empty[dirty_stream]) {
+ if (pdfium::ContainsKey(empty_streams, dirty_stream)) {
// Clear to show that this stream needs to be deleted.
buf->str("");
} else {
diff --git a/testing/resources/hello_world_split_streams.in b/testing/resources/hello_world_split_streams.in
index c7a29352f1..667dd36fb7 100644
--- a/testing/resources/hello_world_split_streams.in
+++ b/testing/resources/hello_world_split_streams.in
@@ -36,6 +36,7 @@ endobj
>>
endobj
{{object 6 0}} <<
+ {{streamlen}}
>>
stream
BT
@@ -49,6 +50,7 @@ ET
endstream
endobj
{{object 7 0}} <<
+ {{streamlen}}
>>
stream
BT
diff --git a/testing/resources/hello_world_split_streams.pdf b/testing/resources/hello_world_split_streams.pdf
index 969fccf7de..824f003d98 100644
--- a/testing/resources/hello_world_split_streams.pdf
+++ b/testing/resources/hello_world_split_streams.pdf
@@ -37,6 +37,7 @@ endobj
>>
endobj
6 0 obj <<
+ /Length 83
>>
stream
BT
@@ -50,6 +51,7 @@ ET
endstream
endobj
7 0 obj <<
+ /Length 45
>>
stream
BT
@@ -67,11 +69,11 @@ xref
0000000311 00000 n
0000000389 00000 n
0000000465 00000 n
-0000000586 00000 n
+0000000599 00000 n
trailer <<
/Root 1 0 R
/Size 8
>>
startxref
-669
+695
%%EOF