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 <html/chd_udk2.hxx>
24 
25 
26 // NOT FULLY DEFINED SERVICES
27 #include <cosv/tpl/tpltools.hxx>
28 #include <ary/ary_disp.hxx>
29 #include <ary/ceslot.hxx>
30 #include <ary/cpp/c_gate.hxx>
31 #include <ary/cpp/c_namesp.hxx>
32 #include <ary/cpp/cp_ce.hxx>
33 
34 #include "dsply_cl.hxx"
35 #include "dsply_da.hxx"
36 #include "dsply_op.hxx"
37 #include "opageenv.hxx"
38 #include "outfile.hxx"
39 #include "pagemake.hxx"
40 
41 
42 
43 //********************      CppHtmlDisplay_Udk2     ********************//
44 
45 
CppHtmlDisplay_Udk2()46 CppHtmlDisplay_Udk2::CppHtmlDisplay_Udk2()
47     :   pCurPageEnv(0)
48 {
49 }
50 
~CppHtmlDisplay_Udk2()51 CppHtmlDisplay_Udk2::~CppHtmlDisplay_Udk2()
52 {
53 }
54 
55 void
do_Run(const char * i_sOutputDirectory,const ary::cpp::Gate & i_rAryGate,const display::CorporateFrame & i_rLayout)56 CppHtmlDisplay_Udk2::do_Run( const char *                      i_sOutputDirectory,
57                              const ary::cpp::Gate &            i_rAryGate,
58                              const display::CorporateFrame &   i_rLayout )
59 {
60     SetRunData( i_sOutputDirectory, i_rAryGate, i_rLayout );
61 
62     Create_Css_File();
63     Create_Overview_File();
64     Create_Help_File();
65     Create_AllDefs_File();
66 
67     CreateFiles_InSubTree_Namespaces();
68     CreateFiles_InSubTree_Index();
69 }
70 
71 void
SetRunData(const char * i_sOutputDirectory,const ary::cpp::Gate & i_rAryGate,const display::CorporateFrame & i_rLayout)72 CppHtmlDisplay_Udk2::SetRunData( const char *                       i_sOutputDirectory,
73                                  const ary::cpp::Gate &             i_rAryGate,
74                                  const display::CorporateFrame &    i_rLayout )
75 {
76     csv::ploc::Path aOutputDir( i_sOutputDirectory, true );
77     pCurPageEnv = new OuputPage_Environment( aOutputDir, i_rAryGate, i_rLayout );
78 }
79 
80 void
Create_Css_File()81 CppHtmlDisplay_Udk2::Create_Css_File()
82 {
83     pCurPageEnv->MoveDir_2Root();
84     pCurPageEnv->SetFile_Css();
85     HtmlDocuFile::WriteCssFile(pCurPageEnv->CurPath());
86 }
87 
88 void
Create_Overview_File()89 CppHtmlDisplay_Udk2::Create_Overview_File()
90 {
91     pCurPageEnv->MoveDir_2Root();
92     PageDisplay aPageMaker( *pCurPageEnv );
93     aPageMaker.Create_OverviewFile();
94 }
95 
96 void
Create_Help_File()97 CppHtmlDisplay_Udk2::Create_Help_File()
98 {
99     PageDisplay aPageMaker( *pCurPageEnv );
100     aPageMaker.Create_HelpFile();
101 }
102 
103 void
Create_AllDefs_File()104 CppHtmlDisplay_Udk2::Create_AllDefs_File()
105 {
106     PageDisplay aPageMaker( *pCurPageEnv );
107     aPageMaker.Create_AllDefsFile();
108 }
109 
110 void
CreateFiles_InSubTree_Namespaces()111 CppHtmlDisplay_Udk2::CreateFiles_InSubTree_Namespaces()
112 {
113     Cout() << "\nCreate files in subtree namespaces" << Endl();
114 
115     const ary::cpp::Namespace &
116         rGlobalNsp = Gate().Ces().GlobalNamespace();
117 
118     RecursiveDisplay_Namespace(rGlobalNsp);
119     Cout() << Endl();
120 }
121 
122 void
CreateFiles_InSubTree_Index()123 CppHtmlDisplay_Udk2::CreateFiles_InSubTree_Index()
124 {
125     Cout() << "\nCreate files in subtree index" << Endl();
126     Cout() << Endl();
127 
128     PageDisplay aPageMaker( *pCurPageEnv );
129     aPageMaker.Create_IndexFiles();
130 }
131 
132 void
RecursiveDisplay_Namespace(const ary::cpp::Namespace & i_rNsp)133 CppHtmlDisplay_Udk2::RecursiveDisplay_Namespace( const ary::cpp::Namespace & i_rNsp )
134 {
135     if (i_rNsp.Owner().IsValid())
136         pCurPageEnv->MoveDir_Down2( i_rNsp );
137     else
138         pCurPageEnv->MoveDir_2Names();
139     DisplayFiles_InNamespace( i_rNsp );
140 
141     typedef std::vector< const ary::cpp::Namespace* > NspList;
142     NspList     aSubNspList;
143     i_rNsp.Get_SubNamespaces( aSubNspList );
144     for ( NspList::const_iterator it = aSubNspList.begin();
145           it != aSubNspList.end();
146           ++it )
147     {
148         RecursiveDisplay_Namespace( *(*it) );
149     }   // end for
150 
151 	pCurPageEnv->MoveDir_Up();
152 }
153 
154 void
DisplayFiles_InNamespace(const ary::cpp::Namespace & i_rNsp)155 CppHtmlDisplay_Udk2::DisplayFiles_InNamespace( const ary::cpp::Namespace & i_rNsp )
156 {
157     PageDisplay aPageMaker( *pCurPageEnv );
158 
159     ary::Slot_AutoPtr pSlot;
160 
161     // Namespace
162     aPageMaker.Create_NamespaceFile();
163 
164     // Classes
165     ClassDisplayer aClassDisplayer( *pCurPageEnv );
166     DisplaySlot( aClassDisplayer, i_rNsp, ary::cpp::Namespace::SLOT_Classes );
167 
168     // Enums
169     DisplaySlot( aPageMaker, i_rNsp, ary::cpp::Namespace::SLOT_Enums );
170 
171     // Typedefs
172     DisplaySlot( aPageMaker, i_rNsp, ary::cpp::Namespace::SLOT_Typedefs );
173 
174     // Operations
175     OperationsDisplay aOperationsDisplayer( *pCurPageEnv );
176     DisplaySlot( aOperationsDisplayer, i_rNsp, ary::cpp::Namespace::SLOT_Operations );
177     aOperationsDisplayer.Create_Files();
178 
179     // Data
180     DataDisplay aDataDisplayer( *pCurPageEnv );
181 
182     aDataDisplayer.PrepareForConstants();
183     DisplaySlot( aDataDisplayer, i_rNsp, ary::cpp::Namespace::SLOT_Constants );
184 
185     aDataDisplayer.PrepareForVariables();
186     DisplaySlot( aDataDisplayer, i_rNsp, ary::cpp::Namespace::SLOT_Variables );
187 
188     aDataDisplayer.Create_Files();
189 }
190 
191 const ary::cpp::Gate &
Gate() const192 CppHtmlDisplay_Udk2::Gate() const
193 {
194     return pCurPageEnv->Gate();
195 }
196