Revision: 27228
          http://sourceforge.net/p/bibdesk/svn/27228
Author:   hofman
Date:     2022-01-16 17:25:35 +0000 (Sun, 16 Jan 2022)
Log Message:
-----------
Use common script command class for auto file and download commands and make 
them object-first with the receiver always a publication

Modified Paths:
--------------
    trunk/bibdesk/BibItem+Scripting.h
    trunk/bibdesk/BibItem+Scripting.m
    trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
    trunk/bibdesk/Scripting/BibDesk.sdef

Added Paths:
-----------
    trunk/bibdesk/BDSKPublicationCommand.h
    trunk/bibdesk/BDSKPublicationCommand.m

Removed Paths:
-------------
    trunk/bibdesk/BDSKAutoFileCommand.h
    trunk/bibdesk/BDSKAutoFileCommand.m
    trunk/bibdesk/BDSKDownloadCommand.h
    trunk/bibdesk/BDSKDownloadCommand.m

Deleted: trunk/bibdesk/BDSKAutoFileCommand.h
===================================================================
--- trunk/bibdesk/BDSKAutoFileCommand.h 2022-01-16 17:19:34 UTC (rev 27227)
+++ trunk/bibdesk/BDSKAutoFileCommand.h 2022-01-16 17:25:35 UTC (rev 27228)
@@ -1,46 +0,0 @@
-//
-//  BDSKAutoFileCommand.h
-//  Bibdesk
-//
-//  Created by Christiaan Hofman on 7/3/07.
-/*
- This software is Copyright (c) 2007-2022
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in
-    the documentation and/or other materials provided with the
-    distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
-    contributors may be used to endorse or promote products derived
-    from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-
-@interface BDSKPublicationCommand : NSScriptCommand {
-    NSScriptObjectSpecifier *keySpecifier;
-}
-@property (nonatomic, readonly) NSScriptObjectSpecifier *keySpecifier;
-@end

Deleted: trunk/bibdesk/BDSKAutoFileCommand.m
===================================================================
--- trunk/bibdesk/BDSKAutoFileCommand.m 2022-01-16 17:19:34 UTC (rev 27227)
+++ trunk/bibdesk/BDSKAutoFileCommand.m 2022-01-16 17:25:35 UTC (rev 27228)
@@ -1,73 +0,0 @@
-//
-//  BDSKPublicationCommand.m
-//  Bibdesk
-//
-//  Created by Christiaan Hofman on 7/3/07.
-/*
- This software is Copyright (c) 2007-2022
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in
-    the documentation and/or other materials provided with the
-    distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
-    contributors may be used to endorse or promote products derived
-    from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "BDSKPublicationCommand.h"
-
-
-@implementation BDSKPublicationCommand
-
-@synthesize keySpecifier;
-
-- (void)dealloc {
-    BDSKDESTROY(keySpecifier);
-    [super dealloc];
-}
-
-- (void)setReceiversSpecifier:(NSScriptObjectSpecifier *)receiversSpecifier {
-    if ([[receiversSpecifier key] isEqualToString:@""]) {
-        // this is an 'item i of linked files' specifier
-        // -indicesOfObjectsByEvaluatingWithContainer:count: does not work here
-        // transform to an index specifier for the element
-        if ([receiversSpecifier isKindOfClass:[NSIndexSpecifier class]] &&
-            [[receiversSpecifier containerSpecifier] 
isKindOfClass:[NSPropertySpecifier class]]) {
-            NSPropertySpecifier *spec = (NSPropertySpecifier 
*)[receiversSpecifier containerSpecifier];
-            receiversSpecifier = [[[NSIndexSpecifier alloc] 
initWithContainerClassDescription:[spec containerClassDescription] 
containerSpecifier:[spec containerSpecifier] key:[spec key] 
index:[(NSIndexSpecifier *)receiversSpecifier index]] autorelease];
-        } else {
-            [self setScriptErrorNumber:NSArgumentsWrongScriptError];
-            [self setScriptErrorString:@"Do not understand receiver 
specifier."];
-        }
-    }
-    if ([[[receiversSpecifier keyClassDescription] className] 
isEqualToString:@"publication"]) {
-        [super setReceiversSpecifier:receiversSpecifier];
-    } else {
-        [super setReceiversSpecifier:[receiversSpecifier containerSpecifier]];
-        keySpecifier = [receiversSpecifier retain];
-    }
-}
-
-@end

Deleted: trunk/bibdesk/BDSKDownloadCommand.h
===================================================================
--- trunk/bibdesk/BDSKDownloadCommand.h 2022-01-16 17:19:34 UTC (rev 27227)
+++ trunk/bibdesk/BDSKDownloadCommand.h 2022-01-16 17:25:35 UTC (rev 27228)
@@ -1,45 +0,0 @@
-//
-//  BDSKDownloadCommand.h
-//  BibDesk
-//
-//  Created by Christiaan Hofman on 03/07/2019.
-/*
- This software is Copyright (c) 2019-2022
- Christiaan Hofman. All rights reserved.
- 
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- 
- - Neither the name of Christiaan Hofman nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-@interface BDSKDownloadCommand : NSScriptCommand {
-    NSScriptObjectSpecifier *keySpecifier;
-}
-@property (nonatomic, readonly) NSScriptObjectSpecifier *keySpecifier;
-@end

Deleted: trunk/bibdesk/BDSKDownloadCommand.m
===================================================================
--- trunk/bibdesk/BDSKDownloadCommand.m 2022-01-16 17:19:34 UTC (rev 27227)
+++ trunk/bibdesk/BDSKDownloadCommand.m 2022-01-16 17:25:35 UTC (rev 27228)
@@ -1,188 +0,0 @@
-//
-//  BDSKDownloadCommand.m
-//  BibDesk
-//
-//  Created by Christiaan Hofman on 03/07/2019.
-/*
- This software is Copyright (c) 2019-2022
- Christiaan Hofman. All rights reserved.
- 
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- 
- - Neither the name of Christiaan Hofman nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "BDSKDownloadCommand.h"
-#import "BDSKStringConstants.h"
-#import "BibItem.h"
-#import "BibDocument.h"
-#import "BDSKLinkedFile.h"
-#import "BDSKOwnerProtocol.h"
-#import "BDSKTypeManager.h"
-
-@implementation BDSKDownloadCommand
-
-@synthesize keySpecifier;
-
-- (void)dealloc {
-    BDSKDESTROY(keySpecifier);
-    [super dealloc];
-}
-
-- (void)setReceiversSpecifier:(NSScriptObjectSpecifier *)receiversSpecifier {
-    if ([[receiversSpecifier key] isEqualToString:@""]) {
-        // this is an 'item i of linked files' specifier
-        // -indicesOfObjectsByEvaluatingWithContainer:count: does not work here
-        // transform to an index specifier for the element
-        if ([receiversSpecifier isKindOfClass:[NSIndexSpecifier class]] &&
-            [[receiversSpecifier containerSpecifier] 
isKindOfClass:[NSPropertySpecifier class]]) {
-            NSPropertySpecifier *spec = (NSPropertySpecifier 
*)[receiversSpecifier containerSpecifier];
-            receiversSpecifier = [[[NSIndexSpecifier alloc] 
initWithContainerClassDescription:[spec containerClassDescription] 
containerSpecifier:[spec containerSpecifier] key:[spec key] 
index:[(NSIndexSpecifier *)receiversSpecifier index]] autorelease];
-        } else {
-            [self setScriptErrorNumber:NSArgumentsWrongScriptError];
-            [self setScriptErrorString:@"Do not understand receiver 
specifier."];
-        }
-    }
-    if ([[[receiversSpecifier keyClassDescription] className] 
isEqualToString:@"publication"]) {
-        [super setReceiversSpecifier:receiversSpecifier];
-    } else {
-        [super setReceiversSpecifier:[receiversSpecifier containerSpecifier]];
-        keySpecifier = [receiversSpecifier retain];
-    }
-}
-
-- (id)performDefaultImplementation {
-    NSScriptObjectSpecifier *keySpec = [self keySpecifier];
-    NSString *keyClass = [[keySpec keyClassDescription] className];
-    NSDictionary *params = [self evaluatedArguments];
-    BOOL replace = [[params objectForKey:@"replace"] boolValue];
-    BibItem *pub = [self evaluatedReceivers];
-    NSString *field = nil;
-    NSInteger start = 0, end = 0;
-    NSMutableIndexSet *indexes = nil;
-    NSArray *linkedURLs = nil;
-    
-    if (pub == nil) {
-        [self setScriptErrorNumber:NSRequiredArgumentsMissingScriptError];
-        [self setScriptErrorString:@"Could not find a publication for which to 
download."];
-        return nil;
-    }
-    if ([pub isKindOfClass:[BibItem class]] == NO) {
-        [self setScriptErrorNumber:NSArgumentsWrongScriptError];
-        [self setScriptErrorString:@"Receiver is not a publication."];
-        return nil;
-    }
-    
-    if (keySpec == nil) {
-        if ([[NSUserDefaults standardUserDefaults] 
boolForKey:BDSKUseLocalUrlAndUrlKey])
-            field = BDSKUrlString;
-        else
-            field = BDSKRemoteURLString;
-    } else if ([keyClass isEqualToString:@"field"]) {
-        field = [[(NSNameSpecifier *)keySpec name] fieldName];
-        if ([field isRemoteURLField] == NO) {
-            [self setScriptErrorNumber:NSArgumentsWrongScriptError];
-            [self setScriptErrorString:@"Field must be a remote URL field."];
-            return nil;
-        }
-    } else if ([keyClass isEqualToString:@"linked URL"]) {
-        field = BDSKRemoteURLString;
-        // NSPropertySpecifier, NSIndexSpecifier, NSRangeSpecifier, 
NSMiddleSpecifier, NSWhoseSpecifier
-        NSInteger i, count = -2;
-        NSInteger *indices = [keySpec 
indicesOfObjectsByEvaluatingWithContainer:pub count:&count];
-        if (count < -1) {
-            [self setScriptErrorNumber:NSArgumentsWrongScriptError];
-            [self setScriptErrorString:@"Do not understand linked URL 
specifier."];
-            return nil;
-        }
-        if (count == 0) {
-            return nil;
-        } else if (count == -1) {
-            start = 0;
-            end = -1;
-        } else {
-            end = start = indices[0];
-            for (i = 1; i < count; i++) {
-                if (indices[i] = end + 1) {
-                    end++;
-                } else {
-                    // not a single range, use an index set, start/end only 
holds the first range
-                    if (indexes == nil)
-                        indexes = [NSMutableIndexSet 
indexSetWithIndexesInRange:NSMakeRange(start, end + 1 - start)];
-                    [indexes addIndex:indices[i]];
-                }
-            }
-        }
-    } else {
-        [self setScriptErrorNumber:NSArgumentsWrongScriptError];
-        [self setScriptErrorString:@"Receiver should be a publication, field, 
or linked URL(s)."];
-        [self setScriptErrorOffendingObjectDescriptor:[keySpec descriptor]];
-        return nil;
-    }
-    
-    BibDocument *doc = (BibDocument *)[pub owner];
-
-    if ([doc isDocument] == NO) {
-        [self setScriptErrorNumber:NSReceiversCantHandleCommandScriptError];
-        [self setScriptErrorString:@"Cannot download for external items."];
-        return nil;
-    }
-    
-    if ([field isEqualToString:BDSKRemoteURLString]) {
-        linkedURLs = [pub remoteURLs];
-        NSInteger count = [linkedURLs count];
-        if (count == 0)
-            return nil;
-        if (start < 0)
-            start += count;
-        if (end < 0)
-            end += count;
-        if (start < 0 || end < 0 || start >= count || end >= count || end < 
start || (NSInteger)[indexes lastIndex] >= count) {
-            [self setScriptErrorNumber:NSArgumentsWrongScriptError];
-            [self setScriptErrorString:@"Invalid linked URL index."];
-            return nil;
-        }
-        if (indexes)
-            linkedURLs = [linkedURLs objectsAtIndexes:indexes];
-        else if (start > 0 || end < count - 1)
-            linkedURLs = [linkedURLs subarrayWithRange:NSMakeRange(start, end 
+ 1 - start)];
-        for (BDSKLinkedFile *linkedURL in linkedURLs) {
-            [pub downloadLinkedFile:linkedURL replace:replace];
-        }
-    } else {
-        if ([pub remoteURLForField:field] == nil) {
-            [self setScriptErrorNumber:NSArgumentsWrongScriptError];
-            [self setScriptErrorString:@"Invalid remote URL field."];
-            return nil;
-        }
-        [pub downloadURLForField:field];
-    }
-    
-    return nil;
-}
-
-@end

Copied: trunk/bibdesk/BDSKPublicationCommand.h (from rev 27227, 
trunk/bibdesk/BDSKAutoFileCommand.h)
===================================================================
--- trunk/bibdesk/BDSKPublicationCommand.h                              (rev 0)
+++ trunk/bibdesk/BDSKPublicationCommand.h      2022-01-16 17:25:35 UTC (rev 
27228)
@@ -0,0 +1,46 @@
+//
+//  BDSKAutoFileCommand.h
+//  Bibdesk
+//
+//  Created by Christiaan Hofman on 7/3/07.
+/*
+ This software is Copyright (c) 2007-2022
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface BDSKPublicationCommand : NSScriptCommand {
+    NSScriptObjectSpecifier *keySpecifier;
+}
+@property (nonatomic, readonly) NSScriptObjectSpecifier *keySpecifier;
+@end

Copied: trunk/bibdesk/BDSKPublicationCommand.m (from rev 27227, 
trunk/bibdesk/BDSKAutoFileCommand.m)
===================================================================
--- trunk/bibdesk/BDSKPublicationCommand.m                              (rev 0)
+++ trunk/bibdesk/BDSKPublicationCommand.m      2022-01-16 17:25:35 UTC (rev 
27228)
@@ -0,0 +1,73 @@
+//
+//  BDSKPublicationCommand.m
+//  Bibdesk
+//
+//  Created by Christiaan Hofman on 7/3/07.
+/*
+ This software is Copyright (c) 2007-2022
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "BDSKPublicationCommand.h"
+
+
+@implementation BDSKPublicationCommand
+
+@synthesize keySpecifier;
+
+- (void)dealloc {
+    BDSKDESTROY(keySpecifier);
+    [super dealloc];
+}
+
+- (void)setReceiversSpecifier:(NSScriptObjectSpecifier *)receiversSpecifier {
+    if ([[receiversSpecifier key] isEqualToString:@""]) {
+        // this is an 'item i of linked files' specifier
+        // -indicesOfObjectsByEvaluatingWithContainer:count: does not work here
+        // transform to an index specifier for the element
+        if ([receiversSpecifier isKindOfClass:[NSIndexSpecifier class]] &&
+            [[receiversSpecifier containerSpecifier] 
isKindOfClass:[NSPropertySpecifier class]]) {
+            NSPropertySpecifier *spec = (NSPropertySpecifier 
*)[receiversSpecifier containerSpecifier];
+            receiversSpecifier = [[[NSIndexSpecifier alloc] 
initWithContainerClassDescription:[spec containerClassDescription] 
containerSpecifier:[spec containerSpecifier] key:[spec key] 
index:[(NSIndexSpecifier *)receiversSpecifier index]] autorelease];
+        } else {
+            [self setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [self setScriptErrorString:@"Do not understand receiver 
specifier."];
+        }
+    }
+    if ([[[receiversSpecifier keyClassDescription] className] 
isEqualToString:@"publication"]) {
+        [super setReceiversSpecifier:receiversSpecifier];
+    } else {
+        [super setReceiversSpecifier:[receiversSpecifier containerSpecifier]];
+        keySpecifier = [receiversSpecifier retain];
+    }
+}
+
+@end

Modified: trunk/bibdesk/BibItem+Scripting.h
===================================================================
--- trunk/bibdesk/BibItem+Scripting.h   2022-01-16 17:19:34 UTC (rev 27227)
+++ trunk/bibdesk/BibItem+Scripting.h   2022-01-16 17:25:35 UTC (rev 27228)
@@ -100,6 +100,8 @@
 @property (nonatomic, retain) BibItem *scriptingCrossrefParent;
 
 - (void)handleShowScriptCommand:(NSScriptCommand *)command;
+- (id)handleAutoFileScriptCommand:(NSScriptCommand *)command;
+- (id)handleDownloadScriptCommand:(NSScriptCommand *)command;
 
 @end
 

Modified: trunk/bibdesk/BibItem+Scripting.m
===================================================================
--- trunk/bibdesk/BibItem+Scripting.m   2022-01-16 17:19:34 UTC (rev 27227)
+++ trunk/bibdesk/BibItem+Scripting.m   2022-01-16 17:25:35 UTC (rev 27228)
@@ -49,6 +49,8 @@
 #import "NSError_BDSKExtensions.h"
 #import "BibDocument_Actions.h"
 #import "BDSKFiler.h"
+#import "BDSKTypeManager.h"
+#import "BDSKPublicationCommand.h"
 
 /* ssp
 A Category on BibItem with a few additional methods to enable and enhance its 
scriptability beyond what comes for free with key value coding.
@@ -562,6 +564,268 @@
     [doc editPub:self];
 }
 
+- (id)handleAutoFileScriptCommand:(NSScriptCommand *)command {
+    NSScriptObjectSpecifier *keySpec = [(BDSKPublicationCommand *)command 
keySpecifier];
+    NSString *keyClass = [[keySpec keyClassDescription] className];
+    NSDictionary *params = [command evaluatedArguments];
+    NSNumber *indexNumber = [params objectForKey:@"index"];
+    NSString *location = [params objectForKey:@"to"];
+    NSString *field = [params objectForKey:@"for"];
+    NSNumber *checkNumber = [params objectForKey:@"check"];
+    BOOL check = checkNumber ? [checkNumber boolValue] : YES;
+    BibDocument *doc = (BibDocument *)[self owner];
+    NSInteger start = 0, end = 0;
+    NSMutableIndexSet *indexes = nil;
+    NSArray *files = nil;
+    NSArray *linkedfiles = nil;
+    
+    if ([doc isDocument] == NO) {
+        [command setScriptErrorNumber:NSReceiversCantHandleCommandScriptError];
+        [command setScriptErrorString:@"Cannot auto file for external items."];
+        return nil;
+    }
+    
+    if (field && [field isKindOfClass:[NSString class]] == NO)  {
+        [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+        return nil;
+    }
+    if (indexNumber && [indexNumber isKindOfClass:[NSNumber class]] == NO)  {
+        [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+        return nil;
+    }
+    
+    if (keySpec == nil) {
+        if (indexNumber) {
+            if (field && [field isEqualToString:BDSKLocalFileString] == NO) {
+                [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+                [command setScriptErrorString:@"Cannot pass both an index and 
a field."];
+                return nil;
+            }
+            field = BDSKLocalFileString;
+            start = [indexNumber integerValue];
+            end = start > 0 ? --start : start;
+        } else if ([field isEqualToString:BDSKLocalFileString] || (field == 
nil && [[NSUserDefaults standardUserDefaults] 
boolForKey:BDSKUseLocalUrlAndUrlKey] == NO)) {
+            field = BDSKLocalFileString;
+            start = 0;
+            end = location ? 0 : -1;
+        } else {
+            field = [field fieldName] ?: BDSKLocalUrlString;
+        }
+    } else if ([keyClass isEqualToString:@"field"]) {
+        if (field) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"Cannot pass both a field and a 
field name."];
+            return nil;
+        }
+        if (indexNumber) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"Cannot pass both a field and an 
index."];
+            return nil;
+        }
+        if ([keySpec isKindOfClass:[NSNameSpecifier class]] == NO) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"Invalid field specifier."];
+            return nil;
+        }
+        field = [[(NSNameSpecifier *)keySpec name] fieldName];
+    } else if ([keyClass isEqualToString:@"linked file"]) {
+        if (field) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"Cannot pass both a linked file and 
a field name."];
+            return nil;
+        }
+        if (indexNumber) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"Cannot pass both a linked file and 
an index."];
+            return nil;
+        }
+        field = BDSKLocalFileString;
+        // NSPropertySpecifier, NSIndexSpecifier, NSRangeSpecifier, 
NSMiddleSpecifier, NSWhoseSpecifier
+        NSInteger i, count = -2;
+        NSInteger *indices = [keySpec 
indicesOfObjectsByEvaluatingWithContainer:self count:&count];
+        if (count < -1) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"Do not understand linked file 
specifier."];
+            return nil;
+        }
+        if (count == 0) {
+            return nil;
+        } else if (count == -1) {
+            start = 0;
+            end = -1;
+        } else {
+            end = start = indices[0];
+            for (i = 1; i < count; i++) {
+                if (indices[i] = end + 1) {
+                    end++;
+                } else {
+                    // not a single range, use an index set, start/end only 
holds the first range
+                    if (indexes == nil)
+                        indexes = [NSMutableIndexSet 
indexSetWithIndexesInRange:NSMakeRange(start, end + 1 - start)];
+                    [indexes addIndex:indices[i]];
+                }
+            }
+        }
+    } else {
+        [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+        [command setScriptErrorString:@"Receiver should be a publication, 
field, or linked file(s)."];
+        [command setScriptErrorOffendingObjectDescriptor:[keySpec descriptor]];
+        return nil;
+    }
+    
+    if ([field isEqualToString:BDSKLocalFileString]) {
+        linkedfiles = [self localFiles];
+        NSInteger count = [linkedfiles count];
+        if (count == 0)
+            return nil;
+        if (start < 0)
+            start += count;
+        if (end < 0)
+            end += count;
+        if (start < 0 || end < 0 || start >= count || end >= count || end < 
start || (NSInteger)[indexes lastIndex] >= count) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"Invalid linked file index."];
+            return nil;
+        }
+        if (location && (end > start || [indexes count] > 0)) {
+            [command 
setScriptErrorNumber:NSReceiversCantHandleCommandScriptError];
+            [command setScriptErrorString:@"Only a single linked file can be 
moved to a given location."];
+            return nil;
+        }
+        if (indexes)
+            linkedfiles = [linkedfiles objectsAtIndexes:indexes];
+        else if (start > 0 || end < count - 1)
+            linkedfiles = [linkedfiles subarrayWithRange:NSMakeRange(start, 
end + 1 - start)];
+    }
+    
+    if (location) {
+        if ([location isKindOfClass:[NSString class]] == NO && [location 
isKindOfClass:[NSURL class]] == NO) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"The 'to' argument should be a path 
or a file."];
+            return nil;
+        }
+        if ([location isKindOfClass:[NSURL class]])
+            location = [(NSURL *)location path];
+        else if ([location hasPrefix:@"file://"])
+            location = [[NSURL URLWithString:location] path];
+        else if ([location hasPrefix:@"~"])
+            location = [location stringByExpandingTildeInPath];
+        else if ([location isAbsolutePath] == NO) // or should we use the 
papers folder?
+            location = [[([doc basePath] ?: NSHomeDirectory()) 
stringByAppendingPathComponent:location] stringByStandardizingPath];
+        NSArray *paperInfos = [NSArray arrayWithObject:[NSDictionary 
dictionaryWithObjectsAndKeys:self, BDSKFilerPublicationKey, location, 
BDSKFilerNewPathKey, [linkedfiles firstObject], BDSKFilerFileKey, nil]];
+        [[BDSKFiler sharedFiler] movePapers:paperInfos forField:field 
fromDocument:doc options:BDSKAutoFileOptionInitial 
actionName:NSLocalizedString(@"AppleScript",@"Undo action name for 
AppleScript")];
+        if (linkedfiles)
+            return [linkedfiles valueForKey:@"URL"];
+        else
+            return [self localFileURLForField:field];
+    } else if (linkedfiles) {
+        [[BDSKFiler sharedFiler] autoFileLinkedFiles:linkedfiles 
fromDocument:doc check:check actionName:NSLocalizedString(@"AppleScript",@"Undo 
action name for AppleScript")];
+        return [linkedfiles valueForKey:@"URL"];
+    } else {
+        [[BDSKFiler sharedFiler] autoFileItems:[NSArray arrayWithObjects:self, 
nil] forField:field fromDocument:doc check:check 
actionName:NSLocalizedString(@"AppleScript",@"Undo action name for 
AppleScript")];
+        return [self localFileURLForField:field];
+    }
+    
+    return nil;
+}
+
+- (id)handleDownloadScriptCommand:(NSScriptCommand *)command {
+    NSScriptObjectSpecifier *keySpec = [(BDSKPublicationCommand *)command 
keySpecifier];
+    NSString *keyClass = [[keySpec keyClassDescription] className];
+    NSDictionary *params = [command evaluatedArguments];
+    BOOL replace = [[params objectForKey:@"replace"] boolValue];
+    BibDocument *doc = (BibDocument *)[self owner];
+    NSString *field = nil;
+    NSInteger start = 0, end = 0;
+    NSMutableIndexSet *indexes = nil;
+    NSArray *linkedURLs = nil;
+    
+    if ([doc isDocument] == NO) {
+        [command setScriptErrorNumber:NSReceiversCantHandleCommandScriptError];
+        [command setScriptErrorString:@"Cannot download for external items."];
+        return nil;
+    }
+    
+    if (keySpec == nil) {
+        if ([[NSUserDefaults standardUserDefaults] 
boolForKey:BDSKUseLocalUrlAndUrlKey])
+            field = BDSKUrlString;
+        else
+            field = BDSKRemoteURLString;
+    } else if ([keyClass isEqualToString:@"field"]) {
+        field = [[(NSNameSpecifier *)keySpec name] fieldName];
+        if ([field isRemoteURLField] == NO) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"Field must be a remote URL 
field."];
+            return nil;
+        }
+    } else if ([keyClass isEqualToString:@"linked URL"]) {
+        field = BDSKRemoteURLString;
+        // NSPropertySpecifier, NSIndexSpecifier, NSRangeSpecifier, 
NSMiddleSpecifier, NSWhoseSpecifier
+        NSInteger i, count = -2;
+        NSInteger *indices = [keySpec 
indicesOfObjectsByEvaluatingWithContainer:self count:&count];
+        if (count < -1) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"Do not understand linked URL 
specifier."];
+            return nil;
+        }
+        if (count == 0) {
+            return nil;
+        } else if (count == -1) {
+            start = 0;
+            end = -1;
+        } else {
+            end = start = indices[0];
+            for (i = 1; i < count; i++) {
+                if (indices[i] = end + 1) {
+                    end++;
+                } else {
+                    // not a single range, use an index set, start/end only 
holds the first range
+                    if (indexes == nil)
+                        indexes = [NSMutableIndexSet 
indexSetWithIndexesInRange:NSMakeRange(start, end + 1 - start)];
+                    [indexes addIndex:indices[i]];
+                }
+            }
+        }
+    } else {
+        [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+        [command setScriptErrorString:@"Receiver should be a publication, 
field, or linked URL(s)."];
+        [command setScriptErrorOffendingObjectDescriptor:[keySpec descriptor]];
+        return nil;
+    }
+    
+    if ([field isEqualToString:BDSKRemoteURLString]) {
+        linkedURLs = [self remoteURLs];
+        NSInteger count = [linkedURLs count];
+        if (count == 0)
+            return nil;
+        if (start < 0)
+            start += count;
+        if (end < 0)
+            end += count;
+        if (start < 0 || end < 0 || start >= count || end >= count || end < 
start || (NSInteger)[indexes lastIndex] >= count) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"Invalid linked URL index."];
+            return nil;
+        }
+        if (indexes)
+            linkedURLs = [linkedURLs objectsAtIndexes:indexes];
+        else if (start > 0 || end < count - 1)
+            linkedURLs = [linkedURLs subarrayWithRange:NSMakeRange(start, end 
+ 1 - start)];
+        for (BDSKLinkedFile *linkedURL in linkedURLs) {
+            [self downloadLinkedFile:linkedURL replace:replace];
+        }
+    } else {
+        if ([self remoteURLForField:field] == nil) {
+            [command setScriptErrorNumber:NSArgumentsWrongScriptError];
+            [command setScriptErrorString:@"Invalid remote URL field."];
+            return nil;
+        }
+        [self downloadURLForField:field];
+    }
+    
+    return nil;
+}
+
 /*
  ssp: 2004-07-10
  Return attribute keys corresponding to the fields present in the current 
BibItem

Modified: trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
===================================================================
--- trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2022-01-16 17:19:34 UTC 
(rev 27227)
+++ trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2022-01-16 17:25:35 UTC 
(rev 27228)
@@ -71,6 +71,8 @@
                CD6295361140DE16002E4751 /* BDSKIACRParser.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CD6295351140DE16002E4751 /* BDSKIACRParser.m */; 
};
                CD6295381140DE1C002E4751 /* BDSKSpringerParser.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CD6295371140DE1C002E4751 /* 
BDSKSpringerParser.m */; };
                CD86BA3A1141C023005EEFDA /* BDSKBibTeXWebParser.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CD86BA391141C023005EEFDA /* 
BDSKBibTeXWebParser.m */; };
+               CE01CBCB27948B6F0074FCBE /* BDSKPublicationCommand.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = CE01CBB527948B6F0074FCBE /* 
BDSKPublicationCommand.m */; };
+               CE01CBCD27948BF20074FCBE /* BDSKPublicationCommand.h in Headers 
*/ = {isa = PBXBuildFile; fileRef = CE01CBCC27948BF20074FCBE /* 
BDSKPublicationCommand.h */; };
                CE023F5D0CC50F87003F52E5 /* Add_Small.tiff in Resources */ = 
{isa = PBXBuildFile; fileRef = CE023F5C0CC50F86003F52E5 /* Add_Small.tiff */; };
                CE038E6A0F5F00E8001808EA /* Bookmark.tiff in Resources */ = 
{isa = PBXBuildFile; fileRef = CE038E690F5F00E8001808EA /* Bookmark.tiff */; };
                CE0391910F612ED5001808EA /* SharingPreferences.tiff in 
Resources */ = {isa = PBXBuildFile; fileRef = CE0391900F612ED5001808EA /* 
SharingPreferences.tiff */; };
@@ -142,7 +144,6 @@
                CE2A09BA2245997A00A8F31C /* BDSKArxivParser.h in Headers */ = 
{isa = PBXBuildFile; fileRef = CE071ECE0F213EB300244F5C /* BDSKArxivParser.h 
*/; };
                CE2A09BB2245997A00A8F31C /* BDSKAsynchronousDOServer.h in 
Headers */ = {isa = PBXBuildFile; fileRef = F946DCE609FDC4B600D471DF /* 
BDSKAsynchronousDOServer.h */; };
                CE2A09BC2245997A00A8F31C /* BDSKAsynchronousWebParser.h in 
Headers */ = {isa = PBXBuildFile; fileRef = CE77963E20372B90009C6A52 /* 
BDSKAsynchronousWebParser.h */; };
-               CE2A09BD2245997A00A8F31C /* BDSKAutoFileCommand.h in Headers */ 
= {isa = PBXBuildFile; fileRef = CEDD189821696373000E28D7 /* 
BDSKAutoFileCommand.h */; };
                CE2A09BF2245997A00A8F31C /* BDSKBibDeskProtocol.h in Headers */ 
