]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/xpdf/Link.h
Scroll at the top of the page when changing page
[evince.git] / pdf / xpdf / Link.h
index 62a4c85e57dfcfc87d1ac486ef48f817778fe5c6..aa8727faec7eb3f15cbba32494f365c44b884923 100644 (file)
@@ -2,14 +2,16 @@
 //
 // Link.h
 //
 //
 // Link.h
 //
-// Copyright 1996 Derek B. Noonburg
+// Copyright 1996-2003 Glyph & Cog, LLC
 //
 //========================================================================
 
 #ifndef LINK_H
 #define LINK_H
 
 //
 //========================================================================
 
 #ifndef LINK_H
 #define LINK_H
 
-#ifdef __GNUC__
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
 #pragma interface
 #endif
 
 #pragma interface
 #endif
 
@@ -28,6 +30,8 @@ enum LinkActionKind {
   actionGoToR,                 // go to destination in new file
   actionLaunch,                        // launch app (or open document)
   actionURI,                   // URI
   actionGoToR,                 // go to destination in new file
   actionLaunch,                        // launch app (or open document)
   actionURI,                   // URI
+  actionNamed,                 // named action
+  actionMovie,                 // movie action
   actionUnknown                        // anything else
 };
 
   actionUnknown                        // anything else
 };
 
@@ -42,6 +46,16 @@ public:
 
   // Check link action type.
   virtual LinkActionKind getKind() = 0;
 
   // Check link action type.
   virtual LinkActionKind getKind() = 0;
+
+  // Parse a destination (old-style action) name, string, or array.
+  static LinkAction *parseDest(Object *obj);
+
+  // Parse an action dictionary.
+  static LinkAction *parseAction(Object *obj, GString *baseURI = NULL);
+
+  // Extract a file name from a file specification (string or
+  // dictionary).
+  static GString *getFileSpecName(Object *fileSpecObj);
 };
 
 //------------------------------------------------------------------------
 };
 
 //------------------------------------------------------------------------
