Revision: 22324 http://sourceforge.net/p/bibdesk/svn/22324 Author: hofman Date: 2018-06-18 14:27:50 +0000 (Mon, 18 Jun 2018) Log Message: ----------- make document info mutable and add setter for a single key
Modified Paths: -------------- trunk/bibdesk/BibDocument.h trunk/bibdesk/BibDocument.m Modified: trunk/bibdesk/BibDocument.h =================================================================== --- trunk/bibdesk/BibDocument.h 2018-06-18 13:54:01 UTC (rev 22323) +++ trunk/bibdesk/BibDocument.h 2018-06-18 14:27:50 UTC (rev 22324) @@ -199,7 +199,7 @@ BDSKMacroResolver *macroResolver; - NSDictionary *documentInfo; + NSMutableDictionary *documentInfo; NSString *frontMatter; // for preambles, and stuff @@ -356,6 +356,7 @@ - (NSDictionary *)documentInfo; - (void)setDocumentInfo:(NSDictionary *)dict; - (NSString *)documentInfoForKey:(NSString *)key; +- (void)setDocumentInfo:(NSString *)value forKey:(NSString *)key; - (id)valueForUndefinedKey:(NSString *)key; - (NSString *)documentInfoString; Modified: trunk/bibdesk/BibDocument.m =================================================================== --- trunk/bibdesk/BibDocument.m 2018-06-18 13:54:01 UTC (rev 22323) +++ trunk/bibdesk/BibDocument.m 2018-06-18 14:27:50 UTC (rev 22324) @@ -205,7 +205,7 @@ groups = [(BDSKGroupsArray *)[BDSKGroupsArray alloc] initWithDocument:self]; frontMatter = nil; - documentInfo = nil; + documentInfo = [[NSMutableDictionary alloc] initForCaseInsensitiveKeys]; macroResolver = [[BDSKMacroResolver alloc] initWithOwner:self]; BDSKUndoManager *newUndoManager = [[[BDSKUndoManager alloc] init] autorelease]; @@ -941,9 +941,8 @@ - (void)setDocumentInfo:(NSDictionary *)dict{ if (dict != documentInfo) { - [[[self undoManager] prepareWithInvocationTarget:self] setDocumentInfo:documentInfo]; - [documentInfo release]; - documentInfo = [[NSDictionary alloc] initForCaseInsensitiveKeysWithDictionary:dict]; + [[[self undoManager] prepareWithInvocationTarget:self] setDocumentInfo:[[documentInfo copy] autorelease]]; + [documentInfo setDictionary:dict]; } } @@ -951,6 +950,11 @@ return [documentInfo valueForKey:key]; } +- (void)setDocumentInfo:(NSString *)value forKey:(NSString *)key { + [[[self undoManager] prepareWithInvocationTarget:self] setDocumentInfo:[documentInfo objectForKey:key] forKey:key]; + [documentInfo setValue:value forKey:key]; +} + - (id)valueForUndefinedKey:(NSString *)key{ return [self documentInfoForKey:key]; } @@ -1868,7 +1872,7 @@ if ((groupData = [[self groups] serializedGroupsDataOfType:BDSKScriptGroupType])) [oldGroups setObject:groupData forKey:[NSNumber numberWithUnsignedInteger:BDSKScriptGroupType]]; - [[[self undoManager] prepareWithInvocationTarget:self] setPublications:oldPubs macros:oldMacros documentInfo:documentInfo groups:oldGroups frontMatter:frontMatter encoding:[self documentStringEncoding]]; + [[[self undoManager] prepareWithInvocationTarget:self] setPublications:oldPubs macros:oldMacros documentInfo:[[documentInfo copy] autorelease] groups:oldGroups frontMatter:frontMatter encoding:[self documentStringEncoding]]; // we need to stop the file search controller on revert, as this will be invalid after we update our publications if ([self isDisplayingFileContentSearch]) @@ -1895,8 +1899,7 @@ [self setDocumentStringEncoding:newEncoding]; [self setPublications:newPubs]; - [documentInfo release]; - documentInfo = [[NSDictionary alloc] initForCaseInsensitiveKeysWithDictionary:newDocumentInfo]; + [documentInfo setDictionary:newDocumentInfo]; [[self macroResolver] setMacroDefinitions:newMacros]; // important that groups are loaded after publications, otherwise the static groups won't find their publications for (NSNumber *groupType in newGroups) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit