Revision: 5091
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5091&view=rev
Author:   hofman
Date:     2008-12-26 16:14:44 +0000 (Fri, 26 Dec 2008)

Log Message:
-----------
Add a script command to get rich text as RTF data, in case anyone wants to put 
it on the clipboard using scripting

Modified Paths:
--------------
    trunk/Skim.sdef
    trunk/Skim.xcodeproj/project.pbxproj

Added Paths:
-----------
    trunk/SKRTFCommand.h
    trunk/SKRTFCommand.m

Added: trunk/SKRTFCommand.h
===================================================================
--- trunk/SKRTFCommand.h                                (rev 0)
+++ trunk/SKRTFCommand.h        2008-12-26 16:14:44 UTC (rev 5091)
@@ -0,0 +1,43 @@
+//
+//  SKRTFCommand.h
+//  Skim
+//
+//  Created by Christiaan Hofman on 12/26/08.
+/*
+ This software is Copyright (c) 2008
+ 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 SKRTFCommand : NSScriptCommand
+...@end

Added: trunk/SKRTFCommand.m
===================================================================
--- trunk/SKRTFCommand.m                                (rev 0)
+++ trunk/SKRTFCommand.m        2008-12-26 16:14:44 UTC (rev 5091)
@@ -0,0 +1,77 @@
+//
+//  SKRTFCommand.m
+//  Skim
+//
+//  Created by Christiaan Hofman on 12/26/08.
+/*
+ This software is Copyright (c) 2008
+ 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 "SKRTFCommand.h"
+#import <Quartz/Quartz.h>
+#import "SKPDFDocument.h"
+#import "PDFAnnotation_SKExtensions.h"
+#import "PDFSelection_SKExtensions.h"
+
+
+...@implementation SKRTFCommand
+
+- (id)performDefaultImplementation {
+    id dP = [self directParameter];
+    id dPO = nil;
+    if ([dP isKindOfClass:[NSArray class]] == NO)
+        dPO = [dP objectsByEvaluatingSpecifier];
+    
+    NSDictionary *args = [self evaluatedArguments];
+    PDFPage *page = [args objectForKey:@"Page"];
+    NSAttributedString *attrString = nil;
+    NSData *data;
+    
+    if ([dPO isKindOfClass:[SKPDFDocument class]]) {
+        attrString = page ? [page attributedString] : [[[dPO pdfDocument] 
selectionForEntireDocument] attributedString];
+    } else if ([dPO isKindOfClass:[PDFPage class]]) {
+        if (page == nil || [page isEqual:dPO])
+            attrString = [dPO attributedString];
+    } else if ([dPO isKindOfClass:[PDFAnnotation class]]) {
+        if (page == nil || [page isEqual:[dPO page]])
+            attrString = [dPO textContents];
+    } else {
+        attrString = [[PDFSelection selectionWithSpecifier:dP onPage:page] 
attributedString];
+    }
+    
+    if (attrString == nil)
+        attrString = [[[NSAttributedString alloc] init] autorelease];
+    data = [attrString RTFFromRange:NSMakeRange(0, [attrString length]) 
documentAttributes:NULL];
+    return [NSAppleEventDescriptor descriptorWithDescriptorType:'RTF ' 
data:data];
+}
+
+...@end

Modified: trunk/Skim.sdef
===================================================================
--- trunk/Skim.sdef     2008-12-26 11:41:31 UTC (rev 5090)
+++ trunk/Skim.sdef     2008-12-26 16:14:44 UTC (rev 5091)
@@ -675,6 +675,10 @@
                 description="The text of the note. Attributes are ignored.">
                 <cocoa key="textContents"/>
             </contents>
+            <property name="RTF" code="RTF " type="any" access="r"
+                description="The RTF text for the note.">
+                <cocoa key="RTFContents"/>
+            </property>
             <property name="color" code="colr" type="RGBA color"
                 description="The color of the note. Can be given as a list of 
(red, green, blue, alpha), a standard color (e.g. red), or a default color 
(e.g. text note color).">
                 <cocoa key="color"/>
@@ -1293,6 +1297,25 @@
                 description="The text of the object."/>
         </command>
 
+        <command name="get RTF for" code="SKIMRTFt"
+            description="Get RTF data for the text of a document, page, note, 
or selection.">
+            <synonym name="RTF for"/>
+            <cocoa class="SKRTFCommand"/>
+            <direct-parameter
+                description="The document, page, note or selection.">
+                <type type="document"/>
+                <type type="page"/>
+                <type type="note"/>
+                <type type="specifier" list="yes"/>
+            </direct-parameter>
+            <parameter name="on" type="page" code="on  " optional="yes"
+                description="The page on which to get the text.">
+                <cocoa key="Page"/>
+            </parameter>
+            <result type="any"
+                description="RTF data for the text of the object."/>
+        </command>
+
         <command name="get index for" code="SKIMIndx"
             description="Get the index of a document, page, note, or 
selection.">
             <cocoa class="SKIndexCommand"/>

Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj        2008-12-26 11:41:31 UTC (rev 
5090)
+++ trunk/Skim.xcodeproj/project.pbxproj        2008-12-26 16:14:44 UTC (rev 
5091)
@@ -115,6 +115,7 @@
                CE4EC87F0B7E6E110091F228 /* NSBezierPath_CoreImageExtensions.m 
in Sources */ = {isa = PBXBuildFile; fileRef = CE4EC87E0B7E6E110091F228 /* 
NSBezierPath_CoreImageExtensions.m */; };
                CE4EC8830B7E6E920091F228 /* CIImage_BDSKExtensions.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = CE4EC8820B7E6E920091F228 /* 
CIImage_BDSKExtensions.m */; };
                CE4EC88C0B7E6EDB0091F228 /* SKSplitView.m in Sources */ = {isa 
= PBXBuildFile; fileRef = CE4EC88B0B7E6EDB0091F228 /* SKSplitView.m */; };
+               CE4EDE3A0F0538B700447C6A /* SKRTFCommand.m in Sources */ = {isa 
= PBXBuildFile; fileRef = CE4EDE390F0538B700447C6A /* SKRTFCommand.m */; };
                CE4F9DEE0BC1BE3A005BE0A1 /* Localizable.strings in Resources */ 
