Revision: 3630
http://skim-app.svn.sourceforge.net/skim-app/?rev=3630&view=rev
Author: hofman
Date: 2008-04-04 17:35:09 -0700 (Fri, 04 Apr 2008)
Log Message:
-----------
Use OS dependent string constants for document types rather than functions.
Modified Paths:
--------------
trunk/SKDocument.m
trunk/SKDocumentController.h
trunk/SKDocumentController.m
Modified: trunk/SKDocument.m
===================================================================
--- trunk/SKDocument.m 2008-04-05 00:20:56 UTC (rev 3629)
+++ trunk/SKDocument.m 2008-04-05 00:35:09 UTC (rev 3630)
@@ -220,7 +220,7 @@
if (formatPopup) {
NSString *lastExportedType = [[NSUserDefaults
standardUserDefaults] stringForKey:SKLastExportedTypeKey];
if ([[self pdfDocument] allowsPrinting] == NO) {
- int idx = [formatPopup
indexOfItemWithRepresentedObject:SKGetEmbeddedPDFDocumentType()];
+ int idx = [formatPopup
indexOfItemWithRepresentedObject:SKEmbeddedPDFDocumentType];
if (idx != -1)
[formatPopup removeItemAtIndex:idx];
}
@@ -287,7 +287,7 @@
if (saveNotesOK) {
NSString *tmpPath = [NSTemporaryDirectory()
stringByAppendingPathComponent:[[NSProcessInfo processInfo]
globallyUniqueString]];
- if ([[self notes] count] == 0 || [self writeToURL:[NSURL
fileURLWithPath:tmpPath] ofType:SKGetNotesDocumentType() error:NULL]) {
+ if ([[self notes] count] == 0 || [self writeToURL:[NSURL
fileURLWithPath:tmpPath] ofType:SKNotesDocumentType error:NULL]) {
if (fileExists)
saveNotesOK = [fm removeFileAtPath:notesPath
handler:nil];
if ([[self notes] count]) {
Modified: trunk/SKDocumentController.h
===================================================================
--- trunk/SKDocumentController.h 2008-04-05 00:20:56 UTC (rev 3629)
+++ trunk/SKDocumentController.h 2008-04-05 00:35:09 UTC (rev 3630)
@@ -52,17 +52,17 @@
extern BOOL SKIsPostScriptDocumentType(NSString *docType);
extern BOOL SKIsDVIDocumentType(NSString *docType);
-extern NSString *SKGetPDFDocumentType();
-extern NSString *SKGetPDFBundleDocumentType();
-extern NSString *SKGetEmbeddedPDFDocumentType();
-extern NSString *SKGetBarePDFDocumentType();
-extern NSString *SKGetNotesDocumentType();
-extern NSString *SKGetNotesTextDocumentType();
-extern NSString *SKGetNotesRTFDocumentType();
-extern NSString *SKGetNotesRTFDDocumentType();
-extern NSString *SKGetNotesFDFDocumentType();
-extern NSString *SKGetPostScriptDocumentType();
-extern NSString *SKGetDVIDocumentType();
+extern NSString *SKPDFDocumentType;
+extern NSString *SKPDFBundleDocumentType;
+extern NSString *SKEmbeddedPDFDocumentType;
+extern NSString *SKBarePDFDocumentType;
+extern NSString *SKNotesDocumentType;
+extern NSString *SKNotesTextDocumentType;
+extern NSString *SKNotesRTFDocumentType;
+extern NSString *SKNotesRTFDDocumentType;
+extern NSString *SKNotesFDFDocumentType;
+extern NSString *SKPostScriptDocumentType;
+extern NSString *SKDVIDocumentType;
enum {
SKImagePboardTypesMask = 1,
Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m 2008-04-05 00:20:56 UTC (rev 3629)
+++ trunk/SKDocumentController.m 2008-04-05 00:35:09 UTC (rev 3630)
@@ -69,6 +69,18 @@
static NSString *SKPostScriptDocumentUTI = @"com.adobe.postscript";
static NSString *SKDVIDocumentUTI = @"net.sourceforge.skim-app.dvi"; // I
don't know the UTI for dvi, is there one?
+NSString *SKPDFDocumentType = nil;
+NSString *SKPDFBundleDocumentType = nil;
+NSString *SKEmbeddedPDFDocumentType = nil;
+NSString *SKBarePDFDocumentType = nil;
+NSString *SKNotesDocumentType = nil;
+NSString *SKNotesTextDocumentType = nil;
+NSString *SKNotesRTFDocumentType = nil;
+NSString *SKNotesRTFDDocumentType = nil;
+NSString *SKNotesFDFDocumentType = nil;
+NSString *SKPostScriptDocumentType = nil;
+NSString *SKDVIDocumentType = nil;
+
static BOOL SKIsEqualToDocumentType(NSString *docType, NSString *docTypeName,
NSString *docUTI) {
return ([[NSWorkspace sharedWorkspace]
respondsToSelector:@selector(type:conformsToType:)] && [[NSWorkspace
sharedWorkspace] type:docType conformsToType:docUTI]) || [docType
isEqualToString:docTypeName];
}
@@ -107,47 +119,35 @@
return SKIsEqualToDocumentType(docType, SKDVIDocumentTypeName,
SKDVIDocumentUTI);
}
-NSString *SKGetPDFDocumentType(void) {
- return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKPDFDocumentTypeName : SKPDFDocumentUTI;
-}
-NSString *SKGetPDFBundleDocumentType(void) {
- return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKPDFBundleDocumentTypeName : SKPDFBundleDocumentUTI;
-}
-NSString *SKGetEmbeddedPDFDocumentType(void) {
- return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKEmbeddedPDFDocumentTypeName : SKEmbeddedPDFDocumentUTI;
-}
-NSString *SKGetBarePDFDocumentType(void) {
- return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKBarePDFDocumentTypeName : SKBarePDFDocumentUTI;
-}
-NSString *SKGetNotesDocumentType(void) {
- return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKNotesDocumentTypeName : SKNotesDocumentUTI;
-}
-NSString *SKGetNotesTextDocumentType(void) {
- return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKNotesTextDocumentTypeName : SKTextDocumentUTI;
-}
-NSString *SKGetNotesRTFDocumentType(void) {
- return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKNotesRTFDocumentTypeName : SKRTFDocumentUTI;
-}
-NSString *SKGetNotesRTFDDocumentType(void) {
- return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKNotesRTFDDocumentTypeName : SKRTFDDocumentUTI;
-}
-NSString *SKGetNotesFDFDocumentType(void) {
- return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKNotesFDFDocumentTypeName : SKFDFDocumentUTI;
-}
-NSString *SKGetPostScriptDocumentType(void) {
- return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKPostScriptDocumentTypeName : SKPostScriptDocumentUTI;
-}
-NSString *SKGetDVIDocumentType(void) {
- return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKDVIDocumentTypeName : SKDVIDocumentUTI;
-}
-
@implementation SKDocumentController
+ (void)initialize {
OBINITIALIZE;
- if (nil == SKPDFDocumentTypeName)
- SKPDFDocumentTypeName = [NSPDFPboardType copy];
+ SKPDFDocumentTypeName = [NSPDFPboardType copy];
+ if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4) {
+ SKPDFBundleDocumentType = SKPDFDocumentTypeName;
+ SKEmbeddedPDFDocumentType = SKEmbeddedPDFDocumentTypeName;
+ SKBarePDFDocumentType = SKBarePDFDocumentTypeName;
+ SKNotesDocumentType = SKNotesDocumentTypeName;
+ SKNotesTextDocumentType = SKNotesTextDocumentTypeName;
+ SKNotesRTFDocumentType = SKNotesRTFDocumentTypeName;
+ SKNotesRTFDDocumentType = SKNotesRTFDDocumentTypeName;
+ SKNotesFDFDocumentType = SKNotesFDFDocumentTypeName;
+ SKPostScriptDocumentType = SKPostScriptDocumentTypeName;
+ SKDVIDocumentType = SKDVIDocumentTypeName;
+ } else {
+ SKPDFBundleDocumentType = SKPDFDocumentUTI;
+ SKEmbeddedPDFDocumentType = SKEmbeddedPDFDocumentUTI;
+ SKBarePDFDocumentType = SKBarePDFDocumentUTI;
+ SKNotesDocumentType = SKNotesDocumentUTI;
+ SKNotesTextDocumentType = SKTextDocumentUTI;
+ SKNotesRTFDocumentType = SKRTFDocumentUTI;
+ SKNotesRTFDDocumentType = SKRTFDDocumentUTI;
+ SKNotesFDFDocumentType = SKFDFDocumentUTI;
+ SKPostScriptDocumentType = SKPostScriptDocumentUTI;
+ SKDVIDocumentType = SKDVIDocumentUTI;
+ }
}
- (NSString *)typeFromFileExtension:(NSString *)fileExtensionOrHFSFileType {
@@ -155,7 +155,7 @@
if (SKIsEmbeddedPDFDocumentType(type) || SKIsBarePDFDocumentType(type)) {
// fix of bug when reading a PDF file on 10.4
// this is interpreted as SKEmbeddedPDFDocumentType, even though we
don't declare that as a readable type
- type = SKGetPDFDocumentType();
+ type = SKPDFDocumentType;
}
return type;
}
@@ -183,9 +183,9 @@
NSFileHandle *fh = [NSFileHandle
fileHandleForReadingAtPath:fileName];
NSData *leadingData = [fh readDataOfLength:headerLength];
if ([leadingData length] >= [pdfHeaderData length] &&
[pdfHeaderData isEqual:[leadingData subdataWithRange:NSMakeRange(0,
[pdfHeaderData length])]]) {
- type = SKGetPostScriptDocumentType();
+ type = SKPostScriptDocumentType;
} else if ([leadingData length] >= [psHeaderData length] &&
[psHeaderData isEqual:[leadingData subdataWithRange:NSMakeRange(0,
[psHeaderData length])]]) {
- type = SKGetPostScriptDocumentType();
+ type = SKPostScriptDocumentType;
}
}
if (type == nil && outError)
@@ -245,7 +245,7 @@
pboardType = NSPDFPboardType;
}
- NSString *type = [pboardType isEqualToString:NSPostScriptPboardType] ?
SKGetPostScriptDocumentType() : SKGetPDFDocumentType();
+ NSString *type = [pboardType isEqualToString:NSPostScriptPboardType] ?
SKPostScriptDocumentType : SKPDFDocumentType;
NSError *error = nil;
document = [self makeUntitledDocumentOfType:type error:&error];
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
Register now and save $200. Hurry, offer ends at 11:59 p.m.,
Monday, April 7! Use priority code J8TLD2.
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