= {isa = PBXBuildFile; fileRef = 6CD26A210F928EEE0089FDFD /* 
BDSKBibDeskProtocol.h */; };
                CE2A09C02245997A00A8F31C /* BDSKBibTeXParser.h in Headers */ = 
{isa = PBXBuildFile; fileRef = F9022C950758038000C3F701 /* BDSKBibTeXParser.h 
*/; };
                CE2A09C12245997A00A8F31C /* BDSKBibTeXWebParser.h in Headers */ 
= {isa = PBXBuildFile; fileRef = CD86BA2C1141C018005EEFDA /* 
BDSKBibTeXWebParser.h */; };
@@ -477,8 +478,6 @@
                CE44BBCE26371AFB008C7833 /* BDSKWebGroupView.xib in Resources 
*/ = {isa = PBXBuildFile; fileRef = CE44BBCD26371AFB008C7833 /* 
BDSKWebGroupView.xib */; };
                CE44BBD926371DCF008C7833 /* BDSKCustomCiteDrawer.xib in 
Resources */ = {isa = PBXBuildFile; fileRef = CE44BBD826371DCF008C7833 /* 
BDSKCustomCiteDrawer.xib */; };
                CE4A0E141115ABEF000A95C5 /* BDSKServiceProvider.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CE4A0E121115ABEF000A95C5 /* 
BDSKServiceProvider.m */; };
-               CE51616C22CD4E7D00832F3E /* BDSKDownloadCommand.h in Headers */ 
= {isa = PBXBuildFile; fileRef = CE51616A22CD4E7D00832F3E /* 
BDSKDownloadCommand.h */; };
-               CE51616D22CD4E7D00832F3E /* BDSKDownloadCommand.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CE51616B22CD4E7D00832F3E /* 
BDSKDownloadCommand.m */; };
                CE51922109E5755600E97C3A /* BDSKFindFieldEditor.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CE51921F09E5755600E97C3A /* 
BDSKFindFieldEditor.m */; };
                CE522F761D5CA7FE00348D7D /* BDSKDOIParser.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CE522F741D5CA7FE00348D7D /* BDSKDOIParser.m */; 
};
                CE5417CA22D4DA7700867189 /* BDSKAuthenticationHandler.h in 
Headers */ = {isa = PBXBuildFile; fileRef = CE5417C822D4DA7700867189 /* 
BDSKAuthenticationHandler.h */; };
@@ -722,7 +721,6 @@
                CEDBDE4C0F4C863500190AF5 /* BDSKPreferenceRecord.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = CEDBDE4A0F4C863500190AF5 /* 
BDSKPreferenceRecord.m */; };
                CEDBE05A0F4CDAD900190AF5 /* NSView_BDSKExtensions.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = CEDBE0580F4CDAD900190AF5 /* 
NSView_BDSKExtensions.m */; };
                CEDBE0900F4CE06600190AF5 /* ScriptMenu.tiff in Resources */ = 
{isa = PBXBuildFile; fileRef = CEDBE08F0F4CE06600190AF5 /* ScriptMenu.tiff */; 
};
-               CEDD189921696373000E28D7 /* BDSKAutoFileCommand.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CEDD188B21696373000E28D7 /* 
BDSKAutoFileCommand.m */; };
                CEDED0952032450B003FA44D /* BDSKIUCrParser.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CEDED0932032450B003FA44D /* BDSKIUCrParser.m */; 
};
                CEE09F1C216147E1009CE63D /* BDSKFieldInfo.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CEE09F1A216147E1009CE63D /* BDSKFieldInfo.m */; 
};
                CEE22B210BFB7DA8002B746B /* RelNotes.rtf in Resources */ = {isa 
= PBXBuildFile; fileRef = F994B8F607F5F65F00751DA1 /* RelNotes.rtf */; };
@@ -1305,6 +1303,8 @@
                CD6295371140DE1C002E4751 /* BDSKSpringerParser.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKSpringerParser.m; sourceTree = "<group>"; };
                CD86BA2C1141C018005EEFDA /* BDSKBibTeXWebParser.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKBibTeXWebParser.h; sourceTree = "<group>"; };
                CD86BA391141C023005EEFDA /* BDSKBibTeXWebParser.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKBibTeXWebParser.m; sourceTree = "<group>"; };
+               CE01CBB527948B6F0074FCBE /* BDSKPublicationCommand.m */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; 
path = BDSKPublicationCommand.m; sourceTree = "<group>"; };
+               CE01CBCC27948BF20074FCBE /* BDSKPublicationCommand.h */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path 
= BDSKPublicationCommand.h; sourceTree = "<group>"; };
                CE023F5C0CC50F86003F52E5 /* Add_Small.tiff */ = {isa = 
PBXFileReference; lastKnownFileType = image.tiff; path = Add_Small.tiff; 
sourceTree = "<group>"; };
                CE038E690F5F00E8001808EA /* Bookmark.tiff */ = {isa = 
PBXFileReference; lastKnownFileType = image.tiff; path = Bookmark.tiff; 
sourceTree = "<group>"; };
                CE0391900F612ED5001808EA /* SharingPreferences.tiff */ = {isa = 
PBXFileReference; lastKnownFileType = image.tiff; path = 
SharingPreferences.tiff; sourceTree = "<group>"; };
@@ -1497,8 +1497,6 @@
                CE4A0E121115ABEF000A95C5 /* BDSKServiceProvider.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKServiceProvider.m; sourceTree = "<group>"; };
                CE5019F5263C1D0600879496 /* fr */ = {isa = PBXFileReference; 
fileEncoding = 10; lastKnownFileType = text.plist.strings; name = fr; path = 
fr.lproj/BDSKFindPanel.strings; sourceTree = "<group>"; };
                CE5019F6263C1D0900879496 /* de */ = {isa = PBXFileReference; 
fileEncoding = 10; lastKnownFileType = text.plist.strings; name = de; path = 
de.lproj/BDSKFindPanel.strings; sourceTree = "<group>"; };
-               CE51616A22CD4E7D00832F3E /* BDSKDownloadCommand.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; path = 
BDSKDownloadCommand.h; sourceTree = "<group>"; };
-               CE51616B22CD4E7D00832F3E /* BDSKDownloadCommand.m */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = 
BDSKDownloadCommand.m; sourceTree = "<group>"; };
                CE51921E09E5755600E97C3A /* BDSKFindFieldEditor.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKFindFieldEditor.h; sourceTree = "<group>"; };
                CE51921F09E5755600E97C3A /* BDSKFindFieldEditor.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKFindFieldEditor.m; sourceTree = "<group>"; };
                CE522F731D5CA7FD00348D7D /* BDSKDOIParser.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKDOIParser.h; sourceTree = "<group>"; };
@@ -1912,8 +1910,6 @@
                CEDBE0570F4CDAD900190AF5 /* NSView_BDSKExtensions.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
NSView_BDSKExtensions.h; sourceTree = "<group>"; };
                CEDBE0580F4CDAD900190AF5 /* NSView_BDSKExtensions.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= NSView_BDSKExtensions.m; sourceTree = "<group>"; };
                CEDBE08F0F4CE06600190AF5 /* ScriptMenu.tiff */ = {isa = 
PBXFileReference; lastKnownFileType = image.tiff; path = ScriptMenu.tiff; 
sourceTree = "<group>"; };
-               CEDD188B21696373000E28D7 /* BDSKAutoFileCommand.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKAutoFileCommand.m; sourceTree = "<group>"; };
-               CEDD189821696373000E28D7 /* BDSKAutoFileCommand.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKAutoFileCommand.h; sourceTree = "<group>"; };
                CEDED0922032450B003FA44D /* BDSKIUCrParser.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BDSKIUCrParser.h; 
sourceTree = "<group>"; };
                CEDED0932032450B003FA44D /* BDSKIUCrParser.m */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = 
