Revision: 6890
http://skim-app.svn.sourceforge.net/skim-app/?rev=6890&view=rev
Author: hofman
Date: 2010-11-26 13:00:48 +0000 (Fri, 26 Nov 2010)
Log Message:
-----------
Workaround for Cocoa Scripting and AppleScript bug. Fix range specifiers in our
scripting commands before they are evaluated, because Cocoa Scripting raises an
error one those when they have absolute containers, while AppleScript breaks on
range specifiers with relative containers.
Modified Paths:
--------------
trunk/SKBoundsCommand.h
trunk/SKIndexCommand.h
trunk/SKJoinCommand.h
trunk/SKPagesCommand.h
trunk/SKTextCommand.h
trunk/Skim.xcodeproj/project.pbxproj
Added Paths:
-----------
trunk/SKScriptCommand.h
trunk/SKScriptCommand.m
Modified: trunk/SKBoundsCommand.h
===================================================================
--- trunk/SKBoundsCommand.h 2010-11-26 11:19:09 UTC (rev 6889)
+++ trunk/SKBoundsCommand.h 2010-11-26 13:00:48 UTC (rev 6890)
@@ -37,7 +37,8 @@
*/
#import <Cocoa/Cocoa.h>
+#import "SKScriptCommand.h"
-...@interface SKBoundsCommand : NSScriptCommand
+...@interface SKBoundsCommand : SKScriptCommand
@end
Modified: trunk/SKIndexCommand.h
===================================================================
--- trunk/SKIndexCommand.h 2010-11-26 11:19:09 UTC (rev 6889)
+++ trunk/SKIndexCommand.h 2010-11-26 13:00:48 UTC (rev 6890)
@@ -37,7 +37,8 @@
*/
#import <Cocoa/Cocoa.h>
+#import "SKScriptCommand.h"
-...@interface SKIndexCommand : NSScriptCommand
+...@interface SKIndexCommand : SKScriptCommand
@end
Modified: trunk/SKJoinCommand.h
===================================================================
--- trunk/SKJoinCommand.h 2010-11-26 11:19:09 UTC (rev 6889)
+++ trunk/SKJoinCommand.h 2010-11-26 13:00:48 UTC (rev 6890)
@@ -37,7 +37,8 @@
*/
#import <Cocoa/Cocoa.h>
+#import "SKScriptCommand.h"
-...@interface SKJoinCommand : NSScriptCommand
+...@interface SKJoinCommand : SKScriptCommand
@end
Modified: trunk/SKPagesCommand.h
===================================================================
--- trunk/SKPagesCommand.h 2010-11-26 11:19:09 UTC (rev 6889)
+++ trunk/SKPagesCommand.h 2010-11-26 13:00:48 UTC (rev 6890)
@@ -37,7 +37,8 @@
*/
#import <Cocoa/Cocoa.h>
+#import "SKScriptCommand.h"
-...@interface SKPagesCommand : NSScriptCommand
+...@interface SKPagesCommand : SKScriptCommand
@end
Added: trunk/SKScriptCommand.h
===================================================================
--- trunk/SKScriptCommand.h (rev 0)
+++ trunk/SKScriptCommand.h 2010-11-26 13:00:48 UTC (rev 6890)
@@ -0,0 +1,43 @@
+//
+// SKScriptCommand.h
+// Skim
+//
+// Created by Christiaan Hofman on 11/26/10.
+/*
+ This software is Copyright (c) 2008-2010
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
+...@interface SKScriptCommand : NSScriptCommand
+...@end
Added: trunk/SKScriptCommand.m
===================================================================
--- trunk/SKScriptCommand.m (rev 0)
+++ trunk/SKScriptCommand.m 2010-11-26 13:00:48 UTC (rev 6890)
@@ -0,0 +1,74 @@
+//
+// SKScriptCommand.m
+// Skim
+//
+// Created by Christiaan Hofman on 11/26/10.
+/*
+ This software is Copyright (c) 2008-2010
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "SKScriptCommand.h"
+
+
+...@implementation SKScriptCommand
+
+// Workaround for Cocoa Scripting and AppleScript bugs.
+// Cocoa Scripting does not accept range specifiers whose start/end specifier
have an absolute container specifier, but AppleScript does not accept range
specifiers with relative container specifiers, so we cannot return those from
PDFSselection
+static void fixRangeSpecifier(NSScriptObjectSpecifier *specifier) {
+ if ([specifier isKindOfClass:[NSRangeSpecifier class]]) {
+ NSScriptObjectSpecifier *childSpec = [(NSRangeSpecifier *)specifier
startSpecifier];
+ if ([childSpec containerSpecifier]) {
+ [childSpec setContainerSpecifier:nil];
+ [childSpec setContainerIsRangeContainerObject:YES];
+ }
+ childSpec = [(NSRangeSpecifier *)specifier endSpecifier];
+ if ([childSpec containerSpecifier]) {
+ [childSpec setContainerSpecifier:nil];
+ [childSpec setContainerIsRangeContainerObject:YES];
+ }
+ }
+}
+
+- (NSScriptObjectSpecifier *)receiversSpecifier {
+ NSScriptObjectSpecifier *specifier = [super receiversSpecifier];
+ fixRangeSpecifier(specifier);
+ return specifier;
+}
+
+- (NSDictionary *)arguments {
+ NSDictionary *arguments = [super arguments];
+ for (NSString *key in arguments)
+ fixRangeSpecifier([arguments objectForKey:key]);
+ return arguments;
+}
+
+...@end
Modified: trunk/SKTextCommand.h
===================================================================
--- trunk/SKTextCommand.h 2010-11-26 11:19:09 UTC (rev 6889)
+++ trunk/SKTextCommand.h 2010-11-26 13:00:48 UTC (rev 6890)
@@ -37,7 +37,8 @@
*/
#import <Cocoa/Cocoa.h>
+#import "SKScriptCommand.h"
-...@interface SKTextCommand : NSScriptCommand
+...@interface SKTextCommand : SKScriptCommand
@end
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2010-11-26 11:19:09 UTC (rev
6889)
+++ trunk/Skim.xcodeproj/project.pbxproj 2010-11-26 13:00:48 UTC (rev
6890)
@@ -86,6 +86,7 @@
CE1CC5BE1143C57300F6B208 /* NoteWindow.xib in Resources */ =
{isa = PBXBuildFile; fileRef = CE1CC5BD1143C57300F6B208 /* NoteWindow.xib */; };
CE1CC6121143DDFD00F6B208 /* LineInspector.xib in Resources */ =
{isa = PBXBuildFile; fileRef = CE1CC6111143DDFD00F6B208 /* LineInspector.xib
*/; };
CE1CC6B91143F05D00F6B208 /* TransitionSheet.xib in Resources */
= {isa = PBXBuildFile; fileRef = CE1CC6B81143F05D00F6B208 /*
TransitionSheet.xib */; };
+ CE1D798F129FE44E00EA3AF0 /* SKScriptCommand.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE1D798E129FE44E00EA3AF0 /* SKScriptCommand.m
*/; };
CE1E2B290BDAB6180011D9DD /* SKPDFSynchronizer.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE1E2B270BDAB6180011D9DD /* SKPDFSynchronizer.m
*/; };
CE1E301D0BDB9D5C0011D9DD /* NSScanner_SKExtensions.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CE1E301B0BDB9D5C0011D9DD /*
NSScanner_SKExtensions.m */; };
CE1E30290BDB9D8E0011D9DD /* NSCharacterSet_SKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CE1E30270BDB9D8E0011D9DD /*
NSCharacterSet_SKExtensions.m */; };
@@ -614,6 +615,8 @@
CE1CC5BD1143C57300F6B208 /* NoteWindow.xib */ = {isa =
PBXFileReference; lastKnownFileType = file.xib; path = NoteWindow.xib;
sourceTree = "<group>"; };
CE1CC6111143DDFD00F6B208 /* LineInspector.xib */ = {isa =
PBXFileReference; lastKnownFileType = file.xib; path = LineInspector.xib;
sourceTree = "<group>"; };
CE1CC6B81143F05D00F6B208 /* TransitionSheet.xib */ = {isa =
PBXFileReference; lastKnownFileType = file.xib; path = TransitionSheet.xib;
sourceTree = "<group>"; };
+ CE1D798D129FE44E00EA3AF0 /* SKScriptCommand.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKScriptCommand.h; sourceTree = "<group>"; };
+ CE1D798E129FE44E00EA3AF0 /* SKScriptCommand.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKScriptCommand.m; sourceTree = "<group>"; };
CE1E2B260BDAB6180011D9DD /* SKPDFSynchronizer.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKPDFSynchronizer.h; sourceTree = "<group>"; };
CE1E2B270BDAB6180011D9DD /* SKPDFSynchronizer.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKPDFSynchronizer.m; sourceTree = "<group>"; };
CE1E2F120BDB86A10011D9DD /* displayline */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path =
displayline; sourceTree = "<group>"; };
@@ -1816,6 +1819,8 @@
CE4643CE0DF6B5A400CFD8D2 /* SKJoinCommand.m */,
CE4643D30DF6B60500CFD8D2 /* SKPagesCommand.h */,
CE4643D40DF6B60500CFD8D2 /* SKPagesCommand.m */,
+ CE1D798D129FE44E00EA3AF0 /* SKScriptCommand.h
*/,
+ CE1D798E129FE44E00EA3AF0 /* SKScriptCommand.m
*/,
CE4643D60DF6B63500CFD8D2 /* SKTextCommand.h */,
CE4643D70DF6B63500CFD8D2 /* SKTextCommand.m */,
);
@@ -2610,6 +2615,7 @@
CEFDEA9111F6FF8300D6FEBA /*
NSScreen_SKExtensions.m in Sources */,
CE1C77B6123FB41E00C73F1A /* SKNoteTextView.m in
Sources */,
CE94D17B125535DE0053A520 /*
synctex_parser_utils.m in Sources */,
+ CE1D798F129FE44E00EA3AF0 /* SKScriptCommand.m
in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit