00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef LINK_H
00010 #define LINK_H
00011
00012 #include <aconf.h>
00013
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017
00018 #include "Object.h"
00019
00020 class GString;
00021 class Array;
00022 class Dict;
00023
00024
00025
00026
00027
00028 enum LinkActionKind {
00029 actionGoTo,
00030 actionGoToR,
00031 actionLaunch,
00032 actionURI,
00033 actionNamed,
00034 actionMovie,
00035 actionUnknown
00036 };
00037
00038 class LinkAction {
00039 public:
00040
00041
00042 virtual ~LinkAction() {}
00043
00044
00045 virtual GBool isOk() = 0;
00046
00047
00048 virtual LinkActionKind getKind() = 0;
00049
00050
00051 static LinkAction *parseDest(Object *obj);
00052
00053
00054 static LinkAction *parseAction(Object *obj, GString *baseURI = NULL);
00055
00056
00057
00058 static GString *getFileSpecName(Object *fileSpecObj);
00059 };
00060
00061
00062
00063
00064
00065 enum LinkDestKind {
00066 destXYZ,
00067 destFit,
00068 destFitH,
00069 destFitV,
00070 destFitR,
00071 destFitB,
00072 destFitBH,
00073 destFitBV
00074 };
00075
00076 class LinkDest {
00077 public:
00078
00079
00080 LinkDest(Array *a);
00081
00082
00083 LinkDest *copy() { return new LinkDest(this); }
00084
00085
00086 GBool isOk() { return ok; }
00087
00088
00089 LinkDestKind getKind() { return kind; }
00090 GBool isPageRef() { return pageIsRef; }
00091 int getPageNum() { return pageNum; }
00092 Ref getPageRef() { return pageRef; }
00093 double getLeft() { return left; }
00094 double getBottom() { return bottom; }
00095 double getRight() { return right; }
00096 double getTop() { return top; }
00097 double getZoom() { return zoom; }
00098 GBool getChangeLeft() { return changeLeft; }
00099 GBool getChangeTop() { return changeTop; }
00100 GBool getChangeZoom() { return changeZoom; }
00101
00102 private:
00103
00104 LinkDestKind kind;
00105 GBool pageIsRef;
00106 union {
00107 Ref pageRef;
00108 int pageNum;
00109 };
00110 double left, bottom;
00111 double right, top;
00112 double zoom;
00113 GBool changeLeft, changeTop;
00114 GBool changeZoom;
00115 GBool ok;
00116
00117 LinkDest(LinkDest *dest);
00118 };
00119
00120
00121
00122
00123
00124 class LinkGoTo: public LinkAction {
00125 public:
00126
00127
00128 LinkGoTo(Object *destObj);
00129
00130
00131 virtual ~LinkGoTo();
00132
00133
00134 virtual GBool isOk() { return dest || namedDest; }
00135
00136
00137 virtual LinkActionKind getKind() { return actionGoTo; }
00138 LinkDest *getDest() { return dest; }
00139 GString *getNamedDest() { return namedDest; }
00140
00141 private:
00142
00143 LinkDest *dest;
00144
00145 GString *namedDest;
00146
00147 };
00148
00149
00150
00151
00152
00153 class LinkGoToR: public LinkAction {
00154 public:
00155
00156
00157
00158 LinkGoToR(Object *fileSpecObj, Object *destObj);
00159
00160
00161 virtual ~LinkGoToR();
00162
00163
00164 virtual GBool isOk() { return fileName && (dest || namedDest); }
00165
00166
00167 virtual LinkActionKind getKind() { return actionGoToR; }
00168 GString *getFileName() { return fileName; }
00169 LinkDest *getDest() { return dest; }
00170 GString *getNamedDest() { return namedDest; }
00171
00172 private:
00173
00174 GString *fileName;
00175 LinkDest *dest;
00176
00177 GString *namedDest;
00178
00179 };
00180
00181
00182
00183
00184
00185 class LinkLaunch: public LinkAction {
00186 public:
00187
00188
00189 LinkLaunch(Object *actionObj);
00190
00191
00192 virtual ~LinkLaunch();
00193
00194
00195 virtual GBool isOk() { return fileName != NULL; }
00196
00197
00198 virtual LinkActionKind getKind() { return actionLaunch; }
00199 GString *getFileName() { return fileName; }
00200 GString *getParams() { return params; }
00201
00202 private:
00203
00204 GString *fileName;
00205 GString *params;
00206 };
00207
00208
00209
00210
00211
00212 class LinkURI: public LinkAction {
00213 public:
00214
00215
00216 LinkURI(Object *uriObj, GString *baseURI);
00217
00218
00219 virtual ~LinkURI();
00220
00221
00222 virtual GBool isOk() { return uri != NULL; }
00223
00224
00225 virtual LinkActionKind getKind() { return actionURI; }
00226 GString *getURI() { return uri; }
00227
00228 private:
00229
00230 GString *uri;
00231 };
00232
00233
00234
00235
00236
00237 class LinkNamed: public LinkAction {
00238 public:
00239
00240
00241 LinkNamed(Object *nameObj);
00242
00243 virtual ~LinkNamed();
00244
00245 virtual GBool isOk() { return name != NULL; }
00246
00247 virtual LinkActionKind getKind() { return actionNamed; }
00248 GString *getName() { return name; }
00249
00250 private:
00251
00252 GString *name;
00253 };
00254
00255
00256
00257
00258
00259 class LinkMovie: public LinkAction {
00260 public:
00261
00262 LinkMovie(Object *annotObj, Object *titleObj);
00263
00264 virtual ~LinkMovie();
00265
00266 virtual GBool isOk() { return annotRef.num >= 0 || title != NULL; }
00267
00268 virtual LinkActionKind getKind() { return actionMovie; }
00269 GBool hasAnnotRef() { return annotRef.num >= 0; }
00270 Ref *getAnnotRef() { return &annotRef; }
00271 GString *getTitle() { return title; }
00272
00273 private:
00274
00275 Ref annotRef;
00276 GString *title;
00277 };
00278
00279
00280
00281
00282
00283 class LinkUnknown: public LinkAction {
00284 public:
00285
00286
00287 LinkUnknown(char *actionA);
00288
00289
00290 virtual ~LinkUnknown();
00291
00292
00293 virtual GBool isOk() { return action != NULL; }
00294
00295
00296 virtual LinkActionKind getKind() { return actionUnknown; }
00297 GString *getAction() { return action; }
00298
00299 private:
00300
00301 GString *action;
00302 };
00303
00304
00305
00306
00307
00308 enum LinkBorderType {
00309 linkBorderSolid,
00310 linkBorderDashed,
00311 linkBorderEmbossed,
00312 linkBorderEngraved,
00313 linkBorderUnderlined
00314 };
00315
00316 class LinkBorderStyle {
00317 public:
00318
00319 LinkBorderStyle(LinkBorderType typeA, double widthA,
00320 double *dashA, int dashLengthA,
00321 double rA, double gA, double bA);
00322 ~LinkBorderStyle();
00323
00324 LinkBorderType getType() { return type; }
00325 double getWidth() { return width; }
00326 void getDash(double **dashA, int *dashLengthA)
00327 { *dashA = dash; *dashLengthA = dashLength; }
00328 void getColor(double *rA, double *gA, double *bA)
00329 { *rA = r; *gA = g; *bA = b; }
00330
00331 private:
00332
00333 LinkBorderType type;
00334 double width;
00335 double *dash;
00336 int dashLength;
00337 double r, g, b;
00338 };
00339
00340
00341
00342
00343
00344 class Link {
00345 public:
00346
00347
00348 Link(Dict *dict, GString *baseURI);
00349
00350
00351 ~Link();
00352
00353
00354 GBool isOk() { return ok; }
00355
00356
00357 GBool inRect(double x, double y)
00358 { return x1 <= x && x <= x2 && y1 <= y && y <= y2; }
00359
00360
00361 LinkAction *getAction() { return action; }
00362
00363
00364 void getRect(double *xa1, double *ya1, double *xa2, double *ya2)
00365 { *xa1 = x1; *ya1 = y1; *xa2 = x2; *ya2 = y2; }
00366
00367
00368 LinkBorderStyle *getBorderStyle() { return borderStyle; }
00369
00370 private:
00371
00372 double x1, y1;
00373 double x2, y2;
00374 LinkBorderStyle *borderStyle;
00375 LinkAction *action;
00376 GBool ok;
00377 };
00378
00379
00380
00381
00382
00383 class Links {
00384 public:
00385
00386
00387 Links(Object *annots, GString *baseURI);
00388
00389
00390 ~Links();
00391
00392
00393 int getNumLinks() { return numLinks; }
00394 Link *getLink(int i) { return links[i]; }
00395
00396
00397
00398 LinkAction *find(double x, double y);
00399
00400
00401 GBool onLink(double x, double y);
00402
00403 private:
00404
00405 Link **links;
00406 int numLinks;
00407 };
00408
00409 #endif