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 "hfi_struct.hxx"
24 
25 
26 // NOT FULLY DEFINED SERVICES
27 #include <ary/idl/i_ce.hxx>
28 #include <ary/idl/i_struct.hxx>
29 #include <ary/idl/ik_exception.hxx>
30 #include <ary/idl/ik_struct.hxx>
31 #include <toolkit/hf_docentry.hxx>
32 #include <toolkit/hf_linachain.hxx>
33 #include <toolkit/hf_navi_sub.hxx>
34 #include <toolkit/hf_title.hxx>
35 #include "hfi_navibar.hxx"
36 #include "hfi_property.hxx"
37 #include "hfi_typetext.hxx"
38 #include "hi_linkhelper.hxx"
39 
40 
41 extern const String
42     C_sCePrefix_Struct("struct");
43 extern const String
44     C_sCePrefix_Exception("exception");
45 
46 
47 namespace
48 {
49 
50 const String
51     C_sBaseStruct("Base Hierarchy");
52 const String
53     C_sBaseException("Base Hierarchy");
54 
55 const String
56     C_sList_Elements("Elements' Summary");
57 const String
58     C_sList_Elements_Label("Elements");
59 
60 const String
61     C_sList_ElementDetails("Elements' Details");
62 const String
63     C_sList_ElementDetails_Label("ElementDetails");
64 
65 enum E_SubListIndices
66 {
67     sli_ElementsSummary = 0,
68     sli_ElementsDetails = 1
69 };
70 
71 }   // anonymous namespace
72 
73 
74 
HF_IdlStruct(Environment & io_rEnv,Xml::Element & o_rOut,bool i_bIsException)75 HF_IdlStruct::HF_IdlStruct( Environment &         io_rEnv,
76                             Xml::Element &        o_rOut,
77                             bool                  i_bIsException )
78     :   HtmlFactory_Idl(io_rEnv, &o_rOut),
79         bIsException(i_bIsException)
80 {
81 }
82 
~HF_IdlStruct()83 HF_IdlStruct::~HF_IdlStruct()
84 {
85 }
86 
87 void
Produce_byData(const client & i_ce) const88 HF_IdlStruct::Produce_byData( const client & i_ce ) const
89 {
90     const ary::idl::Struct *
91         pStruct =
92             bIsException
93                 ?   0
94                 :   static_cast< const ary::idl::Struct* >(&i_ce);
95     bool bIsTemplate =
96             pStruct != 0
97                 ?   pStruct->TemplateParameterType().IsValid()
98                 :   false;
99 
100     Dyn<HF_NaviSubRow>
101         pNaviSubRow( &make_Navibar(i_ce) );
102 
103     HF_TitleTable
104         aTitle(CurOut());
105     HF_LinkedNameChain
106         aNameChain(aTitle.Add_Row());
107 
108     aNameChain.Produce_CompleteChain(Env().CurPosition(), nameChainLinker);
109 
110     // Title:
111     StreamLock
112         slAnnotations(200);
113     get_Annotations(slAnnotations(), i_ce);
114 
115     StreamLock rTitle(200);
116     if (bIsTemplate)
117         rTitle() << "template ";
118     rTitle()
119         << (bIsException
120 		    ?   C_sCePrefix_Exception
121 			:   C_sCePrefix_Struct)
122 	    << " "
123 		<< i_ce.LocalName();
124     if (bIsTemplate)
125     {
126         csv_assert(pStruct != 0);
127         rTitle()
128             << "<"
129             << pStruct->TemplateParameter()
130             << ">";
131     }
132     aTitle.Produce_Title(slAnnotations().c_str(), rTitle().c_str());
133 
134     // Bases:
135     produce_Bases( aTitle.Add_Row(),
136                    i_ce,
137                    bIsException
138                     ?   C_sBaseException
139                     :   C_sBaseStruct );
140 
141     // Docu:
142     write_Docu(aTitle.Add_Row(), i_ce);
143     CurOut() << new Html::HorizontalLine();
144 
145     // Elements:
146     dyn_ce_list
147         dpElements;
148     if (bIsException)
149         ary::idl::ifc_exception::attr::Get_Elements(dpElements, i_ce);
150     else
151         ary::idl::ifc_struct::attr::Get_Elements(dpElements, i_ce);
152 
153     if ( (*dpElements).operator bool() )
154     {
155         produce_Members( *dpElements,
156                          C_sList_Elements,
157                          C_sList_Elements_Label,
158                          C_sList_ElementDetails,
159                          C_sList_ElementDetails_Label );
160         pNaviSubRow->SwitchOn(sli_ElementsSummary);
161         pNaviSubRow->SwitchOn(sli_ElementsDetails);
162     }
163     pNaviSubRow->Produce_Row();
164 }
165 
166 HtmlFactory_Idl::type_id
inq_BaseOf(const client & i_ce) const167 HF_IdlStruct::inq_BaseOf( const client & i_ce ) const
168 {
169     return bIsException
170                 ?   ary::idl::ifc_exception::attr::Base(i_ce)
171                 :   ary::idl::ifc_struct::attr::Base(i_ce);
172 }
173 
174 HF_NaviSubRow &
make_Navibar(const client & i_ce) const175 HF_IdlStruct::make_Navibar( const client & i_ce ) const
176 {
177     HF_IdlNavigationBar
178         aNaviBar(Env(), CurOut());
179     aNaviBar.Produce_CeMainRow(i_ce);
180 
181     DYN HF_NaviSubRow &
182         ret = aNaviBar.Add_SubRow();
183     ret.AddItem(C_sList_Elements, C_sList_Elements_Label, false);
184     ret.AddItem(C_sList_ElementDetails, C_sList_ElementDetails_Label, false);
185 
186     CurOut() << new Html::HorizontalLine();
187     return ret;
188 }
189 
190 void
produce_MemberDetails(HF_SubTitleTable & o_table,const client & i_ce) const191 HF_IdlStruct::produce_MemberDetails( HF_SubTitleTable &  o_table,
192                                      const client &      i_ce) const
193 {
194     HF_IdlStructElement
195         aElement( Env(), o_table );
196     aElement.Produce_byData(i_ce);
197 }
198