Revision: 2748
http://skim-app.svn.sourceforge.net/skim-app/?rev=2748&view=rev
Author: hofman
Date: 2007-08-28 10:12:56 -0700 (Tue, 28 Aug 2007)
Log Message:
-----------
Fix exportable types. Return a standard error when writing fails and the error
has not been set. make sure we save chosen export type only when exporting
using the panel.
Modified Paths:
--------------
trunk/Info.plist
trunk/SKDocument.h
trunk/SKDocument.m
Modified: trunk/Info.plist
===================================================================
--- trunk/Info.plist 2007-08-28 16:25:19 UTC (rev 2747)
+++ trunk/Info.plist 2007-08-28 17:12:56 UTC (rev 2748)
@@ -37,7 +37,7 @@
<key>NSExportableAs</key>
<array>
<string>NSPDFPboardType</string>
- <string>PDF Package</string>
+ <string>PDF Bundle</string>
<string>PDF With Embedded Notes</string>
<string>PDF Without Notes</string>
<string>Skim Notes</string>
@@ -73,6 +73,7 @@
<key>NSExportableAs</key>
<array>
<string>NSPDFPboardType</string>
+ <string>PDF Bundle</string>
<string>PDF With Embedded Notes</string>
<string>PDF Without Notes</string>
<string>Skim Notes</string>
Modified: trunk/SKDocument.h
===================================================================
--- trunk/SKDocument.h 2007-08-28 16:25:19 UTC (rev 2747)
+++ trunk/SKDocument.h 2007-08-28 17:12:56 UTC (rev 2748)
@@ -81,7 +81,7 @@
BOOL autoUpdate;
BOOL isSaving;
BOOL fileChangedOnDisk;
- NSSaveOperationType currentSaveOperation;
+ BOOL exportUsingPanel;
// only used for network filesystems; fileUpdateTimer is not retained by
the doc
NSDate *lastModifiedDate;
Modified: trunk/SKDocument.m
===================================================================
--- trunk/SKDocument.m 2007-08-28 16:25:19 UTC (rev 2747)
+++ trunk/SKDocument.m 2007-08-28 17:12:56 UTC (rev 2748)
@@ -174,7 +174,7 @@
}
- (BOOL)prepareSavePanel:(NSSavePanel *)savePanel {
- if (currentSaveOperation == NSSaveToOperation) {
+ if (exportUsingPanel) {
NSPopUpButton *formatPopup = popUpButtonSubview([savePanel
accessoryView]);
NSString *lastExportedType = [[NSUserDefaults standardUserDefaults]
stringForKey:@"SKLastExportedType"];
if ([[self pdfDocument] allowsPrinting] == NO) {
@@ -195,7 +195,8 @@
- (void)runModalSavePanelForSaveOperation:(NSSaveOperationType)saveOperation
delegate:(id)delegate didSaveSelector:(SEL)didSaveSelector contextInfo:(void
*)contextInfo {
// Override so we can determine if this is a save, saveAs or export
operation, so we can prepare the correct accessory view
- currentSaveOperation = saveOperation;
+ if (saveOperation == NSSaveToOperation)
+ exportUsingPanel = YES;
[super runModalSavePanelForSaveOperation:saveOperation delegate:delegate
didSaveSelector:didSaveSelector contextInfo:contextInfo];
}
@@ -203,7 +204,7 @@
if (saveOperation == NSSaveOperation || saveOperation ==
NSSaveAsOperation) {
[self stopCheckingFileUpdates];
isSaving = YES;
- } else if (saveOperation == NSSaveToOperation) {
+ } else if (exportUsingPanel) {
[[NSUserDefaults standardUserDefaults] setObject:typeName
forKey:@"SKLastExportedType"];
}
@@ -211,6 +212,7 @@
// we check for notes and may save a .skim as well:
if ([typeName isEqualToString:SKPDFDocumentType]) {
+
NSFileManager *fm = [NSFileManager defaultManager];
if (success = [super saveToURL:absoluteURL ofType:typeName
forSaveOperation:saveOperation error:outError]) {
@@ -247,12 +249,12 @@
}
} else if ([typeName isEqualToString:SKPDFBundleDocumentType]) {
+
NSFileManager *fm = [NSFileManager defaultManager];
NSString *path = [absoluteURL path];
BOOL isDir = NO;
- BOOL fileExists = [fm fileExistsAtPath:path isDirectory:&isDir];
- if (fileExists == NO || isDir == NO) {
+ if ([fm fileExistsAtPath:path isDirectory:&isDir] == NO || isDir ==
NO) {
success = [super saveToURL:absoluteURL ofType:typeName
forSaveOperation:saveOperation error:outError];
} else {
NSString *filename = [path lastPathComponent];
@@ -262,7 +264,7 @@
if (success = [self writeToURL:tmpURL ofType:typeName
error:outError]) {
- NSSet *knownExtensions = [NSSet setWithObjects:@"pdf",
@"skim", @"txt", @"text", @"rtf", nil];
+ NSSet *ourExtensions = [NSSet setWithObjects:@"pdf", @"skim",
@"txt", @"text", @"rtf", nil];
NSEnumerator *fileEnum;
NSString *file;
NSMutableDictionary *attributes = [[fm
fileAttributesAtPath:path traverseLink:YES] mutableCopy];
@@ -276,7 +278,7 @@
fileEnum = [[fm directoryContentsAtPath:path]
objectEnumerator];
while (file = [fileEnum nextObject]) {
- if ([knownExtensions containsObject:[[file pathExtension]
lowercaseString]])
+ if ([ourExtensions containsObject:[[file pathExtension]
lowercaseString]])
[fm removeFileAtPath:[path
stringByAppendingPathComponent:file] handler:nil];
}
@@ -286,10 +288,18 @@
if (success)
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/touch"
arguments:[NSArray arrayWithObjects:@"-fm", path, nil]];
+
+ if (saveOperation == NSSaveAsOperation)
+ [self setFileURL:absoluteURL];
}
[fm removeFileAtPath:tmpDir handler:nil];
}
+
+ } else {
+
+ success = [super saveToURL:absoluteURL ofType:typeName
forSaveOperation:saveOperation error:outError];
+
}
if (saveOperation == NSSaveOperation || saveOperation ==
NSSaveAsOperation) {
@@ -304,6 +314,8 @@
isSaving = NO;
}
+ exportUsingPanel = NO;
+
return success;
}
@@ -355,6 +367,10 @@
else if (outError != NULL)
*outError = [NSError errorWithDomain:SKDocumentErrorDomain code:1
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable
to write notes as text", @"Error description"), NSLocalizedDescriptionKey,
nil]];
}
+
+ if (didWrite == NO && outError != NULL && *outError == nil)
+ *outError = [NSError errorWithDomain:SKDocumentErrorDomain code:0
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable
to write file", @"Error description"), NSLocalizedDescriptionKey, nil]];
+
return didWrite;
}
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: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit