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 "html_kit.hxx"
24 
25 
26 // NOT FULLY DEFINED SERVICES
27 #include <stdio.h>
28 #include <ary/cpp/c_slntry.hxx>
29 #include "hdimpl.hxx"
30 
31 
32 namespace adcdisp
33 {
34 
35 
36 using namespace csi::xml;
37 using namespace csi::html;
38 
39 
40 void
operator ()(XmlElement & o_rOwner,const char * i_sTypeTitle,const String & i_sLocalName)41 PageTitle_Left::operator()( XmlElement &        o_rOwner,
42                             const char *        i_sTypeTitle,
43                             const String &      i_sLocalName )
44 {
45     o_rOwner
46         >> *new Headline(2)
47             << i_sTypeTitle
48             << " "
49             << i_sLocalName;
50 }
51 
52 void
operator ()(XmlElement & o_rOwner,const char * i_sTypeTitle,const String & i_sLocalName)53 PageTitle_Std::operator()( XmlElement &         o_rOwner,
54                            const char *         i_sTypeTitle,
55                            const String &       i_sLocalName )
56 {
57     o_rOwner
58         >> *new AnElement("div")
59             << new ClassAttr("title")
60             >> *new Headline(2)
61                 << i_sTypeTitle
62                 << " "
63                 << i_sLocalName;
64 }
65 
66 XmlElement &
operator ()(XmlElement & o_rOwner)67 PageTitle_Std::operator()( XmlElement & o_rOwner )
68 {
69     XmlElement & ret =
70         o_rOwner
71             >> *new AnElement("div")
72                 << new ClassAttr("title")
73                 >> *new Headline(2);
74     return ret;
75 }
76 
77 void
operator ()(XmlElement & o_owner,const char * i_itemName,ary::cpp::Ce_id i_id,const::ary::cpp::Gate & i_gate)78 OperationTitle::operator()( XmlElement &                o_owner,
79                             const char *                i_itemName,
80                             ary::cpp::Ce_id             i_id,
81                             const ::ary::cpp::Gate &    i_gate )
82 {
83     o_owner
84         >> *new Label( OperationLabel(i_itemName, i_id, i_gate) )
85             << " ";
86     o_owner
87         << i_itemName;
88 }
89 
90 
91 void
operator ()(XmlElement & o_rOwner,const List_TplParams & i_rTplParams)92 TemplateClause::operator()( XmlElement &           o_rOwner,
93                             const List_TplParams & i_rTplParams )
94 {
95     if ( i_rTplParams.size() == 0 )
96         return;
97 
98     Element & rOut =
99         o_rOwner
100             << new LineBreak
101             >> *new Paragraph
102                 >> *new Strong
103                     << "template< ";
104 
105     List_TplParams::const_iterator
106         it      = i_rTplParams.begin();
107     List_TplParams::const_iterator
108         itEnd   = i_rTplParams.end();
109 
110     rOut
111         << (*it).Name();
112     for ( ++it; it != itEnd; ++it )
113     {
114         rOut
115             << ", "
116             << (*it).Name();
117     }  // end for
118   	rOut << " >";
119 }
120 
ExplanationList(XmlElement & o_rOwner,bool i_bMemberStyle)121 ExplanationList::ExplanationList( XmlElement & o_rOwner,
122                                   bool         i_bMemberStyle )
123     :   pList( new DefList),
124         pTerm(0),
125         pDefinition(0),
126         bMemberStyle(i_bMemberStyle)
127 {
128     if (bMemberStyle)
129         *pList << new ClassAttr("member");
130 
131     o_rOwner << pList;
132 }
133 
134 void
AddEntry(const char * i_sTerm,const char * i_sDifferentClass)135 ExplanationList::AddEntry( const char *        i_sTerm,
136                            const char *        i_sDifferentClass )
137 {
138     DefListTerm & rNewTerm = pList->AddTerm();
139     if ( i_sDifferentClass != 0 )
140     {
141         rNewTerm << new ClassAttr(i_sDifferentClass);
142     }
143     else if (bMemberStyle)
144     {
145         rNewTerm << new ClassAttr("member");
146     }
147     if ( i_sTerm != 0 )
148         rNewTerm << i_sTerm;
149 
150     pTerm = &rNewTerm;
151     pDefinition = &pList->AddDefinition();
152     if (bMemberStyle)
153         *pDefinition << new ClassAttr("member");
154 }
155 
156 void
AddEntry_NoTerm()157 ExplanationList::AddEntry_NoTerm()
158 {
159     pTerm = 0;
160     pDefinition = &pList->AddDefinition();
161     if (bMemberStyle)
162         *pDefinition << new ClassAttr("member");
163 }
164 
ExplanationTable(XmlElement & o_rOwner)165 ExplanationTable::ExplanationTable( XmlElement &    o_rOwner )
166     :   pTable(0),
167         pTerm(0),
168         pDefinition(0)
169 {
170     pTable = new Table("0", "100%", "3", "0");
171     *pTable << new AnAttribute("class", "expl-table");
172     o_rOwner << pTable;
173 }
174 
175 void
AddEntry(const char * i_sTerm,const char * i_sDifferentStyle)176 ExplanationTable::AddEntry( const char *        i_sTerm,
177                             const char *        i_sDifferentStyle )
178 {
179     TableRow &
180         rNewRow = pTable->AddRow();
181     TableCell &
182         rNewTerm = rNewRow.AddCell();
183     TableCell &
184         rNewDefinition = rNewRow.AddCell();
185 
186     if ( i_sDifferentStyle == 0 )
187     {
188         rNewTerm << new WidthAttr("15%")
189                  << new StyleAttr("vertical-align:top; font-weight:bold");
190     }
191     else
192     {
193         rNewTerm << new StyleAttr(i_sDifferentStyle);
194     }
195     if ( i_sTerm != 0 )
196         rNewTerm << i_sTerm;
197 
198     pTerm = &rNewTerm;
199     pDefinition = & (rNewDefinition >> *new APureElement("pre"));
200 }
201 
ParameterTable(XmlElement & o_rOwner)202 ParameterTable::ParameterTable( XmlElement &    o_rOwner )
203     :   pTable(0),
204         pTerm(0),
205         pDefinition(0)
206 {
207     pTable = new Table;
208     *pTable << new AnAttribute("class", "param-table");
209     o_rOwner << pTable;
210 }
211 
212 void
AddEntry()213 ParameterTable::AddEntry()
214 {
215     TableRow &
216         rNewRow = pTable->AddRow();
217     TableCell &
218         rNewTerm = rNewRow.AddCell();
219     TableCell &
220         rNewDefinition = rNewRow.AddCell();
221 
222     pTerm = &rNewTerm;
223     pDefinition = &rNewDefinition;
224 }
225 
FlagTable(XmlElement & o_rOwner,uintt i_nNrOfColumns)226 FlagTable::FlagTable( XmlElement &        o_rOwner,
227                       uintt               i_nNrOfColumns )
228 {
229     pTable = new Table;
230     *pTable << new AnAttribute("class", "flag-table");
231     *pTable << new AnAttribute("border", "1");
232     *pTable << new AnAttribute("cellspacing", "0");
233     o_rOwner << pTable;
234 
235     TableRow & rRow1 = pTable->AddRow();
236     TableRow & rRow2 = pTable->AddRow();
237 
238     for ( uintt c = 0; c < i_nNrOfColumns; ++c )
239     {
240         TableCell & rCell1 = rRow1.AddCell();
241         int nWidth = 100 / i_nNrOfColumns;
242         static char sWidth[20];
243         sprintf( sWidth, "%d%%", nWidth );      // SAFE SPRINTF (#100211# - checked)
244 
245         rCell1
246             << new WidthAttr( sWidth )
247             << new ClassAttr( "flagname" );
248         TableCell & rCell2 = rRow2.AddCell();
249         aCells.push_back( CellPair(&rCell1, &rCell2) );
250     }   // end for
251 }
252 
253 void
SetColumn(uintt i_nColumnPosition,const char * i_sColumnName,bool i_bValue)254 FlagTable::SetColumn( uintt               i_nColumnPosition,
255                       const char *        i_sColumnName,
256                       bool                i_bValue )
257 {
258     csv_assert( i_nColumnPosition < aCells.size() );
259 
260     TableCell &
261         rCell1 = *aCells[i_nColumnPosition].first;
262     TableCell &
263         rCell2 = *aCells[i_nColumnPosition].second;
264     rCell1
265         << i_sColumnName;
266     if (i_bValue)
267     {
268         rCell2
269             << new ClassAttr("flagyes")
270             << "YES";
271     }
272     else //
273     {
274         rCell2
275             << new ClassAttr("flagno")
276             << "NO";
277     }  // endif
278 }
279 
IndexList(XmlElement & o_rOwner)280 IndexList::IndexList( XmlElement & o_rOwner )
281     :   pList( new DefList ),
282         pTerm(0),
283         pDefinition(0)
284 {
285     o_rOwner << pList;
286 }
287 
288 void
AddEntry()289 IndexList::AddEntry()
290 {
291     pTerm = &pList->AddTerm();
292     pDefinition = &pList->AddDefinition();
293 }
294 
295 
296 }   // namespace adcdisp
297 
298 
299 
300