00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef LINK_H
00010 #define LINK_H
00011
00012 #ifdef __GNUC__
00013 #pragma interface
00014 #endif
00015
00016 #include "Object.h"
00017
00018 class GString;
00019 class Array;
00020 class Dict;
00021
00022
00023
00024
00025
00026 enum LinkActionKind {
00027 actionGoTo,
00028 actionGoToR,
00029 actionLaunch,
00030 actionURI,
00031 actionNamed,
00032 actionUnknown
00033 };
00034
00035 class LinkAction {
00036 public:
00037
00038
00039 virtual ~LinkAction() {}
00040
00041
00042 virtual GBool isOk() = 0;
00043
00044
00045 virtual LinkActionKind getKind() = 0;
00046 };
00047
00048
00049
00050
00051
00052 enum LinkDestKind {
00053 destXYZ,
00054 destFit,
00055 destFitH,
00056 destFitV,
00057 destFitR,
00058 destFitB,
00059 destFitBH,
00060 destFitBV
00061 };
00062
00063 class LinkDest {
00064 public:
00065
00066
00067 LinkDest(Array *a);
00068
00069
00070 LinkDest *copy() { return new LinkDest(this); }
00071
00072
00073 GBool isOk() { return ok; }
00074
00075
00076 LinkDestKind getKind() { return kind; }
00077 GBool isPageRef() { return pageIsRef; }
00078 int getPageNum() { return pageNum; }
00079 Ref getPageRef() { return pageRef; }
00080 fouble getLeft() { return left; }
00081 fouble getBottom() { return bottom; }
00082 fouble getRight() { return right; }
00083 fouble getTop() { return top; }
00084 fouble getZoom() { return zoom; }
00085 GBool getChangeLeft() { return changeLeft; }
00086 GBool getChangeTop() { return changeTop; }
00087 GBool getChangeZoom() { return changeZoom; }
00088
00089 private:
00090
00091 LinkDestKind kind;
00092 GBool pageIsRef;
00093 union {
00094 Ref pageRef;
00095 int pageNum;
00096 };
00097 fouble left, bottom;
00098 fouble right, top;
00099 fouble zoom;
00100 GBool changeLeft, changeTop;
00101 GBool changeZoom;
00102 GBool ok;
00103
00104 LinkDest(LinkDest *dest);
00105 };
00106
00107
00108
00109
00110
00111 class LinkGoTo: public LinkAction {
00112 public:
00113
00114
00115 LinkGoTo(Object *destObj);
00116
00117
00118 virtual ~LinkGoTo();
00119
00120
00121 virtual GBool isOk() { return dest || namedDest; }
00122
00123
00124 virtual LinkActionKind getKind() { return actionGoTo; }
00125 LinkDest *getDest() { return dest; }
00126 GString *getNamedDest() { return namedDest; }
00127
00128 private:
00129
00130 LinkDest *dest;
00131
00132 GString *namedDest;
00133
00134 };
00135
00136
00137
00138
00139
00140 class LinkGoToR: public LinkAction {
00141 public:
00142
00143
00144
00145 LinkGoToR(Object *fileSpecObj, Object *destObj);
00146
00147
00148 virtual ~LinkGoToR();
00149
00150
00151 virtual GBool isOk() { return fileName && (dest || namedDest); }
00152
00153
00154 virtual LinkActionKind getKind() { return actionGoToR; }
00155 GString *getFileName() { return fileName; }
00156 LinkDest *getDest() { return dest; }
00157 GString *getNamedDest() { return namedDest; }
00158
00159 private:
00160
00161 GString *fileName;
00162 LinkDest *dest;
00163
00164 GString *namedDest;
00165
00166 };
00167
00168
00169
00170
00171
00172 class LinkLaunch: public LinkAction {
00173 public:
00174
00175
00176 LinkLaunch(Object *actionObj);
00177
00178
00179 virtual ~LinkLaunch();
00180
00181
00182 virtual GBool isOk() { return fileName != NULL; }
00183
00184
00185 virtual LinkActionKind getKind() { return actionLaunch; }
00186 GString *getFileName() { return fileName; }
00187 GString *getParams() { return params; }
00188
00189 private:
00190
00191 GString *fileName;
00192 GString *params;
00193 };
00194
00195
00196
00197
00198
00199 class LinkURI: public LinkAction {
00200 public:
00201
00202
00203 LinkURI(Object *uriObj, GString *baseURI);
00204
00205
00206 virtual ~LinkURI();
00207
00208
00209 virtual GBool isOk() { return uri != NULL; }
00210
00211
00212 virtual LinkActionKind getKind() { return actionURI; }
00213 GString *getURI() { return uri; }
00214
00215 private:
00216
00217 GString *uri;
00218 };
00219
00220
00221
00222
00223
00224 class LinkNamed: public LinkAction {
00225 public:
00226
00227
00228 LinkNamed(Object *nameObj);
00229
00230 virtual ~LinkNamed();
00231
00232 virtual GBool isOk() { return name != NULL; }
00233
00234 virtual LinkActionKind getKind() { return actionNamed; }
00235 GString *getName() { return name; }
00236
00237 private:
00238
00239 GString *name;
00240 };
00241
00242
00243
00244
00245
00246 class LinkUnknown: public LinkAction {
00247 public:
00248
00249
00250 LinkUnknown(char *actionA);
00251
00252
00253 virtual ~LinkUnknown();
00254
00255
00256 virtual GBool isOk() { return action != NULL; }
00257
00258
00259 virtual LinkActionKind getKind() { return actionUnknown; }
00260 GString *getAction() { return action; }
00261
00262 private:
00263
00264 GString *action;
00265 };
00266
00267
00268
00269
00270
00271 class Link {
00272 public:
00273
00274
00275 Link(Dict *dict, GString *baseURI);
00276
00277
00278 ~Link();
00279
00280
00281 GBool isOk() { return ok; }
00282
00283
00284 GBool inRect(fouble x, fouble y)
00285 { return x1 <= x && x <= x2 && y1 <= y && y <= y2; }
00286
00287
00288 LinkAction *getAction() { return action; }
00289
00290
00291 void getBorder(fouble *xa1, fouble *ya1, fouble *xa2, fouble *ya2,
00292 fouble *wa)
00293 { *xa1 = x1; *ya1 = y1; *xa2 = x2; *ya2 = y2; *wa = borderW; }
00294
00295 private:
00296
00297 fouble x1, y1;
00298 fouble x2, y2;
00299 fouble borderW;
00300 LinkAction *action;
00301 GBool ok;
00302 };
00303
00304
00305
00306
00307
00308 class Links {
00309 public:
00310
00311
00312 Links(Object *annots, GString *baseURI);
00313
00314
00315 ~Links();
00316
00317
00318 int getNumLinks() { return numLinks; }
00319 Link *getLink(int i) { return links[i]; }
00320
00321
00322
00323 LinkAction *find(fouble x, fouble y);
00324
00325
00326 GBool onLink(fouble x, fouble y);
00327
00328 private:
00329
00330 Link **links;
00331 int numLinks;
00332 };
00333
00334 #endif