Back to index

tetex-bin  3.0
Public Member Functions | Private Attributes
Link Class Reference

#include <Link.h>

Collaboration diagram for Link:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Link (Dict *dict, GString *baseURI)
 ~Link ()
GBool isOk ()
GBool inRect (double x, double y)
LinkActiongetAction ()
void getRect (double *xa1, double *ya1, double *xa2, double *ya2)
LinkBorderStylegetBorderStyle ()

Private Attributes

double x1
double y1
double x2
double y2
LinkBorderStyleborderStyle
LinkActionaction
GBool ok

Detailed Description

Definition at line 344 of file Link.h.


Constructor & Destructor Documentation

Link::Link ( Dict dict,
GString baseURI 
)

Definition at line 609 of file Link.cc.

                                       {
  Object obj1, obj2, obj3;
  LinkBorderType borderType;
  double borderWidth;
  double *borderDash;
  int borderDashLength;
  double borderR, borderG, borderB;
  double t;
  int i;

  borderStyle = NULL;
  action = NULL;
  ok = gFalse;

  // get rectangle
  if (!dict->lookup("Rect", &obj1)->isArray()) {
    error(-1, "Annotation rectangle is wrong type");
    goto err2;
  }
  if (!obj1.arrayGet(0, &obj2)->isNum()) {
    error(-1, "Bad annotation rectangle");
    goto err1;
  }
  x1 = obj2.getNum();
  obj2.free();
  if (!obj1.arrayGet(1, &obj2)->isNum()) {
    error(-1, "Bad annotation rectangle");
    goto err1;
  }
  y1 = obj2.getNum();
  obj2.free();
  if (!obj1.arrayGet(2, &obj2)->isNum()) {
    error(-1, "Bad annotation rectangle");
    goto err1;
  }
  x2 = obj2.getNum();
  obj2.free();
  if (!obj1.arrayGet(3, &obj2)->isNum()) {
    error(-1, "Bad annotation rectangle");
    goto err1;
  }
  y2 = obj2.getNum();
  obj2.free();
  obj1.free();
  if (x1 > x2) {
    t = x1;
    x1 = x2;
    x2 = t;
  }
  if (y1 > y2) {
    t = y1;
    y1 = y2;
    y2 = t;
  }

  // get the border style info
  borderType = linkBorderSolid;
  borderWidth = 1;
  borderDash = NULL;
  borderDashLength = 0;
  borderR = 0;
  borderG = 0;
  borderB = 1;
  if (dict->lookup("BS", &obj1)->isDict()) {
    if (obj1.dictLookup("S", &obj2)->isName()) {
      if (obj2.isName("S")) {
       borderType = linkBorderSolid;
      } else if (obj2.isName("D")) {
       borderType = linkBorderDashed;
      } else if (obj2.isName("B")) {
       borderType = linkBorderEmbossed;
      } else if (obj2.isName("I")) {
       borderType = linkBorderEngraved;
      } else if (obj2.isName("U")) {
       borderType = linkBorderUnderlined;
      }
    }
    obj2.free();
    if (obj1.dictLookup("W", &obj2)->isNum()) {
      borderWidth = obj2.getNum();
    }
    obj2.free();
    if (obj1.dictLookup("D", &obj2)->isArray()) {
      borderDashLength = obj2.arrayGetLength();
      borderDash = (double *)gmalloc(borderDashLength * sizeof(double));
      for (i = 0; i < borderDashLength; ++i) {
       if (obj2.arrayGet(i, &obj3)->isNum()) {
         borderDash[i] = obj3.getNum();
       } else {
         borderDash[i] = 1;
       }
       obj3.free();
      }
    }
    obj2.free();
  } else {
    obj1.free();
    if (dict->lookup("Border", &obj1)->isArray()) {
      if (obj1.arrayGetLength() >= 3) {
       if (obj1.arrayGet(2, &obj2)->isNum()) {
         borderWidth = obj2.getNum();
       }
       obj2.free();
       if (obj1.arrayGetLength() >= 4) {
         if (obj1.arrayGet(3, &obj2)->isArray()) {
           borderType = linkBorderDashed;
           borderDashLength = obj2.arrayGetLength();
           borderDash = (double *)gmalloc(borderDashLength * sizeof(double));
           for (i = 0; i < borderDashLength; ++i) {
             if (obj2.arrayGet(i, &obj3)->isNum()) {
              borderDash[i] = obj3.getNum();
             } else {
              borderDash[i] = 1;
             }
             obj3.free();
           }
         }
         obj2.free();
       }
      }
    }
  }
  obj1.free();
  if (dict->lookup("C", &obj1)->isArray() && obj1.arrayGetLength() == 3) {
    if (obj1.arrayGet(0, &obj2)->isNum()) {
      borderR = obj2.getNum();
    }
    obj1.free();
    if (obj1.arrayGet(1, &obj2)->isNum()) {
      borderG = obj2.getNum();
    }
    obj1.free();
    if (obj1.arrayGet(2, &obj2)->isNum()) {
      borderB = obj2.getNum();
    }
    obj1.free();
  }
  obj1.free();
  borderStyle = new LinkBorderStyle(borderType, borderWidth,
                                borderDash, borderDashLength,
                                borderR, borderG, borderB);

  // look for destination
  if (!dict->lookup("Dest", &obj1)->isNull()) {
    action = LinkAction::parseDest(&obj1);

  // look for action
  } else {
    obj1.free();
    if (dict->lookup("A", &obj1)->isDict()) {
      action = LinkAction::parseAction(&obj1, baseURI);
    }
  }
  obj1.free();

  // check for bad action
  if (action) {
    ok = gTrue;
  }

  return;

 err1:
  obj2.free();
 err2:
  obj1.free();
}

Here is the call graph for this function:

Definition at line 777 of file Link.cc.

            {
  if (borderStyle) {
    delete borderStyle;
  }
  if (action) {
    delete action;
  }
}

Member Function Documentation

LinkAction* Link::getAction ( ) [inline]

Definition at line 361 of file Link.h.

{ return action; }

Here is the caller graph for this function:

Definition at line 368 of file Link.h.

{ return borderStyle; }
void Link::getRect ( double *  xa1,
double *  ya1,
double *  xa2,
double *  ya2 
) [inline]

Definition at line 364 of file Link.h.

    { *xa1 = x1; *ya1 = y1; *xa2 = x2; *ya2 = y2; }
GBool Link::inRect ( double  x,
double  y 
) [inline]

Definition at line 357 of file Link.h.

    { return x1 <= x && x <= x2 && y1 <= y && y <= y2; }
GBool Link::isOk ( ) [inline]

Definition at line 354 of file Link.h.

{ return ok; }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 375 of file Link.h.

Definition at line 374 of file Link.h.

GBool Link::ok [private]

Definition at line 376 of file Link.h.

double Link::x1 [private]

Definition at line 372 of file Link.h.

double Link::x2 [private]

Definition at line 373 of file Link.h.

double Link::y1 [private]

Definition at line 372 of file Link.h.

double Link::y2 [private]

Definition at line 373 of file Link.h.


The documentation for this class was generated from the following files: