Revision: 7741
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7741&view=rev
Author:   hofman
Date:     2012-10-22 11:57:06 +0000 (Mon, 22 Oct 2012)
Log Message:
-----------
convenience checks for document types

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

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2012-10-22 00:13:04 UTC (rev 7740)
+++ trunk/SKMainDocument.m      2012-10-22 11:57:06 UTC (rev 7741)
@@ -335,10 +335,17 @@
     return [super fileNameExtensionForType:typeName 
saveOperation:saveOperation] ?: [[SKTemplateManager sharedManager] 
fileNameExtensionForTemplateType:typeName];
 }
 
+- (BOOL)canAttachNotesForType:(NSString *)typeName {
+    return ([typeName isEqualToString:SKPDFDocumentType] || 
+            [typeName isEqualToString:SKPostScriptDocumentType] || 
+            [typeName isEqualToString:SKDVIDocumentType] || 
+            [typeName isEqualToString:SKXDVDocumentType]);
+}
+
 - (void)updateExportAccessoryView {
     NSString *typeName = [self fileTypeFromLastRunSavePanel];
     NSMatrix *matrix = [exportAccessoryController matrix];
-    if ([typeName isEqualToString:SKPDFDocumentType] || [typeName 
isEqualToString:SKPostScriptDocumentType] || [typeName 
isEqualToString:SKDVIDocumentType] || [typeName 
isEqualToString:SKXDVDocumentType]) {
+    if ([self canAttachNotesForType:typeName]) {
         [matrix setHidden:NO];
         if ([typeName isEqualToString:SKPDFDocumentType] && [[self 
pdfDocument] allowsPrinting]) {
             [[matrix cellWithTag:SKExportOptionWithEmbeddedNotes] 
setEnabled:YES];
@@ -482,7 +489,7 @@
         NSURL *absoluteURL = [info objectForKey:URL_KEY];
         NSString *typeName = [info objectForKey:TYPE_KEY];
         
-        if (([typeName isEqualToString:SKPDFDocumentType] || [typeName 
isEqualToString:SKPostScriptDocumentType] || [typeName 
isEqualToString:SKDVIDocumentType] || [typeName 
isEqualToString:SKXDVDocumentType]) && exportOption == SKExportOptionDefault) {
+        if ([self canAttachNotesForType:typeName] && exportOption == 
SKExportOptionDefault) {
             // we check for notes and may save a .skim as well:
             [self saveNotesToURL:absoluteURL forSaveOperation:saveOperation];
         } else if ([typeName isEqualToString:SKPDFBundleDocumentType] && 
tmpPath) {
@@ -602,15 +609,11 @@
             didWrite = [[self pdfDocument] writeToURL:absoluteURL];
         else
             didWrite = [pdfData writeToURL:absoluteURL options:0 error:&error];
-    } else if ([typeName isEqualToString:SKPostScriptDocumentType]) {
-        if ([[self fileType] isEqualToString:SKPostScriptDocumentType])
+    } else if ([typeName isEqualToString:SKPostScriptDocumentType] || 
+               [typeName isEqualToString:SKDVIDocumentType] || 
+               [typeName isEqualToString:SKXDVDocumentType]) {
+        if ([[self fileType] isEqualToString:typeName])
             didWrite = [originalData writeToURL:absoluteURL options:0 
error:&error];
-    } else if ([typeName isEqualToString:SKDVIDocumentType]) {
-        if ([[self fileType] isEqualToString:SKDVIDocumentType])
-            didWrite = [originalData writeToURL:absoluteURL options:0 
error:&error];
-    } else if ([typeName isEqualToString:SKXDVDocumentType]) {
-        if ([[self fileType] isEqualToString:SKXDVDocumentType])
-            didWrite = [originalData writeToURL:absoluteURL options:0 
error:&error];
     } else if ([typeName isEqualToString:SKPDFBundleDocumentType]) {
         NSFileWrapper *fileWrapper = [self 
PDFBundleFileWrapperForName:[[[absoluteURL path] lastPathComponent] 
stringByDeletingPathExtension]];
         if (fileWrapper)
@@ -671,7 +674,8 @@
     NSMutableDictionary *dict = [[[super 
fileAttributesToWriteToURL:absoluteURL ofType:typeName 
forSaveOperation:saveOperation originalContentsURL:absoluteOriginalContentsURL 
error:outError] mutableCopy] autorelease];
     
     // only set the creator code for our native types
-    if ([[NSUserDefaults standardUserDefaults] 
boolForKey:SKShouldSetCreatorCodeKey] && ([typeName 
isEqualToString:SKPDFDocumentType] || [typeName 
isEqualToString:SKPDFBundleDocumentType] || [typeName 
isEqualToString:SKPostScriptDocumentType] || [typeName 
isEqualToString:SKDVIDocumentType] || [typeName 
isEqualToString:SKXDVDocumentType] || [typeName 
isEqualToString:SKNotesDocumentType]))
+    if ([[NSUserDefaults standardUserDefaults] 
boolForKey:SKShouldSetCreatorCodeKey] && 
+        ([[self class] isNativeType:typeName] || [typeName 
isEqualToString:SKNotesDocumentType]))
         [dict setObject:[NSNumber numberWithUnsignedInt:'SKim'] 
forKey:NSFileHFSCreatorCode];
     
     if ([[[absoluteURL path] pathExtension] isEqualToString:@"pdf"] || 

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


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to