Revision: 12379
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12379&view=rev
Author:   hofman
Date:     2008-01-08 17:34:18 -0800 (Tue, 08 Jan 2008)

Log Message:
-----------
Add support for PDFD bundles.

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon_Private.h
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.h
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m  2008-01-09 01:02:48 UTC 
(rev 12378)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m  2008-01-09 01:34:18 UTC 
(rev 12379)
@@ -199,6 +199,9 @@
     else if (UTTypeConformsTo(theUTI, CFSTR("com.adobe.postscript"))) {
         anIcon = [[FVPDFIcon allocWithZone:[self zone]] 
initWithPostscriptAtURL:representedURL];
     }
+    else if (UTTypeConformsTo(theUTI, CFSTR("net.sourceforge.skim-app.pdfd"))) 
{
+        anIcon = [[FVPDFIcon allocWithZone:[self zone]] 
initWithPDFDAtURL:representedURL];
+    }
     else if (UTTypeConformsTo(theUTI, kUTTypeImage)) {
         anIcon = [[FVCGImageIcon allocWithZone:[self zone]] 
initWithImageAtURL:representedURL];
     }

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon_Private.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon_Private.h  2008-01-09 
01:02:48 UTC (rev 12378)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon_Private.h  2008-01-09 
01:34:18 UTC (rev 12379)
@@ -53,6 +53,7 @@
     FVImageFileType,
     FVQTMovieType,
     FVPDFType,
+    FVPDFDType,
     FVPostscriptType
 };
 typedef NSUInteger FVIconType;

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.h       2008-01-09 
01:02:48 UTC (rev 12378)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.h       2008-01-09 
01:34:18 UTC (rev 12379)
@@ -59,5 +59,6 @@
     BOOL              _drawsLinkBadge;
 }
 - (id)initWithPDFAtURL:(NSURL *)aURL;
+- (id)initWithPDFDAtURL:(NSURL *)aURL;
 - (id)initWithPostscriptAtURL:(NSURL *)aURL;
 @end

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m       2008-01-09 
01:02:48 UTC (rev 12378)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m       2008-01-09 
01:34:18 UTC (rev 12379)
@@ -37,6 +37,7 @@
  */
 
 #import "FVPDFIcon.h"
+#import "FVFinderIcon.h"
 
 // cache these so we avoid hitting NSPrintInfo; we only care to have something 
that approximates a page size, anyway
 static NSSize __paperSize;
@@ -82,14 +83,49 @@
     return pdfDoc;
 }
 
+static NSURL *PDFURLForPDFBundleURL(NSURL *aURL)
+{
+    NSString *filePath = [aURL path];
+    NSArray *files = [[NSFileManager defaultManager] subpathsAtPath:filePath];
+    NSString *fileName = [[[filePath lastPathComponent] 
stringByDeletingPathExtension] stringByAppendingPathExtension:@"pdf"];
+    NSString *pdfFile = nil;
+    
+    if ([files containsObject:fileName]) {
+        pdfFile = fileName;
+    } else {
+        unsigned int idx = [[files 
valueForKeyPath:@"pathExtension.lowercaseString"] indexOfObject:@"pdf"];
+        if (idx != NSNotFound)
+            pdfFile = [files objectAtIndex:idx];
+    }
+    if (pdfFile)
+        pdfFile = [filePath stringByAppendingPathComponent:pdfFile];
+    return pdfFile ? [NSURL fileURLWithPath:pdfFile] : nil;
+}
+
 // return the same thing as PDF; just a container for the URL, until actually 
asked to render the PS file
 - (id)initWithPostscriptAtURL:(NSURL *)aURL;
 {
-    self = [self initWithPDFAtURL:aURL];
-    _iconType = FVPostscriptType;
+    if (self = [self initWithPDFAtURL:aURL]) {
+        _iconType = FVPostscriptType;
+    }
     return self;
 }
 
+// return the same thing as PDF; just a container for the URL, until actually 
asked to render the PDF file
+- (id)initWithPDFDAtURL:(NSURL *)aURL;
+{
+    if (self = [self initWithPDFAtURL:aURL]) {
+        if (PDFURLForPDFBundleURL(_fileURL)) {
+            _iconType = FVPDFDType;
+        } else {
+            NSZone *zone = [self zone];
+            [self release];
+            self = [[FVFinderIcon allocWithZone:zone] 
initWithFinderIconOfURL:aURL];
+        }
+    }
+    return self;
+}
+
 - (id)initWithPDFAtURL:(NSURL *)aURL;
 {
     self = [super init];
@@ -268,6 +304,8 @@
         if (NULL == _pdfDoc) {
             if (FVPDFType == _iconType)
                 _pdfDoc = CGPDFDocumentCreateWithURL((CFURLRef)_fileURL);
+            else if (FVPDFDType == _iconType)
+                _pdfDoc = 
CGPDFDocumentCreateWithURL((CFURLRef)PDFURLForPDFBundleURL(_fileURL));
             else
                 _pdfDoc = createCGPDFDocumentWithPostScriptURL(_fileURL);
             


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

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to