Revision: 18381
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18381&view=rev
Author: hofman
Date: 2012-01-09 12:30:55 +0000 (Mon, 09 Jan 2012)
Log Message:
-----------
variable and class accessor for default cite key
Modified Paths:
--------------
trunk/bibdesk/BDSKMASParser.m
trunk/bibdesk/BDSKWebGroup.m
trunk/bibdesk/BibItem.h
trunk/bibdesk/BibItem.m
Modified: trunk/bibdesk/BDSKMASParser.m
===================================================================
--- trunk/bibdesk/BDSKMASParser.m 2012-01-09 12:08:07 UTC (rev 18380)
+++ trunk/bibdesk/BDSKMASParser.m 2012-01-09 12:30:55 UTC (rev 18381)
@@ -95,7 +95,7 @@
if (bibtexString == nil)
continue;
- NSArray *parsedItems = [BDSKBibTeXParser itemsFromString:[bibtexString
stringWithPhoneyCiteKeys:@"cite-key"] owner:nil isPartialData:NULL
error:&error];
+ NSArray *parsedItems = [BDSKBibTeXParser itemsFromString:[bibtexString
stringWithPhoneyCiteKeys:[BibItem defaultCiteKey]] owner:nil isPartialData:NULL
error:&error];
if ([parsedItems count] > 0)
[items addObjectsFromArray:parsedItems];
}
Modified: trunk/bibdesk/BDSKWebGroup.m
===================================================================
--- trunk/bibdesk/BDSKWebGroup.m 2012-01-09 12:08:07 UTC (rev 18380)
+++ trunk/bibdesk/BDSKWebGroup.m 2012-01-09 12:30:55 UTC (rev 18381)
@@ -208,7 +208,7 @@
if (type == BDSKBibTeXStringType)
newPubs = [BDSKBibTeXParser itemsFromString:string owner:nil
isPartialData:&isPartialData error:&error];
else if (type == BDSKNoKeyBibTeXStringType)
- newPubs = [BDSKBibTeXParser itemsFromString:[string
stringWithPhoneyCiteKeys:@"cite-key"] owner:nil isPartialData:&isPartialData
error:&error];
+ newPubs = [BDSKBibTeXParser itemsFromString:[string
stringWithPhoneyCiteKeys:[BibItem defaultCiteKey]] owner:nil
isPartialData:&isPartialData error:&error];
else if (type != BDSKUnknownStringType)
newPubs = [BDSKStringParser itemsFromString:string ofType:type
error:&error];
}
Modified: trunk/bibdesk/BibItem.h
===================================================================
--- trunk/bibdesk/BibItem.h 2012-01-09 12:08:07 UTC (rev 18380)
+++ trunk/bibdesk/BibItem.h 2012-01-09 12:30:55 UTC (rev 18381)
@@ -101,6 +101,8 @@
NSUInteger colorLabel;
}
++ (NSString *)defaultCiteKey;
+
- (NSArray *)files;
- (NSUInteger)countOfFiles;
- (BDSKLinkedFile *)objectInFilesAtIndex:(NSUInteger)idx;
Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m 2012-01-09 12:08:07 UTC (rev 18380)
+++ trunk/bibdesk/BibItem.m 2012-01-09 12:30:55 UTC (rev 18381)
@@ -83,8 +83,6 @@
NSString *BDSKBibItemURLScheme = @"x-bdsk";
-#define DEFAULT_CITEKEY @"cite-key"
-
#define BDSKFieldsToWriteIfEmptyKey @"BDSKFieldsToWriteIfEmpty"
static NSSet *fieldsToWriteIfEmpty = nil;
@@ -170,6 +168,8 @@
return identifierURL;
}
+static NSString *defaultCiteKey = nil;
+
/* Paragraph styles cached for efficiency. */
static NSParagraphStyle* keyParagraphStyle = nil;
static NSParagraphStyle* bodyParagraphStyle = nil;
@@ -184,6 +184,8 @@
{
BDSKINITIALIZE;
+ defaultCiteKey = @"cite-key";
+
NSMutableParagraphStyle *defaultStyle = [[NSMutableParagraphStyle alloc]
init];
[defaultStyle setParagraphStyle:[NSParagraphStyle defaultParagraphStyle]];
keyParagraphStyle = [defaultStyle copy];
@@ -222,7 +224,7 @@
- (id)init
{
self = [self initWithType:[[NSUserDefaults standardUserDefaults]
stringForKey:BDSKPubTypeStringKey]
- citeKey:DEFAULT_CITEKEY
+ citeKey:defaultCiteKey
pubFields:nil
files:nil
isNew:YES];
@@ -278,7 +280,7 @@
[self updateMetadataForKey:nil];
if (key == nil) {
- [self setCiteKeyString: DEFAULT_CITEKEY];
+ [self setCiteKeyString: defaultCiteKey];
} else {
[self setCiteKeyString: key];
}
@@ -291,6 +293,10 @@
return self;
}
++ (NSString *)defaultCiteKey {
+ return defaultCiteKey;
+}
+
// Never copy between different documents, as this messes up the macroResolver
for complex string values, unfortunately we don't always control that
- (id)copyWithZone:(NSZone *)zone{
// We set isNew to YES because this is used for duplicate, either from the
menu or AppleScript, and these items are supposed to be newly added to the
document so who0uld have their Date-Added field set to now
@@ -1046,7 +1052,7 @@
- (BOOL)hasEmptyOrDefaultCiteKey{
NSString *key = [self citeKey];
- return [NSString isEmptyString:key] || [key
isEqualToString:DEFAULT_CITEKEY];
+ return [NSString isEmptyString:key] || [key
isEqualToString:defaultCiteKey];
}
- (BOOL)canGenerateAndSetCiteKey
@@ -3306,7 +3312,7 @@
if(newCiteKey != citeKey){
[citeKey autorelease];
citeKey = [newCiteKey copy];
- if ([newCiteKey isEqualToString:DEFAULT_CITEKEY] == NO)
+ if ([newCiteKey isEqualToString:defaultCiteKey] == NO)
[[BDSKCompletionManager sharedManager] addString:newCiteKey
forCompletionEntry:BDSKCrossrefString];
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit