Revision: 18482
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18482&view=rev
Author: hofman
Date: 2012-02-03 18:25:37 +0000 (Fri, 03 Feb 2012)
Log Message:
-----------
return isPartialError by reference from string parser when we may use the
bibtex parser, for consistency
Modified Paths:
--------------
trunk/bibdesk/BDSKEditor.m
trunk/bibdesk/BDSKImportCommand.m
trunk/bibdesk/BDSKStringParser.h
trunk/bibdesk/BDSKStringParser.m
trunk/bibdesk/BDSKTextImportController.m
trunk/bibdesk/BibDocument.m
Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m 2012-02-03 17:59:02 UTC (rev 18481)
+++ trunk/bibdesk/BDSKEditor.m 2012-02-03 18:25:37 UTC (rev 18482)
@@ -2688,15 +2688,18 @@
if([pboardType isEqualToString:NSStringPboardType]){
NSString *pbString = [pboard stringForType:NSStringPboardType];
NSError *error = nil;
+ BOOL isPartialData = NO;
// this returns nil when there was a parser error and the user didn't
decide to proceed anyway
- draggedPubs = [BDSKStringParser itemsFromString:pbString
ofType:[pbString contentStringType] owner:[self document] error:&error];
+ draggedPubs = [BDSKStringParser itemsFromString:pbString
ofType:[pbString contentStringType] owner:[self document]
isPartialData:&isPartialData error:&error];
// we ignore warnings for parsing with temporary keys, but we want to
ignore the cite key in that case
- if([error isLocalError] && [error code] == kBDSKHadMissingCiteKeys) {
- hasTemporaryCiteKey = YES;
- error = nil;
- } else if ([error isLocalError] && [error code] ==
kBDSKBibTeXParserFailed) {
- // should we accept partially parsed bibtex?
- draggedPubs = nil;
+ if (isPartialData && [error isLocalError]) {
+ if ([error code] == kBDSKHadMissingCiteKeys) {
+ hasTemporaryCiteKey = YES;
+ error = nil;
+ } else if ([error code] == kBDSKBibTeXParserFailed) {
+ // should we accept partially parsed bibtex?
+ draggedPubs = nil;
+ }
}
}else if([pboardType isEqualToString:BDSKBibItemPboardType]){
NSData *pbData = [pboard dataForType:BDSKBibItemPboardType];
Modified: trunk/bibdesk/BDSKImportCommand.m
===================================================================
--- trunk/bibdesk/BDSKImportCommand.m 2012-02-03 17:59:02 UTC (rev 18481)
+++ trunk/bibdesk/BDSKImportCommand.m 2012-02-03 18:25:37 UTC (rev 18482)
@@ -118,7 +118,7 @@
[self setScriptErrorNumber:NSArgumentsWrongScriptError];
return nil;
}
- pubs = [BDSKStringParser itemsFromString:string
ofType:BDSKUnknownStringType owner:document error:NULL];
+ pubs = [BDSKStringParser itemsFromString:string
ofType:BDSKUnknownStringType owner:document isPartialData:NULL error:NULL];
} else if (searchTerm) {
pubs = [NSArray arrayWithObjects:[BibItem
itemWithPubMedSearchTerm:searchTerm], nil];
} else {
Modified: trunk/bibdesk/BDSKStringParser.h
===================================================================
--- trunk/bibdesk/BDSKStringParser.h 2012-02-03 17:59:02 UTC (rev 18481)
+++ trunk/bibdesk/BDSKStringParser.h 2012-02-03 18:25:37 UTC (rev 18482)
@@ -62,7 +62,7 @@
// passing BDSKUnknownStringType will ise the appropriate -contentStringType
+ (BOOL)canParseString:(NSString *)string ofType:(BDSKStringType)stringType;
+ (NSArray *)itemsFromString:(NSString *)string
ofType:(BDSKStringType)stringType error:(NSError **)outError;
-+ (NSArray *)itemsFromString:(NSString *)string ofType:(BDSKStringType)type
owner:(id <BDSKOwner>)owner error:(NSError **)outError;
++ (NSArray *)itemsFromString:(NSString *)string ofType:(BDSKStringType)type
owner:(id <BDSKOwner>)owner isPartialData:(BOOL *)isPartialData error:(NSError
**)outError;
@end
Modified: trunk/bibdesk/BDSKStringParser.m
===================================================================
--- trunk/bibdesk/BDSKStringParser.m 2012-02-03 17:59:02 UTC (rev 18481)
+++ trunk/bibdesk/BDSKStringParser.m 2012-02-03 18:25:37 UTC (rev 18482)
@@ -95,22 +95,24 @@
return [parserClass itemsFromString:string error:outError];
}
-+ (NSArray *)itemsFromString:(NSString *)string ofType:(BDSKStringType)type
owner:(id <BDSKOwner>)owner error:(NSError **)outError {
++ (NSArray *)itemsFromString:(NSString *)string ofType:(BDSKStringType)type
owner:(id <BDSKOwner>)owner isPartialData:(BOOL *)isPartialData error:(NSError
**)outError {
NSArray *newPubs = nil;
NSError *parseError = nil;
- BOOL isPartialData = NO;
// @@ BDSKStringParser doesn't handle any BibTeX types, so it's not really
useful as a funnel point for any string type, since each usage requires special
casing for BibTeX.
if(BDSKUnknownStringType == type)
type = [string contentStringType];
- if(type == BDSKBibTeXStringType)
- newPubs = [BDSKBibTeXParser itemsFromString:string owner:owner
isPartialData:&isPartialData error:&parseError];
- else if(type == BDSKNoKeyBibTeXStringType)
- newPubs = [BDSKBibTeXParser itemsFromString:[string
stringWithPhoneyCiteKeys:@"FixMe"] owner:owner isPartialData:&isPartialData
error:&parseError];
- else
+ if(type == BDSKBibTeXStringType){
+ newPubs = [BDSKBibTeXParser itemsFromString:string owner:owner
isPartialData:isPartialData error:&parseError];
+ }else if(type == BDSKNoKeyBibTeXStringType){
+ newPubs = [BDSKBibTeXParser itemsFromString:[string
stringWithPhoneyCiteKeys:@"FixMe"] owner:owner isPartialData:isPartialData
error:&parseError];
+ }else{
// this will create the NSError if the type is unrecognized
newPubs = [self itemsFromString:string ofType:type error:&parseError];
+ if(isPartialData)
+ *isPartialData = newPubs != nil;
+ }
if([parseError isLocalError] && [parseError code] ==
kBDSKBibTeXParserFailed){
NSError *error = [NSError
mutableLocalErrorWithCode:kBDSKBibTeXParserFailed
localizedDescription:NSLocalizedString(@"Error Reading String", @"Message in
alert dialog when failing to parse dropped or copied string")];
Modified: trunk/bibdesk/BDSKTextImportController.m
===================================================================
--- trunk/bibdesk/BDSKTextImportController.m 2012-02-03 17:59:02 UTC (rev
18481)
+++ trunk/bibdesk/BDSKTextImportController.m 2012-02-03 18:25:37 UTC (rev
18482)
@@ -1501,13 +1501,16 @@
return;
NSError *error = nil;
- NSArray *pubs = [BDSKStringParser itemsFromString:string ofType:type
owner:owner error:&error];
+ BOOL isPartialData = NO;
+ NSArray *pubs = [BDSKStringParser itemsFromString:string ofType:type
owner:owner isPartialData:&isPartialData error:&error];
// ignore warnings for parsing with temporary citekeys, as we're not
interested in the cite key
- if ([error isLocalError] && [error code] == kBDSKHadMissingCiteKeys)
+ if ([error isLocalError] && [error code] == kBDSKHadMissingCiteKeys) {
+ isPartialData = NO;
error = nil;
+ }
- if(error || [pubs count] == 0)
+ if(isPartialData || [pubs count] == 0)
return;
if([[self publication] hasBeenEdited]){
Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2012-02-03 17:59:02 UTC (rev 18481)
+++ trunk/bibdesk/BibDocument.m 2012-02-03 18:25:37 UTC (rev 18482)
@@ -2179,6 +2179,7 @@
[groups addSearchGroup:group];
} else {
NSError *parseError = nil;
+ BOOL isPartialData = NO;
NSArray *contentArray = nil;
if ([unreadableTypes containsObject:[fileName pathExtension]] ==
NO) {
@@ -2195,9 +2196,9 @@
type = [contentString contentStringType];
if (type != BDSKUnknownStringType) {
- contentArray = [BDSKStringParser
itemsFromString:contentString ofType:type owner:self error:&parseError];
+ contentArray = [BDSKStringParser
itemsFromString:contentString ofType:type owner:self
isPartialData:&isPartialData error:&parseError];
- if ([parseError isLocalError]) {
+ if (isPartialData && [parseError isLocalError]) {
if ([parseError code] ==
kBDSKParserIgnoredFrontMatter) {
if (verbose) [self presentError:parseError];
parseError = nil;
@@ -2301,6 +2302,7 @@
NSArray *newFiles = nil;
NSURL *newURL = nil;
NSError *error = nil;
+ BOOL isPartialData = NO;
NSString *temporaryCiteKey = nil;
BOOL shouldEdit = [[NSUserDefaults standardUserDefaults]
boolForKey:BDSKEditOnPasteKey];
@@ -2310,11 +2312,11 @@
}else if([type isEqualToString:BDSKReferenceMinerStringPboardType]){
NSString *pbString = [pb stringForType:NSStringPboardType];
// sniffing the string for RIS is broken because RefMiner puts junk at
the beginning
- newPubs = [BDSKStringParser itemsFromString:pbString
ofType:BDSKReferenceMinerStringType owner:self error:&error];
+ newPubs = [BDSKStringParser itemsFromString:pbString
ofType:BDSKReferenceMinerStringType owner:self isPartialData:&isPartialData
error:&error];
}else if([type isEqualToString:NSStringPboardType]){
NSString *pbString = [pb stringForType:NSStringPboardType];
// sniff the string to see what its type is
- newPubs = [BDSKStringParser itemsFromString:pbString
ofType:BDSKUnknownStringType owner:self error:&error];
+ newPubs = [BDSKStringParser itemsFromString:pbString
ofType:BDSKUnknownStringType owner:self isPartialData:&isPartialData
error:&error];
}else if([type isEqualToString:NSFilenamesPboardType]){
NSArray *pbArray = [pb
propertyListForType:NSFilenamesPboardType]; // we will get an array
// try this first, in case these files are a type we can open
@@ -2349,7 +2351,7 @@
error = nil;
}else if([error isLocalError] && [error code] == kBDSKBibTeXParserFailed){
// this asks whether to ignore partially failed bibtex when verbose,
otherwise just ignore, for NSFilenamesPboardType this was already handled
- if([type isEqualToString:NSFilenamesPboardType] == NO && (verbose ==
NO || [self presentError:error] == NO))
+ if(isPartialData && (verbose == NO || [self presentError:error] == NO))
newPubs = nil;
}else if(error && verbose){
// display error for non-bibtex string parsers when verbose
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit