Revision: 3443
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3443&view=rev
Author:   hofman
Date:     2008-02-25 05:23:58 -0800 (Mon, 25 Feb 2008)

Log Message:
-----------
Use UTIs for document types on Leopard.

Modified Paths:
--------------
    trunk/Info.plist
    trunk/SKDocument.m
    trunk/SKDocumentController.m

Modified: trunk/Info.plist
===================================================================
--- trunk/Info.plist    2008-02-25 11:17:12 UTC (rev 3442)
+++ trunk/Info.plist    2008-02-25 13:23:58 UTC (rev 3443)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
@@ -26,6 +26,10 @@
                        </array>
                        <key>CFBundleTypeRole</key>
                        <string>Editor</string>
+                       <key>LSItemContentTypes</key>
+                       <array>
+                               <string>com.adobe.pdf</string>
+                       </array>
                        <key>LSTypeIsPackage</key>
                        <false/>
                        <key>NSDocumentClass</key>
@@ -42,6 +46,18 @@
                                <string>Notes as RTFD</string>
                                <string>Notes as FDF</string>
                        </array>
+                       <key>NSExportableTypes</key>
+                       <array>
+                               <string>com.adobe.pdf</string>
+                               <string>net.sourceforge.skim-app.pdfd</string>
+                               
<string>net.sourceforge.skim-app.embedded.pdf</string>
+                               
<string>net.sourceforge.skim-app.bare.pdf</string>
+                               
<string>net.sourceforge.skim-app.skimnotes</string>
+                               <string>public.plain-text</string>
+                               <string>com.apple.rtf</string>
+                               <string>com.apple.rtfd</string>
+                               <string>com.adobe.fdf</string>
+                       </array>
                </dict>
                <dict>
                        <key>CFBundleTypeExtensions</key>
@@ -60,6 +76,10 @@
                        <string>Editor</string>
                        <key>LSIsAppleDefaultForType</key>
                        <true/>
+                       <key>LSItemContentTypes</key>
+                       <array>
+                               <string>net.sourceforge.skim-app.pdfd</string>
+                       </array>
                        <key>LSTypeIsPackage</key>
                        <true/>
                        <key>NSDocumentClass</key>
@@ -76,6 +96,18 @@
                                <string>Notes as RTFD</string>
                                <string>Notes as FDF</string>
                        </array>
+                       <key>NSExportableTypes</key>
+                       <array>
+                               <string>com.adobe.pdf</string>
+                               <string>net.sourceforge.skim-app.pdfd</string>
+                               
<string>net.sourceforge.skim-app.embedded.pdf</string>
+                               
<string>net.sourceforge.skim-app.bare.pdf</string>
+                               
<string>net.sourceforge.skim-app.skimnotes</string>
+                               <string>public.plain-text</string>
+                               <string>com.apple.rtf</string>
+                               <string>com.apple.rtfd</string>
+                               <string>com.adobe.fdf</string>
+                       </array>
                        <key>NSPersistentStoreTypeKey</key>
                        <string>Binary</string>
                </dict>
@@ -96,6 +128,10 @@
                        <string>Editor</string>
                        <key>LSIsAppleDefaultForType</key>
                        <true/>
+                       <key>LSItemContentTypes</key>
+                       <array>
+                               
<string>net.sourceforge.skim-app.skimnotes</string>
+                       </array>
                        <key>LSTypeIsPackage</key>
                        <false/>
                        <key>NSDocumentClass</key>
@@ -105,6 +141,11 @@
                                <string>Notes as RTF</string>
                                <string>Notes as Text</string>
                        </array>
+                       <key>NSExportableTypes</key>
+                       <array>
+                               <string>public.plain-text</string>
+                               <string>com.apple.rtf</string>
+                       </array>
                        <key>NSPersistentStoreTypeKey</key>
                        <string>Binary</string>
                </dict>
@@ -127,6 +168,10 @@
                        <string>PostScript document</string>
                        <key>CFBundleTypeRole</key>
                        <string>Viewer</string>
