Bump for 3.6-28
[LibreOffice.git] / autodoc / source / display / idl / hfi_property.cxx
blobf10e6694799c86245814482a1093a3367919500a
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_property.hxx"
33 // NOT FULLY DEFINED SERVICES
34 #include <ary/idl/i_ce.hxx>
35 #include <ary/idl/ik_attribute.hxx>
36 #include <ary/idl/ik_constant.hxx>
37 #include <ary/idl/ik_enumvalue.hxx>
38 #include <ary/idl/ik_property.hxx>
39 #include <ary/idl/ik_structelem.hxx>
40 #include <toolkit/hf_docentry.hxx>
41 #include <toolkit/hf_title.hxx>
42 #include "hfi_typetext.hxx"
43 #include "hfi_doc.hxx"
44 #include "hfi_tag.hxx"
45 #include "hi_env.hxx"
46 #include "hi_ary.hxx"
47 #include "hi_linkhelper.hxx"
49 void
50 HF_IdlDataMember::Produce_byData( const client & ce ) const
52 write_Title(ce);
53 enter_ContentCell();
54 write_Declaration(ce);
55 write_Description(ce);
56 leave_ContentCell();
59 HF_IdlDataMember::HF_IdlDataMember( Environment & io_rEnv,
60 HF_SubTitleTable & o_table )
61 : HtmlFactory_Idl( io_rEnv,
62 &(o_table.Add_Row()
63 >> *new Html::TableCell
64 << new Html::ClassAttr(C_sCellStyle_MDetail))
69 const String sContentBorder("0");
70 const String sContentWidth("96%");
71 const String sContentPadding("5");
72 const String sContentSpacing("0");
74 const String sBgWhite("#ffffff");
75 const String sCenter("center");
77 void
78 HF_IdlDataMember::write_Title( const client & i_ce ) const
80 CurOut()
81 >> *new Html::Label(i_ce.LocalName())
82 << new Html::ClassAttr(C_sMemberTitle)
83 << i_ce.LocalName();
86 void
87 HF_IdlDataMember::write_Description( const client & i_ce ) const
89 CurOut() << new Html::HorizontalLine;
90 write_Docu(CurOut(), i_ce);
93 void
94 HF_IdlDataMember::enter_ContentCell() const
97 Xml::Element &
98 rContentCell = CurOut()
99 >> *new Html::Table( sContentBorder,
100 sContentWidth,
101 sContentPadding,
102 sContentSpacing )
103 << new Html::ClassAttr("table-in-data")
104 << new Html::BgColorAttr(sBgWhite)
105 << new Html::AlignAttr(sCenter)
106 >> *new Html::TableRow
107 >> *new Html::TableCell;
108 Out().Enter(rContentCell);
112 void
113 HF_IdlDataMember::leave_ContentCell() const
115 Out().Leave();
119 HF_IdlProperty::~HF_IdlProperty()
123 typedef ary::idl::ifc_property::attr PropertyAttr;
125 void
126 HF_IdlProperty::write_Declaration( const client & i_ce ) const
128 if (PropertyAttr::HasAnyStereotype(i_ce))
130 CurOut() << "[ ";
131 if (PropertyAttr::IsReadOnly(i_ce))
132 CurOut() << "readonly ";
133 if (PropertyAttr::IsBound(i_ce))
134 CurOut() << "bound ";
135 if (PropertyAttr::IsConstrained(i_ce))
136 CurOut() << "constrained ";
137 if (PropertyAttr::IsMayBeAmbiguous(i_ce))
138 CurOut() << "maybeambiguous ";
139 if (PropertyAttr::IsMayBeDefault(i_ce))
140 CurOut() << "maybedefault ";
141 if (PropertyAttr::IsMayBeVoid(i_ce))
142 CurOut() << "maybevoid ";
143 if (PropertyAttr::IsRemovable(i_ce))
144 CurOut() << "removable ";
145 if (PropertyAttr::IsTransient(i_ce))
146 CurOut() << "transient ";
147 CurOut() << "] ";
148 } // end if
150 HF_IdlTypeText
151 aType( Env(), CurOut(), true );
152 aType.Produce_byData( PropertyAttr::Type(i_ce) );
154 CurOut() << " " >> *new Html::Bold << i_ce.LocalName();
155 CurOut() << ";";
161 HF_IdlAttribute::~HF_IdlAttribute()
165 typedef ary::idl::ifc_attribute::attr AttributeAttr;
167 void
168 HF_IdlAttribute::write_Declaration( const client & i_ce ) const
170 if (AttributeAttr::HasAnyStereotype(i_ce))
172 CurOut() << "[ ";
173 if (AttributeAttr::IsReadOnly(i_ce))
174 CurOut() << "readonly ";
175 if (AttributeAttr::IsBound(i_ce))
176 CurOut() << "bound ";
177 CurOut() << "] ";
180 HF_IdlTypeText
181 aType( Env(), CurOut(), true );
182 aType.Produce_byData( AttributeAttr::Type(i_ce) );
184 CurOut()
185 << " "
186 >> *new Html::Bold
187 << i_ce.LocalName();
189 dyn_type_list pGetExceptions;
190 dyn_type_list pSetExceptions;
191 AttributeAttr::Get_GetExceptions(pGetExceptions, i_ce);
192 AttributeAttr::Get_SetExceptions(pSetExceptions, i_ce);
194 bool bGetRaises = (*pGetExceptions).IsValid();
195 bool bSetRaises = (*pSetExceptions).IsValid();
196 bool bRaises = bGetRaises OR bSetRaises;
197 if (bRaises)
199 HF_DocEntryList aSub(CurOut());
201 if (bGetRaises)
203 Xml::Element &
204 rGet = aSub.Produce_Definition();
205 HF_IdlTypeText
206 aExc(Env(), rGet, true);
207 type_list & itExc = *pGetExceptions;
209 rGet << "get raises (";
210 aExc.Produce_byData(*itExc);
211 for (++itExc; itExc.operator bool(); ++itExc)
213 rGet
214 << ",";
215 aExc.Produce_byData(*itExc);
216 } // end for
217 rGet << ")";
218 if (NOT bSetRaises)
219 rGet << ";";
220 } // end if (bGetRaises)
222 if (bSetRaises)
224 Xml::Element &
225 rSet = aSub.Produce_Definition();
226 HF_IdlTypeText
227 aExc(Env(), rSet, true);
228 type_list & itExc = *pSetExceptions;
230 rSet << "set raises (";
231 aExc.Produce_byData(*itExc);
232 for (++itExc; itExc.operator bool(); ++itExc)
234 rSet
235 << ",";
236 aExc.Produce_byData(*itExc);
237 } // end for
238 rSet << ");";
239 } // end if (bSetRaises)
241 else
243 CurOut() << ";";
250 HF_IdlEnumValue::~HF_IdlEnumValue()
254 typedef ary::idl::ifc_enumvalue::attr EnumValueAttr;
256 void
257 HF_IdlEnumValue::write_Declaration( const client & i_ce ) const
259 CurOut()
260 >> *new Html::Bold
261 << i_ce.LocalName();
263 const String &
264 rValue = EnumValueAttr::Value(i_ce);
265 if ( NOT rValue.empty() )
266 { CurOut() << " " // << " = " // In the moment this is somehow in the value
267 << rValue;
268 // CurOut() << ","; // In the moment this is somehow in the value
270 else
271 CurOut() << ",";
275 HF_IdlConstant::~HF_IdlConstant()
279 typedef ary::idl::ifc_constant::attr ConstantAttr;
281 void
282 HF_IdlConstant::write_Declaration( const client & i_ce ) const
284 CurOut() << "const ";
285 HF_IdlTypeText
286 aType( Env(), CurOut(), true );
287 aType.Produce_byData(ConstantAttr::Type(i_ce));
288 CurOut()
289 << " "
290 >> *new Html::Bold
291 << i_ce.LocalName();
292 const String &
293 rValue = ConstantAttr::Value(i_ce);
294 CurOut() << " " // << " = " // In the moment this is somehow in the value
295 << rValue;
296 // << ";"; // In the moment this is somehow in the value
300 HF_IdlStructElement::~HF_IdlStructElement()
304 typedef ary::idl::ifc_structelement::attr StructElementAttr;
306 void
307 HF_IdlStructElement::write_Declaration( const client & i_ce ) const
309 HF_IdlTypeText
310 aType( Env(), CurOut(), true );
311 aType.Produce_byData(StructElementAttr::Type(i_ce));
312 CurOut()
313 << " "
314 >> *new Html::Bold
315 << i_ce.LocalName();
316 CurOut()
317 << ";";
320 HF_IdlCommentedRelationElement::~HF_IdlCommentedRelationElement()
324 void
325 HF_IdlCommentedRelationElement::produce_Summary( Environment & io_env,
326 Xml::Element & io_context,
327 const comref & i_commentedRef,
328 const client & i_rScopeGivingCe )
330 csv_assert( i_commentedRef.Info() );
332 const ce_info & rDocu = *i_commentedRef.Info();
334 bool bShort = NOT rDocu.Short().IsEmpty();
335 bool bDescr = NOT rDocu.Description().IsEmpty();
337 if ( bShort )
339 HF_IdlDocuTextDisplay
340 aDescription(io_env, 0, i_rScopeGivingCe);
342 Xml::Element& rPara = io_context >> *new Html::Paragraph;
343 aDescription.Out().Enter( rPara );
344 rDocu.Short().DisplayAt( aDescription );
346 // if there's more than just the summary - i.e. a description, or usage restrictions, or tags -,
347 // then add a link to the details section
348 if ( bDescr OR rDocu.IsDeprecated() OR rDocu.IsOptional() OR NOT rDocu.Tags().empty() )
350 StreamLock aLocalLink(100);
351 aLocalLink() << "#" << get_LocalLinkName(io_env, i_commentedRef);
353 aDescription.Out().Out() << "(";
354 aDescription.Out().Out()
355 >> *new Html::Link( aLocalLink().c_str() )
356 << "details";
357 aDescription.Out().Out() << ")";
360 aDescription.Out().Leave();
364 void
365 HF_IdlCommentedRelationElement::produce_LinkDoc( Environment & io_env,
366 const client & i_ce,
367 Xml::Element & io_context,
368 const comref & i_commentedRef,
369 const E_DocType i_docType )
371 if ( i_commentedRef.Info() != 0 )
373 if ( i_docType == doctype_complete )
375 HF_DocEntryList aDocList(io_context);
376 HF_IdlDocu aDocuDisplay(io_env, aDocList);
378 aDocuDisplay.Produce_fromReference(*i_commentedRef.Info(), i_ce);
380 else
382 produce_Summary(io_env, io_context, i_commentedRef, i_ce);
385 else
387 HF_DocEntryList aDocList(io_context);
389 const client *
390 pCe = io_env.Linker().Search_CeFromType(i_commentedRef.Type());
391 const ce_info *
392 pShort = pCe != 0
393 ? Get_IdlDocu(pCe->Docu())
394 : (const ce_info *)(0);
395 if ( pShort != 0 )
397 aDocList.Produce_NormalTerm("(referenced entity's summary:)");
398 Xml::Element &
399 rDef = aDocList.Produce_Definition();
400 HF_IdlDocuTextDisplay
401 aShortDisplay( io_env, &rDef, *pCe);
402 pShort->Short().DisplayAt(aShortDisplay);
403 } // end if (pShort != 0)
404 } // endif ( (*i_commentedRef).Info() != 0 ) else
408 String
409 HF_IdlCommentedRelationElement::get_LocalLinkName( Environment & io_env,
410 const comref & i_commentedRef )
412 StringVector aModules;
413 String sLocalName;
414 ce_id nCe;
415 int nSequenceCount = 0;
417 const ary::idl::Type &
418 rType = io_env.Data().Find_Type(i_commentedRef.Type());
419 io_env.Data().Get_TypeText(aModules, sLocalName, nCe, nSequenceCount, rType);
421 // speaking strictly, this is not correct: If we have two interfaces with the same local
422 // name, but in different modules, then the link name will be ambiguous. However, this should
423 // be too seldom a case to really make the link names that ugly by adding the module information.
424 return sLocalName;
427 void
428 HF_IdlCommentedRelationElement::write_Title( const client & /*i_ce*/ ) const
431 Xml::Element &
432 rAnchor = CurOut()
433 >> *new Html::Label(get_LocalLinkName(Env(), m_relation))
434 << new Html::ClassAttr(C_sMemberTitle);
436 HF_IdlTypeText
437 aText(Env(), rAnchor, true);
438 aText.Produce_byData(m_relation.Type());
441 void
442 HF_IdlCommentedRelationElement::write_Declaration( const client & /*i_ce*/ ) const
444 // nothing to do here - an entity which is a commented relation does not have a declaration
447 void
448 HF_IdlCommentedRelationElement::write_Description( const client & i_ce ) const
450 produce_LinkDoc( Env(), i_ce, CurOut(), m_relation, doctype_complete );
453 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */