1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include <html/chd_udk2.hxx>
30 
31 
32 // NOT FULLY DEFINED SERVICES
33 #include <cosv/tpl/tpltools.hxx>
34 #include <ary/ary_disp.hxx>
35 #include <ary/ceslot.hxx>
36 #include <ary/cpp/c_gate.hxx>
37 #include <ary/cpp/c_namesp.hxx>
38 #include <ary/cpp/cp_ce.hxx>
39 
40 #include "dsply_cl.hxx"
41 #include "dsply_da.hxx"
42 #include "dsply_op.hxx"
43 #include "opageenv.hxx"
44 #include "outfile.hxx"
45 #include "pagemake.hxx"
46 
47 
48 
49 //********************      CppHtmlDisplay_Udk2     ********************//
50 
51 
52 CppHtmlDisplay_Udk2::CppHtmlDisplay_Udk2()
53     :   pCurPageEnv(0)
54 {
55 }
56 
57 CppHtmlDisplay_Udk2::~CppHtmlDisplay_Udk2()
58 {
59 }
60 
61 void
62 CppHtmlDisplay_Udk2::do_Run( const char *                      i_sOutputDirectory,
63                              const ary::cpp::Gate &            i_rAryGate,
64                              const display::CorporateFrame &   i_rLayout )
65 {
66     SetRunData( i_sOutputDirectory, i_rAryGate, i_rLayout );
67 
68     Create_Css_File();
69     Create_Overview_File();
70     Create_Help_File();
71     Create_AllDefs_File();
72 
73     CreateFiles_InSubTree_Namespaces();
74     CreateFiles_InSubTree_Index();
75 }
76 
77 void
78 CppHtmlDisplay_Udk2::SetRunData( const char *                       i_sOutputDirectory,
79                                  const ary::cpp::Gate &             i_rAryGate,
80                                  const display::CorporateFrame &    i_rLayout )
81 {
82     csv::ploc::Path aOutputDir( i_sOutputDirectory, true );
83     pCurPageEnv = new OuputPage_Environment( aOutputDir, i_rAryGate, i_rLayout );
84 }
85 
86 void
87 CppHtmlDisplay_Udk2::Create_Css_File()
88 {
89     pCurPageEnv->MoveDir_2Root();
90     pCurPageEnv->SetFile_Css();
91     HtmlDocuFile::WriteCssFile(pCurPageEnv->CurPath());
92 }
93 
94 void
95 CppHtmlDisplay_Udk2::Create_Overview_File()
96 {
97     pCurPageEnv->MoveDir_2Root();
98     PageDisplay aPageMaker( *pCurPageEnv );
99     aPageMaker.Create_OverviewFile();
100 }
101 
102 void
103 CppHtmlDisplay_Udk2::Create_Help_File()
104 {
105     PageDisplay aPageMaker( *pCurPageEnv );
106     aPageMaker.Create_HelpFile();
107 }
108 
109 void
110 CppHtmlDisplay_Udk2::Create_AllDefs_File()
111 {
112     PageDisplay aPageMaker( *pCurPageEnv );
113     aPageMaker.Create_AllDefsFile();
114 }
115 
116 void
117 CppHtmlDisplay_Udk2::CreateFiles_InSubTree_Namespaces()
118 {
119     Cout() << "\nCreate files in subtree namespaces" << Endl();
120 
121     const ary::cpp::Namespace &
122         rGlobalNsp = Gate().Ces().GlobalNamespace();
123 
124     RecursiveDisplay_Namespace(rGlobalNsp);
125     Cout() << Endl();
126 }
127 
128 void
129 CppHtmlDisplay_Udk2::CreateFiles_InSubTree_Index()
130 {
131     Cout() << "\nCreate files in subtree index" << Endl();
132     Cout() << Endl();
133 
134     PageDisplay aPageMaker( *pCurPageEnv );
135     aPageMaker.Create_IndexFiles();
136 }
137 
138 void
139 CppHtmlDisplay_Udk2::RecursiveDisplay_Namespace( const ary::cpp::Namespace & i_rNsp )
140 {
141     if (i_rNsp.Owner().IsValid())
142         pCurPageEnv->MoveDir_Down2( i_rNsp );
143     else
144         pCurPageEnv->MoveDir_2Names();
145     DisplayFiles_InNamespace( i_rNsp );
146 
147     typedef std::vector< const ary::cpp::Namespace* > NspList;
148     NspList     aSubNspList;
149     i_rNsp.Get_SubNamespaces( aSubNspList );
150     for ( NspList::const_iterator it = aSubNspList.begin();
151           it != aSubNspList.end();
152           ++it )
153     {
154         RecursiveDisplay_Namespace( *(*it) );
155     }   // end for
156 
157 	pCurPageEnv->MoveDir_Up();
158 }
159 
160 void
161 CppHtmlDisplay_Udk2::DisplayFiles_InNamespace( const ary::cpp::Namespace & i_rNsp )
162 {
163     PageDisplay aPageMaker( *pCurPageEnv );
164 
165     ary::Slot_AutoPtr pSlot;
166 
167     // Namespace
168     aPageMaker.Create_NamespaceFile();
169 
170     // Classes
171     ClassDisplayer aClassDisplayer( *pCurPageEnv );
172     DisplaySlot( aClassDisplayer, i_rNsp, ary::cpp::Namespace::SLOT_Classes );
173 
174     // Enums
175     DisplaySlot( aPageMaker, i_rNsp, ary::cpp::Namespace::SLOT_Enums );
176 
177     // Typedefs
178     DisplaySlot( aPageMaker, i_rNsp, ary::cpp::Namespace::SLOT_Typedefs );
179 
180     // Operations
181     OperationsDisplay aOperationsDisplayer( *pCurPageEnv );
182     DisplaySlot( aOperationsDisplayer, i_rNsp, ary::cpp::Namespace::SLOT_Operations );
183     aOperationsDisplayer.Create_Files();
184 
185     // Data
186     DataDisplay aDataDisplayer( *pCurPageEnv );
187 
188     aDataDisplayer.PrepareForConstants();
189     DisplaySlot( aDataDisplayer, i_rNsp, ary::cpp::Namespace::SLOT_Constants );
190 
191     aDataDisplayer.PrepareForVariables();
192     DisplaySlot( aDataDisplayer, i_rNsp, ary::cpp::Namespace::SLOT_Variables );
193 
194     aDataDisplayer.Create_Files();
195 }
196 
197 const ary::cpp::Gate &
198 CppHtmlDisplay_Udk2::Gate() const
199 {
200     return pCurPageEnv->Gate();
201 }
202