Revision: 27285
http://sourceforge.net/p/bibdesk/svn/27285
Author: hofman
Date: 2022-03-08 16:07:35 +0000 (Tue, 08 Mar 2022)
Log Message:
-----------
No need for separate method to get promised types. Remove intermediate data
when removing corresponding promised type.
Modified Paths:
--------------
trunk/bibdesk/BDSKItemPasteboardHelper.m
Modified: trunk/bibdesk/BDSKItemPasteboardHelper.m
===================================================================
--- trunk/bibdesk/BDSKItemPasteboardHelper.m 2022-03-08 14:46:39 UTC (rev
27284)
+++ trunk/bibdesk/BDSKItemPasteboardHelper.m 2022-03-08 16:07:35 UTC (rev
27285)
@@ -53,7 +53,6 @@
@interface BDSKItemPasteboardHelper (Private)
- (BOOL)pasteboardIsValid:(NSPasteboard *)pboard;
-- (NSMutableArray *)promisedTypesForPasteboard:(NSPasteboard *)pboard;
- (void)setPromisedTypes:(NSMutableArray *)types items:(NSArray *)items
dragCopyType:(BDSKDragCopyType)dragCopyType forPasteboard:(NSPasteboard
*)pboard;
- (void)removePromisedType:(NSString *)type forPasteboard:(NSPasteboard
*)pboard;
- (void)removePromisedTypesForPasteboard:(NSPasteboard *)pboard;
@@ -166,8 +165,7 @@
if (items) {
data = [BibItem archivedPublications:items];
} else {
- data = [[[dict objectForKey:ARCHIVEDDATA_KEY] retain] autorelease];
- [dict removeObjectForKey:ARCHIVEDDATA_KEY];
+ data = [dict objectForKey:ARCHIVEDDATA_KEY];
}
} else {
NSString *bibString = nil;
@@ -177,10 +175,8 @@
bibString = [delegate pasteboardHelper:self
bibTeXStringForItems:items];
citeKeys = [items valueForKey:@"citeKey"];
} else {
- bibString = [[[dict objectForKey:BIBTEXSTRING_KEY] retain]
autorelease];
- citeKeys = [[[dict objectForKey:CITEKEYS_KEY] retain] autorelease];
- [dict removeObjectForKey:BIBTEXSTRING_KEY];
- [dict removeObjectForKey:CITEKEYS_KEY];
+ bibString = [dict objectForKey:BIBTEXSTRING_KEY];
+ citeKeys = [dict objectForKey:CITEKEYS_KEY];
}
if (bibString != nil) {
BDSKDragCopyType dragCopyType = [[dict
objectForKey:DRAGCOPYTYPE_KEY] integerValue];
@@ -286,10 +282,6 @@
return isValid;
}
-- (NSMutableArray *)promisedTypesForPasteboard:(NSPasteboard *)pboard {
- return [self pasteboardIsValid:pboard] ? [[promisedPboardTypes
objectForKey:[pboard name]] objectForKey:TYPES_KEY] : nil;
-}
-
- (void)setPromisedTypes:(NSMutableArray *)types items:(NSArray *)items
dragCopyType:(BDSKDragCopyType)dragCopyType forPasteboard:(NSPasteboard
*)pboard {
if ([self pasteboardIsValid:pboard]) {
NSMutableDictionary *dict = [NSMutableDictionary
dictionaryWithObjectsAndKeys:types, TYPES_KEY, [NSNumber
numberWithInteger:dragCopyType], DRAGCOPYTYPE_KEY, nil];
@@ -317,10 +309,21 @@
}
- (void)removePromisedType:(NSString *)type forPasteboard:(NSPasteboard
*)pboard {
- NSMutableArray *types = [self promisedTypesForPasteboard:pboard];
- [types removeObject:type];
- if ([types count] == 0)
- [self removePromisedTypesForPasteboard:pboard];
+ if ([self pasteboardIsValid:pboard]) {
+ NSMutableDictionary *dict = [promisedPboardTypes objectForKey:[pboard
name]];
+ if (dict) {
+ NSMutableArray *types = [dict objectForKey:TYPES_KEY];
+ [types removeObject:type];
+ if ([type isEqualToString:BDSKPasteboardTypePublications]) {
+ [dict removeObjectForKey:ARCHIVEDDATA_KEY];
+ } else {
+ [dict removeObjectForKey:BIBTEXSTRING_KEY];
+ [dict removeObjectForKey:CITEKEYS_KEY];
+ }
+ if ([types count] == 0)
+ [self removePromisedTypesForPasteboard:pboard];
+ }
+ }
}
- (void)removePromisedTypesForPasteboard:(NSPasteboard *)pboard {
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