From: helge Date: Mon, 28 Mar 2005 14:54:04 +0000 (+0000) Subject: moved some classes out of WOComponentDefinition X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecaf7191aa8322cd9392ed961a8ff036be62fa4a;p=sope moved some classes out of WOComponentDefinition git-svn-id: http://svn.opengroupware.org/SOPE/trunk@702 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 58f2e9f4..9318fdff 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,9 @@ +2005-03-28 Helge Hess + + * WOComponentDefinition.m: moved WONoContentElement and + _WOStaticHTMLElement classes to own files in DynamicElements + (v4.5.144) + 2005-03-25 Helge Hess * WebDAV/SoObjectDataSource.m: fixed a small memory leak (v4.5.143) diff --git a/sope-appserver/NGObjWeb/DynamicElements/GNUmakefile b/sope-appserver/NGObjWeb/DynamicElements/GNUmakefile index 268d3785..0a73c0be 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/GNUmakefile +++ b/sope-appserver/NGObjWeb/DynamicElements/GNUmakefile @@ -53,6 +53,9 @@ DynamicElements_OBJC_FILES = \ WOVBScript.m \ WOEntity.m \ WOSetCursor.m \ + \ + WONoContentElement.m \ + _WOStaticHTMLElement.m \ DynamicElements_OBJC_FILES += \ _WOConstResourceImage.m \ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WONoContentElement.h b/sope-appserver/NGObjWeb/DynamicElements/WONoContentElement.h new file mode 100644 index 00000000..e6a8eadd --- /dev/null +++ b/sope-appserver/NGObjWeb/DynamicElements/WONoContentElement.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2000-2005 SKYRIX Software AG + + This file is part of SOPE. + + SOPE is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + SOPE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with SOPE; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#ifndef __NGObjWeb_WONoContentElement_H__ +#define __NGObjWeb_WONoContentElement_H__ + +#include + +/* + WONoContentElement + + This is a private element used by the WOComponentDefinition. +*/ + +@class NSString, NSArray, NSDictionary; +@class WOComponentDefinition; + +@interface WONoContentElement : WOElement +{ + WOComponentDefinition *cdef; + NSString *element; +} + +- (id)initWithElementName:(NSString *)_elementName + attributes:(NSDictionary *)_attributes + contentElements:(NSArray *)_subElements + componentDefinition:(WOComponentDefinition *)_cdef; + +@end + +#endif /* __NGObjWeb_WONoContentElement_H__ */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WONoContentElement.m b/sope-appserver/NGObjWeb/DynamicElements/WONoContentElement.m new file mode 100644 index 00000000..fa95763b --- /dev/null +++ b/sope-appserver/NGObjWeb/DynamicElements/WONoContentElement.m @@ -0,0 +1,53 @@ +/* + Copyright (C) 2000-2005 SKYRIX Software AG + + This file is part of SOPE. + + SOPE is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + SOPE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with SOPE; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#include "WONoContentElement.h" +#include +#include +#include "common.h" + +@implementation WONoContentElement + +- (id)initWithElementName:(NSString *)_elementName + attributes:(NSDictionary *)_attributes + contentElements:(NSArray *)_subElements + componentDefinition:(WOComponentDefinition *)_cdef +{ + self->cdef = [_cdef retain]; + self->element = [_elementName copy]; + return self; +} + +- (void)dealloc { + [self->cdef release]; + [self->element release]; + [super dealloc]; +} + +- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { + [_response appendContentHTMLString:@"<element]; + [_response appendContentHTMLString:@"' in component '"]; + [_response appendContentHTMLString:[self->cdef componentName]]; + [_response appendContentHTMLString:@"'>>"]; +} + +@end /* WONoContentElement */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/_WOStaticHTMLElement.h b/sope-appserver/NGObjWeb/DynamicElements/_WOStaticHTMLElement.h new file mode 100644 index 00000000..ac871e5e --- /dev/null +++ b/sope-appserver/NGObjWeb/DynamicElements/_WOStaticHTMLElement.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2000-2005 SKYRIX Software AG + + This file is part of SOPE. + + SOPE is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + SOPE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with SOPE; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#ifndef __DynamicElements__WOStaticHTMLElement_H__ +#define __DynamicElements__WOStaticHTMLElement_H__ + +#include + +/* + _WOStaticHTMLElement + + This element is used by the WOHTMLParser. +*/ + +@class NSString; + +@interface _WOStaticHTMLElement : WOElement +{ + NSString *text; +} + +// TODO: use Unicode? +- (id)initWithBuffer:(const char *)_buffer length:(unsigned)_len; + +@end + +#endif /* __DynamicElements__WOStaticHTMLElement_H__ */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/_WOStaticHTMLElement.m b/sope-appserver/NGObjWeb/DynamicElements/_WOStaticHTMLElement.m new file mode 100644 index 00000000..f98ad6a2 --- /dev/null +++ b/sope-appserver/NGObjWeb/DynamicElements/_WOStaticHTMLElement.m @@ -0,0 +1,53 @@ +/* + Copyright (C) 2000-2005 SKYRIX Software AG + + This file is part of SOPE. + + SOPE is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + SOPE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with SOPE; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#include "_WOStaticHTMLElement.h" +#include +#include "common.h" + +@implementation _WOStaticHTMLElement + +static Class StrClass = Nil; + ++ (void)initialize { + StrClass = [NSString class]; +} + +- (id)initWithBuffer:(const char *)_buffer length:(unsigned)_len { + self->text = (_len > 0) + ? [[StrClass alloc] initWithCString:_buffer length:_len] + : nil; + return self; +} + +- (void)dealloc { + [self->text release]; + [super dealloc]; +} + +/* generate response */ + +- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { + if (self->text != nil) + [_response appendContentString:self->text]; +} + +@end /* _WOStaticHTMLElement */ diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 3bd97516..7a1a2673 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=143 +SUBMINOR_VERSION:=144 # v4.5.122 requires libNGExtensions v4.5.153 # v4.5.91 requires libNGExtensions v4.5.134 diff --git a/sope-appserver/NGObjWeb/WOComponent.m b/sope-appserver/NGObjWeb/WOComponent.m index ab567889..734e1131 100644 --- a/sope-appserver/NGObjWeb/WOComponent.m +++ b/sope-appserver/NGObjWeb/WOComponent.m @@ -443,10 +443,10 @@ static inline id _getExtraVar(WOComponent *self, NSString *_key) { } - (void)setCachingEnabled:(BOOL)_flag { - self->componentFlags.reloadTemplates = _flag ? NO : YES; + self->componentFlags.reloadTemplates = _flag ? 0 : 1; } - (BOOL)isCachingEnabled { - return (self->componentFlags.reloadTemplates == NO) ? YES : NO; + return (!self->componentFlags.reloadTemplates) ? YES : NO; } - (WOComponent *)pageWithName:(NSString *)_name { @@ -683,7 +683,8 @@ static inline id _getExtraVar(WOComponent *self, NSString *_key) { - (WOElement *)_woComponentTemplate { WOElement *element; - if ((element = _getExtraVar(self, @"__wotemplate"))) + // TODO: move to ivar? + if ((element = _getExtraVar(self, @"__wotemplate")) != nil) return element; return [self templateWithName:[self name]]; diff --git a/sope-appserver/NGObjWeb/WOComponentDefinition.m b/sope-appserver/NGObjWeb/WOComponentDefinition.m index 1339f275..07b9bc47 100644 --- a/sope-appserver/NGObjWeb/WOComponentDefinition.m +++ b/sope-appserver/NGObjWeb/WOComponentDefinition.m @@ -22,6 +22,7 @@ #include #include "WOComponent+private.h" #include "WOComponentFault.h" +#include "WONoContentElement.h" #include #include #include @@ -44,24 +45,6 @@ static NSNumber *noNum = nil; - (void)setBaseURL:(id)_url; @end -@interface WONoContentElement : WOElement -{ - WOComponentDefinition *cdef; - NSString *element; -} -- (id)initWithElementName:(NSString *)_elementName - attributes:(NSDictionary *)_attributes - contentElements:(NSArray *)_subElements - componentDefinition:(WOComponentDefinition *)_cdef; -@end - -@interface _WOStaticHTMLElement : WOElement -{ - NSString *text; -} -- (id)initWithBuffer:(const char *)_buffer length:(unsigned)_len; -@end - @interface WOComponentDefinition(PrivateMethods) - (BOOL)load; @@ -417,7 +400,7 @@ static NSArray *woxExtensions = nil; [_component setBaseURL:self->baseUrl]; if (enableWOOFiles) { - if (self->template) { + if (self->template != nil) { [self _applyWOOVariables: [self->template keyValueArchivedTemplateVariables] onComponent:_component]; @@ -434,10 +417,9 @@ static NSArray *woxExtensions = nil; Class cClass; WOComponentScript *script; - if ((script = [self->template componentScript])) - cClass = NSClassFromString(@"WOScriptedComponent"); - else - cClass = [self componentClass]; + cClass = ((script = [self->template componentScript]) != nil) + ? NSClassFromString(@"WOScriptedComponent") + : [self componentClass]; if (cClass == nil) { NSString *tmpPath; @@ -582,53 +564,3 @@ static NSArray *woxExtensions = nil; } @end /* WOComponentDefinition */ - -@implementation WONoContentElement - -- (id)initWithElementName:(NSString *)_elementName - attributes:(NSDictionary *)_attributes - contentElements:(NSArray *)_subElements - componentDefinition:(WOComponentDefinition *)_cdef -{ - self->cdef = [_cdef retain]; - self->element = [_elementName copy]; - return self; -} - -- (void)dealloc { - [self->cdef release]; - [self->element release]; - [super dealloc]; -} - -- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { - [_response appendContentHTMLString:@"<element]; - [_response appendContentHTMLString:@"' in component '"]; - [_response appendContentHTMLString:[self->cdef componentName]]; - [_response appendContentHTMLString:@"'>>"]; -} - -@end /* WONoContentElement */ - -@implementation _WOStaticHTMLElement - -- (id)initWithBuffer:(const char *)_buffer length:(unsigned)_len { - if (StrClass == Nil) - StrClass = [NSString class]; - - self->text = [[StrClass alloc] initWithCString:_buffer length:_len]; - return self; -} - -- (void)dealloc { - [self->text release]; - [super dealloc]; -} - -- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { - if (self->text) - [_response appendContentString:self->text]; -} - -@end /* _WOStaticHTMLElement */