1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include <precomp.h> 29*cdf0e10cSrcweir #include "pm_index.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 33*cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx> 34*cdf0e10cSrcweir #include <ary/cpp/c_class.hxx> 35*cdf0e10cSrcweir #include <ary/cpp/c_define.hxx> 36*cdf0e10cSrcweir #include <ary/cpp/c_enum.hxx> 37*cdf0e10cSrcweir #include <ary/cpp/c_enuval.hxx> 38*cdf0e10cSrcweir #include <ary/cpp/c_funct.hxx> 39*cdf0e10cSrcweir #include <ary/cpp/c_macro.hxx> 40*cdf0e10cSrcweir #include <ary/cpp/c_namesp.hxx> 41*cdf0e10cSrcweir #include <ary/cpp/c_tydef.hxx> 42*cdf0e10cSrcweir #include <ary/cpp/c_vari.hxx> 43*cdf0e10cSrcweir #include <ary/cpp/cp_ce.hxx> 44*cdf0e10cSrcweir #include "aryattrs.hxx" 45*cdf0e10cSrcweir #include "hd_chlst.hxx" 46*cdf0e10cSrcweir #include "hd_docu.hxx" 47*cdf0e10cSrcweir #include "html_kit.hxx" 48*cdf0e10cSrcweir #include "navibar.hxx" 49*cdf0e10cSrcweir #include "opageenv.hxx" 50*cdf0e10cSrcweir #include "pagemake.hxx" 51*cdf0e10cSrcweir #include "strconst.hxx" 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir using namespace csi; 54*cdf0e10cSrcweir using ary::GlobalId; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir namespace 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir inline const char * 63*cdf0e10cSrcweir F_CK_Text( ary::cpp::E_ClassKey i_eCK ) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir switch (i_eCK) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir case ary::cpp::CK_class: return "class"; 68*cdf0e10cSrcweir case ary::cpp::CK_struct: return "struct"; 69*cdf0e10cSrcweir case ary::cpp::CK_union: return "union"; 70*cdf0e10cSrcweir } // end switch 71*cdf0e10cSrcweir return ""; 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir template <class CE> 75*cdf0e10cSrcweir inline const char * 76*cdf0e10cSrcweir F_OwnerType( const CE & i_rData, const ary::cpp::Gate & i_rGate ) 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir if ( i_rData.Protection() == ary::cpp::PROTECT_global ) 79*cdf0e10cSrcweir return "namespace "; 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir const ary::cpp::Class * 82*cdf0e10cSrcweir pClass = dynamic_cast< const ary::cpp::Class* >( 83*cdf0e10cSrcweir i_rGate.Ces().Search_Ce(i_rData.Owner()) ); 84*cdf0e10cSrcweir if (pClass != 0) 85*cdf0e10cSrcweir return F_CK_Text(pClass->ClassKey()); 86*cdf0e10cSrcweir return ""; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir } // anonymous namespace 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir PageMaker_Index::PageMaker_Index( PageDisplay & io_rPage, 92*cdf0e10cSrcweir char i_c ) 93*cdf0e10cSrcweir : SpecializedPageMaker(io_rPage), 94*cdf0e10cSrcweir pNavi(0), 95*cdf0e10cSrcweir c(i_c), 96*cdf0e10cSrcweir pCurIndex(0) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir PageMaker_Index::~PageMaker_Index() 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir void 105*cdf0e10cSrcweir PageMaker_Index::MakePage() 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir pNavi = new NavigationBar( Env(), NavigationBar::LOC_Index ); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir Write_NavBar(); 110*cdf0e10cSrcweir Write_TopArea(); 111*cdf0e10cSrcweir Write_CompleteAlphabeticalList(); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir void 115*cdf0e10cSrcweir PageMaker_Index::do_Process( const ary::cpp::Namespace & i_rData ) 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir Write_CeIndexEntry( i_rData, "namespace", "namespace" ); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir void 121*cdf0e10cSrcweir PageMaker_Index::do_Process( const ary::cpp::Class & i_rData ) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir // KORR_FUTURE 124*cdf0e10cSrcweir // Really throw out all anonymous classes from index? 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir if ( strncmp(i_rData.LocalName().c_str()+1,"_Anonymous",10) == 0 ) 127*cdf0e10cSrcweir return; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir Write_CeIndexEntry( i_rData, 130*cdf0e10cSrcweir F_CK_Text(i_rData.ClassKey()), 131*cdf0e10cSrcweir F_OwnerType(i_rData, Env().Gate()) ); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir void 135*cdf0e10cSrcweir PageMaker_Index::do_Process( const ary::cpp::Enum & i_rData ) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir Write_CeIndexEntry( i_rData, "enum", F_OwnerType(i_rData, Env().Gate()) ); 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir void 141*cdf0e10cSrcweir PageMaker_Index::do_Process( const ary::cpp::Typedef & i_rData ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir Write_CeIndexEntry( i_rData, "typedef", F_OwnerType(i_rData, Env().Gate()) ); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir void 147*cdf0e10cSrcweir PageMaker_Index::do_Process( const ary::cpp::Function & i_rData ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir Write_CeIndexEntry( i_rData, "function", F_OwnerType(i_rData, Env().Gate()) ); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir void 153*cdf0e10cSrcweir PageMaker_Index::do_Process( const ary::cpp::Variable & i_rData ) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir Write_CeIndexEntry( i_rData, "variable", F_OwnerType(i_rData, Env().Gate()) ); 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir void 159*cdf0e10cSrcweir PageMaker_Index::do_Process( const ary::cpp::EnumValue & i_rData ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir Write_CeIndexEntry( i_rData, "enum value", "" ); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir void 165*cdf0e10cSrcweir PageMaker_Index::do_Process( const ary::cpp::Define & i_rData ) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir String sFileName; 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir pCurIndex->AddEntry(); 170*cdf0e10cSrcweir pCurIndex->Term() 171*cdf0e10cSrcweir >> *new html::Link( Link2CppDefinition(Env(), i_rData) ) 172*cdf0e10cSrcweir >> *new html::Bold 173*cdf0e10cSrcweir << i_rData.LocalName(); 174*cdf0e10cSrcweir pCurIndex->Term() 175*cdf0e10cSrcweir << " - define"; 176*cdf0e10cSrcweir pCurIndex->Def() << " "; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir void 180*cdf0e10cSrcweir PageMaker_Index::do_Process( const ary::cpp::Macro & i_rData ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir String sFileName; 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir pCurIndex->AddEntry(); 185*cdf0e10cSrcweir pCurIndex->Term() 186*cdf0e10cSrcweir >> *new html::Link( Link2CppDefinition(Env(), i_rData) ) 187*cdf0e10cSrcweir >> *new html::Bold 188*cdf0e10cSrcweir << i_rData.LocalName(); 189*cdf0e10cSrcweir pCurIndex->Term() 190*cdf0e10cSrcweir << " - macro"; 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir pCurIndex->Def() << " "; 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir const ary::cpp::Gate * 196*cdf0e10cSrcweir PageMaker_Index::inq_Get_ReFinder() const 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir return &Env().Gate(); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir void 202*cdf0e10cSrcweir PageMaker_Index::Write_NavBar() 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir pNavi->Write( CurOut() ); 205*cdf0e10cSrcweir CurOut() << new html::HorizontalLine; 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir const String C_sAlphabet( 210*cdf0e10cSrcweir "<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> " 211*cdf0e10cSrcweir "<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> " 212*cdf0e10cSrcweir "<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> " 213*cdf0e10cSrcweir "<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> " 214*cdf0e10cSrcweir "<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> " 215*cdf0e10cSrcweir "<a href=\"index-26.html\"><B>Z</B></a> <a href=\"index-27.html\"><B>_</B></a>" ); 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir void 218*cdf0e10cSrcweir PageMaker_Index::Write_TopArea() 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir String sLetter(&c, 1); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir adcdisp::PageTitle_Std fTitle; 223*cdf0e10cSrcweir fTitle( CurOut(), "Global Index", sLetter ); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir CurOut() >>* new html::Paragraph 226*cdf0e10cSrcweir << new html::AlignAttr("center") 227*cdf0e10cSrcweir << new xml::XmlCode(C_sAlphabet); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir CurOut() << new html::HorizontalLine; 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir void 233*cdf0e10cSrcweir PageMaker_Index::Write_CompleteAlphabeticalList() 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir std::vector<GlobalId> 236*cdf0e10cSrcweir aThisPagesItems; 237*cdf0e10cSrcweir const ary::cpp::Gate & 238*cdf0e10cSrcweir rGate = Env().Gate(); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir static char sBegin[] = "X"; 241*cdf0e10cSrcweir static char sEnd[] = "Y"; 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir switch ( c ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir case 'Z': sBegin[0] = 'Z'; 246*cdf0e10cSrcweir sEnd[0] = '_'; 247*cdf0e10cSrcweir break; 248*cdf0e10cSrcweir case '_': sBegin[0] = '_'; 249*cdf0e10cSrcweir sEnd[0] = '0'; 250*cdf0e10cSrcweir break; 251*cdf0e10cSrcweir default: sBegin[0] = c; 252*cdf0e10cSrcweir sEnd[0] = char(c + 1); 253*cdf0e10cSrcweir break; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir uintt 257*cdf0e10cSrcweir nCount = rGate.Get_AlphabeticalList( aThisPagesItems, sBegin, sEnd ); 258*cdf0e10cSrcweir if (nCount > 0 ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir adcdisp::IndexList 261*cdf0e10cSrcweir aIndex(CurOut()); 262*cdf0e10cSrcweir pCurIndex = &aIndex; 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir std::vector<GlobalId>::const_iterator itEnd = aThisPagesItems.end(); 265*cdf0e10cSrcweir for ( std::vector<GlobalId>::const_iterator it = aThisPagesItems.begin(); 266*cdf0e10cSrcweir it != itEnd; 267*cdf0e10cSrcweir ++it ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir const ary::Entity * 270*cdf0e10cSrcweir pRe = rGate.Search_Entity( *it ); 271*cdf0e10cSrcweir if ( pRe != 0 ) 272*cdf0e10cSrcweir pRe->Accept(*this); 273*cdf0e10cSrcweir } // end for 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir pCurIndex = 0; 276*cdf0e10cSrcweir } // endif (nCount > 0) 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir void 280*cdf0e10cSrcweir PageMaker_Index::Write_CeIndexEntry( const ary::cpp::CodeEntity & 281*cdf0e10cSrcweir i_rCe, 282*cdf0e10cSrcweir const char * i_sType, 283*cdf0e10cSrcweir const char * i_sOwnerType ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir if ( Ce_IsInternal(i_rCe) ) 286*cdf0e10cSrcweir return; 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir static csv::StreamStr aQualification(500); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir const ary::cpp::CodeEntity & 291*cdf0e10cSrcweir rOwner = Env().Gate().Ces().Find_Ce(i_rCe.Owner()); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir pCurIndex->AddEntry(); 294*cdf0e10cSrcweir pCurIndex->Term() 295*cdf0e10cSrcweir >> *new html::Link( Link2Ce(Env(), i_rCe) ) 296*cdf0e10cSrcweir >> *new html::Bold 297*cdf0e10cSrcweir << i_rCe.LocalName(); 298*cdf0e10cSrcweir pCurIndex->Term() 299*cdf0e10cSrcweir << " - " 300*cdf0e10cSrcweir << i_sType; 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir if ( rOwner.Owner().IsValid() ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir aQualification.seekp(0); 305*cdf0e10cSrcweir Env().Gate().Ces().Get_QualifiedName( aQualification, 306*cdf0e10cSrcweir rOwner.LocalName(), 307*cdf0e10cSrcweir rOwner.Owner() ); 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir pCurIndex->Term() 310*cdf0e10cSrcweir << " in " 311*cdf0e10cSrcweir << i_sOwnerType 312*cdf0e10cSrcweir << " " 313*cdf0e10cSrcweir << aQualification.c_str(); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir pCurIndex->Def() << " "; 317*cdf0e10cSrcweir } 318