]> err.no Git - sope/blob - sope-appserver/WEExtensions/WExDnDElemBuilder.m
new Xcode projects, removed old Xcode project
[sope] / sope-appserver / WEExtensions / WExDnDElemBuilder.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
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 drag&drop elements from the WEExtensions library.
27   Note that there are other builders for WEExtensions elements as well !!
28
29   All tags are mapped into the <var:> namespace (XMLNS_OD_BIND).
30
31   Supported tags:
32     <var:js-drag .../>      maps to WEDragContainer
33     <var:js-drop .../>      maps to WEDropContainer
34     <var:script-drag/>      maps to WEDragScript
35     <var:script-drop/>      maps to WEDropScript
36 */
37
38 @interface WExDnDElemBuilder : WOxTagClassElemBuilder
39 {
40 }
41
42 @end
43
44 #include <SaxObjC/XMLNamespaces.h>
45 #include "common.h"
46
47 @implementation WExDnDElemBuilder
48
49 - (Class)classForElement:(id<DOMElement>)_element {
50   NSString *tagName;
51   unsigned tl;
52   unichar c1;
53   
54   if (![[_element namespaceURI] isEqualToString:XMLNS_OD_BIND])
55     return Nil;
56   
57   tagName = [_element tagName];
58   if ((tl = [tagName length]) < 7)
59     return Nil;
60   
61   c1 = [tagName characterAtIndex:0];
62
63   switch (c1) {
64     case 'j': /* starting with 'j' */
65       if (tl == 7) {
66         if ([tagName hasPrefix:@"js-dr"]) {
67           if ([tagName isEqualToString:@"js-drag"])
68             return NSClassFromString(@"WEDragContainer");
69           if ([tagName isEqualToString:@"js-drop"])
70             return NSClassFromString(@"WEDropContainer");
71         }
72       }
73       break;
74       
75     case 's': /* starting with 's' */
76       if (tl == 11) {
77         if ([tagName hasPrefix:@"script-"]) {
78           if ([tagName isEqualToString:@"script-drag"])
79             return NSClassFromString(@"WEDragScript");
80           if ([tagName isEqualToString:@"script-drop"])
81             return NSClassFromString(@"WEDropScript");
82         }
83       }
84       break;
85   }
86   return Nil;
87 }
88
89 @end /* WExDnDElemBuilder */