Revision: 7434
http://skim-app.svn.sourceforge.net/skim-app/?rev=7434&view=rev
Author: hofman
Date: 2011-08-19 10:10:53 +0000 (Fri, 19 Aug 2011)
Log Message:
-----------
class methods for template file resolution
Modified Paths:
--------------
trunk/NSDocument_SKExtensions.h
trunk/NSDocument_SKExtensions.m
trunk/SKFormatCommand.m
Modified: trunk/NSDocument_SKExtensions.h
===================================================================
--- trunk/NSDocument_SKExtensions.h 2011-08-18 16:46:29 UTC (rev 7433)
+++ trunk/NSDocument_SKExtensions.h 2011-08-19 10:10:53 UTC (rev 7434)
@@ -84,6 +84,9 @@
- (NSData *)notesFDFDataForFile:(NSString *)filename fileIDStrings:(NSArray
*)fileIDStrings;
++ (BOOL)isRichTextTemplate:(NSString *)templateFile;
++ (NSString *)pathForTemplateFile:(NSString *)filename;
+
#pragma mark Scripting
- (NSArray *)pages;
Modified: trunk/NSDocument_SKExtensions.m
===================================================================
--- trunk/NSDocument_SKExtensions.m 2011-08-18 16:46:29 UTC (rev 7433)
+++ trunk/NSDocument_SKExtensions.m 2011-08-19 10:10:53 UTC (rev 7434)
@@ -136,14 +136,14 @@
- (NSArray *)notes { return nil; }
-static BOOL isRichTextType(NSString *templateFile) {
++ (BOOL)isRichTextTemplate:(NSString *)templateFile {
static NSSet *types = nil;
if (types == nil)
types = [[NSSet alloc] initWithObjects:@"rtf", @"doc", @"docx",
@"odt", @"webarchive", @"rtfd", nil];
return [types containsObject:[[templateFile pathExtension]
lowercaseString]];
}
-- (NSString *)pathForTemplateFile:(NSString *)filename {
++ (NSString *)pathForTemplateFile:(NSString *)filename {
NSFileManager *fm = [NSFileManager defaultManager];
NSString *fullPath = nil;
@@ -164,8 +164,8 @@
- (NSString *)notesStringUsingTemplateFile:(NSString *)templateFile {
NSString *string = nil;
- if (isRichTextType(templateFile) == NO) {
- NSString *templatePath = [self pathForTemplateFile:templateFile];
+ if ([[self class] isRichTextTemplate:templateFile] == NO) {
+ NSString *templatePath = [[self class]
pathForTemplateFile:templateFile];
NSError *error = nil;
NSString *templateString = [[NSString alloc]
initWithContentsOfFile:templatePath encoding:NSUTF8StringEncoding error:&error];
string = [SKTemplateParser
stringByParsingTemplateString:templateString usingObject:self];
@@ -176,8 +176,8 @@
- (NSData *)notesDataUsingTemplateFile:(NSString *)templateFile {
NSData *data = nil;
- if (isRichTextType(templateFile)) {
- NSString *templatePath = [self pathForTemplateFile:templateFile];
+ if ([[self class] isRichTextTemplate:templateFile]) {
+ NSString *templatePath = [[self class]
pathForTemplateFile:templateFile];
NSDictionary *docAttributes = nil;
NSError *error = nil;
NSAttributedString *templateAttrString = [[NSAttributedString alloc]
initWithPath:templatePath documentAttributes:&docAttributes];
@@ -198,7 +198,7 @@
- (NSFileWrapper *)notesFileWrapperUsingTemplateFile:(NSString *)templateFile {
NSFileWrapper *fileWrapper = nil;
if ([[templateFile pathExtension] isCaseInsensitiveEqual:@"rtfd"]) {
- NSString *templatePath = [self pathForTemplateFile:templateFile];
+ NSString *templatePath = [[self class]
pathForTemplateFile:templateFile];
NSDictionary *docAttributes = nil;
NSAttributedString *templateAttrString = [[NSAttributedString alloc]
initWithPath:templatePath documentAttributes:&docAttributes];
NSAttributedString *attrString = [SKTemplateParser
attributedStringByParsingTemplateAttributedString:templateAttrString
usingObject:self];
Modified: trunk/SKFormatCommand.m
===================================================================
--- trunk/SKFormatCommand.m 2011-08-18 16:46:29 UTC (rev 7433)
+++ trunk/SKFormatCommand.m 2011-08-19 10:10:53 UTC (rev 7434)
@@ -39,6 +39,7 @@
#import "SKFormatCommand.h"
#import "SKTemplateParser.h"
#import "SKRichTextFormat.h"
+#import "NSDocument_SKExtensions.h"
@implementation SKFormatCommand
@@ -61,7 +62,7 @@
attrString = template;
else if ([template isKindOfClass:[NSURL class]] == NO)
[self setScriptErrorNumber:NSArgumentsWrongScriptError];
- else if ([[NSSet setWithObjects:@"rtf", @"doc", @"docx", @"odt",
@"webarchive", @"rtfd", nil] containsObject:[[[template path] pathExtension]
lowercaseString]])
+ else if ([NSDocument isRichTextTemplate:[template path]])
attrString = [[[NSAttributedString alloc] initWithURL:template
documentAttributes:&docAttrs] autorelease];
else
string = [NSString stringWithContentsOfURL:template
encoding:NSUTF8StringEncoding error:NULL];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit