2 Copyright (C) 2000-2005 SKYRIX Software AG
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 #include "WETreeMatrixElement.h"
25 @implementation _WETreeMatrixElement
27 static Class StrClass = Nil;
30 StrClass = [NSString class];
33 - (id)initWithElement:(_WETreeMatrixElement *)_element {
34 if ((self = [super init])) {
37 for (j = 0; j < MAX_TREE_DEPTH; j++)
38 self->elements[j] = 0;
43 self->depth = _element->depth + 1;
44 for (i = 0; i < self->depth; i++) {
45 self->leaf = _element->leaf;
46 self->elements[i] = [_element->elements[i] retain];
47 self->indexPath[i] = _element->indexPath[i];
48 self->itemPath[i] = [_element->itemPath[i] retain];
58 return [self initWithElement:nil];
64 for (i = 0; i < self->depth; i++) {
65 [self->itemPath[i] release];
66 [self->elements[i] release];
73 - (void)setElement:(NSString *)_element {
74 ASSIGN(self->elements[self->depth], _element);
76 - (NSString *)elementAtIndex:(int)_index {
77 return self->elements[_index];
80 - (void)setItem:(id)_item {
81 ASSIGN(self->itemPath[self->depth], _item);
84 return self->itemPath[self->depth-1];
87 - (void)setIndex:(int)_index {
88 self->indexPath[self->depth] = _index;
91 return self->indexPath[self->depth-1];
94 - (void)setLeaf:(NSString *)_leaf {
95 ASSIGN(self->leaf, _leaf);
101 - (void)setColspan:(int)_colspan {
102 self->colspan = _colspan;
105 - (NSString *)colspanAsString {
107 sprintf(buf, "%d", self->colspan);
108 return [NSString stringWithCString:buf];
115 - (NSArray *)currentPath {
116 NSMutableArray *result;
119 result = [NSMutableArray arrayWithCapacity:self->depth];
120 for (i = 0; i < self->depth+1; i++) {
121 if (self->itemPath[i] == nil)
123 [result addObject:self->itemPath[i]];
125 return (NSArray *)result;
128 - (NSString *)elementID {
129 // TODO: improve performance
134 tmp = [[NSMutableArray alloc] initWithCapacity:self->depth];
136 for (i = 0; i < self->depth; i++) {
137 s = [[StrClass alloc] initWithFormat:@"%d", self->indexPath[i]];
141 s = [tmp componentsJoinedByString:@"."];
146 @end /* _WETreeMatrixElement */