Revision: 18161
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18161&view=rev
Author: hofman
Date: 2011-10-07 12:41:30 +0000 (Fri, 07 Oct 2011)
Log Message:
-----------
Redesign scripting support for stand-alone rich text. Use NSAttributedString
for "rich text format" class and NSData for "RTF" value type. No need to for a
separate class.
Modified Paths:
--------------
trunk/bibdesk/BDSKTemplatedTextCommand.m
trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
trunk/bibdesk/NSAttributedString_BDSKExtensions.h
trunk/bibdesk/NSAttributedString_BDSKExtensions.m
trunk/bibdesk/NSData_BDSKExtensions.h
trunk/bibdesk/NSData_BDSKExtensions.m
trunk/bibdesk/Scripting/BibDesk.sdef
Added Paths:
-----------
trunk/bibdesk/BDSKRichTextForCommand.h
trunk/bibdesk/BDSKRichTextForCommand.m
Removed Paths:
-------------
trunk/bibdesk/BDSKRichTextFormat.h
trunk/bibdesk/BDSKRichTextFormat.m
Copied: trunk/bibdesk/BDSKRichTextForCommand.h (from rev 18131,
trunk/bibdesk/BDSKRichTextFormat.h)
===================================================================
--- trunk/bibdesk/BDSKRichTextForCommand.h (rev 0)
+++ trunk/bibdesk/BDSKRichTextForCommand.h 2011-10-07 12:41:30 UTC (rev
18161)
@@ -0,0 +1,43 @@
+//
+// BDSKRichTextForCommand.h
+// Bibdesk
+//
+// Created by Christiaan Hofman on 1/19/09.
+/*
+ This software is Copyright (c) 2009-2011
+ 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 BDSKRichTextForCommand : NSScriptCommand
+@end
Copied: trunk/bibdesk/BDSKRichTextForCommand.m (from rev 18131,
trunk/bibdesk/BDSKRichTextFormat.m)
===================================================================
--- trunk/bibdesk/BDSKRichTextForCommand.m (rev 0)
+++ trunk/bibdesk/BDSKRichTextForCommand.m 2011-10-07 12:41:30 UTC (rev
18161)
@@ -0,0 +1,61 @@
+//
+// BDSKRichTextForCommand.m
+// Bibdesk
+//
+// Created by Christiaan Hofman on 1/19/09.
+/*
+ This software is Copyright (c) 2009-2011
+ 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 "BDSKRichTextForCommand.h"
+#import "NSAttributedString_BDSKExtensions.h"
+
+
+@implementation BDSKRichTextForCommand
+
+- (id)performDefaultImplementation {
+ id data = [self directParameter];
+
+ if ([data isKindOfClass:[NSData class]] == NO) {
+ [self setScriptErrorNumber:NSArgumentsWrongScriptError];
+ return nil;
+ } else {
+ NSAttributedString *attrString = [[[NSAttributedString alloc]
initWithData:data options:[NSDictionary dictionary] documentAttributes:NULL
error:NULL] autorelease];
+ if (attrString == nil) {
+ [self setScriptErrorNumber:NSArgumentsWrongScriptError];
+ return nil;
+ }
+ return [attrString richTextSpecifier];
+ }
+}
+
+@end
Deleted: trunk/bibdesk/BDSKRichTextFormat.h
===================================================================
--- trunk/bibdesk/BDSKRichTextFormat.h 2011-10-07 06:36:20 UTC (rev 18160)
+++ trunk/bibdesk/BDSKRichTextFormat.h 2011-10-07 12:41:30 UTC (rev 18161)
@@ -1,63 +0,0 @@
-//
-// BDSKRichTextFormat.h
-// Bibdesk
-//
-// Created by Christiaan Hofman on 1/19/09.
-/*
- This software is Copyright (c) 2009-2011
- 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 BDSKRichTextFormat : NSObject {
- NSData *data;
-}
-
-+ (id)richTextSpecifierWithData:(NSData *)aData;
-
-- (id)initWithData:(NSData *)aData;
-- (id)initWithName:(NSString *)aName;
-
-- (NSString *)name;
-- (NSTextStorage *)richText;
-
-@end
-
-
-@interface NSApplication (BDSKRichTextFormat)
-- (BDSKRichTextFormat *)valueInRichTextFormatWithName:(NSString *)name;
-@end
-
-
-@interface BDSKRichTextForCommand : NSScriptCommand
-@end
Deleted: trunk/bibdesk/BDSKRichTextFormat.m
===================================================================
--- trunk/bibdesk/BDSKRichTextFormat.m 2011-10-07 06:36:20 UTC (rev 18160)
+++ trunk/bibdesk/BDSKRichTextFormat.m 2011-10-07 12:41:30 UTC (rev 18161)
@@ -1,118 +0,0 @@
-//
-// BDSKRichTextFormat.m
-// Bibdesk
-//
-// Created by Christiaan Hofman on 1/19/09.
-/*
- This software is Copyright (c) 2009-2011
- 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 "BDSKRichTextFormat.h"
-#import "NSData_BDSKExtensions.h"
-#import "NSObject_BDSKExtensions.h"
-
-
-@implementation BDSKRichTextFormat
-
-+ (id)richTextSpecifierWithData:(NSData *)aData {
- BDSKRichTextFormat *rtf = [[BDSKRichTextFormat alloc] initWithData:aData];
- NSScriptObjectSpecifier *rtfSpecifier = [rtf objectSpecifier];
- NSPropertySpecifier *richTextSpecifier = rtfSpecifier ?
[[[NSPropertySpecifier alloc] initWithContainerClassDescription:[rtfSpecifier
keyClassDescription] containerSpecifier:rtfSpecifier key:@"richText"]
autorelease] : nil;
- [rtf release];
- return richTextSpecifier;
-}
-
-- (id)initWithData:(NSData *)aData {
- self = [super init];
- if (self) {
- if (aData) {
- data = [aData retain];
- } else {
- [self release];
- self = nil;
- }
- }
- return self;
-}
-
-- (id)initWithName:(NSString *)aName {
- NSData *aData = [[NSData alloc] initWithBase64String:aName];
- self = [self initWithData:aData];
- [aData release];
- return self;
-}
-
-- (void)dealloc {
- BDSKDESTROY(data);
- [super dealloc];
-}
-
-- (NSScriptObjectSpecifier *)objectSpecifier {
- NSScriptClassDescription *containerClassDescription = [NSApp
scriptClassDescription];
- return [[[NSNameSpecifier allocWithZone:[self zone]]
initWithContainerClassDescription:containerClassDescription
containerSpecifier:nil key:@"richTextFormat" name:[self name]] autorelease];
-}
-
-- (NSString *)name {
- return [data base64String];
-}
-
-- (NSTextStorage *)richText {
- NSError *error;
- return [[[NSTextStorage alloc] initWithData:data options:[NSDictionary
dictionary] documentAttributes:NULL error:&error] autorelease];
-}
-
-@end
-
-
-@implementation NSApplication (BDSKRichTextFormat)
-
-- (BDSKRichTextFormat *)valueInRichTextFormatWithName:(NSString *)name {
- return [[[BDSKRichTextFormat alloc] initWithName:name] autorelease];
-}
-
-@end
-
-
-@implementation BDSKRichTextForCommand
-
-- (id)performDefaultImplementation {
- id attrString = [self directParameter];
-
- if ([attrString isKindOfClass:[NSAttributedString class]] == NO) {
- [self setScriptErrorNumber:NSArgumentsWrongScriptError];
- return nil;
- } else {
- return [BDSKRichTextFormat richTextSpecifierWithData:[attrString
RTFFromRange:NSMakeRange(0, [attrString length]) documentAttributes:nil]];
- }
-}
-
-@end
Modified: trunk/bibdesk/BDSKTemplatedTextCommand.m
===================================================================
--- trunk/bibdesk/BDSKTemplatedTextCommand.m 2011-10-07 06:36:20 UTC (rev
18160)
+++ trunk/bibdesk/BDSKTemplatedTextCommand.m 2011-10-07 12:41:30 UTC (rev
18161)
@@ -43,7 +43,7 @@
#import "BDSKPublicationsArray.h"
#import "NSArray_BDSKExtensions.h"
#import "BibItem.h"
-#import "BDSKRichTextFormat.h"
+#import "NSAttributedString_BDSKExtensions.h"
@implementation BDSKTemplatedTextCommand
@@ -254,8 +254,7 @@
attrString = [[[NSAttributedString alloc] initWithString:string]
autorelease];
}
- NSData *data = [attrString RTFFromRange:NSMakeRange(0, [attrString
length]) documentAttributes:nil];
- return data ? [BDSKRichTextFormat richTextSpecifierWithData:data] : nil;
+ return [attrString richTextSpecifier];
}
@end
Modified: trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
===================================================================
--- trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj 2011-10-07 06:36:20 UTC
(rev 18160)
+++ trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj 2011-10-07 12:41:30 UTC
(rev 18161)
@@ -104,6 +104,7 @@
CE248773112C974D006B4FA5 /* NSFont_BDSKExtensions.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CE248771112C974D006B4FA5 /*
NSFont_BDSKExtensions.m */; };
CE24B33510C3E13900818EDF /* BDSKLibraryGroup.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE24B33310C3E13900818EDF /* BDSKLibraryGroup.m
*/; };
CE24B35510C3E9E100818EDF /* BDSKLastImportGroup.m in Sources */
= {isa = PBXBuildFile; fileRef = CE24B35310C3E9E100818EDF /*
BDSKLastImportGroup.m */; };
+ CE24BA69143F2A1900B3216B /* BDSKRichTextForCommand.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CEC3158B0F24D0B9008D2C75 /*
BDSKRichTextForCommand.m */; };
CE26481D0B5AB4B800D4B5B8 /* BDSKDragTextField.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE26481B0B5AB4B700D4B5B8 /* BDSKDragTextField.m
*/; };
CE27D95C0AF92BFD00419879 /* BDSKZoomableTextView.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CE27D95A0AF92BFD00419879 /*
BDSKZoomableTextView.m */; };
CE28346509176CA3006B4C63 /* BDSKGradientView.m in Sources */ =
{isa = PBXBuildFile; fileRef = F9706DE409102DF500526FC8 /* BDSKGradientView.m
*/; };
@@ -274,7 +275,6 @@
CEBB8D8809C8B0D90074C79E /* Font.tiff in Resources */ = {isa =
PBXBuildFile; fileRef = CEBB8D8709C8B0D90074C79E /* Font.tiff */; };
CEBC676F0B4A845F00CE0B2D /* BDSKSearchGroupViewController.m in
Sources */ = {isa = PBXBuildFile; fileRef = CEBC676D0B4A845F00CE0B2D /*
BDSKSearchGroupViewController.m */; };
CEC1CEA80F51D2CE00D18921 /* BDSKReadWriteLock.m in Sources */ =
{isa = PBXBuildFile; fileRef = CEC1CEA60F51D2CE00D18921 /* BDSKReadWriteLock.m
*/; };
- CEC3158D0F24D0B9008D2C75 /* BDSKRichTextFormat.m in Sources */
= {isa = PBXBuildFile; fileRef = CEC3158B0F24D0B9008D2C75 /*
BDSKRichTextFormat.m */; };
CEC7CDE10F6725890051794E /* BDSKFilePathCell.m in Sources */ =
{isa = PBXBuildFile; fileRef = CEC7CDDF0F6725890051794E /* BDSKFilePathCell.m
*/; };
CEC7D0260F680C970051794E /* BDSKIconTextFieldCell.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CEC7D0240F680C970051794E /*
BDSKIconTextFieldCell.m */; };
CED65AB70906BCC6003EED90 /* BDSKScriptHook.m in Sources */ =
{isa = PBXBuildFile; fileRef = CED65AB30906BCC6003EED90 /* BDSKScriptHook.m */;
};
@@ -1302,8 +1302,8 @@
CEBC676D0B4A845F00CE0B2D /* BDSKSearchGroupViewController.m */
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = BDSKSearchGroupViewController.m; sourceTree =
"<group>"; };
CEC1CEA50F51D2CE00D18921 /* BDSKReadWriteLock.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
BDSKReadWriteLock.h; sourceTree = "<group>"; };
CEC1CEA60F51D2CE00D18921 /* BDSKReadWriteLock.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= BDSKReadWriteLock.m; sourceTree = "<group>"; };
- CEC3158A0F24D0B9008D2C75 /* BDSKRichTextFormat.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
BDSKRichTextFormat.h; sourceTree = "<group>"; };
- CEC3158B0F24D0B9008D2C75 /* BDSKRichTextFormat.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= BDSKRichTextFormat.m; sourceTree = "<group>"; };
+ CEC3158A0F24D0B9008D2C75 /* BDSKRichTextForCommand.h */ = {isa
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path
= BDSKRichTextForCommand.h; sourceTree = "<group>"; };
+ CEC3158B0F24D0B9008D2C75 /* BDSKRichTextForCommand.m */ = {isa
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc;
path = BDSKRichTextForCommand.m; sourceTree = "<group>"; };
CEC7CDDE0F6725890051794E /* BDSKFilePathCell.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
BDSKFilePathCell.h; sourceTree = "<group>"; };
CEC7CDDF0F6725890051794E /* BDSKFilePathCell.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= BDSKFilePathCell.m; sourceTree = "<group>"; };
CEC7D0230F680C970051794E /* BDSKIconTextFieldCell.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
BDSKIconTextFieldCell.h; sourceTree = "<group>"; };
@@ -1989,7 +1989,7 @@
F9201E000B72504C007E45BB /* BDSKMacro.m */,
CE82BE8B0D58C12A00A2E8C5 /*
BDSKMacroResolver+Scripting.m */,
CE3011AB0D5CC46F00C0B7FA /* BDSKRemoveCommand.m
*/,
- CEC3158B0F24D0B9008D2C75 /*
BDSKRichTextFormat.m */,
+ CEC3158B0F24D0B9008D2C75 /*
BDSKRichTextForCommand.m */,
CED65DCB0907A338003EED90 /*
BDSKScriptHook+Scripting.m */,
CE095D50135C52B5000E4396 /* BDSKSelectCommand.m
*/,
F9022FBE07580B9400C3F701 /*
BibAuthor+Scripting.m */,
@@ -2709,7 +2709,7 @@
F940D1070B5568E400B5917A /* BDSKReferParser.h
*/,
CE601A4C0AF4C488000B5680 /*
BDSKReferenceMinerParser.h */,
CE3011AA0D5CC46F00C0B7FA /* BDSKRemoveCommand.h
*/,
- CEC3158A0F24D0B9008D2C75 /*
BDSKRichTextFormat.h */,
+ CEC3158A0F24D0B9008D2C75 /*
BDSKRichTextForCommand.h */,
CE600E2D0AF405D6000B5680 /* BDSKRISParser.h */,
CEED2F320F4E0C860078E87A /* BDSKRuntime.h */,
F90C4ACB0C7395FB0035DD50 /*
BDSKSciFinderParser.h */,
@@ -3728,7 +3728,6 @@
CE3C02A10EA54C650002AD5B /*
KFAppleScriptHandlerAdditionsCore.m in Sources */,
CE40EC550EE9AAF000BCF379 /* BDSKImportCommand.m
in Sources */,
CE071ED10F213EB300244F5C /* BDSKArxivParser.m
in Sources */,
- CEC3158D0F24D0B9008D2C75 /*
BDSKRichTextFormat.m in Sources */,
CEF2EEE70F3462A900A7989E /*
NSColor_BDSKExtensions.m in Sources */,
CE62DE350F4B75B400BDF01E /*
BDSKPreferencePane.m in Sources */,
CE62DE3C0F4B777800BDF01E /*
BDSKPreferenceWindow.m in Sources */,
@@ -3789,6 +3788,7 @@
CE095D52135C52B5000E4396 /* BDSKSelectCommand.m
in Sources */,
CE33D607136AB73600ACE924 /*
BDSKTextImportItemTableView.m in Sources */,
CE33D61C136AB8A700ACE924 /*
BDSKImportTextView.m in Sources */,
+ CE24BA69143F2A1900B3216B /*
BDSKRichTextForCommand.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/bibdesk/NSAttributedString_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSAttributedString_BDSKExtensions.h 2011-10-07 06:36:20 UTC
(rev 18160)
+++ trunk/bibdesk/NSAttributedString_BDSKExtensions.h 2011-10-07 12:41:30 UTC
(rev 18161)
@@ -47,9 +47,12 @@
-
(NSComparisonResult)localizedCaseInsensitiveNonTeXNonArticleCompare:(NSAttributedString
*)other;
-+ (id)scriptingRtfWithDescriptor:(NSAppleEventDescriptor *)descriptor;
-- (id)scriptingRtfDescriptor;
+- (NSString *)scriptingName;
+- (NSTextStorage *)scriptingRichText;
+- (NSScriptObjectSpecifier *)objectSpecifier;
+- (NSScriptObjectSpecifier *)richTextSpecifier;
+
@end
@@ -63,7 +66,11 @@
@interface NSTextStorage (BDSKExtensions)
- (id)scriptingRTF;
-- (void)setScriptingRTF:(id)attrString;
+- (void)setScriptingRTF:(id)data;
@end
+
+@interface NSApplication (BDSKRichTextFormat)
+- (NSAttributedString *)valueInRichTextFormatWithName:(NSString *)name;
+@end
Modified: trunk/bibdesk/NSAttributedString_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSAttributedString_BDSKExtensions.m 2011-10-07 06:36:20 UTC
(rev 18160)
+++ trunk/bibdesk/NSAttributedString_BDSKExtensions.m 2011-10-07 12:41:30 UTC
(rev 18161)
@@ -40,6 +40,7 @@
#import "BDSKComplexString.h"
#import "NSString_BDSKExtensions.h"
#import "NSCharacterSet_BDSKExtensions.h"
+#import "NSData_BDSKExtensions.h"
#define BDSKRangeKey @"__BDSKRange"
@@ -226,20 +227,24 @@
#pragma mark Scripting support
-+ (id)scriptingRtfWithDescriptor:(NSAppleEventDescriptor *)descriptor {
- NSString *string = [descriptor stringValue];
- if (string) {
- return [[[self alloc] initWithString:string] autorelease];
- } else {
- NSError *error;
- return [[[self alloc] initWithData:[descriptor data]
options:[NSDictionary dictionary] documentAttributes:NULL error:&error]
autorelease];
- }
+- (NSString *)scriptingName {
+ return [[self RTFFromRange:NSMakeRange(0, [self length])
documentAttributes:nil] base64String];
}
-- (id)scriptingRtfDescriptor {
- return [NSAppleEventDescriptor descriptorWithDescriptorType:'RTF '
data:[self RTFFromRange:NSMakeRange(0, [self length]) documentAttributes:nil]];
+- (NSTextStorage *)scriptingRichText {
+ return [[[NSTextStorage alloc] initWithAttributedString:self] autorelease];
}
+- (NSScriptObjectSpecifier *)objectSpecifier {
+ NSScriptClassDescription *containerClassDescription =
[NSScriptClassDescription classDescriptionForClass:[NSApp class]];
+ return [[[NSNameSpecifier allocWithZone:[self zone]]
initWithContainerClassDescription:containerClassDescription
containerSpecifier:nil key:@"richTextFormat" name:[self scriptingName]]
autorelease];
+}
+
+- (NSScriptObjectSpecifier *)richTextSpecifier {
+ NSScriptObjectSpecifier *rtfSpecifier = [self objectSpecifier];
+ return [[[NSPropertySpecifier alloc]
initWithContainerClassDescription:[rtfSpecifier keyClassDescription]
containerSpecifier:rtfSpecifier key:@"scriptingRichText"] autorelease];
+}
+
@end
@@ -257,13 +262,27 @@
@implementation NSTextStorage (BDSKExtensions)
- (id)scriptingRTF {
- return self;
+ return [self RTFFromRange:NSMakeRange(0, [self length])
documentAttributes:nil];
}
-- (void)setScriptingRTF:(id)attrString {
- if (attrString)
- [self setAttributedString:attrString];
+- (void)setScriptingRTF:(id)data {
+ if (data) {
+ NSAttributedString *attrString = [[NSAttributedString alloc]
initWithData:data options:[NSDictionary dictionary] documentAttributes:NULL
error:NULL];
+ if (attrString)
+ [self setAttributedString:attrString];
+ [attrString release];
+ }
}
@end
+
+@implementation NSApplication (BDSKRichTextFormat)
+
+- (NSAttributedString *)valueInRichTextFormatWithName:(NSString *)name {
+ NSData *data = [[[NSData alloc] initWithBase64String:name] autorelease];
+ return data ? [[[NSAttributedString alloc] initWithData:data
options:[NSDictionary dictionary] documentAttributes:NULL error:NULL]
autorelease] : nil;
+}
+
+@end
+
Modified: trunk/bibdesk/NSData_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSData_BDSKExtensions.h 2011-10-07 06:36:20 UTC (rev
18160)
+++ trunk/bibdesk/NSData_BDSKExtensions.h 2011-10-07 12:41:30 UTC (rev
18161)
@@ -67,6 +67,9 @@
- (FILE *)openReadStream;
++ (id)scriptingRtfWithDescriptor:(NSAppleEventDescriptor *)descriptor;
+- (id)scriptingRtfDescriptor;
+
@end
@interface NSMutableData (BDSKExtensions)
Modified: trunk/bibdesk/NSData_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSData_BDSKExtensions.m 2011-10-07 06:36:20 UTC (rev
18160)
+++ trunk/bibdesk/NSData_BDSKExtensions.m 2011-10-07 12:41:30 UTC (rev
18161)
@@ -377,6 +377,14 @@
return (-1 == fd) ? NULL : fdopen(fd, "r");
}
++ (id)scriptingRtfWithDescriptor:(NSAppleEventDescriptor *)descriptor {
+ return [descriptor data];
+}
+
+- (id)scriptingRtfDescriptor {
+ return [NSAppleEventDescriptor descriptorWithDescriptorType:'RTF '
data:self];
+}
+
@end
Modified: trunk/bibdesk/Scripting/BibDesk.sdef
===================================================================
--- trunk/bibdesk/Scripting/BibDesk.sdef 2011-10-07 06:36:20 UTC (rev
18160)
+++ trunk/bibdesk/Scripting/BibDesk.sdef 2011-10-07 12:41:30 UTC (rev
18161)
@@ -270,7 +270,7 @@
</value-type>
<value-type name="RTF" code="RTF ">
- <cocoa class="NSAttributedString"/>
+ <cocoa class="NSData"/>
</value-type>
<class name="rich text" plural="rich text" code="ricT"
@@ -422,14 +422,14 @@
<class name="rich text format" plural="rich text formats" code="RTFt"
hidden="yes"
description="Rich text format, encoding rich text.">
- <cocoa class="BDSKRichTextFormat"/>
+ <cocoa class="NSAttributedString"/>
<property name="name" code="pnam" type="text" access="r"
description="The name for the rich text format.">
- <cocoa key="name"/>
+ <cocoa key="scriptingName"/>
</property>
<contents name="rich text" code="ricT" type="rich text" access="r"
description="The rich text representation of the rich text
format.">
- <cocoa key="richText"/>
+ <cocoa key="scriptingRichText"/>
</contents>
</class>
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit