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