]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/xpdf/Object.cc
Scroll at the top of the page when changing page
[evince.git] / pdf / xpdf / Object.cc
index 777f5262dc54679f72289f4616d73375a867cf82..ddd6da693cd771902347191b52efff2197366b76 100644 (file)
@@ -2,11 +2,13 @@
 //
 // Object.cc
 //
 //
 // Object.cc
 //
-// Copyright 1996 Derek B. Noonburg
+// Copyright 1996-2003 Glyph & Cog, LLC
 //
 //========================================================================
 
 //
 //========================================================================
 
-#ifdef __GNUC__
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
 #pragma implementation
 #endif
 
 #pragma implementation
 #endif
 
@@ -44,21 +46,28 @@ int Object::numAlloc[numObjTypes] =
   {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 #endif
 
   {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 #endif
 
-Object *Object::initArray() {
+Object *Object::initArray(XRef *xref) {
   initObj(objArray);
   initObj(objArray);
-  array = new Array();
+  array = new Array(xref);
+  return this;
+}
+
+Object *Object::initDict(XRef *xref) {
+  initObj(objDict);
+  dict = new Dict(xref);
   return this;
 }
 
   return this;
 }
 
-Object *Object::initDict() {
+Object *Object::initDict(Dict *dictA) {
   initObj(objDict);
   initObj(objDict);
-  dict = new Dict();
+  dict = dictA;
+  dict->incRef();
   return this;
 }
 
   return this;
 }
 
-Object *Object::initStream(Stream *stream1) {
+Object *Object::initStream(Stream *streamA) {
   initObj(objStream);
   initObj(objStream);
-  stream = stream1;
+  stream = streamA;
   return this;
 }
 
   return this;
 }
 
@@ -92,7 +101,7 @@ Object *Object::copy(Object *obj) {
   return obj;
 }
 
   return obj;
 }
 
-Object *Object::fetch(Object *obj) {
+Object *Object::fetch(XRef *xref, Object *obj) {
   return (type == objRef && xref) ?
          xref->fetch(ref.num, ref.gen, obj) : copy(obj);
 }
   return (type == objRef && xref) ?
          xref->fetch(ref.num, ref.gen, obj) : copy(obj);
 }
@@ -106,16 +115,19 @@ void Object::free() {
     gfree(name);
     break;
   case objArray:
     gfree(name);
     break;
   case objArray:
-    if (!array->decRef())
+    if (!array->decRef()) {
       delete array;
       delete array;
+    }
     break;
   case objDict:
     break;
   case objDict:
-    if (!dict->decRef())
+    if (!dict->decRef()) {
       delete dict;
       delete dict;
+    }
     break;
   case objStream:
     break;
   case objStream:
-    if (!stream->decRef())
+    if (!stream->decRef()) {
       delete stream;
       delete stream;
+    }
     break;
   case objCmd:
     gfree(cmd);
     break;
   case objCmd:
     gfree(cmd);
@@ -148,7 +160,9 @@ void Object::print(FILE *f) {
     fprintf(f, "%g", real);
     break;
   case objString:
     fprintf(f, "%g", real);
     break;
   case objString:
-    fprintf(f, "(%s)", string->getCString());
+    fprintf(f, "(");
+    fwrite(string->getCString(), 1, string->getLength(), stdout);
+    fprintf(f, ")");
     break;
   case objName:
     fprintf(f, "/%s", name);
     break;
   case objName:
     fprintf(f, "/%s", name);