Revision: 7463
http://skim-app.svn.sourceforge.net/skim-app/?rev=7463&view=rev
Author: hofman
Date: 2011-08-31 11:08:58 +0000 (Wed, 31 Aug 2011)
Log Message:
-----------
convenience method to avoid code duplication
Modified Paths:
--------------
trunk/SKMainDocument.m
trunk/SKNotesDocument.m
trunk/SKTemplateManager.h
trunk/SKTemplateManager.m
Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m 2011-08-31 09:59:04 UTC (rev 7462)
+++ trunk/SKMainDocument.m 2011-08-31 11:08:58 UTC (rev 7463)
@@ -1837,15 +1837,8 @@
normalizedType = SKDVIDocumentType;
else if ([fileType isEqualToString:@"XDV"])
normalizedType = SKXDVDocumentType;
- else if ([[self writableTypesForSaveOperation:NSSaveToOperation]
containsObject:fileType] == NO) {
- SKTemplateManager *tm = [SKTemplateManager sharedManager];
- for (NSString *typeName in [tm customTemplateTypes]) {
- if ([[tm displayNameForTemplateType:fileType]
isEqualToString:fileType]) {
- normalizedType = typeName;
- break;
- }
- }
- }
+ else if ([[self writableTypesForSaveOperation:NSSaveToOperation]
containsObject:fileType] == NO)
+ normalizedType = [[SKTemplateManager sharedManager]
templateTypeForDisplayName:fileType];
if (normalizedType) {
fileType = normalizedType;
NSMutableDictionary *arguments = [[command arguments] mutableCopy];
Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m 2011-08-31 09:59:04 UTC (rev 7462)
+++ trunk/SKNotesDocument.m 2011-08-31 11:08:58 UTC (rev 7463)
@@ -825,18 +825,13 @@
NSDictionary *args = [command evaluatedArguments];
id fileType = [args objectForKey:@"FileType"];
// we allow template file names without extension
- if (fileType) {
- if ([[self writableTypesForSaveOperation:NSSaveToOperation]
containsObject:fileType] == NO) {
- SKTemplateManager *tm = [SKTemplateManager sharedManager];
- for (NSString *typeName in [tm customTemplateTypes]) {
- if ([[tm displayNameForTemplateType:fileType]
isEqualToString:fileType]) {
- NSMutableDictionary *arguments = [[command arguments]
mutableCopy];
- [arguments setObject:typeName forKey:@"FileType"];
- [command setArguments:arguments];
- [arguments release];
- break;
- }
- }
+ if (fileType && [[self writableTypesForSaveOperation:NSSaveToOperation]
containsObject:fileType] == NO) {
+ NSString *normalizedType = [[SKTemplateManager sharedManager]
templateTypeForDisplayName:fileType];
+ if (normalizedType) {
+ NSMutableDictionary *arguments = [[command arguments] mutableCopy];
+ [arguments setObject:normalizedType forKey:@"FileType"];
+ [command setArguments:arguments];
+ [arguments release];
}
}
return [super handleSaveScriptCommand:command];
Modified: trunk/SKTemplateManager.h
===================================================================
--- trunk/SKTemplateManager.h 2011-08-31 09:59:04 UTC (rev 7462)
+++ trunk/SKTemplateManager.h 2011-08-31 11:08:58 UTC (rev 7463)
@@ -51,6 +51,7 @@
- (NSString *)pathForTemplateType:(NSString *)typeName;
- (NSString *)fileNameExtensionForTemplateType:(NSString *)typeName;
- (NSString *)displayNameForTemplateType:(NSString *)typeName;
+- (NSString *)templateTypeForDisplayName:(NSString *)name;
- (BOOL)isRichTextTemplateType:(NSString *)typeName;
Modified: trunk/SKTemplateManager.m
===================================================================
--- trunk/SKTemplateManager.m 2011-08-31 09:59:04 UTC (rev 7462)
+++ trunk/SKTemplateManager.m 2011-08-31 11:08:58 UTC (rev 7463)
@@ -103,6 +103,14 @@
return [[self customTemplateTypes] containsObject:typeName] ? [typeName
stringByDeletingPathExtension] : nil;
}
+- (NSString *)templateTypeForDisplayName:(NSString *)name {
+ for (NSString *typeName in [self customTemplateTypes]) {
+ if ([[self displayNameForTemplateType:typeName] isEqualToString:name])
+ return typeName;
+ }
+ return nil;
+}
+
- (BOOL)isRichTextTemplateType:(NSString *)isRichTextTemplateFile {
static NSSet *types = nil;
if (types == nil)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit