Revision: 5935
http://skim-app.svn.sourceforge.net/skim-app/?rev=5935&view=rev
Author: hofman
Date: 2009-10-22 17:31:55 +0000 (Thu, 22 Oct 2009)
Log Message:
-----------
Coerce scripting properties for new notes in one call and let the frameworks
figure it out further. Remove only the read-only keys we use for creation so we
can get meaningful error messages.
Modified Paths:
--------------
trunk/PDFPage_SKExtensions.m
Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m 2009-10-22 17:08:12 UTC (rev 5934)
+++ trunk/PDFPage_SKExtensions.m 2009-10-22 17:31:55 UTC (rev 5935)
@@ -461,12 +461,14 @@
- (id)newScriptingObjectOfClass:(Class)class forValueForKey:(NSString *)key
withContentsValue:(id)contentsValue properties:(NSDictionary *)properties {
if ([key isEqualToString:@"notes"]) {
PDFAnnotation *annotation = nil;
+ NSMutableDictionary *props = [[properties mutableCopy] autorelease];
NSRect bounds = NSMakeRect(100.0, 100.0, 0.0, 0.0);
bounds.size.width = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteWidthKey];
bounds.size.height = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteHeightKey];
FourCharCode type = [[properties
objectForKey:SKPDFAnnotationScriptingNoteTypeKey] unsignedLongValue];
+ [props removeObjectForKey:SKPDFAnnotationScriptingNoteTypeKey];
if (type == 0) {
[[NSScriptCommand currentCommand]
setScriptErrorNumber:NSRequiredArgumentsMissingScriptError];
@@ -475,7 +477,7 @@
id selSpec = [properties
objectForKey:SKPDFAnnotationSelectionSpecifierKey];
PDFSelection *selection;
NSInteger markupType = 0;
-
+ [props removeObjectForKey:SKPDFAnnotationSelectionSpecifierKey];
if (selSpec == nil) {
[[NSScriptCommand currentCommand]
setScriptErrorNumber:NSRequiredArgumentsMissingScriptError];
[[NSScriptCommand currentCommand]
setScriptErrorString:NSLocalizedString(@"New markup notes need a selection.",
@"Error description")];
@@ -490,6 +492,7 @@
}
} else if (type == SKScriptingInkNote) {
NSArray *pointLists = [properties
objectForKey:SKPDFAnnotationScriptingPointListsKey];
+ [props removeObjectForKey:SKPDFAnnotationScriptingPointListsKey];
if ([pointLists isKindOfClass:[NSArray class]] == NO) {
[[NSScriptCommand currentCommand]
setScriptErrorNumber:NSRequiredArgumentsMissingScriptError];
[[NSScriptCommand currentCommand]
setScriptErrorString:NSLocalizedString(@"New markup notes need a selection.",
@"Error description")];
@@ -534,20 +537,13 @@
annotation = [[PDFAnnotationLine alloc]
initSkimNoteWithBounds:bounds];
}
if (annotation) {
- NSMutableDictionary *validProps = [NSMutableDictionary dictionary];
- NSScriptClassDescription *classDesc = [NSScriptClassDescription
classDescriptionForClass:class];
-
if (contentsValue) {
- NSString *contentsKey = [classDesc
defaultSubcontainerAttributeKey];
- if (contentsKey)
- [validProps setObject:[annotation
coerceValue:contentsValue forKey:contentsKey] forKey:contentsKey];
+ NSString *contentsKey = [[NSScriptClassDescription
classDescriptionForClass:class] defaultSubcontainerAttributeKey];
+ if (contentsKey && [props objectForKey:contentsKey] == nil)
+ [props setObject:contentsValue forKey:contentsKey];
}
- for (NSString *aKey in properties) {
- if ([classDesc hasWritablePropertyForKey:aKey])
- [validProps setValue:[annotation coerceValue:[properties
objectForKey:aKey] forKey:aKey] forKey:aKey];
- }
- if ([validProps count])
- [annotation setScriptingProperties:validProps];
+ if ([props count])
+ [annotation setScriptingProperties:[annotation
coerceValue:props forKey:@"scriptingProperties"]];
}
return annotation;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit