1997-09-01 21:59:51 +00:00
|
|
|
|
/*
|
|
|
|
|
NSAttributedString.m
|
|
|
|
|
|
|
|
|
|
Implementation of string class with attributes
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
Copyright (C) 1997,1999 Free Software Foundation, Inc.
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
Written by: ANOQ of the sun <anoq@vip.cybercity.dk>
|
1997-11-21 18:19:29 +00:00
|
|
|
|
Date: November 1997
|
1999-04-09 17:07:21 +00:00
|
|
|
|
Rewrite by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
|
Date: April 1999
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
This file is part of GNUstep-base
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
|
|
If you are interested in a warranty or support for this source code,
|
|
|
|
|
contact Scott Christley <scottc@net-community.com> for more information.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
|
License along with this library; if not, write to the Free
|
1999-09-09 02:56:20 +00:00
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
1997-09-01 21:59:51 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
/* Warning - [-initWithString:attributes:] is the designated initialiser,
|
|
|
|
|
* but it doesn't provide any way to perform the function of the
|
|
|
|
|
* [-initWithAttributedString:] initialiser.
|
2000-03-09 19:06:49 +00:00
|
|
|
|
* In order to work round this, the string argument of the
|
1999-04-09 17:07:21 +00:00
|
|
|
|
* designated initialiser has been overloaded such that it
|
|
|
|
|
* is expected to accept an NSAttributedString here instead of
|
|
|
|
|
* a string. If you create an NSAttributedString subclass, you
|
|
|
|
|
* must make sure that your implementation of the initialiser
|
|
|
|
|
* copes with either an NSString or an NSAttributedString.
|
|
|
|
|
* If it receives an NSAttributedString, it should ignore the
|
|
|
|
|
* attributes argument and use the values from the string.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <base/preface.h>
|
|
|
|
|
#include <base/fast.x>
|
|
|
|
|
#include <base/Unicode.h>
|
1997-11-21 18:19:29 +00:00
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
#include <Foundation/NSAttributedString.h>
|
1997-11-21 18:19:29 +00:00
|
|
|
|
#include <Foundation/NSGAttributedString.h>
|
1997-09-01 21:59:51 +00:00
|
|
|
|
#include <Foundation/NSException.h>
|
|
|
|
|
#include <Foundation/NSAutoreleasePool.h>
|
1998-12-18 17:05:44 +00:00
|
|
|
|
#include <Foundation/NSPortCoder.h>
|
1999-06-21 08:30:26 +00:00
|
|
|
|
#include <Foundation/NSRange.h>
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
|
|
|
|
|
@interface GSMutableAttributedStringTracker : NSMutableString
|
|
|
|
|
{
|
|
|
|
|
NSMutableAttributedString *_owner;
|
|
|
|
|
}
|
|
|
|
|
+ (NSMutableString*) stringWithOwner: (NSMutableAttributedString*)as;
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@implementation NSAttributedString
|
|
|
|
|
|
1999-07-14 15:57:55 +00:00
|
|
|
|
static Class NSAttributedString_abstract_class;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
static Class NSAttributedString_concrete_class;
|
1999-07-14 20:16:49 +00:00
|
|
|
|
static Class NSMutableAttributedString_abstract_class;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
static Class NSMutableAttributedString_concrete_class;
|
|
|
|
|
|
|
|
|
|
//Internal methods
|
|
|
|
|
+ (void) _setConcreteClass: (Class)c
|
|
|
|
|
{
|
|
|
|
|
NSAttributedString_concrete_class = c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (void) _setMutableConcreteClass: (Class)c
|
|
|
|
|
{
|
|
|
|
|
NSMutableAttributedString_concrete_class = c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (Class) _concreteClass
|
|
|
|
|
{
|
|
|
|
|
return NSAttributedString_concrete_class;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (Class) _mutableConcreteClass
|
|
|
|
|
{
|
|
|
|
|
return NSMutableAttributedString_concrete_class;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [NSAttributedString class])
|
1999-04-09 17:07:21 +00:00
|
|
|
|
{
|
1999-07-14 15:57:55 +00:00
|
|
|
|
NSAttributedString_abstract_class = self;
|
|
|
|
|
NSAttributedString_concrete_class = [NSGAttributedString class];
|
1999-07-14 20:16:49 +00:00
|
|
|
|
NSMutableAttributedString_abstract_class
|
|
|
|
|
= [NSMutableAttributedString class];
|
1999-04-09 17:07:21 +00:00
|
|
|
|
NSMutableAttributedString_concrete_class
|
|
|
|
|
= [NSGMutableAttributedString class];
|
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
+ (id) allocWithZone: (NSZone*)z
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-07-14 15:57:55 +00:00
|
|
|
|
if (self == NSAttributedString_abstract_class)
|
|
|
|
|
return NSAllocateObject([self _concreteClass], 0, z);
|
|
|
|
|
else
|
|
|
|
|
return NSAllocateObject(self, 0, z);
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//NSCoding protocol
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)anEncoder
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
[super encodeWithCoder: anEncoder];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
return [super initWithCoder: aDecoder];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-09-29 14:39:53 +00:00
|
|
|
|
- (Class) classForPortCoder
|
1997-09-12 17:54:10 +00:00
|
|
|
|
{
|
|
|
|
|
return [self class];
|
|
|
|
|
}
|
1998-12-18 17:05:44 +00:00
|
|
|
|
|
|
|
|
|
- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder
|
1997-09-12 17:54:10 +00:00
|
|
|
|
{
|
1998-12-18 17:05:44 +00:00
|
|
|
|
if ([aCoder isByref] == NO)
|
1997-09-12 17:54:10 +00:00
|
|
|
|
return self;
|
1998-12-18 17:05:44 +00:00
|
|
|
|
return [super replacementObjectForPortCoder: aCoder];
|
1997-09-12 17:54:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
//NSCopying protocol
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (id) copyWithZone: (NSZone*)zone
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
2000-03-08 08:38:42 +00:00
|
|
|
|
if ([self isKindOfClass: [NSMutableAttributedString class]]
|
|
|
|
|
|| NSShouldRetainWithZone(self, zone) == NO)
|
1999-04-09 17:07:21 +00:00
|
|
|
|
return [[[[self class] _concreteClass] allocWithZone: zone]
|
2000-03-08 08:38:42 +00:00
|
|
|
|
initWithAttributedString: self];
|
1998-07-29 14:04:17 +00:00
|
|
|
|
else
|
1999-04-21 20:16:25 +00:00
|
|
|
|
return RETAIN(self);
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//NSMutableCopying protocol
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (id) mutableCopyWithZone: (NSZone*)zone
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
return [[[[self class] _mutableConcreteClass] allocWithZone: zone]
|
2000-03-08 08:38:42 +00:00
|
|
|
|
initWithAttributedString: self];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Creating an NSAttributedString
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (id) init
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
return [self initWithString: nil attributes: nil];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (id) initWithString: (NSString*)aString
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
return [self initWithString: aString attributes: nil];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (id) initWithAttributedString: (NSAttributedString*)attributedString
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
return [self initWithString: (NSString*)attributedString attributes: nil];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (id) initWithString: (NSString*)aString attributes: (NSDictionary*)attributes
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
|
|
|
|
//This is the designated initializer
|
1999-04-09 17:07:21 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];/* Primitive method! */
|
|
|
|
|
return nil;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-17 13:13:08 +00:00
|
|
|
|
- (NSString*) description
|
|
|
|
|
{
|
|
|
|
|
NSRange r = NSMakeRange(0, 0);
|
|
|
|
|
unsigned index = NSMaxRange(r);
|
|
|
|
|
unsigned length = [self length];
|
|
|
|
|
NSString *string = [self string];
|
|
|
|
|
NSDictionary *attrs;
|
|
|
|
|
NSMutableString *desc;
|
|
|
|
|
|
|
|
|
|
desc = AUTORELEASE([[super description] mutableCopy]);
|
|
|
|
|
while (index <= length &&
|
|
|
|
|
(attrs = [self attributesAtIndex: index effectiveRange: &r]) != nil)
|
|
|
|
|
{
|
|
|
|
|
index = NSMaxRange(r);
|
|
|
|
|
[desc appendFormat: @"\nRange: %@ Chars:'%@' Attrs: %@",
|
|
|
|
|
NSStringFromRange(r), [string substringFromRange: r], attrs];
|
|
|
|
|
}
|
|
|
|
|
return desc;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
//Retrieving character information
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (unsigned int) length
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
|
|
|
|
return [[self string] length];
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (NSString*) string
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];/* Primitive method! */
|
1997-09-01 21:59:51 +00:00
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Retrieving attribute information
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (NSDictionary*) attributesAtIndex: (unsigned)index
|
|
|
|
|
effectiveRange: (NSRange*)aRange
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];/* Primitive method! */
|
1997-09-01 21:59:51 +00:00
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (NSDictionary*) attributesAtIndex: (unsigned)index
|
|
|
|
|
longestEffectiveRange: (NSRange*)aRange
|
|
|
|
|
inRange: (NSRange)rangeLimit
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
NSDictionary *attrDictionary, *tmpDictionary;
|
|
|
|
|
NSRange tmpRange;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
if (rangeLimit.location < 0 || NSMaxRange(rangeLimit) > [self length])
|
|
|
|
|
{
|
2000-03-09 19:06:49 +00:00
|
|
|
|
[NSException raise: NSRangeException
|
|
|
|
|
format: @"RangeError in method -attributesAtIndex:longestEffectiveRange:inRange: in class NSAttributedString"];
|
1999-04-09 17:07:21 +00:00
|
|
|
|
}
|
|
|
|
|
attrDictionary = [self attributesAtIndex: index effectiveRange: aRange];
|
2000-03-09 19:06:49 +00:00
|
|
|
|
if (aRange == 0)
|
1997-09-01 21:59:51 +00:00
|
|
|
|
return attrDictionary;
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
while (aRange->location > rangeLimit.location)
|
|
|
|
|
{
|
|
|
|
|
//Check extend range backwards
|
2000-03-09 19:06:49 +00:00
|
|
|
|
tmpDictionary = [self attributesAtIndex: aRange->location-1
|
|
|
|
|
effectiveRange: &tmpRange];
|
2000-03-08 08:38:42 +00:00
|
|
|
|
if ([tmpDictionary isEqualToDictionary: attrDictionary])
|
2000-03-09 19:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
aRange->length = NSMaxRange(*aRange) - tmpRange.location;
|
|
|
|
|
aRange->location = tmpRange.location;
|
|
|
|
|
}
|
2000-03-08 08:38:42 +00:00
|
|
|
|
else
|
2000-03-09 19:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2000-03-08 08:38:42 +00:00
|
|
|
|
}
|
|
|
|
|
while (NSMaxRange(*aRange) < NSMaxRange(rangeLimit))
|
|
|
|
|
{
|
|
|
|
|
//Check extend range forwards
|
2000-03-09 19:06:49 +00:00
|
|
|
|
tmpDictionary = [self attributesAtIndex: NSMaxRange(*aRange)
|
|
|
|
|
effectiveRange: &tmpRange];
|
2000-03-08 08:38:42 +00:00
|
|
|
|
if ([tmpDictionary isEqualToDictionary: attrDictionary])
|
2000-03-09 19:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
aRange->length = NSMaxRange(tmpRange) - aRange->location;
|
|
|
|
|
}
|
2000-03-08 08:38:42 +00:00
|
|
|
|
else
|
2000-03-09 19:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2000-03-08 08:38:42 +00:00
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
*aRange = NSIntersectionRange(*aRange,rangeLimit);//Clip to rangeLimit
|
|
|
|
|
return attrDictionary;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (id) attribute: (NSString*)attributeName
|
|
|
|
|
atIndex: (unsigned)index
|
|
|
|
|
effectiveRange: (NSRange*)aRange
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
|
|
|
|
NSDictionary *tmpDictionary;
|
|
|
|
|
id attrValue;
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
tmpDictionary = [self attributesAtIndex: index effectiveRange: aRange];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
2000-03-09 19:06:49 +00:00
|
|
|
|
if (attributeName == nil)
|
2000-03-08 08:38:42 +00:00
|
|
|
|
{
|
2000-03-09 19:06:49 +00:00
|
|
|
|
if (aRange != 0)
|
|
|
|
|
{
|
|
|
|
|
*aRange = NSMakeRange(0,[self length]);
|
|
|
|
|
/*
|
|
|
|
|
* If attributeName is nil, then the attribute will not exist in the
|
|
|
|
|
* entire text - therefore aRange of the entire text must be correct
|
|
|
|
|
*/
|
|
|
|
|
}
|
2000-03-08 08:38:42 +00:00
|
|
|
|
return nil;
|
|
|
|
|
}
|
1999-04-09 17:07:21 +00:00
|
|
|
|
attrValue = [tmpDictionary objectForKey: attributeName];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
return attrValue;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-09 19:06:49 +00:00
|
|
|
|
- (id) attribute: (NSString*)attributeName
|
|
|
|
|
atIndex: (unsigned int)index
|
|
|
|
|
longestEffectiveRange: (NSRange*)aRange
|
|
|
|
|
inRange: (NSRange)rangeLimit
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
2000-03-09 19:06:49 +00:00
|
|
|
|
NSDictionary *tmpDictionary;
|
|
|
|
|
id attrValue;
|
|
|
|
|
id tmpAttrValue;
|
|
|
|
|
NSRange tmpRange;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
if (rangeLimit.location < 0 || NSMaxRange(rangeLimit) > [self length])
|
2000-03-08 08:38:42 +00:00
|
|
|
|
{
|
2000-03-09 19:06:49 +00:00
|
|
|
|
[NSException raise: NSRangeException
|
|
|
|
|
format: @"RangeError in method -attribute:atIndex:longestEffectiveRange:inRange: in class NSAttributedString"];
|
2000-03-08 08:38:42 +00:00
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
2000-03-09 19:06:49 +00:00
|
|
|
|
attrValue = [self attribute: attributeName
|
|
|
|
|
atIndex: index
|
|
|
|
|
effectiveRange: aRange];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
2000-03-09 19:06:49 +00:00
|
|
|
|
if (attributeName == nil)
|
|
|
|
|
return nil;
|
|
|
|
|
if (aRange == 0)
|
1997-09-01 21:59:51 +00:00
|
|
|
|
return attrValue;
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
while (aRange->location > rangeLimit.location)
|
|
|
|
|
{
|
|
|
|
|
//Check extend range backwards
|
2000-03-09 19:06:49 +00:00
|
|
|
|
tmpDictionary = [self attributesAtIndex: aRange->location-1
|
|
|
|
|
effectiveRange: &tmpRange];
|
2000-03-08 08:38:42 +00:00
|
|
|
|
tmpAttrValue = [tmpDictionary objectForKey: attributeName];
|
|
|
|
|
if (tmpAttrValue == attrValue)
|
2000-03-09 19:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
aRange->length = NSMaxRange(*aRange) - tmpRange.location;
|
|
|
|
|
aRange->location = tmpRange.location;
|
|
|
|
|
}
|
2000-03-08 08:38:42 +00:00
|
|
|
|
else
|
2000-03-09 19:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2000-03-08 08:38:42 +00:00
|
|
|
|
}
|
|
|
|
|
while (NSMaxRange(*aRange) < NSMaxRange(rangeLimit))
|
|
|
|
|
{
|
|
|
|
|
//Check extend range forwards
|
2000-03-09 19:06:49 +00:00
|
|
|
|
tmpDictionary = [self attributesAtIndex: NSMaxRange(*aRange)
|
|
|
|
|
effectiveRange: &tmpRange];
|
2000-03-08 08:38:42 +00:00
|
|
|
|
tmpAttrValue = [tmpDictionary objectForKey: attributeName];
|
|
|
|
|
if (tmpAttrValue == attrValue)
|
2000-03-09 19:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
aRange->length = NSMaxRange(tmpRange) - aRange->location;
|
|
|
|
|
}
|
2000-03-08 08:38:42 +00:00
|
|
|
|
else
|
2000-03-09 19:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2000-03-08 08:38:42 +00:00
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
*aRange = NSIntersectionRange(*aRange,rangeLimit);//Clip to rangeLimit
|
|
|
|
|
return attrValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Comparing attributed strings
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (BOOL) isEqualToAttributedString: (NSAttributedString*)otherString
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
|
|
|
|
NSRange ownEffectiveRange,otherEffectiveRange;
|
|
|
|
|
unsigned int length;
|
|
|
|
|
NSDictionary *ownDictionary,*otherDictionary;
|
|
|
|
|
BOOL result;
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
if (!otherString)
|
1997-09-01 21:59:51 +00:00
|
|
|
|
return NO;
|
1999-04-09 17:07:21 +00:00
|
|
|
|
if (![[otherString string] isEqual: [self string]])
|
1997-09-01 21:59:51 +00:00
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
|
|
length = [otherString length];
|
1999-04-09 17:07:21 +00:00
|
|
|
|
if (length<=0)
|
1997-09-01 21:59:51 +00:00
|
|
|
|
return YES;
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
ownDictionary = [self attributesAtIndex: 0
|
2000-03-09 19:06:49 +00:00
|
|
|
|
effectiveRange: &ownEffectiveRange];
|
1999-04-09 17:07:21 +00:00
|
|
|
|
otherDictionary = [otherString attributesAtIndex: 0
|
2000-03-09 19:06:49 +00:00
|
|
|
|
effectiveRange: &otherEffectiveRange];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
result = YES;
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
while (YES)
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
2000-03-08 08:38:42 +00:00
|
|
|
|
if (NSIntersectionRange(ownEffectiveRange, otherEffectiveRange).length > 0
|
|
|
|
|
&& ![ownDictionary isEqualToDictionary: otherDictionary])
|
|
|
|
|
{
|
|
|
|
|
result = NO;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (NSMaxRange(ownEffectiveRange) < NSMaxRange(otherEffectiveRange))
|
|
|
|
|
{
|
2000-03-09 19:06:49 +00:00
|
|
|
|
ownDictionary = [self attributesAtIndex: NSMaxRange(ownEffectiveRange)
|
|
|
|
|
effectiveRange: &ownEffectiveRange];
|
2000-03-08 08:38:42 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (NSMaxRange(otherEffectiveRange) >= length)
|
2000-03-09 19:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
break;//End of strings
|
|
|
|
|
}
|
2000-03-08 08:38:42 +00:00
|
|
|
|
otherDictionary = [otherString
|
|
|
|
|
attributesAtIndex: NSMaxRange(otherEffectiveRange)
|
|
|
|
|
effectiveRange: &otherEffectiveRange];
|
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
1998-07-29 14:04:17 +00:00
|
|
|
|
- (BOOL) isEqual: (id)anObject
|
|
|
|
|
{
|
|
|
|
|
if (anObject == self)
|
|
|
|
|
return YES;
|
1999-04-09 17:07:21 +00:00
|
|
|
|
if ([anObject isKindOf: [NSAttributedString class]])
|
|
|
|
|
return [self isEqualToAttributedString: anObject];
|
1998-07-29 14:04:17 +00:00
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
//Extracting a substring
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (NSAttributedString*) attributedSubstringFromRange: (NSRange)aRange
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
NSAttributedString *newAttrString;
|
|
|
|
|
NSString *newSubstring;
|
|
|
|
|
NSDictionary *attrs;
|
|
|
|
|
NSRange range;
|
1999-06-21 08:30:26 +00:00
|
|
|
|
unsigned len = [self length];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-06-21 08:30:26 +00:00
|
|
|
|
GS_RANGE_CHECK(aRange, len);
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
newSubstring = [[self string] substringFromRange: aRange];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
attrs = [self attributesAtIndex: aRange.location effectiveRange: &range];
|
|
|
|
|
range = NSIntersectionRange(range, aRange);
|
|
|
|
|
if (NSEqualRanges(range, aRange) == YES)
|
|
|
|
|
{
|
|
|
|
|
newAttrString = [[NSAttributedString alloc] initWithString: newSubstring
|
|
|
|
|
attributes: attrs];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSMutableAttributedString *m;
|
|
|
|
|
NSRange rangeToSet = range;
|
|
|
|
|
|
|
|
|
|
m = [[NSMutableAttributedString alloc] initWithString: newSubstring
|
|
|
|
|
attributes: nil];
|
|
|
|
|
rangeToSet.location = 0;
|
|
|
|
|
[m setAttributes: attrs range: rangeToSet];
|
|
|
|
|
while (NSMaxRange(range) < NSMaxRange(aRange))
|
|
|
|
|
{
|
|
|
|
|
attrs = [self attributesAtIndex: NSMaxRange(range)
|
|
|
|
|
effectiveRange: &range];
|
|
|
|
|
rangeToSet = NSIntersectionRange(range, aRange);
|
|
|
|
|
rangeToSet.location -= aRange.location;
|
|
|
|
|
[m setAttributes: attrs range: rangeToSet];
|
|
|
|
|
}
|
|
|
|
|
newAttrString = [m copy];
|
1999-04-21 20:16:25 +00:00
|
|
|
|
RELEASE(m);
|
1999-04-09 17:07:21 +00:00
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-09-28 19:35:09 +00:00
|
|
|
|
IF_NO_GC(AUTORELEASE(newAttrString));
|
1997-09-01 21:59:51 +00:00
|
|
|
|
return newAttrString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end //NSAttributedString
|
|
|
|
|
|
|
|
|
|
@implementation NSMutableAttributedString
|
|
|
|
|
|
|
|
|
|
+ allocWithZone: (NSZone*)z
|
|
|
|
|
{
|
1999-07-14 20:16:49 +00:00
|
|
|
|
if (self == NSMutableAttributedString_abstract_class)
|
|
|
|
|
return NSAllocateObject([self _mutableConcreteClass], 0, z);
|
|
|
|
|
else
|
|
|
|
|
return NSAllocateObject(self, 0, z);
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Retrieving character information
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (NSMutableString*) mutableString
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
return [GSMutableAttributedStringTracker stringWithOwner: self];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Changing characters
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (void) deleteCharactersInRange: (NSRange)aRange
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
[self replaceCharactersInRange: aRange withString: nil];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Changing attributes
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (void) setAttributes: (NSDictionary*)attributes range: (NSRange)aRange
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];// Primitive method!
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (void) addAttribute: (NSString*)name value: (id)value range: (NSRange)aRange
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
2000-03-08 08:38:42 +00:00
|
|
|
|
NSRange effectiveRange;
|
|
|
|
|
NSDictionary *attrDict;
|
|
|
|
|
NSMutableDictionary *newDict;
|
|
|
|
|
unsigned int tmpLength;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
tmpLength = [self length];
|
1999-06-21 08:30:26 +00:00
|
|
|
|
GS_RANGE_CHECK(aRange, tmpLength);
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
attrDict = [self attributesAtIndex: aRange.location
|
2000-03-08 08:38:42 +00:00
|
|
|
|
effectiveRange: &effectiveRange];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
while (effectiveRange.location < NSMaxRange(aRange))
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
2000-03-08 08:38:42 +00:00
|
|
|
|
effectiveRange = NSIntersectionRange(aRange, effectiveRange);
|
|
|
|
|
|
|
|
|
|
newDict = [[NSMutableDictionary alloc] initWithDictionary: attrDict];
|
|
|
|
|
IF_NO_GC(AUTORELEASE(newDict));
|
|
|
|
|
[newDict setObject: value forKey: name];
|
|
|
|
|
[self setAttributes: newDict range: effectiveRange];
|
|
|
|
|
|
|
|
|
|
if (NSMaxRange(effectiveRange) >= NSMaxRange(aRange))
|
|
|
|
|
{
|
|
|
|
|
effectiveRange.location = NSMaxRange(aRange);//This stops the loop...
|
|
|
|
|
}
|
|
|
|
|
else if (NSMaxRange(effectiveRange) < tmpLength)
|
|
|
|
|
{
|
|
|
|
|
attrDict = [self attributesAtIndex: NSMaxRange(effectiveRange)
|
|
|
|
|
effectiveRange: &effectiveRange];
|
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (void) addAttributes: (NSDictionary*)attributes range: (NSRange)aRange
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
2000-03-08 08:38:42 +00:00
|
|
|
|
NSRange effectiveRange;
|
|
|
|
|
NSDictionary *attrDict;
|
|
|
|
|
NSMutableDictionary *newDict;
|
|
|
|
|
unsigned int tmpLength;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
if (!attributes)
|
2000-03-08 08:38:42 +00:00
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
|
format: @"attributes is nil in method -addAttributes:range: "
|
|
|
|
|
@"in class NSMutableAtrributedString"];
|
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
tmpLength = [self length];
|
1999-04-09 17:07:21 +00:00
|
|
|
|
if (aRange.location <= 0 || NSMaxRange(aRange) > tmpLength)
|
2000-03-08 08:38:42 +00:00
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSRangeException
|
|
|
|
|
format: @"RangeError in method -addAttribute:value:range: "
|
|
|
|
|
@"in class NSMutableAttributedString"];
|
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
attrDict = [self attributesAtIndex: aRange.location
|
2000-03-08 08:38:42 +00:00
|
|
|
|
effectiveRange: &effectiveRange];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
while (effectiveRange.location < NSMaxRange(aRange))
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
2000-03-08 08:38:42 +00:00
|
|
|
|
effectiveRange = NSIntersectionRange(aRange,effectiveRange);
|
|
|
|
|
|
|
|
|
|
newDict = [[NSMutableDictionary alloc] initWithDictionary: attrDict];
|
|
|
|
|
IF_NO_GC(AUTORELEASE(newDict));
|
|
|
|
|
[newDict addEntriesFromDictionary: attributes];
|
|
|
|
|
[self setAttributes: newDict range: effectiveRange];
|
|
|
|
|
|
|
|
|
|
if (NSMaxRange(effectiveRange) >= NSMaxRange(aRange))
|
|
|
|
|
{
|
|
|
|
|
effectiveRange.location = NSMaxRange(aRange);//This stops the loop...
|
|
|
|
|
}
|
|
|
|
|
else if (NSMaxRange(effectiveRange) < tmpLength)
|
|
|
|
|
{
|
|
|
|
|
attrDict = [self attributesAtIndex: NSMaxRange(effectiveRange)
|
|
|
|
|
effectiveRange: &effectiveRange];
|
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (void) removeAttribute: (NSString*)name range: (NSRange)aRange
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
2000-03-08 08:38:42 +00:00
|
|
|
|
NSRange effectiveRange;
|
|
|
|
|
NSDictionary *attrDict;
|
|
|
|
|
NSMutableDictionary *newDict;
|
|
|
|
|
unsigned int tmpLength;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
tmpLength = [self length];
|
1999-06-21 08:30:26 +00:00
|
|
|
|
GS_RANGE_CHECK(aRange, tmpLength);
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
attrDict = [self attributesAtIndex: aRange.location
|
2000-03-08 08:38:42 +00:00
|
|
|
|
effectiveRange: &effectiveRange];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
while (effectiveRange.location < NSMaxRange(aRange))
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
2000-03-08 08:38:42 +00:00
|
|
|
|
effectiveRange = NSIntersectionRange(aRange,effectiveRange);
|
|
|
|
|
|
|
|
|
|
newDict = [[NSMutableDictionary alloc] initWithDictionary: attrDict];
|
|
|
|
|
IF_NO_GC(AUTORELEASE(newDict));
|
|
|
|
|
[newDict removeObjectForKey: name];
|
|
|
|
|
[self setAttributes: newDict range: effectiveRange];
|
|
|
|
|
|
|
|
|
|
if (NSMaxRange(effectiveRange) >= NSMaxRange(aRange))
|
|
|
|
|
{
|
|
|
|
|
effectiveRange.location = NSMaxRange(aRange);//This stops the loop...
|
|
|
|
|
}
|
|
|
|
|
else if (NSMaxRange(effectiveRange) < tmpLength)
|
|
|
|
|
{
|
|
|
|
|
attrDict = [self attributesAtIndex: NSMaxRange(effectiveRange)
|
|
|
|
|
effectiveRange: &effectiveRange];
|
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Changing characters and attributes
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (void) appendAttributedString: (NSAttributedString*)attributedString
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
[self replaceCharactersInRange: NSMakeRange([self length],0)
|
2000-03-08 08:38:42 +00:00
|
|
|
|
withAttributedString: attributedString];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (void) insertAttributedString: (NSAttributedString*)attributedString
|
|
|
|
|
atIndex: (unsigned int)index
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
[self replaceCharactersInRange: NSMakeRange(index,0)
|
2000-03-08 08:38:42 +00:00
|
|
|
|
withAttributedString: attributedString];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (void) replaceCharactersInRange: (NSRange)aRange
|
|
|
|
|
withAttributedString: (NSAttributedString*)attributedString
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
2000-03-08 08:38:42 +00:00
|
|
|
|
NSRange effectiveRange;
|
|
|
|
|
NSRange clipRange;
|
|
|
|
|
NSRange ownRange;
|
|
|
|
|
NSDictionary *attrDict;
|
|
|
|
|
NSString *tmpStr;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
tmpStr = [attributedString string];
|
2000-03-08 08:38:42 +00:00
|
|
|
|
[self replaceCharactersInRange: aRange withString: tmpStr];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
effectiveRange = NSMakeRange(0,0);
|
|
|
|
|
clipRange = NSMakeRange(0,[tmpStr length]);
|
2000-03-08 08:38:42 +00:00
|
|
|
|
while (NSMaxRange(effectiveRange) < NSMaxRange(clipRange))
|
|
|
|
|
{
|
|
|
|
|
attrDict = [attributedString attributesAtIndex: effectiveRange.location
|
|
|
|
|
effectiveRange: &effectiveRange];
|
|
|
|
|
ownRange = NSIntersectionRange(clipRange,effectiveRange);
|
|
|
|
|
ownRange.location += aRange.location;
|
|
|
|
|
[self setAttributes: attrDict range: ownRange];
|
|
|
|
|
}
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (void) replaceCharactersInRange: (NSRange)aRange
|
|
|
|
|
withString: (NSString*)aString
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];// Primitive method!
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (void) setAttributedString: (NSAttributedString*)attributedString
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-09 17:07:21 +00:00
|
|
|
|
[self replaceCharactersInRange: NSMakeRange(0,[self length])
|
2000-03-08 08:38:42 +00:00
|
|
|
|
withAttributedString: attributedString];
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Grouping changes
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (void) beginEditing
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
|
|
|
|
//Overridden by subclasses
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
|
- (void) endEditing
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
|
|
|
|
//Overridden by subclasses
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end //NSMutableAttributedString
|
1999-04-09 17:07:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The GSMutableAttributedStringTracker class is a concrete subclass of
|
|
|
|
|
* NSMutableString which keeps it's owner informed of any changes made
|
|
|
|
|
* to it.
|
|
|
|
|
*/
|
|
|
|
|
@implementation GSMutableAttributedStringTracker
|
|
|
|
|
|
|
|
|
|
+ (NSMutableString*) stringWithOwner: (NSMutableAttributedString*)as
|
|
|
|
|
{
|
|
|
|
|
GSMutableAttributedStringTracker *str;
|
|
|
|
|
NSZone *z = NSDefaultMallocZone();
|
|
|
|
|
|
|
|
|
|
str = (GSMutableAttributedStringTracker*) NSAllocateObject(self, 0, z);
|
|
|
|
|
|
|
|
|
|
str->_owner = RETAIN(as);
|
1999-04-21 20:16:25 +00:00
|
|
|
|
return AUTORELEASE(str);
|
1999-04-09 17:07:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
RELEASE(_owner);
|
|
|
|
|
NSDeallocateObject(self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (unsigned int) length
|
|
|
|
|
{
|
|
|
|
|
return [[_owner string] length];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (unichar) characterAtIndex: (unsigned int)index
|
|
|
|
|
{
|
|
|
|
|
return [[_owner string] characterAtIndex: index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)getCharacters: (unichar*)buffer
|
|
|
|
|
{
|
|
|
|
|
return [[_owner string] getCharacters: buffer];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)getCharacters: (unichar*)buffer range: (NSRange)aRange
|
|
|
|
|
{
|
|
|
|
|
return [[_owner string] getCharacters: buffer range: aRange];
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 08:38:42 +00:00
|
|
|
|
- (const char*) cString
|
1999-04-09 17:07:21 +00:00
|
|
|
|
{
|
|
|
|
|
return [[_owner string] cString];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (unsigned int) cStringLength
|
|
|
|
|
{
|
|
|
|
|
return [[_owner string] cStringLength];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSStringEncoding) fastestEncoding
|
|
|
|
|
{
|
|
|
|
|
return [[_owner string] fastestEncoding];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSStringEncoding) smallestEncoding
|
|
|
|
|
{
|
|
|
|
|
return [[_owner string] smallestEncoding];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int) _baseLength
|
|
|
|
|
{
|
|
|
|
|
return [[_owner string] _baseLength];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
|
|
|
|
return [[_owner string] encodeWithCoder: aCoder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (Class) classForCoder
|
|
|
|
|
{
|
|
|
|
|
return [[_owner string] classForCoder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) replaceCharactersInRange: (NSRange)aRange
|
|
|
|
|
withString: (NSString*)aString
|
|
|
|
|
{
|
|
|
|
|
[_owner replaceCharactersInRange: aRange withString: aString];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|