+                       <key>LSItemContentTypes</key>
+                       <array>
+                               <string>com.adobe.postscript</string>
+                       </array>
                        <key>LSTypeIsPackage</key>
                        <false/>
                        <key>NSDocumentClass</key>
@@ -135,6 +180,10 @@
                        <array>
                                <string>NSPDFPboardType</string>
                        </array>
+                       <key>NSExportableType</key>
+                       <array>
+                               <string>com.adobe.pdf</string>
+                       </array>
                </dict>
                <dict>
                        <key>CFBundleTypeExtensions</key>
@@ -155,6 +204,10 @@
                        </array>
                        <key>CFBundleTypeRole</key>
                        <string>Viewer</string>
+                       <key>LSItemContentTypes</key>
+                       <array>
+                               <string>net.sourceforge.skim-app.dvi</string>
+                       </array>
                        <key>LSTypeIsPackage</key>
                        <false/>
                        <key>NSDocumentClass</key>
@@ -181,6 +234,10 @@
                        </array>
                        <key>CFBundleTypeRole</key>
                        <string>None</string>
+                       <key>LSItemContentTypes</key>
+                       <array>
+                               
<string>net.sourceforge.skim-app.embedded.pdf</string>
+                       </array>
                        <key>LSTypeIsPackage</key>
                        <false/>
                        <key>NSDocumentClass</key>
@@ -207,6 +264,10 @@
                        </array>
                        <key>CFBundleTypeRole</key>
                        <string>None</string>
+                       <key>LSItemContentTypes</key>
+                       <array>
+                               
<string>net.sourceforge.skim-app.bare.pdf</string>
+                       </array>
                        <key>LSTypeIsPackage</key>
                        <false/>
                        <key>NSDocumentClass</key>
@@ -227,6 +288,10 @@
                        <string>Notes as Text</string>
                        <key>CFBundleTypeRole</key>
                        <string>None</string>
+                       <key>LSItemContentTypes</key>
+                       <array>
+                               <string>public.plain-text</string>
+                       </array>
                        <key>LSTypeIsPackage</key>
                        <false/>
                        <key>NSDocumentClass</key>
@@ -251,6 +316,10 @@
                        </array>
                        <key>CFBundleTypeRole</key>
                        <string>None</string>
+                       <key>LSItemContentTypes</key>
+                       <array>
+                               <string>com.apple.rtf</string>
+                       </array>
                        <key>LSTypeIsPackage</key>
                        <false/>
                        <key>NSDocumentClass</key>
@@ -275,6 +344,10 @@
                        </array>
                        <key>CFBundleTypeRole</key>
                        <string>None</string>
+                       <key>LSItemContentTypes</key>
+                       <array>
+                               <string>com.apple.rtfd</string>
+                       </array>
                        <key>LSTypeIsPackage</key>
                        <true/>
                        <key>NSDocumentClass</key>
@@ -299,6 +372,10 @@
                        </array>
                        <key>CFBundleTypeRole</key>
                        <string>Viewer</string>
+                       <key>LSItemContentTypes</key>
+                       <array>
+                               <string>com.adobe.fdf</string>
+                       </array>
                        <key>LSTypeIsPackage</key>
                        <false/>
                        <key>NSDocumentClass</key>
@@ -423,6 +500,155 @@
                                </array>
                        </dict>
                </dict>
+               <dict>
+                       <key>UTTypeConformsTo</key>
+                       <array>
+                               <string>public.data</string>
+                               <string>public.composite-content</string>
+                               <string>com.apple.pdf</string>
+                       </array>
+                       <key>UTTypeDescription</key>
+                       <string>PDF With Embedded Notes</string>
+                       <key>UTTypeIconFile</key>
+                       <string>PDFDDocument</string>
+                       <key>UTTypeIdentifier</key>
+                       <string>net.sourceforge.skim-app.embedded.pdf</string>
+                       <key>UTTypeTagSpecification</key>
+                       <dict>
+                               <key>com.apple.ostype</key>
+                               <string>PDF </string>
+                               <key>public.filename-extension</key>
+                               <array>
+                                       <string>pdf</string>
+                               </array>
+                       </dict>
+               </dict>
+               <dict>
+                       <key>UTTypeConformsTo</key>
+                       <array>
+                               <string>public.data</string>
+                               <string>public.composite-content</string>
+                               <string>com.apple.pdf</string>
+                       </array>
+                       <key>UTTypeDescription</key>
+                       <string>PDF Without Notes</string>
+                       <key>UTTypeIconFile</key>
+                       <string>PDFDDocument</string>
+                       <key>UTTypeIdentifier</key>
+                       <string>net.sourceforge.skim-app.bare.pdf</string>
+                       <key>UTTypeTagSpecification</key>
+                       <dict>
+                               <key>com.apple.ostype</key>
+                               <string>PDF </string>
+                               <key>public.filename-extension</key>
+                               <array>
+                                       <string>pdf</string>
+                               </array>
+                       </dict>
+               </dict>
        </array>
