Update ooo320-m1
[ooovba.git] / autodoc / source / display / html / pagemake.cxx
blob0ff07566bf5972210dabf7c51b7b79d4f5c44311
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pagemake.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <precomp.h>
32 #include "pagemake.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/cpp/c_gate.hxx>
37 #include <ary/cpp/c_namesp.hxx>
38 #include <ary/cpp/c_class.hxx>
39 #include <ary/cpp/c_enum.hxx>
40 #include <ary/cpp/c_tydef.hxx>
41 #include <ary/cpp/cp_ce.hxx>
42 #include <ary/loc/loc_file.hxx>
43 #include <display/corframe.hxx>
44 #include "hd_chlst.hxx"
45 #include "hd_docu.hxx"
46 #include "hdimpl.hxx"
47 #include "html_kit.hxx"
48 #include "navibar.hxx"
49 #include "opageenv.hxx"
50 #include "outfile.hxx"
51 #include "pm_aldef.hxx"
52 #include "pm_class.hxx"
53 #include "pm_help.hxx"
54 #include "pm_index.hxx"
55 #include "pm_namsp.hxx"
56 #include "pm_start.hxx"
57 #include "strconst.hxx"
60 using namespace csi;
61 using csi::html::Link;
62 using csi::html::HorizontalLine;
65 const int C_nNrOfIndexLetters = 27;
68 template <class SPECIAL_MAKER>
69 inline void
70 Make_SpecialPage( DYN SPECIAL_MAKER * let_dpMaker )
72 Dyn< SPECIAL_MAKER > pMaker( let_dpMaker );
73 pMaker->MakePage();
74 pMaker = 0;
78 PageDisplay::PageDisplay( OuputPage_Environment & io_rEnv )
79 : HtmlDisplay_Impl( io_rEnv ),
80 pMyFile( new HtmlDocuFile )
84 PageDisplay::~PageDisplay()
89 void
90 PageDisplay::Create_OverviewFile()
92 Env().SetFile_Overview();
93 File().SetLocation( Env().CurPath(), 0 );
95 SetupFileOnCurEnv( C_sHFTitle_Overview );
96 Make_SpecialPage( new PageMaker_Overview(*this) );
97 Create_File();
100 void
101 PageDisplay::Create_AllDefsFile()
103 // This method is a provisorium, because later this will
104 // be spreaded over the files.
106 Env().MoveDir_2Root();
107 Env().SetFile_AllDefs();
108 File().SetLocation( Env().CurPath(), 0 );
110 SetupFileOnCurEnv( "Defines and Macros" );
111 Make_SpecialPage( new PageMaker_AllDefs(*this) );
112 Create_File();
115 void
116 PageDisplay::Create_IndexFiles()
118 Env().MoveDir_2Index();
120 for ( int i = 0; i < C_nNrOfIndexLetters; ++i )
121 Create_IndexFile(i);
124 void
125 PageDisplay::Create_HelpFile()
127 Env().SetFile_Help();
128 File().SetLocation( Env().CurPath(), 0 );
130 SetupFileOnCurEnv( C_sHFTitle_Help );
131 Make_SpecialPage( new PageMaker_Help(*this) );
132 Create_File();
135 void
136 PageDisplay::Create_NamespaceFile()
138 csv_assert( Env().CurNamespace() != 0 );
139 Env().SetFile_CurNamespace();
140 File().SetLocation( Env().CurPath(), Env().Depth() );
141 if (Env().CurNamespace()->Owner().IsValid())
143 StreamLock sNsp(100);
144 SetupFileOnCurEnv( sNsp() << C_sHFTypeTitle_Namespace
145 << " "
146 << Env().CurNamespace()->LocalName()
147 << c_str );
149 else
151 SetupFileOnCurEnv( C_sHFTitle_GlobalNamespaceCpp );
154 Make_SpecialPage( new PageMaker_Namespace(*this) );
156 Create_File();
159 void
160 PageDisplay::Setup_OperationsFile_for( const ary::loc::File & i_rFile )
162 csv_assert( Env().CurNamespace() != 0 );
163 Env().SetFile_Operations(&i_rFile);
164 File().SetLocation( Env().CurPath(), Env().Depth() );
166 StreamLock sOpFile(100);
167 SetupFileOnCurEnv( sOpFile() << "Global Functions in Namespace "
168 << Env().CurNamespace()->LocalName()
169 << " in Sourcefile "
170 << i_rFile.LocalName()
171 << c_str );
172 NavigationBar
173 aNavi( Env(),
174 NavigationBar::CEGT_operations );
175 aNavi.Write( CurOut() );
176 CurOut() << new HorizontalLine;
178 adcdisp::PageTitle_Std fTitle;
179 csi::xml::Element & rTitle = fTitle( CurOut() );
180 if (Env().CurNamespace()->Owner().IsValid())
182 rTitle << "Global Functions in Namespace "
183 << Env().CurNamespace()->LocalName();
185 else
187 rTitle << "Global Functions in Global Namespace C++";
190 rTitle << new html::LineBreak
191 << "in Sourcefile "
192 << i_rFile.LocalName();
193 CurOut() << new HorizontalLine;
196 void
197 PageDisplay::Setup_OperationsFile_for( const ary::cpp::Class & i_rClass )
199 csv_assert( Env().CurNamespace() != 0 );
200 Env().SetFile_Operations(0);
201 File().SetLocation( Env().CurPath(), Env().Depth() );
203 StreamLock sOpFile(100);
204 SetupFileOnCurEnv( sOpFile() << "Methods of Class "
205 << i_rClass.LocalName()
206 << c_str );
207 NavigationBar
208 aNavi( Env(),
209 NavigationBar::CEGT_operations );
210 aNavi.Write( CurOut() );
211 CurOut() << new HorizontalLine;
213 adcdisp::PageTitle_Std fTitle;
214 fTitle( CurOut(), "Methods of Class", i_rClass.LocalName() );
216 CurOut() << new HorizontalLine;
219 void
220 PageDisplay::Setup_DataFile_for( const ary::loc::File & i_rFile )
222 csv_assert( Env().CurNamespace() != 0 );
223 Env().SetFile_Data(&i_rFile);
224 File().SetLocation( Env().CurPath(), Env().Depth() );
226 StreamLock sDataFile(100);
227 SetupFileOnCurEnv( sDataFile() << "Global Data in Namespace "
228 << Env().CurNamespace()->LocalName()
229 << " in Sourcefile "
230 << i_rFile.LocalName()
231 << c_str );
232 NavigationBar
233 aNavi( Env(),
234 NavigationBar::CEGT_data );
235 aNavi.Write( CurOut() );
236 CurOut() << new HorizontalLine;
238 adcdisp::PageTitle_Std fTitle;
239 csi::xml::Element & rTitle = fTitle( CurOut() );
240 if ( Env().CurNamespace()->Owner().IsValid() )
242 rTitle << "Global Data in Namespace "
243 << Env().CurNamespace()->LocalName();
245 else
247 rTitle << "Global Data in Global Namespace C++";
250 rTitle
251 << new html::LineBreak
252 << "in Sourcefile "
253 << i_rFile.LocalName();
254 CurOut() << new HorizontalLine;
257 void
258 PageDisplay::Setup_DataFile_for( const ary::cpp::Class & i_rClass )
260 csv_assert( Env().CurNamespace() != 0 );
261 Env().SetFile_Data(0);
262 File().SetLocation( Env().CurPath(), Env().Depth() );
264 StreamLock sDataFile(100);
265 SetupFileOnCurEnv( sDataFile() << "Data of Class "
266 << i_rClass.LocalName()
267 << c_str );
269 NavigationBar
270 aNavi( Env(),
271 NavigationBar::CEGT_data );
272 aNavi.Write( CurOut() );
273 CurOut() << new HorizontalLine;
275 adcdisp::PageTitle_Std fTitle;
276 fTitle( CurOut(), "Data of Class", i_rClass.LocalName() );
278 CurOut() << new HorizontalLine;
281 void
282 PageDisplay::Create_File()
284 Easy().Leave();
285 File().CreateFile();
288 void
289 PageDisplay::do_Process(const ary::cpp::Class & i_rData)
291 Env().SetFile_Class(i_rData);
292 File().SetLocation( Env().CurPath(), Env().Depth() );
294 const char *
295 sTypeTitle = i_rData.ClassKey() == ary::cpp::CK_class
296 ? C_sHFTypeTitle_Class
297 : i_rData.ClassKey() == ary::cpp::CK_struct
298 ? C_sHFTypeTitle_Struct
299 : C_sHFTypeTitle_Union;
300 StreamLock sClassFile(60);
301 SetupFileOnCurEnv( sClassFile() << sTypeTitle
302 << " "
303 << i_rData.LocalName()
304 << c_str );
306 Make_SpecialPage( new PageMaker_Class(*this, i_rData) );
308 Create_File();
311 void
312 PageDisplay::do_Process(const ary::cpp::Enum & i_rData)
314 if ( Ce_IsInternal(i_rData) )
315 return;
317 Env().SetFile_Enum(i_rData);
318 File().SetLocation( Env().CurPath(), Env().Depth() );
320 StreamLock sEnumFile(100);
321 SetupFileOnCurEnv( sEnumFile() << C_sHFTypeTitle_Enum
322 << " "
323 << i_rData.LocalName()
324 << c_str );
325 Write_NavBar_Enum(i_rData);
326 Write_TopArea_Enum(i_rData);
327 Write_DocuArea_Enum(i_rData);
328 Write_ChildList_Enum(i_rData);
330 Create_File();
333 void
334 PageDisplay::do_Process(const ary::cpp::Typedef & i_rData)
336 if ( Ce_IsInternal(i_rData) )
337 return;
339 Env().SetFile_Typedef(i_rData);
340 File().SetLocation( Env().CurPath(), Env().Depth() );
342 StreamLock sTypedefFile(100);
343 SetupFileOnCurEnv( sTypedefFile() << C_sHFTypeTitle_Typedef
344 << " "
345 << i_rData.LocalName()
346 << c_str );
347 Write_NavBar_Typedef(i_rData);
348 Write_TopArea_Typedef(i_rData);
349 Write_DocuArea_Typedef(i_rData);
352 Create_File();
355 void
356 PageDisplay::Write_NameChainWithLinks( const ary::cpp::CodeEntity & i_rCe )
358 if ( Env().CurNamespace()->Id() != i_rCe.Id() )
360 RecursiveWrite_NamespaceLink( Env().CurNamespace() );
361 if ( Env().CurClass() != 0 )
363 CurOut() << new html::Sbr;
364 RecursiveWrite_ClassLink( Env().CurClass(), 1 );
367 else
369 RecursiveWrite_NamespaceLink( Env().CurNamespace()->Parent() );
373 const ary::cpp::Gate *
374 PageDisplay::inq_Get_ReFinder() const
376 return &Env().Gate();
379 void
380 PageDisplay::RecursiveWrite_NamespaceLink( const ary::cpp::Namespace * i_pNamespace )
382 if ( i_pNamespace == 0 )
384 return;
386 else if (NOT i_pNamespace->Owner().IsValid())
387 { // Global namespace:
388 StreamLock sNspDir(50);
389 CurOut()
390 >> *new Link( PathPerRoot(Env(),
391 sNspDir() << C_sDIR_NamespacesCpp
392 << "/"
393 << C_sHFN_Namespace
394 << c_str) )
395 << new xml::AnAttribute( "alt", C_sHFTitle_GlobalNamespaceCpp )
396 >> *new html::Font
397 << new html::SizeAttr("+1")
398 >> *new html::Bold
399 << "::";
400 CurOut()
401 << " ";
402 return;
404 else
406 RecursiveWrite_NamespaceLink( i_pNamespace->Parent() );
409 uintt nLevelDistance = Env().Depth() - ( i_pNamespace->Depth() + 1 );
410 csv_assert( nLevelDistance < 100 );
411 CurOut()
412 >> *new Link( PathPerLevelsUp(nLevelDistance, C_sHFN_Namespace) )
413 << new xml::AnAttribute( "alt", C_sHFTypeTitle_Namespace)
414 >> *new html::Font
415 << new html::SizeAttr("+1")
416 >> *new html::Bold
417 << i_pNamespace->LocalName();
418 CurOut()
419 >> *new html::Font
420 << new html::SizeAttr("+1")
421 << " :: ";
424 void
425 PageDisplay::RecursiveWrite_ClassLink( const ary::cpp::Class * i_pClass,
426 uintt i_nLevelDistance )
428 if ( i_pClass == 0 )
429 return;
431 if ( i_pClass->Protection() != ary::cpp::PROTECT_global )
433 RecursiveWrite_ClassLink(
434 dynamic_cast< const ary::cpp::Class* >(
435 Env().Gate().Ces().Search_Ce(i_pClass->Owner())),
436 i_nLevelDistance + 1 );
439 CurOut()
440 >> *new Link( Path2Class(i_nLevelDistance, i_pClass->LocalName()) )
441 << new html::ClassAttr("nqclass")
442 << i_pClass->LocalName()
443 << " :: ";
446 void
447 PageDisplay::SetupFileOnCurEnv( const char * i_sTitle )
449 File().SetLocation( Env().CurPath(), Env().Depth() );
450 File().SetTitle( i_sTitle );
451 File().SetCopyright( Env().Layout().CopyrightText() );
452 File().EmptyBody();
454 // This sets CurOut() to the contents of <body></body>
455 // in File() :
456 Easy().Enter( File().Body() );
459 void
460 PageDisplay::Write_NavBar_Enum( const ary::cpp::Enum & i_rData )
462 NavigationBar aNavi( Env(), i_rData );
463 aNavi.MakeSubRow("List of");
464 aNavi.AddItem( C_sTitle_EnumValues, C_sLabel_EnumValues, true );
465 aNavi.Write( CurOut(), true );
467 CurOut() << new HorizontalLine;
470 void
471 PageDisplay::Write_TopArea_Enum( const ary::cpp::Enum & i_rData )
473 Write_NameChainWithLinks( i_rData );
475 adcdisp::PageTitle_Std fTitle;
476 fTitle( CurOut(), C_sHFTypeTitle_Enum, i_rData.LocalName() );
478 CurOut() << new HorizontalLine;
481 void
482 PageDisplay::Write_DocuArea_Enum( const ary::cpp::Enum & i_rData )
484 Docu_Display aDocuShow( Env() );
486 aDocuShow.Assign_Out(CurOut());
487 aDocuShow.Process(i_rData.Docu());
488 aDocuShow.Unassign_Out();
490 CurOut() << new HorizontalLine;
493 void
494 PageDisplay::Write_ChildList_Enum( const ary::cpp::Enum & i_rData )
496 bool bChildrenExist = false;
497 ChildList_Display::Area_Result
498 aResult( bChildrenExist, CurOut() );
500 ChildList_Display aDisplay(Env(), i_rData);
501 aDisplay.Run_Simple( aResult,
502 ary::cpp::Enum::SLOT_Values,
503 C_sLabel_EnumValues,
504 C_sTitle_EnumValues );
506 if (NOT bChildrenExist)
507 CurOut() >> *new html::Headline(4) << "This enum has no values.";
508 CurOut() << new HorizontalLine;
511 void
512 PageDisplay::Write_NavBar_Typedef( const ary::cpp::Typedef & i_rData )
514 NavigationBar aNavi( Env(), i_rData );
515 aNavi.Write( CurOut(), true );
517 CurOut() << new HorizontalLine;
520 void
521 PageDisplay::Write_TopArea_Typedef( const ary::cpp::Typedef & i_rData )
523 Write_NameChainWithLinks( i_rData );
525 adcdisp::PageTitle_Std fTitle;
526 fTitle( CurOut(), C_sHFTypeTitle_Typedef, i_rData.LocalName() );
528 CurOut() << new HorizontalLine;
531 void
532 PageDisplay::Write_DocuArea_Typedef( const ary::cpp::Typedef & i_rData )
534 adcdisp::ExplanationList aDef( CurOut() );
535 aDef.AddEntry("Definition:");
536 xml::Element & rDef = aDef.Def();
538 ary::cpp::Type_id
539 nDefiningType = i_rData.DescribingType();
541 const ary::cpp::CodeEntity *
542 pRelatedCe = Env().Gate().Search_RelatedCe(nDefiningType);
543 if ( pRelatedCe != 0 )
545 const char * sTypeKey = Get_TypeKey(*pRelatedCe);
546 if ( NOT csv::no_str(sTypeKey) )
547 rDef << sTypeKey << " ";
550 dshelp::Get_LinkedTypeText( rDef, Env(), nDefiningType );
552 Docu_Display aDocuShow( Env() );
554 aDocuShow.Assign_Out(CurOut());
555 aDocuShow.Process(i_rData.Docu());
556 aDocuShow.Unassign_Out();
558 CurOut() << new HorizontalLine;
561 void
562 PageDisplay::Create_IndexFile( int i_nLetter )
564 static char aLetters[C_nNrOfIndexLetters+1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
565 csv_assert( 0 <= i_nLetter AND i_nLetter < C_nNrOfIndexLetters );
567 char cCurLetter = aLetters[i_nLetter];
568 Env().SetFile_Index( cCurLetter );
570 static char sIndexFileTitle[] = "Global Index X";
571 const int nPositionOfLetterInTitle = 13;
572 sIndexFileTitle[nPositionOfLetterInTitle] = cCurLetter;
573 SetupFileOnCurEnv( sIndexFileTitle );
575 Make_SpecialPage( new PageMaker_Index(*this, cCurLetter ) );
577 Create_File();