1999-12-16 22:56:45 +00:00
|
|
|
|
/* attributedStringConsumer.m
|
|
|
|
|
|
|
|
|
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
|
Author: Stefan B<EFBFBD>hringer (stefan.boehringer@uni-bochum.de)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
Date: Dec 1999
|
2000-06-16 17:00:17 +00:00
|
|
|
|
Author: Fred Kiefer <FredKiefer@gmx.de>
|
|
|
|
|
Date: June 2000
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1999-12-16 22:56:45 +00:00
|
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
|
|
|
|
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
|
2007-10-29 21:16:17 +00:00
|
|
|
|
Lesser General Public License for more details.
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1999-12-16 22:56:45 +00:00
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA.
|
1999-12-16 22:56:45 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
|
#include <AppKit/AppKit.h>
|
2001-08-21 14:52:00 +00:00
|
|
|
|
#include "RTFConsumer.h"
|
|
|
|
|
#include "RTFConsumerFunctions.h"
|
|
|
|
|
#include "RTFProducer.h"
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
|
|
|
|
/* we have to satisfy the scanner with a stream reading function */
|
|
|
|
|
typedef struct {
|
|
|
|
|
NSString *string;
|
|
|
|
|
int position;
|
|
|
|
|
int length;
|
|
|
|
|
} StringContext;
|
|
|
|
|
|
|
|
|
|
static void
|
2001-07-25 09:43:15 +00:00
|
|
|
|
initStringContext (StringContext *ctxt, NSString *string)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
|
|
|
|
ctxt->string = string;
|
|
|
|
|
ctxt->position = 0;
|
|
|
|
|
ctxt->length = [string length];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2001-07-25 09:43:15 +00:00
|
|
|
|
readNSString (StringContext *ctxt)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
|
|
|
|
return (ctxt->position < ctxt->length )
|
|
|
|
|
? [ctxt->string characterAtIndex:ctxt->position++]: EOF;
|
|
|
|
|
}
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
// Hold the attributs of the current run
|
|
|
|
|
@interface RTFAttribute: NSObject <NSCopying>
|
|
|
|
|
{
|
|
|
|
|
@public
|
|
|
|
|
BOOL changed;
|
2000-06-24 22:10:09 +00:00
|
|
|
|
BOOL tabChanged;
|
|
|
|
|
NSMutableParagraphStyle *paragraph;
|
2000-06-16 17:00:17 +00:00
|
|
|
|
NSColor *fgColour;
|
|
|
|
|
NSColor *bgColour;
|
|
|
|
|
NSString *fontName;
|
|
|
|
|
float fontSize;
|
|
|
|
|
BOOL bold;
|
|
|
|
|
BOOL italic;
|
|
|
|
|
BOOL underline;
|
|
|
|
|
int script;
|
2003-02-13 00:16:12 +00:00
|
|
|
|
|
|
|
|
|
float real_fi, real_li;
|
2000-06-16 17:00:17 +00:00
|
|
|
|
}
|
2000-04-23 22:28:46 +00:00
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
- (NSFont*) currentFont;
|
2000-06-17 17:53:14 +00:00
|
|
|
|
- (NSNumber*) script;
|
|
|
|
|
- (NSNumber*) underline;
|
|
|
|
|
- (void) resetParagraphStyle;
|
|
|
|
|
- (void) resetFont;
|
2001-07-25 09:43:15 +00:00
|
|
|
|
- (void) addTab: (float)location type: (NSTextTabType)type;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
@end
|
2000-04-23 22:28:46 +00:00
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
@implementation RTFAttribute
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
- (id) init
|
|
|
|
|
{
|
2000-06-17 17:53:14 +00:00
|
|
|
|
[self resetFont];
|
|
|
|
|
[self resetParagraphStyle];
|
2000-06-16 17:00:17 +00:00
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
- (void) dealloc
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
RELEASE(paragraph);
|
|
|
|
|
RELEASE(fontName);
|
|
|
|
|
RELEASE(fgColour);
|
|
|
|
|
RELEASE(bgColour);
|
|
|
|
|
[super dealloc];
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
- (id) copyWithZone: (NSZone*)zone
|
|
|
|
|
{
|
2000-06-24 22:10:09 +00:00
|
|
|
|
RTFAttribute *new = (RTFAttribute *)NSCopyObject (self, 0, zone);
|
2000-06-16 17:00:17 +00:00
|
|
|
|
|
2003-01-28 22:39:56 +00:00
|
|
|
|
new->paragraph = [paragraph mutableCopyWithZone: zone];
|
2000-10-15 20:55:38 +00:00
|
|
|
|
RETAIN(new->fontName);
|
|
|
|
|
RETAIN(new->fgColour);
|
|
|
|
|
RETAIN(new->bgColour);
|
2000-06-16 17:00:17 +00:00
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSFont*) currentFont
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
|
|
|
|
NSFont *font;
|
|
|
|
|
NSFontTraitMask traits = 0;
|
|
|
|
|
int weight;
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (bold)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
|
|
|
|
weight = 9;
|
|
|
|
|
traits |= NSBoldFontMask;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-06-24 22:10:09 +00:00
|
|
|
|
weight = 5;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
traits |= NSUnboldFontMask;
|
|
|
|
|
}
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (italic)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
|
|
|
|
traits |= NSItalicFontMask;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
traits |= NSUnitalicFontMask;
|
|
|
|
|
}
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
font = [[NSFontManager sharedFontManager] fontWithFamily: fontName
|
2000-04-23 22:28:46 +00:00
|
|
|
|
traits: traits
|
|
|
|
|
weight: weight
|
2000-06-16 17:00:17 +00:00
|
|
|
|
size: fontSize];
|
2000-06-17 17:53:14 +00:00
|
|
|
|
if (font == nil)
|
|
|
|
|
{
|
2002-10-10 23:52:09 +00:00
|
|
|
|
/* Before giving up and using a default font, we try if this is
|
|
|
|
|
* not the case of a font with a composite name, such as
|
|
|
|
|
* 'Helvetica-Light'. In that case, even if we don't have
|
|
|
|
|
* exactly an 'Helvetica-Light' font family, we might have an
|
|
|
|
|
* 'Helvetica' one. */
|
|
|
|
|
NSRange range = [fontName rangeOfString:@"-"];
|
|
|
|
|
|
|
|
|
|
if (range.location != NSNotFound)
|
|
|
|
|
{
|
|
|
|
|
NSString *fontFamily = [fontName substringToIndex: range.location];
|
|
|
|
|
|
|
|
|
|
font = [[NSFontManager sharedFontManager] fontWithFamily: fontFamily
|
|
|
|
|
traits: traits
|
|
|
|
|
weight: weight
|
|
|
|
|
size: fontSize];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (font == nil)
|
|
|
|
|
{
|
|
|
|
|
NSDebugMLLog(@"RTFParser",
|
|
|
|
|
@"Could not find font %@ size %f traits %d weight %d",
|
|
|
|
|
fontName, fontSize, traits, weight);
|
|
|
|
|
|
|
|
|
|
/* Last resort, default font. :-( */
|
|
|
|
|
font = [NSFont userFontOfSize: fontSize];
|
|
|
|
|
}
|
2000-06-17 17:53:14 +00:00
|
|
|
|
}
|
2002-06-11 13:57:38 +00:00
|
|
|
|
|
2000-04-23 22:28:46 +00:00
|
|
|
|
return font;
|
|
|
|
|
}
|
2000-06-17 17:53:14 +00:00
|
|
|
|
|
|
|
|
|
- (NSNumber*) script
|
|
|
|
|
{
|
|
|
|
|
return [NSNumber numberWithInt: script];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSNumber*) underline
|
|
|
|
|
{
|
|
|
|
|
if (underline)
|
|
|
|
|
return [NSNumber numberWithInt: NSSingleUnderlineStyle];
|
|
|
|
|
else
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) resetParagraphStyle
|
|
|
|
|
{
|
2003-04-07 10:02:47 +00:00
|
|
|
|
DESTROY(paragraph);
|
|
|
|
|
paragraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
2003-02-13 00:16:12 +00:00
|
|
|
|
real_fi = real_li = 0.0;
|
2000-06-17 17:53:14 +00:00
|
|
|
|
|
2000-06-24 22:10:09 +00:00
|
|
|
|
tabChanged = NO;
|
2000-06-17 17:53:14 +00:00
|
|
|
|
changed = YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) resetFont
|
|
|
|
|
{
|
|
|
|
|
NSFont *font = [NSFont userFontOfSize:12];
|
|
|
|
|
|
|
|
|
|
ASSIGN(fontName, [font familyName]);
|
|
|
|
|
fontSize = 12.0;
|
|
|
|
|
italic = NO;
|
|
|
|
|
bold = NO;
|
|
|
|
|
|
|
|
|
|
underline = NO;
|
|
|
|
|
script = 0;
|
|
|
|
|
DESTROY(fgColour);
|
|
|
|
|
DESTROY(bgColour);
|
|
|
|
|
|
|
|
|
|
changed = YES;
|
|
|
|
|
}
|
2000-06-24 22:10:09 +00:00
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
- (void) addTab: (float) location type: (NSTextTabType) type
|
2000-06-24 22:10:09 +00:00
|
|
|
|
{
|
|
|
|
|
NSTextTab *tab = [[NSTextTab alloc] initWithType: NSLeftTabStopType
|
|
|
|
|
location: location];
|
|
|
|
|
|
|
|
|
|
if (!tabChanged)
|
2002-06-11 13:57:38 +00:00
|
|
|
|
{
|
2003-04-07 10:02:47 +00:00
|
|
|
|
NSArray *a;
|
|
|
|
|
a = [[NSArray alloc] initWithObjects: tab, nil];
|
2002-06-11 13:57:38 +00:00
|
|
|
|
// remove all tab stops
|
2003-04-07 10:02:47 +00:00
|
|
|
|
[paragraph setTabStops: a];
|
|
|
|
|
DESTROY(a);
|
2002-06-11 13:57:38 +00:00
|
|
|
|
tabChanged = YES;
|
|
|
|
|
}
|
2000-06-24 22:10:09 +00:00
|
|
|
|
else
|
2001-07-25 09:43:15 +00:00
|
|
|
|
{
|
|
|
|
|
[paragraph addTabStop: tab];
|
|
|
|
|
}
|
2000-06-24 22:10:09 +00:00
|
|
|
|
|
|
|
|
|
changed = YES;
|
|
|
|
|
RELEASE(tab);
|
|
|
|
|
}
|
2002-06-11 13:57:38 +00:00
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2002-06-11 14:58:31 +00:00
|
|
|
|
static BOOL classInheritsFromNSMutableAttributedString (Class c)
|
|
|
|
|
{
|
|
|
|
|
Class mutable = [NSMutableAttributedString class];
|
|
|
|
|
|
|
|
|
|
while (c != Nil)
|
|
|
|
|
{
|
|
|
|
|
if (c == mutable)
|
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
c = [c superclass];
|
|
|
|
|
}
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-02 16:53:30 +00:00
|
|
|
|
@interface RTFConsumer (Private)
|
2000-06-16 17:00:17 +00:00
|
|
|
|
|
2000-07-02 16:53:30 +00:00
|
|
|
|
- (NSAttributedString*) parseRTF: (NSData *)rtfData
|
2002-06-11 14:58:31 +00:00
|
|
|
|
documentAttributes: (NSDictionary **)dict
|
|
|
|
|
class: (Class)class;
|
2000-06-16 17:00:17 +00:00
|
|
|
|
- (NSDictionary*) documentAttributes;
|
2000-06-17 17:53:14 +00:00
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
- (RTFAttribute*) attr;
|
|
|
|
|
- (void) push;
|
|
|
|
|
- (void) pop;
|
2003-07-15 22:18:01 +00:00
|
|
|
|
- (void) appendString: (NSString*)string;
|
2000-06-16 17:00:17 +00:00
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation RTFConsumer
|
|
|
|
|
|
2001-08-21 14:52:00 +00:00
|
|
|
|
/* RTFConsumer is the principal class and thus implements this */
|
|
|
|
|
+ (Class) classForFormat: (NSString *)format producer: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
Class cClass = Nil;
|
|
|
|
|
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
2009-09-19 14:55:57 +00:00
|
|
|
|
if (([format isEqual: NSRTFDTextDocumentType]) ||
|
|
|
|
|
([format isEqual: @"com.apple.rtfd"]) ||
|
|
|
|
|
([format isEqual: @"rtfd"]))
|
2002-06-11 13:57:38 +00:00
|
|
|
|
{
|
|
|
|
|
cClass = [RTFDProducer class];
|
|
|
|
|
}
|
2009-09-19 14:55:57 +00:00
|
|
|
|
else if (([format isEqual: NSRTFTextDocumentType]) ||
|
|
|
|
|
([format isEqual: @"public.rtf"]) ||
|
|
|
|
|
([format isEqual: @"rtf"]))
|
2002-06-11 13:57:38 +00:00
|
|
|
|
{
|
|
|
|
|
cClass = [RTFProducer class];
|
|
|
|
|
}
|
2001-08-21 14:52:00 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-09-19 14:55:57 +00:00
|
|
|
|
if (([format isEqual: NSRTFDTextDocumentType]) ||
|
|
|
|
|
([format isEqual: @"com.apple.rtfd"]) ||
|
|
|
|
|
([format isEqual: @"rtfd"]))
|
2002-06-11 13:57:38 +00:00
|
|
|
|
{
|
|
|
|
|
cClass = [RTFDConsumer class];
|
|
|
|
|
}
|
2009-09-19 14:55:57 +00:00
|
|
|
|
else if (([format isEqual: NSRTFTextDocumentType]) ||
|
|
|
|
|
([format isEqual: @"public.rtf"]) ||
|
|
|
|
|
([format isEqual: @"rtf"]))
|
2002-06-11 13:57:38 +00:00
|
|
|
|
{
|
|
|
|
|
cClass = [RTFConsumer class];
|
|
|
|
|
}
|
2001-08-21 14:52:00 +00:00
|
|
|
|
}
|
|
|
|
|
return cClass;
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-18 22:08:28 +00:00
|
|
|
|
+ (NSAttributedString*) parseFile: (NSFileWrapper *)wrapper
|
2009-09-19 14:55:57 +00:00
|
|
|
|
options: (NSDictionary *)options
|
2001-07-25 09:43:15 +00:00
|
|
|
|
documentAttributes: (NSDictionary **)dict
|
2009-09-19 14:55:57 +00:00
|
|
|
|
error: (NSError **)error
|
2002-06-11 14:58:31 +00:00
|
|
|
|
class: (Class)class
|
2000-07-02 16:53:30 +00:00
|
|
|
|
{
|
|
|
|
|
NSAttributedString *text = nil;
|
|
|
|
|
|
|
|
|
|
if ([wrapper isRegularFile])
|
2001-07-25 09:43:15 +00:00
|
|
|
|
{
|
2006-05-11 21:03:21 +00:00
|
|
|
|
RTFConsumer *consumer = [RTFConsumer new];
|
2001-07-25 09:43:15 +00:00
|
|
|
|
text = [consumer parseRTF: [wrapper regularFileContents]
|
2002-06-11 14:58:31 +00:00
|
|
|
|
documentAttributes: dict
|
|
|
|
|
class: class];
|
2006-05-11 21:03:21 +00:00
|
|
|
|
RELEASE(consumer);
|
2001-07-25 09:43:15 +00:00
|
|
|
|
}
|
2000-07-02 16:53:30 +00:00
|
|
|
|
else if ([wrapper isDirectory])
|
|
|
|
|
{
|
|
|
|
|
NSDictionary *files = [wrapper fileWrappers];
|
|
|
|
|
NSFileWrapper *contents;
|
2006-05-11 21:03:21 +00:00
|
|
|
|
RTFDConsumer* consumer = [RTFDConsumer new];
|
2000-07-02 16:53:30 +00:00
|
|
|
|
|
|
|
|
|
if ((contents = [files objectForKey: @"TXT.rtf"]) != nil)
|
2001-07-25 09:43:15 +00:00
|
|
|
|
{
|
2006-05-11 21:03:21 +00:00
|
|
|
|
[consumer setFiles: files];
|
2001-07-25 09:43:15 +00:00
|
|
|
|
text = [consumer parseRTF: [contents regularFileContents]
|
2002-06-11 14:58:31 +00:00
|
|
|
|
documentAttributes: dict
|
|
|
|
|
class: class];
|
2001-07-25 09:43:15 +00:00
|
|
|
|
}
|
2006-05-11 21:03:21 +00:00
|
|
|
|
RELEASE(consumer);
|
2000-07-02 16:53:30 +00:00
|
|
|
|
}
|
2002-06-11 13:57:38 +00:00
|
|
|
|
|
2000-07-02 16:53:30 +00:00
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-18 22:08:28 +00:00
|
|
|
|
+ (NSAttributedString*) parseData: (NSData *)rtfData
|
2009-09-19 14:55:57 +00:00
|
|
|
|
options: (NSDictionary *)options
|
2002-06-11 13:57:38 +00:00
|
|
|
|
documentAttributes: (NSDictionary **)dict
|
2009-09-19 14:55:57 +00:00
|
|
|
|
error: (NSError **)error
|
2002-06-11 14:58:31 +00:00
|
|
|
|
class: (Class)class
|
2000-07-02 16:53:30 +00:00
|
|
|
|
{
|
|
|
|
|
RTFConsumer *consumer = [RTFConsumer new];
|
|
|
|
|
NSAttributedString *text;
|
|
|
|
|
|
|
|
|
|
text = [consumer parseRTF: rtfData
|
2002-06-11 14:58:31 +00:00
|
|
|
|
documentAttributes: dict
|
|
|
|
|
class: class];
|
2000-07-02 16:53:30 +00:00
|
|
|
|
RELEASE(consumer);
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
- (id) init
|
|
|
|
|
{
|
|
|
|
|
ignore = 0;
|
2000-06-17 17:53:14 +00:00
|
|
|
|
result = nil;
|
|
|
|
|
documentAttributes = nil;
|
|
|
|
|
fonts = nil;
|
|
|
|
|
attrs = nil;
|
|
|
|
|
colours = nil;
|
2002-06-11 14:58:31 +00:00
|
|
|
|
_class = Nil;
|
2000-06-16 17:00:17 +00:00
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
- (void) dealloc
|
2000-06-16 17:00:17 +00:00
|
|
|
|
{
|
|
|
|
|
RELEASE(fonts);
|
|
|
|
|
RELEASE(attrs);
|
|
|
|
|
RELEASE(colours);
|
|
|
|
|
RELEASE(result);
|
|
|
|
|
RELEASE(documentAttributes);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-02 16:53:30 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2006-05-12 15:31:04 +00:00
|
|
|
|
|
|
|
|
|
@interface RTFDConsumer (Private)
|
|
|
|
|
|
|
|
|
|
- (void) appendImage: (NSString*) string;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
2001-08-18 22:08:28 +00:00
|
|
|
|
@implementation RTFDConsumer
|
|
|
|
|
|
2006-05-11 21:03:21 +00:00
|
|
|
|
- (id) init
|
|
|
|
|
{
|
|
|
|
|
self = [super init];
|
|
|
|
|
|
|
|
|
|
files = nil;
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
RELEASE(files);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setFiles: (NSDictionary*) theFiles
|
|
|
|
|
{
|
|
|
|
|
ASSIGN (files, theFiles);
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-18 22:08:28 +00:00
|
|
|
|
+ (NSAttributedString*) parseData: (NSData *)rtfData
|
2009-09-19 14:55:57 +00:00
|
|
|
|
options: (NSDictionary *)options
|
2001-08-18 22:08:28 +00:00
|
|
|
|
documentAttributes: (NSDictionary **)dict
|
2009-09-19 14:55:57 +00:00
|
|
|
|
error: (NSError **)error
|
2003-01-30 15:36:15 +00:00
|
|
|
|
class: (Class)class
|
2001-08-18 22:08:28 +00:00
|
|
|
|
{
|
|
|
|
|
NSAttributedString *str;
|
|
|
|
|
NSFileWrapper *wrapper = [[NSFileWrapper alloc]
|
2002-06-11 13:57:38 +00:00
|
|
|
|
initWithSerializedRepresentation: rtfData];
|
|
|
|
|
|
2009-09-19 14:55:57 +00:00
|
|
|
|
str = [self parseFile: wrapper
|
|
|
|
|
options: options
|
|
|
|
|
documentAttributes: dict
|
|
|
|
|
error: error
|
|
|
|
|
class: class];
|
2001-08-18 22:08:28 +00:00
|
|
|
|
RELEASE (wrapper);
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-11 21:03:21 +00:00
|
|
|
|
- (void) appendImage: (NSString*)string
|
|
|
|
|
{
|
|
|
|
|
int oldPosition = [result length];
|
|
|
|
|
NSRange insertionRange = NSMakeRange(oldPosition,0);
|
|
|
|
|
|
|
|
|
|
if (!ignore)
|
|
|
|
|
{
|
|
|
|
|
NSString* fileName = [string stringByTrimmingCharactersInSet:
|
|
|
|
|
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
|
|
|
NSFileWrapper* wrapper = [files objectForKey: fileName];
|
|
|
|
|
|
|
|
|
|
if (wrapper != nil)
|
|
|
|
|
{
|
|
|
|
|
NSImage* image = [[NSImage alloc] initWithData: [wrapper regularFileContents]];
|
|
|
|
|
NSTextAttachmentCell* attachedCell = [[NSTextAttachmentCell alloc] initImageCell: image];
|
|
|
|
|
NSTextAttachment* attachment = [[NSTextAttachment alloc] initWithFileWrapper: wrapper];
|
2006-05-12 15:31:04 +00:00
|
|
|
|
RTFAttribute* attr = [self attr];
|
|
|
|
|
NSMutableDictionary* attributes = nil;
|
|
|
|
|
NSMutableAttributedString* str = nil;
|
|
|
|
|
|
2006-05-11 21:03:21 +00:00
|
|
|
|
[attachment setAttachmentCell: attachedCell];
|
|
|
|
|
|
2006-05-12 15:31:04 +00:00
|
|
|
|
attributes = [[NSMutableDictionary alloc]
|
2006-05-11 21:03:21 +00:00
|
|
|
|
initWithObjectsAndKeys:
|
|
|
|
|
[attr currentFont], NSFontAttributeName,
|
|
|
|
|
attr->paragraph, NSParagraphStyleAttributeName,
|
|
|
|
|
nil];
|
|
|
|
|
|
2006-05-12 15:31:04 +00:00
|
|
|
|
str = (NSMutableAttributedString*) [NSMutableAttributedString
|
|
|
|
|
attributedStringWithAttachment: attachment];
|
|
|
|
|
|
2006-05-11 21:03:21 +00:00
|
|
|
|
[str addAttributes: attributes range: NSMakeRange (0, [str length])];
|
|
|
|
|
|
|
|
|
|
[result replaceCharactersInRange: insertionRange withAttributedString: str];
|
|
|
|
|
|
|
|
|
|
RELEASE(attributes);
|
|
|
|
|
RELEASE(attachment);
|
|
|
|
|
RELEASE(attachedCell);
|
|
|
|
|
RELEASE(image);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-18 22:08:28 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2000-07-02 16:53:30 +00:00
|
|
|
|
@implementation RTFConsumer (Private)
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
- (NSDictionary*) documentAttributes
|
|
|
|
|
{
|
|
|
|
|
RETAIN(documentAttributes);
|
|
|
|
|
return AUTORELEASE(documentAttributes);
|
|
|
|
|
}
|
|
|
|
|
|
2000-06-17 17:53:14 +00:00
|
|
|
|
- (void) reset
|
|
|
|
|
{
|
|
|
|
|
RTFAttribute *attr = [RTFAttribute new];
|
|
|
|
|
|
|
|
|
|
ignore = 0;
|
|
|
|
|
DESTROY(result);
|
2002-06-11 14:58:31 +00:00
|
|
|
|
|
|
|
|
|
if (classInheritsFromNSMutableAttributedString (_class))
|
|
|
|
|
{
|
|
|
|
|
result = [[_class alloc] init];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = [[NSMutableAttributedString alloc] init];
|
|
|
|
|
}
|
2000-06-17 17:53:14 +00:00
|
|
|
|
ASSIGN(documentAttributes, [NSMutableDictionary dictionary]);
|
|
|
|
|
ASSIGN(fonts, [NSMutableDictionary dictionary]);
|
|
|
|
|
ASSIGN(attrs, [NSMutableArray array]);
|
|
|
|
|
ASSIGN(colours, [NSMutableArray array]);
|
|
|
|
|
[attrs addObject: attr];
|
2000-10-15 20:55:38 +00:00
|
|
|
|
RELEASE(attr);
|
2000-06-17 17:53:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
- (RTFAttribute*) attr
|
|
|
|
|
{
|
|
|
|
|
return [attrs lastObject];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) push
|
|
|
|
|
{
|
2000-10-15 20:55:38 +00:00
|
|
|
|
RTFAttribute *attr = [[attrs lastObject] copy];
|
|
|
|
|
|
|
|
|
|
[attrs addObject: attr];
|
|
|
|
|
RELEASE(attr);
|
2000-06-16 17:00:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) pop
|
|
|
|
|
{
|
|
|
|
|
[attrs removeLastObject];
|
2000-06-24 22:10:09 +00:00
|
|
|
|
((RTFAttribute*)[attrs lastObject])->changed = YES;
|
2000-06-16 17:00:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSAttributedString*) parseRTF: (NSData *)rtfData
|
|
|
|
|
documentAttributes: (NSDictionary **)dict
|
2002-06-11 14:58:31 +00:00
|
|
|
|
class: (Class)class
|
2000-06-16 17:00:17 +00:00
|
|
|
|
{
|
|
|
|
|
CREATE_AUTORELEASE_POOL(pool);
|
|
|
|
|
RTFscannerCtxt scanner;
|
|
|
|
|
StringContext stringCtxt;
|
2010-01-05 13:19:24 +00:00
|
|
|
|
NSString *rtfString;
|
|
|
|
|
char buffer[5];
|
|
|
|
|
NSStringEncoding encoding = NSASCIIStringEncoding;
|
|
|
|
|
|
|
|
|
|
// We read in the first few characters to find out which
|
2001-07-25 09:43:15 +00:00
|
|
|
|
// encoding we have
|
2010-01-05 13:19:24 +00:00
|
|
|
|
if ([rtfData length] < 10)
|
|
|
|
|
{
|
|
|
|
|
// Too short to be an RTF
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
[rtfData getBytes: buffer range: NSMakeRange(7, 3)];
|
|
|
|
|
if (strncmp(buffer, "mac", 3) == 0)
|
|
|
|
|
{
|
|
|
|
|
encoding = NSMacOSRomanStringEncoding;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp(buffer, "pc", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
// FIXME: Code page 437 kCFStringEncodingDOSLatinUS
|
|
|
|
|
encoding = NSASCIIStringEncoding;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp(buffer, "pca", 3) == 0)
|
|
|
|
|
{
|
|
|
|
|
// FIXME: Code page 850 kCFStringEncodingDOSLatin1
|
|
|
|
|
encoding = NSASCIIStringEncoding;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp(buffer, "ansi", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
encoding = NSASCIIStringEncoding;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtfString = [[NSString alloc]
|
2001-07-25 09:43:15 +00:00
|
|
|
|
initWithData: rtfData
|
2010-01-05 13:19:24 +00:00
|
|
|
|
encoding: encoding];
|
2000-06-16 17:00:17 +00:00
|
|
|
|
|
2000-06-17 17:53:14 +00:00
|
|
|
|
// Reset this RFTConsumer, as it might already have been used!
|
2002-06-11 14:58:31 +00:00
|
|
|
|
_class = class;
|
2000-06-17 17:53:14 +00:00
|
|
|
|
[self reset];
|
2000-06-16 17:00:17 +00:00
|
|
|
|
|
|
|
|
|
initStringContext(&stringCtxt, rtfString);
|
|
|
|
|
lexInitContext(&scanner, &stringCtxt, (int (*)(void*))readNSString);
|
2003-04-07 10:02:47 +00:00
|
|
|
|
[result beginEditing];
|
2000-06-16 17:00:17 +00:00
|
|
|
|
NS_DURING
|
|
|
|
|
GSRTFparse((void *)self, &scanner);
|
|
|
|
|
NS_HANDLER
|
|
|
|
|
NSLog(@"Problem during RTF Parsing: %@",
|
|
|
|
|
[localException reason]);
|
|
|
|
|
//[localException raise];
|
|
|
|
|
NS_ENDHANDLER
|
2003-04-07 10:02:47 +00:00
|
|
|
|
[result endEditing];
|
|
|
|
|
|
2000-10-15 20:55:38 +00:00
|
|
|
|
RELEASE(rtfString);
|
2000-06-16 17:00:17 +00:00
|
|
|
|
RELEASE(pool);
|
|
|
|
|
// document attributes
|
|
|
|
|
if (dict)
|
2001-07-25 09:43:15 +00:00
|
|
|
|
{
|
|
|
|
|
*dict = [self documentAttributes];
|
|
|
|
|
}
|
2000-06-16 17:00:17 +00:00
|
|
|
|
|
2002-06-11 14:58:31 +00:00
|
|
|
|
if (classInheritsFromNSMutableAttributedString (_class))
|
|
|
|
|
{
|
|
|
|
|
RETAIN (result);
|
|
|
|
|
AUTORELEASE (result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return AUTORELEASE ([[_class alloc] initWithAttributedString: result]);
|
|
|
|
|
}
|
2000-06-16 17:00:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-15 22:18:01 +00:00
|
|
|
|
- (void) appendString: (NSString*)string
|
|
|
|
|
{
|
|
|
|
|
int oldPosition = [result length];
|
|
|
|
|
int textlen = [string length];
|
|
|
|
|
NSRange insertionRange = NSMakeRange(oldPosition,0);
|
|
|
|
|
NSMutableDictionary *attributes;
|
|
|
|
|
|
|
|
|
|
if (!ignore && textlen)
|
|
|
|
|
{
|
|
|
|
|
RTFAttribute* attr = [self attr];
|
|
|
|
|
[result replaceCharactersInRange: insertionRange
|
|
|
|
|
withString: string];
|
|
|
|
|
|
|
|
|
|
if (attr->changed)
|
|
|
|
|
{
|
|
|
|
|
NSParagraphStyle *ps = [attr->paragraph copy];
|
|
|
|
|
attributes = [[NSMutableDictionary alloc]
|
|
|
|
|
initWithObjectsAndKeys:
|
|
|
|
|
[attr currentFont], NSFontAttributeName,
|
|
|
|
|
ps, NSParagraphStyleAttributeName,
|
|
|
|
|
nil];
|
|
|
|
|
DESTROY(ps);
|
|
|
|
|
if (attr->underline)
|
|
|
|
|
{
|
|
|
|
|
[attributes setObject: [attr underline]
|
|
|
|
|
forKey: NSUnderlineStyleAttributeName];
|
|
|
|
|
}
|
|
|
|
|
if (attr->script)
|
|
|
|
|
{
|
|
|
|
|
[attributes setObject: [attr script]
|
|
|
|
|
forKey: NSSuperscriptAttributeName];
|
|
|
|
|
}
|
|
|
|
|
if (attr->fgColour != nil)
|
|
|
|
|
{
|
|
|
|
|
[attributes setObject: attr->fgColour
|
|
|
|
|
forKey: NSForegroundColorAttributeName];
|
|
|
|
|
}
|
|
|
|
|
if (attr->bgColour != nil)
|
|
|
|
|
{
|
|
|
|
|
[attributes setObject: attr->bgColour
|
|
|
|
|
forKey: NSBackgroundColorAttributeName];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[result setAttributes: attributes
|
|
|
|
|
range: NSMakeRange(oldPosition, textlen)];
|
|
|
|
|
DESTROY(attributes);
|
|
|
|
|
attr->changed = NO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2001-07-30 21:30:51 +00:00
|
|
|
|
#undef IGNORE
|
2002-06-11 13:57:38 +00:00
|
|
|
|
#define FONTS ((RTFConsumer *)ctxt)->fonts
|
|
|
|
|
#define COLOURS ((RTFConsumer *)ctxt)->colours
|
|
|
|
|
#define RESULT ((RTFConsumer *)ctxt)->result
|
|
|
|
|
#define IGNORE ((RTFConsumer *)ctxt)->ignore
|
|
|
|
|
#define TEXTPOSITION [RESULT length]
|
2000-06-16 17:00:17 +00:00
|
|
|
|
#define DOCUMENTATTRIBUTES ((RTFConsumer*)ctxt)->documentAttributes
|
|
|
|
|
|
2006-05-11 21:03:21 +00:00
|
|
|
|
#define FILES ((RTFDConsumer*)ctxt)->files
|
|
|
|
|
|
2002-06-11 13:57:38 +00:00
|
|
|
|
#define CTXT [((RTFConsumer *)ctxt) attr]
|
|
|
|
|
#define CHANGED CTXT->changed
|
|
|
|
|
#define PARAGRAPH CTXT->paragraph
|
|
|
|
|
#define FONTNAME CTXT->fontName
|
|
|
|
|
#define SCRIPT CTXT->script
|
|
|
|
|
#define ITALIC CTXT->italic
|
|
|
|
|
#define BOLD CTXT->bold
|
|
|
|
|
#define UNDERLINE CTXT->underline
|
|
|
|
|
#define FGCOLOUR CTXT->fgColour
|
|
|
|
|
#define BGCOLOUR CTXT->bgColour
|
2000-06-16 17:00:17 +00:00
|
|
|
|
|
|
|
|
|
#define PAPERSIZE @"PaperSize"
|
|
|
|
|
#define LEFTMARGIN @"LeftMargin"
|
|
|
|
|
#define RIGHTMARGIN @"RightMargin"
|
|
|
|
|
#define TOPMARGIN @"TopMargin"
|
|
|
|
|
#define BUTTOMMARGIN @"ButtomMargin"
|
2000-04-23 22:28:46 +00:00
|
|
|
|
|
2000-06-17 17:53:14 +00:00
|
|
|
|
/*
|
|
|
|
|
we must implement from the rtfConsumerFunctions.h file (Supporting files)
|
|
|
|
|
this includes the yacc error handling and output
|
|
|
|
|
*/
|
|
|
|
|
|
2000-04-23 22:28:46 +00:00
|
|
|
|
/* handle errors (this is the yacc error mech) */
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFerror (const char *msg)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2003-04-07 10:02:47 +00:00
|
|
|
|
/* [NSException raise:NSInvalidArgumentException
|
|
|
|
|
format:@"Syntax error in RTF: %s", msg];*/
|
|
|
|
|
NSDebugLLog(@"RTFParser",@"Syntax error in RTF: %s", msg);
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFgenericRTFcommand (void *ctxt, RTFcmd cmd)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-06-17 17:53:14 +00:00
|
|
|
|
NSDebugLLog(@"RTFParser", @"encountered rtf cmd:%s", cmd.name);
|
|
|
|
|
if (!cmd.isEmpty)
|
|
|
|
|
NSDebugLLog(@"RTFParser", @" argument is %d\n", cmd.parameter);
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Start: we're doing some initialization
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFstart (void *ctxt)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-06-24 22:10:09 +00:00
|
|
|
|
NSDebugLLog(@"RTFParser", @"Start RTF parsing");
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Finished to parse one piece of RTF.
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFstop (void *ctxt)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
|
|
|
|
//<!> close all open bolds et al.
|
2000-06-24 22:10:09 +00:00
|
|
|
|
NSDebugLLog(@"RTFParser", @"End RTF parsing");
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFopenBlock (void *ctxt, BOOL ignore)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (!IGNORE)
|
2001-07-25 09:43:15 +00:00
|
|
|
|
{
|
|
|
|
|
[(RTFConsumer *)ctxt push];
|
|
|
|
|
}
|
2000-06-16 17:00:17 +00:00
|
|
|
|
// Switch off any output for ignored block statements
|
|
|
|
|
if (ignore)
|
2001-07-25 09:43:15 +00:00
|
|
|
|
{
|
|
|
|
|
IGNORE++;
|
|
|
|
|
}
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFcloseBlock (void *ctxt, BOOL ignore)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (ignore)
|
2001-07-25 09:43:15 +00:00
|
|
|
|
{
|
|
|
|
|
IGNORE--;
|
|
|
|
|
}
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (!IGNORE)
|
2000-06-24 22:10:09 +00:00
|
|
|
|
{
|
|
|
|
|
[(RTFConsumer *)ctxt pop];
|
|
|
|
|
}
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFmangleText (void *ctxt, const char *text)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2003-07-15 22:18:01 +00:00
|
|
|
|
NSData *data = [[NSData alloc] initWithBytes: (void*)text
|
|
|
|
|
length: strlen(text)];
|
|
|
|
|
NSString *str = [[NSString alloc] initWithData: data
|
|
|
|
|
encoding: NSISOLatin1StringEncoding];
|
2000-04-23 22:28:46 +00:00
|
|
|
|
|
2003-07-15 22:18:01 +00:00
|
|
|
|
[(RTFConsumer *)ctxt appendString: str];
|
|
|
|
|
DESTROY(str);
|
|
|
|
|
DESTROY(data);
|
|
|
|
|
}
|
2003-04-07 10:02:47 +00:00
|
|
|
|
|
2003-07-15 22:18:01 +00:00
|
|
|
|
void GSRTFunicode (void *ctxt, int uchar)
|
|
|
|
|
{
|
|
|
|
|
unichar chars = uchar;
|
|
|
|
|
NSString *str = [[NSString alloc] initWithCharacters: &chars
|
|
|
|
|
length: 1];
|
|
|
|
|
[(RTFConsumer *)ctxt appendString: str];
|
|
|
|
|
DESTROY(str);
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFregisterFont (void *ctxt, const char *fontName,
|
|
|
|
|
RTFfontFamily family, int fontNumber)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
|
|
|
|
NSString *fontNameString;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
NSNumber *fontId = [NSNumber numberWithInt: fontNumber];
|
2002-06-11 13:57:38 +00:00
|
|
|
|
|
2000-04-23 22:28:46 +00:00
|
|
|
|
if (!fontName || !*fontName)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-06-17 17:53:14 +00:00
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
|
format: @"Error in RTF (font omitted?), position:%d",
|
2000-06-16 17:00:17 +00:00
|
|
|
|
TEXTPOSITION];
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
2000-04-23 22:28:46 +00:00
|
|
|
|
// exclude trailing ';' from fontName
|
2002-11-24 01:05:58 +00:00
|
|
|
|
if (';' == fontName[strlen(fontName)-1])
|
|
|
|
|
{
|
|
|
|
|
fontNameString = [NSString stringWithCString: fontName
|
|
|
|
|
length: strlen(fontName)-1];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fontNameString = [NSString stringWithCString: fontName
|
|
|
|
|
length: strlen(fontName)];
|
|
|
|
|
}
|
2000-04-23 22:28:46 +00:00
|
|
|
|
[FONTS setObject: fontNameString forKey: fontId];
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFfontNumber (void *ctxt, int fontNumber)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-04-23 22:28:46 +00:00
|
|
|
|
NSNumber *fontId = [NSNumber numberWithInt: fontNumber];
|
|
|
|
|
NSString *fontName = [FONTS objectForKey: fontId];
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
2000-04-23 22:28:46 +00:00
|
|
|
|
if (fontName == nil)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-04-23 22:28:46 +00:00
|
|
|
|
/* we're about to set an unknown font */
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
|
format: @"Error in RTF (referring to undefined font \\f%d), position:%d",
|
1999-12-16 22:56:45 +00:00
|
|
|
|
fontNumber,
|
2000-06-16 17:00:17 +00:00
|
|
|
|
TEXTPOSITION];
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (![fontName isEqual: FONTNAME])
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
ASSIGN(FONTNAME, fontName);
|
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <N> fontSize is in halfpoints according to spec
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFfontSize (void *ctxt, int fontSize)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-04-23 22:28:46 +00:00
|
|
|
|
float size = halfpoints2points(fontSize);
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (size != CTXT->fontSize)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
CTXT->fontSize = size;
|
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFpaperWidth (void *ctxt, int width)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
float fwidth = twips2points(width);
|
|
|
|
|
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
|
|
|
|
NSValue *val = [dict objectForKey: PAPERSIZE];
|
|
|
|
|
NSSize size;
|
|
|
|
|
|
|
|
|
|
if (val == nil)
|
2001-07-25 09:43:15 +00:00
|
|
|
|
{
|
|
|
|
|
size = NSMakeSize(fwidth, 792);
|
|
|
|
|
}
|
2000-06-16 17:00:17 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
size = [val sizeValue];
|
|
|
|
|
size.width = fwidth;
|
|
|
|
|
}
|
2001-07-25 09:43:15 +00:00
|
|
|
|
[dict setObject: [NSValue valueWithSize: size] forKey: PAPERSIZE];
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFpaperHeight (void *ctxt, int height)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
float fheight = twips2points(height);
|
|
|
|
|
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
|
|
|
|
NSValue *val = [dict objectForKey: PAPERSIZE];
|
|
|
|
|
NSSize size;
|
|
|
|
|
|
|
|
|
|
if (val == nil)
|
2001-07-25 09:43:15 +00:00
|
|
|
|
{
|
|
|
|
|
size = NSMakeSize(612, fheight);
|
|
|
|
|
}
|
2000-06-16 17:00:17 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
size = [val sizeValue];
|
|
|
|
|
size.height = fheight;
|
|
|
|
|
}
|
2001-07-25 09:43:15 +00:00
|
|
|
|
[dict setObject: [NSValue valueWithSize: size] forKey: PAPERSIZE];
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFmarginLeft (void *ctxt, int margin)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
float fmargin = twips2points(margin);
|
|
|
|
|
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
[dict setObject: [NSNumber numberWithFloat: fmargin] forKey: LEFTMARGIN];
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFmarginRight (void *ctxt, int margin)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
float fmargin = twips2points(margin);
|
|
|
|
|
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
[dict setObject: [NSNumber numberWithFloat: fmargin] forKey: RIGHTMARGIN];
|
2000-06-16 17:00:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFmarginTop (void *ctxt, int margin)
|
2000-06-16 17:00:17 +00:00
|
|
|
|
{
|
|
|
|
|
float fmargin = twips2points(margin);
|
|
|
|
|
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
[dict setObject: [NSNumber numberWithFloat: fmargin] forKey: TOPMARGIN];
|
2000-06-16 17:00:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFmarginButtom (void *ctxt, int margin)
|
2000-06-16 17:00:17 +00:00
|
|
|
|
{
|
|
|
|
|
float fmargin = twips2points(margin);
|
|
|
|
|
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
[dict setObject: [NSNumber numberWithFloat: fmargin] forKey: BUTTOMMARGIN];
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFfirstLineIndent (void *ctxt, int indent)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
|
|
|
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
|
|
|
|
float findent = twips2points(indent);
|
|
|
|
|
|
2003-02-13 00:16:12 +00:00
|
|
|
|
CTXT->real_fi = findent;
|
|
|
|
|
|
|
|
|
|
findent = CTXT->real_li + CTXT->real_fi;
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
// for attributed strings only positiv indent is allowed
|
|
|
|
|
if ((findent >= 0.0) && ([para firstLineHeadIndent] != findent))
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-04-23 22:28:46 +00:00
|
|
|
|
[para setFirstLineHeadIndent: findent];
|
2000-06-16 17:00:17 +00:00
|
|
|
|
CHANGED = YES;
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFleftIndent (void *ctxt, int indent)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-04-23 22:28:46 +00:00
|
|
|
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
|
|
|
|
float findent = twips2points(indent);
|
|
|
|
|
|
2003-02-13 00:16:12 +00:00
|
|
|
|
CTXT->real_li = findent;
|
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
// for attributed strings only positiv indent is allowed
|
|
|
|
|
if ((findent >= 0.0) && ([para headIndent] != findent))
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
|
|
|
|
[para setHeadIndent: findent];
|
2000-06-16 17:00:17 +00:00
|
|
|
|
CHANGED = YES;
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
2003-02-13 00:16:12 +00:00
|
|
|
|
|
|
|
|
|
findent = CTXT->real_li + CTXT->real_fi;
|
|
|
|
|
if ((findent >= 0.0) && ([para firstLineHeadIndent] != findent))
|
|
|
|
|
{
|
|
|
|
|
[para setFirstLineHeadIndent: findent];
|
|
|
|
|
CHANGED = YES;
|
|
|
|
|
}
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFrightIndent (void *ctxt, int indent)
|
2000-06-17 17:53:14 +00:00
|
|
|
|
{
|
|
|
|
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
|
|
|
|
float findent = twips2points(indent);
|
|
|
|
|
|
|
|
|
|
// for attributed strings only positiv indent is allowed
|
|
|
|
|
if ((findent >= 0.0) && ([para tailIndent] != findent))
|
|
|
|
|
{
|
2003-02-13 00:16:12 +00:00
|
|
|
|
[para setTailIndent: -findent];
|
2000-06-17 17:53:14 +00:00
|
|
|
|
CHANGED = YES;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFtabstop (void *ctxt, int location)
|
2000-06-17 17:53:14 +00:00
|
|
|
|
{
|
|
|
|
|
float flocation = twips2points(location);
|
|
|
|
|
|
2000-06-24 22:10:09 +00:00
|
|
|
|
if (flocation >= 0.0)
|
2000-06-17 17:53:14 +00:00
|
|
|
|
{
|
2000-06-24 22:10:09 +00:00
|
|
|
|
[CTXT addTab: flocation type: NSLeftTabStopType];
|
2000-06-17 17:53:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFalignCenter (void *ctxt)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-04-23 22:28:46 +00:00
|
|
|
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
|
|
|
|
|
|
|
|
|
if ([para alignment] != NSCenterTextAlignment)
|
|
|
|
|
{
|
|
|
|
|
[para setAlignment: NSCenterTextAlignment];
|
2000-06-16 17:00:17 +00:00
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFalignJustified (void *ctxt)
|
2000-06-24 22:10:09 +00:00
|
|
|
|
{
|
|
|
|
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
|
|
|
|
|
|
|
|
|
if ([para alignment] != NSJustifiedTextAlignment)
|
|
|
|
|
{
|
|
|
|
|
[para setAlignment: NSJustifiedTextAlignment];
|
|
|
|
|
CHANGED = YES;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFalignLeft (void *ctxt)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
{
|
2000-04-23 22:28:46 +00:00
|
|
|
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
|
|
|
|
|
|
|
|
|
if ([para alignment] != NSLeftTextAlignment)
|
|
|
|
|
{
|
|
|
|
|
[para setAlignment: NSLeftTextAlignment];
|
2000-06-16 17:00:17 +00:00
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFalignRight (void *ctxt)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
|
|
|
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
|
|
|
|
|
|
|
|
|
if ([para alignment] != NSRightTextAlignment)
|
|
|
|
|
{
|
|
|
|
|
[para setAlignment: NSRightTextAlignment];
|
2000-06-16 17:00:17 +00:00
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFspaceAbove (void *ctxt, int space)
|
2000-06-24 22:10:09 +00:00
|
|
|
|
{
|
|
|
|
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
|
|
|
|
float fspace = twips2points(space);
|
|
|
|
|
|
|
|
|
|
if (fspace >= 0.0)
|
|
|
|
|
{
|
|
|
|
|
[para setParagraphSpacing: fspace];
|
2003-02-18 18:59:03 +00:00
|
|
|
|
CHANGED = YES;
|
2000-06-24 22:10:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFlineSpace (void *ctxt, int space)
|
2000-06-24 22:10:09 +00:00
|
|
|
|
{
|
|
|
|
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
|
|
|
|
float fspace = twips2points(space);
|
|
|
|
|
|
|
|
|
|
if (space == 1000)
|
|
|
|
|
{
|
|
|
|
|
[para setMinimumLineHeight: 0.0];
|
|
|
|
|
[para setMaximumLineHeight: 0.0];
|
2003-02-18 18:59:03 +00:00
|
|
|
|
CHANGED = YES;
|
2000-06-24 22:10:09 +00:00
|
|
|
|
}
|
|
|
|
|
else if (fspace < 0.0)
|
|
|
|
|
{
|
|
|
|
|
[para setMaximumLineHeight: -fspace];
|
2003-02-18 18:59:03 +00:00
|
|
|
|
CHANGED = YES;
|
2000-06-24 22:10:09 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[para setMinimumLineHeight: fspace];
|
2003-02-18 18:59:03 +00:00
|
|
|
|
CHANGED = YES;
|
2000-06-24 22:10:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFdefaultParagraph (void *ctxt)
|
2000-06-17 17:53:14 +00:00
|
|
|
|
{
|
|
|
|
|
[CTXT resetParagraphStyle];
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFstyle (void *ctxt, int style)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFdefaultCharacterStyle (void *ctxt)
|
2000-06-24 22:10:09 +00:00
|
|
|
|
{
|
|
|
|
|
[CTXT resetFont];
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFaddColor (void *ctxt, int red, int green, int blue)
|
2000-06-16 17:00:17 +00:00
|
|
|
|
{
|
|
|
|
|
NSColor *colour = [NSColor colorWithCalibratedRed: red/255.0
|
|
|
|
|
green: green/255.0
|
|
|
|
|
blue: blue/255.0
|
|
|
|
|
alpha: 1.0];
|
|
|
|
|
|
|
|
|
|
[COLOURS addObject: colour];
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFaddDefaultColor (void *ctxt)
|
2000-06-16 17:00:17 +00:00
|
|
|
|
{
|
|
|
|
|
[COLOURS addObject: [NSColor textColor]];
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFcolorbg (void *ctxt, int color)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2003-07-15 22:18:01 +00:00
|
|
|
|
if ([COLOURS count] <= (unsigned int)color)
|
2001-08-11 17:51:02 +00:00
|
|
|
|
{
|
|
|
|
|
ASSIGN (BGCOLOUR, [NSColor whiteColor]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ASSIGN (BGCOLOUR, [COLOURS objectAtIndex: color]);
|
|
|
|
|
}
|
2003-02-18 18:59:03 +00:00
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFcolorfg (void *ctxt, int color)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2003-07-15 22:18:01 +00:00
|
|
|
|
if ([COLOURS count] <= (unsigned int)color)
|
2001-08-11 17:51:02 +00:00
|
|
|
|
{
|
|
|
|
|
ASSIGN (FGCOLOUR, [NSColor blackColor]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ASSIGN (FGCOLOUR, [COLOURS objectAtIndex: color]);
|
|
|
|
|
}
|
2003-02-18 18:59:03 +00:00
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFsubscript (void *ctxt, int script)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-05-07 22:25:34 +00:00
|
|
|
|
script = (int) (-halfpoints2points(script) / 3.0);
|
2000-04-23 22:28:46 +00:00
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (script != SCRIPT)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
SCRIPT = script;
|
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFsuperscript (void *ctxt, int script)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-05-07 22:25:34 +00:00
|
|
|
|
script = (int) (halfpoints2points(script) / 3.0);
|
2000-04-23 22:28:46 +00:00
|
|
|
|
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (script != SCRIPT)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
SCRIPT = script;
|
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
1999-12-16 22:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFitalic (void *ctxt, BOOL state)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (state != ITALIC)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
ITALIC = state;
|
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFbold (void *ctxt, BOOL state)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (state != BOLD)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
BOLD = state;
|
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFunderline (void *ctxt, BOOL state)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
if (state != UNDERLINE)
|
2000-04-23 22:28:46 +00:00
|
|
|
|
{
|
2000-06-16 17:00:17 +00:00
|
|
|
|
UNDERLINE = state;
|
|
|
|
|
CHANGED = YES;
|
2000-04-23 22:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 09:43:15 +00:00
|
|
|
|
void GSRTFparagraph (void *ctxt)
|
2000-06-24 22:10:09 +00:00
|
|
|
|
{
|
|
|
|
|
GSRTFmangleText(ctxt, "\n");
|
|
|
|
|
CTXT->tabChanged = NO;
|
|
|
|
|
}
|
2006-05-11 21:03:21 +00:00
|
|
|
|
|
|
|
|
|
void GSRTFNeXTGraphic (void *ctxt, const char *fileName, int width, int height)
|
|
|
|
|
{
|
|
|
|
|
[(RTFDConsumer *)ctxt appendImage: [NSString stringWithCString: fileName]];
|
|
|
|
|
}
|
|
|
|
|
|