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 "hfi_linklist.hxx"
24 
25 
26 // NOT FULLY DEFINED SERVICES
27 #include <ary/idl/i_ce.hxx>
28 #include <ary/idl/i_gate.hxx>
29 #include <ary/idl/ip_ce.hxx>
30 #include <ary/idl/ip_type.hxx>
31 #include <toolkit/hf_docentry.hxx>
32 #include <toolkit/hf_title.hxx>
33 #include "hfi_doc.hxx"
34 #include "hfi_tag.hxx"
35 #include "hfi_typetext.hxx"
36 #include "hi_ary.hxx"
37 #include "hi_env.hxx"
38 
39 
40 
41 
42 //*******************           HF_CommentedLink_Table         **********************************//
43 
HF_CommentedLink_Table(Environment & io_rEnv,Xml::Element & o_rOut,const String & i_sTitle,const String & i_sLabel,bool i_bBorder)44 HF_CommentedLink_Table::HF_CommentedLink_Table( Environment  &          io_rEnv,
45                                                 Xml::Element &          o_rOut,
46                                                 const String &          i_sTitle,
47                                                 const String &          i_sLabel,
48                                                 bool                    i_bBorder )
49     :    HtmlFactory_Idl(io_rEnv,&o_rOut),
50          pTable( new Html::Table( (i_bBorder ? "1" : "0"), "100%", "5", "0") ),
51          pCurLinkColumn(0),
52          pCurCommentColumn(0)
53 {
54     *pTable
55         << new Html::ClassAttr("commentedlinks");
56 
57     CurOut()
58         >> *new Html::Label(i_sLabel)
59            << new Html::LineBreak;
60     CurOut()
61         << pTable;
62 //    HF_SubTitle aTitle(*pTable);
63 //    aTitle.Produce_it(i_sTitle);
64 }
65 
~HF_CommentedLink_Table()66 HF_CommentedLink_Table::~HF_CommentedLink_Table()
67 {
68 }
69 
70 void
Add_Line()71 HF_CommentedLink_Table::Add_Line()
72 {
73     Html::TableRow &
74         rRow = pTable->AddRow();
75 
76     pCurLinkColumn = & (rRow.AddCell()
77                             << new Html::WidthAttr("30%")
78                             << new Xml::AnAttribute("valign","top") );
79     pCurCommentColumn  = & rRow.AddCell();
80 }
81 
82 Xml::Element &
Cur_LinkColumn()83 HF_CommentedLink_Table::Cur_LinkColumn()
84 {
85     csv_assert(pCurLinkColumn != 0);
86     return *pCurLinkColumn;
87 }
88 
89 Xml::Element &
Cur_CommentColumn()90 HF_CommentedLink_Table::Cur_CommentColumn()
91 {
92     csv_assert(pCurCommentColumn != 0);
93     return *pCurCommentColumn;
94 }
95 
96 
97 //*******************           HF_MemberTable         **********************************//
98 
HF_MemberTable(Environment & io_rEnv,Xml::Element & o_rOut,const String & i_sTitle,const String & i_sLabel,bool i_bInline)99 HF_MemberTable::HF_MemberTable( Environment  &      io_rEnv,
100                                 Xml::Element &      o_rOut,
101                                 const String &      i_sTitle,
102                                 const String &      i_sLabel,
103                                 bool                i_bInline )
104     :    HtmlFactory_Idl(io_rEnv,&o_rOut),
105          pTable( new Html::Table("1", "100%", "5", "0") ),
106          pCurDeclaration(0),
107          pCurDescription(0),
108          bInline(i_bInline)
109 {
110     *pTable
111         << new Html::ClassAttr("memberlist");
112 
113     CurOut()
114         >> *new Html::Label(i_sLabel)
115            << new Html::LineBreak;
116     CurOut()
117         << pTable;
118 //    HF_SubTitle aTitle(*pTable);
119 //    aTitle.Produce_it(i_sTitle);
120 }
121 
~HF_MemberTable()122 HF_MemberTable::~HF_MemberTable()
123 {
124 }
125 
126 void
Add_Line()127 HF_MemberTable::Add_Line()
128 {
129     if (bInline)
130     {
131         Html::TableRow & rRow = pTable->AddRow();
132 
133         pCurDeclaration = &( rRow.AddCell()
134                                 << new Xml::AnAttribute("valign","top")
135                                 << new Html::WidthAttr("30%") );
136         pCurDescription = & rRow.AddCell();
137     }
138     else
139     {
140         Html::DefList *
141             pMemberSpace = new Html::DefList;
142         *pMemberSpace
143             << new Html::ClassAttr("member");
144 
145         pTable->AddRow().AddCell() << pMemberSpace;
146 
147         pCurDeclaration =
148             & ( *pMemberSpace
149                     >> *new Html::DefListTerm
150                         << new Html::ClassAttr("member") );
151         pCurDescription =
152             & ( *pMemberSpace
153                     >> *new Html::DefListDefinition()
154                         << new Html::ClassAttr("member") );
155     }
156 }
157 
158 Xml::Element &
Cur_Declaration()159 HF_MemberTable::Cur_Declaration()
160 {
161     csv_assert(pCurDeclaration != 0);
162     return *pCurDeclaration;
163 }
164 
165 Xml::Element &
Cur_Description()166 HF_MemberTable::Cur_Description()
167 {
168     csv_assert(pCurDescription != 0);
169     return *pCurDescription;
170 }
171 
172 
173 
174 //*******************           HF_IdlLinkList         **********************************//
175 
HF_IdlLinkList(Environment & io_rEnv,Xml::Element * o_pOut)176 HF_IdlLinkList::HF_IdlLinkList( Environment  &   io_rEnv,
177                                 Xml::Element *   o_pOut )
178     :    HtmlFactory_Idl(io_rEnv,o_pOut)
179 {
180 }
181 
~HF_IdlLinkList()182 HF_IdlLinkList::~HF_IdlLinkList()
183 {
184 }
185 
186 void
Produce_NamespaceMembers(const String & i_sTitle,const String & i_sLabel,const std::vector<ary::idl::Ce_id> & i_rList,bool i_bNestedNamespaces) const187 HF_IdlLinkList::Produce_NamespaceMembers( const String &                        i_sTitle,
188                                           const String &                        i_sLabel,
189                                           const std::vector<ary::idl::Ce_id> &  i_rList,
190                                           bool                                  i_bNestedNamespaces ) const
191 {
192     HF_CommentedLink_Table
193         aTableMaker( Env(), CurOut(),
194                      i_sTitle, i_sLabel,
195                      true );
196 
197     std::vector<ary::idl::Ce_id>::const_iterator itEnd = i_rList.end();
198     for ( std::vector<ary::idl::Ce_id>::const_iterator it = i_rList.begin();
199           it != itEnd;
200           ++it )
201     {
202         static String   sEntryName;
203         static String   sEntryLink;
204         const ce_info *
205                         pDocu = 0;
206         Get_EntryData_NamespaceMembers( sEntryName, sEntryLink, pDocu, *it, i_bNestedNamespaces );
207         aTableMaker.Add_Line();
208 
209         aTableMaker.Cur_LinkColumn()
210            >> *new Html::Link(sEntryLink)
211               << sEntryName;
212 
213         if ( pDocu != 0 )
214         {
215             HF_IdlShortDocu
216                 aTextDisplay(Env(), aTableMaker.Cur_CommentColumn() );
217             aTextDisplay.Produce_byData( pDocu );
218         }
219     }   // end for
220 }
221 
222 void
Produce_GlobalLinks(const String & i_sTitle,const String & i_sLabel,ce_list & i_rList) const223 HF_IdlLinkList::Produce_GlobalLinks( const String &      i_sTitle,
224                                      const String &      i_sLabel,
225                                      ce_list &           i_rList ) const
226 {
227     HF_CommentedLink_Table
228         aTableMaker( Env(), CurOut(),
229                      i_sTitle, i_sLabel,
230                      true );
231 
232     for ( ; i_rList; ++i_rList )
233     {
234         aTableMaker.Add_Line();
235         HF_IdlTypeText
236             aLinkText( Env(), aTableMaker.Cur_LinkColumn(), true );
237         aLinkText.Produce_byData(*i_rList);
238 
239         const ce_info *
240             pDocu = Get_EntryDocu(*i_rList);
241         if ( pDocu != 0 )
242         {
243             HF_IdlShortDocu
244                 aTextDisplay(Env(), aTableMaker.Cur_CommentColumn() );
245             aTextDisplay.Produce_byData( pDocu, *i_rList );
246         }
247     }
248 }
249 
250 void
Produce_GlobalCommentedLinks(const String & i_sTitle,const String & i_sLabel,comref_list & i_rList) const251 HF_IdlLinkList::Produce_GlobalCommentedLinks( const String &          i_sTitle,
252                                               const String &          i_sLabel,
253                                               comref_list &           i_rList ) const
254 {
255     HF_CommentedLink_Table
256         aTableMaker( Env(), CurOut(),
257                      i_sTitle, i_sLabel,
258                      true );
259 /*
260     for ( ; i_rList; ++i_rList )
261     {
262         aTableMaker.Add_Line();
263         HF_IdlTypeText
264             aLinkText( Env(), aTableMaker.Cur_LinkColumn(), true );
265         aLinkText.Produce_byData( (*i_rList).first );
266 
267         HF_DocEntryList
268             aDocList( aTableMaker.Cur_CommentColumn() );
269         if ( (*i_rList).second != 0 )
270         {
271             HF_IdlDocu
272                 aDocuDisplay( Env(), aDocList );
273             aDocuDisplay.Produce_byData( (*i_rList).second );
274         }
275         else
276         {
277             const ce_info *
278                 pShort = Get_EntryDocu(
279                             Env().Gate().Types().Search_CeRelatedTo(
280                                             (*i_rList).first) );
281             if ( pShort != 0 )
282             {
283                 if (pShort->IsDeprecated())
284                 {
285                     aDocList.Produce_Term()
286                         << "[ DEPRECATED ]";
287                 }
288                 if (pShort->IsOptional())
289                 {
290                     aDocList.Produce_Term()
291                         << "[ OPTIONAL ]";
292                 }
293 
294                 aDocList.Produce_Term()
295                     << "Description";
296 
297                 HF_IdlDocuTextDisplay
298                     aShortDisplay( Env(), &aDocList.Produce_Definition() );
299                 aShortDisplay.Set_CurScopeTo(
300                         Env().Gate().Types().Search_CeRelatedTo((*i_rList).first) );
301                 pShort->Short().DisplayAt(aShortDisplay);
302             }
303         }
304     }
305 */
306 }
307 
308 void
Produce_MemberLinks(const String & i_sTitle,const String & i_sLabel,ce_list & i_rList) const309 HF_IdlLinkList::Produce_MemberLinks( const String &     i_sTitle,
310                                      const String &     i_sLabel,
311                                      ce_list &          i_rList ) const
312 {
313     HF_CommentedLink_Table
314         aTableMaker( Env(), CurOut(),
315                      i_sTitle, i_sLabel,
316                      true );
317 
318 /*
319     for ( ; i_rList; ++i_rList )
320     {
321         const ary::idl::CodeEntity &
322             rCe = Env().Gate().Ces().Find_Ce(*i_rList);
323 
324         aTableMaker.Add_Line();
325         aTableMaker.Cur_LinkColumn()
326             >> *new Html::Link(
327                     StreamLock(200)() << "#" << rCe.LocalName() << c_str)
328                << rCe.LocalName();
329 
330         const ce_info *
331             pDocu = rCe.Docu();
332         if ( pDocu != 0 )
333         {
334             HF_IdlShortDocu
335                 aTextDisplay(Env(), aTableMaker.Cur_CommentColumn() );
336             aTextDisplay.Produce_byData( *pDocu );
337         }
338     }   // end for
339 */
340 }
341 
342 void
Get_EntryData_NamespaceMembers(String & o_sEntryName,String & o_sEntryLink,const ce_info * & o_pDocu,ce_id i_nMemberId,bool i_bIsNestedNamespace) const343 HF_IdlLinkList::Get_EntryData_NamespaceMembers(
344                             String &                o_sEntryName,
345                             String &                o_sEntryLink,
346                             const ce_info * &       o_pDocu,
347                             ce_id                   i_nMemberId,
348                             bool                    i_bIsNestedNamespace  ) const
349 {
350     const ary::idl::CodeEntity &
351         rCe = Env().Data().Find_Ce(i_nMemberId);
352 
353     o_sEntryName = rCe.LocalName();
354     o_sEntryLink = StreamLock(200)() << rCe.LocalName()
355                                      << ( i_bIsNestedNamespace
356                                                 ?   "/module-ix"
357                                                 :   "" )
358                                      << ".html"
359                                      << c_str;
360     o_pDocu = rCe.Docu();
361 }
362 
363 const ary::doc::OldIdlDocu *
Get_EntryDocu(ce_id i_nMemberId) const364 HF_IdlLinkList::Get_EntryDocu(ce_id i_nMemberId) const
365 {
366     if (i_nMemberId.IsValid())
367         return Env().Data().Find_Ce(i_nMemberId).Docu();
368     else
369         return 0;
370 }
371 
372 
373