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