+       <key>UTImportedTypeDeclarations</key>
+       <array>
+               <dict>
+                       <key>UTTypeConformsTo</key>
+                       <array>
+                               <string>public.data</string>
+                               <string>public.composite-content</string>
+                       </array>
+                       <key>UTTypeDescription</key>
+                       <string>PDF</string>
+                       <key>UTTypeIconFile</key>
+                       <string>PDFDDocument</string>
+                       <key>UTTypeIdentifier</key>
+                       <string>com.adobe.pdf</string>
+                       <key>UTTypeTagSpecification</key>
+                       <dict>
+                               <key>com.apple.ostype</key>
+                               <string>PDF</string>
+                               <key>public.filename-extension</key>
+                               <array>
+                                       <string>pdf</string>
+                               </array>
+                       </dict>
+               </dict>
+               <dict>
+                       <key>UTTypeConformsTo</key>
+                       <array>
+                               <string>public.text</string>
+                       </array>
+                       <key>UTTypeDescription</key>
+                       <string>Text</string>
+                       <key>UTTypeIdentifier</key>
+                       <string>public.plain-text</string>
+                       <key>UTTypeTagSpecification</key>
+                       <dict>
+                               <key>com.apple.ostype</key>
+                               <string>TEXT</string>
+                               <key>public.filename-extension</key>
+                               <array>
+                                       <string>txt</string>
+                               </array>
+                       </dict>
+               </dict>
+               <dict>
+                       <key>UTTypeConformsTo</key>
+                       <array>
+                               <string>public.text</string>
+                       </array>
+                       <key>UTTypeDescription</key>
+                       <string>RTF</string>
+                       <key>UTTypeIdentifier</key>
+                       <string>com.apple.rtf</string>
+                       <key>UTTypeTagSpecification</key>
+                       <dict>
+                               <key>com.apple.ostype</key>
+                               <string>RTF </string>
+                               <key>public.filename-extension</key>
+                               <array>
+                                       <string>rtf</string>
+                               </array>
+                       </dict>
+               </dict>
+               <dict>
+                       <key>UTTypeConformsTo</key>
+                       <array>
+                               <string>com.apple.package</string>
+                               <string>public.composite-​content</string>
+                       </array>
+                       <key>UTTypeDescription</key>
+                       <string>RTFD</string>
+                       <key>UTTypeIdentifier</key>
+                       <string>com.apple.rtfd</string>
+                       <key>UTTypeTagSpecification</key>
+                       <dict>
+                               <key>com.apple.ostype</key>
+                               <string>RTFD</string>
+                               <key>public.filename-extension</key>
+                               <array>
+                                       <string>rtfd</string>
+                               </array>
+                       </dict>
+               </dict>
+               <dict>
+                       <key>UTTypeConformsTo</key>
+                       <array>
+                               <string>public.data</string>
+                               <string>public.composite-content</string>
+                       </array>
+                       <key>UTTypeDescription</key>
+                       <string>FDF</string>
+                       <key>UTTypeIdentifier</key>
+                       <string>com.adobe.fdf</string>
+                       <key>UTTypeTagSpecification</key>
+                       <dict>
+                               <key>com.apple.ostype</key>
+                               <string>FDF </string>
+                               <key>public.filename-extension</key>
+                               <array>
+                                       <string>fdf</string>
+                               </array>
+                       </dict>
+               </dict>
+       </array>
 </dict>
 </plist>

