[PDF] Add a concept of a substitute object to the SkPDFCatalog class.
Code by Arthur Hsu, original code review: http://codereview.appspot.com/4650060/
Review URL: http://codereview.appspot.com/4639102
git-svn-id: http://skia.googlecode.com/svn/trunk@1812 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index fce100b..faa9360 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -78,14 +78,14 @@
fDocCatalog->insert("OutputIntent", intentArray.get());
*/
- bool first_page = true;
+ bool firstPage = true;
for (int i = 0; i < fPages.count(); i++) {
int resourceCount = fPageResources.count();
- fPages[i]->finalizePage(&fCatalog, first_page, &fPageResources);
- addResourcesToCatalog(resourceCount, first_page, &fPageResources,
- &fCatalog);
+ fPages[i]->finalizePage(&fCatalog, firstPage, &fPageResources);
+ addResourcesToCatalog(resourceCount, firstPage, &fPageResources,
+ &fCatalog);
if (i == 0) {
- first_page = false;
+ firstPage = false;
fSecondPageFirstResourceIndex = fPageResources.count();
}
}
@@ -97,6 +97,8 @@
fileOffset += fPages[0]->getPageSize(&fCatalog, fileOffset);
for (int i = 0; i < fSecondPageFirstResourceIndex; i++)
fileOffset += fCatalog.setFileOffset(fPageResources[i], fileOffset);
+ // Add the size of resources of substitute objects used on page 1.
+ fileOffset += fCatalog.setSubstituteResourcesOffsets(fileOffset, true);
if (fPages.count() > 1) {
// TODO(vandebo) For linearized format, save the start of the
// first page xref table and calculate the size.
@@ -113,6 +115,7 @@
i++)
fileOffset += fCatalog.setFileOffset(fPageResources[i], fileOffset);
+ fileOffset += fCatalog.setSubstituteResourcesOffsets(fileOffset, false);
fXRefFileOffset = fileOffset;
}
@@ -121,7 +124,8 @@
fPages[0]->emitObject(stream, &fCatalog, true);
fPages[0]->emitPage(stream, &fCatalog);
for (int i = 0; i < fSecondPageFirstResourceIndex; i++)
- fPageResources[i]->emitObject(stream, &fCatalog, true);
+ fPageResources[i]->emit(stream, &fCatalog, true);
+ fCatalog.emitSubstituteResources(stream, true);
// TODO(vandebo) support linearized format
//if (fPages.size() > 1) {
// // TODO(vandebo) save the file offset for the first page xref table.
@@ -135,8 +139,9 @@
fPages[i]->emitPage(stream, &fCatalog);
for (int i = fSecondPageFirstResourceIndex; i < fPageResources.count(); i++)
- fPageResources[i]->emitObject(stream, &fCatalog, true);
+ fPageResources[i]->emit(stream, &fCatalog, true);
+ fCatalog.emitSubstituteResources(stream, false);
int64_t objCount = fCatalog.emitXrefTable(stream, fPages.count() > 1);
emitFooter(stream, objCount);
return true;