/************************************************************************* * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: pm_index.cxx,v $ * * $Revision: 1.5 $ * * last change: $Author: rt $ $Date: 2005-09-07 17:36:19 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. * * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2005 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ************************************************************************/ #include #include "pm_index.hxx" // NOT FULLY DEFINED SERVICES #include #include #include #include #include #include #include #include #include #include #include #include "aryattrs.hxx" #include "hd_chlst.hxx" #include "hd_docu.hxx" #include "html_kit.hxx" #include "navibar.hxx" #include "opageenv.hxx" #include "pagemake.hxx" #include "strconst.hxx" using namespace csi; namespace { inline const char * F_CK_Text( ary::cpp::E_ClassKey i_eCK ) { switch (i_eCK) { case ary::cpp::CK_class: return "class"; case ary::cpp::CK_struct: return "struct"; case ary::cpp::CK_union: return "union"; } // end switch return ""; } template inline const char * F_OwnerType( const CE & i_rData, const ary::cpp::DisplayGate & i_rGate ) { if ( i_rData.Protection() == ary::cpp::PROTECT_global ) return "namespace "; const ary::cpp::Class * pClass = dynamic_cast< const ary::cpp::Class* >( i_rGate.Find_Ce(i_rData.Owner()) ); if (pClass != 0) return F_CK_Text(pClass->ClassKey()); return ""; } } // anonymous namespace PageMaker_Index::PageMaker_Index( PageDisplay & io_rPage, char i_c ) : SpecializedPageMaker(io_rPage), pNavi(0), c(i_c), pCurIndex(0) { } PageMaker_Index::~PageMaker_Index() { } void PageMaker_Index::MakePage() { pNavi = new NavigationBar( Env(), NavigationBar::LOC_Index ); Write_NavBar(); Write_TopArea(); Write_CompleteAlphabeticalList(); } void PageMaker_Index::Display_Namespace( const ary::cpp::Namespace & i_rData ) { Write_CeIndexEntry( i_rData, "namespace", "namespace" ); } void PageMaker_Index::Display_Class( const ary::cpp::Class & i_rData ) { // KORR_FUTURE // Really throw out all anonymous classes from index? if ( strncmp(i_rData.LocalName().c_str()+1,"_Anonymous",10) == 0 ) return; Write_CeIndexEntry( i_rData, F_CK_Text(i_rData.ClassKey()), F_OwnerType(i_rData, Env().Gate()) ); } void PageMaker_Index::Display_Enum( const ary::cpp::Enum & i_rData ) { Write_CeIndexEntry( i_rData, "enum", F_OwnerType(i_rData, Env().Gate()) ); } void PageMaker_Index::Display_Typedef( const ary::cpp::Typedef & i_rData ) { Write_CeIndexEntry( i_rData, "typedef", F_OwnerType(i_rData, Env().Gate()) ); } void PageMaker_Index::Display_Function( const ary::cpp::Function & i_rData ) { Write_CeIndexEntry( i_rData, "function", F_OwnerType(i_rData, Env().Gate()) ); } void PageMaker_Index::Display_Variable( const ary::cpp::Variable & i_rData ) { Write_CeIndexEntry( i_rData, "variable", F_OwnerType(i_rData, Env().Gate()) ); } void PageMaker_Index::Display_EnumValue( const ary::cpp::EnumValue & i_rData ) { Write_CeIndexEntry( i_rData, "enum value", "" ); } void PageMaker_Index::Display_Define( const ary::cpp::Define & i_rData ) { udmstri sFileName; pCurIndex->AddEntry(); pCurIndex->Term() >> *new html::Link( Link2CppDefinition(Env(), i_rData) ) >> *new html::Bold << i_rData.DefinedName() << " - define"; // KORR FUTURE // pCurIndex->Term() // << " - " // << " define in file " // << sFileName; pCurIndex->Def() << " "; } void PageMaker_Index::Display_Macro( const ary::cpp::Macro & i_rData ) { udmstri sFileName; pCurIndex->AddEntry(); pCurIndex->Term() >> *new html::Link( Link2CppDefinition(Env(), i_rData) ) >> *new html::Bold << i_rData.DefinedName() << " - macro"; // KORR FUTURE // pCurIndex->Term() // << " - " // << " macro in file " // << sFileName; pCurIndex->Def() << " "; } void PageMaker_Index::Write_NavBar() { pNavi->Write( CurOut() ); CurOut() << new html::HorizontalLine; } const udmstri C_sAlphabet( "A B C D E " "F G H I J " "K L M N O " "P Q R S T " "U V W X Y " "Z _" ); void PageMaker_Index::Write_TopArea() { udmstri sLetter(&c, 1); adcdisp::PageTitle_Std fTitle; fTitle( CurOut(), "Global Index", sLetter ); CurOut() >>* new html::Paragraph << new html::AlignAttr("center") << new xml::XmlCode(C_sAlphabet); CurOut() << new html::HorizontalLine; } void PageMaker_Index::Write_CompleteAlphabeticalList() { std::vector aThisPagesItems; const ary::cpp::DisplayGate & rGate = Env().Gate(); static char sBegin[] = "X"; static char sEnd[] = "Y"; switch ( c ) { case 'Z': sBegin[0] = 'Z'; sEnd[0] = '_'; break; case '_': sBegin[0] = '_'; sEnd[0] = '0'; break; default: sBegin[0] = c; sEnd[0] = char(c + 1); break; } uintt nCount = rGate.Get_AlphabeticalList( aThisPagesItems, sBegin, sEnd ); if (nCount > 0 ) { adcdisp::IndexList aIndex(CurOut()); pCurIndex = &aIndex; std::vector::const_iterator itEnd = aThisPagesItems.end(); for ( std::vector::const_iterator it = aThisPagesItems.begin(); it != itEnd; ++it ) { const ary::RepositoryEntity * pRe = rGate.Find_Re( *it ); if ( pRe != 0 ) pRe->StoreAt(*this); } // end for pCurIndex = 0; } // endif (nCount > 0) } void PageMaker_Index::Write_CeIndexEntry( const ary::CodeEntity & i_rCe, const char * i_sType, const char * i_sOwnerType ) { if ( Ce_IsInternal(i_rCe) ) return; static csv::StreamStr aQualification(500); const ary::CodeEntity & rOwner = Env().Gate().Ref_Ce(i_rCe.Owner()); pCurIndex->AddEntry(); pCurIndex->Term() >> *new html::Link( Link2Ce(Env(), i_rCe) ) >> *new html::Bold << i_rCe.LocalName(); pCurIndex->Term() << " - " << i_sType; if ( rOwner.Owner() != 0 ) { aQualification.seekp(0); Env().Gate().Get_QualifiedName( aQualification, rOwner.LocalName(), rOwner.Owner() ); pCurIndex->Term() << " in " << i_sOwnerType << " " << aQualification.c_str(); } pCurIndex->Def() << " "; }