BDSKIUCrParser.m; sourceTree = "<group>"; };
                CEE09F19216147E1009CE63D /* BDSKFieldInfo.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BDSKFieldInfo.h; 
sourceTree = "<group>"; };
@@ -2486,9 +2482,8 @@
                        children = (
                                F9022FBF07580B9400C3F701 /* BibDesk.sdef */,
                                CE3011A10D5CC41D00C0B7FA /* BDSKAddCommand.m */,
-                               CEDD188B21696373000E28D7 /* 
BDSKAutoFileCommand.m */,
-                               CE51616B22CD4E7D00832F3E /* 
BDSKDownloadCommand.m */,
                                CED65DC70907A2FD003EED90 /* 
BDSKParseFormatCommand.m */,
+                               CE01CBB527948B6F0074FCBE /* 
BDSKPublicationCommand.m */,
                                CE3011AB0D5CC46F00C0B7FA /* BDSKRemoveCommand.m 
*/,
                                CED876D8216D09EB0005FF8D /* 
BDSKResolveCommand.m */,
                                CEC3158B0F24D0B9008D2C75 /* 
BDSKRichTextForCommand.m */,
@@ -3192,7 +3187,6 @@
                                CE77963E20372B90009C6A52 /* 
BDSKAsynchronousWebParser.h */,
                                CE5417E122D4DA9500867189 /* 
BDSKAuthenticationController.h */,
                                CE5417C822D4DA7700867189 /* 
BDSKAuthenticationHandler.h */,
-                               CEDD189821696373000E28D7 /* 
BDSKAutoFileCommand.h */,
                                6CD26A210F928EEE0089FDFD /* 
BDSKBibDeskProtocol.h */,
                                F9022C950758038000C3F701 /* BDSKBibTeXParser.h 
*/,
                                CD86BA2C1141C018005EEFDA /* 
BDSKBibTeXWebParser.h */,
@@ -3234,7 +3228,6 @@
                                F990C5890D42D58D00B5425E /* 
BDSKDocumentSearch.h */,
                                CE522F731D5CA7FD00348D7D /* BDSKDOIParser.h */,
                                CE7B88902045664200D6A648 /* BDSKDOIWebParser.h 
*/,
-                               CE51616A22CD4E7D00832F3E /* 
BDSKDownloadCommand.h */,
                                CE6958F4223A9B94001239A6 /* BDSKDownloader.h */,
                                CE044A4212667EB500CE55C4 /* 
BDSKDownloadManager.h */,
                                CEEC70DF093B6EC200A64F54 /* BDSKDragImageView.h 
*/,
@@ -3348,6 +3341,7 @@
                                CE3448010A11302F0026A92A /* BDSKPreviewItem.h 
*/,
                                CE8F75B8239D3F7F00511336 /* BDSKPRISMParser.h 
*/,
                                6C5DE3E50F8FC33B00E02D5F /* 
BDSKProjectEuclidParser.h */,
+                               CE01CBCC27948BF20074FCBE /* 
BDSKPublicationCommand.h */,
                                CE565BBD0AEF848B002F0A24 /* 
BDSKPublicationsArray.h */,
                                F9022CA60758038000C3F701 /* BDSKPubMedParser.h 
*/,
                                CE73BACE0FB1CE9600A43716 /* 
BDSKPubMedXMLParser.h */,
@@ -3652,7 +3646,6 @@
                                CE2A0A6622459A0A00A8F31C /* 
BDSKSearchForCommand.h in Headers */,
                                CE2A09D7224599B300A8F31C /* BDSKCondition.h in 
Headers */,
                                CE2A0A9122459A3600A8F31C /* BDSKTreeNode.h in 
Headers */,
-                               CE51616C22CD4E7D00832F3E /* 
BDSKDownloadCommand.h in Headers */,
                                CE2A09F7224599E100A8F31C /* 
BDSKFieldNameFormatter.h in Headers */,
                                CE2A09F0224599DB00A8F31C /* BDSKErrorObject.h 
in Headers */,
                                CE2A0A7122459A0A00A8F31C /* 
BDSKSharingBrowser.h in Headers */,
@@ -3909,7 +3902,6 @@
                                CE2A0A5E22459A0A00A8F31C /* 
BDSKScriptHook+Scripting.h in Headers */,
                                CE2A09CE2245997A00A8F31C /* 
BDSKCiteULikeParser.h in Headers */,
                                CE2A0AB422459A4500A8F31C /* BibPref_AutoFile.h 
in Headers */,
-                               CE2A09BD2245997A00A8F31C /* 
BDSKAutoFileCommand.h in Headers */,
                                CE2A0A6522459A0A00A8F31C /* 
BDSKSearchBookmark+Scripting.h in Headers */,
                                CE2A0AE522459A5100A8F31C /* 
NSView_BDSKExtensions.h in Headers */,
                                CE2A09C62245997A00A8F31C /* 
BDSKBooleanValueTransformer.h in Headers */,
@@ -3917,6 +3909,7 @@
                                CE2A09E3224599B300A8F31C /* BDSKDOIWebParser.h 
in Headers */,
                                CE2A09B32245997A00A8F31C /* BDSKAddCommand.h in 
Headers */,
                                CE2A0A27224599EF00A8F31C /* BDSKLinkedFile.h in 
Headers */,
+                               CE01CBCD27948BF20074FCBE /* 
BDSKPublicationCommand.h in Headers */,
                                CE2A09EE224599DB00A8F31C /* BDSKErrorEditor.h 
in Headers */,
                                CE2A0ACA22459A4B00A8F31C /* 
NSColor_BDSKExtensions.h in Headers */,
                                CE2A0AC122459A4B00A8F31C /* 
DOMNode_BDSKExtensions.h in Headers */,
@@ -4703,7 +4696,6 @@
                                F946DCE909FDC4B600D471DF /* 
BDSKAsynchronousDOServer.m in Sources */,
                                F9A411FC0A0B2066008493C0 /* 
BDSKPreferenceController.m in Sources */,
                                CE3448020A11302F0026A92A /* BDSKPreviewItem.m 
in Sources */,
-                               CEDD189921696373000E28D7 /* 
BDSKAutoFileCommand.m in Sources */,
                                CE3256000A1748D0002D6E4C /* 
NSGeometry_BDSKExtensions.m in Sources */,
                                CE325FCE0A1A74E9002D6E4C /* 
BDSKTemplateParser.m in Sources */,
                                F963E45B0A1D828100695DDC /* BDSKTreeNode.m in 
Sources */,
@@ -4721,7 +4713,6 @@
                                CE22E1CE0A8CCF9D002CEFB8 /* 
BDSKOrphanedFilesFinder.m in Sources */,
                                CE35DCEA0A99B1A700029B66 /* BDSKErrorEditor.m 
in Sources */,
                                CE15C0D80AA5B9A3002C555F /* BDSKErrorManager.m 
in Sources */,
-                               CE51616D22CD4E7D00832F3E /* 
BDSKDownloadCommand.m in Sources */,
                                CE7EA95D0AAC55B2000FE8FD /* 
NSWindowController_BDSKExtensions.m in Sources */,
                                F96F11970AAF4FD100815D06 /* 
NSData_BDSKExtensions.m in Sources */,
                                F9937E230AD8268E001D1DFB /* 
BDSKZoomablePDFView.m in Sources */,
@@ -4781,6 +4772,7 @@
                                CE6C04450BEDFA2D007BF0B5 /* 
NSParagraphStyle_BDSKExtensions.m in Sources */,
                                F9D0E5370BF92768001C6C22 /* BDSKMODSParser.m in 
Sources */,
                                CE6CF99B2038413C000B73D3 /* BDSKNumdamParser.m 
in Sources */,
+                               CE01CBCB27948B6F0074FCBE /* 
BDSKPublicationCommand.m in Sources */,
                                CEFD45890BFFC1F80027B933 /* 
NSWindow+Scripting.m in Sources */,
                                F97C9DB20C4481670002EE01 /* 
BDSKISIGroupServer.m in Sources */,
                                CED876DA216D09EB0005FF8D /* 
BDSKResolveCommand.m in Sources */,

