1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #include <precomp.h> 23 #include "hfi_globalindex.hxx" 24 25 26 // NOT FULLY DEFINED SERVICES 27 #include <cosv/tpl/tpltools.hxx> 28 #include <ary/idl/i_ce.hxx> 29 #include <ary/idl/i_types4idl.hxx> 30 #include <ary/idl/i_module.hxx> 31 #include <toolkit/hf_title.hxx> 32 #include "hfi_navibar.hxx" 33 #include "hfi_typetext.hxx" 34 #include "hi_linkhelper.hxx" 35 36 37 38 39 namespace 40 { 41 42 /** 43 */ 44 enum E_Types 45 { 46 t_service = 0, 47 t_interface = 1, 48 t_struct = 2, 49 t_exception = 3, 50 t_enum = 4, 51 t_typedef = 5, 52 t_constantsgroup = 6, 53 t_property = 7, 54 t_function = 8, 55 t_structelement = 9, 56 t_enumvalue = 10, 57 t_constant = 11, 58 t_module = 12, 59 t_singleton = 13, 60 t_attribute = 14, 61 t_siservice = 15, 62 t_sisingleton = 16, 63 t_MAX 64 }; 65 66 String G_sDummy; 67 68 69 /* RC-Ids for IDL types (see reposy.cxx): 70 71 Module 2000 72 Interface 2001 73 Function 2002 74 Service 2003 75 Property 2004 76 77 Enum 2005 78 EnumValue 2006 79 Typedef 2007 80 Struct 2008 81 StructElement 2009 82 83 Exception 2010 84 ConstantGroup 2011 85 Constant 2012 86 Singleton 2013 87 Attribute 2014 88 SglIfcService 2015 89 SglIfcSingleton 2016 90 */ 91 const int C_nNumberOfIdlTypes = 17; 92 const char * C_sTypeNames[C_nNumberOfIdlTypes] = 93 { "module ", "interface ", "function ", "service ", "property ", 94 "enum ", "value ", "typedef ", "struct ", "field ", 95 "exception ", "constants group ", "constant ","singleton ", "attribute ", 96 "service", "singleton" 97 }; 98 const char * C_sOwnerNames[C_nNumberOfIdlTypes] = 99 { "module ", "module ", "interface ", "module ", "service ", 100 "module ", "enum ", "module ", "module ", "", // could be struct or exception 101 "module ", "module ", "constants group ", "module ", "interface ", 102 "module", "module" 103 }; 104 const intt C_nNamesArrayOffset = intt(ary::idl::Module::class_id); 105 const int C_nIxField = 9; 106 107 108 109 110 const char C_cAlphabet[] = 111 "<a class=\"inverse\" href=\"index-1.html\"><B>A</B></a> <a class=\"inverse\" href=\"index-2.html\"><B>B</B></a> <a class=\"inverse\" href=\"index-3.html\"><B>C</B></a> <a class=\"inverse\" href=\"index-4.html\"><B>D</B></a> <a class=\"inverse\" href=\"index-5.html\"><B>E</B></a> " 112 "<a class=\"inverse\" href=\"index-6.html\"><B>F</B></a> <a class=\"inverse\" href=\"index-7.html\"><B>G</B></a> <a class=\"inverse\" href=\"index-8.html\"><B>H</B></a> <a class=\"inverse\" href=\"index-9.html\"><B>I</B></a> <a class=\"inverse\" href=\"index-10.html\"><B>J</B></a> " 113 "<a class=\"inverse\" href=\"index-11.html\"><B>K</B></a> <a class=\"inverse\" href=\"index-12.html\"><B>L</B></a> <a class=\"inverse\" href=\"index-13.html\"><B>M</B></a> <a class=\"inverse\" href=\"index-14.html\"><B>N</B></a> <a class=\"inverse\" href=\"index-15.html\"><B>O</B></a> " 114 "<a class=\"inverse\" href=\"index-16.html\"><B>P</B></a> <a class=\"inverse\" href=\"index-17.html\"><B>Q</B></a> <a class=\"inverse\" href=\"index-18.html\"><B>R</B></a> <a class=\"inverse\" href=\"index-19.html\"><B>S</B></a> <a class=\"inverse\" href=\"index-20.html\"><B>T</B></a> " 115 "<a class=\"inverse\" href=\"index-21.html\"><B>U</B></a> <a class=\"inverse\" href=\"index-22.html\"><B>V</B></a> <a class=\"inverse\" href=\"index-23.html\"><B>W</B></a> <a class=\"inverse\" href=\"index-24.html\"><B>X</B></a> <a class=\"inverse\" href=\"index-25.html\"><B>Y</B></a> " 116 "<a class=\"inverse\" href=\"index-26.html\"><B>Z</B></a>"; 117 118 119 120 HF_IdlGlobalIndex::PageData G_PageData; 121 122 } // end anonymous namespace 123 124 125 inline void 126 HF_IdlGlobalIndex::write_EntryItself( Xml::Element & o_destination, 127 const ary::idl::CodeEntity & i_ce, 128 const HF_IdlTypeText & i_typeLinkWriter ) const 129 { 130 i_typeLinkWriter.Produce_IndexLink(o_destination, i_ce); 131 o_destination << " - "; 132 } 133 134 135 HF_IdlGlobalIndex::HF_IdlGlobalIndex( Environment & io_rEnv, 136 Xml::Element & o_rOut ) 137 : HtmlFactory_Idl(io_rEnv, &o_rOut) 138 { 139 } 140 141 HF_IdlGlobalIndex::~HF_IdlGlobalIndex() 142 { 143 } 144 145 void 146 HF_IdlGlobalIndex::Produce_Page(ary::idl::alphabetical_index::E_Letter i_letter) const 147 { 148 make_Navibar(); 149 150 HF_TitleTable 151 aTitle(CurOut()); 152 StreamLock sl(100); 153 aTitle.Produce_Title( sl() 154 << "Global Index " 155 << ( i_letter != ary::idl::alphabetical_index::non_alpha 156 ? char(int(i_letter)-'a'+'A') 157 : '_' ) 158 << c_str ); 159 160 // Letters Index 161 aTitle.Add_Row() 162 << new Xml::XmlCode( 163 "<p align=\"center\"><a href=\"index-1.html\"><b>A</b></a> <a href=\"index-2.html\"><b>B</b></a> <a href=\"index-3.html\"><b>C</b></a> <a href=\"index-4.html\"><b>D</b></a> <a href=\"index-5.html\"><b>E</b></a> <a href=\"index-6.html\"><b>F</b></a> <a href=\"index-7.html\"><b>G</b></a> <a href=\"index-8.html\"><b>H</b></a> <a href=\"index-9.html\"><b>I</b></a> <a href=\"index-10.html\"><b>J</b></a>" 164 " <a href=\"index-11.html\"><b>K</b></a> <a href=\"index-12.html\"><b>L</b></a> <a href=\"index-13.html\"><b>M</b></a> <a href=\"index-14.html\"><b>N</b></a> <a href=\"index-15.html\"><b>O</b></a> <a href=\"index-16.html\"><b>P</b></a> <a href=\"index-17.html\"><b>Q</b></a> <a href=\"index-18.html\"><b>R</b></a> <a href=\"index-19.html\"><b>S</b></a> <a href=\"index-20.html\"><b>T</b></a>" 165 " <a href=\"index-21.html\"><b>U</b></a> <a href=\"index-22.html\"><b>V</b></a> <a href=\"index-23.html\"><b>W</b></a> <a href=\"index-24.html\"><b>X</b></a> <a href=\"index-25.html\"><b>Y</b></a> <a href=\"index-26.html\"><b>Z</b></a> <a href=\"index-27.html\"><b>_</b></a></p>" ); 166 167 Out().Enter(CurOut() >> *new Html::DefList); 168 169 csv::erase_container(G_PageData); 170 Env().Data().Get_IndexData(G_PageData, i_letter); 171 172 // Helper object to produce links to the index Entries. 173 HF_IdlTypeText aTypeLinkWriter(Env(),HF_IdlTypeText::use_for_javacompatible_index); 174 175 PageData::const_iterator itEnd = G_PageData.end(); 176 for ( PageData::const_iterator iter = G_PageData.begin(); 177 iter != itEnd; 178 ++iter ) 179 { 180 produce_Line(iter, aTypeLinkWriter); 181 } // end for 182 183 Out().Leave(); 184 CurOut() << new Html::HorizontalLine; 185 } 186 187 void 188 HF_IdlGlobalIndex::make_Navibar() const 189 { 190 HF_IdlNavigationBar 191 aNaviBar(Env(), CurOut()); 192 aNaviBar.Produce_IndexMainRow(); 193 194 CurOut() << new Html::HorizontalLine(); 195 } 196 197 void 198 HF_IdlGlobalIndex::produce_Line( PageData::const_iterator i_entry, 199 const HF_IdlTypeText & i_typeLinkWriter) const 200 { 201 const client & 202 rCe = Env().Data().Find_Ce(*i_entry); 203 if (NOT rCe.Owner().IsValid()) 204 return; // Omit global namespace. 205 206 // The destination for the created output: 207 Xml::Element & rDT = CurOut() >> *new Html::DefListTerm; 208 209 /** The following code is intended to produce an output that 210 will be recognized by the context help system of Forte. 211 That is reached by making it similar to the indices, that 212 Javadoc produces. 213 If the link to the Entry contains a hashmark, the Forte-Help 214 requires following a link to the owner. 215 But if there is no hashmark, the following link must go to 216 the same Entry again. Doesn't make really sense :-(, but that's 217 like it is. 218 */ 219 write_EntryItself(rDT,rCe,i_typeLinkWriter); 220 if (rCe.SightLevel() == ary::idl::sl_Member) 221 write_OwnerOfEntry(rDT,rCe,i_typeLinkWriter); 222 else 223 write_EntrySecondTime(rDT,rCe,i_typeLinkWriter); 224 225 // This produces an empty "<dd></dd>", which is also needed to reach 226 // similarity to the Javadoc index: 227 CurOut() << new Html::DefListDefinition; 228 } 229 230 void 231 HF_IdlGlobalIndex::write_OwnerOfEntry( Xml::Element & o_destination, 232 const ary::idl::CodeEntity & i_ce, 233 const HF_IdlTypeText & i_typeLinkWriter ) const 234 { 235 const client & 236 rOwner = Env().Data().Find_Ce(i_ce.Owner()); 237 238 int nIx = int(i_ce.AryClass() - C_nNamesArrayOffset); 239 csv_assert(csv::in_range(0,nIx,C_nNumberOfIdlTypes)); 240 241 o_destination << C_sTypeNames[nIx] 242 << "in "; 243 if (nIx != C_nIxField) 244 { 245 o_destination << C_sOwnerNames[nIx]; 246 } 247 else 248 { 249 uintt 250 nOwnerIx = rOwner.AryClass() - C_nNamesArrayOffset; 251 csv_assert( 252 nOwnerIx < static_cast< unsigned int >(C_nNumberOfIdlTypes)); 253 o_destination << C_sTypeNames[nOwnerIx]; 254 } 255 i_typeLinkWriter.Produce_IndexOwnerLink(o_destination, rOwner); 256 } 257 258 void 259 HF_IdlGlobalIndex::write_EntrySecondTime( Xml::Element & o_destination, 260 const ary::idl::CodeEntity & i_ce, 261 const HF_IdlTypeText & i_typeLinkWriter ) const 262 { 263 int nIx = int(i_ce.AryClass() - C_nNamesArrayOffset); 264 csv_assert(csv::in_range(0,nIx,C_nNumberOfIdlTypes)); 265 266 o_destination << C_sTypeNames[nIx] 267 << " "; 268 i_typeLinkWriter.Produce_IndexSecondEntryLink(o_destination, i_ce); 269 } 270