1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include <precomp.h>
23 #include <toolkit/hf_navi_main.hxx>
24 
25 
26 // NOT FULLY DEFINED SERVICES
27 #include <cosv/tpl/tpltools.hxx>
28 
29 
30 
31 //********************    MainItem and derived ones      ***************//
32 class HF_MainItem : public HtmlMaker
33 {
34   public:
~HF_MainItem()35     virtual             ~HF_MainItem() {}
Produce_Item() const36     void                Produce_Item() const    { do_ProduceItem(); }
37   protected:
HF_MainItem(Xml::Element & o_out)38                         HF_MainItem(
39                             Xml::Element &      o_out )
40                                                 :   HtmlMaker(o_out) {}
41   private:
42     virtual void        do_ProduceItem() const = 0;
43 };
44 
45 
46 namespace
47 {
48 
49 class StdItem : public HF_MainItem
50 {
51   public:
52                         StdItem(
53                             Xml::Element &      o_out,
54                             const char *        i_sText,
55                             const char *        i_sLink );
56 
57                         ~StdItem();
58   private:
59     virtual void        do_ProduceItem() const;
60 
61     // DATA
62     String              sText;
63     String              sLink;
64 };
65 
66 class SelfItem : public HF_MainItem
67 {
68   public:
69                         SelfItem(
70                             Xml::Element &      o_out,
71                             const char *        i_sText );
72                         ~SelfItem();
73   private:
74     virtual void        do_ProduceItem() const;
75 
76     // DATA
77     String              sText;
78 };
79 
80 class NoneItem : public HF_MainItem
81 {
82   public:
83                         NoneItem(
84                             Xml::Element &      o_out,
85                             const char *        i_sText );
86                         ~NoneItem();
87   private:
88     virtual void        do_ProduceItem() const;
89 
90     // DATA
91     String              sText;
92 };
93 
94 }   // anonymous namespace
95 
96 
97 
98 //********************    HF_NaviMainRow      ***************//
99 
100 
101 
HF_NaviMainRow(Xml::Element & o_out)102 HF_NaviMainRow::HF_NaviMainRow( Xml::Element & o_out )
103     :   HtmlMaker(o_out),
104         aItems(),
105         pRow(0)
106 {
107     aItems.reserve(5);
108 
109     pRow =
110     &(  CurOut()
111         >> *new Html::Table
112            << new Html::ClassAttr("navimain")
113            << new Xml::AnAttribute( "border", "0" )
114            << new Xml::AnAttribute( "cellpadding", "3" )
115            >> *new Html::TableRow
116      );
117 }
118 
~HF_NaviMainRow()119 HF_NaviMainRow::~HF_NaviMainRow()
120 {
121     csv::erase_container_of_heap_ptrs(aItems);
122 }
123 
124 void
Add_StdItem(const char * i_sText,const char * i_sLink)125 HF_NaviMainRow::Add_StdItem( const char * i_sText,
126                              const char * i_sLink )
127 {
128     aItems.push_back(new StdItem( *pRow,i_sText,i_sLink ));
129 }
130 
131 void
Add_SelfItem(const char * i_sText)132 HF_NaviMainRow::Add_SelfItem( const char * i_sText )
133 {
134     aItems.push_back(new SelfItem( *pRow,i_sText ));
135 }
136 
137 void
Add_NoneItem(const char * i_sText)138 HF_NaviMainRow::Add_NoneItem( const char * i_sText )
139 {
140     aItems.push_back(new NoneItem( *pRow,i_sText ));
141 }
142 
143 void
Produce_Row()144 HF_NaviMainRow::Produce_Row()
145 {
146     ItemList::iterator itEnd = aItems.end();
147     for ( ItemList::iterator iter = aItems.begin();
148           iter != itEnd;
149           ++iter )
150     {
151      	(*iter)->Produce_Item();
152     }
153 }
154 
155 
156 
157 
158 //********************    MainItem and derived ones      ***************//
159 
160 namespace
161 {
162 
StdItem(Xml::Element & o_out,const char * i_sText,const char * i_sLink)163 StdItem::StdItem( Xml::Element &      o_out,
164                   const char *        i_sText,
165                   const char *        i_sLink )
166     :   HF_MainItem(o_out),
167         sText(i_sText),
168         sLink(i_sLink)
169 {
170 }
171 
~StdItem()172 StdItem::~StdItem()
173 {
174 }
175 
176 void
do_ProduceItem() const177 StdItem::do_ProduceItem() const
178 {
179     Xml::Element &
180                 rCell = CurOut() >>* new Html::TableCell;
181     rCell
182         << new Html::ClassAttr( "navimain" )
183         >> *new Html::Link(sLink.c_str())
184             << new Html::ClassAttr( "navimain" )
185             << sText.c_str();
186 }
187 
SelfItem(Xml::Element & o_out,const char * i_sText)188 SelfItem::SelfItem( Xml::Element &      o_out,
189                     const char *        i_sText )
190     :   HF_MainItem(o_out),
191         sText(i_sText)
192 {
193 }
194 
~SelfItem()195 SelfItem::~SelfItem()
196 {
197 }
198 
199 void
do_ProduceItem() const200 SelfItem::do_ProduceItem() const
201 {
202     Xml::Element &
203                 rCell = CurOut() >>* new Html::TableCell;
204     rCell
205         << new Html::ClassAttr( "navimainself" )
206         << sText.c_str();
207 }
208 
NoneItem(Xml::Element & o_out,const char * i_sText)209 NoneItem::NoneItem( Xml::Element &      o_out,
210                     const char *        i_sText )
211     :   HF_MainItem(o_out),
212         sText(i_sText)
213 {
214 }
215 
~NoneItem()216 NoneItem::~NoneItem()
217 {
218 }
219 
220 void
do_ProduceItem() const221 NoneItem::do_ProduceItem() const
222 {
223     Xml::Element &
224                 rCell = CurOut() >>* new Html::TableCell;
225     rCell
226         << new Html::ClassAttr( "navimainnone" )
227         << sText.c_str();
228 }
229 
230 }   // anonymous namespace
231 
232 
233