@@ -62,10 +76,8 @@ enum LinkDestKind {
 class LinkDest {
 public:
 
 class LinkDest {
 public:
 
-  // Build a LinkDest from the array.  If <pageIsRef> is true, the
-  // page is specified by an object reference; otherwise the page is
-  // specified by a (zero-relative) page number.
-  LinkDest(Array *a, GBool pageIsRef1);
+  // Build a LinkDest from the array.
+  LinkDest(Array *a);
 
   // Copy a LinkDest.
   LinkDest *copy() { return new LinkDest(this); }
 
   // Copy a LinkDest.
   LinkDest *copy() { return new LinkDest(this); }
@@ -200,8 +212,8 @@ private:
 class LinkURI: public LinkAction {
 public:
 
 class LinkURI: public LinkAction {
 public:
 
-  // Build a LinkURI given the URI (string).
-  LinkURI(Object *uriObj);
+  // Build a LinkURI given the URI (string) and base URI.
+  LinkURI(Object *uriObj, GString *baseURI);
 
   // Destructor.
   virtual ~LinkURI();
 
   // Destructor.
   virtual ~LinkURI();
@@ -218,6 +230,52 @@ private:
   GString *uri;                        // the URI
 };
 
   GString *uri;                        // the URI
 };
 
+//------------------------------------------------------------------------
+// LinkNamed
+//------------------------------------------------------------------------
+
+class LinkNamed: public LinkAction {
+public:
+
+  // Build a LinkNamed given the action name.
+  LinkNamed(Object *nameObj);
+
+  virtual ~LinkNamed();
+
+  virtual GBool isOk() { return name != NULL; }
+
+  virtual LinkActionKind getKind() { return actionNamed; }
+  GString *getName() { return name; }
+
+private:
+
+  GString *name;
+};
+
+//------------------------------------------------------------------------
+// LinkMovie
+//------------------------------------------------------------------------
+
+class LinkMovie: public LinkAction {
+public:
+
+  LinkMovie(Object *annotObj, Object *titleObj);
+
+  virtual ~LinkMovie();
+
+  virtual GBool isOk() { return annotRef.num >= 0 || title != NULL; }
+
+  virtual LinkActionKind getKind() { return actionMovie; }
+  GBool hasAnnotRef() { return annotRef.num >= 0; }
+  Ref *getAnnotRef() { return &annotRef; }
+  GString *getTitle() { return title; }
+
+private:
+
+  Ref annotRef;
+  GString *title;
+};
+
 //------------------------------------------------------------------------
 // LinkUnknown
 //------------------------------------------------------------------------
 //------------------------------------------------------------------------
 // LinkUnknown
 //------------------------------------------------------------------------
@@ -226,7 +284,7 @@ class LinkUnknown: public LinkAction {
 public:
 
   // Build a LinkUnknown with the specified action type.
 public:
 
   // Build a LinkUnknown with the specified action type.
-  LinkUnknown(char *action1);
+  LinkUnknown(char *actionA);
 
   // Destructor.
   virtual ~LinkUnknown();
 
   // Destructor.
   virtual ~LinkUnknown();
@@ -243,6 +301,42 @@ private:
   GString *action;             // action subtype
 };
 
   GString *action;             // action subtype
 };
 
+//------------------------------------------------------------------------
+// LinkBorderStyle
+//------------------------------------------------------------------------
+
+enum LinkBorderType {
+  linkBorderSolid,
+  linkBorderDashed,
+  linkBorderEmbossed,
+  linkBorderEngraved,
+  linkBorderUnderlined
+};
+
+class LinkBorderStyle {
+public:
+
+  LinkBorderStyle(LinkBorderType typeA, double widthA,
+                 double *dashA, int dashLengthA,
+                 double rA, double gA, double bA);
+  ~LinkBorderStyle();
+
+  LinkBorderType getType() { return type; }
+  double getWidth() { return width; }
+  void getDash(double **dashA, int *dashLengthA)
+    { *dashA = dash; *dashLengthA = dashLength; }
+  void getColor(double *rA, double *gA, double *bA)
+    { *rA = r; *gA = g; *bA = b; }
+
+private:
+
+  LinkBorderType type;
+  double width;
+  double *dash;
+  int dashLength;
+  double r, g, b;
+};
+
 //------------------------------------------------------------------------
 // Link
 //------------------------------------------------------------------------
 //------------------------------------------------------------------------
 // Link
 //------------------------------------------------------------------------
@@ -251,7 +345,7 @@ class Link {
 public:
 
   // Construct a link, given its dictionary.
 public:
 
   // Construct a link, given its dictionary.
-  Link(Dict *dict);
+  Link(Dict *dict, GString *baseURI);
 
   // Destructor.
   ~Link();
 
   // Destructor.
   ~Link();
@@ -266,16 +360,18 @@ public:
   // Get action.
   LinkAction *getAction() { return action; }
 
   // Get action.
   LinkAction *getAction() { return action; }
 
-  // Get border corners and width.
-  void getBorder(double *xa1, double *ya1, double *xa2, double *ya2,
-                double *wa)
-    { *xa1 = x1; *ya1 = y1; *xa2 = x2; *ya2 = y2; *wa = borderW; }
+  // Get the link rectangle.
+  void getRect(double *xa1, double *ya1, double *xa2, double *ya2)
+    { *xa1 = x1; *ya1 = y1; *xa2 = x2; *ya2 = y2; }
+
+  // Get the border style info.
+  LinkBorderStyle *getBorderStyle() { return borderStyle; }
 
 private:
 
   double x1, y1;               // lower left corner
   double x2, y2;               // upper right corner
 
 private:
 
   double x1, y1;               // lower left corner
   double x2, y2;               // upper right corner
-  double borderW;              // border width
+  LinkBorderStyle *borderStyle;        // border style
   LinkAction *action;          // action
   GBool ok;                    // is link valid?
 };
   LinkAction *action;          // action
   GBool ok;                    // is link valid?
 };
@@ -288,21 +384,21 @@ class Links {
 public:
 
   // Extract links from array of annotations.
 public:
 
   // Extract links from array of annotations.
-  Links(Object *annots);
+  Links(Object *annots, GString *baseURI);
 
   // Destructor.
   ~Links();
 
   // Iterate through list of links.
 
   // Destructor.
   ~Links();
 
   // Iterate through list of links.
-  int getNumLinks() { return numLinks; }
-  Link *getLink(int i) { return links[i]; }
+  int getNumLinks() const { return numLinks; }
+  Link *getLink(int i) const { return links[i]; }
 
   // If point <x>,<y> is in a link, return the associated action;
   // else return NULL.
 
   // If point <x>,<y> is in a link, return the associated action;
   // else return NULL.
-  LinkAction *find(double x, double y);
+  LinkAction *find(double x, double y) const;
 
   // Return true if <x>,<y> is in a link.
 
   // Return true if <x>,<y> is in a link.
-  GBool onLink(double x, double y);
+  GBool onLink(double x, double y) const;
 
 private:
 
 
 private: