Revision: 3792
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3792&view=rev
Author:   hofman
Date:     2008-04-22 11:45:27 -0700 (Tue, 22 Apr 2008)

Log Message:
-----------
Return only accessible children for displayed pages when not in continuous mode.

Modified Paths:
--------------
    trunk/SKPDFView.m

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2008-04-22 18:07:29 UTC (rev 3791)
+++ trunk/SKPDFView.m   2008-04-22 18:45:27 UTC (rev 3792)
@@ -2132,50 +2132,57 @@
     }
 }
 
-- (NSArray *)accessibilityChildren {
-    if (accessibilityChildren == nil) {
-        NSMutableArray *children = [[NSMutableArray alloc] init];
-        
-        [children addObject:[[[SKAccessibilityPDFDisplayViewElement alloc] 
initWithParent:[self documentView]] autorelease]];
-        
-        PDFDocument *pdfDoc = [self document];
-        unsigned int i, iMax = [pdfDoc pageCount];
-        for (i = 0; i < iMax; i++) {
-            PDFPage *page = [pdfDoc pageAtIndex:i];
-            NSEnumerator *annotationEnum = [[page annotations] 
objectEnumerator];
-            PDFAnnotation *annotation;
-            while (annotation = [annotationEnum nextObject]) {
-                if ([[annotation type] isEqualToString:SKLinkString] || 
[annotation isNoteAnnotation])
-                    [children addObject:[[[SKAccessibilityPDFAnnotationElement 
alloc] initWithAnnotation:annotation pdfView:self parent:[self documentView]] 
autorelease]];
-            }
-        }
-        accessibilityChildren = children;
-    }
-    return accessibilityChildren;
-}
-
-- (NSArray *)accessibilityVisibleChildren {
+- (NSArray *)accessibilityChildrenForPageRange:(NSRange)range 
visible:(BOOL)onlyVisible {
     NSMutableArray *children = [NSMutableArray array];
     
     [children addObject:[[[SKAccessibilityPDFDisplayViewElement alloc] 
initWithParent:[self documentView]] autorelease]];
     
     PDFDocument *pdfDoc = [self document];
-    NSRect visibleRect = [self visibleContentRect];
-    NSRange range = [self visiblePageIndexRange];
     unsigned int i;
+    NSRect visibleRect = onlyVisible ? [self visibleContentRect] : NSZeroRect;
     for (i = range.location; i < NSMaxRange(range); i++) {
         PDFPage *page = [pdfDoc pageAtIndex:i];
         NSEnumerator *annotationEnum = [[page annotations] objectEnumerator];
         PDFAnnotation *annotation;
         while (annotation = [annotationEnum nextObject]) {
-            if ([[annotation type] isEqualToString:SKLinkString] || 
[annotation isNoteAnnotation] && 
-                NSIntersectsRect([self convertRect:[annotation bounds] 
fromPage:[annotation page]], visibleRect))
+            if ([[annotation type] isEqualToString:SKLinkString] || 
[annotation isNoteAnnotation] &&
+                (onlyVisible == NO || NSIntersectsRect([self 
convertRect:[annotation bounds] fromPage:[annotation page]], visibleRect)))
                 [children addObject:[[[SKAccessibilityPDFAnnotationElement 
alloc] initWithAnnotation:annotation pdfView:self parent:[self documentView]] 
autorelease]];
         }
     }
     return children;
 }
 
+- (NSArray *)accessibilityChildren {
+    if ([self displayMode] == kPDFDisplaySinglePage || [self displayMode] == 
kPDFDisplayTwoUp) {
+        unsigned pageCount = [[self document] pageCount];
+        NSRange range = pageCount ? NSMakeRange([[self currentPage] 
pageIndex], 1) : NSMakeRange(NSNotFound, 0);
+        if (pageCount && [self displayMode] == kPDFDisplayTwoUp) {
+            range.length = 2;
+            if ((unsigned)[self displaysAsBook] != (range.location % 2)) {
+                if (range.location == 0)
+                    range.length = 1;
+                else
+                    range.location -= 1;
+            }
+            if (NSMaxRange(range) == pageCount)
+                range.length = 1;
+        }
+        return [self accessibilityChildrenForPageRange:range visible:NO];
+    } else {
+        if (accessibilityChildren == nil) {
+            NSRange range = NSMakeRange(0, [[self document] pageCount]);
+            accessibilityChildren = [[self 
accessibilityChildrenForPageRange:range visible:NO] copy];
+        }
+        return accessibilityChildren;
+    }
+}
+
+- (NSArray *)accessibilityVisibleChildren {
+    NSRange range = [self visiblePageIndexRange];
+    return [self accessibilityChildrenForPageRange:range visible:YES];
+}
+
 #pragma mark Snapshots
 
 - (void)takeSnapshot:(id)sender {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to