= {isa = PBXBuildFile; fileRef = CE4F9DEC0BC1BE3A005BE0A1 /* 
Localizable.strings */; };
                CE51630B0EAB5A1A009FA237 /* SKSegmentedControl.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CE5163090EAB5A1A009FA237 /* 
SKSegmentedControl.m */; };
                CE5163380EAB5EE2009FA237 /* Segment_Cap.tiff in Resources */ = 
{isa = PBXBuildFile; fileRef = CE51632C0EAB5EE2009FA237 /* Segment_Cap.tiff */; 
};
@@ -607,6 +608,8 @@
                CE4EC8820B7E6E920091F228 /* CIImage_BDSKExtensions.m */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; 
path = CIImage_BDSKExtensions.m; sourceTree = "<group>"; };
                CE4EC88A0B7E6EDB0091F228 /* SKSplitView.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKSplitView.h; sourceTree = "<group>"; };
                CE4EC88B0B7E6EDB0091F228 /* SKSplitView.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKSplitView.m; sourceTree = "<group>"; };
+               CE4EDE380F0538B700447C6A /* SKRTFCommand.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKRTFCommand.h; sourceTree = "<group>"; };
+               CE4EDE390F0538B700447C6A /* SKRTFCommand.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKRTFCommand.m; sourceTree = "<group>"; };
                CE4F96AE0CFB49B100DBEA14 /* ru */ = {isa = PBXFileReference; 
lastKnownFileType = wrapper.nib; name = ru; path = ru.lproj/InfoWindow.nib; 
sourceTree = "<group>"; };
                CE4F96B20CFB49C200DBEA14 /* ru */ = {isa = PBXFileReference; 
lastKnownFileType = wrapper.nib; name = ru; path = ru.lproj/MainMenu.nib; 
sourceTree = "<group>"; };
                CE4F96B80CFB49D700DBEA14 /* ru */ = {isa = PBXFileReference; 
lastKnownFileType = wrapper.nib; name = ru; path = ru.lproj/NoteWindow.nib; 
sourceTree = "<group>"; };
@@ -1427,6 +1430,8 @@
                                CE4643CE0DF6B5A400CFD8D2 /* SKJoinCommand.m */,
                                CE4643D30DF6B60500CFD8D2 /* SKPagesCommand.h */,
                                CE4643D40DF6B60500CFD8D2 /* SKPagesCommand.m */,
+                               CE4EDE380F0538B700447C6A /* SKRTFCommand.h */,
+                               CE4EDE390F0538B700447C6A /* SKRTFCommand.m */,
                                CE4643D60DF6B63500CFD8D2 /* SKTextCommand.h */,
                                CE4643D70DF6B63500CFD8D2 /* SKTextCommand.m */,
                        );
@@ -2146,6 +2151,7 @@
                                CED6A3120EADF37800E8CD11 /* 
NSImageCell_SKExtensions.m in Sources */,
                                CEE0F5EB0EBB3DEC000A7A8C /* 
SKLevelIndicatorCell.m in Sources */,
                                CE0A3C8E0EBF3AAA00526C74 /* 
NSResponder_SKExtensions.m in Sources */,
+                               CE4EDE3A0F0538B700447C6A /* SKRTFCommand.m in 
Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to