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