Fixes from ANOQ.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2657 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 1997-11-21 18:19:29 +00:00
parent 8e5f91e5f8
commit 4345bf7ce0
4 changed files with 91 additions and 48 deletions

View file

@ -6,9 +6,9 @@
Copyright (C) 1997 Free Software Foundation, Inc.
Written by: ANOQ of the sun <anoq@vip.cybercity.dk>
Date: June 1997
Date: November 1997
This file is part of ...
This file is part of GNUStep-base
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@ -28,6 +28,23 @@
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//FIXME: 1) The NSMutableString object returned from the -mutableString method
// in NSMutableAttributedString is NOT tracked for changes to update
// NSMutableAttributedString's attributes as it should.
//FIXME: 2) If out-of-memory exceptions are raised in some methods,
// inconsistencies may develop, because the two internal arrays in
// NSGAttributedString and NSGMutableAttributedString called
// attributeArray and locateArray must always be syncronized.
//FIXME: 3) The method _setAttributesFrom: must be overridden by
// concrete subclasses of NSAttributedString which is WRONG and
// VERY bad! I haven't found any other way to make
// - initWithString:attributes: the designated initializer
// in NSAttributedString and still implement
// - initWithAttributedString: without having to override it
// in the concrete subclass.
#ifndef _NSXKit_H_NSAttributedString
#define _NSXKit_H_NSAttributedString
@ -36,17 +53,6 @@
#include <Foundation/NSArray.h>
#include <Foundation/NSCoder.h>
NSString *NSFontAttributeName;
NSString *NSForegroundColorAttributeName;
NSString *NSBackgroundColorAttributeName;
NSString *NSUnderlineStyleAttributeName;
NSString *NSSuperscriptAttributeName;
NSString *NSBaselineOffsetAttributeName;
NSString *NSKernAttributeName;
NSString *NSLigatureAttributeName;
NSString *NSParagraphStyleAttributeName;
NSString *NSAttachmentAttributeName;
@interface NSAttributedString : NSObject <NSCoding, NSCopying, NSMutableCopying>
{
@ -105,6 +111,5 @@ NSString *NSAttachmentAttributeName;
@end //NSMutableAttributedString
#include "NSGAttributedString.h"
#endif //_NSXKit_H_NSAttributedString
#endif //_NSXKit_H_NSAttributedString

View file

@ -6,9 +6,9 @@
Copyright (C) 1997 Free Software Foundation, Inc.
Written by: ANOQ of the sun <anoq@vip.cybercity.dk>
Date: June 1997
Date: November 1997
This file is part of ...
This file is part of GNUStep-base
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@ -28,6 +28,23 @@
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//FIXME: 1) The NSMutableString object returned from the -mutableString method
// in NSMutableAttributedString is NOT tracked for changes to update
// NSMutableAttributedString's attributes as it should.
//FIXME: 2) If out-of-memory exceptions are raised in some methods,
// inconsistencies may develop, because the two internal arrays in
// NSGAttributedString and NSGMutableAttributedString called
// attributeArray and locateArray must always be syncronized.
//FIXME: 3) The method _setAttributesFrom: must be overridden by
// concrete subclasses of NSAttributedString which is WRONG and
// VERY bad! I haven't found any other way to make
// - initWithString:attributes: the designated initializer
// in NSAttributedString and still implement
// - initWithAttributedString: without having to override it
// in the concrete subclass.
#ifndef _NSGAttributedString_h_INCLUDE
#define _NSGAttributedString_h_INCLUDE

View file

@ -6,9 +6,9 @@
Copyright (C) 1997 Free Software Foundation, Inc.
Written by: ANOQ of the sun <anoq@vip.cybercity.dk>
Date: June 1997
Date: November 1997
This file is part of ...
This file is part of GNUStep-base
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@ -28,22 +28,28 @@
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
//FIXME: 1) The NSMutableString object returned from the -mutableString method
// in NSMutableAttributedString is NOT tracked for changes to update
// NSMutableAttributedString's attributes as it should.
//FIXME: 2) If out-of-memory exceptions are raised in some methods,
// inconsistencies may develop, because the two internal arrays in
// NSGAttributedString and NSGMutableAttributedString called
// attributeArray and locateArray must always be syncronized.
//FIXME: 3) The method _setAttributesFrom: must be overridden by
// concrete subclasses of NSAttributedString which is WRONG and
// VERY bad! I haven't found any other way to make
// - initWithString:attributes: the designated initializer
// in NSAttributedString and still implement
// - initWithAttributedString: without having to override it
// in the concrete subclass.
#include <Foundation/NSAttributedString.h>
#include <Foundation/NSGAttributedString.h>
#include <Foundation/NSException.h>
#include <Foundation/NSAutoreleasePool.h>
NSString *NSFontAttributeName = @"FontAttribute";
NSString *NSForegroundColorAttributeName = @"ForegroundColorAttribute";
NSString *NSBackgroundColorAttributeName = @"BackgroundColorAttribute";
NSString *NSUnderlineStyleAttributeName = @"UnderlineStyleAttribute";
NSString *NSSuperscriptAttributeName = @"SuperscriptAttribute";
NSString *NSBaselineOffsetAttributeName = @"BaselineOffsetAttribute";
NSString *NSKernAttributeName = @"KernAttribute";
NSString *NSLigatureAttributeName = @"LigatureAttribute";
NSString *NSParagraphStyleAttributeName = @"ParagraphStyleAttribute";
NSString *NSAttachmentAttributeName = @"AttachmentAttribute";
@implementation NSAttributedString
static Class NSAttributedString_concrete_class;
@ -140,14 +146,12 @@ static Class NSMutableAttributedString_concrete_class;
//Creating an NSAttributedString
- (id)init
{
[self initWithString:nil attributes:nil];//Designated initializer
return self;
return [self initWithString:nil attributes:nil];//Designated initializer
}
- (id)initWithString:(NSString *)aString
{
[self initWithString:aString attributes:nil];//Designated initializer
return self;
return [self initWithString:aString attributes:nil];//Designated initializer
}
- (id)initWithAttributedString:(NSAttributedString *)attributedString
@ -168,8 +172,7 @@ static Class NSMutableAttributedString_concrete_class;
- (id)initWithString:(NSString *)aString attributes:(NSDictionary *)attributes
{
//This is the designated initializer
[self subclassResponsibility:_cmd];
return self;
return [super init];
}
//Retrieving character information

View file

@ -6,9 +6,9 @@
Copyright (C) 1997 Free Software Foundation, Inc.
Written by: ANOQ of the sun <anoq@vip.cybercity.dk>
Date: June 1997
Date: November 1997
This file is part of ...
This file is part of GNUStep-base
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@ -28,8 +28,24 @@
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
#include <Foundation/NSAttributedString.h>
//FIXME: 1) The NSMutableString object returned from the -mutableString method
// in NSMutableAttributedString is NOT tracked for changes to update
// NSMutableAttributedString's attributes as it should.
//FIXME: 2) If out-of-memory exceptions are raised in some methods,
// inconsistencies may develop, because the two internal arrays in
// NSGAttributedString and NSGMutableAttributedString called
// attributeArray and locateArray must always be syncronized.
//FIXME: 3) The method _setAttributesFrom: must be overridden by
// concrete subclasses of NSAttributedString which is WRONG and
// VERY bad! I haven't found any other way to make
// - initWithString:attributes: the designated initializer
// in NSAttributedString and still implement
// - initWithAttributedString: without having to override it
// in the concrete subclass.
#include <Foundation/NSGAttributedString.h>
#include <Foundation/NSException.h>
#include <Foundation/NSValue.h>
@ -67,14 +83,14 @@ void _setAttributesFrom(
void _initWithString(
NSString *aString,
NSDictionary *attributes,
NSString *textChars,
NSString **textChars,
NSMutableArray **attributeArray,
NSMutableArray **locateArray)
{
if (aString)
[textChars initWithString:aString];
*textChars = [(*textChars) initWithString:aString];
else
[textChars init];
*textChars = [(*textChars) init];
*attributeArray = [[NSMutableArray alloc] init];
*locateArray = [[NSMutableArray alloc] init];
if(!attributes)
@ -159,7 +175,7 @@ NSDictionary *_attributesAtIndexEffectiveRange(
- initWithCoder: aCoder
{
[super initWithCoder:aCoder];
self = [super initWithCoder:aCoder];
textChars = [[aCoder decodeObject] retain];
attributeArray = [[aCoder decodeObject] retain];
locateArray = [[aCoder decodeObject] retain];
@ -175,8 +191,9 @@ NSDictionary *_attributesAtIndexEffectiveRange(
- (id)initWithString:(NSString *)aString attributes:(NSDictionary *)attributes
{
self = [super initWithString:aString attributes:attributes];
textChars = [NSString alloc];
_initWithString(aString,attributes,textChars,&attributeArray,&locateArray);
_initWithString(aString,attributes,&textChars,&attributeArray,&locateArray);
return self;
}
@ -223,7 +240,7 @@ NSDictionary *_attributesAtIndexEffectiveRange(
- initWithCoder: aCoder
{
[super initWithCoder:aCoder];
self = [super initWithCoder:aCoder];
textChars = [[aCoder decodeObject] retain];
attributeArray = [[aCoder decodeObject] retain];
locateArray = [[aCoder decodeObject] retain];
@ -239,8 +256,9 @@ NSDictionary *_attributesAtIndexEffectiveRange(
- (id)initWithString:(NSString *)aString attributes:(NSDictionary *)attributes
{
self = [super initWithString:aString attributes:attributes];
textChars = [NSMutableString alloc];
_initWithString(aString,attributes,textChars,&attributeArray,&locateArray);
_initWithString(aString,attributes,&textChars,&attributeArray,&locateArray);
return self;
}