Revision: 7398
http://skim-app.svn.sourceforge.net/skim-app/?rev=7398&view=rev
Author: hofman
Date: 2011-07-27 00:08:05 +0000 (Wed, 27 Jul 2011)
Log Message:
-----------
Don't implement NSCopying in PDFBorder and PDFAnnotation, because that may
interfere with Lion's NSCopying implementation. Implement scripting duplicate
for notes explicitly.
Modified Paths:
--------------
trunk/PDFAnnotation_SKExtensions.m
trunk/PDFBorder_SKExtensions.h
trunk/PDFBorder_SKExtensions.m
trunk/PDFPage_SKExtensions.m
trunk/SKMainDocument.m
Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m 2011-07-26 23:34:43 UTC (rev 7397)
+++ trunk/PDFAnnotation_SKExtensions.m 2011-07-27 00:08:05 UTC (rev 7398)
@@ -46,7 +46,6 @@
#import "PDFAnnotationInk_SKExtensions.h"
#import <SkimNotes/SkimNotes.h>
#import "SKNPDFAnnotationNote_SKExtensions.h"
-#import "PDFBorder_SKExtensions.h"
#import "SKStringConstants.h"
#import "SKFDFParser.h"
#import "PDFPage_SKExtensions.h"
@@ -140,9 +139,14 @@
- (void)setBorderStyle:(PDFBorderStyle)style {
if ([self isEditable]) {
- PDFBorder *border = [[self border] copyWithZone:[self zone]];
- if (border == nil && style)
+ PDFBorder *oldBorder = [self border];
+ PDFBorder *border = nil;
+ if (oldBorder || style)
border = [[PDFBorder allocWithZone:[self zone]] init];
+ if (oldBorder) {
+ [border setLineWidth:[oldBorder lineWidth]];
+ [border setDashPattern:[oldBorder dashPattern]];
+ }
[border setStyle:style];
[self setBorder:border];
[border release];
@@ -157,9 +161,12 @@
if ([self isEditable]) {
PDFBorder *border = nil;
if (width > 0.0) {
- border = [[self border] copyWithZone:[self zone]];
- if (border == nil)
- border = [[PDFBorder allocWithZone:[self zone]] init];
+ PDFBorder *oldBorder = [self border];
+ border = [[PDFBorder allocWithZone:[self zone]] init];
+ if (oldBorder) {
+ [border setDashPattern:[oldBorder dashPattern]];
+ [border setStyle:[oldBorder style]];
+ }
[border setLineWidth:width];
}
[self setBorder:border];
@@ -173,9 +180,14 @@
- (void)setDashPattern:(NSArray *)pattern {
if ([self isEditable]) {
- PDFBorder *border = [[self border] copyWithZone:[self zone]];
- if (border == nil && [pattern count])
+ PDFBorder *oldBorder = [self border];
+ PDFBorder *border = nil;
+ if (oldBorder || [pattern count])
border = [[PDFBorder allocWithZone:[self zone]] init];
+ if (oldBorder) {
+ [border setLineWidth:[oldBorder lineWidth]];
+ [border setStyle:[oldBorder style]];
+ }
[border setDashPattern:pattern];
[self setBorder:border];
[border release];
@@ -247,16 +259,6 @@
}
}
-// to support the 'duplicate' command
-- (id)copyWithZone:(NSZone *)zone {
- PDFAnnotation *copy = nil;
- if ([self isMovable]) { // we don't want to duplicate markup
- copy = [[PDFAnnotation allocWithZone:zone]
initSkimNoteWithProperties:[self SkimNoteProperties]];
- [copy registerUserName];
- }
- return copy;
-}
-
// overridden by subclasses to add or remove custom scripting keys relevant
for the class, subclasses should call super first
+ (NSSet *)customScriptingKeys {
static NSSet *customScriptingKeys = nil;
Modified: trunk/PDFBorder_SKExtensions.h
===================================================================
--- trunk/PDFBorder_SKExtensions.h 2011-07-26 23:34:43 UTC (rev 7397)
+++ trunk/PDFBorder_SKExtensions.h 2011-07-27 00:08:05 UTC (rev 7398)
@@ -40,5 +40,5 @@
#import <Quartz/Quartz.h>
-@interface PDFBorder (SKExtensions) <NSCopying>
+@interface PDFBorder (SKExtensions)
@end
Modified: trunk/PDFBorder_SKExtensions.m
===================================================================
--- trunk/PDFBorder_SKExtensions.m 2011-07-26 23:34:43 UTC (rev 7397)
+++ trunk/PDFBorder_SKExtensions.m 2011-07-27 00:08:05 UTC (rev 7398)
@@ -55,14 +55,6 @@
@implementation PDFBorder (SKExtensions)
-- (id)copyWithZone:(NSZone *)aZone {
- PDFBorder *copy = [[PDFBorder allocWithZone:aZone] init];
- [copy setLineWidth:[self lineWidth]];
- [copy setDashPattern:[[[self dashPattern] copyWithZone:aZone]
autorelease]];
- [copy setStyle:[self style]];
- return copy;
-}
-
#if __LP64__
static id (*original_dashPattern)(id, SEL) = NULL;
Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m 2011-07-26 23:34:43 UTC (rev 7397)
+++ trunk/PDFPage_SKExtensions.m 2011-07-27 00:08:05 UTC (rev 7398)
@@ -567,6 +567,31 @@
return [super newScriptingObjectOfClass:class forValueForKey:key
withContentsValue:contentsValue properties:properties];
}
+- (id)copyScriptingValue:(id)value forKey:(NSString *)key
withProperties:(NSDictionary *)properties {
+ if ([key isEqualToString:@"notes"]) {
+ NSMutableArray *copiedValue = [[NSMutableArray alloc] init];
+ for (PDFAnnotation *annotation in value) {
+ if ([annotation isMovable]) { // we don't want to duplicate markup
+ PDFAnnotation *copiedAnnotation = [[PDFAnnotation alloc]
initSkimNoteWithProperties:[annotation SkimNoteProperties]];
+ [copiedAnnotation registerUserName];
+ if ([properties count]) {
+ NSMutableDictionary *validProps = [NSMutableDictionary
dictionary];
+ NSScriptClassDescription *classDesc =
[NSScriptClassDescription classDescriptionForClass:[copiedAnnotation class]];
+ for (NSString *aKey in properties) {
+ if ([classDesc hasWritablePropertyForKey:aKey])
+ [validProps setValue:[copiedAnnotation
coerceValue:[properties objectForKey:aKey] forKey:aKey] forKey:aKey];
+ }
+ if ([validProps count])
+ [copiedAnnotation setScriptingProperties:validProps];
+ }
+ [copiedValue addObject:copiedAnnotation];
+ }
+ }
+ return copiedValue;
+ }
+ return [super copyScriptingValue:value forKey:key
withProperties:properties];
+}
+
- (id)handleGrabScriptCommand:(NSScriptCommand *)command {
NSDictionary *args = [command evaluatedArguments];
NSData *boundsData = [args objectForKey:@"Bounds"];
Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m 2011-07-26 23:34:43 UTC (rev 7397)
+++ trunk/SKMainDocument.m 2011-07-27 00:08:05 UTC (rev 7398)
@@ -1821,6 +1821,33 @@
return [super newScriptingObjectOfClass:class forValueForKey:key
withContentsValue:contentsValue properties:properties];
}
+- (id)copyScriptingValue:(id)value forKey:(NSString *)key
withProperties:(NSDictionary *)properties {
+ if ([key isEqualToString:@"notes"]) {
+ NSMutableArray *copiedValue = [[NSMutableArray alloc] init];
+ for (PDFAnnotation *annotation in value) {
+ if ([annotation isMovable]) { // we don't want to duplicate markup
+ PDFAnnotation *copiedAnnotation = [[PDFAnnotation alloc]
initSkimNoteWithProperties:[annotation SkimNoteProperties]];
+ [copiedAnnotation registerUserName];
+ if ([copiedAnnotation respondsToSelector:@selector(setPage:)])
+ [copiedAnnotation performSelector:@selector(setPage:)
withObject:[annotation page]];
+ if ([properties count]) {
+ NSMutableDictionary *validProps = [NSMutableDictionary
dictionary];
+ NSScriptClassDescription *classDesc =
[NSScriptClassDescription classDescriptionForClass:[copiedAnnotation class]];
+ for (NSString *aKey in properties) {
+ if ([classDesc hasWritablePropertyForKey:aKey])
+ [validProps setValue:[copiedAnnotation
coerceValue:[properties objectForKey:aKey] forKey:aKey] forKey:aKey];
+ }
+ if ([validProps count])
+ [copiedAnnotation setScriptingProperties:validProps];
+ }
+ [copiedValue addObject:copiedAnnotation];
+ }
+ }
+ return copiedValue;
+ }
+ return [super copyScriptingValue:value forKey:key
withProperties:properties];
+}
+
- (id)handleSaveScriptCommand:(NSScriptCommand *)command {
NSDictionary *args = [command evaluatedArguments];
id fileType = [args objectForKey:@"FileType"];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit