1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pagemake.cxx,v $
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 ************************************************************************/
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"
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"
61 using csi::html::Link
;
62 using csi::html::HorizontalLine
;
65 const int C_nNrOfIndexLetters
= 27;
68 template <class SPECIAL_MAKER
>
70 Make_SpecialPage( DYN SPECIAL_MAKER
* let_dpMaker
)
72 Dyn
< SPECIAL_MAKER
> pMaker( let_dpMaker
);
78 PageDisplay::PageDisplay( OuputPage_Environment
& io_rEnv
)
79 : HtmlDisplay_Impl( io_rEnv
),
80 pMyFile( new HtmlDocuFile
)
84 PageDisplay::~PageDisplay()
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) );
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) );
116 PageDisplay::Create_IndexFiles()
118 Env().MoveDir_2Index();
120 for ( int i
= 0; i
< C_nNrOfIndexLetters
; ++i
)
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) );
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
146 << Env().CurNamespace()->LocalName()
151 SetupFileOnCurEnv( C_sHFTitle_GlobalNamespaceCpp
);
154 Make_SpecialPage( new PageMaker_Namespace(*this) );
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()
170 << i_rFile
.LocalName()
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();
187 rTitle
<< "Global Functions in Global Namespace C++";
190 rTitle
<< new html::LineBreak
192 << i_rFile
.LocalName();
193 CurOut() << new HorizontalLine
;
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()
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
;
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()
230 << i_rFile
.LocalName()
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();
247 rTitle
<< "Global Data in Global Namespace C++";
251 << new html::LineBreak
253 << i_rFile
.LocalName();
254 CurOut() << new HorizontalLine
;
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()
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
;
282 PageDisplay::Create_File()
289 PageDisplay::do_Process(const ary::cpp::Class
& i_rData
)
291 Env().SetFile_Class(i_rData
);
292 File().SetLocation( Env().CurPath(), Env().Depth() );
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
303 << i_rData
.LocalName()
306 Make_SpecialPage( new PageMaker_Class(*this, i_rData
) );
312 PageDisplay::do_Process(const ary::cpp::Enum
& i_rData
)
314 if ( Ce_IsInternal(i_rData
) )
317 Env().SetFile_Enum(i_rData
);
318 File().SetLocation( Env().CurPath(), Env().Depth() );
320 StreamLock
sEnumFile(100);
321 SetupFileOnCurEnv( sEnumFile() << C_sHFTypeTitle_Enum
323 << i_rData
.LocalName()
325 Write_NavBar_Enum(i_rData
);
326 Write_TopArea_Enum(i_rData
);
327 Write_DocuArea_Enum(i_rData
);
328 Write_ChildList_Enum(i_rData
);
334 PageDisplay::do_Process(const ary::cpp::Typedef
& i_rData
)
336 if ( Ce_IsInternal(i_rData
) )
339 Env().SetFile_Typedef(i_rData
);
340 File().SetLocation( Env().CurPath(), Env().Depth() );
342 StreamLock
sTypedefFile(100);
343 SetupFileOnCurEnv( sTypedefFile() << C_sHFTypeTitle_Typedef
345 << i_rData
.LocalName()
347 Write_NavBar_Typedef(i_rData
);
348 Write_TopArea_Typedef(i_rData
);
349 Write_DocuArea_Typedef(i_rData
);
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 );
369 RecursiveWrite_NamespaceLink( Env().CurNamespace()->Parent() );
373 const ary::cpp::Gate
*
374 PageDisplay::inq_Get_ReFinder() const
376 return &Env().Gate();
380 PageDisplay::RecursiveWrite_NamespaceLink( const ary::cpp::Namespace
* i_pNamespace
)
382 if ( i_pNamespace
== 0 )
386 else if (NOT i_pNamespace
->Owner().IsValid())
387 { // Global namespace:
388 StreamLock
sNspDir(50);
390 >> *new Link( PathPerRoot(Env(),
391 sNspDir() << C_sDIR_NamespacesCpp
395 << new xml::AnAttribute( "alt", C_sHFTitle_GlobalNamespaceCpp
)
397 << new html::SizeAttr("+1")
406 RecursiveWrite_NamespaceLink( i_pNamespace
->Parent() );
409 uintt nLevelDistance
= Env().Depth() - ( i_pNamespace
->Depth() + 1 );
410 csv_assert( nLevelDistance
< 100 );
412 >> *new Link( PathPerLevelsUp(nLevelDistance
, C_sHFN_Namespace
) )
413 << new xml::AnAttribute( "alt", C_sHFTypeTitle_Namespace
)
415 << new html::SizeAttr("+1")
417 << i_pNamespace
->LocalName();
420 << new html::SizeAttr("+1")
425 PageDisplay::RecursiveWrite_ClassLink( const ary::cpp::Class
* i_pClass
,
426 uintt i_nLevelDistance
)
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 );
440 >> *new Link( Path2Class(i_nLevelDistance
, i_pClass
->LocalName()) )
441 << new html::ClassAttr("nqclass")
442 << i_pClass
->LocalName()
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() );
454 // This sets CurOut() to the contents of <body></body>
456 Easy().Enter( File().Body() );
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
;
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
;
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
;
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
,
504 C_sTitle_EnumValues
);
506 if (NOT bChildrenExist
)
507 CurOut() >> *new html::Headline(4) << "This enum has no values.";
508 CurOut() << new HorizontalLine
;
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
;
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
;
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();
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
;
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
) );