Revision: 29468
          http://sourceforge.net/p/bibdesk/svn/29468
Author:   hofman
Date:     2025-08-25 15:00:18 +0000 (Mon, 25 Aug 2025)
Log Message:
-----------
use modern pastebboard methods

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

Modified: trunk/bibdesk/BDSKTextImportController.m
===================================================================
--- trunk/bibdesk/BDSKTextImportController.m    2025-08-25 14:43:43 UTC (rev 
29467)
+++ trunk/bibdesk/BDSKTextImportController.m    2025-08-25 15:00:18 UTC (rev 
29468)
@@ -672,32 +672,26 @@
 }
 
 - (void)loadPasteboardData{
-    NSPasteboard* pb = [NSPasteboard generalPasteboard];
+    NSPasteboard *pb = [NSPasteboard generalPasteboard];
 
-    NSArray *typeArray = @[NSURLPboardType, NSRTFDPboardType,
-        NSRTFPboardType, NSStringPboardType];
+    NSURL *pbURL = [[pb readObjectsForClasses:@[[NSURL class]] options:@{}] 
firstObject];
     
-    NSString *pbType = [pb availableTypeFromArray:typeArray];    
-    if([pbType isEqualToString:NSURLPboardType]){
+    if(pbURL){
         // setup webview and load page
+        [self showWebViewWithURL:pbURL];
         
-        NSArray *urls = (NSArray *)[pb propertyListForType:pbType];
-        NSURL *url = [NSURL URLWithString:[urls firstObject]];
-        
-        [self showWebViewWithURL:url];
-        
     }else{
                
+        NSString *pbType = [pb availableTypeFromArray:@[NSRTFDPboardType, 
NSRTFPboardType, NSStringPboardType]];
+        
                [self setShowingWebView:NO];
                
-        id pbString = nil;
-        NSURL *pbURL = nil;
+        NSString *pbString = nil;
+        NSAttributedString *pbAttrString = nil;
         NSData *pbData;
         
-               if([pbType isEqualToString:NSRTFPboardType]){
-            pbData = [pb dataForType:pbType];
-            pbString = [[NSAttributedString alloc] initWithRTF:pbData
-                                             documentAttributes:NULL];
+               if([pbType isEqualToString:NSRTFPboardType] || [pbType 
isEqualToString:NSRTFDPboardType]){
+            pbAttrString = [[pb readObjectsForClasses:@[[NSAttributedString 
class]] options:@{}] firstObject];
             pbString = [[(NSAttributedString *)pbString string] 
stringByTrimmingCharactersInSet:[NSCharacterSet 
whitespaceAndNewlineCharacterSet]];
             if([pbString hasCaseInsensitivePrefix:@"http://";] || [pbString 
hasCaseInsensitivePrefix:@"https://";])
                 pbURL = [NSURL URLWithString:pbString];
@@ -706,26 +700,11 @@
                 [self showWebViewWithURL:pbURL];
             }else{
                 NSRange r = NSMakeRange(0,[[sourceTextView string] length]);
-                [sourceTextView replaceCharactersInRange:r withRTF:pbData];
+                [[sourceTextView textStorage] 
setAttributedString:pbAttrString];
                        }
             
-               }else if([pbType isEqualToString:NSRTFDPboardType]){
-            pbData = [pb dataForType:pbType];
-            pbString = [[NSAttributedString alloc] initWithRTFD:pbData
-                                              documentAttributes:NULL];
-            pbString = [[(NSAttributedString *)pbString string] 
stringByTrimmingCharactersInSet:[NSCharacterSet 
whitespaceAndNewlineCharacterSet]];
-            if([pbString hasCaseInsensitivePrefix:@"http://";] || [pbString 
hasCaseInsensitivePrefix:@"https://";])
-                pbURL = [NSURL URLWithString:pbString];
-            
-            if(pbURL){
-                [self showWebViewWithURL:pbURL];
-            }else{
-                NSRange r = NSMakeRange(0,[[sourceTextView string] length]);
-                [sourceTextView replaceCharactersInRange:r withRTFD:pbData];
-            }
-            
                }else if([pbType isEqualToString:NSStringPboardType]){
-            pbString = [pb stringForType:pbType];
+            pbString = [[pb readObjectsForClasses:@[[NSString class]] 
options:@{}] firstObject];
             pbString = [pbString 
stringByTrimmingCharactersInSet:[NSCharacterSet 
whitespaceAndNewlineCharacterSet]];
             if([pbString hasCaseInsensitivePrefix:@"http://";] || [pbString 
hasCaseInsensitivePrefix:@"https://";])
                 pbURL = [NSURL URLWithString:pbString];

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