Update ooo320-m1
[ooovba.git] / autodoc / source / display / html / pm_index.cxx
blob2d095279a4d9b7e603dc92a07e994a5a064bdee7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pm_index.cxx,v $
10 * $Revision: 1.9 $
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 ************************************************************************/
31 #include <precomp.h>
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"
56 using namespace csi;
57 using ary::GlobalId;
62 namespace
65 inline const char *
66 F_CK_Text( ary::cpp::E_ClassKey i_eCK )
68 switch (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";
73 } // end switch
74 return "";
77 template <class CE>
78 inline const char *
79 F_OwnerType( const CE & i_rData, const ary::cpp::Gate & i_rGate )
81 if ( i_rData.Protection() == ary::cpp::PROTECT_global )
82 return "namespace ";
84 const ary::cpp::Class *
85 pClass = dynamic_cast< const ary::cpp::Class* >(
86 i_rGate.Ces().Search_Ce(i_rData.Owner()) );
87 if (pClass != 0)
88 return F_CK_Text(pClass->ClassKey());
89 return "";
92 } // anonymous namespace
94 PageMaker_Index::PageMaker_Index( PageDisplay & io_rPage,
95 char i_c )
96 : SpecializedPageMaker(io_rPage),
97 pNavi(0),
98 c(i_c),
99 pCurIndex(0)
103 PageMaker_Index::~PageMaker_Index()
107 void
108 PageMaker_Index::MakePage()
110 pNavi = new NavigationBar( Env(), NavigationBar::LOC_Index );
112 Write_NavBar();
113 Write_TopArea();
114 Write_CompleteAlphabeticalList();
117 void
118 PageMaker_Index::do_Process( const ary::cpp::Namespace & i_rData )
120 Write_CeIndexEntry( i_rData, "namespace", "namespace" );
123 void
124 PageMaker_Index::do_Process( const ary::cpp::Class & i_rData )
126 // KORR_FUTURE
127 // Really throw out all anonymous classes from index?
129 if ( strncmp(i_rData.LocalName().c_str()+1,"_Anonymous",10) == 0 )
130 return;
132 Write_CeIndexEntry( i_rData,
133 F_CK_Text(i_rData.ClassKey()),
134 F_OwnerType(i_rData, Env().Gate()) );
137 void
138 PageMaker_Index::do_Process( const ary::cpp::Enum & i_rData )
140 Write_CeIndexEntry( i_rData, "enum", F_OwnerType(i_rData, Env().Gate()) );
143 void
144 PageMaker_Index::do_Process( const ary::cpp::Typedef & i_rData )
146 Write_CeIndexEntry( i_rData, "typedef", F_OwnerType(i_rData, Env().Gate()) );
149 void
150 PageMaker_Index::do_Process( const ary::cpp::Function & i_rData )
152 Write_CeIndexEntry( i_rData, "function", F_OwnerType(i_rData, Env().Gate()) );
155 void
156 PageMaker_Index::do_Process( const ary::cpp::Variable & i_rData )
158 Write_CeIndexEntry( i_rData, "variable", F_OwnerType(i_rData, Env().Gate()) );
161 void
162 PageMaker_Index::do_Process( const ary::cpp::EnumValue & i_rData )
164 Write_CeIndexEntry( i_rData, "enum value", "" );
167 void
168 PageMaker_Index::do_Process( const ary::cpp::Define & i_rData )
170 String sFileName;
172 pCurIndex->AddEntry();
173 pCurIndex->Term()
174 >> *new html::Link( Link2CppDefinition(Env(), i_rData) )
175 >> *new html::Bold
176 << i_rData.LocalName();
177 pCurIndex->Term()
178 << " - define";
179 pCurIndex->Def() << " ";
182 void
183 PageMaker_Index::do_Process( const ary::cpp::Macro & i_rData )
185 String sFileName;
187 pCurIndex->AddEntry();
188 pCurIndex->Term()
189 >> *new html::Link( Link2CppDefinition(Env(), i_rData) )
190 >> *new html::Bold
191 << i_rData.LocalName();
192 pCurIndex->Term()
193 << " - macro";
195 pCurIndex->Def() << " ";
198 const ary::cpp::Gate *
199 PageMaker_Index::inq_Get_ReFinder() const
201 return &Env().Gate();
204 void
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>" );
220 void
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;
235 void
236 PageMaker_Index::Write_CompleteAlphabeticalList()
238 std::vector<GlobalId>
239 aThisPagesItems;
240 const ary::cpp::Gate &
241 rGate = Env().Gate();
243 static char sBegin[] = "X";
244 static char sEnd[] = "Y";
246 switch ( c )
248 case 'Z': sBegin[0] = 'Z';
249 sEnd[0] = '_';
250 break;
251 case '_': sBegin[0] = '_';
252 sEnd[0] = '0';
253 break;
254 default: sBegin[0] = c;
255 sEnd[0] = char(c + 1);
256 break;
259 uintt
260 nCount = rGate.Get_AlphabeticalList( aThisPagesItems, sBegin, sEnd );
261 if (nCount > 0 )
263 adcdisp::IndexList
264 aIndex(CurOut());
265 pCurIndex = &aIndex;
267 std::vector<GlobalId>::const_iterator itEnd = aThisPagesItems.end();
268 for ( std::vector<GlobalId>::const_iterator it = aThisPagesItems.begin();
269 it != itEnd;
270 ++it )
272 const ary::Entity *
273 pRe = rGate.Search_Entity( *it );
274 if ( pRe != 0 )
275 pRe->Accept(*this);
276 } // end for
278 pCurIndex = 0;
279 } // endif (nCount > 0)
282 void
283 PageMaker_Index::Write_CeIndexEntry( const ary::cpp::CodeEntity &
284 i_rCe,
285 const char * i_sType,
286 const char * i_sOwnerType )
288 if ( Ce_IsInternal(i_rCe) )
289 return;
291 static csv::StreamStr aQualification(500);
293 const ary::cpp::CodeEntity &
294 rOwner = Env().Gate().Ces().Find_Ce(i_rCe.Owner());
296 pCurIndex->AddEntry();
297 pCurIndex->Term()
298 >> *new html::Link( Link2Ce(Env(), i_rCe) )
299 >> *new html::Bold
300 << i_rCe.LocalName();
301 pCurIndex->Term()
302 << " - "
303 << i_sType;
305 if ( rOwner.Owner().IsValid() )
307 aQualification.seekp(0);
308 Env().Gate().Ces().Get_QualifiedName( aQualification,
309 rOwner.LocalName(),
310 rOwner.Owner() );
312 pCurIndex->Term()
313 << " in "
314 << i_sOwnerType
315 << " "
316 << aQualification.c_str();
319 pCurIndex->Def() << " ";