2 Copyright (C) 2004 eXtrapola Srl
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #import "StructuredLine.h"
25 @implementation StructuredLine
27 - (id)initWithString:(NSString *)aString level:(int)aLevel {
28 if ((self = [super init])) {
29 [self setText:aString];
36 [self->_text release];
37 [self->_originalText release];
44 NSMutableString *result;
51 result = [NSMutableString stringWithCapacity:16];
52 components = [_originalText componentsSeparatedByString:@"\n"];
53 count = [components count];
55 for (i = 0; i < count; i++) {
59 [result appendString:@" "];
61 s = [components objectAtIndex:i];
62 s = [s stringByTrimmingCharactersInSet:
63 [NSCharacterSet whitespaceCharacterSet]];
64 [result appendString:s];
67 self->_text = [result copy];
71 - (NSString *)originalText {
72 return self->_originalText;
75 - (void)setText:(NSString *)aString {
81 length = [aString length];
83 for (i = 0; i < length; i++) {
84 switch (([aString characterAtIndex:i])) {
104 self->_originalText = [aString retain];
107 [self->_text release]; self->_text = nil;
110 - (void)setLevel:(int)aLevel {
117 - (int)numberOfSpacesAtBeginning {
118 return numberOfSpaces;
121 @end /* StructuredLine */