Bump for 3.6-28
[LibreOffice.git] / autodoc / source / display / idl / hfi_interface.cxx
blobd5e35a5e2a8362352a554dcd126c03f79c1633f6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <precomp.h>
30 #include "hfi_interface.hxx"
33 // NOT FULLY DEFINED SERVICES
34 #include <ary/idl/i_ce.hxx>
35 #include <ary/idl/i_gate.hxx>
36 #include <ary/idl/ik_function.hxx>
37 #include <ary/idl/ik_interface.hxx>
38 #include <ary/idl/ip_ce.hxx>
39 #include <ary/idl/ip_type.hxx>
40 #include <toolkit/hf_docentry.hxx>
41 #include <toolkit/hf_linachain.hxx>
42 #include <toolkit/hf_navi_sub.hxx>
43 #include <toolkit/hf_title.hxx>
44 #include "hfi_doc.hxx"
45 #include "hfi_hierarchy.hxx"
46 #include "hfi_method.hxx"
47 #include "hfi_navibar.hxx"
48 #include "hfi_property.hxx"
49 #include "hfi_tag.hxx"
50 #include "hfi_typetext.hxx"
51 #include "hi_linkhelper.hxx"
54 extern const String
55 C_sCePrefix_Interface("interface");
57 namespace
60 const String
61 C_sBaseInterface("Base Interfaces");
62 const String
63 C_sList_BaseComments("Comments on Base Interfaces");
64 const String
65 C_sList_Methods("Methods' Summary");
66 const String
67 C_sList_Methods_Label("MethodsSummary");
68 const String
69 C_sDetails_Methods("Methods' Details");
70 const String
71 C_sDetails_Methods_Label("MethodsDetails");
73 const String
74 C_sList_Attributes("Attributes' Summary");
75 const String
76 C_sList_Attributes_Label("AttributesSummary");
77 const String
78 C_sList_AttributesDetails("Attributes' Details");
79 const String
80 C_sList_AttributesDetails_Label("AttributesDetails");
84 enum E_SubListIndices
86 sli_MethodsSummay = 0,
87 sli_AttributesSummary = 1,
88 sli_MethodDetails = 2,
89 sli_AttributesDetails = 3
92 } //anonymous namespace
97 HF_IdlInterface::HF_IdlInterface( Environment & io_rEnv,
98 Xml::Element & o_rOut )
99 : HtmlFactory_Idl(io_rEnv, &o_rOut),
100 eCurProducedMembers(mem_none)
104 HF_IdlInterface::~HF_IdlInterface()
108 void
109 HF_IdlInterface::Produce_byData( const client & i_ce ) const
111 Dyn<HF_NaviSubRow>
112 pNaviSubRow( &make_Navibar(i_ce) );
114 HF_TitleTable
115 aTitle(CurOut());
117 HF_LinkedNameChain
118 aNameChain(aTitle.Add_Row());
119 aNameChain.Produce_CompleteChain(Env().CurPosition(), nameChainLinker);
121 produce_Title(aTitle, C_sCePrefix_Interface, i_ce);
123 produce_BaseHierarchy( aTitle.Add_Row(),
124 i_ce,
125 C_sBaseInterface );
127 write_Docu(aTitle.Add_Row(), i_ce);
128 CurOut() << new Html::HorizontalLine();
130 dyn_ce_list dpFunctions;
131 ary::idl::ifc_interface::attr::Get_Functions(dpFunctions, i_ce);
132 if ( (*dpFunctions).operator bool() )
134 eCurProducedMembers = mem_Functions;
136 produce_Members( *dpFunctions,
137 C_sList_Methods,
138 C_sList_Methods_Label,
139 C_sDetails_Methods,
140 C_sDetails_Methods_Label,
141 HtmlFactory_Idl::viewtype_summary );
142 pNaviSubRow->SwitchOn(sli_MethodsSummay);
145 dyn_ce_list
146 dpAttributes;
147 ary::idl::ifc_interface::attr::Get_Attributes(dpAttributes, i_ce);
148 if ( (*dpAttributes).operator bool() )
150 eCurProducedMembers = mem_Attributes;
152 produce_Members( *dpAttributes,
153 C_sList_Attributes,
154 C_sList_Attributes_Label,
155 C_sList_AttributesDetails,
156 C_sList_AttributesDetails_Label,
157 HtmlFactory_Idl::viewtype_summary );
158 pNaviSubRow->SwitchOn(sli_AttributesSummary);
161 ary::idl::ifc_interface::attr::Get_Functions(dpFunctions, i_ce);
162 if ( (*dpFunctions).operator bool() )
164 eCurProducedMembers = mem_Functions;
166 produce_Members( *dpFunctions,
167 C_sList_Methods,
168 C_sList_Methods_Label,
169 C_sDetails_Methods,
170 C_sDetails_Methods_Label,
171 HtmlFactory_Idl::viewtype_details );
172 pNaviSubRow->SwitchOn(sli_MethodDetails);
175 ary::idl::ifc_interface::attr::Get_Attributes(dpAttributes, i_ce);
176 if ( (*dpAttributes).operator bool() )
178 eCurProducedMembers = mem_Attributes;
180 produce_Members( *dpAttributes,
181 C_sList_Attributes,
182 C_sList_Attributes_Label,
183 C_sList_AttributesDetails,
184 C_sList_AttributesDetails_Label,
185 HtmlFactory_Idl::viewtype_details );
186 pNaviSubRow->SwitchOn(sli_AttributesDetails);
189 eCurProducedMembers = mem_none;
191 pNaviSubRow->Produce_Row();
194 DYN HF_NaviSubRow &
195 HF_IdlInterface::make_Navibar( const client & i_ce ) const
197 HF_IdlNavigationBar
198 aNaviBar(Env(), CurOut());
199 aNaviBar.Produce_CeMainRow(i_ce);
201 DYN HF_NaviSubRow &
202 ret = aNaviBar.Add_SubRow();
203 ret.AddItem(C_sList_Methods, C_sList_Methods_Label, false);
204 ret.AddItem(C_sList_Attributes, C_sList_Attributes_Label, false);
205 ret.AddItem(C_sDetails_Methods, C_sDetails_Methods_Label, false);
206 ret.AddItem(C_sList_AttributesDetails, C_sList_AttributesDetails_Label, false);
208 CurOut() << new Html::HorizontalLine();
209 return ret;
212 void
213 HF_IdlInterface::produce_MemberDetails( HF_SubTitleTable & o_table,
214 const client & i_ce ) const
216 switch (eCurProducedMembers)
218 case mem_Functions:
219 break;
220 case mem_Attributes:
222 HF_IdlAttribute
223 aAttribute( Env(), o_table);
224 aAttribute.Produce_byData( i_ce );
225 return;
227 default: //Won't happen.
228 return;
229 } // end switch
231 typedef ary::idl::ifc_function::attr funcAttr;
233 HF_IdlMethod
234 aFunction( Env(),
235 o_table.Add_Row()
236 >> *new Html::TableCell
237 << new Html::ClassAttr(C_sCellStyle_MDetail) );
239 ary::Dyn_StdConstIterator<ary::idl::Parameter>
240 pParameters;
241 funcAttr::Get_Parameters(pParameters, i_ce);
243 ary::Dyn_StdConstIterator<ary::idl::Type_id>
244 pExceptions;
245 funcAttr::Get_Exceptions(pExceptions, i_ce);
247 aFunction.Produce_byData( i_ce.LocalName(),
248 funcAttr::ReturnType(i_ce),
249 *pParameters,
250 *pExceptions,
251 funcAttr::IsOneway(i_ce),
252 funcAttr::HasEllipse(i_ce),
253 i_ce );
256 void
257 HF_IdlInterface::produce_BaseHierarchy( Xml::Element & o_screen,
258 const client & i_ce,
259 const String & i_sLabel ) const
261 ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
262 pHelp;
263 ary::idl::ifc_interface::attr::Get_Bases(pHelp, i_ce);
264 if (NOT (*pHelp).operator bool())
265 return;
267 // Check for XInterface as only base:
268 ary::StdConstIterator<ary::idl::CommentedRelation> &
269 itTest = *pHelp;
270 ary::idl::Ce_id
271 nCe = Env().Gate().Types().Search_CeRelatedTo((*itTest).Type());
272 if (nCe.IsValid())
274 // KORR_FUTURE
275 // Rather check for id(!) of com::sun::star::uno::XInterface.
276 if (Env().Gate().Ces().Find_Ce(nCe).LocalName() == "XInterface")
278 ++itTest;
279 if (NOT itTest.operator bool())
280 return;
284 // Write hierarchy:
286 HF_DocEntryList
287 aDocList( o_screen );
288 aDocList.Produce_Term(i_sLabel);
289 Xml::Element &
290 rBaseList = aDocList.Produce_Definition();
292 // NEW
293 Write_BaseHierarchy(rBaseList, Env(), i_ce);
295 // Write comments:
296 // KORR_FUTURE: Make sure, no empty table is constructed when comments list is empty.
297 HF_SubTitleTable
298 aBaseTable( aDocList.Produce_Definition(),
300 C_sList_BaseComments,
302 HF_SubTitleTable::sublevel_3 );
304 ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
305 pBases;
306 ary::idl::ifc_interface::attr::Get_Bases(pBases, i_ce);
307 for ( ary::StdConstIterator<ary::idl::CommentedRelation> & it = *pBases;
308 it.operator bool();
309 ++it )
311 Xml::Element &
312 rRow = aBaseTable.Add_Row();
314 Xml::Element &
315 rTerm = rRow
316 >> *new Html::TableCell
317 << new Html::ClassAttr(C_sCellStyle_SummaryLeft);
318 HF_IdlTypeText
319 aTypeDisplay( Env(), rTerm, false, 0);
320 aTypeDisplay.Produce_byData((*it).Type());
322 Xml::Element &
323 rDocu = rRow
324 >> *new Html::TableCell
325 << new Html::ClassAttr(C_sCellStyle_SummaryRight);
327 HF_DocEntryList
328 aDocuList(rDocu);
330 if ((*it).Info() != 0)
332 // aDocuList.Produce_Term("Comment on Base Reference");
334 HF_IdlDocu
335 aDocuDisplay(Env(), aDocuList);
336 aDocuDisplay.Produce_fromReference(*(*it).Info(), i_ce);
338 else
340 const client *
341 pCe = Env().Linker().Search_CeFromType((*it).Type());
342 const ce_info *
343 pShort = pCe != 0
344 ? Get_IdlDocu(pCe->Docu())
345 : (const ce_info *)(0);
346 if ( pShort != 0 )
348 aDocuList.Produce_NormalTerm("(referenced interface's summary:)");
350 Xml::Element &
351 rDef = aDocuList.Produce_Definition();
352 HF_IdlDocuTextDisplay
353 aShortDisplay( Env(), &rDef, *pCe);
354 pShort->Short().DisplayAt(aShortDisplay);
355 } // end if (pShort != 0)
356 } // endif ( (*i_commentedRef).Info() != 0 ) else
357 } // end for
360 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */