1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <precomp.h> 29 #include "hfi_property.hxx" 30 31 32 // NOT FULLY DEFINED SERVICES 33 #include <ary/idl/i_ce.hxx> 34 #include <ary/idl/ik_attribute.hxx> 35 #include <ary/idl/ik_constant.hxx> 36 #include <ary/idl/ik_enumvalue.hxx> 37 #include <ary/idl/ik_property.hxx> 38 #include <ary/idl/ik_structelem.hxx> 39 #include <toolkit/hf_docentry.hxx> 40 #include <toolkit/hf_title.hxx> 41 #include "hfi_typetext.hxx" 42 #include "hfi_doc.hxx" 43 #include "hfi_tag.hxx" 44 #include "hi_env.hxx" 45 #include "hi_ary.hxx" 46 #include "hi_linkhelper.hxx" 47 48 void 49 HF_IdlDataMember::Produce_byData( const client & ce ) const 50 { 51 write_Title(ce); 52 enter_ContentCell(); 53 write_Declaration(ce); 54 write_Description(ce); 55 leave_ContentCell(); 56 } 57 58 HF_IdlDataMember::HF_IdlDataMember( Environment & io_rEnv, 59 HF_SubTitleTable & o_table ) 60 : HtmlFactory_Idl( io_rEnv, 61 &(o_table.Add_Row() 62 >> *new Html::TableCell 63 << new Html::ClassAttr(C_sCellStyle_MDetail)) 64 ) 65 { 66 } 67 68 const String sContentBorder("0"); 69 const String sContentWidth("96%"); 70 const String sContentPadding("5"); 71 const String sContentSpacing("0"); 72 73 const String sBgWhite("#ffffff"); 74 const String sCenter("center"); 75 76 void 77 HF_IdlDataMember::write_Title( const client & i_ce ) const 78 { 79 CurOut() 80 >> *new Html::Label(i_ce.LocalName()) 81 << new Html::ClassAttr(C_sMemberTitle) 82 << i_ce.LocalName(); 83 } 84 85 void 86 HF_IdlDataMember::write_Description( const client & i_ce ) const 87 { 88 CurOut() << new Html::HorizontalLine; 89 write_Docu(CurOut(), i_ce); 90 } 91 92 void 93 HF_IdlDataMember::enter_ContentCell() const 94 { 95 96 Xml::Element & 97 rContentCell = CurOut() 98 >> *new Html::Table( sContentBorder, 99 sContentWidth, 100 sContentPadding, 101 sContentSpacing ) 102 << new Html::ClassAttr("table-in-data") 103 << new Html::BgColorAttr(sBgWhite) 104 << new Html::AlignAttr(sCenter) 105 >> *new Html::TableRow 106 >> *new Html::TableCell; 107 Out().Enter(rContentCell); 108 } 109 110 111 void 112 HF_IdlDataMember::leave_ContentCell() const 113 { 114 Out().Leave(); 115 } 116 117 118 HF_IdlProperty::~HF_IdlProperty() 119 { 120 } 121 122 typedef ary::idl::ifc_property::attr PropertyAttr; 123 124 void 125 HF_IdlProperty::write_Declaration( const client & i_ce ) const 126 { 127 if (PropertyAttr::HasAnyStereotype(i_ce)) 128 { 129 CurOut() << "[ "; 130 if (PropertyAttr::IsReadOnly(i_ce)) 131 CurOut() << "readonly "; 132 if (PropertyAttr::IsBound(i_ce)) 133 CurOut() << "bound "; 134 if (PropertyAttr::IsConstrained(i_ce)) 135 CurOut() << "constrained "; 136 if (PropertyAttr::IsMayBeAmbiguous(i_ce)) 137 CurOut() << "maybeambiguous "; 138 if (PropertyAttr::IsMayBeDefault(i_ce)) 139 CurOut() << "maybedefault "; 140 if (PropertyAttr::IsMayBeVoid(i_ce)) 141 CurOut() << "maybevoid "; 142 if (PropertyAttr::IsRemovable(i_ce)) 143 CurOut() << "removable "; 144 if (PropertyAttr::IsTransient(i_ce)) 145 CurOut() << "transient "; 146 CurOut() << "] "; 147 } // end if 148 149 HF_IdlTypeText 150 aType( Env(), CurOut(), true ); 151 aType.Produce_byData( PropertyAttr::Type(i_ce) ); 152 153 CurOut() << " " >> *new Html::Bold << i_ce.LocalName(); 154 CurOut() << ";"; 155 } 156 157 158 159 160 HF_IdlAttribute::~HF_IdlAttribute() 161 { 162 } 163 164 typedef ary::idl::ifc_attribute::attr AttributeAttr; 165 166 void 167 HF_IdlAttribute::write_Declaration( const client & i_ce ) const 168 { 169 if (AttributeAttr::HasAnyStereotype(i_ce)) 170 { 171 CurOut() << "[ "; 172 if (AttributeAttr::IsReadOnly(i_ce)) 173 CurOut() << "readonly "; 174 if (AttributeAttr::IsBound(i_ce)) 175 CurOut() << "bound "; 176 CurOut() << "] "; 177 } 178 179 HF_IdlTypeText 180 aType( Env(), CurOut(), true ); 181 aType.Produce_byData( AttributeAttr::Type(i_ce) ); 182 183 CurOut() 184 << " " 185 >> *new Html::Bold 186 << i_ce.LocalName(); 187 188 dyn_type_list pGetExceptions; 189 dyn_type_list pSetExceptions; 190 AttributeAttr::Get_GetExceptions(pGetExceptions, i_ce); 191 AttributeAttr::Get_SetExceptions(pSetExceptions, i_ce); 192 193 bool bGetRaises = (*pGetExceptions).IsValid(); 194 bool bSetRaises = (*pSetExceptions).IsValid(); 195 bool bRaises = bGetRaises OR bSetRaises; 196 if (bRaises) 197 { 198 HF_DocEntryList aSub(CurOut()); 199 200 if (bGetRaises) 201 { 202 Xml::Element & 203 rGet = aSub.Produce_Definition(); 204 HF_IdlTypeText 205 aExc(Env(), rGet, true); 206 type_list & itExc = *pGetExceptions; 207 208 rGet << "get raises ("; 209 aExc.Produce_byData(*itExc); 210 for (++itExc; itExc.operator bool(); ++itExc) 211 { 212 rGet 213 << ","; 214 aExc.Produce_byData(*itExc); 215 } // end for 216 rGet << ")"; 217 if (NOT bSetRaises) 218 rGet << ";"; 219 } // end if (bGetRaises) 220 221 if (bSetRaises) 222 { 223 Xml::Element & 224 rSet = aSub.Produce_Definition(); 225 HF_IdlTypeText 226 aExc(Env(), rSet, true); 227 type_list & itExc = *pSetExceptions; 228 229 rSet << "set raises ("; 230 aExc.Produce_byData(*itExc); 231 for (++itExc; itExc.operator bool(); ++itExc) 232 { 233 rSet 234 << ","; 235 aExc.Produce_byData(*itExc); 236 } // end for 237 rSet << ");"; 238 } // end if (bSetRaises) 239 } 240 else 241 { 242 CurOut() << ";"; 243 } 244 } 245 246 247 248 249 HF_IdlEnumValue::~HF_IdlEnumValue() 250 { 251 } 252 253 typedef ary::idl::ifc_enumvalue::attr EnumValueAttr; 254 255 void 256 HF_IdlEnumValue::write_Declaration( const client & i_ce ) const 257 { 258 CurOut() 259 >> *new Html::Bold 260 << i_ce.LocalName(); 261 262 const String & 263 rValue = EnumValueAttr::Value(i_ce); 264 if ( NOT rValue.empty() ) 265 { CurOut() << " " // << " = " // In the moment this is somehow in the value 266 << rValue; 267 // CurOut() << ","; // In the moment this is somehow in the value 268 } 269 else 270 CurOut() << ","; 271 } 272 273 274 HF_IdlConstant::~HF_IdlConstant() 275 { 276 } 277 278 typedef ary::idl::ifc_constant::attr ConstantAttr; 279 280 void 281 HF_IdlConstant::write_Declaration( const client & i_ce ) const 282 { 283 CurOut() << "const "; 284 HF_IdlTypeText 285 aType( Env(), CurOut(), true ); 286 aType.Produce_byData(ConstantAttr::Type(i_ce)); 287 CurOut() 288 << " " 289 >> *new Html::Bold 290 << i_ce.LocalName(); 291 const String & 292 rValue = ConstantAttr::Value(i_ce); 293 CurOut() << " " // << " = " // In the moment this is somehow in the value 294 << rValue; 295 // << ";"; // In the moment this is somehow in the value 296 } 297 298 299 HF_IdlStructElement::~HF_IdlStructElement() 300 { 301 } 302 303 typedef ary::idl::ifc_structelement::attr StructElementAttr; 304 305 void 306 HF_IdlStructElement::write_Declaration( const client & i_ce ) const 307 { 308 HF_IdlTypeText 309 aType( Env(), CurOut(), true ); 310 aType.Produce_byData(StructElementAttr::Type(i_ce)); 311 CurOut() 312 << " " 313 >> *new Html::Bold 314 << i_ce.LocalName(); 315 CurOut() 316 << ";"; 317 } 318 319 HF_IdlCommentedRelationElement::~HF_IdlCommentedRelationElement() 320 { 321 } 322 323 void 324 HF_IdlCommentedRelationElement::produce_Summary( Environment & io_env, 325 Xml::Element & io_context, 326 const comref & i_commentedRef, 327 const client & i_rScopeGivingCe ) 328 { 329 csv_assert( i_commentedRef.Info() ); 330 331 const ary::idl::Type_id aType = i_commentedRef.Type(); 332 const ce_info & rDocu = *i_commentedRef.Info(); 333 334 bool bShort = NOT rDocu.Short().IsEmpty(); 335 bool bDescr = NOT rDocu.Description().IsEmpty(); 336 337 if ( bShort ) 338 { 339 HF_IdlDocuTextDisplay 340 aDescription(io_env, 0, i_rScopeGivingCe); 341 342 Xml::Element& rPara = io_context >> *new Html::Paragraph; 343 aDescription.Out().Enter( rPara ); 344 rDocu.Short().DisplayAt( aDescription ); 345 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() ) 349 { 350 StreamLock aLocalLink(100); 351 aLocalLink() << "#" << get_LocalLinkName(io_env, i_commentedRef); 352 353 aDescription.Out().Out() << "("; 354 aDescription.Out().Out() 355 >> *new Html::Link( aLocalLink().c_str() ) 356 << "details"; 357 aDescription.Out().Out() << ")"; 358 } 359 360 aDescription.Out().Leave(); 361 } 362 } 363 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 ) 370 { 371 if ( i_commentedRef.Info() != 0 ) 372 { 373 if ( i_docType == doctype_complete ) 374 { 375 HF_DocEntryList aDocList(io_context); 376 HF_IdlDocu aDocuDisplay(io_env, aDocList); 377 378 aDocuDisplay.Produce_fromReference(*i_commentedRef.Info(), i_ce); 379 } 380 else 381 { 382 produce_Summary(io_env, io_context, i_commentedRef, i_ce); 383 } 384 } 385 else 386 { 387 HF_DocEntryList aDocList(io_context); 388 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 ) 396 { 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 405 } 406 407 408 String 409 HF_IdlCommentedRelationElement::get_LocalLinkName( Environment & io_env, 410 const comref & i_commentedRef ) 411 { 412 StringVector aModules; 413 String sLocalName; 414 ce_id nCe; 415 int nSequenceCount = 0; 416 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); 420 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; 425 } 426 427 void 428 HF_IdlCommentedRelationElement::write_Title( const client & /*i_ce*/ ) const 429 { 430 431 Xml::Element & 432 rAnchor = CurOut() 433 >> *new Html::Label(get_LocalLinkName(Env(), m_relation)) 434 << new Html::ClassAttr(C_sMemberTitle); 435 436 HF_IdlTypeText 437 aText(Env(), rAnchor, true); 438 aText.Produce_byData(m_relation.Type()); 439 } 440 441 void 442 HF_IdlCommentedRelationElement::write_Declaration( const client & /*i_ce*/ ) const 443 { 444 // nothing to do here - an entity which is a commented relation does not have a declaration 445 } 446 447 void 448 HF_IdlCommentedRelationElement::write_Description( const client & i_ce ) const 449 { 450 produce_LinkDoc( Env(), i_ce, CurOut(), m_relation, doctype_complete ); 451 } 452