1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include "hfi_struct.hxx"
30 
31 
32 // NOT FULLY DEFINED SERVICES
33 #include <ary/idl/i_ce.hxx>
34 #include <ary/idl/i_struct.hxx>
35 #include <ary/idl/ik_exception.hxx>
36 #include <ary/idl/ik_struct.hxx>
37 #include <toolkit/hf_docentry.hxx>
38 #include <toolkit/hf_linachain.hxx>
39 #include <toolkit/hf_navi_sub.hxx>
40 #include <toolkit/hf_title.hxx>
41 #include "hfi_navibar.hxx"
42 #include "hfi_property.hxx"
43 #include "hfi_typetext.hxx"
44 #include "hi_linkhelper.hxx"
45 
46 
47 extern const String
48     C_sCePrefix_Struct("struct");
49 extern const String
50     C_sCePrefix_Exception("exception");
51 
52 
53 namespace
54 {
55 
56 const String
57     C_sBaseStruct("Base Hierarchy");
58 const String
59     C_sBaseException("Base Hierarchy");
60 
61 const String
62     C_sList_Elements("Elements' Summary");
63 const String
64     C_sList_Elements_Label("Elements");
65 
66 const String
67     C_sList_ElementDetails("Elements' Details");
68 const String
69     C_sList_ElementDetails_Label("ElementDetails");
70 
71 enum E_SubListIndices
72 {
73     sli_ElementsSummary = 0,
74     sli_ElementsDetails = 1
75 };
76 
77 }   // anonymous namespace
78 
79 
80 
81 HF_IdlStruct::HF_IdlStruct( Environment &         io_rEnv,
82                             Xml::Element &        o_rOut,
83                             bool                  i_bIsException )
84     :   HtmlFactory_Idl(io_rEnv, &o_rOut),
85         bIsException(i_bIsException)
86 {
87 }
88 
89 HF_IdlStruct::~HF_IdlStruct()
90 {
91 }
92 
93 void
94 HF_IdlStruct::Produce_byData( const client & i_ce ) const
95 {
96     const ary::idl::Struct *
97         pStruct =
98             bIsException
99                 ?   0
100                 :   static_cast< const ary::idl::Struct* >(&i_ce);
101     bool bIsTemplate =
102             pStruct != 0
103                 ?   pStruct->TemplateParameterType().IsValid()
104                 :   false;
105 
106     Dyn<HF_NaviSubRow>
107         pNaviSubRow( &make_Navibar(i_ce) );
108 
109     HF_TitleTable
110         aTitle(CurOut());
111     HF_LinkedNameChain
112         aNameChain(aTitle.Add_Row());
113 
114     aNameChain.Produce_CompleteChain(Env().CurPosition(), nameChainLinker);
115 
116     // Title:
117     StreamLock
118         slAnnotations(200);
119     get_Annotations(slAnnotations(), i_ce);
120 
121     StreamLock rTitle(200);
122     if (bIsTemplate)
123         rTitle() << "template ";
124     rTitle()
125         << (bIsException
126 		    ?   C_sCePrefix_Exception
127 			:   C_sCePrefix_Struct)
128 	    << " "
129 		<< i_ce.LocalName();
130     if (bIsTemplate)
131     {
132         csv_assert(pStruct != 0);
133         rTitle()
134             << "<"
135             << pStruct->TemplateParameter()
136             << ">";
137     }
138     aTitle.Produce_Title(slAnnotations().c_str(), rTitle().c_str());
139 
140     // Bases:
141     produce_Bases( aTitle.Add_Row(),
142                    i_ce,
143                    bIsException
144                     ?   C_sBaseException
145                     :   C_sBaseStruct );
146 
147     // Docu:
148     write_Docu(aTitle.Add_Row(), i_ce);
149     CurOut() << new Html::HorizontalLine();
150 
151     // Elements:
152     dyn_ce_list
153         dpElements;
154     if (bIsException)
155         ary::idl::ifc_exception::attr::Get_Elements(dpElements, i_ce);
156     else
157         ary::idl::ifc_struct::attr::Get_Elements(dpElements, i_ce);
158 
159     if ( (*dpElements).operator bool() )
160     {
161         produce_Members( *dpElements,
162                          C_sList_Elements,
163                          C_sList_Elements_Label,
164                          C_sList_ElementDetails,
165                          C_sList_ElementDetails_Label );
166         pNaviSubRow->SwitchOn(sli_ElementsSummary);
167         pNaviSubRow->SwitchOn(sli_ElementsDetails);
168     }
169     pNaviSubRow->Produce_Row();
170 }
171 
172 HtmlFactory_Idl::type_id
173 HF_IdlStruct::inq_BaseOf( const client & i_ce ) const
174 {
175     return bIsException
176                 ?   ary::idl::ifc_exception::attr::Base(i_ce)
177                 :   ary::idl::ifc_struct::attr::Base(i_ce);
178 }
179 
180 HF_NaviSubRow &
181 HF_IdlStruct::make_Navibar( const client & i_ce ) const
182 {
183     HF_IdlNavigationBar
184         aNaviBar(Env(), CurOut());
185     aNaviBar.Produce_CeMainRow(i_ce);
186 
187     DYN HF_NaviSubRow &
188         ret = aNaviBar.Add_SubRow();
189     ret.AddItem(C_sList_Elements, C_sList_Elements_Label, false);
190     ret.AddItem(C_sList_ElementDetails, C_sList_ElementDetails_Label, false);
191 
192     CurOut() << new Html::HorizontalLine();
193     return ret;
194 }
195 
196 void
197 HF_IdlStruct::produce_MemberDetails( HF_SubTitleTable &  o_table,
198                                      const client &      i_ce) const
199 {
200     HF_IdlStructElement
201         aElement( Env(), o_table );
202     aElement.Produce_byData(i_ce);
203 }
204