Revision: 5355
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5355&view=rev
Author:   hofman
Date:     2009-05-06 17:49:10 +0000 (Wed, 06 May 2009)

Log Message:
-----------
simplify reading by inverting type checks

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

Modified: trunk/SKPDFDocument.m
===================================================================
--- trunk/SKPDFDocument.m       2009-05-06 17:16:22 UTC (rev 5354)
+++ trunk/SKPDFDocument.m       2009-05-06 17:49:10 UTC (rev 5355)
@@ -680,7 +680,32 @@
     [self setOpenMetaTags:nil];
     [self setOpenMetaRating:0.0];
     
-    if (SKIsPDFDocumentType(docType) || SKIsPostScriptDocumentType(docType) || 
SKIsDVIDocumentType(docType)) {
+    if (SKIsPDFBundleDocumentType(docType)) {
+        NSString *path = [absoluteURL path];
+        NSString *pdfFile = [[NSFileManager defaultManager] 
bundledFileWithExtension:@"pdf" inPDFBundleAtPath:path error:&error];
+        if (pdfFile) {
+            NSURL *pdfURL = [NSURL fileURLWithPath:pdfFile];
+            if ((data = [[NSData alloc] initWithContentsOfURL:pdfURL 
options:NSUncachedRead error:&error]) &&
+                (pdfDoc = [[PDFDocument alloc] initWithURL:pdfURL])) {
+                NSArray *array = [[NSFileManager defaultManager] 
readSkimNotesFromPDFBundleAtURL:absoluteURL error:&error];
+                if (array == nil) {
+                    NSAlert *alert = [NSAlert 
alertWithMessageText:NSLocalizedString(@"Unable to Read Notes", @"Message in 
alert dialog") 
+                                                     
defaultButton:NSLocalizedString(@"No", @"Button title")
+                                                   
alternateButton:NSLocalizedString(@"Yes", @"Button title")
+                                                       otherButton:nil
+                                         
informativeTextWithFormat:NSLocalizedString(@"Skim was not able to read the 
notes at %...@. %@ Do you want to continue to open the PDF document anyway?", 
@"Informative text in alert dialog"), [path 
stringByAbbreviatingWithTildeInPath], [[error userInfo] 
objectForKey:NSLocalizedDescriptionKey]];
+                    if ([alert runModal] == NSAlertDefaultReturn) {
+                        [data release];
+                        data = nil;
+                        [pdfDoc release];
+                        pdfDoc = nil;
+                    }
+                } else if ([array count]) {
+                    [self setNoteDicts:array];
+                }
+            }
+        }
+    } else  {
         if (fileData = [[NSData alloc] initWithContentsOfURL:absoluteURL 
options:NSUncachedRead error:&error]) {
             if (SKIsPDFDocumentType(docType)) {
                 if (data = [fileData retain])
@@ -737,31 +762,6 @@
                 }
             }
         }
-    } else if (SKIsPDFBundleDocumentType(docType)) {
-        NSString *path = [absoluteURL path];
-        NSString *pdfFile = [[NSFileManager defaultManager] 
bundledFileWithExtension:@"pdf" inPDFBundleAtPath:path error:&error];
-        if (pdfFile) {
-            NSURL *pdfURL = [NSURL fileURLWithPath:pdfFile];
-            if ((data = [[NSData alloc] initWithContentsOfURL:pdfURL 
options:NSUncachedRead error:&error]) &&
-                (pdfDoc = [[PDFDocument alloc] initWithURL:pdfURL])) {
-                NSArray *array = [[NSFileManager defaultManager] 
readSkimNotesFromPDFBundleAtURL:absoluteURL error:&error];
-                if (array == nil) {
-                    NSAlert *alert = [NSAlert 
alertWithMessageText:NSLocalizedString(@"Unable to Read Notes", @"Message in 
alert dialog") 
-                                                     
defaultButton:NSLocalizedString(@"No", @"Button title")
-                                                   
alternateButton:NSLocalizedString(@"Yes", @"Button title")
-                                                       otherButton:nil
-                                         
informativeTextWithFormat:NSLocalizedString(@"Skim was not able to read the 
notes at %...@. %@ Do you want to continue to open the PDF document anyway?", 
@"Informative text in alert dialog"), [path 
stringByAbbreviatingWithTildeInPath], [[error userInfo] 
objectForKey:NSLocalizedDescriptionKey]];
-                    if ([alert runModal] == NSAlertDefaultReturn) {
-                        [data release];
-                        data = nil;
-                        [pdfDoc release];
-                        pdfDoc = nil;
-                    }
-                } else if ([array count]) {
-                    [self setNoteDicts:array];
-                }
-            }
-        }
     }
     
     if (data) {
@@ -802,8 +802,8 @@
             [self setPDFData:nil];
         }
         [data release];
-        [fileData release];
     }
+    [fileData release];
     
     if (didRead == NO && outError != NULL)
         *outError = error ?: [NSError errorWithDomain:SKDocumentErrorDomain 
code:0 userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable to load file", @"Error 
description"), NSLocalizedDescriptionKey, nil]];


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

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to