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 "hi_factory.hxx"
24
25
26 // NOT FULLY DEFINED SERVICES
27 #include <ary/idl/i_ce.hxx>
28 #include <toolkit/hf_title.hxx>
29 #include "hfi_doc.hxx"
30 #include "hfi_navibar.hxx"
31 #include "hfi_tag.hxx"
32 #include "hfi_typetext.hxx"
33 #include "hi_linkhelper.hxx"
34
35
36 extern const String
37 C_sCellStyle_SummaryLeft("imsum_left");
38 extern const String
39 C_sCellStyle_SummaryRight("imsum_right");
40 extern const String
41 C_sCellStyle_MDetail("imdetail");
42 extern const String
43 C_sMemberTitle("membertitle");
44
45
46 namespace
47 {
48
49 const char C_sSpace[92] = " "
50 " "
51 " ";
52 }
53
54
55 void
produce_SummaryDeclaration(Xml::Element & o_row,const client & i_ce) const56 HtmlFactory_Idl::produce_SummaryDeclaration( Xml::Element & o_row,
57 const client & i_ce ) const
58 {
59 produce_InternalLink(o_row, i_ce);
60 }
61
62 void
produce_InternalLink(Xml::Element & o_screen,const client & i_ce) const63 HtmlFactory_Idl::produce_InternalLink( Xml::Element & o_screen,
64 const client & i_ce ) const
65 {
66 StreamLock aLocalLink(100);
67 aLocalLink() << "#" << i_ce.LocalName();
68
69 o_screen
70 >> *new Html::TableCell
71 << new Html::ClassAttr( C_sCellStyle_SummaryLeft )
72 >> *new Html::Link( aLocalLink().c_str() )
73 << i_ce.LocalName();
74 }
75
76 void
produce_ShortDoc(Xml::Element & o_screen,const client & i_ce) const77 HtmlFactory_Idl::produce_ShortDoc( Xml::Element & o_screen,
78 const client & i_ce ) const
79 {
80 Xml::Element &
81 rDetailsRowCell = o_screen
82 >> *new Html::TableCell
83 << new Html::ClassAttr( C_sCellStyle_SummaryRight );
84 HF_IdlShortDocu
85 aLinkDoc(Env(), rDetailsRowCell);
86 aLinkDoc.Produce_byData( i_ce );
87
88 rDetailsRowCell << new Xml::XmlCode(" ");
89 }
90
91 // KORR_FUTURE: Does not belong here (implementation inheritance)!
92 void
produce_Bases(Xml::Element & o_screen,const client & i_ce,const String & i_sLabel) const93 HtmlFactory_Idl::produce_Bases( Xml::Element & o_screen,
94 const client & i_ce,
95 const String & i_sLabel ) const
96 {
97 ary::idl::Type_id nBaseT = baseOf(i_ce);
98 if ( nBaseT.IsValid() )
99 {
100 HF_DocEntryList
101 aDocList( o_screen );
102 aDocList.Produce_Term(i_sLabel);
103
104 int nDepth = 0;
105 Xml::Element &
106 rBaseList = aDocList.Produce_Definition()
107 >> *new Xml::AnElement("pre")
108 << new Xml::AnAttribute("style","font-family:monospace;");
109 rBaseList
110 >> *new Html::Strong
111 << i_ce.LocalName();
112 rBaseList
113 << "\n";
114 recursive_ShowBases( rBaseList,
115 nBaseT,
116 nDepth );
117 }
118 }
119
120 void
produce_Members(ce_list & it_list,const String & i_summaryTitle,const String & i_summaryLabel,const String & i_detailsTitle,const String & i_detailsLabel,const E_MemberViewType i_viewType) const121 HtmlFactory_Idl::produce_Members( ce_list & it_list,
122 const String & i_summaryTitle,
123 const String & i_summaryLabel,
124 const String & i_detailsTitle,
125 const String & i_detailsLabel,
126 const E_MemberViewType i_viewType ) const
127 {
128 csv_assert( it_list );
129
130 Dyn< HF_SubTitleTable > pSummary;
131 if ( ( i_viewType == viewtype_summary )
132 || ( i_viewType == viewtype_complete )
133 )
134 {
135 pSummary = new HF_SubTitleTable(
136 CurOut(),
137 i_summaryLabel,
138 i_summaryTitle,
139 2 );
140 }
141
142 Dyn< HF_SubTitleTable > pDetails;
143 if ( ( i_viewType == viewtype_details )
144 || ( i_viewType == viewtype_complete )
145 )
146 {
147 pDetails = new HF_SubTitleTable(
148 CurOut(),
149 i_detailsLabel,
150 i_detailsTitle,
151 1 );
152 }
153
154 for ( ; it_list.operator bool(); ++it_list )
155 {
156 const ary::idl::CodeEntity &
157 rCe = Env().Data().Find_Ce(*it_list);
158
159 if ( pSummary )
160 {
161 Xml::Element &
162 rSummaryRow = pSummary->Add_Row();
163 produce_SummaryDeclaration(rSummaryRow, rCe);
164 // produce_InternalLink(rSummaryRow, rCe);
165 produce_ShortDoc(rSummaryRow, rCe);
166 }
167
168 if ( pDetails )
169 produce_MemberDetails(*pDetails, rCe);
170 }
171 }
172
173 void
produce_Title(HF_TitleTable & o_title,const String & i_label,const client & i_ce) const174 HtmlFactory_Idl::produce_Title( HF_TitleTable & o_title,
175 const String & i_label,
176 const client & i_ce ) const
177 {
178 StreamLock
179 slAnnotations(200);
180 get_Annotations(slAnnotations(), i_ce);
181 StreamLock
182 slTitle(200);
183 slTitle() << i_label << " " << i_ce.LocalName();
184 o_title.Produce_Title( slAnnotations().c_str(),
185 slTitle().c_str() );
186 }
187
188 void
get_Annotations(StreamStr & o_out,const client & i_ce) const189 HtmlFactory_Idl::get_Annotations( StreamStr & o_out,
190 const client & i_ce ) const
191 {
192 const ary::doc::OldIdlDocu *
193 doc = Get_IdlDocu(i_ce.Docu());
194 if (doc != 0)
195 {
196 if (doc->IsDeprecated())
197 o_out << "deprecated ";
198 if (NOT doc->IsPublished())
199 o_out << "unpublished ";
200 }
201
202 // KORR
203 // Need to display "unpublished", if there is no docu.
204 }
205
206 void
write_Docu(Xml::Element & o_screen,const client & i_ce) const207 HtmlFactory_Idl::write_Docu( Xml::Element & o_screen,
208 const client & i_ce ) const
209 {
210 const ary::doc::OldIdlDocu *
211 doc = Get_IdlDocu(i_ce.Docu());
212 if (doc != 0)
213 {
214 HF_DocEntryList
215 aDocuList( o_screen );
216 HF_IdlDocu
217 aDocu( Env(), aDocuList );
218 aDocu.Produce_fromCodeEntity(i_ce);
219 }
220
221 write_ManualLinks(o_screen, i_ce);
222 }
223
224 void
write_ManualLinks(Xml::Element & o_screen,const client & i_ce) const225 HtmlFactory_Idl::write_ManualLinks( Xml::Element & o_screen,
226 const client & i_ce ) const
227 {
228 const StringVector &
229 rLinks2Descrs = i_ce.Secondaries().Links2DescriptionInManual();
230 if ( rLinks2Descrs.size() == 0 )
231 return;
232
233 o_screen
234 >> *new Html::Label(C_sLocalManualLinks.c_str()+1) // Leave out the leading '#'.
235 << " ";
236 HF_DocEntryList
237 aDocuList( o_screen );
238 aDocuList.Produce_Term("Developers Guide");
239 csv_assert(rLinks2Descrs.size() % 2 == 0);
240 for ( StringVector::const_iterator it = rLinks2Descrs.begin();
241 it != rLinks2Descrs.end();
242 ++it )
243 {
244 Xml::Element &
245 rLink = aDocuList.Produce_Definition() >> *new Html::Link( Env().Link2Manual(*it));
246 if ( (*(it+1)).empty() )
247 // HACK KORR_FUTURE
248 // Research what happens with manual links which contain normal characters
249 // in non-utf-8 texts. And research, why utfF-8 does not work here.
250 rLink << new Xml::XmlCode(*it);
251 else
252 rLink << new Xml::XmlCode( *(it+1) );
253 ++it;
254 } // end for
255 }
256
257 void
produce_MemberDetails(HF_SubTitleTable &,const client &) const258 HtmlFactory_Idl::produce_MemberDetails( HF_SubTitleTable & ,
259 const client & ) const
260 {
261 // Dummy, which does not need to do anything.
262 }
263
264 void
recursive_ShowBases(Xml::Element & o_screen,type_id i_baseType,int & io_nDepth) const265 HtmlFactory_Idl::recursive_ShowBases( Xml::Element & o_screen,
266 type_id i_baseType,
267 int & io_nDepth ) const
268 {
269 // Show this base
270 ++io_nDepth;
271 const ary::idl::CodeEntity *
272 pCe = Env().Linker().Search_CeFromType(i_baseType);
273
274 csv_assert(io_nDepth > 0);
275 if (io_nDepth > 30)
276 io_nDepth = 30;
277 o_screen
278 << (C_sSpace + 93 - 3*io_nDepth)
279 << new csi::xml::XmlCode("┗")
280 << " ";
281
282 if (pCe == 0)
283 {
284 HF_IdlTypeText
285 aText( Env(), o_screen, false );
286 aText.Produce_byData( i_baseType );
287 o_screen
288 << "\n";
289 --io_nDepth;
290 return;
291 }
292
293 HF_IdlTypeText
294 aBaseLink( Env(), o_screen, true );
295 aBaseLink.Produce_byData(pCe->CeId());
296 o_screen
297 << "\n";
298
299 // Bases
300 ary::idl::Type_id
301 nBaseT = baseOf(*pCe);
302 if (nBaseT.IsValid())
303 recursive_ShowBases(o_screen,nBaseT,io_nDepth);
304
305 --io_nDepth;
306 return;
307 }
308
309 HtmlFactory_Idl::type_id
inq_BaseOf(const client &) const310 HtmlFactory_Idl::inq_BaseOf( const client & ) const
311 {
312 // Unused dummy.
313 return type_id(0);
314 }
315
316