[PDF] Fix bug in catalog substitution.

Review URL: http://codereview.appspot.com/4816051

git-svn-id: http://skia.googlecode.com/svn/trunk@1955 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFCatalog.cpp b/src/pdf/SkPDFCatalog.cpp
index 420ce40..794bbf5 100644
--- a/src/pdf/SkPDFCatalog.cpp
+++ b/src/pdf/SkPDFCatalog.cpp
@@ -50,7 +50,7 @@
     SkASSERT(fCatalog[objIndex].fFileOffset == 0);
     fCatalog[objIndex].fFileOffset = offset;
 
-    return obj->getOutputSize(this, true);
+    return getSubstituteObject(obj)->getOutputSize(this, true);
 }
 
 void SkPDFCatalog::emitObjectNumber(SkWStream* stream, SkPDFObject* obj) {
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index b3f5105..8dabaf5 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -227,6 +227,11 @@
     proxy->emit(&buffer, &catalog, false);
     catalog.emitSubstituteResources(&buffer, false);
 
+    char objectResult[] = "2 0 obj\n<</Value 33\n>>\nendobj\n";
+    REPORTER_ASSERT(
+        reporter,
+        catalog.setFileOffset(proxy.get(), 0) == strlen(objectResult));
+
     char expectedResult[] =
         "<</Value 33\n>>1 0 obj\n<</InnerValue 44\n>>\nendobj\n";
     REPORTER_ASSERT(reporter, buffer.getOffset() == strlen(expectedResult));