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_interface.hxx"
24
25
26 // NOT FULLY DEFINED SERVICES
27 #include <ary/idl/i_ce.hxx>
28 #include <ary/idl/i_gate.hxx>
29 #include <ary/idl/ik_function.hxx>
30 #include <ary/idl/ik_interface.hxx>
31 #include <ary/idl/ip_ce.hxx>
32 #include <ary/idl/ip_type.hxx>
33 #include <toolkit/hf_docentry.hxx>
34 #include <toolkit/hf_linachain.hxx>
35 #include <toolkit/hf_navi_sub.hxx>
36 #include <toolkit/hf_title.hxx>
37 #include "hfi_doc.hxx"
38 #include "hfi_hierarchy.hxx"
39 #include "hfi_method.hxx"
40 #include "hfi_navibar.hxx"
41 #include "hfi_property.hxx"
42 #include "hfi_tag.hxx"
43 #include "hfi_typetext.hxx"
44 #include "hi_linkhelper.hxx"
45
46
47 extern const String
48 C_sCePrefix_Interface("interface");
49
50 namespace
51 {
52
53 const String
54 C_sBaseInterface("Base Interfaces");
55 const String
56 C_sList_BaseComments("Comments on Base Interfaces");
57 const String
58 C_sList_Methods("Methods' Summary");
59 const String
60 C_sList_Methods_Label("MethodsSummary");
61 const String
62 C_sDetails_Methods("Methods' Details");
63 const String
64 C_sDetails_Methods_Label("MethodsDetails");
65
66 const String
67 C_sList_Attributes("Attributes' Summary");
68 const String
69 C_sList_Attributes_Label("AttributesSummary");
70 const String
71 C_sList_AttributesDetails("Attributes' Details");
72 const String
73 C_sList_AttributesDetails_Label("AttributesDetails");
74
75
76
77 enum E_SubListIndices
78 {
79 sli_MethodsSummay = 0,
80 sli_AttributesSummary = 1,
81 sli_MethodDetails = 2,
82 sli_AttributesDetails = 3
83 };
84
85 } //anonymous namespace
86
87
88
89
HF_IdlInterface(Environment & io_rEnv,Xml::Element & o_rOut)90 HF_IdlInterface::HF_IdlInterface( Environment & io_rEnv,
91 Xml::Element & o_rOut )
92 : HtmlFactory_Idl(io_rEnv, &o_rOut),
93 eCurProducedMembers(mem_none)
94 {
95 }
96
~HF_IdlInterface()97 HF_IdlInterface::~HF_IdlInterface()
98 {
99 }
100
101 void
Produce_byData(const client & i_ce) const102 HF_IdlInterface::Produce_byData( const client & i_ce ) const
103 {
104 Dyn<HF_NaviSubRow>
105 pNaviSubRow( &make_Navibar(i_ce) );
106
107 HF_TitleTable
108 aTitle(CurOut());
109
110 HF_LinkedNameChain
111 aNameChain(aTitle.Add_Row());
112 aNameChain.Produce_CompleteChain(Env().CurPosition(), nameChainLinker);
113
114 produce_Title(aTitle, C_sCePrefix_Interface, i_ce);
115
116 produce_BaseHierarchy( aTitle.Add_Row(),
117 i_ce,
118 C_sBaseInterface );
119
120 write_Docu(aTitle.Add_Row(), i_ce);
121 CurOut() << new Html::HorizontalLine();
122
123 dyn_ce_list dpFunctions;
124 ary::idl::ifc_interface::attr::Get_Functions(dpFunctions, i_ce);
125 if ( (*dpFunctions).operator bool() )
126 {
127 eCurProducedMembers = mem_Functions;
128
129 produce_Members( *dpFunctions,
130 C_sList_Methods,
131 C_sList_Methods_Label,
132 C_sDetails_Methods,
133 C_sDetails_Methods_Label,
134 HtmlFactory_Idl::viewtype_summary );
135 pNaviSubRow->SwitchOn(sli_MethodsSummay);
136 }
137
138 dyn_ce_list
139 dpAttributes;
140 ary::idl::ifc_interface::attr::Get_Attributes(dpAttributes, i_ce);
141 if ( (*dpAttributes).operator bool() )
142 {
143 eCurProducedMembers = mem_Attributes;
144
145 produce_Members( *dpAttributes,
146 C_sList_Attributes,
147 C_sList_Attributes_Label,
148 C_sList_AttributesDetails,
149 C_sList_AttributesDetails_Label,
150 HtmlFactory_Idl::viewtype_summary );
151 pNaviSubRow->SwitchOn(sli_AttributesSummary);
152 }
153
154 ary::idl::ifc_interface::attr::Get_Functions(dpFunctions, i_ce);
155 if ( (*dpFunctions).operator bool() )
156 {
157 eCurProducedMembers = mem_Functions;
158
159 produce_Members( *dpFunctions,
160 C_sList_Methods,
161 C_sList_Methods_Label,
162 C_sDetails_Methods,
163 C_sDetails_Methods_Label,
164 HtmlFactory_Idl::viewtype_details );
165 pNaviSubRow->SwitchOn(sli_MethodDetails);
166 }
167
168 ary::idl::ifc_interface::attr::Get_Attributes(dpAttributes, i_ce);
169 if ( (*dpAttributes).operator bool() )
170 {
171 eCurProducedMembers = mem_Attributes;
172
173 produce_Members( *dpAttributes,
174 C_sList_Attributes,
175 C_sList_Attributes_Label,
176 C_sList_AttributesDetails,
177 C_sList_AttributesDetails_Label,
178 HtmlFactory_Idl::viewtype_details );
179 pNaviSubRow->SwitchOn(sli_AttributesDetails);
180 }
181
182 eCurProducedMembers = mem_none;
183
184 pNaviSubRow->Produce_Row();
185 }
186
187 DYN HF_NaviSubRow &
make_Navibar(const client & i_ce) const188 HF_IdlInterface::make_Navibar( const client & i_ce ) const
189 {
190 HF_IdlNavigationBar
191 aNaviBar(Env(), CurOut());
192 aNaviBar.Produce_CeMainRow(i_ce);
193
194 DYN HF_NaviSubRow &
195 ret = aNaviBar.Add_SubRow();
196 ret.AddItem(C_sList_Methods, C_sList_Methods_Label, false);
197 ret.AddItem(C_sList_Attributes, C_sList_Attributes_Label, false);
198 ret.AddItem(C_sDetails_Methods, C_sDetails_Methods_Label, false);
199 ret.AddItem(C_sList_AttributesDetails, C_sList_AttributesDetails_Label, false);
200
201 CurOut() << new Html::HorizontalLine();
202 return ret;
203 }
204
205 void
produce_MemberDetails(HF_SubTitleTable & o_table,const client & i_ce) const206 HF_IdlInterface::produce_MemberDetails( HF_SubTitleTable & o_table,
207 const client & i_ce ) const
208 {
209 switch (eCurProducedMembers)
210 {
211 case mem_Functions:
212 break;
213 case mem_Attributes:
214 {
215 HF_IdlAttribute
216 aAttribute( Env(), o_table);
217 aAttribute.Produce_byData( i_ce );
218 return;
219 };
220 default: //Won't happen.
221 return;
222 } // end switch
223
224 typedef ary::idl::ifc_function::attr funcAttr;
225
226 HF_IdlMethod
227 aFunction( Env(),
228 o_table.Add_Row()
229 >> *new Html::TableCell
230 << new Html::ClassAttr(C_sCellStyle_MDetail) );
231
232 ary::Dyn_StdConstIterator<ary::idl::Parameter>
233 pParameters;
234 funcAttr::Get_Parameters(pParameters, i_ce);
235
236 ary::Dyn_StdConstIterator<ary::idl::Type_id>
237 pExceptions;
238 funcAttr::Get_Exceptions(pExceptions, i_ce);
239
240 aFunction.Produce_byData( i_ce.LocalName(),
241 funcAttr::ReturnType(i_ce),
242 *pParameters,
243 *pExceptions,
244 funcAttr::IsOneway(i_ce),
245 funcAttr::HasEllipse(i_ce),
246 i_ce );
247 }
248
249 void
produce_BaseHierarchy(Xml::Element & o_screen,const client & i_ce,const String & i_sLabel) const250 HF_IdlInterface::produce_BaseHierarchy( Xml::Element & o_screen,
251 const client & i_ce,
252 const String & i_sLabel ) const
253 {
254 ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
255 pHelp;
256 ary::idl::ifc_interface::attr::Get_Bases(pHelp, i_ce);
257 if (NOT (*pHelp).operator bool())
258 return;
259
260 // Check for XInterface as only base:
261 ary::StdConstIterator<ary::idl::CommentedRelation> &
262 itTest = *pHelp;
263 ary::idl::Ce_id
264 nCe = Env().Gate().Types().Search_CeRelatedTo((*itTest).Type());
265 if (nCe.IsValid())
266 {
267 // KORR_FUTURE
268 // Rather check for id(!) of com::sun::star::uno::XInterface.
269 if (Env().Gate().Ces().Find_Ce(nCe).LocalName() == "XInterface")
270 {
271 ++itTest;
272 if (NOT itTest.operator bool())
273 return;
274 }
275 }
276
277 // Write hierarchy:
278
279 HF_DocEntryList
280 aDocList( o_screen );
281 aDocList.Produce_Term(i_sLabel);
282 Xml::Element &
283 rBaseList = aDocList.Produce_Definition();
284
285 // NEW
286 Write_BaseHierarchy(rBaseList, Env(), i_ce);
287
288 // Write comments:
289 // KORR_FUTURE: Make sure, no empty table is constructed when comments list is empty.
290 HF_SubTitleTable
291 aBaseTable( aDocList.Produce_Definition(),
292 "",
293 C_sList_BaseComments,
294 2,
295 HF_SubTitleTable::sublevel_3 );
296
297 ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
298 pBases;
299 ary::idl::ifc_interface::attr::Get_Bases(pBases, i_ce);
300 for ( ary::StdConstIterator<ary::idl::CommentedRelation> & it = *pBases;
301 it.operator bool();
302 ++it )
303 {
304 Xml::Element &
305 rRow = aBaseTable.Add_Row();
306
307 Xml::Element &
308 rTerm = rRow
309 >> *new Html::TableCell
310 << new Html::ClassAttr(C_sCellStyle_SummaryLeft);
311 HF_IdlTypeText
312 aTypeDisplay( Env(), rTerm, false, 0);
313 aTypeDisplay.Produce_byData((*it).Type());
314
315 Xml::Element &
316 rDocu = rRow
317 >> *new Html::TableCell
318 << new Html::ClassAttr(C_sCellStyle_SummaryRight);
319
320 HF_DocEntryList
321 aDocuList(rDocu);
322
323 if ((*it).Info() != 0)
324 {
325 // aDocuList.Produce_Term("Comment on Base Reference");
326
327 HF_IdlDocu
328 aDocuDisplay(Env(), aDocuList);
329 aDocuDisplay.Produce_fromReference(*(*it).Info(), i_ce);
330 }
331 else
332 {
333 const client *
334 pCe = Env().Linker().Search_CeFromType((*it).Type());
335 const ce_info *
336 pShort = pCe != 0
337 ? Get_IdlDocu(pCe->Docu())
338 : (const ce_info *)(0);
339 if ( pShort != 0 )
340 {
341 aDocuList.Produce_NormalTerm("(referenced interface's summary:)");
342
343 Xml::Element &
344 rDef = aDocuList.Produce_Definition();
345 HF_IdlDocuTextDisplay
346 aShortDisplay( Env(), &rDef, *pCe);
347 pShort->Short().DisplayAt(aShortDisplay);
348 } // end if (pShort != 0)
349 } // endif ( (*i_commentedRef).Info() != 0 ) else
350 } // end for
351 }
352