Revision: 22830
          http://sourceforge.net/p/bibdesk/svn/22830
Author:   hofman
Date:     2018-10-14 13:01:51 +0000 (Sun, 14 Oct 2018)
Log Message:
-----------
get document for open location command from subject if relevant

Modified Paths:
--------------
    trunk/bibdesk/BDSKAppController.m

Modified: trunk/bibdesk/BDSKAppController.m
===================================================================
--- trunk/bibdesk/BDSKAppController.m   2018-10-14 12:50:04 UTC (rev 22829)
+++ trunk/bibdesk/BDSKAppController.m   2018-10-14 13:01:51 UTC (rev 22830)
@@ -804,6 +804,7 @@
 
 - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event 
withReplyEvent:(NSAppleEventDescriptor *)replyEvent{
     NSString *theURLString = [[event descriptorForKeyword:keyDirectObject] 
stringValue];
+    NSScriptObjectSpecifier *subject = [NSScriptObjectSpecifier 
objectSpecifierWithDescriptor:[event attributeDescriptorForKeyword:'subj']];
     NSURL *theURL = nil;
     BibDocument *document = nil;
     NSError *error = nil;
@@ -818,6 +819,12 @@
         theURL = [NSURL URLWithString:theURLString] ?: [NSURL 
URLWithStringByNormalizingPercentEscapes:theURLString];
     }
     
+    if (subject) {
+        document = [subject objectsByEvaluatingSpecifier];
+        if ([document isKindOfClass:[BibDocument class]] == NO)
+            document = nil;
+    }
+    
     if ([[theURL scheme] isEqualToString:BDSKBibItemURLScheme]) {
         
         NSString *citeKey = [[theURLString substringFromIndex:9] 
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
@@ -834,7 +841,8 @@
         BDSKSearchGroup *group = [[BDSKSearchGroup alloc] initWithURL:theURL];
         
         if (group) {
-            document = [self frontDocumentOfClass:[BibDocument class] 
error:&error];
+            if (document == nil)
+                document = [self frontDocumentOfClass:[BibDocument class] 
error:&error];
             [[document groups] addSearchGroup:group];
             [group release];
         } else {
@@ -841,9 +849,10 @@
             error = [NSError localErrorWithCode:kBDSKURLOperationFailed 
localizedDescription:NSLocalizedString(@"Unable to get search group from 
bdsksearch:// URL.", @"error when opening bdsksearch URL")];
         }
         
-    } else if ([@"http" isCaseInsensitiveEqual:[theURL scheme]] || [@"https" 
isCaseInsensitiveEqual:[theURL scheme]]) {
+    } else if ([@"http" isCaseInsensitiveEqual:[theURL scheme]] || [@"https" 
isCaseInsensitiveEqual:[theURL scheme]]|| [[theURL absoluteString] 
hasCaseInsensitivePrefix:@"bibdesk:"]) {
         
-        document = [self frontDocumentOfClass:[BibDocument class] 
error:&error];
+        if (document == nil)
+            document = [self frontDocumentOfClass:[BibDocument class] 
error:&error];
         [document openURL:theURL];
         
     } else if (theURL) {
@@ -852,7 +861,7 @@
         
     }
     
-    if (document == nil && error && errorReporting)
+    if (error && errorReporting)
         [NSApp presentError:error];
 }
 

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to