Revision: 22639
http://sourceforge.net/p/bibdesk/svn/22639
Author: hofman
Date: 2018-09-19 16:12:31 +0000 (Wed, 19 Sep 2018)
Log Message:
-----------
Add optional argument to rich text for script command to control return type,
to convert to plain text
Modified Paths:
--------------
trunk/bibdesk/BDSKRichTextForCommand.m
trunk/bibdesk/Scripting/BibDesk.sdef
Modified: trunk/bibdesk/BDSKRichTextForCommand.m
===================================================================
--- trunk/bibdesk/BDSKRichTextForCommand.m 2018-09-19 12:08:37 UTC (rev
22638)
+++ trunk/bibdesk/BDSKRichTextForCommand.m 2018-09-19 16:12:31 UTC (rev
22639)
@@ -44,6 +44,8 @@
- (id)performDefaultImplementation {
id data = [self directParameter];
+ id asTypeNumber = [[self evaluatedArguments] objectForKey:@"Type"];
+ FourCharCode asType = [asTypeNumber
respondsToSelector:@selector(unsignedIntValue)] ? [asTypeNumber
unsignedIntValue] : 'ricT';
if ([data isKindOfClass:[NSData class]] == NO) {
[self setScriptErrorNumber:NSArgumentsWrongScriptError];
@@ -52,10 +54,15 @@
NSAttributedString *attrString = [[[NSAttributedString alloc]
initWithData:data options:[NSDictionary dictionary] documentAttributes:NULL
error:NULL] autorelease];
if (attrString == nil) {
[self setScriptErrorNumber:NSArgumentsWrongScriptError];
- return nil;
+ } else if (asType == cText || asType == typeText || asType ==
typeUnicodeText || asType == typeUTF8Text || asType == typeCString || asType ==
typeChar) {
+ return [attrString string];
+ } else if (asType == 'ricT' || asType == typeStyledText || asType ==
typeObjectSpecifier) {
+ return [attrString richTextSpecifier];
+ } else {
+ [self setScriptErrorNumber:NSArgumentsWrongScriptError];
}
- return [attrString richTextSpecifier];
}
+ return nil;
}
@end
Modified: trunk/bibdesk/Scripting/BibDesk.sdef
===================================================================
--- trunk/bibdesk/Scripting/BibDesk.sdef 2018-09-19 12:08:37 UTC (rev
22638)
+++ trunk/bibdesk/Scripting/BibDesk.sdef 2018-09-19 16:12:31 UTC (rev
22639)
@@ -731,7 +731,15 @@
description="Convert raw RTF data to rich text.">
<cocoa class="BDSKRichTextForCommand"/>
<direct-parameter type="RTF" description="The raw RTF data."/>
- <result description="The rich text" type="specifier"/>
+ <parameter name="as" type="type" code="rtyp" optional="yes"
+ description="The type of object to return, rich text or a text
type. The default is rich text.">
+ <cocoa key="Type"/>
+ </parameter>
+ <result description="The (rich) text" type="specifier">
+ <type type="text"/>
+ <type type="specifier" hidden="yes"/>
+ <type type="rich text"/>
+ </result>
</command>
<class-extension extends="application"
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit