2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
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
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.
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
23 #ifndef __NGObjDOM_common_H__
24 #define __NGObjDOM_common_H__
26 #import <Foundation/Foundation.h>
28 #if NeXT_Foundation_LIBRARY || APPLE_FOUNDATION_LIBRARY
29 # include <NGExtensions/NGObjectMacros.h>
32 #include <NGExtensions/NGExtensions.h>
33 #include <NGObjWeb/NGObjWeb.h>
36 @class ODNodeRenderer;
38 @interface WOContext(ODNodeRenderPrivate)
39 - (void)addActiveFormElement:(ODNodeRenderer *)_element;
42 @interface DOMElement(ODNodeRenderPrivate)
43 - (id)lookupQueryPath:(NSString *)_queryPath;
47 static inline void ODRAppendFont(WOResponse *_resp,
52 [_resp appendContentString:@"<font"];
54 [_resp appendContentString:@" color=\""];
55 [_resp appendContentHTMLAttributeValue:_color];
56 [_resp appendContentCharacter:'"'];
59 [_resp appendContentString:@" face=\""];
60 [_resp appendContentHTMLAttributeValue:_face];
61 [_resp appendContentCharacter:'"'];
64 [_resp appendContentString:@" size=\""];
65 [_resp appendContentHTMLAttributeValue:_size];
66 [_resp appendContentCharacter:'"'];
68 [_resp appendContentCharacter:'>'];
71 static inline void ODRAppendTD(WOResponse *_resp,
77 [_resp appendContentString:@"<td"];
79 [_resp appendContentString:@" bgcolor=\""];
80 [_resp appendContentHTMLAttributeValue:_bgColor];
81 [_resp appendContentCharacter:'"'];
84 [_resp appendContentString:@" align=\""];
85 [_resp appendContentHTMLAttributeValue:_align];
86 [_resp appendContentCharacter:'"'];
89 [_resp appendContentString:@" valign=\""];
90 [_resp appendContentHTMLAttributeValue:_valign];
91 [_resp appendContentCharacter:'"'];
94 [_resp appendContentString:@" colspan=\""];
95 [_resp appendContentHTMLAttributeValue:_colspan];
96 [_resp appendContentCharacter:'"'];
98 [_resp appendContentCharacter:'>'];
101 static inline void ODRAppendButton(WOResponse *_response,
108 [_response appendContentHTMLString:(_alt) ? _alt : @"[button]"];
111 [_response appendContentString:@"<input border=\"0\" type=\""];
112 [_response appendContentString:(_src) ? @"image" : @"submit"];
113 [_response appendContentString:@"\" name=\""];
114 [_response appendContentString:_name];
115 [_response appendContentCharacter:'"'];
117 [_response appendContentString:@" src=\""];
118 [_response appendContentString:_src];
119 [_response appendContentCharacter:'"'];
122 [_response appendContentString:@" alt=\""];
123 [_response appendContentString:_alt];
124 [_response appendContentCharacter:'"'];
128 [_response appendContentString:@" value=\""];
129 [_response appendContentString:(_alt) ? _alt : @"submit"];
130 [_response appendContentCharacter:'"'];
132 [_response appendContentString:@" />"];
135 static inline void ODRAppendImage(WOResponse *_response,
141 [_response appendContentHTMLString:(_alt) ? _alt : @"[img]"];
145 [_response appendContentString:@"<img border=\"0\" src=\""];
146 [_response appendContentString:_src];
148 [_response appendContentString:@"\" name=\""];
149 [_response appendContentString:_name];
151 [_response appendContentString:@"\" alt=\""];
152 [_response appendContentString:_alt];
153 [_response appendContentString:@"\" />"];
157 static inline NSArray *ODRLookupQueryPath(id _node, NSString *_path) {
158 static Class arrayClass = Nil;
161 if (arrayClass == Nil)
162 arrayClass = [NSArray class];
164 if (!(tmp = [_node lookupQueryPath:_path]))
167 return ([tmp isKindOfClass:arrayClass])
169 : [arrayClass arrayWithObject:tmp];
172 static inline NSString *ODRUriOfResource(NSString *_name, WOContext *_ctx) {
174 WOResourceManager *resourceManager;
180 languages = [_ctx hasSession]
181 ? [[_ctx session] languages]
182 : [[_ctx request] browserLanguages];
184 if ((resourceManager = [[_ctx component] resourceManager]) == nil)
185 resourceManager = [[_ctx application] resourceManager];
187 uri = [resourceManager urlForResourceNamed:_name
190 request:[_ctx request]];
191 if ([uri rangeOfString:@"/missingresource?"].length > 0)
198 # define BEGIN_PROFILE \
199 { NSTimeInterval __ti = [[NSDate date] timeIntervalSince1970];
201 # define END_PROFILE \
202 __ti = [[NSDate date] timeIntervalSince1970] - __ti;\
204 printf("***PROF[%s]: %0.3fs\n", __PRETTY_FUNCTION__, __ti);\
205 else if (__ti > 0.005) \
206 printf("PROF[%s]: %0.3fs\n", __PRETTY_FUNCTION__, __ti);\
209 # define PROFILE_CHECKPOINT(__key__) \
210 printf("---PROF[%s] CP %s: %0.3fs\n", __PRETTY_FUNCTION__, __key__,\
211 [[NSDate date] timeIntervalSince1970] - __ti)
214 # define BEGIN_PROFILE {
215 # define END_PROFILE }
216 # define PROFILE_CHECKPOINT(__key__)
219 @interface NSObject(AttrNodeNSURI)
220 - (id)attributeNode:(NSString *)_name namespaceURI:(NSString *)_nsuri;
223 #endif /* __NGObjDOM_common_H__ */