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: hi_main.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 "hi_main.hxx"
35 // NOT FULLY DEFINED SERVICES
37 #include <cosv/ploc.hxx>
38 #include <cosv/file.hxx>
39 #include <ary/idl/i_ce.hxx>
40 #include <ary/idl/ik_ce.hxx>
41 #include <ary/idl/ik_enum.hxx>
42 #include <ary/idl/ik_typedef.hxx>
43 #include <ary/idl/ik_interface.hxx>
44 #include <ary/idl/ik_struct.hxx>
45 #include <ary/idl/ik_exception.hxx>
46 #include <ary/idl/i_constant.hxx>
47 #include <ary/idl/i_constgroup.hxx>
48 #include <ary/idl/i_enum.hxx>
49 #include <ary/idl/i_singleton.hxx>
50 #include <ary/idl/i_sisingleton.hxx>
51 #include <ary/idl/i_exception.hxx>
52 #include <ary/idl/i_interface.hxx>
53 #include <ary/idl/i_service.hxx>
54 #include <ary/idl/i_siservice.hxx>
55 #include <ary/idl/i_struct.hxx>
56 #include <ary/idl/i_typedef.hxx>
57 #include <ary/idl/i_module.hxx>
59 #include <toolkit/htmlfile.hxx>
60 #include <toolkit/out_position.hxx>
61 #include <toolkit/out_tree.hxx>
62 #include "hfi_constgroup.hxx"
63 #include "hfi_enum.hxx"
64 #include "hfi_globalindex.hxx"
65 #include "hfi_interface.hxx"
66 #include "hfi_module.hxx"
67 #include "hfi_struct.hxx"
68 #include "hfi_service.hxx"
69 #include "hfi_singleton.hxx"
70 #include "hfi_siservice.hxx"
71 #include "hfi_typedef.hxx"
72 #include "hfi_xrefpage.hxx"
74 #include "hi_linkhelper.hxx"
77 using ::ary::idl::Ce_id
;
78 using ::ary::idl::Type_id
;
79 using ::ary::idl::ifc_ce::Dyn_CeIterator
;
83 extern const String
C_sCssFilename_Idl("idl.css");
86 typedef ::ary::Dyn_StdConstIterator< ::ary::idl::CommentedRelation>
88 namespace read_module = ::ary::idl::ifc_module;
89 namespace read_interface = ::ary::idl::ifc_interface;
90 namespace read_service = ::ary::idl::ifc_service;
91 namespace read_struct = ::ary::idl::ifc_struct;
92 namespace read_exception = ::ary::idl::ifc_exception;
93 namespace read_enum = ::ary::idl::ifc_enum;
94 namespace read_typedef = ::ary::idl::ifc_typedef;
95 namespace read_constgroup = ::ary::idl::ifc_constantsgroup;
102 Inits (constructor) and creates (destructor) the current
103 html documentation file ( MainDisplay_Idl.pMyFile ).
108 Guard_CurFile( /// For CodeEntities
109 DocuFile_Html
& io_client
,
110 HtmlEnvironment_Idl
&
112 const ary::idl::CodeEntity
&
114 const String
& i_titlePrefix
);
115 Guard_CurFile( /// For Use pages
116 DocuFile_Html
& io_client
,
117 HtmlEnvironment_Idl
&
119 const String
& i_fileName
,
120 const String
& i_titlePrefix
);
121 Guard_CurFile( /// For Modules
122 DocuFile_Html
& io_client
,
123 HtmlEnvironment_Idl
&
125 const ary::idl::CodeEntity
&
127 Guard_CurFile( /// For Indices
128 DocuFile_Html
& io_client
,
129 HtmlEnvironment_Idl
&
134 DocuFile_Html
& rClient
;
135 HtmlEnvironment_Idl
&
141 Sets and releases the current factory pointer
142 ( MainDisplay_Idl.pCurFactory ).
144 class Guard_CurFactoryPtr
148 HtmlFactory_Idl
*& io_client
,
149 HtmlFactory_Idl
& i_factory
)
150 : rpClient(io_client
)
151 { rpClient
= &i_factory
; }
153 ~Guard_CurFactoryPtr()
157 HtmlFactory_Idl
*& rpClient
;
162 Guard_CurFile::Guard_CurFile( DocuFile_Html
& io_client
,
163 HtmlEnvironment_Idl
& io_env
,
164 const ary::idl::CodeEntity
& i_ce
,
165 const String
& i_titlePrefix
)
166 : rClient(io_client
),
170 io_env
.Set_CurFile( sl() << i_ce
.LocalName()
173 StreamLock
aCurFilePath(700);
174 io_env
.Get_CurFilePath(aCurFilePath());
178 aLocation(aCurFilePath().c_str());
179 rClient
.SetLocation(aLocation
);
181 rClient
.SetTitle( sl() << i_titlePrefix
186 rClient
.SetRelativeCssPath(
187 sl() << io_env
.CurPosition().LinkToRoot()
188 << C_sCssFilename_Idl
191 io_env
.Set_CurPageCe(&i_ce
);
194 Guard_CurFile::Guard_CurFile( DocuFile_Html
& io_client
,
195 HtmlEnvironment_Idl
& io_env
,
196 const String
& i_fileName
,
197 const String
& i_titlePrefix
)
198 : rClient(io_client
),
202 io_env
.Set_CurFile( sl() << i_fileName
205 StreamLock
aCurFilePath(700);
206 io_env
.Get_CurFilePath(aCurFilePath());
208 aLocation(aCurFilePath().c_str());
211 rClient
.SetLocation(aLocation
);
213 rClient
.SetTitle( sl() << i_titlePrefix
<< " " << i_fileName
<< c_str
);
215 rClient
.SetRelativeCssPath(
216 sl() << io_env
.CurPosition().LinkToRoot()
217 << C_sCssFilename_Idl
220 io_env
.Set_CurPageCe(0);
223 Guard_CurFile::Guard_CurFile( DocuFile_Html
& io_client
,
224 HtmlEnvironment_Idl
& io_env
,
225 const ary::idl::CodeEntity
& i_ce
)
226 : rClient(io_client
),
229 io_env
.Set_CurFile( output::ModuleFileName() );
230 StreamLock
aCurFilePath(700);
231 io_env
.Get_CurFilePath(aCurFilePath());
233 aLocation(aCurFilePath().c_str());
236 rClient
.SetLocation(aLocation
);
238 rClient
.SetTitle( sl() << "Module " << io_env
.CurPosition().Name() << c_str
);
240 rClient
.SetRelativeCssPath(
241 sl() << io_env
.CurPosition().LinkToRoot()
242 << C_sCssFilename_Idl
245 io_env
.Set_CurPageCe(&i_ce
);
248 Guard_CurFile::Guard_CurFile( DocuFile_Html
& io_client
,
249 HtmlEnvironment_Idl
& io_env
,
251 : rClient(io_client
),
255 io_env
.Set_CurFile( sl() << "index-"
257 ? int(i_letter
)-'a'+1
261 StreamLock
aCurFilePath(700);
262 io_env
.Get_CurFilePath(aCurFilePath());
264 aLocation(aCurFilePath().c_str());
267 rClient
.SetLocation(aLocation
);
269 rClient
.SetTitle( sl() << "Global Index "
271 ? char(i_letter
-'a'+'A')
275 rClient
.SetRelativeCssPath(
277 << C_sCssFilename_Idl
281 Guard_CurFile::~Guard_CurFile()
283 rClient
.CreateFile();
284 rEnv
.Set_CurPageCe(0);
288 } // anonymous namespace
293 MainDisplay_Idl::MainDisplay_Idl( HtmlEnvironment_Idl
& io_rEnv
)
295 pMyFile(new DocuFile_Html
),
298 // pMyFile->SetStyle( Env().Layout().CssStyle() );
299 pMyFile
->SetCopyright( Env().Layout().CopyrightText() );
302 MainDisplay_Idl::~MainDisplay_Idl()
308 MainDisplay_Idl::WriteGlobalIndices()
310 for ( const char * pLetter
= "abcdefghijklmnopqrstuvwxyz_X"; *pLetter
!= 'X'; ++pLetter
)
312 Guard_CurFile
gFile( *pMyFile
, Env(), *pLetter
);
314 HF_IdlGlobalIndex
aFactory( *pEnv
, pMyFile
->Body() );
315 Guard_CurFactoryPtr
gFactory(pCurFactory
,aFactory
);
317 aFactory
.Produce_Page( ary::idl::alphabetical_index::E_Letter(*pLetter
) );
323 MainDisplay_Idl::do_Process( const ary::idl::Module
& i_ce
)
325 Guard_CurFile
gFile( *pMyFile
,
328 HF_IdlModule
aFactory( *pEnv
, pMyFile
->Body() );
329 Guard_CurFactoryPtr
gFactory(pCurFactory
,aFactory
);
331 aFactory
.Produce_byData(i_ce
);
335 MainDisplay_Idl::do_Process( const ary::idl::Interface
& i_ce
)
337 do_InterfaceDescr(i_ce
);
338 do_Interface2s(i_ce
);
342 MainDisplay_Idl::do_Process( const ary::idl::Service
& i_ce
)
344 do_ServiceDescr(i_ce
);
349 MainDisplay_Idl::do_Process( const ary::idl::SglIfcService
& i_ce
)
351 do_SglIfcServiceDescr(i_ce
);
355 MainDisplay_Idl::do_Process( const ary::idl::Struct
& i_ce
)
357 do_StructDescr(i_ce
);
362 MainDisplay_Idl::do_Process( const ary::idl::Exception
& i_ce
)
364 do_ExceptionDescr(i_ce
);
365 do_Exception2s(i_ce
);
369 MainDisplay_Idl::do_Process( const ary::idl::Enum
& i_ce
)
376 MainDisplay_Idl::do_Process( const ary::idl::Typedef
& i_ce
)
378 do_TypedefDescr(i_ce
);
383 MainDisplay_Idl::do_Process( const ary::idl::ConstantsGroup
& i_ce
)
385 Guard_CurFile
gFile( *pMyFile
,
388 "Constants' Group" );
389 HF_IdlConstGroup
aFactory( *pEnv
, pMyFile
->Body() );
390 Guard_CurFactoryPtr
gFactory(pCurFactory
,aFactory
);
392 aFactory
.Produce_byData(i_ce
);
396 MainDisplay_Idl::do_Process( const ary::idl::Singleton
& i_ce
)
398 Guard_CurFile
gFile( *pMyFile
,
402 HF_IdlSingleton
aFactory( *pEnv
, pMyFile
->Body() );
403 Guard_CurFactoryPtr
gFactory(pCurFactory
,aFactory
);
405 aFactory
.Produce_byData_ServiceBased(i_ce
);
409 MainDisplay_Idl::do_Process( const ary::idl::SglIfcSingleton
& i_ce
)
411 Guard_CurFile
gFile( *pMyFile
,
415 HF_IdlSingleton
aFactory( *pEnv
, pMyFile
->Body() );
416 Guard_CurFactoryPtr
gFactory(pCurFactory
,aFactory
);
418 aFactory
.Produce_byData_InterfaceBased(i_ce
);
422 MainDisplay_Idl::do_InterfaceDescr( const ary::idl::CodeEntity
& i_ce
)
424 Guard_CurFile
gFile( *pMyFile
,
428 HF_IdlInterface
aInterface( *pEnv
, pMyFile
->Body() );
429 Guard_CurFactoryPtr
gFactory(pCurFactory
,aInterface
);
431 aInterface
.Produce_byData(i_ce
);
435 MainDisplay_Idl::do_ServiceDescr( const ary::idl::CodeEntity
& i_ce
)
437 Guard_CurFile
gFile( *pMyFile
,
441 HF_IdlService
aFactory( *pEnv
, pMyFile
->Body() );
442 Guard_CurFactoryPtr
gFactory(pCurFactory
,aFactory
);
444 aFactory
.Produce_byData(i_ce
);
448 MainDisplay_Idl::do_SglIfcServiceDescr( const ary::idl::CodeEntity
& i_ce
)
450 Guard_CurFile
gFile( *pMyFile
,
454 HF_IdlSglIfcService
aFactory( *pEnv
, pMyFile
->Body() );
455 Guard_CurFactoryPtr
gFactory(pCurFactory
,aFactory
);
457 aFactory
.Produce_byData(i_ce
);
461 MainDisplay_Idl::do_StructDescr( const ary::idl::CodeEntity
& i_ce
)
463 Guard_CurFile
gFile( *pMyFile
,
467 HF_IdlStruct
aFactory( *pEnv
, pMyFile
->Body(), false );
468 Guard_CurFactoryPtr
gFactory(pCurFactory
,aFactory
);
470 aFactory
.Produce_byData(i_ce
);
474 MainDisplay_Idl::do_ExceptionDescr( const ary::idl::CodeEntity
& i_ce
)
476 Guard_CurFile
gFile( *pMyFile
,
480 HF_IdlStruct
aFactory( *pEnv
, pMyFile
->Body(), true );
481 Guard_CurFactoryPtr
gFactory(pCurFactory
,aFactory
);
483 aFactory
.Produce_byData(i_ce
);
487 MainDisplay_Idl::do_EnumDescr( const ary::idl::CodeEntity
& i_ce
)
489 Guard_CurFile
gFile( *pMyFile
,
493 HF_IdlEnum
aFactory( *pEnv
, pMyFile
->Body() );
494 Guard_CurFactoryPtr
gFactory(pCurFactory
,aFactory
);
496 aFactory
.Produce_byData(i_ce
);
500 MainDisplay_Idl::do_TypedefDescr( const ary::idl::CodeEntity
& i_ce
)
502 Guard_CurFile
gFile( *pMyFile
,
506 HF_IdlTypedef
aFactory( *pEnv
, pMyFile
->Body() );
507 Guard_CurFactoryPtr
gFactory(pCurFactory
,aFactory
);
509 aFactory
.Produce_byData(i_ce
);
513 MainDisplay_Idl::do_Interface2s( const ary::idl::CodeEntity
& i_ce
)
516 String
sUsesFileName(
519 << Env().Linker().XrefsSuffix()
521 Guard_CurFile
gFile( *pMyFile
,
524 "Uses of Interface" );
525 HF_IdlXrefs
aUses( *pEnv
,
527 C_sCePrefix_Interface
,
532 "Derived Interfaces",
535 &ary::idl::ifc_interface::xref::Get_Derivations
);
537 Dyn_CeIterator pXrefList
;
539 ary::idl::ifc_interface::xref::Get_SynonymTypedefs(pXrefList
,i_ce
);
544 ary::idl::ifc_interface::xref::Get_ExportingServices(pXrefList
,i_ce
);
546 "Services which Support this Interface",
547 "#SupportingServices",
549 ary::idl::ifc_interface::xref::Get_ExportingSingletons(pXrefList
,i_ce
);
551 "Singletons which Support this Interface",
552 "#SupportingSingletons",
554 ary::idl::ifc_interface::xref::Get_AsReturns(pXrefList
,i_ce
);
556 "Uses as Return Type",
559 ary::idl::ifc_interface::xref::Get_AsParameters(pXrefList
,i_ce
);
564 ary::idl::ifc_interface::xref::Get_AsDataTypes(pXrefList
,i_ce
);
569 aUses
.Write_ManualLinks(i_ce
);
573 MainDisplay_Idl::do_Service2s( const ary::idl::CodeEntity
& i_ce
)
576 String
sUsesFileName(
579 << Env().Linker().XrefsSuffix()
581 Guard_CurFile
gFile( *pMyFile
,
585 HF_IdlXrefs
aUses( *pEnv
,
589 Dyn_CeIterator pXrefList
;
590 ary::idl::ifc_service::xref::Get_IncludingServices(pXrefList
,i_ce
);
592 "Services which Include this Service",
593 "#IncludingServices",
596 ary::idl::ifc_service::xref::Get_InstantiatingSingletons(pXrefList
,i_ce
);
598 "Singletons which Instantiate this Service",
601 aUses
.Write_ManualLinks(i_ce
);
605 MainDisplay_Idl::do_Struct2s( const ary::idl::CodeEntity
& i_ce
)
608 String
sUsesFileName(
611 << Env().Linker().XrefsSuffix()
613 Guard_CurFile
gFile( *pMyFile
,
617 HF_IdlXrefs
aUses( *pEnv
,
626 &ary::idl::ifc_struct::xref::Get_Derivations
);
628 Dyn_CeIterator pXrefList
;
630 ary::idl::ifc_struct::xref::Get_SynonymTypedefs(pXrefList
,i_ce
);
635 ary::idl::ifc_struct::xref::Get_AsReturns(pXrefList
,i_ce
);
637 "Uses as Return Type",
640 ary::idl::ifc_struct::xref::Get_AsParameters(pXrefList
,i_ce
);
645 ary::idl::ifc_struct::xref::Get_AsDataTypes(pXrefList
,i_ce
);
650 aUses
.Write_ManualLinks(i_ce
);
654 MainDisplay_Idl::do_Exception2s( const ary::idl::CodeEntity
& i_ce
)
657 String
sUsesFileName(
660 << Env().Linker().XrefsSuffix()
662 Guard_CurFile
gFile( *pMyFile
,
665 "Uses of Exception" );
666 HF_IdlXrefs
aUses( *pEnv
,
668 C_sCePrefix_Exception
,
672 "Derived Exceptions",
675 &ary::idl::ifc_exception::xref::Get_Derivations
);
677 Dyn_CeIterator pXrefList
;
679 ary::idl::ifc_exception::xref::Get_RaisingFunctions(pXrefList
,i_ce
);
684 aUses
.Write_ManualLinks(i_ce
);
688 MainDisplay_Idl::do_Enum2s( const ary::idl::CodeEntity
& i_ce
)
691 String
sUsesFileName(
694 << Env().Linker().XrefsSuffix()
696 Guard_CurFile
gFile( *pMyFile
,
700 HF_IdlXrefs
aUses( *pEnv
,
704 Dyn_CeIterator pXrefList
;
705 ary::idl::ifc_enum::xref::Get_SynonymTypedefs(pXrefList
,i_ce
);
710 ary::idl::ifc_enum::xref::Get_AsReturns(pXrefList
,i_ce
);
712 "Uses as Return Type",
715 ary::idl::ifc_enum::xref::Get_AsParameters(pXrefList
,i_ce
);
720 ary::idl::ifc_enum::xref::Get_AsDataTypes(pXrefList
,i_ce
);
725 aUses
.Write_ManualLinks(i_ce
);
729 MainDisplay_Idl::do_Typedef2s( const ary::idl::CodeEntity
& i_ce
)
732 String
sUsesFileName(
733 sl() << i_ce
.LocalName()
734 << Env().Linker().XrefsSuffix()
736 Guard_CurFile
gFile( *pMyFile
,
740 HF_IdlXrefs
aUses( *pEnv
,
744 Dyn_CeIterator pXrefList
;
745 ary::idl::ifc_typedef::xref::Get_SynonymTypedefs(pXrefList
,i_ce
);
750 ary::idl::ifc_typedef::xref::Get_AsReturns(pXrefList
,i_ce
);
752 "Uses as Return Type",
755 ary::idl::ifc_typedef::xref::Get_AsParameters(pXrefList
,i_ce
);
760 ary::idl::ifc_typedef::xref::Get_AsDataTypes(pXrefList
,i_ce
);
765 aUses
.Write_ManualLinks(i_ce
);