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 "pm_aldef.hxx"
24
25
26 // NOT FULLY DEFINED SERVICES
27 #include <cosv/tpl/tpltools.hxx>
28 #include <ary/cpp/c_gate.hxx>
29 #include <ary/cpp/c_define.hxx>
30 #include <ary/cpp/c_macro.hxx>
31 #include <ary/cpp/cp_def.hxx>
32 #include <ary/loc/loc_file.hxx>
33 #include <ary/loc/locp_le.hxx>
34 #include <ary/getncast.hxx>
35 #include "hd_docu.hxx"
36 #include "html_kit.hxx"
37 #include "navibar.hxx"
38 #include "opageenv.hxx"
39 #include "pagemake.hxx"
40 #include "strconst.hxx"
41
42
43 using namespace csi;
44 using csi::html::HorizontalLine;
45 using csi::html::Link;
46 using csi::html::Label;
47 using csi::html::AlignAttr;
48
49
50
PageMaker_AllDefs(PageDisplay & io_rPage)51 PageMaker_AllDefs::PageMaker_AllDefs( PageDisplay & io_rPage )
52 : SpecializedPageMaker(io_rPage),
53 pDocuDisplay( new Docu_Display(io_rPage.Env()) ),
54 pNavi(0)
55 {
56 }
57
~PageMaker_AllDefs()58 PageMaker_AllDefs::~PageMaker_AllDefs()
59 {
60 }
61
62 void
MakePage()63 PageMaker_AllDefs::MakePage()
64 {
65 pNavi = new NavigationBar( Env(), NavigationBar::LOC_AllDefs );
66 Write_NavBar();
67
68 Write_TopArea();
69
70 Write_DefinesList();
71 Write_MacrosList();
72
73 pNavi->Write_SubRows();
74 }
75
76 void
Write_NavBar()77 PageMaker_AllDefs::Write_NavBar()
78 {
79 pNavi->MakeSubRow( "" );
80 pNavi->AddItem( "Defines", "defines", true );
81 pNavi->AddItem( "Macros", "macros", true );
82 pNavi->Write( CurOut() );
83 CurOut() << new HorizontalLine;
84 }
85
86 void
Write_TopArea()87 PageMaker_AllDefs::Write_TopArea()
88 {
89 adcdisp::PageTitle_Std fTitle;
90 fTitle( CurOut(), "Defines and ", "Macros" );
91
92 CurOut() << new HorizontalLine;
93 }
94
95 void
Write_DocuArea()96 PageMaker_AllDefs::Write_DocuArea()
97 {
98 // Not needed.
99 }
100
101 void
Write_DefinesList()102 PageMaker_AllDefs::Write_DefinesList()
103 {
104 CurOut()
105 << new html::LineBreak
106 << new html::LineBreak
107 >> *new xml::AnElement("div")
108 << new html::ClassAttr("define")
109 >> *new html::Label("defines")
110 >> *new html::Headline(3)
111 << "Defines";
112
113 ary::cpp::DefsResultList
114 aAllDefines = Env().Gate().Defs().AllDefines();
115 ary::cpp::DefsConstIterator
116 itEnd = aAllDefines.end();
117
118 if (aAllDefines.begin() != itEnd)
119 {
120 for ( ary::cpp::DefsConstIterator it = aAllDefines.begin();
121 it != itEnd;
122 ++it )
123 {
124 Write_Define(*it);
125 }
126 }
127 else
128 {
129 CurOut() << "None.";
130 }
131
132 CurOut() << new HorizontalLine;
133 }
134
135 void
Write_MacrosList()136 PageMaker_AllDefs::Write_MacrosList()
137
138 {
139 CurOut()
140 << new html::LineBreak
141 << new html::LineBreak
142 >> *new xml::AnElement("div")
143 << new html::ClassAttr("define")
144 >> *new html::Label("macros")
145 >> *new html::Headline(3)
146 << "Macros";
147
148 ary::cpp::DefsResultList
149 aAllMacros = Env().Gate().Defs().AllMacros();
150 ary::cpp::DefsConstIterator
151 itEnd = aAllMacros.end();
152
153 if (aAllMacros.begin() != itEnd)
154 {
155 for ( ary::cpp::DefsConstIterator it = aAllMacros.begin();
156 it != itEnd;
157 ++it )
158 {
159 Write_Macro(*it);
160 }
161 }
162 else
163 {
164 CurOut() << "None.";
165 }
166
167 CurOut() << new HorizontalLine;
168 }
169
170 void
Write_Define(De_id i_nId)171 PageMaker_AllDefs::Write_Define(De_id i_nId)
172 {
173 csv_assert( ary::is_type<ary::cpp::Define>( Env().Gate().Defs().Find_Def(i_nId)) );
174 const ary::cpp::Define &
175 rDef = static_cast< const ary::cpp::Define& >( Env().Gate().Defs().Find_Def(i_nId) );
176
177 CurOut() << new html::HorizontalLine;
178
179 adcdisp::ExplanationList aDocu( CurOut(), true );
180 aDocu.AddEntry();
181
182 aDocu.Term()
183 >> *new html::Label( rDef.LocalName() )
184 << " ";
185 aDocu.Term()
186 << rDef.LocalName();
187
188 Write_DefsDocu( aDocu.Def(), rDef );
189 }
190
191 void
Write_Macro(De_id i_nId)192 PageMaker_AllDefs::Write_Macro(De_id i_nId)
193 {
194 csv_assert( Env().Gate().Defs().Find_Def(i_nId).AryClass() == ary::cpp::Macro::class_id );
195 const ary::cpp::Macro &
196 rDef = static_cast< const ary::cpp::Macro& >( Env().Gate().Defs().Find_Def(i_nId) );
197
198 CurOut() << new html::HorizontalLine;
199
200 adcdisp::ExplanationList aDocu( CurOut(), true );
201 aDocu.AddEntry();
202
203 aDocu.Term()
204 >> *new html::Label( rDef.LocalName() )
205 << " ";
206 aDocu.Term()
207 << rDef.LocalName()
208 << "(";
209 WriteOut_TokenList( aDocu.Term(), rDef.Params(), ", " );
210 aDocu.Term()
211 << ")";
212
213 Write_DefsDocu( aDocu.Def(), rDef );
214 }
215
216
217 void
Write_DefsDocu(csi::xml::Element & o_rOut,const ary::cpp::DefineEntity & i_rTextReplacement)218 PageMaker_AllDefs::Write_DefsDocu( csi::xml::Element & o_rOut,
219 const ary::cpp::DefineEntity & i_rTextReplacement )
220 {
221 if ( i_rTextReplacement.DefinitionText().size() > 0 )
222 {
223 EraseLeadingSpace( *const_cast< String * >(
224 &(*i_rTextReplacement.DefinitionText().begin())
225 ) );
226 }
227
228 adcdisp::ExplanationTable rList( o_rOut );
229
230 rList.AddEntry( "Defined As" );
231 WriteOut_TokenList( rList.Def(), i_rTextReplacement.DefinitionText(), " " );
232
233 const ary::loc::File &
234 rFile = Env().Gate().Locations().Find_File( i_rTextReplacement.Location() );
235 rList.AddEntry( "In File" );
236 rList.Def() << rFile.LocalName();
237
238 ShowDocu_On( o_rOut, *pDocuDisplay, i_rTextReplacement );
239 }
240