Revision: 27283
http://sourceforge.net/p/bibdesk/svn/27283
Author: hofman
Date: 2022-03-08 10:40:22 +0000 (Tue, 08 Mar 2022)
Log Message:
-----------
No need toexplicitlyclear pasteboard promises, clear pasteboard
Modified Paths:
--------------
trunk/bibdesk/BDSKCustomCiteDrawerController.m
trunk/bibdesk/BDSKItemPasteboardHelper.h
trunk/bibdesk/BDSKItemPasteboardHelper.m
trunk/bibdesk/BibDocument.m
trunk/bibdesk/BibDocument_DataSource.h
trunk/bibdesk/BibDocument_DataSource.m
Modified: trunk/bibdesk/BDSKCustomCiteDrawerController.m
===================================================================
--- trunk/bibdesk/BDSKCustomCiteDrawerController.m 2022-03-08 07:30:18 UTC
(rev 27282)
+++ trunk/bibdesk/BDSKCustomCiteDrawerController.m 2022-03-08 10:40:22 UTC
(rev 27283)
@@ -195,7 +195,7 @@
}
- (void)tableView:(NSTableView *)tv
concludeDragOperation:(NSDragOperation)operation{
- [document clearPromisedDraggedItems];
+ [[NSPasteboard pasteboardWithName:NSDragPboard] clearContents];
}
- (NSImage *)tableView:(NSTableView *)tv
dragImageForRowsWithIndexes:(NSIndexSet *)dragRows{
Modified: trunk/bibdesk/BDSKItemPasteboardHelper.h
===================================================================
--- trunk/bibdesk/BDSKItemPasteboardHelper.h 2022-03-08 07:30:18 UTC (rev
27282)
+++ trunk/bibdesk/BDSKItemPasteboardHelper.h 2022-03-08 10:40:22 UTC (rev
27283)
@@ -58,6 +58,5 @@
- (void)writeItems:(NSArray *)items textRepresentation:(id)text
forDragCopyType:(BDSKDragCopyType)dragCopyType toPasteboard:(NSPasteboard
*)pboard;
- (NSArray *)promisedItemsForPasteboard:(NSPasteboard *)pboard;
-- (void)clearPromisedTypesForPasteboard:(NSPasteboard *)pboard;
@end
Modified: trunk/bibdesk/BDSKItemPasteboardHelper.m
===================================================================
--- trunk/bibdesk/BDSKItemPasteboardHelper.m 2022-03-08 07:30:18 UTC (rev
27282)
+++ trunk/bibdesk/BDSKItemPasteboardHelper.m 2022-03-08 10:40:22 UTC (rev
27283)
@@ -76,34 +76,28 @@
- (void)setDelegate:(id<BDSKItemPasteboardHelperDelegate>)newDelegate {
if (newDelegate != delegate) {
if (delegate) {
- for (NSString *name in [promisedPboardTypes allKeys]) {
- NSPasteboard *pboard = [NSPasteboard pasteboardWithName:name];
- if ([self pasteboardIsValid:pboard] == NO) {
- [self clearPromisedTypesForPasteboard:pboard];
- continue;
- }
- NSMutableDictionary *dict = [promisedPboardTypes
objectForKey:name];
- if (pboard == nil) continue;
- NSArray *items = [[[dict objectForKey:ITEMS_KEY] copy]
autorelease];
- if (items == nil) continue;
- [dict removeObjectForKey:ITEMS_KEY];
- NSArray *types = [[[dict objectForKey:TYPES_KEY] copy]
autorelease];
- if ([types containsObject:BDSKPasteboardTypePublications]) {
- [dict setObject:[BibItem archivedPublications:items]
forKey:ARCHIVEDDATA_KEY];
- }
- if ([types containsObject:NSPasteboardTypePDF] || [types
containsObject:NSPasteboardTypeRTF] || [types
containsObject:NSPasteboardTypeString]) {
- // the remaining type needs a texTask
- // get intermediate data so we don't need the delegate and
the items
- NSString *bibString = nil;
- bibString = [delegate pasteboardHelper:self
bibTeXStringForItems:items];
- if (bibString != nil) {
- [dict setObject:bibString forKey:BIBTEXSTRING_KEY];
- [dict setObject:[items valueForKey:@"citeKey"]
forKey:CITEKEYS_KEY];
- } else {
- [self clearPromisedTypesForPasteboard:pboard];
+ [promisedPboardTypes enumerateKeysAndObjectsUsingBlock:^(NSString
*name, NSMutableDictionary *dict, BOOL *stop){
+ NSArray *items = [dict objectForKey:ITEMS_KEY];
+ if (items) {
+ NSArray *types = [dict objectForKey:TYPES_KEY];
+ if ([types containsObject:BDSKPasteboardTypePublications])
{
+ NSData *data = [BibItem archivedPublications:items];
+ if (data)
+ [dict setObject:data forKey:ARCHIVEDDATA_KEY];
}
+ if ([types containsObject:NSPasteboardTypePDF] || [types
containsObject:NSPasteboardTypeRTF] || [types
containsObject:NSPasteboardTypeString]) {
+ // the remaining type needs a texTask
+ // get intermediate data so we don't need the delegate
and the items
+ NSString *bibString = nil;
+ bibString = [delegate pasteboardHelper:self
bibTeXStringForItems:items];
+ if (bibString != nil) {
+ [dict setObject:bibString forKey:BIBTEXSTRING_KEY];
+ [dict setObject:[items valueForKey:@"citeKey"]
forKey:CITEKEYS_KEY];
+ }
+ }
+ [dict removeObjectForKey:ITEMS_KEY];
}
- }
+ }];
}
delegate = newDelegate;
}
@@ -264,31 +258,12 @@
BDSKENSURE_MAIN_THREAD( [self removePromisedTypesForPasteboard:pboard]; );
}
-#pragma mark Promised items and types
+#pragma mark Promised items
- (NSArray *)promisedItemsForPasteboard:(NSPasteboard *)pboard {
return [self pasteboardIsValid:pboard] ? [[promisedPboardTypes
objectForKey:[pboard name]] objectForKey:ITEMS_KEY] : nil;
}
-- (void)clearPromisedTypesForPasteboard:(NSPasteboard *)pboard {
- NSArray *types = [[[self promisedTypesForPasteboard:pboard] copy]
autorelease];
- if (types) {
- if ([self isProviderForPasteboard:pboard]) {
- for (NSString *type in types) {
- for (NSPasteboardItem *item in [pboard pasteboardItems]) {
- if ([[item types] containsObject:type]) {
- // can raise NSPasteboardCommunicationException
- @try { [item setData:[NSData data] forType:type]; }
- @catch(id exception) { NSLog(@"ignoring exception %@
in -[%@ %@]", exception, [self class], NSStringFromSelector(_cmd)); }
- break;
- }
- }
- }
- }
- [self removePromisedTypesForPasteboard:pboard];
- }
-}
-
@end
Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2022-03-08 07:30:18 UTC (rev 27282)
+++ trunk/bibdesk/BibDocument.m 2022-03-08 10:40:22 UTC (rev 27283)
@@ -1596,7 +1596,6 @@
[pboardHelper writeItems:[self publicationsForSaving]
textRepresentation:nil forDragCopyType:BDSKDragCopyLTB toPasteboard:pboard];
NSArray *ltbStrings = [pboard readObjectsForClasses:[NSArray
arrayWithObject:[NSString class]] options:[NSDictionary dictionary]];
[pboard clearContents]; // this will clear the pasteboard helper for this
pasteboard
- [pboardHelper clearPromisedTypesForPasteboard:pboard]; // just to be sure
[pboard releaseGlobally];
if([ltbStrings count] == 0){
if (error)
Modified: trunk/bibdesk/BibDocument_DataSource.h
===================================================================
--- trunk/bibdesk/BibDocument_DataSource.h 2022-03-08 07:30:18 UTC (rev
27282)
+++ trunk/bibdesk/BibDocument_DataSource.h 2022-03-08 10:40:22 UTC (rev
27283)
@@ -48,7 +48,6 @@
- (BOOL)writePublications:(NSArray*)pubs
forDragCopyType:(BDSKDragCopyType)dragCopyType
toPasteboard:(NSPasteboard*)pboard;
- (BOOL)writePublications:(NSArray*)pubs
forDragCopyType:(BDSKDragCopyType)dragCopyType citeString:(NSString
*)citeString toPasteboard:(NSPasteboard*)pboard;
- (NSImage *)dragImageForPromisedItemsUsingCiteString:(NSString *)citeString;
-- (void)clearPromisedDraggedItems;
@property (nonatomic, readonly) NSDictionary
*currentTableColumnWidthsAndIdentifiers;
@property (nonatomic, getter=isDragFromExternalGroups) BOOL
dragFromExternalGroups;
Modified: trunk/bibdesk/BibDocument_DataSource.m
===================================================================
--- trunk/bibdesk/BibDocument_DataSource.m 2022-03-08 07:30:18 UTC (rev
27282)
+++ trunk/bibdesk/BibDocument_DataSource.m 2022-03-08 10:40:22 UTC (rev
27283)
@@ -459,15 +459,10 @@
- (void)tableView:(NSTableView *)tv
concludeDragOperation:(NSDragOperation)operation{
if (tv == tableView) {
- [self clearPromisedDraggedItems];
+ [[NSPasteboard pasteboardWithName:NSDragPboard] clearContents];
}
}
-- (void)clearPromisedDraggedItems{
- [[NSPasteboard pasteboardWithName:NSDragPboard] clearContents];
- [pboardHelper clearPromisedTypesForPasteboard:[NSPasteboard
pasteboardWithName:NSDragPboard]];
-}
-
- (NSImage *)tableView:(NSTableView *)tv
dragImageForRowsWithIndexes:(NSIndexSet *)dragRows{
if (tv == tableView) {
return [self dragImageForPromisedItemsUsingCiteString:nil];
@@ -1130,7 +1125,7 @@
}
- (void)outlineView:(NSOutlineView *)ov
concludeDragOperation:(NSDragOperation)operation {
- [self clearPromisedDraggedItems];
+ [[NSPasteboard pasteboardWithName:NSDragPboard] clearContents];
}
- (NSImage *)outlineView:(NSOutlineView *)ov dragImageForItems:(NSArray
*)items{
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