]> err.no Git - sope/blob - Recycler/NGObjDOM/ODNodeRendererFactory.m
renamed packages as discussed in the developer list
[sope] / Recycler / NGObjDOM / ODNodeRendererFactory.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 <NGObjDOM/ODNodeRendererFactory.h>
24 #include <NGObjDOM/ODRNodeText.h>
25 #include <NGObjDOM/ODRGenericTag.h>
26 #include "common.h"
27
28 @implementation ODNodeRendererFactory
29
30 + (int)version {
31   return 1;
32 }
33
34 - (ODNodeRenderer *)rendererForTextNode:(id)_domNode 
35   inContext:(WOContext *)_ctx
36 {
37   static id r = nil;
38   if (r == nil) r = [[ODRNodeText alloc] init];
39   return r;
40 }
41
42 - (ODNodeRenderer *)rendererForElementNode:(id)_domNode
43   inContext:(WOContext *)_ctx
44 {
45   static id r = nil;
46   if (r == nil) r = [[ODRGenericTag alloc] init];
47   return r;
48 }
49
50 - (ODNodeRenderer *)rendererForDocumentNode:(id)_domNode
51   inContext:(WOContext *)_ctx
52 {
53   static id r = nil;
54   if (r == nil) r = [[ODNodeRenderer alloc] init];
55   return r;
56 }
57 - (ODNodeRenderer *)rendererForDocumentFragmentNode:(id)_domNode
58   inContext:(WOContext *)_ctx
59 {
60   static id r = nil;
61   if (r == nil) r = [[ODNodeRenderer alloc] init];
62   return r;
63 }
64
65 - (ODNodeRenderer *)rendererForNode:(id)_domNode
66   inContext:(WOContext *)_ctx
67 {
68   ODNodeRenderer *renderer;
69   
70   switch ([_domNode nodeType]) {
71     case DOM_TEXT_NODE:
72     case DOM_CDATA_SECTION_NODE:
73       renderer = [self rendererForTextNode:_domNode inContext:_ctx];
74       break;
75       
76     case DOM_ELEMENT_NODE:
77       renderer = [self rendererForElementNode:_domNode inContext:_ctx];
78       break;
79
80     case DOM_DOCUMENT_NODE:
81       renderer = [self rendererForDocumentNode:_domNode inContext:_ctx];
82       break;
83       
84     case DOM_DOCUMENT_FRAGMENT_NODE:
85       renderer =
86         [self rendererForDocumentFragmentNode:_domNode inContext:_ctx];
87       break;
88       
89     default:
90       renderer = nil;
91       break;
92   }
93   return renderer;
94 }
95
96 @end /* ODNodeRendererFactory */