Modified: trunk/bibdesk/Scripting/BibDesk.sdef
===================================================================
--- trunk/bibdesk/Scripting/BibDesk.sdef        2022-01-16 17:19:34 UTC (rev 
27227)
+++ trunk/bibdesk/Scripting/BibDesk.sdef        2022-01-16 17:25:35 UTC (rev 
27228)
@@ -633,7 +633,7 @@
         
         <command name="auto file" code="BDSKAfil"
                        description="Auto file a linked file.">
-            <cocoa class="BDSKAutoFileCommand"/>
+            <cocoa class="BDSKPublicationCommand"/>
             <direct-parameter type="specifier"
                 description="A reference to a publication, linked file(s), or 
field to auto file. For a publication, either linked file(s) or a local file 
field are auto filed, depending on your Fields preferences or the 'from' or 'at 
index' arguments."/>
             <parameter name="for" type="text" code="for " optional="yes" 
hidden="yes"
@@ -662,7 +662,7 @@
         
         <command name="download" code="BDSKDnld"
             description="Download a linked URL or URL field.">
-            <cocoa class="BDSKDownloadCommand"/>
+            <cocoa class="BDSKPublicationCommand"/>
             <direct-parameter type="specifier"
                 description="A reference to a publication, linked URL(s), or 
field to download. For a publication, either linked URL(s) or a remote URL 
field are downloaded, depending on your Fields preferences."/>
             <parameter name="replace" type="boolean" code="Repl" optional="yes"
@@ -1118,10 +1118,10 @@
                 <cocoa method="handleShowScriptCommand:"/>
             </responds-to>
             <responds-to name="auto file">
-                <cocoa method=""/>
+                <cocoa method="handleAutoFileScriptCommand:"/>
             </responds-to>
             <responds-to name="download">
-                <cocoa method=""/>
+                <cocoa method="handleDownloadScriptCommand:"/>
             </responds-to>
         </class>
         
@@ -1246,12 +1246,6 @@
                 description="Citation values of the field.">
                 <cocoa key="scriptingPublications"/>
             </element>
-            <responds-to name="auto file">
-                <cocoa method=""/>
-            </responds-to>
-            <responds-to name="download">
-                <cocoa method=""/>
-            </responds-to>
         </class>
         
         <class name="info" plural="infos" code="Info"
@@ -1329,9 +1323,6 @@
             <responds-to name="remove">
                 <cocoa method=""/>
             </responds-to>
-            <responds-to name="auto file">
-                <cocoa method=""/>
-            </responds-to>
                </class>
         
         <class name="group" plural="groups" code="Grup"

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



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to