Modified: trunk/SKDocument.m
===================================================================
--- trunk/SKDocument.m  2008-02-25 11:17:12 UTC (rev 3442)
+++ trunk/SKDocument.m  2008-02-25 13:23:58 UTC (rev 3443)
@@ -225,11 +225,16 @@
                     [formatPopup removeItemAtIndex:index];
             }
             if (lastExportedType) {
-                int index = [formatPopup 
indexOfItemWithRepresentedObject:lastExportedType];
-                if (index != -1 && index != [formatPopup indexOfSelectedItem]) 
{
-                    [formatPopup selectItemAtIndex:index];
+                int idx = [formatPopup 
indexOfItemWithRepresentedObject:lastExportedType];
+                if (idx != -1 && idx != [formatPopup indexOfSelectedItem]) {
+                    [formatPopup selectItemAtIndex:idx];
                     [formatPopup sendAction:[formatPopup action] 
to:[formatPopup target]];
-                    [savePanel setAllowedFileTypes:[[NSDocumentController 
sharedDocumentController] fileExtensionsFromType:lastExportedType]];
+                    NSArray *fileTypes = nil;
+                    if ([self 
respondsToSelector:@selector(fileNameExtensionForType:saveOperation:)])
+                        fileTypes = [NSArray arrayWithObjects:[self 
fileNameExtensionForType:lastExportedType saveOperation:NSSaveToOperation], 
nil];
+                    else
+                        fileTypes = [[NSDocumentController 
sharedDocumentController] fileExtensionsFromType:lastExportedType];
+                    [savePanel setAllowedFileTypes:fileTypes];
                 }
             }
         }

Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m        2008-02-25 11:17:12 UTC (rev 3442)
+++ trunk/SKDocumentController.m        2008-02-25 13:23:58 UTC (rev 3443)
@@ -89,15 +89,17 @@
 }
 
 - (NSString *)typeForContentsOfURL:(NSURL *)inAbsoluteURL error:(NSError 
**)outError {
+    unsigned int headerLength = 5;
+    
     static NSData *pdfHeaderData = nil;
     if (nil == pdfHeaderData) {
         char *h = "%PDF-";
-        pdfHeaderData = [[NSData alloc] initWithBytes:h length:strlen(h)];
+        pdfHeaderData = [[NSData alloc] initWithBytes:h length:headerLength];
     }
     static NSData *psHeaderData = nil;
     if (nil == psHeaderData) {
         char *h = "%!PS-";
-        psHeaderData = [[NSData alloc] initWithBytes:h length:strlen(h)];
+        psHeaderData = [[NSData alloc] initWithBytes:h length:headerLength];
     }
     
     NSError *error = nil;
@@ -107,11 +109,11 @@
         if ([inAbsoluteURL isFileURL]) {
             NSString *fileName = [inAbsoluteURL path];
             NSFileHandle *fh = [NSFileHandle 
fileHandleForReadingAtPath:fileName];
-            NSData *leadingData = [fh readDataOfLength:5];
+            NSData *leadingData = [fh readDataOfLength:headerLength];
             if ([leadingData length] >= [pdfHeaderData length] && 
[pdfHeaderData isEqual:[leadingData subdataWithRange:NSMakeRange(0, 
[pdfHeaderData length])]]) {
-                type = SKPDFDocumentType;
+                type = floor(NSAppKitVersionNumber) <= 
NSAppKitVersionNumber10_4 ? SKPDFDocumentType : SKPDFDocumentUTI;
             } else if ([leadingData length] >= [psHeaderData length] && 
[psHeaderData isEqual:[leadingData subdataWithRange:NSMakeRange(0, 
[psHeaderData length])]]) {
-                type = SKPostScriptDocumentType;
+                type = floor(NSAppKitVersionNumber) <= 
NSAppKitVersionNumber10_4 ? SKPostScriptDocumentType : SKPostScriptDocumentUTI;
             }
         }
         if (type == nil && outError)


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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to