Update ooo320-m1
[ooovba.git] / autodoc / source / display / idl / hfi_property.cxx
blob37e009efaada1fbdb5b8b3bce933224e490608d0
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_property.cxx,v $
10 * $Revision: 1.7 $
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_property.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/idl/i_ce.hxx>
37 #include <ary/idl/ik_attribute.hxx>
38 #include <ary/idl/ik_constant.hxx>
39 #include <ary/idl/ik_enumvalue.hxx>
40 #include <ary/idl/ik_property.hxx>
41 #include <ary/idl/ik_structelem.hxx>
42 #include <toolkit/hf_docentry.hxx>
43 #include <toolkit/hf_title.hxx>
44 #include "hfi_typetext.hxx"
45 #include "hfi_doc.hxx"
46 #include "hfi_tag.hxx"
47 #include "hi_env.hxx"
48 #include "hi_ary.hxx"
49 #include "hi_linkhelper.hxx"
51 void
52 HF_IdlDataMember::Produce_byData( const client & ce ) const
54 write_Title(ce);
55 enter_ContentCell();
56 write_Declaration(ce);
57 write_Description(ce);
58 leave_ContentCell();
61 HF_IdlDataMember::HF_IdlDataMember( Environment & io_rEnv,
62 HF_SubTitleTable & o_table )
63 : HtmlFactory_Idl( io_rEnv,
64 &(o_table.Add_Row()
65 >> *new Html::TableCell
66 << new Html::ClassAttr(C_sCellStyle_MDetail))
71 const String sContentBorder("0");
72 const String sContentWidth("96%");
73 const String sContentPadding("5");
74 const String sContentSpacing("0");
76 const String sBgWhite("#ffffff");
77 const String sCenter("center");
79 void
80 HF_IdlDataMember::write_Title( const client & i_ce ) const
82 CurOut()
83 >> *new Html::Label(i_ce.LocalName())
84 << new Html::ClassAttr(C_sMemberTitle)
85 << i_ce.LocalName();
88 void
89 HF_IdlDataMember::write_Description( const client & i_ce ) const
91 CurOut() << new Html::HorizontalLine;
92 write_Docu(CurOut(), i_ce);
95 void
96 HF_IdlDataMember::enter_ContentCell() const
99 Xml::Element &
100 rContentCell = CurOut()
101 >> *new Html::Table( sContentBorder,
102 sContentWidth,
103 sContentPadding,
104 sContentSpacing )
105 << new Html::ClassAttr("table-in-data")
106 << new Html::BgColorAttr(sBgWhite)
107 << new Html::AlignAttr(sCenter)
108 >> *new Html::TableRow
109 >> *new Html::TableCell;
110 Out().Enter(rContentCell);
114 void
115 HF_IdlDataMember::leave_ContentCell() const
117 Out().Leave();
121 HF_IdlProperty::~HF_IdlProperty()
125 typedef ary::idl::ifc_property::attr PropertyAttr;
127 void
128 HF_IdlProperty::write_Declaration( const client & i_ce ) const
130 if (PropertyAttr::HasAnyStereotype(i_ce))
132 CurOut() << "[ ";
133 if (PropertyAttr::IsReadOnly(i_ce))
134 CurOut() << "readonly ";
135 if (PropertyAttr::IsBound(i_ce))
136 CurOut() << "bound ";
137 if (PropertyAttr::IsConstrained(i_ce))
138 CurOut() << "constrained ";
139 if (PropertyAttr::IsMayBeAmbiguous(i_ce))
140 CurOut() << "maybeambiguous ";
141 if (PropertyAttr::IsMayBeDefault(i_ce))
142 CurOut() << "maybedefault ";
143 if (PropertyAttr::IsMayBeVoid(i_ce))
144 CurOut() << "maybevoid ";
145 if (PropertyAttr::IsRemovable(i_ce))
146 CurOut() << "removable ";
147 if (PropertyAttr::IsTransient(i_ce))
148 CurOut() << "transient ";
149 CurOut() << "] ";
150 } // end if
152 HF_IdlTypeText
153 aType( Env(), CurOut(), true );
154 aType.Produce_byData( PropertyAttr::Type(i_ce) );
156 CurOut() << " " >> *new Html::Bold << i_ce.LocalName();
157 CurOut() << ";";
163 HF_IdlAttribute::~HF_IdlAttribute()
167 typedef ary::idl::ifc_attribute::attr AttributeAttr;
169 void
170 HF_IdlAttribute::write_Declaration( const client & i_ce ) const
172 if (AttributeAttr::HasAnyStereotype(i_ce))
174 CurOut() << "[ ";
175 if (AttributeAttr::IsReadOnly(i_ce))
176 CurOut() << "readonly ";
177 if (AttributeAttr::IsBound(i_ce))
178 CurOut() << "bound ";
179 CurOut() << "] ";
182 HF_IdlTypeText
183 aType( Env(), CurOut(), true );
184 aType.Produce_byData( AttributeAttr::Type(i_ce) );
186 CurOut()
187 << " "
188 >> *new Html::Bold
189 << i_ce.LocalName();
191 dyn_type_list pGetExceptions;
192 dyn_type_list pSetExceptions;
193 AttributeAttr::Get_GetExceptions(pGetExceptions, i_ce);
194 AttributeAttr::Get_SetExceptions(pSetExceptions, i_ce);
196 bool bGetRaises = (*pGetExceptions).IsValid();
197 bool bSetRaises = (*pSetExceptions).IsValid();
198 bool bRaises = bGetRaises OR bSetRaises;
199 if (bRaises)
201 HF_DocEntryList aSub(CurOut());
203 if (bGetRaises)
205 Xml::Element &
206 rGet = aSub.Produce_Definition();
207 HF_IdlTypeText
208 aExc(Env(), rGet, true);
209 type_list & itExc = *pGetExceptions;
211 rGet << "get raises (";
212 aExc.Produce_byData(*itExc);
213 for (++itExc; itExc.operator bool(); ++itExc)
215 rGet
216 << ",";
217 aExc.Produce_byData(*itExc);
218 } // end for
219 rGet << ")";
220 if (NOT bSetRaises)
221 rGet << ";";
222 } // end if (bGetRaises)
224 if (bSetRaises)
226 Xml::Element &
227 rSet = aSub.Produce_Definition();
228 HF_IdlTypeText
229 aExc(Env(), rSet, true);
230 type_list & itExc = *pSetExceptions;
232 rSet << "set raises (";
233 aExc.Produce_byData(*itExc);
234 for (++itExc; itExc.operator bool(); ++itExc)
236 rSet
237 << ",";
238 aExc.Produce_byData(*itExc);
239 } // end for
240 rSet << ");";
241 } // end if (bSetRaises)
243 else
245 CurOut() << ";";
252 HF_IdlEnumValue::~HF_IdlEnumValue()
256 typedef ary::idl::ifc_enumvalue::attr EnumValueAttr;
258 void
259 HF_IdlEnumValue::write_Declaration( const client & i_ce ) const
261 CurOut()
262 >> *new Html::Bold
263 << i_ce.LocalName();
265 const String &
266 rValue = EnumValueAttr::Value(i_ce);
267 if ( NOT rValue.empty() )
268 { CurOut() << " " // << " = " // In the moment this is somehow in the value
269 << rValue;
270 // CurOut() << ","; // In the moment this is somehow in the value
272 else
273 CurOut() << ",";
277 HF_IdlConstant::~HF_IdlConstant()
281 typedef ary::idl::ifc_constant::attr ConstantAttr;
283 void
284 HF_IdlConstant::write_Declaration( const client & i_ce ) const
286 CurOut() << "const ";
287 HF_IdlTypeText
288 aType( Env(), CurOut(), true );
289 aType.Produce_byData(ConstantAttr::Type(i_ce));
290 CurOut()
291 << " "
292 >> *new Html::Bold
293 << i_ce.LocalName();
294 const String &
295 rValue = ConstantAttr::Value(i_ce);
296 CurOut() << " " // << " = " // In the moment this is somehow in the value
297 << rValue;
298 // << ";"; // In the moment this is somehow in the value
302 HF_IdlStructElement::~HF_IdlStructElement()
306 typedef ary::idl::ifc_structelement::attr StructElementAttr;
308 void
309 HF_IdlStructElement::write_Declaration( const client & i_ce ) const
311 HF_IdlTypeText
312 aType( Env(), CurOut(), true );
313 aType.Produce_byData(StructElementAttr::Type(i_ce));
314 CurOut()
315 << " "
316 >> *new Html::Bold
317 << i_ce.LocalName();
318 CurOut()
319 << ";";
322 HF_IdlCommentedRelationElement::~HF_IdlCommentedRelationElement()
326 void
327 HF_IdlCommentedRelationElement::produce_Summary( Environment & io_env,
328 Xml::Element & io_context,
329 const comref & i_commentedRef,
330 const client & i_rScopeGivingCe )
332 csv_assert( i_commentedRef.Info() );
334 const ary::idl::Type_id aType = i_commentedRef.Type();
335 const ce_info & rDocu = *i_commentedRef.Info();
337 bool bShort = NOT rDocu.Short().IsEmpty();
338 bool bDescr = NOT rDocu.Description().IsEmpty();
340 if ( bShort )
342 HF_IdlDocuTextDisplay
343 aDescription(io_env, 0, i_rScopeGivingCe);
345 Xml::Element& rPara = io_context >> *new Html::Paragraph;
346 aDescription.Out().Enter( rPara );
347 rDocu.Short().DisplayAt( aDescription );
349 // if there's more than just the summary - i.e. a description, or usage restrictions, or tags -,
350 // then add a link to the details section
351 if ( bDescr OR rDocu.IsDeprecated() OR rDocu.IsOptional() OR NOT rDocu.Tags().empty() )
353 StreamLock aLocalLink(100);
354 aLocalLink() << "#" << get_LocalLinkName(io_env, i_commentedRef);
356 aDescription.Out().Out() << "(";
357 aDescription.Out().Out()
358 >> *new Html::Link( aLocalLink().c_str() )
359 << "details";
360 aDescription.Out().Out() << ")";
363 aDescription.Out().Leave();
367 void
368 HF_IdlCommentedRelationElement::produce_LinkDoc( Environment & io_env,
369 const client & i_ce,
370 Xml::Element & io_context,
371 const comref & i_commentedRef,
372 const E_DocType i_docType )
374 if ( i_commentedRef.Info() != 0 )
376 if ( i_docType == doctype_complete )
378 HF_DocEntryList aDocList(io_context);
379 HF_IdlDocu aDocuDisplay(io_env, aDocList);
381 aDocuDisplay.Produce_byDocu4Reference(*i_commentedRef.Info(), i_ce);
383 else
385 produce_Summary(io_env, io_context, i_commentedRef, i_ce);
388 else
390 HF_DocEntryList aDocList(io_context);
392 const client *
393 pCe = io_env.Linker().Search_CeFromType(i_commentedRef.Type());
394 const ce_info *
395 pShort = pCe != 0
396 ? Get_IdlDocu(pCe->Docu())
397 : (const ce_info *)(0);
398 if ( pShort != 0 )
400 aDocList.Produce_NormalTerm("(referenced entity's summary:)");
401 Xml::Element &
402 rDef = aDocList.Produce_Definition();
403 HF_IdlDocuTextDisplay
404 aShortDisplay( io_env, &rDef, *pCe);
405 pShort->Short().DisplayAt(aShortDisplay);
406 } // end if (pShort != 0)
407 } // endif ( (*i_commentedRef).Info() != 0 ) else
411 String
412 HF_IdlCommentedRelationElement::get_LocalLinkName( Environment & io_env,
413 const comref & i_commentedRef )
415 StringVector aModules;
416 String sLocalName;
417 ce_id nCe;
418 int nSequenceCount = 0;
420 const ary::idl::Type &
421 rType = io_env.Data().Find_Type(i_commentedRef.Type());
422 io_env.Data().Get_TypeText(aModules, sLocalName, nCe, nSequenceCount, rType);
424 // speaking strictly, this is not correct: If we have two interfaces with the same local
425 // name, but in different modules, then the link name will be ambiguous. However, this should
426 // be too seldom a case to really make the link names that ugly by adding the module information.
427 return sLocalName;
430 void
431 HF_IdlCommentedRelationElement::write_Title( const client & /*i_ce*/ ) const
434 Xml::Element &
435 rAnchor = CurOut()
436 >> *new Html::Label(get_LocalLinkName(Env(), m_relation))
437 << new Html::ClassAttr(C_sMemberTitle);
439 HF_IdlTypeText
440 aText(Env(), rAnchor, true);
441 aText.Produce_byData(m_relation.Type());
444 void
445 HF_IdlCommentedRelationElement::write_Declaration( const client & /*i_ce*/ ) const
447 // nothing to do here - an entity which is a commented relation does not have a declaration
450 void
451 HF_IdlCommentedRelationElement::write_Description( const client & i_ce ) const
453 produce_LinkDoc( Env(), i_ce, CurOut(), m_relation, doctype_complete );