1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pm_index.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include "pm_index.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/cpp/c_gate.hxx>
37 #include <ary/cpp/c_class.hxx>
38 #include <ary/cpp/c_define.hxx>
39 #include <ary/cpp/c_enum.hxx>
40 #include <ary/cpp/c_enuval.hxx>
41 #include <ary/cpp/c_funct.hxx>
42 #include <ary/cpp/c_macro.hxx>
43 #include <ary/cpp/c_namesp.hxx>
44 #include <ary/cpp/c_tydef.hxx>
45 #include <ary/cpp/c_vari.hxx>
46 #include <ary/cpp/cp_ce.hxx>
47 #include "aryattrs.hxx"
48 #include "hd_chlst.hxx"
49 #include "hd_docu.hxx"
50 #include "html_kit.hxx"
51 #include "navibar.hxx"
52 #include "opageenv.hxx"
53 #include "pagemake.hxx"
54 #include "strconst.hxx"
66 F_CK_Text( ary::cpp::E_ClassKey i_eCK
)
70 case ary::cpp::CK_class
: return "class";
71 case ary::cpp::CK_struct
: return "struct";
72 case ary::cpp::CK_union
: return "union";
79 F_OwnerType( const CE
& i_rData
, const ary::cpp::Gate
& i_rGate
)
81 if ( i_rData
.Protection() == ary::cpp::PROTECT_global
)
84 const ary::cpp::Class
*
85 pClass
= dynamic_cast< const ary::cpp::Class
* >(
86 i_rGate
.Ces().Search_Ce(i_rData
.Owner()) );
88 return F_CK_Text(pClass
->ClassKey());
92 } // anonymous namespace
94 PageMaker_Index::PageMaker_Index( PageDisplay
& io_rPage
,
96 : SpecializedPageMaker(io_rPage
),
103 PageMaker_Index::~PageMaker_Index()
108 PageMaker_Index::MakePage()
110 pNavi
= new NavigationBar( Env(), NavigationBar::LOC_Index
);
114 Write_CompleteAlphabeticalList();
118 PageMaker_Index::do_Process( const ary::cpp::Namespace
& i_rData
)
120 Write_CeIndexEntry( i_rData
, "namespace", "namespace" );
124 PageMaker_Index::do_Process( const ary::cpp::Class
& i_rData
)
127 // Really throw out all anonymous classes from index?
129 if ( strncmp(i_rData
.LocalName().c_str()+1,"_Anonymous",10) == 0 )
132 Write_CeIndexEntry( i_rData
,
133 F_CK_Text(i_rData
.ClassKey()),
134 F_OwnerType(i_rData
, Env().Gate()) );
138 PageMaker_Index::do_Process( const ary::cpp::Enum
& i_rData
)
140 Write_CeIndexEntry( i_rData
, "enum", F_OwnerType(i_rData
, Env().Gate()) );
144 PageMaker_Index::do_Process( const ary::cpp::Typedef
& i_rData
)
146 Write_CeIndexEntry( i_rData
, "typedef", F_OwnerType(i_rData
, Env().Gate()) );
150 PageMaker_Index::do_Process( const ary::cpp::Function
& i_rData
)
152 Write_CeIndexEntry( i_rData
, "function", F_OwnerType(i_rData
, Env().Gate()) );
156 PageMaker_Index::do_Process( const ary::cpp::Variable
& i_rData
)
158 Write_CeIndexEntry( i_rData
, "variable", F_OwnerType(i_rData
, Env().Gate()) );
162 PageMaker_Index::do_Process( const ary::cpp::EnumValue
& i_rData
)
164 Write_CeIndexEntry( i_rData
, "enum value", "" );
168 PageMaker_Index::do_Process( const ary::cpp::Define
& i_rData
)
172 pCurIndex
->AddEntry();
174 >> *new html::Link( Link2CppDefinition(Env(), i_rData
) )
176 << i_rData
.LocalName();
179 pCurIndex
->Def() << " ";
183 PageMaker_Index::do_Process( const ary::cpp::Macro
& i_rData
)
187 pCurIndex
->AddEntry();
189 >> *new html::Link( Link2CppDefinition(Env(), i_rData
) )
191 << i_rData
.LocalName();
195 pCurIndex
->Def() << " ";
198 const ary::cpp::Gate
*
199 PageMaker_Index::inq_Get_ReFinder() const
201 return &Env().Gate();
205 PageMaker_Index::Write_NavBar()
207 pNavi
->Write( CurOut() );
208 CurOut() << new html::HorizontalLine
;
212 const String
C_sAlphabet(
213 "<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> "
214 "<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> "
215 "<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> "
216 "<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> "
217 "<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> "
218 "<a href=\"index-26.html\"><B>Z</B></a> <a href=\"index-27.html\"><B>_</B></a>" );
221 PageMaker_Index::Write_TopArea()
223 String
sLetter(&c
, 1);
225 adcdisp::PageTitle_Std fTitle
;
226 fTitle( CurOut(), "Global Index", sLetter
);
228 CurOut() >>* new html::Paragraph
229 << new html::AlignAttr("center")
230 << new xml::XmlCode(C_sAlphabet
);
232 CurOut() << new html::HorizontalLine
;
236 PageMaker_Index::Write_CompleteAlphabeticalList()
238 std::vector
<GlobalId
>
240 const ary::cpp::Gate
&
241 rGate
= Env().Gate();
243 static char sBegin
[] = "X";
244 static char sEnd
[] = "Y";
248 case 'Z': sBegin
[0] = 'Z';
251 case '_': sBegin
[0] = '_';
254 default: sBegin
[0] = c
;
255 sEnd
[0] = char(c
+ 1);
260 nCount
= rGate
.Get_AlphabeticalList( aThisPagesItems
, sBegin
, sEnd
);
267 std::vector
<GlobalId
>::const_iterator itEnd
= aThisPagesItems
.end();
268 for ( std::vector
<GlobalId
>::const_iterator it
= aThisPagesItems
.begin();
273 pRe
= rGate
.Search_Entity( *it
);
279 } // endif (nCount > 0)
283 PageMaker_Index::Write_CeIndexEntry( const ary::cpp::CodeEntity
&
285 const char * i_sType
,
286 const char * i_sOwnerType
)
288 if ( Ce_IsInternal(i_rCe
) )
291 static csv::StreamStr
aQualification(500);
293 const ary::cpp::CodeEntity
&
294 rOwner
= Env().Gate().Ces().Find_Ce(i_rCe
.Owner());
296 pCurIndex
->AddEntry();
298 >> *new html::Link( Link2Ce(Env(), i_rCe
) )
300 << i_rCe
.LocalName();
305 if ( rOwner
.Owner().IsValid() )
307 aQualification
.seekp(0);
308 Env().Gate().Ces().Get_QualifiedName( aQualification
,
316 << aQualification
.c_str();
319 pCurIndex
->Def() << " ";