/* Copyright (C) 2004 eXtrapola Srl This file is part of OpenGroupware.org. OGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. OGo 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with OGo; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // $Id$ #error does not compile, just for reference! #include "StructuredText_XHTML.h" #include "common.h" @implementation StructuredTextRenderingDelegate_XHTML - (NSString *)insertText:(NSString *)_txt inContext:(NSDictionary *)_ctx { return [NSString stringWithFormat:@"
%@
", _txt]; } - (NSString *)insertItalics:(NSString *)_txt inContext:(NSDictionary *)_ctx { return [NSString stringWithFormat: @"%@", _txt]; } - (NSString *)insertUnderline:(NSString *)_txt inContext:(NSDictionary *)_ctx { return [NSString stringWithFormat: @"%@", _txt]; } - (NSString *)insertBold:(NSString *)_txt inContext:(NSDictionary *)_ctx { return [NSString stringWithFormat:@"%@", _txt]; } - (NSString *)insertPreformatted:(NSString *)_txt inContext:(NSDictionary *)_ctx { return [NSString stringWithFormat: @"%@", _txt]; } - (NSString *)insertLink:(NSString *)_txt withUrl:(NSString *)anUrl target:(NSString *)aTarget inContext:(NSDictionary *)_ctx { NSString *result; if ([aTarget length] > 0) { result = [NSString stringWithFormat: @"%@", anUrl, aTarget, _txt]; } else { result = [NSString stringWithFormat:@"%@", anUrl, _txt]; } return result; } - (NSString *)insertEmail:(NSString *)_txt withAddress:(NSString *)anAddress inContext:(NSDictionary *)_ctx { return [NSString stringWithFormat:@"%@", anAddress, _txt]; } - (NSString *)insertImage:(NSString *)_txt withUrl:(NSString *)anUrl inContext:(NSDictionary *)_ctx { return [NSString stringWithFormat:@"", anUrl, _txt]; } - (NSString *)insertExtrapolaLink:(NSString *)_txt parameters:(NSDictionary *)someParameters withTarget:(NSString *)aTarget inContext:(NSDictionary *)_ctx { NSString *result; NSString *targetString; if ([aTarget length] > 0) targetString = [NSString stringWithFormat:@" target = \"%@\"", aTarget]; else targetString = @""; result = [NSString stringWithFormat: @"%@", [someParameters objectForKey:@"page"], targetString, _txt]; return result; } - (NSString *)insertPreprocessedTextForKey:(NSString *)aKey inContext:(NSDictionary *)_ctx { return [_ctx objectForKey:aKey]; } @end /* StructuredTextRenderingDelegate_XHTML */ @implementation NSArray (StructuredText_XHTML) - (NSString *)toXhtmlInContext:(NSDictionary *)_ctx { NSMutableString *result; int i,c; c = [self count]; result = [NSMutableString stringWithCapacity:(c * 16)]; for (i = 0; i < c; i++) { id currentObject; currentObject = [self objectAtIndex:i]; [result appendString:[currentObject toXhtmlInContext:_ctx]]; } return result; } @end @implementation StructuredText(StructuredText_XHTML) - (NSString *)toXhtmlInContext:(NSDictionary *)_ctx { return [[self document] toXhtmlInContext:_ctx]; } @end /* StructuredText(StructuredText_XHTML) */ @implementation StructuredTextDocument(StructuredText_XHTML) - (NSString *)toXhtmlInContext:(NSDictionary *)_ctx { return [[self bodyElements] toXhtmlInContext:_ctx]; } @end /* StructuredTextDocument(StructuredText_XHTML) */ @implementation StructuredTextBodyElement(StructuredText_XHTML) - (NSString *)toXhtmlInContext:(NSDictionary *)_ctx { return [[self elements] toXhtmlInContext:_ctx]; } @end /* StructuredTextBodyElement(StructuredText_XHTML) */ @implementation StructuredTextHeader(StructuredText_XHTML) - (NSString *)toXhtmlInContext:(NSDictionary *)_ctx { NSMutableString *ms; id delegate; delegate = [StructuredTextRenderingDelegate_XHTML delegate] ; ms = [NSMutableString stringWithCapacity:64]; [ms appendFormat:@"