]> err.no Git - scalable-opengroupware.org/blob - UI/Common/UIxElemBuilder.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1108 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / Common / UIxElemBuilder.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
6   OGo 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
9   later version.
10
11   OGo 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.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include <NGObjWeb/WOxElemBuilder.h>
24
25 /*
26   This builder builds various elements from the UI-X product.
27
28   All tags are mapped into the <uix:> namespace (XMLNS_OD_BIND).
29
30     <var:tabview   .../>    maps to UIxTabView
31     <var:tab       .../>    maps to UIxTabItem
32 */
33
34 @interface UIxElemBuilder : WOxTagClassElemBuilder
35 {
36 }
37
38 @end
39
40 #include <SaxObjC/XMLNamespaces.h>
41 #include "common.h"
42
43 #define XMLNS_UIX @"OGo:uix"
44
45
46 @implementation UIxElemBuilder
47
48 - (Class)classForElement:(id<DOMElement>)_element {
49   NSString *tagName;
50   unsigned tl;
51   unichar c1;
52   
53   if (![[_element namespaceURI] isEqualToString:XMLNS_UIX])
54     return Nil;
55
56   tagName = [_element tagName];
57   if ((tl = [tagName length]) < 2)
58     return Nil;
59
60   c1 = [tagName characterAtIndex:0];
61
62   switch (c1) {
63     case 't': { /* starting with 't' */
64       unichar c2;
65       
66       c2 = [tagName characterAtIndex:1];
67       
68       if (tl == 3 && c2 == 'a') {
69         if ([tagName characterAtIndex:2] == 'b')
70           return NSClassFromString(@"UIxTabItem");
71       }
72
73       if (tl > 5) {
74         if (c2 == 'a') {
75           if ([tagName isEqualToString:@"tabview"])
76             return NSClassFromString(@"UIxTabView");
77         }
78       }
79       break;
80     }
81   }
82   
83   return Nil;
84 }
85
86 @end /* UIxElemBuilder */