Revision: 27383
http://sourceforge.net/p/bibdesk/svn/27383
Author: hofman
Date: 2022-04-20 14:44:29 +0000 (Wed, 20 Apr 2022)
Log Message:
-----------
No need to write html data to file for preview, we can pass the baseURL to the
initializer
Modified Paths:
--------------
trunk/bibdesk/BibDocument_UI.m
Modified: trunk/bibdesk/BibDocument_UI.m
===================================================================
--- trunk/bibdesk/BibDocument_UI.m 2022-04-20 06:30:20 UTC (rev 27382)
+++ trunk/bibdesk/BibDocument_UI.m 2022-04-20 14:44:29 UTC (rev 27383)
@@ -167,11 +167,11 @@
NSURL *tmpDirURL = nil;
// make sure this is really one of the attributed string types...
- if([template templateFormat] & BDSKTemplateFormatRichText){
+ if(([template templateFormat] & BDSKTemplateFormatRichText)){
NSDictionary *docAttributes = nil;
templateString = [BDSKTemplateObjectProxy
attributedStringByParsingTemplate:template withObject:self publications:items
documentAttributes:&docAttributes];
backgroundColor = [docAttributes
objectForKey:NSBackgroundColorDocumentAttribute];
- } else if([template templateFormat] & BDSKTemplateFormatPlainText){
+ } else {
// parse as plain text, so the HTML is interpreted properly by
NSAttributedString
NSString *str = [BDSKTemplateObjectProxy
stringByParsingTemplate:template withObject:self publications:items];
NSArray *accessoryURLs = [template accessoryFileURLs];
@@ -181,13 +181,16 @@
tmpDirURL = [fm uniqueTemporaryDirectoryURLWithBasename:@""];
for (NSURL *accessoryURL in accessoryURLs)
[fm createSymbolicLinkAtURL:[tmpDirURL
URLByAppendingPathComponent:[accessoryURL lastPathComponent] isDirectory:NO]
withDestinationURL:accessoryURL error:NULL];
- NSURL *tmpFileURL = [fm uniqueFileURLWithName:[@"templatepreview"
stringByAppendingPathExtension:[template fileExtension]] atURL:tmpDirURL
isDirectory:NO];
+ }
+ if ([template templateFormat] == BDSKTemplateFormatPlainHTML) {
+ templateString = [[[NSAttributedString alloc] initWithHTML:[str
dataUsingEncoding:NSUTF8StringEncoding] baseURL:tmpDirURL
documentAttributes:NULL] autorelease];
+ } else if (tmpDirURL) {
+ NSURL *tmpFileURL = [[NSFileManager defaultManager]
uniqueFileURLWithName:[@"templatepreview"
stringByAppendingPathExtension:[template fileExtension]] atURL:tmpDirURL
isDirectory:NO];
[str writeToURL:tmpFileURL atomically:NO
encoding:NSUTF8StringEncoding error:NULL];
templateString = [[[NSAttributedString alloc]
initWithURL:tmpFileURL options:[NSDictionary dictionary] documentAttributes:nil
error:NULL] autorelease];
- } else if ([template templateFormat] == BDSKTemplateFormatPlainHTML)
- templateString = [[[NSAttributedString alloc] initWithHTML:[str
dataUsingEncoding:NSUTF8StringEncoding] documentAttributes:NULL] autorelease];
- else
+ } else {
templateString = [[[NSAttributedString alloc] initWithString:str
attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont
userFontOfSize:0.0], NSFontAttributeName, nil]] autorelease];
+ }
}
// do this _before_ messing with the text storage; otherwise you can have
a leftover selection that ends up being out of range
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