Better handling of text attachtment. Fixes bug #28464

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29260 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2010-01-11 12:32:27 +00:00
parent db53bb1c7f
commit 4195bb1f3d
3 changed files with 28 additions and 6 deletions

View file

@ -1,3 +1,13 @@
2010-01-06 Fred Kiefer <FredKiefer@gmx.de>
* TextConverters/RTF/RTFConsumer.m (RTFDConsumer-appendImage:):
Flag the attributes as being changed. This prevents the next
appended string from getting that attachment attribute.
* TextConverters/RTF/RTFConsumer.m (GSRTFunicode): Don't append
the attachment character.
* Source/NSAttributedString.m (-fixAttachmentAttributeInRange:):
Keep the local copy of string up to date.
2010-01-09 Wolfgang Lux <wolfgang.lux@mail.com>
* Source/NSTextView.m (-performDragOperation:): Fix a bug that

View file

@ -1604,6 +1604,7 @@ static NSMutableDictionary *cachedCSets = nil;
// Check for attachment characters without attachments
location = range.location;
string = [self string];
while (location < end)
{
NSRange eRange = [string rangeOfString: attachmentString
@ -1623,6 +1624,8 @@ static NSMutableDictionary *cachedCSets = nil;
[self deleteCharactersInRange: NSMakeRange (eRange.location, 1)];
eRange.length--;
end--;
// Need to reset this after every character change
string = [self string];
}
location = NSMaxRange (eRange);

View file

@ -461,6 +461,11 @@ static BOOL classInheritsFromNSMutableAttributedString (Class c)
[wrapper setIcon: image];
}
attachment = [[NSTextAttachment alloc] initWithFileWrapper: wrapper];
if (attachment == nil)
{
NSLog(@"No attachment at %d", oldPosition);
return;
}
attributes = [[NSMutableDictionary alloc]
initWithObjectsAndKeys:
@ -474,7 +479,7 @@ static BOOL classInheritsFromNSMutableAttributedString (Class c)
[str addAttributes: attributes range: NSMakeRange (0, [str length])];
[result replaceCharactersInRange: insertionRange withAttributedString: str];
attr->changed = YES;
RELEASE(attributes);
RELEASE(attachment);
RELEASE(image);
@ -764,11 +769,15 @@ void GSRTFmangleText (void *ctxt, const char *text)
void GSRTFunicode (void *ctxt, int uchar)
{
unichar chars = uchar;
NSString *str = [[NSString alloc] initWithCharacters: &chars
length: 1];
[(RTFConsumer *)ctxt appendString: str];
DESTROY(str);
// Don't add the attachment character, this gets handled separatly
if (uchar != (int)NSAttachmentCharacter)
{
unichar chars = uchar;
NSString *str = [[NSString alloc] initWithCharacters: &chars
length: 1];
[(RTFConsumer *)ctxt appendString: str];
DESTROY(str);
}
}
void GSRTFregisterFont (void *ctxt, const char *fontName,