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 "dsply_da.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_vari.hxx>
30 #include <ary/doc/d_docu.hxx>
31 #include <ary/loc/loc_file.hxx>
32 #include <ary/loc/locp_le.hxx>
33 #include <udm/html/htmlitem.hxx>
34 #include "hd_docu.hxx"
35 #include "hdimpl.hxx"
36 #include "html_kit.hxx"
37 #include "opageenv.hxx"
38 #include "pagemake.hxx"
39
40
41 using namespace csi;
42
43
44
DataDisplay(OuputPage_Environment & io_rEnv)45 DataDisplay::DataDisplay( OuputPage_Environment & io_rEnv )
46 : aMap_GlobalDataDisplay(),
47 pClassMembersDisplay(0),
48 pEnv( &io_rEnv ),
49 pDocuShow( new Docu_Display(io_rEnv) )
50 {
51 }
52
~DataDisplay()53 DataDisplay::~DataDisplay()
54 {
55 csv::erase_map_of_heap_ptrs( aMap_GlobalDataDisplay );
56 }
57
58 void
PrepareForConstants()59 DataDisplay::PrepareForConstants()
60 {
61 if (pClassMembersDisplay)
62 pClassMembersDisplay = 0;
63
64 csv::erase_map_of_heap_ptrs( aMap_GlobalDataDisplay );
65 }
66
67 void
PrepareForVariables()68 DataDisplay::PrepareForVariables()
69 {
70 // Doesn't need to do anything yet.
71 }
72
73 void
PrepareForStdMembers()74 DataDisplay::PrepareForStdMembers()
75 {
76 csv::erase_map_of_heap_ptrs( aMap_GlobalDataDisplay );
77
78 pClassMembersDisplay = new PageDisplay(*pEnv);
79 const ary::cpp::Class * pClass = pEnv->CurClass();
80 csv_assert( pClass != 0 );
81 pClassMembersDisplay->Setup_DataFile_for(*pClass);
82 }
83
84 void
PrepareForStaticMembers()85 DataDisplay::PrepareForStaticMembers()
86 {
87 // Doesn't need to do anything yet.
88 }
89
90 void
Create_Files()91 DataDisplay::Create_Files()
92 {
93 if (pClassMembersDisplay)
94 {
95 pClassMembersDisplay->Create_File();
96 pClassMembersDisplay = 0;
97 }
98 else
99 {
100 for ( Map_FileId2PagePtr::const_iterator it = aMap_GlobalDataDisplay.begin();
101 it != aMap_GlobalDataDisplay.end();
102 ++it )
103 {
104 (*it).second->Create_File();
105 }
106 csv::erase_map_of_heap_ptrs( aMap_GlobalDataDisplay );
107 }
108 }
109
110 void
do_Process(const ary::cpp::Variable & i_rData)111 DataDisplay::do_Process( const ary::cpp::Variable & i_rData )
112 {
113 if ( Ce_IsInternal(i_rData) )
114 return;
115
116 PageDisplay & rPage = FindPage_for( i_rData );
117
118 csi::xml::Element & rOut = rPage.CurOut();
119 Display_SglDatum( rOut, i_rData );
120 }
121
122 const ary::cpp::Gate *
inq_Get_ReFinder() const123 DataDisplay::inq_Get_ReFinder() const
124 {
125 return & pEnv->Gate();
126 }
127
128 PageDisplay &
FindPage_for(const ary::cpp::Variable & i_rData)129 DataDisplay::FindPage_for( const ary::cpp::Variable & i_rData )
130 {
131 if ( pClassMembersDisplay )
132 return *pClassMembersDisplay;
133
134 SourceFileId
135 nSourceFile = i_rData.Location();
136 PageDisplay *
137 pFound = csv::value_from_map( aMap_GlobalDataDisplay, nSourceFile, (PageDisplay*)0 );
138 if ( pFound == 0 )
139 {
140 pFound = new PageDisplay( *pEnv );
141 const ary::loc::File &
142 rFile = pEnv->Gate().Locations().Find_File( nSourceFile );
143 pFound->Setup_DataFile_for(rFile);
144 aMap_GlobalDataDisplay[nSourceFile] = pFound;
145 }
146
147 return *pFound;
148 }
149
150 void
Display_SglDatum(csi::xml::Element & rOut,const ary::cpp::Variable & i_rData)151 DataDisplay::Display_SglDatum( csi::xml::Element & rOut,
152 const ary::cpp::Variable & i_rData )
153 {
154 adcdisp::ExplanationList aDocu(rOut, true);
155 aDocu.AddEntry( 0 );
156
157 aDocu.Term()
158 >> *new html::Label( DataLabel(i_rData.LocalName()) )
159 << " ";
160 aDocu.Term()
161 << i_rData.LocalName();
162
163 dshelp::Get_LinkedTypeText( aDocu.Def(), *pEnv, i_rData.Type() );
164 aDocu.Def()
165 << " "
166 >> *new html::Strong
167 << i_rData.LocalName();
168 if ( i_rData.ArraySize().length() > 0 )
169 {
170 aDocu.Def()
171 << "["
172 << i_rData.ArraySize()
173 << "]";
174 }
175 if ( i_rData.Initialisation().length() > 0 )
176 {
177 aDocu.Def()
178 << " = "
179 << i_rData.Initialisation();
180 }
181 aDocu.Def()
182 << ";"
183 << new html::LineBreak
184 << new html::LineBreak;
185
186 aDocu.AddEntry_NoTerm();
187
188 pDocuShow->Assign_Out(aDocu.Def());
189 pDocuShow->Process(i_rData.Docu());
190 pDocuShow->Unassign_Out();
191
192 rOut << new html::HorizontalLine;
193 }
194