ReaderContentPage.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. //
  2. // ReaderContentPage.m
  3. // Reader v2.8.6
  4. //
  5. // Created by Julius Oklamcak on 2011-07-01.
  6. // Copyright © 2011-2015 Julius Oklamcak. All rights reserved.
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining a copy
  9. // of this software and associated documentation files (the "Software"), to deal
  10. // in the Software without restriction, including without limitation the rights to
  11. // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  12. // of the Software, and to permit persons to whom the Software is furnished to
  13. // do so, subject to the following conditions:
  14. //
  15. // The above copyright notice and this permission notice shall be included in all
  16. // copies or substantial portions of the Software.
  17. //
  18. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  22. // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. //
  25. #import "ReaderConstants.h"
  26. #import "ReaderContentPage.h"
  27. #import "ReaderContentTile.h"
  28. #import "CGPDFDocument.h"
  29. @implementation ReaderContentPage
  30. {
  31. NSMutableArray *_links;
  32. CGPDFDocumentRef _PDFDocRef;
  33. CGPDFPageRef _PDFPageRef;
  34. NSInteger _pageAngle;
  35. CGFloat _pageWidth;
  36. CGFloat _pageHeight;
  37. CGFloat _pageOffsetX;
  38. CGFloat _pageOffsetY;
  39. }
  40. #pragma mark - ReaderContentPage class methods
  41. + (Class)layerClass
  42. {
  43. return [ReaderContentTile class];
  44. }
  45. #pragma mark - ReaderContentPage PDF link methods
  46. - (void)highlightPageLinks
  47. {
  48. if (_links.count > 0) // Add highlight views over all links
  49. {
  50. UIColor *hilite = [UIColor colorWithRed:0.0f green:0.0f blue:1.0f alpha:0.15f];
  51. for (ReaderDocumentLink *link in _links) // Enumerate the links array
  52. {
  53. UIView *highlight = [[UIView alloc] initWithFrame:link.rect];
  54. highlight.autoresizesSubviews = NO;
  55. highlight.userInteractionEnabled = NO;
  56. highlight.contentMode = UIViewContentModeRedraw;
  57. highlight.autoresizingMask = UIViewAutoresizingNone;
  58. highlight.backgroundColor = hilite; // Color
  59. [self addSubview:highlight];
  60. }
  61. }
  62. }
  63. - (ReaderDocumentLink *)linkFromAnnotation:(CGPDFDictionaryRef)annotationDictionary
  64. {
  65. ReaderDocumentLink *documentLink = nil; // Document link object
  66. CGPDFArrayRef annotationRectArray = NULL; // Annotation co-ordinates array
  67. if (CGPDFDictionaryGetArray(annotationDictionary, "Rect", &annotationRectArray))
  68. {
  69. CGPDFReal ll_x = 0.0f; CGPDFReal ll_y = 0.0f; // PDFRect lower-left X and Y
  70. CGPDFReal ur_x = 0.0f; CGPDFReal ur_y = 0.0f; // PDFRect upper-right X and Y
  71. CGPDFArrayGetNumber(annotationRectArray, 0, &ll_x); // Lower-left X co-ordinate
  72. CGPDFArrayGetNumber(annotationRectArray, 1, &ll_y); // Lower-left Y co-ordinate
  73. CGPDFArrayGetNumber(annotationRectArray, 2, &ur_x); // Upper-right X co-ordinate
  74. CGPDFArrayGetNumber(annotationRectArray, 3, &ur_y); // Upper-right Y co-ordinate
  75. if (ll_x > ur_x) { CGPDFReal t = ll_x; ll_x = ur_x; ur_x = t; } // Normalize Xs
  76. if (ll_y > ur_y) { CGPDFReal t = ll_y; ll_y = ur_y; ur_y = t; } // Normalize Ys
  77. ll_x -= _pageOffsetX; ll_y -= _pageOffsetY; // Offset lower-left co-ordinate
  78. ur_x -= _pageOffsetX; ur_y -= _pageOffsetY; // Offset upper-right co-ordinate
  79. switch (_pageAngle) // Page rotation angle (in degrees)
  80. {
  81. case 90: // 90 degree page rotation
  82. {
  83. CGPDFReal swap;
  84. swap = ll_y; ll_y = ll_x; ll_x = swap;
  85. swap = ur_y; ur_y = ur_x; ur_x = swap;
  86. break;
  87. }
  88. case 270: // 270 degree page rotation
  89. {
  90. CGPDFReal swap;
  91. swap = ll_y; ll_y = ll_x; ll_x = swap;
  92. swap = ur_y; ur_y = ur_x; ur_x = swap;
  93. ll_x = ((0.0f - ll_x) + _pageWidth);
  94. ur_x = ((0.0f - ur_x) + _pageWidth);
  95. break;
  96. }
  97. case 0: // 0 degree page rotation
  98. {
  99. ll_y = ((0.0f - ll_y) + _pageHeight);
  100. ur_y = ((0.0f - ur_y) + _pageHeight);
  101. break;
  102. }
  103. }
  104. NSInteger vr_x = ll_x; NSInteger vr_w = (ur_x - ll_x); // Integer X and width
  105. NSInteger vr_y = ll_y; NSInteger vr_h = (ur_y - ll_y); // Integer Y and height
  106. CGRect viewRect = CGRectMake(vr_x, vr_y, vr_w, vr_h); // View CGRect from PDFRect
  107. documentLink = [ReaderDocumentLink newWithRect:viewRect dictionary:annotationDictionary];
  108. }
  109. return documentLink;
  110. }
  111. - (void)buildAnnotationLinksList
  112. {
  113. _links = [NSMutableArray new]; // Links list array
  114. CGPDFArrayRef pageAnnotations = NULL; // Page annotations array
  115. CGPDFDictionaryRef pageDictionary = CGPDFPageGetDictionary(_PDFPageRef);
  116. if (CGPDFDictionaryGetArray(pageDictionary, "Annots", &pageAnnotations) == true)
  117. {
  118. NSInteger count = CGPDFArrayGetCount(pageAnnotations); // Number of annotations
  119. for (NSInteger index = 0; index < count; index++) // Iterate through all annotations
  120. {
  121. CGPDFDictionaryRef annotationDictionary = NULL; // PDF annotation dictionary
  122. if (CGPDFArrayGetDictionary(pageAnnotations, index, &annotationDictionary) == true)
  123. {
  124. const char *annotationSubtype = NULL; // PDF annotation subtype string
  125. if (CGPDFDictionaryGetName(annotationDictionary, "Subtype", &annotationSubtype) == true)
  126. {
  127. if (strcmp(annotationSubtype, "Link") == 0) // Found annotation subtype of 'Link'
  128. {
  129. ReaderDocumentLink *documentLink = [self linkFromAnnotation:annotationDictionary];
  130. if (documentLink != nil) [_links insertObject:documentLink atIndex:0]; // Add link
  131. }
  132. }
  133. }
  134. }
  135. //[self highlightPageLinks]; // Link support debugging
  136. }
  137. }
  138. - (CGPDFArrayRef)destinationWithName:(const char *)destinationName inDestsTree:(CGPDFDictionaryRef)node
  139. {
  140. CGPDFArrayRef destinationArray = NULL;
  141. CGPDFArrayRef limitsArray = NULL; // Limits array
  142. if (CGPDFDictionaryGetArray(node, "Limits", &limitsArray) == true)
  143. {
  144. CGPDFStringRef lowerLimit = NULL; CGPDFStringRef upperLimit = NULL;
  145. if (CGPDFArrayGetString(limitsArray, 0, &lowerLimit) == true) // Lower limit
  146. {
  147. if (CGPDFArrayGetString(limitsArray, 1, &upperLimit) == true) // Upper limit
  148. {
  149. const char *ll = (const char *)CGPDFStringGetBytePtr(lowerLimit); // Lower string
  150. const char *ul = (const char *)CGPDFStringGetBytePtr(upperLimit); // Upper string
  151. if ((strcmp(destinationName, ll) < 0) || (strcmp(destinationName, ul) > 0))
  152. {
  153. return NULL; // Destination name is outside this node's limits
  154. }
  155. }
  156. }
  157. }
  158. CGPDFArrayRef namesArray = NULL; // Names array
  159. if (CGPDFDictionaryGetArray(node, "Names", &namesArray) == true)
  160. {
  161. NSInteger namesCount = CGPDFArrayGetCount(namesArray);
  162. for (NSInteger index = 0; index < namesCount; index += 2)
  163. {
  164. CGPDFStringRef destName; // Destination name string
  165. if (CGPDFArrayGetString(namesArray, index, &destName) == true)
  166. {
  167. const char *dn = (const char *)CGPDFStringGetBytePtr(destName);
  168. if (strcmp(dn, destinationName) == 0) // Found the destination name
  169. {
  170. if (CGPDFArrayGetArray(namesArray, (index + 1), &destinationArray) == false)
  171. {
  172. CGPDFDictionaryRef destinationDictionary = NULL; // Destination dictionary
  173. if (CGPDFArrayGetDictionary(namesArray, (index + 1), &destinationDictionary) == true)
  174. {
  175. CGPDFDictionaryGetArray(destinationDictionary, "D", &destinationArray);
  176. }
  177. }
  178. return destinationArray; // Return the destination array
  179. }
  180. }
  181. }
  182. }
  183. CGPDFArrayRef kidsArray = NULL; // Kids array
  184. if (CGPDFDictionaryGetArray(node, "Kids", &kidsArray) == true)
  185. {
  186. NSInteger kidsCount = CGPDFArrayGetCount(kidsArray);
  187. for (NSInteger index = 0; index < kidsCount; index++)
  188. {
  189. CGPDFDictionaryRef kidNode = NULL; // Kid node dictionary
  190. if (CGPDFArrayGetDictionary(kidsArray, index, &kidNode) == true) // Recurse into node
  191. {
  192. destinationArray = [self destinationWithName:destinationName inDestsTree:kidNode];
  193. if (destinationArray != NULL) return destinationArray; // Return destination array
  194. }
  195. }
  196. }
  197. return NULL;
  198. }
  199. - (id)annotationLinkTarget:(CGPDFDictionaryRef)annotationDictionary
  200. {
  201. id linkTarget = nil; // Link target object
  202. CGPDFStringRef destName = NULL; const char *destString = NULL;
  203. CGPDFDictionaryRef actionDictionary = NULL; CGPDFArrayRef destArray = NULL;
  204. if (CGPDFDictionaryGetDictionary(annotationDictionary, "A", &actionDictionary) == true)
  205. {
  206. const char *actionType = NULL; // Annotation action type string
  207. if (CGPDFDictionaryGetName(actionDictionary, "S", &actionType) == true)
  208. {
  209. if (strcmp(actionType, "GoTo") == 0) // GoTo action type
  210. {
  211. if (CGPDFDictionaryGetArray(actionDictionary, "D", &destArray) == false)
  212. {
  213. CGPDFDictionaryGetString(actionDictionary, "D", &destName);
  214. }
  215. }
  216. else // Handle other link action type possibility
  217. {
  218. if (strcmp(actionType, "URI") == 0) // URI action type
  219. {
  220. CGPDFStringRef uriString = NULL; // Action's URI string
  221. if (CGPDFDictionaryGetString(actionDictionary, "URI", &uriString) == true)
  222. {
  223. const char *uri = (const char *)CGPDFStringGetBytePtr(uriString); // Destination URI string
  224. NSString *target = [NSString stringWithCString:uri encoding:NSUTF8StringEncoding]; // NSString - UTF8
  225. //linkTarget = [NSURL URLWithString:[target stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; DEPRECATED iOS0
  226. linkTarget = [NSURL URLWithString:[target stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];
  227. if (linkTarget == nil) NSLog(@"%s Bad URI '%@'", __FUNCTION__, target);
  228. }
  229. }
  230. }
  231. }
  232. }
  233. else // Handle other link target possibilities
  234. {
  235. if (CGPDFDictionaryGetArray(annotationDictionary, "Dest", &destArray) == false)
  236. {
  237. if (CGPDFDictionaryGetString(annotationDictionary, "Dest", &destName) == false)
  238. {
  239. CGPDFDictionaryGetName(annotationDictionary, "Dest", &destString);
  240. }
  241. }
  242. }
  243. if (destName != NULL) // Handle a destination name
  244. {
  245. CGPDFDictionaryRef catalogDictionary = CGPDFDocumentGetCatalog(_PDFDocRef);
  246. CGPDFDictionaryRef namesDictionary = NULL; // Destination names in the document
  247. if (CGPDFDictionaryGetDictionary(catalogDictionary, "Names", &namesDictionary) == true)
  248. {
  249. CGPDFDictionaryRef destsDictionary = NULL; // Document destinations dictionary
  250. if (CGPDFDictionaryGetDictionary(namesDictionary, "Dests", &destsDictionary) == true)
  251. {
  252. const char *destinationName = (const char *)CGPDFStringGetBytePtr(destName); // Name
  253. destArray = [self destinationWithName:destinationName inDestsTree:destsDictionary];
  254. }
  255. }
  256. }
  257. if (destString != NULL) // Handle a destination string
  258. {
  259. CGPDFDictionaryRef catalogDictionary = CGPDFDocumentGetCatalog(_PDFDocRef);
  260. CGPDFDictionaryRef destsDictionary = NULL; // Document destinations dictionary
  261. if (CGPDFDictionaryGetDictionary(catalogDictionary, "Dests", &destsDictionary) == true)
  262. {
  263. CGPDFDictionaryRef targetDictionary = NULL; // Destination target dictionary
  264. if (CGPDFDictionaryGetDictionary(destsDictionary, destString, &targetDictionary) == true)
  265. {
  266. CGPDFDictionaryGetArray(targetDictionary, "D", &destArray);
  267. }
  268. }
  269. }
  270. if (destArray != NULL) // Handle a destination array
  271. {
  272. NSInteger targetPageNumber = 0; // The target page number
  273. CGPDFDictionaryRef pageDictionaryFromDestArray = NULL; // Target reference
  274. if (CGPDFArrayGetDictionary(destArray, 0, &pageDictionaryFromDestArray) == true)
  275. {
  276. NSInteger pageCount = CGPDFDocumentGetNumberOfPages(_PDFDocRef); // Pages
  277. for (NSInteger pageNumber = 1; pageNumber <= pageCount; pageNumber++)
  278. {
  279. CGPDFPageRef pageRef = CGPDFDocumentGetPage(_PDFDocRef, pageNumber);
  280. CGPDFDictionaryRef pageDictionaryFromPage = CGPDFPageGetDictionary(pageRef);
  281. if (pageDictionaryFromPage == pageDictionaryFromDestArray) // Found it
  282. {
  283. targetPageNumber = pageNumber; break;
  284. }
  285. }
  286. }
  287. else // Try page number from array possibility
  288. {
  289. CGPDFInteger pageNumber = 0; // Page number in array
  290. if (CGPDFArrayGetInteger(destArray, 0, &pageNumber) == true)
  291. {
  292. targetPageNumber = (pageNumber + 1); // 1-based
  293. }
  294. }
  295. if (targetPageNumber > 0) // We have a target page number
  296. {
  297. linkTarget = [NSNumber numberWithInteger:targetPageNumber];
  298. }
  299. }
  300. return linkTarget;
  301. }
  302. - (id)processSingleTap:(UITapGestureRecognizer *)recognizer
  303. {
  304. id result = nil; // Tap result object
  305. if (recognizer.state == UIGestureRecognizerStateRecognized)
  306. {
  307. if (_links.count > 0) // Process the single tap
  308. {
  309. CGPoint point = [recognizer locationInView:self];
  310. for (ReaderDocumentLink *link in _links) // Enumerate links
  311. {
  312. if (CGRectContainsPoint(link.rect, point) == true) // Found it
  313. {
  314. result = [self annotationLinkTarget:link.dictionary]; break;
  315. }
  316. }
  317. }
  318. }
  319. return result;
  320. }
  321. #pragma mark - ReaderContentPage instance methods
  322. - (instancetype)initWithFrame:(CGRect)frame
  323. {
  324. if ((self = [super initWithFrame:frame]))
  325. {
  326. self.autoresizesSubviews = NO;
  327. self.userInteractionEnabled = NO;
  328. self.contentMode = UIViewContentModeRedraw;
  329. self.autoresizingMask = UIViewAutoresizingNone;
  330. self.backgroundColor = [UIColor clearColor];
  331. }
  332. return self;
  333. }
  334. - (instancetype)initWithURL:(NSURL *)fileURL page:(NSInteger)page password:(NSString *)phrase
  335. {
  336. CGRect viewRect = CGRectZero; // View rect
  337. if (fileURL != nil) // Check for non-nil file URL
  338. {
  339. _PDFDocRef = CGPDFDocumentCreateUsingUrl((__bridge CFURLRef)fileURL, phrase);
  340. if (_PDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef
  341. {
  342. if (page < 1) page = 1; // Check the lower page bounds
  343. NSInteger pages = CGPDFDocumentGetNumberOfPages(_PDFDocRef);
  344. if (page > pages) page = pages; // Check the upper page bounds
  345. _PDFPageRef = CGPDFDocumentGetPage(_PDFDocRef, page); // Get page
  346. if (_PDFPageRef != NULL) // Check for non-NULL CGPDFPageRef
  347. {
  348. CGPDFPageRetain(_PDFPageRef); // Retain the PDF page
  349. CGRect cropBoxRect = CGPDFPageGetBoxRect(_PDFPageRef, kCGPDFCropBox);
  350. CGRect mediaBoxRect = CGPDFPageGetBoxRect(_PDFPageRef, kCGPDFMediaBox);
  351. CGRect effectiveRect = CGRectIntersection(cropBoxRect, mediaBoxRect);
  352. _pageAngle = CGPDFPageGetRotationAngle(_PDFPageRef); // Angle
  353. switch (_pageAngle) // Page rotation angle (in degrees)
  354. {
  355. default: // Default case
  356. case 0: case 180: // 0 and 180 degrees
  357. {
  358. _pageWidth = effectiveRect.size.width;
  359. _pageHeight = effectiveRect.size.height;
  360. _pageOffsetX = effectiveRect.origin.x;
  361. _pageOffsetY = effectiveRect.origin.y;
  362. break;
  363. }
  364. case 90: case 270: // 90 and 270 degrees
  365. {
  366. _pageWidth = effectiveRect.size.height;
  367. _pageHeight = effectiveRect.size.width;
  368. _pageOffsetX = effectiveRect.origin.y;
  369. _pageOffsetY = effectiveRect.origin.x;
  370. break;
  371. }
  372. }
  373. NSInteger page_w = _pageWidth; // Integer width
  374. NSInteger page_h = _pageHeight; // Integer height
  375. if (page_w % 2) page_w--; if (page_h % 2) page_h--; // Even
  376. viewRect.size = CGSizeMake(page_w, page_h); // View size
  377. }
  378. else // Error out with a diagnostic
  379. {
  380. (void)(CGPDFDocumentRelease(_PDFDocRef)), _PDFDocRef = NULL;
  381. NSAssert(NO, @"CGPDFPageRef == NULL");
  382. }
  383. }
  384. else // Error out with a diagnostic
  385. {
  386. NSAssert(NO, @"CGPDFDocumentRef == NULL");
  387. }
  388. }
  389. else // Error out with a diagnostic
  390. {
  391. NSAssert(NO, @"fileURL == nil");
  392. }
  393. ReaderContentPage *view = [self initWithFrame:viewRect];
  394. if (view != nil) [self buildAnnotationLinksList];
  395. return view;
  396. }
  397. - (void)removeFromSuperview
  398. {
  399. self.layer.delegate = nil;
  400. //self.layer.contents = nil;
  401. [super removeFromSuperview];
  402. }
  403. - (void)dealloc
  404. {
  405. (void)(CGPDFPageRelease(_PDFPageRef)), _PDFPageRef = NULL;
  406. (void)(CGPDFDocumentRelease(_PDFDocRef)), _PDFDocRef = NULL;
  407. }
  408. #if (READER_DISABLE_RETINA == TRUE) // Option
  409. - (void)didMoveToWindow
  410. {
  411. self.contentScaleFactor = 1.0f; // Override scale factor
  412. }
  413. #endif // end of READER_DISABLE_RETINA Option
  414. #pragma mark - CATiledLayer delegate methods
  415. - (void)drawLayer:(CATiledLayer *)layer inContext:(CGContextRef)context
  416. {
  417. ReaderContentPage *readerContentPage = self; // Retain self
  418. CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f); // White
  419. CGContextFillRect(context, CGContextGetClipBoundingBox(context)); // Fill
  420. //NSLog(@"%s %@", __FUNCTION__, NSStringFromCGRect(CGContextGetClipBoundingBox(context)));
  421. CGContextTranslateCTM(context, 0.0f, self.bounds.size.height); CGContextScaleCTM(context, 1.0f, -1.0f);
  422. CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(_PDFPageRef, kCGPDFCropBox, self.bounds, 0, true));
  423. //CGContextSetRenderingIntent(context, kCGRenderingIntentDefault); CGContextSetInterpolationQuality(context, kCGInterpolationDefault);
  424. CGContextDrawPDFPage(context, _PDFPageRef); // Render the PDF page into the context
  425. if (readerContentPage != nil) readerContentPage = nil; // Release self
  426. }
  427. @end
  428. #pragma mark -
  429. //
  430. // ReaderDocumentLink class implementation
  431. //
  432. @implementation ReaderDocumentLink
  433. {
  434. CGPDFDictionaryRef _dictionary;
  435. CGRect _rect;
  436. }
  437. #pragma mark - Properties
  438. @synthesize rect = _rect;
  439. @synthesize dictionary = _dictionary;
  440. #pragma mark - ReaderDocumentLink class methods
  441. + (instancetype)newWithRect:(CGRect)linkRect dictionary:(CGPDFDictionaryRef)linkDictionary
  442. {
  443. return [[ReaderDocumentLink alloc] initWithRect:linkRect dictionary:linkDictionary];
  444. }
  445. #pragma mark - ReaderDocumentLink instance methods
  446. - (instancetype)initWithRect:(CGRect)linkRect dictionary:(CGPDFDictionaryRef)linkDictionary
  447. {
  448. if ((self = [super init]))
  449. {
  450. _dictionary = linkDictionary;
  451. _rect = linkRect;
  452. }
  453. return self;
  454. }
  455. @end