Hi all,

       I added 2 new constructors for LinkRendition class. So that it will
be helpful to add Rendition actions for the screen annotation.
Please give all your suggestions.

Thanks
--
A Srinivas
Index: poppler-0.16.2/poppler/Link.cc
===================================================================
--- poppler-0.16.2/poppler/Link.cc	(revision 14)
+++ poppler-0.16.2/poppler/Link.cc	(working copy)
@@ -44,6 +44,7 @@
 #include "Sound.h"
 #include "FileSpec.h"
 #include "Rendition.h"
+#include "XRef.h"
 
 //------------------------------------------------------------------------
 // LinkAction
@@ -738,6 +739,46 @@
   }
 }
 
+LinkRendition::LinkRendition(XRef *xrefA, MediaRendition *rendition, int op, Annot *annot) {
+  operation = op;
+  media = rendition;
+  js = NULL;
+
+  Object obj;
+  Ref annotRef = annot->getRef();
+  renditionObj.initDict(xrefA);
+  renditionObj.dictSet("Type", obj.initName("Action"));
+  renditionObj.dictSet("S", obj.initName("Rendition"));
+  renditionObj.dictSet("OP", obj.initInt(op));
+  renditionObj.dictSet("AN", obj.initRef(annotRef.num, annotRef.gen));
+
+  Ref newRef = rendition->getRef();
+  obj.initRef(newRef.num, newRef.gen);
+  renditionObj.dictSet("R", &obj);
+  ref = xrefA->addIndirectObject(&renditionObj);
+}
+
+LinkRendition::LinkRendition(XRef *xrefA, Object *jsObj) {
+  operation = -1;
+  media = NULL;
+  js = NULL;
+
+  Object obj;
+  renditionObj.initDict(xrefA);
+  renditionObj.dictSet("Type", obj.initName("Action"));
+  renditionObj.dictSet("S", obj.initName("Rendition"));
+  renditionObj.dictSet("JS", jsObj);
+  ref = xrefA->addIndirectObject(&renditionObj);
+
+  if (jsObj->isString())
+    js = new GooString(jsObj->getString());
+  else {
+    Stream *stream = jsObj->getStream();
+    js = new GooString();
+    stream->fillGooString(js);
+  }
+}
+
 LinkRendition::~LinkRendition() {
   renditionObj.free();
   screenRef.free();
Index: poppler-0.16.2/poppler/Link.h
===================================================================
--- poppler-0.16.2/poppler/Link.h	(revision 14)
+++ poppler-0.16.2/poppler/Link.h	(working copy)
@@ -37,6 +37,7 @@
 class Dict;
 class Sound;
 class MediaRendition;
+class Annot;
 
 //------------------------------------------------------------------------
 // LinkAction
@@ -68,6 +69,9 @@
   // Check link action type.
   virtual LinkActionKind getKind() = 0;
 
+  // Get the reference object of the corresponding action
+  virtual Ref getRef() {};
+
   // Parse a destination (old-style action) name, string, or array.
   static LinkAction *parseDest(Object *obj);
 
@@ -317,6 +321,8 @@
 public:
 
   LinkRendition(Object *Obj);
+  LinkRendition(XRef *xrefA, MediaRendition *rendition, int op, Annot *annot);
+  LinkRendition(XRef *xrefA, Object *js);
 
   virtual ~LinkRendition();
 
@@ -327,6 +333,9 @@
   GBool hasRenditionObject() { return renditionObj.isDict(); }
   Object* getRenditionObject() { return &renditionObj; }
 
+  // Get the reference of the Rendition action object
+  Ref getRef() { return ref; }
+
   GBool hasScreenAnnot() { return screenRef.isRef(); }
   Ref getScreenAnnot() { return screenRef.getRef(); }
 
@@ -341,6 +350,7 @@
   Object screenRef;
   Object renditionObj;
   int operation;
+  Ref ref; // reference to the renditionObj
 
   MediaRendition* media;
 
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to