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 "pagemake.hxx"
24
25
26 // NOT FULLY DEFINED SERVICES
27 #include <ary/cpp/c_gate.hxx>
28 #include <ary/cpp/c_namesp.hxx>
29 #include <ary/cpp/c_class.hxx>
30 #include <ary/cpp/c_enum.hxx>
31 #include <ary/cpp/c_tydef.hxx>
32 #include <ary/cpp/cp_ce.hxx>
33 #include <ary/loc/loc_file.hxx>
34 #include <display/corframe.hxx>
35 #include "hd_chlst.hxx"
36 #include "hd_docu.hxx"
37 #include "hdimpl.hxx"
38 #include "html_kit.hxx"
39 #include "navibar.hxx"
40 #include "opageenv.hxx"
41 #include "outfile.hxx"
42 #include "pm_aldef.hxx"
43 #include "pm_class.hxx"
44 #include "pm_help.hxx"
45 #include "pm_index.hxx"
46 #include "pm_namsp.hxx"
47 #include "pm_start.hxx"
48 #include "strconst.hxx"
49
50
51 using namespace csi;
52 using csi::html::Link;
53 using csi::html::HorizontalLine;
54
55
56 const int C_nNrOfIndexLetters = 27;
57
58
59 template <class SPECIAL_MAKER>
60 inline void
Make_SpecialPage(DYN SPECIAL_MAKER * let_dpMaker)61 Make_SpecialPage( DYN SPECIAL_MAKER * let_dpMaker )
62 {
63 Dyn< SPECIAL_MAKER > pMaker( let_dpMaker );
64 pMaker->MakePage();
65 pMaker = 0;
66 }
67
68
PageDisplay(OuputPage_Environment & io_rEnv)69 PageDisplay::PageDisplay( OuputPage_Environment & io_rEnv )
70 : HtmlDisplay_Impl( io_rEnv ),
71 pMyFile( new HtmlDocuFile )
72 {
73 }
74
~PageDisplay()75 PageDisplay::~PageDisplay()
76 {
77
78 }
79
80 void
Create_OverviewFile()81 PageDisplay::Create_OverviewFile()
82 {
83 Env().SetFile_Overview();
84 File().SetLocation( Env().CurPath(), 0 );
85
86 SetupFileOnCurEnv( C_sHFTitle_Overview );
87 Make_SpecialPage( new PageMaker_Overview(*this) );
88 Create_File();
89 }
90
91 void
Create_AllDefsFile()92 PageDisplay::Create_AllDefsFile()
93 {
94 // This method is a provisorium, because later this will
95 // be spread over the files.
96
97 Env().MoveDir_2Root();
98 Env().SetFile_AllDefs();
99 File().SetLocation( Env().CurPath(), 0 );
100
101 SetupFileOnCurEnv( "Defines and Macros" );
102 Make_SpecialPage( new PageMaker_AllDefs(*this) );
103 Create_File();
104 }
105
106 void
Create_IndexFiles()107 PageDisplay::Create_IndexFiles()
108 {
109 Env().MoveDir_2Index();
110
111 for ( int i = 0; i < C_nNrOfIndexLetters; ++i )
112 Create_IndexFile(i);
113 }
114
115 void
Create_HelpFile()116 PageDisplay::Create_HelpFile()
117 {
118 Env().SetFile_Help();
119 File().SetLocation( Env().CurPath(), 0 );
120
121 SetupFileOnCurEnv( C_sHFTitle_Help );
122 Make_SpecialPage( new PageMaker_Help(*this) );
123 Create_File();
124 }
125
126 void
Create_NamespaceFile()127 PageDisplay::Create_NamespaceFile()
128 {
129 csv_assert( Env().CurNamespace() != 0 );
130 Env().SetFile_CurNamespace();
131 File().SetLocation( Env().CurPath(), Env().Depth() );
132 if (Env().CurNamespace()->Owner().IsValid())
133 {
134 StreamLock sNsp(100);
135 SetupFileOnCurEnv( sNsp() << C_sHFTypeTitle_Namespace
136 << " "
137 << Env().CurNamespace()->LocalName()
138 << c_str );
139 }
140 else
141 {
142 SetupFileOnCurEnv( C_sHFTitle_GlobalNamespaceCpp );
143 }
144
145 Make_SpecialPage( new PageMaker_Namespace(*this) );
146
147 Create_File();
148 }
149
150 void
Setup_OperationsFile_for(const ary::loc::File & i_rFile)151 PageDisplay::Setup_OperationsFile_for( const ary::loc::File & i_rFile )
152 {
153 csv_assert( Env().CurNamespace() != 0 );
154 Env().SetFile_Operations(&i_rFile);
155 File().SetLocation( Env().CurPath(), Env().Depth() );
156
157 StreamLock sOpFile(100);
158 SetupFileOnCurEnv( sOpFile() << "Global Functions in Namespace "
159 << Env().CurNamespace()->LocalName()
160 << " in Sourcefile "
161 << i_rFile.LocalName()
162 << c_str );
163 NavigationBar
164 aNavi( Env(),
165 NavigationBar::CEGT_operations );
166 aNavi.Write( CurOut() );
167 CurOut() << new HorizontalLine;
168
169 adcdisp::PageTitle_Std fTitle;
170 csi::xml::Element & rTitle = fTitle( CurOut() );
171 if (Env().CurNamespace()->Owner().IsValid())
172 {
173 rTitle << "Global Functions in Namespace "
174 << Env().CurNamespace()->LocalName();
175 }
176 else
177 {
178 rTitle << "Global Functions in Global Namespace C++";
179 }
180
181 rTitle << new html::LineBreak
182 << "in Sourcefile "
183 << i_rFile.LocalName();
184 CurOut() << new HorizontalLine;
185 }
186
187 void
Setup_OperationsFile_for(const ary::cpp::Class & i_rClass)188 PageDisplay::Setup_OperationsFile_for( const ary::cpp::Class & i_rClass )
189 {
190 csv_assert( Env().CurNamespace() != 0 );
191 Env().SetFile_Operations(0);
192 File().SetLocation( Env().CurPath(), Env().Depth() );
193
194 StreamLock sOpFile(100);
195 SetupFileOnCurEnv( sOpFile() << "Methods of Class "
196 << i_rClass.LocalName()
197 << c_str );
198 NavigationBar
199 aNavi( Env(),
200 NavigationBar::CEGT_operations );
201 aNavi.Write( CurOut() );
202 CurOut() << new HorizontalLine;
203
204 adcdisp::PageTitle_Std fTitle;
205 fTitle( CurOut(), "Methods of Class", i_rClass.LocalName() );
206
207 CurOut() << new HorizontalLine;
208 }
209
210 void
Setup_DataFile_for(const ary::loc::File & i_rFile)211 PageDisplay::Setup_DataFile_for( const ary::loc::File & i_rFile )
212 {
213 csv_assert( Env().CurNamespace() != 0 );
214 Env().SetFile_Data(&i_rFile);
215 File().SetLocation( Env().CurPath(), Env().Depth() );
216
217 StreamLock sDataFile(100);
218 SetupFileOnCurEnv( sDataFile() << "Global Data in Namespace "
219 << Env().CurNamespace()->LocalName()
220 << " in Sourcefile "
221 << i_rFile.LocalName()
222 << c_str );
223 NavigationBar
224 aNavi( Env(),
225 NavigationBar::CEGT_data );
226 aNavi.Write( CurOut() );
227 CurOut() << new HorizontalLine;
228
229 adcdisp::PageTitle_Std fTitle;
230 csi::xml::Element & rTitle = fTitle( CurOut() );
231 if ( Env().CurNamespace()->Owner().IsValid() )
232 {
233 rTitle << "Global Data in Namespace "
234 << Env().CurNamespace()->LocalName();
235 }
236 else
237 {
238 rTitle << "Global Data in Global Namespace C++";
239 }
240
241 rTitle
242 << new html::LineBreak
243 << "in Sourcefile "
244 << i_rFile.LocalName();
245 CurOut() << new HorizontalLine;
246 }
247
248 void
Setup_DataFile_for(const ary::cpp::Class & i_rClass)249 PageDisplay::Setup_DataFile_for( const ary::cpp::Class & i_rClass )
250 {
251 csv_assert( Env().CurNamespace() != 0 );
252 Env().SetFile_Data(0);
253 File().SetLocation( Env().CurPath(), Env().Depth() );
254
255 StreamLock sDataFile(100);
256 SetupFileOnCurEnv( sDataFile() << "Data of Class "
257 << i_rClass.LocalName()
258 << c_str );
259
260 NavigationBar
261 aNavi( Env(),
262 NavigationBar::CEGT_data );
263 aNavi.Write( CurOut() );
264 CurOut() << new HorizontalLine;
265
266 adcdisp::PageTitle_Std fTitle;
267 fTitle( CurOut(), "Data of Class", i_rClass.LocalName() );
268
269 CurOut() << new HorizontalLine;
270 }
271
272 void
Create_File()273 PageDisplay::Create_File()
274 {
275 Easy().Leave();
276 File().CreateFile();
277 }
278
279 void
do_Process(const ary::cpp::Class & i_rData)280 PageDisplay::do_Process(const ary::cpp::Class & i_rData)
281 {
282 Env().SetFile_Class(i_rData);
283 File().SetLocation( Env().CurPath(), Env().Depth() );
284
285 const char *
286 sTypeTitle = i_rData.ClassKey() == ary::cpp::CK_class
287 ? C_sHFTypeTitle_Class
288 : i_rData.ClassKey() == ary::cpp::CK_struct
289 ? C_sHFTypeTitle_Struct
290 : C_sHFTypeTitle_Union;
291 StreamLock sClassFile(60);
292 SetupFileOnCurEnv( sClassFile() << sTypeTitle
293 << " "
294 << i_rData.LocalName()
295 << c_str );
296
297 Make_SpecialPage( new PageMaker_Class(*this, i_rData) );
298
299 Create_File();
300 }
301
302 void
do_Process(const ary::cpp::Enum & i_rData)303 PageDisplay::do_Process(const ary::cpp::Enum & i_rData)
304 {
305 if ( Ce_IsInternal(i_rData) )
306 return;
307
308 Env().SetFile_Enum(i_rData);
309 File().SetLocation( Env().CurPath(), Env().Depth() );
310
311 StreamLock sEnumFile(100);
312 SetupFileOnCurEnv( sEnumFile() << C_sHFTypeTitle_Enum
313 << " "
314 << i_rData.LocalName()
315 << c_str );
316 Write_NavBar_Enum(i_rData);
317 Write_TopArea_Enum(i_rData);
318 Write_DocuArea_Enum(i_rData);
319 Write_ChildList_Enum(i_rData);
320
321 Create_File();
322 }
323
324 void
do_Process(const ary::cpp::Typedef & i_rData)325 PageDisplay::do_Process(const ary::cpp::Typedef & i_rData)
326 {
327 if ( Ce_IsInternal(i_rData) )
328 return;
329
330 Env().SetFile_Typedef(i_rData);
331 File().SetLocation( Env().CurPath(), Env().Depth() );
332
333 StreamLock sTypedefFile(100);
334 SetupFileOnCurEnv( sTypedefFile() << C_sHFTypeTitle_Typedef
335 << " "
336 << i_rData.LocalName()
337 << c_str );
338 Write_NavBar_Typedef(i_rData);
339 Write_TopArea_Typedef(i_rData);
340 Write_DocuArea_Typedef(i_rData);
341
342
343 Create_File();
344 }
345
346 void
Write_NameChainWithLinks(const ary::cpp::CodeEntity & i_rCe)347 PageDisplay::Write_NameChainWithLinks( const ary::cpp::CodeEntity & i_rCe )
348 {
349 if ( Env().CurNamespace()->Id() != i_rCe.Id() )
350 {
351 RecursiveWrite_NamespaceLink( Env().CurNamespace() );
352 if ( Env().CurClass() != 0 )
353 {
354 CurOut() << new html::Sbr;
355 RecursiveWrite_ClassLink( Env().CurClass(), 1 );
356 }
357 }
358 else
359 {
360 RecursiveWrite_NamespaceLink( Env().CurNamespace()->Parent() );
361 }
362 }
363
364 const ary::cpp::Gate *
inq_Get_ReFinder() const365 PageDisplay::inq_Get_ReFinder() const
366 {
367 return &Env().Gate();
368 }
369
370 void
RecursiveWrite_NamespaceLink(const ary::cpp::Namespace * i_pNamespace)371 PageDisplay::RecursiveWrite_NamespaceLink( const ary::cpp::Namespace * i_pNamespace )
372 {
373 if ( i_pNamespace == 0 )
374 {
375 return;
376 }
377 else if (NOT i_pNamespace->Owner().IsValid())
378 { // Global namespace:
379 StreamLock sNspDir(50);
380 CurOut()
381 >> *new Link( PathPerRoot(Env(),
382 sNspDir() << C_sDIR_NamespacesCpp
383 << "/"
384 << C_sHFN_Namespace
385 << c_str) )
386 << new xml::AnAttribute( "alt", C_sHFTitle_GlobalNamespaceCpp )
387 >> *new html::Font
388 << new html::SizeAttr("+1")
389 >> *new html::Bold
390 << "::";
391 CurOut()
392 << " ";
393 return;
394 }
395 else
396 {
397 RecursiveWrite_NamespaceLink( i_pNamespace->Parent() );
398 }
399
400 uintt nLevelDistance = Env().Depth() - ( i_pNamespace->Depth() + 1 );
401 csv_assert( nLevelDistance < 100 );
402 CurOut()
403 >> *new Link( PathPerLevelsUp(nLevelDistance, C_sHFN_Namespace) )
404 << new xml::AnAttribute( "alt", C_sHFTypeTitle_Namespace)
405 >> *new html::Font
406 << new html::SizeAttr("+1")
407 >> *new html::Bold
408 << i_pNamespace->LocalName();
409 CurOut()
410 >> *new html::Font
411 << new html::SizeAttr("+1")
412 << " :: ";
413 }
414
415 void
RecursiveWrite_ClassLink(const ary::cpp::Class * i_pClass,uintt i_nLevelDistance)416 PageDisplay::RecursiveWrite_ClassLink( const ary::cpp::Class * i_pClass,
417 uintt i_nLevelDistance )
418 {
419 if ( i_pClass == 0 )
420 return;
421
422 if ( i_pClass->Protection() != ary::cpp::PROTECT_global )
423 {
424 RecursiveWrite_ClassLink(
425 dynamic_cast< const ary::cpp::Class* >(
426 Env().Gate().Ces().Search_Ce(i_pClass->Owner())),
427 i_nLevelDistance + 1 );
428 }
429
430 CurOut()
431 >> *new Link( Path2Class(i_nLevelDistance, i_pClass->LocalName()) )
432 << new html::ClassAttr("nqclass")
433 << i_pClass->LocalName()
434 << " :: ";
435 }
436
437 void
SetupFileOnCurEnv(const char * i_sTitle)438 PageDisplay::SetupFileOnCurEnv( const char * i_sTitle )
439 {
440 File().SetLocation( Env().CurPath(), Env().Depth() );
441 File().SetTitle( i_sTitle );
442 File().SetCopyright( Env().Layout().CopyrightText() );
443 File().EmptyBody();
444
445 // This sets CurOut() to the contents of <body></body>
446 // in File() :
447 Easy().Enter( File().Body() );
448 }
449
450 void
Write_NavBar_Enum(const ary::cpp::Enum & i_rData)451 PageDisplay::Write_NavBar_Enum( const ary::cpp::Enum & i_rData )
452 {
453 NavigationBar aNavi( Env(), i_rData );
454 aNavi.MakeSubRow("List of");
455 aNavi.AddItem( C_sTitle_EnumValues, C_sLabel_EnumValues, true );
456 aNavi.Write( CurOut(), true );
457
458 CurOut() << new HorizontalLine;
459 }
460
461 void
Write_TopArea_Enum(const ary::cpp::Enum & i_rData)462 PageDisplay::Write_TopArea_Enum( const ary::cpp::Enum & i_rData )
463 {
464 Write_NameChainWithLinks( i_rData );
465
466 adcdisp::PageTitle_Std fTitle;
467 fTitle( CurOut(), C_sHFTypeTitle_Enum, i_rData.LocalName() );
468
469 CurOut() << new HorizontalLine;
470 }
471
472 void
Write_DocuArea_Enum(const ary::cpp::Enum & i_rData)473 PageDisplay::Write_DocuArea_Enum( const ary::cpp::Enum & i_rData )
474 {
475 Docu_Display aDocuShow( Env() );
476
477 aDocuShow.Assign_Out(CurOut());
478 aDocuShow.Process(i_rData.Docu());
479 aDocuShow.Unassign_Out();
480
481 CurOut() << new HorizontalLine;
482 }
483
484 void
Write_ChildList_Enum(const ary::cpp::Enum & i_rData)485 PageDisplay::Write_ChildList_Enum( const ary::cpp::Enum & i_rData )
486 {
487 bool bChildrenExist = false;
488 ChildList_Display::Area_Result
489 aResult( bChildrenExist, CurOut() );
490
491 ChildList_Display aDisplay(Env(), i_rData);
492 aDisplay.Run_Simple( aResult,
493 ary::cpp::Enum::SLOT_Values,
494 C_sLabel_EnumValues,
495 C_sTitle_EnumValues );
496
497 if (NOT bChildrenExist)
498 CurOut() >> *new html::Headline(4) << "This enum has no values.";
499 CurOut() << new HorizontalLine;
500 }
501
502 void
Write_NavBar_Typedef(const ary::cpp::Typedef & i_rData)503 PageDisplay::Write_NavBar_Typedef( const ary::cpp::Typedef & i_rData )
504 {
505 NavigationBar aNavi( Env(), i_rData );
506 aNavi.Write( CurOut(), true );
507
508 CurOut() << new HorizontalLine;
509 }
510
511 void
Write_TopArea_Typedef(const ary::cpp::Typedef & i_rData)512 PageDisplay::Write_TopArea_Typedef( const ary::cpp::Typedef & i_rData )
513 {
514 Write_NameChainWithLinks( i_rData );
515
516 adcdisp::PageTitle_Std fTitle;
517 fTitle( CurOut(), C_sHFTypeTitle_Typedef, i_rData.LocalName() );
518
519 CurOut() << new HorizontalLine;
520 }
521
522 void
Write_DocuArea_Typedef(const ary::cpp::Typedef & i_rData)523 PageDisplay::Write_DocuArea_Typedef( const ary::cpp::Typedef & i_rData )
524 {
525 adcdisp::ExplanationList aDef( CurOut() );
526 aDef.AddEntry("Definition:");
527 xml::Element & rDef = aDef.Def();
528
529 ary::cpp::Type_id
530 nDefiningType = i_rData.DescribingType();
531
532 const ary::cpp::CodeEntity *
533 pRelatedCe = Env().Gate().Search_RelatedCe(nDefiningType);
534 if ( pRelatedCe != 0 )
535 {
536 const char * sTypeKey = Get_TypeKey(*pRelatedCe);
537 if ( NOT csv::no_str(sTypeKey) )
538 rDef << sTypeKey << " ";
539 }
540
541 dshelp::Get_LinkedTypeText( rDef, Env(), nDefiningType );
542
543 Docu_Display aDocuShow( Env() );
544
545 aDocuShow.Assign_Out(CurOut());
546 aDocuShow.Process(i_rData.Docu());
547 aDocuShow.Unassign_Out();
548
549 CurOut() << new HorizontalLine;
550 }
551
552 void
Create_IndexFile(int i_nLetter)553 PageDisplay::Create_IndexFile( int i_nLetter )
554 {
555 static char aLetters[C_nNrOfIndexLetters+1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
556 csv_assert( 0 <= i_nLetter AND i_nLetter < C_nNrOfIndexLetters );
557
558 char cCurLetter = aLetters[i_nLetter];
559 Env().SetFile_Index( cCurLetter );
560
561 static char sIndexFileTitle[] = "Global Index X";
562 const int nPositionOfLetterInTitle = 13;
563 sIndexFileTitle[nPositionOfLetterInTitle] = cCurLetter;
564 SetupFileOnCurEnv( sIndexFileTitle );
565
566 Make_SpecialPage( new PageMaker_Index(*this, cCurLetter ) );
567
568 Create_File();
569 }
570
571