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_module.hxx" 30 31 32 // NOT FULLY DEFINED SERVICES 33 #include <ary/idl/i_ce.hxx> 34 #include <ary/idl/i_module.hxx> 35 #include <ary/idl/ik_module.hxx> 36 #include <ary/doc/d_oldidldocu.hxx> 37 #include <ary/getncast.hxx> 38 #include <toolkit/hf_docentry.hxx> 39 #include <toolkit/hf_linachain.hxx> 40 #include <toolkit/hf_navi_sub.hxx> 41 #include <toolkit/hf_title.hxx> 42 #include "hfi_doc.hxx" 43 #include "hfi_navibar.hxx" 44 #include "hfi_tag.hxx" 45 #include "hfi_typetext.hxx" 46 #include "hi_linkhelper.hxx" 47 48 49 extern const String 50 C_sCePrefix_Module("module"); 51 52 namespace 53 { 54 55 const String 56 C_sList_NestedModules("Nested Modules"); 57 const String 58 C_sList_NestedModules_Label("NestedModules"); 59 const String 60 C_sList_Services("Services"); 61 const String 62 C_sList_Singletons("Singletons"); 63 const String 64 C_sList_Interfaces("Interfaces"); 65 const String 66 C_sList_Structs("Structs"); 67 const String 68 C_sList_Exceptions("Exceptions"); 69 const String 70 C_sList_Enums("Enums"); 71 const String 72 C_sList_Typedefs("Typedefs"); 73 const String 74 C_sList_ConstGroups("Constant Groups"); 75 const String 76 C_sList_ConstGroups_Label("ConstantGroups"); 77 78 79 enum E_SubListIndices 80 { // In case of changes, also adapt make_Navibar() !! 81 sli_NestedModules = 0, 82 sli_Services = 1, 83 sli_Singletons = 2, 84 sli_Interfaces = 3, 85 sli_Structs = 4, 86 sli_Exceptions = 5, 87 sli_Enums = 6, 88 sli_Typedefs = 7, 89 sli_ConstGroups = 8 90 }; 91 92 } //anonymous namespace 93 94 95 HF_IdlModule::HF_IdlModule( Environment & io_rEnv, 96 Xml::Element & o_rOut ) 97 : HtmlFactory_Idl(io_rEnv, &o_rOut) 98 { 99 } 100 101 HF_IdlModule::~HF_IdlModule() 102 { 103 } 104 105 typedef ary::idl::ifc_module::attr ModuleAttr; 106 107 108 void 109 HF_IdlModule::Produce_byData( const client & i_ce ) const 110 { 111 Dyn<HF_NaviSubRow> 112 pNaviSubRow( &make_Navibar(i_ce) ); 113 114 HF_TitleTable 115 aTitle(CurOut()); 116 HF_LinkedNameChain 117 aNameChain(aTitle.Add_Row()); 118 119 if ( Env().CurPosition().Depth() > 0 ) 120 { 121 aNameChain.Produce_CompleteChain_forModule(Env().CurPosition(), nameChainLinker); 122 123 StreamLock 124 sl(200); 125 aTitle.Produce_Title( sl() 126 << C_sCePrefix_Module 127 << " " 128 << i_ce.LocalName() 129 << c_str ); 130 } 131 else 132 { 133 aTitle.Produce_Title( "Global Module" ); 134 } 135 136 write_Docu(aTitle.Add_Row(), i_ce); 137 CurOut() << new Html::HorizontalLine(); 138 139 140 // Write children lists: 141 ce_ptr_list aNestedModules; 142 ce_ptr_list aServices; 143 ce_ptr_list aInterfaces; 144 ce_ptr_list aStructs; 145 ce_ptr_list aExceptions; 146 ce_ptr_list aEnums; 147 ce_ptr_list aTypedefs; 148 ce_ptr_list aConstantGroups; 149 ce_ptr_list aSingletons; 150 151 ModuleAttr::Get_AllChildrenSeparated( 152 aNestedModules, 153 aServices, 154 aInterfaces, 155 aStructs, 156 aExceptions, 157 aEnums, 158 aTypedefs, 159 aConstantGroups, 160 aSingletons, 161 Env().Data().Ces(), 162 i_ce ); 163 164 // Has this to be in the order of enum E_SubListIndices ??? 165 if (produce_ChildList(C_sList_NestedModules, C_sList_NestedModules_Label, aNestedModules )) 166 pNaviSubRow->SwitchOn(sli_NestedModules); 167 if (produce_ChildList(C_sList_Services, C_sList_Services, aServices)) 168 pNaviSubRow->SwitchOn(sli_Services); 169 if (produce_ChildList(C_sList_Singletons, C_sList_Singletons, aSingletons)) 170 pNaviSubRow->SwitchOn(sli_Singletons); 171 if (produce_ChildList(C_sList_Interfaces, C_sList_Interfaces, aInterfaces)) 172 pNaviSubRow->SwitchOn(sli_Interfaces); 173 if (produce_ChildList(C_sList_Structs, C_sList_Structs, aStructs)) 174 pNaviSubRow->SwitchOn(sli_Structs); 175 if (produce_ChildList(C_sList_Exceptions, C_sList_Exceptions, aExceptions)) 176 pNaviSubRow->SwitchOn(sli_Exceptions); 177 if (produce_ChildList(C_sList_Enums, C_sList_Enums, aEnums)) 178 pNaviSubRow->SwitchOn(sli_Enums); 179 if (produce_ChildList(C_sList_Typedefs, C_sList_Typedefs, aTypedefs)) 180 pNaviSubRow->SwitchOn(sli_Typedefs); 181 if (produce_ChildList(C_sList_ConstGroups, C_sList_ConstGroups_Label, aConstantGroups)) 182 pNaviSubRow->SwitchOn(sli_ConstGroups); 183 pNaviSubRow->Produce_Row(); 184 } 185 186 DYN HF_NaviSubRow & 187 HF_IdlModule::make_Navibar( const client & i_ce ) const 188 { 189 HF_IdlNavigationBar 190 aNaviBar(Env(), CurOut()); 191 aNaviBar.Produce_ModuleMainRow(i_ce); 192 193 DYN HF_NaviSubRow & 194 ret = aNaviBar.Add_SubRow(); 195 196 // Has to be in the order of E_SubListIndices: 197 ret.AddItem(C_sList_NestedModules, C_sList_NestedModules_Label, false); 198 ret.AddItem(C_sList_Services, C_sList_Services, false); 199 ret.AddItem(C_sList_Singletons, C_sList_Singletons, false); 200 ret.AddItem(C_sList_Interfaces, C_sList_Interfaces, false); 201 ret.AddItem(C_sList_Structs, C_sList_Structs, false); 202 ret.AddItem(C_sList_Exceptions, C_sList_Exceptions, false); 203 ret.AddItem(C_sList_Enums, C_sList_Enums, false); 204 ret.AddItem(C_sList_Typedefs, C_sList_Typedefs, false); 205 ret.AddItem(C_sList_ConstGroups, C_sList_ConstGroups_Label, false); 206 207 CurOut() << new Html::HorizontalLine(); 208 return ret; 209 } 210 211 bool 212 HF_IdlModule::produce_ChildList( const String & i_sName, 213 const String & i_sLabel, 214 const ce_ptr_list & i_list ) const 215 { 216 if ( i_list.size() == 0 ) 217 return false; 218 219 HF_SubTitleTable 220 aTable( CurOut(), 221 i_sLabel, 222 i_sName, 223 2 ); 224 225 ce_ptr_list::const_iterator 226 itEnd = i_list.end(); 227 for ( ce_ptr_list::const_iterator it = i_list.begin(); 228 it != itEnd; 229 ++it ) 230 { 231 Xml::Element & 232 rRow = aTable.Add_Row(); 233 produce_Link(rRow, *it); 234 produce_LinkDoc(rRow, *it); 235 } // end for 236 237 return true; 238 } 239 240 void 241 HF_IdlModule::produce_Link( Xml::Element & o_row, 242 const client * i_ce ) const 243 { 244 csv_assert(i_ce != 0); 245 Xml::Element & 246 rCell = o_row 247 >> *new Html::TableCell 248 << new Html::ClassAttr(C_sCellStyle_SummaryLeft); 249 250 if ( NOT ary::is_type<ary::idl::Module>(*i_ce) ) 251 { 252 HF_IdlTypeText 253 aText(Env(), rCell, true); 254 aText.Produce_byData(i_ce->CeId()); 255 } 256 else 257 { 258 StreamLock slBuf(100); 259 rCell 260 >> *new Html::Link( slBuf() << i_ce->LocalName() 261 << "/module-ix.html" 262 << c_str ) 263 << i_ce->LocalName(); 264 } 265 } 266 267 void 268 HF_IdlModule::produce_LinkDoc( Xml::Element & o_row, 269 const client * i_ce ) const 270 { 271 csv_assert(i_ce != 0); 272 273 // We need the cell in any case, because, the rendering may be hurt else. 274 Xml::Element & 275 rCell = o_row 276 >> *new Html::TableCell 277 << new Html::ClassAttr(C_sCellStyle_SummaryRight); 278 279 const client & 280 rCe = *i_ce; 281 const ce_info * 282 pShort = Get_IdlDocu(rCe.Docu()); 283 if ( pShort == 0 ) 284 return; 285 286 287 if (pShort->IsDeprecated()) 288 { 289 rCell << "[ DEPRECATED ]" << new Html::LineBreak; 290 } 291 if (pShort->IsOptional()) 292 { 293 rCell << "[ OPTIONAL ]" << new Html::LineBreak; 294 } 295 296 HF_IdlDocuTextDisplay 297 aShortDisplay(Env(), &rCell, *i_ce); 298 pShort->Short().DisplayAt(aShortDisplay); 299 } 300