[PDF] Clean up SkPDFStream and make it inherit from SkPDFDict.

A stream is a dictionary (with a couple particular entries) plus the data.
The common parent is useful for the shader implementation.

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

git-svn-id: http://skia.googlecode.com/svn/trunk@852 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/pdf/SkPDFStream.h b/include/pdf/SkPDFStream.h
index 5310b4e..35e199f 100644
--- a/include/pdf/SkPDFStream.h
+++ b/include/pdf/SkPDFStream.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2010 Google Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,8 +28,7 @@
 
     A stream object in a PDF.
 */
-// TODO(vandebo) This should handle filters as well.
-class SkPDFStream : public SkPDFObject {
+class SkPDFStream : public SkPDFDict {
 public:
     /** Create a PDF stream. A Length entry is automatically added to the
      *  stream dictionary.
@@ -43,26 +42,13 @@
                             bool indirect);
     virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect);
 
-    /** Add the value to the stream dictionary with the given key.  Refs value.
-     *  @param key   The key for this dictionary entry.
-     *  @param value The value for this dictionary entry.
-     *  @return The value argument is returned.
-     */
-    SkPDFObject* insert(SkPDFName* key, SkPDFObject* value);
-
-    /** Add the value to the stream dictionary with the given key.  Refs value.
-     *  @param key   The text of the key for this dictionary entry.
-     *  @param value The value for this dictionary entry.
-     *  @return The value argument is returned.
-     */
-    SkPDFObject* insert(const char key[], SkPDFObject* value);
-
 private:
-    SkPDFDict fDict;
     size_t fLength;
     // Only one of the two streams will be valid.
     SkRefPtr<SkStream> fPlainData;
     SkDynamicMemoryWStream fCompressedData;
+
+    typedef SkPDFDict INHERITED;
 };
 
 #endif
diff --git a/src/pdf/SkPDFStream.cpp b/src/pdf/SkPDFStream.cpp
index 9e9859b..b1bd5ff 100644
--- a/src/pdf/SkPDFStream.cpp
+++ b/src/pdf/SkPDFStream.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2010 Google Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,13 +26,13 @@
     if (SkFlate::HaveFlate() &&
             fCompressedData.getOffset() < stream->getLength()) {
         fLength = fCompressedData.getOffset();
-        fDict.insert("Filter", new SkPDFName("FlateDecode"))->unref();
+        insert("Filter", new SkPDFName("FlateDecode"))->unref();
     } else {
         fCompressedData.reset();
         fPlainData = stream;
         fLength = fPlainData->getLength();
     }
-    fDict.insert("Length", new SkPDFInt(fLength))->unref();
+    insert("Length", new SkPDFInt(fLength))->unref();
 }
 
 SkPDFStream::~SkPDFStream() {
@@ -43,7 +43,7 @@
     if (indirect)
         return emitIndirectObject(stream, catalog);
 
-    fDict.emitObject(stream, catalog, false);
+    this->INHERITED::emitObject(stream, catalog, false);
     stream->writeText(" stream\n");
     if (fPlainData.get())
         stream->write(fPlainData->getMemoryBase(), fLength);
@@ -56,14 +56,6 @@
     if (indirect)
         return getIndirectOutputSize(catalog);
 
-    return fDict.getOutputSize(catalog, false) +
+    return this->INHERITED::getOutputSize(catalog, false) +
         strlen(" stream\n\nendstream") + fLength;
 }
-
-SkPDFObject* SkPDFStream::insert(SkPDFName* key, SkPDFObject* value) {
-    return fDict.insert(key, value);
-}
-
-SkPDFObject* SkPDFStream::insert(const char key[], SkPDFObject* value) {
-    return fDict.insert(key, value);
-}