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