Revision: 5151
http://skim-app.svn.sourceforge.net/skim-app/?rev=5151&view=rev
Author: hofman
Date: 2009-01-21 19:23:55 +0000 (Wed, 21 Jan 2009)
Log Message:
-----------
Change boolean parameter for grab command to generic type parameter. Introduce
value-type for data we use, and implement accessors. Implement setter for RTF
data of rich text.
Modified Paths:
--------------
trunk/NSAttributedString_SKExtensions.h
trunk/NSAttributedString_SKExtensions.m
trunk/NSData_SKExtensions.h
trunk/NSData_SKExtensions.m
trunk/PDFPage_SKExtensions.m
trunk/Skim.sdef
Modified: trunk/NSAttributedString_SKExtensions.h
===================================================================
--- trunk/NSAttributedString_SKExtensions.h 2009-01-21 15:56:26 UTC (rev
5150)
+++ trunk/NSAttributedString_SKExtensions.h 2009-01-21 19:23:55 UTC (rev
5151)
@@ -46,6 +46,12 @@
- (NSString *)xmlString;
- (NSData *)RTFRepresentation;
+...@end
+
+
+...@interface NSTextStorage (SKExtensions)
+
- (id)scriptingRTF;
+- (void)setScriptingRTF:(id)data;
@end
Modified: trunk/NSAttributedString_SKExtensions.m
===================================================================
--- trunk/NSAttributedString_SKExtensions.m 2009-01-21 15:56:26 UTC (rev
5150)
+++ trunk/NSAttributedString_SKExtensions.m 2009-01-21 19:23:55 UTC (rev
5151)
@@ -60,10 +60,22 @@
return [self RTFFromRange:NSMakeRange(0, [self length])
documentAttributes:nil];
}
+...@end
+
+
+...@implementation NSTextStorage (SKExtensions)
+
#pragma mark Scripting support
- (id)scriptingRTF {
- return [NSAppleEventDescriptor descriptorWithDescriptorType:'RTF '
data:[self RTFRepresentation]];
+ return [self RTFRepresentation];
}
+- (void)setScriptingRTF:(id)data {
+ NSError *error;
+ NSAttributedString *attrString = [[[NSAttributedString alloc]
initWithData:data options:[NSDictionary dictionary] documentAttributes:NULL
error:&error] autorelease];
+ if (attrString)
+ [self setAttributedString:attrString];
+}
+
@end
Modified: trunk/NSData_SKExtensions.h
===================================================================
--- trunk/NSData_SKExtensions.h 2009-01-21 15:56:26 UTC (rev 5150)
+++ trunk/NSData_SKExtensions.h 2009-01-21 19:23:55 UTC (rev 5151)
@@ -60,4 +60,11 @@
- (NSPoint)pointValueAsQDPoint;
- (NSRect)rectValueAsQDRect;
++ (id)scriptingRtfWithDescriptor:(NSAppleEventDescriptor *)descriptor;
+- (id)scriptingRtfDescriptor;
++ (id)scriptingPdfWithDescriptor:(NSAppleEventDescriptor *)descriptor;
+- (id)scriptingPdfDescriptor;
++ (id)scriptingTiffPictureWithDescriptor:(NSAppleEventDescriptor *)descriptor;
+- (id)scriptingTiffPictureDescriptor;
+
@end
Modified: trunk/NSData_SKExtensions.m
===================================================================
--- trunk/NSData_SKExtensions.m 2009-01-21 15:56:26 UTC (rev 5150)
+++ trunk/NSData_SKExtensions.m 2009-01-21 19:23:55 UTC (rev 5151)
@@ -240,4 +240,28 @@
return rect;
}
++ (id)scriptingRtfWithDescriptor:(NSAppleEventDescriptor *)descriptor {
+ return [descriptor data];
+}
+
+- (id)scriptingRtfDescriptor {
+ return [NSAppleEventDescriptor descriptorWithDescriptorType:'RTF '
data:self];
+}
+
++ (id)scriptingPdfWithDescriptor:(NSAppleEventDescriptor *)descriptor {
+ return [descriptor data];
+}
+
+- (id)scriptingPdfDescriptor {
+ return [NSAppleEventDescriptor descriptorWithDescriptorType:'PDF '
data:self];
+}
+
++ (id)scriptingTiffPictureWithDescriptor:(NSAppleEventDescriptor *)descriptor {
+ return [descriptor data];
+}
+
+- (id)scriptingTiffPictureDescriptor {
+ return [NSAppleEventDescriptor descriptorWithDescriptorType:'TIFF'
data:self];
+}
+
@end
Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m 2009-01-21 15:56:26 UTC (rev 5150)
+++ trunk/PDFPage_SKExtensions.m 2009-01-21 19:23:55 UTC (rev 5151)
@@ -556,12 +556,15 @@
NSDictionary *args = [command evaluatedArguments];
NSData *boundsData = [args objectForKey:@"Bounds"];
id asTIFFNumber = [args objectForKey:@"AsTIFF"];
+ id asTypeNumber = [args objectForKey:@"Type"];
NSRect bounds = [boundsData
respondsToSelector:@selector(rectValueAsQDRect)] ? [boundsData
rectValueAsQDRect] : NSZeroRect;
+ FourCharCode asType = [asTypeNumber
respondsToSelector:@selector(unsignedLongValue)] ? [asTypeNumber
unsignedLongValue] : 0;
BOOL asTIFF = [asTIFFNumber respondsToSelector:@selector(boolValue)] ?
[asTIFFNumber boolValue] : NO;
+
NSData *data = nil;
DescType type = 0;
- if (asTIFF) {
+ if (asTIFF || asType == 'TIFF') {
data = [self TIFFDataForRect:bounds];
type = 'TIFF';
} else {
Modified: trunk/Skim.sdef
===================================================================
--- trunk/Skim.sdef 2009-01-21 15:56:26 UTC (rev 5150)
+++ trunk/Skim.sdef 2009-01-21 19:23:55 UTC (rev 5151)
@@ -493,7 +493,7 @@
description="The size in points of the first character.">
<cocoa key="fontSize"/>
</property>
- <property name="RTF" code="RTF " type="any"
+ <property name="RTF" code="RTF " type="RTF"
description="The raw RTF data.">
<cocoa key="scriptingRTF"/>
</property>
@@ -520,7 +520,7 @@
description="The size in points of the first character.">
<cocoa key="fontSize"/>
</property>
- <property name="RTF" code="RTF " type="any"
+ <property name="RTF" code="RTF " type="RTF"
description="The raw RTF data.">
<cocoa key="scriptingRTF"/>
</property>
@@ -547,7 +547,7 @@
description="The size in points of the first character.">
<cocoa key="fontSize"/>
</property>
- <property name="RTF" code="RTF " type="any"
+ <property name="RTF" code="RTF " type="RTF"
description="The raw RTF data.">
<cocoa key="scriptingRTF"/>
</property>
@@ -574,7 +574,7 @@
description="The size in points of the first character.">
<cocoa key="fontSize"/>
</property>
- <property name="RTF" code="RTF " type="any"
+ <property name="RTF" code="RTF " type="RTF"
description="The raw RTF data.">
<cocoa key="scriptingRTF"/>
</property>
@@ -601,7 +601,7 @@
description="The size in points of the first character.">
<cocoa key="fontSize"/>
</property>
- <property name="RTF" code="RTF " type="any"
+ <property name="RTF" code="RTF " type="RTF"
description="The raw RTF data.">
<cocoa key="scriptingRTF"/>
</property>
@@ -1052,6 +1052,18 @@
<cocoa class="NSColor"/>
</value-type>
+ <value-type name="RTF" code="RTF ">
+ <cocoa class="NSData"/>
+ </value-type>
+
+ <value-type name="PDF" code="PDF ">
+ <cocoa class="NSData"/>
+ </value-type>
+
+ <value-type name="TIFF picture" code="TIFF">
+ <cocoa class="NSData"/>
+ </value-type>
+
<enumeration name="standard color" code="ClrE">
<enumerator name="red" code="Red "
description="Red color."/>
@@ -1373,10 +1385,14 @@
description="The bounds for the picture.">
<cocoa key="Bounds"/>
</parameter>
- <parameter name="TIFF format" type="boolean" code="Tiff"
optional="yes"
+ <parameter name="TIFF format" type="boolean" code="Tiff"
optional="yes" hidden="yes"
description="Whether to return TIFF data. By default returns
PDF data.">
<cocoa key="AsTIFF"/>
</parameter>
+ <parameter name="as" type="type" code="rtyp" optional="yes"
+ description="The type of data to return. Currently 'PDF' and
'TIFF picture' are supported. Defaults to PDF.">
+ <cocoa key="Type"/>
+ </parameter>
<result type="any"
description="The PDF or TIFF data of the picture."/>
</command>
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit