Update ooo320-m1
[ooovba.git] / autodoc / source / display / idl / hfi_interface.cxx
blobcddc4c05b01b5373fc5c4dbecf2624783aebf189
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hfi_interface.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <precomp.h>
32 #include "hfi_interface.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/idl/i_ce.hxx>
37 #include <ary/idl/i_gate.hxx>
38 #include <ary/idl/ik_function.hxx>
39 #include <ary/idl/ik_interface.hxx>
40 #include <ary/idl/ip_ce.hxx>
41 #include <ary/idl/ip_type.hxx>
42 #include <toolkit/hf_docentry.hxx>
43 #include <toolkit/hf_linachain.hxx>
44 #include <toolkit/hf_navi_sub.hxx>
45 #include <toolkit/hf_title.hxx>
46 #include "hfi_doc.hxx"
47 #include "hfi_hierarchy.hxx"
48 #include "hfi_method.hxx"
49 #include "hfi_navibar.hxx"
50 #include "hfi_property.hxx"
51 #include "hfi_tag.hxx"
52 #include "hfi_typetext.hxx"
53 #include "hi_linkhelper.hxx"
56 extern const String
57 C_sCePrefix_Interface("interface");
59 namespace
62 const String
63 C_sBaseInterface("Base Interfaces");
64 const String
65 C_sList_BaseComments("Comments on Base Interfaces");
66 const String
67 C_sList_Methods("Methods' Summary");
68 const String
69 C_sList_Methods_Label("MethodsSummary");
70 const String
71 C_sDetails_Methods("Methods' Details");
72 const String
73 C_sDetails_Methods_Label("MethodsDetails");
75 const String
76 C_sList_Attributes("Attributes' Summary");
77 const String
78 C_sList_Attributes_Label("AttributesSummary");
79 const String
80 C_sList_AttributesDetails("Attributes' Details");
81 const String
82 C_sList_AttributesDetails_Label("AttributesDetails");
86 enum E_SubListIndices
88 sli_MethodsSummay = 0,
89 sli_AttributesSummary = 1,
90 sli_MethodDetails = 2,
91 sli_AttributesDetails = 3
94 } //anonymous namespace
99 HF_IdlInterface::HF_IdlInterface( Environment & io_rEnv,
100 Xml::Element & o_rOut )
101 : HtmlFactory_Idl(io_rEnv, &o_rOut),
102 eCurProducedMembers(mem_none)
106 HF_IdlInterface::~HF_IdlInterface()
110 void
111 HF_IdlInterface::Produce_byData( const client & i_ce ) const
113 Dyn<HF_NaviSubRow>
114 pNaviSubRow( &make_Navibar(i_ce) );
116 HF_TitleTable
117 aTitle(CurOut());
119 HF_LinkedNameChain
120 aNameChain(aTitle.Add_Row());
121 aNameChain.Produce_CompleteChain(Env().CurPosition(), nameChainLinker);
123 produce_Title(aTitle, C_sCePrefix_Interface, i_ce);
125 produce_BaseHierarchy( aTitle.Add_Row(),
126 i_ce,
127 C_sBaseInterface );
129 write_Docu(aTitle.Add_Row(), i_ce);
130 CurOut() << new Html::HorizontalLine();
132 dyn_ce_list dpFunctions;
133 ary::idl::ifc_interface::attr::Get_Functions(dpFunctions, i_ce);
134 if ( (*dpFunctions).operator bool() )
136 eCurProducedMembers = mem_Functions;
138 produce_Members( *dpFunctions,
139 C_sList_Methods,
140 C_sList_Methods_Label,
141 C_sDetails_Methods,
142 C_sDetails_Methods_Label,
143 HtmlFactory_Idl::viewtype_summary );
144 pNaviSubRow->SwitchOn(sli_MethodsSummay);
147 dyn_ce_list
148 dpAttributes;
149 ary::idl::ifc_interface::attr::Get_Attributes(dpAttributes, i_ce);
150 if ( (*dpAttributes).operator bool() )
152 eCurProducedMembers = mem_Attributes;
154 produce_Members( *dpAttributes,
155 C_sList_Attributes,
156 C_sList_Attributes_Label,
157 C_sList_AttributesDetails,
158 C_sList_AttributesDetails_Label,
159 HtmlFactory_Idl::viewtype_summary );
160 pNaviSubRow->SwitchOn(sli_AttributesSummary);
163 ary::idl::ifc_interface::attr::Get_Functions(dpFunctions, i_ce);
164 if ( (*dpFunctions).operator bool() )
166 eCurProducedMembers = mem_Functions;
168 produce_Members( *dpFunctions,
169 C_sList_Methods,
170 C_sList_Methods_Label,
171 C_sDetails_Methods,
172 C_sDetails_Methods_Label,
173 HtmlFactory_Idl::viewtype_details );
174 pNaviSubRow->SwitchOn(sli_MethodDetails);
177 ary::idl::ifc_interface::attr::Get_Attributes(dpAttributes, i_ce);
178 if ( (*dpAttributes).operator bool() )
180 eCurProducedMembers = mem_Attributes;
182 produce_Members( *dpAttributes,
183 C_sList_Attributes,
184 C_sList_Attributes_Label,
185 C_sList_AttributesDetails,
186 C_sList_AttributesDetails_Label,
187 HtmlFactory_Idl::viewtype_details );
188 pNaviSubRow->SwitchOn(sli_AttributesDetails);
191 eCurProducedMembers = mem_none;
193 pNaviSubRow->Produce_Row();
196 DYN HF_NaviSubRow &
197 HF_IdlInterface::make_Navibar( const client & i_ce ) const
199 HF_IdlNavigationBar
200 aNaviBar(Env(), CurOut());
201 aNaviBar.Produce_CeMainRow(i_ce);
203 DYN HF_NaviSubRow &
204 ret = aNaviBar.Add_SubRow();
205 ret.AddItem(C_sList_Methods, C_sList_Methods_Label, false);
206 ret.AddItem(C_sList_Attributes, C_sList_Attributes_Label, false);
207 ret.AddItem(C_sDetails_Methods, C_sDetails_Methods_Label, false);
208 ret.AddItem(C_sList_AttributesDetails, C_sList_AttributesDetails_Label, false);
210 CurOut() << new Html::HorizontalLine();
211 return ret;
214 void
215 HF_IdlInterface::produce_MemberDetails( HF_SubTitleTable & o_table,
216 const client & i_ce ) const
218 switch (eCurProducedMembers)
220 case mem_Functions:
221 break;
222 case mem_Attributes:
224 HF_IdlAttribute
225 aAttribute( Env(), o_table);
226 aAttribute.Produce_byData( i_ce );
227 return;
229 default: //Won't happen.
230 return;
231 } // end switch
233 typedef ary::idl::ifc_function::attr funcAttr;
235 HF_IdlMethod
236 aFunction( Env(),
237 o_table.Add_Row()
238 >> *new Html::TableCell
239 << new Html::ClassAttr(C_sCellStyle_MDetail) );
241 ary::Dyn_StdConstIterator<ary::idl::Parameter>
242 pParameters;
243 funcAttr::Get_Parameters(pParameters, i_ce);
245 ary::Dyn_StdConstIterator<ary::idl::Type_id>
246 pExceptions;
247 funcAttr::Get_Exceptions(pExceptions, i_ce);
249 aFunction.Produce_byData( i_ce.LocalName(),
250 funcAttr::ReturnType(i_ce),
251 *pParameters,
252 *pExceptions,
253 funcAttr::IsOneway(i_ce),
254 funcAttr::HasEllipse(i_ce),
255 i_ce );
258 void
259 HF_IdlInterface::produce_BaseHierarchy( Xml::Element & o_screen,
260 const client & i_ce,
261 const String & i_sLabel ) const
263 ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
264 pHelp;
265 ary::idl::ifc_interface::attr::Get_Bases(pHelp, i_ce);
266 if (NOT (*pHelp).operator bool())
267 return;
269 // Check for XInterface as only base:
270 ary::StdConstIterator<ary::idl::CommentedRelation> &
271 itTest = *pHelp;
272 ary::idl::Ce_id
273 nCe = Env().Gate().Types().Search_CeRelatedTo((*itTest).Type());
274 if (nCe.IsValid())
276 // KORR_FUTURE
277 // Rather check for id(!) of com::sun::star::uno::XInterface.
278 if (Env().Gate().Ces().Find_Ce(nCe).LocalName() == "XInterface")
280 ++itTest;
281 if (NOT itTest.operator bool())
282 return;
286 // Write hierarchy:
288 HF_DocEntryList
289 aDocList( o_screen );
290 aDocList.Produce_Term(i_sLabel);
291 Xml::Element &
292 rBaseList = aDocList.Produce_Definition();
294 // NEW
295 Write_BaseHierarchy(rBaseList, Env(), i_ce);
297 // Write comments:
298 // KORR_FUTURE: Make sure, no empty table is constructed when comments list is empty.
299 HF_SubTitleTable
300 aBaseTable( aDocList.Produce_Definition(),
302 C_sList_BaseComments,
304 HF_SubTitleTable::sublevel_3 );
306 ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
307 pBases;
308 ary::idl::ifc_interface::attr::Get_Bases(pBases, i_ce);
309 for ( ary::StdConstIterator<ary::idl::CommentedRelation> & it = *pBases;
310 it.operator bool();
311 ++it )
313 Xml::Element &
314 rRow = aBaseTable.Add_Row();
316 Xml::Element &
317 rTerm = rRow
318 >> *new Html::TableCell
319 << new Html::ClassAttr(C_sCellStyle_SummaryLeft);
320 HF_IdlTypeText
321 aTypeDisplay( Env(), rTerm, false, 0);
322 aTypeDisplay.Produce_byData((*it).Type());
324 Xml::Element &
325 rDocu = rRow
326 >> *new Html::TableCell
327 << new Html::ClassAttr(C_sCellStyle_SummaryRight);
329 HF_DocEntryList
330 aDocuList(rDocu);
332 if ((*it).Info() != 0)
334 // aDocuList.Produce_Term("Comment on Base Reference");
336 HF_IdlDocu
337 aDocuDisplay(Env(), aDocuList);
338 aDocuDisplay.Produce_byDocu4Reference(*(*it).Info(), i_ce);
340 else
342 const client *
343 pCe = Env().Linker().Search_CeFromType((*it).Type());
344 const ce_info *
345 pShort = pCe != 0
346 ? Get_IdlDocu(pCe->Docu())
347 : (const ce_info *)(0);
348 if ( pShort != 0 )
350 aDocuList.Produce_NormalTerm("(referenced interface's summary:)");
352 Xml::Element &
353 rDef = aDocuList.Produce_Definition();
354 HF_IdlDocuTextDisplay
355 aShortDisplay( Env(), &rDef, *pCe);
356 pShort->Short().DisplayAt(aShortDisplay);
357 } // end if (pShort != 0)
358 } // endif ( (*i_commentedRef).Info() != 0 ) else
359 } // end for