1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hfi_property.cxx,v $
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 ************************************************************************/
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"
49 #include "hi_linkhelper.hxx"
52 HF_IdlDataMember::Produce_byData( const client
& ce
) const
56 write_Declaration(ce
);
57 write_Description(ce
);
61 HF_IdlDataMember::HF_IdlDataMember( Environment
& io_rEnv
,
62 HF_SubTitleTable
& o_table
)
63 : HtmlFactory_Idl( io_rEnv
,
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");
80 HF_IdlDataMember::write_Title( const client
& i_ce
) const
83 >> *new Html::Label(i_ce
.LocalName())
84 << new Html::ClassAttr(C_sMemberTitle
)
89 HF_IdlDataMember::write_Description( const client
& i_ce
) const
91 CurOut() << new Html::HorizontalLine
;
92 write_Docu(CurOut(), i_ce
);
96 HF_IdlDataMember::enter_ContentCell() const
100 rContentCell
= CurOut()
101 >> *new Html::Table( sContentBorder
,
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
);
115 HF_IdlDataMember::leave_ContentCell() const
121 HF_IdlProperty::~HF_IdlProperty()
125 typedef ary::idl::ifc_property::attr PropertyAttr
;
128 HF_IdlProperty::write_Declaration( const client
& i_ce
) const
130 if (PropertyAttr::HasAnyStereotype(i_ce
))
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 ";
153 aType( Env(), CurOut(), true );
154 aType
.Produce_byData( PropertyAttr::Type(i_ce
) );
156 CurOut() << " " >> *new Html::Bold
<< i_ce
.LocalName();
163 HF_IdlAttribute::~HF_IdlAttribute()
167 typedef ary::idl::ifc_attribute::attr AttributeAttr
;
170 HF_IdlAttribute::write_Declaration( const client
& i_ce
) const
172 if (AttributeAttr::HasAnyStereotype(i_ce
))
175 if (AttributeAttr::IsReadOnly(i_ce
))
176 CurOut() << "readonly ";
177 if (AttributeAttr::IsBound(i_ce
))
178 CurOut() << "bound ";
183 aType( Env(), CurOut(), true );
184 aType
.Produce_byData( AttributeAttr::Type(i_ce
) );
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
;
201 HF_DocEntryList
aSub(CurOut());
206 rGet
= aSub
.Produce_Definition();
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
)
217 aExc
.Produce_byData(*itExc
);
222 } // end if (bGetRaises)
227 rSet
= aSub
.Produce_Definition();
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
)
238 aExc
.Produce_byData(*itExc
);
241 } // end if (bSetRaises)
252 HF_IdlEnumValue::~HF_IdlEnumValue()
256 typedef ary::idl::ifc_enumvalue::attr EnumValueAttr
;
259 HF_IdlEnumValue::write_Declaration( const client
& i_ce
) const
266 rValue
= EnumValueAttr::Value(i_ce
);
267 if ( NOT rValue
.empty() )
268 { CurOut() << " " // << " = " // In the moment this is somehow in the value
270 // CurOut() << ","; // In the moment this is somehow in the value
277 HF_IdlConstant::~HF_IdlConstant()
281 typedef ary::idl::ifc_constant::attr ConstantAttr
;
284 HF_IdlConstant::write_Declaration( const client
& i_ce
) const
286 CurOut() << "const ";
288 aType( Env(), CurOut(), true );
289 aType
.Produce_byData(ConstantAttr::Type(i_ce
));
295 rValue
= ConstantAttr::Value(i_ce
);
296 CurOut() << " " // << " = " // In the moment this is somehow in the value
298 // << ";"; // In the moment this is somehow in the value
302 HF_IdlStructElement::~HF_IdlStructElement()
306 typedef ary::idl::ifc_structelement::attr StructElementAttr
;
309 HF_IdlStructElement::write_Declaration( const client
& i_ce
) const
312 aType( Env(), CurOut(), true );
313 aType
.Produce_byData(StructElementAttr::Type(i_ce
));
322 HF_IdlCommentedRelationElement::~HF_IdlCommentedRelationElement()
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();
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() )
360 aDescription
.Out().Out() << ")";
363 aDescription
.Out().Leave();
368 HF_IdlCommentedRelationElement::produce_LinkDoc( Environment
& io_env
,
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
);
385 produce_Summary(io_env
, io_context
, i_commentedRef
, i_ce
);
390 HF_DocEntryList
aDocList(io_context
);
393 pCe
= io_env
.Linker().Search_CeFromType(i_commentedRef
.Type());
396 ? Get_IdlDocu(pCe
->Docu())
397 : (const ce_info
*)(0);
400 aDocList
.Produce_NormalTerm("(referenced entity's summary:)");
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
412 HF_IdlCommentedRelationElement::get_LocalLinkName( Environment
& io_env
,
413 const comref
& i_commentedRef
)
415 StringVector aModules
;
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.
431 HF_IdlCommentedRelationElement::write_Title( const client
& /*i_ce*/ ) const
436 >> *new Html::Label(get_LocalLinkName(Env(), m_relation
))
437 << new Html::ClassAttr(C_sMemberTitle
);
440 aText(Env(), rAnchor
, true);
441 aText
.Produce_byData(m_relation
.Type());
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
451 HF_IdlCommentedRelationElement::write_Description( const client
& i_ce
) const
453 produce_LinkDoc( Env(), i_ce
, CurOut(), m_relation
, doctype_complete
);