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_service.hxx"
30 
31 
32 // NOT FULLY DEFINED SERVICES
33 #include <ary/idl/i_ce.hxx>
34 #include <ary/idl/ik_property.hxx>
35 #include <ary/idl/ik_service.hxx>
36 #include <toolkit/hf_docentry.hxx>
37 #include <toolkit/hf_linachain.hxx>
38 #include <toolkit/hf_navi_sub.hxx>
39 #include <toolkit/hf_title.hxx>
40 #include "hfi_doc.hxx"
41 #include "hfi_navibar.hxx"
42 #include "hfi_property.hxx"
43 #include "hfi_tag.hxx"
44 #include "hfi_typetext.hxx"
45 #include "hi_linkhelper.hxx"
46 
47 
48 
49 
50 extern const String
51     C_sCePrefix_Service("service");
52 
53 namespace
54 {
55 
56 const String
57     C_sList_IncludedServices("Services' Summary");
58 const String
59     C_sList_IncludedServices_Heading("Included Services - Summary");
60 const String
61     C_sList_IncludedServices_Label("ServicesSummary");
62 const String
63     C_sList_IncludedServicesDetails("Services' Details");
64 const String
65     C_sList_IncludedServicesDetails_Heading("Included Services - Details");
66 const String
67     C_sList_IncludedServicesDetails_Label("ServicesDetails");
68 const String
69     C_sList_ExportedInterfaces("Interfaces' Summary");
70 const String
71     C_sList_ExportedInterfaces_Heading("Exported Interfaces - Summary");
72 const String
73     C_sList_ExportedInterfaces_Label("InterfacesSummary");
74 const String
75     C_sList_ExportedInterfacesDetails("Interfaces' Details");
76 const String
77     C_sList_ExportedInterfacesDetails_Heading("Exported Interfaces - Details");
78 const String
79     C_sList_ExportedInterfacesDetails_Label("InterfacesDetails");
80 const String
81     C_sList_Properties("Properties' Summary");
82 const String
83     C_sList_Properties_Label("PropertiesSummary");
84 const String
85     C_sList_PropertiesDetails("Properties' Details");
86 const String
87     C_sList_PropertiesDetails_Label("PropertiesDetails");
88 
89 
90 enum E_SubListIndices
91 {
92     sli_IncludedServicesSummary = 0,
93     sli_InterfacesSummary = 1,
94     sli_PropertiesSummary = 2,
95     sli_IncludedServicesDetails = 3,
96     sli_InterfacesDetails = 4,
97     sli_PropertiesDetails = 5
98 };
99 
100 } //anonymous namespace
101 
102 
103 HF_IdlService::HF_IdlService( Environment &         io_rEnv,
104                               Xml::Element &        o_rOut )
105     :   HtmlFactory_Idl(io_rEnv, &o_rOut)
106 {
107 }
108 
109 HF_IdlService::~HF_IdlService()
110 {
111 
112 }
113 
114 typedef ::ary::idl::ifc_service::attr
115     ServiceAttr;
116 typedef ::ary::Dyn_StdConstIterator< ::ary::idl::CommentedRelation >
117     dyn_comref_list;
118 
119 void
120 HF_IdlService::produce_CommentedRelations( const client &   i_ce,
121                                            comref_list &    it_list,
122                                            const String &   i_summaryTitle,
123                                            const String &   i_summaryLabel,
124                                            const String &   i_detailsTitle,
125                                            const String &   i_detailsLabel,
126                                            const E_DocType  i_docType ) const
127 {
128     csv_assert( it_list );
129 
130     bool bSummaryOnly = ( i_docType == doctype_summaryOnly );
131     HF_SubTitleTable aTable(
132                 CurOut(),
133                 bSummaryOnly ? i_summaryLabel : i_detailsLabel,
134                 bSummaryOnly ? i_summaryTitle : i_detailsTitle,
135                 2 );
136 
137     for ( ; it_list; ++it_list )
138     {
139         Xml::Element &
140             rRow = aTable.Add_Row();
141 
142         if ( bSummaryOnly )
143         {
144             produce_Link(rRow, (*it_list).Type());
145             produce_LinkSummary(i_ce, rRow, *it_list);
146         }
147         else
148         {
149             HF_IdlCommentedRelationElement
150                 aRelation( Env(), aTable, *it_list );
151             aRelation.Produce_byData( i_ce );
152         }
153     }   // end for
154 }
155 
156 void
157 HF_IdlService::Produce_byData( const client & i_ce ) const
158 {
159     Dyn<HF_NaviSubRow>
160         pNaviSubRow( &make_Navibar(i_ce) );
161 
162     HF_TitleTable
163         aTitle(CurOut());
164     HF_LinkedNameChain
165         aNameChain(aTitle.Add_Row());
166 
167     aNameChain.Produce_CompleteChain(Env().CurPosition(), nameChainLinker);
168     produce_Title(aTitle, C_sCePrefix_Service, i_ce);
169 
170     write_Docu(aTitle.Add_Row(), i_ce);
171     CurOut() << new Html::HorizontalLine();
172 
173     // produce ...
174     // - included services: summary
175     dyn_comref_list dpIncludedServices;
176     ServiceAttr::Get_IncludedServices(dpIncludedServices, i_ce);
177     if ( (*dpIncludedServices).operator bool() )
178     {
179         produce_CommentedRelations( i_ce, *dpIncludedServices,
180                          C_sList_IncludedServices_Heading,
181                          C_sList_IncludedServices_Label,
182                          C_sList_IncludedServicesDetails_Heading,
183                          C_sList_IncludedServicesDetails_Label,
184                          doctype_summaryOnly );
185         pNaviSubRow->SwitchOn(sli_IncludedServicesSummary);
186     }
187 
188     // - exported interfaces: summary
189     dyn_comref_list dpExportedInterfaces;
190     ServiceAttr::Get_ExportedInterfaces(dpExportedInterfaces, i_ce);
191     if ( (*dpExportedInterfaces).operator bool() )
192     {
193         produce_CommentedRelations( i_ce, *dpExportedInterfaces,
194                          C_sList_ExportedInterfaces_Heading,
195                          C_sList_ExportedInterfaces_Label,
196                          C_sList_ExportedInterfacesDetails_Heading,
197                          C_sList_ExportedInterfacesDetails_Label,
198                          doctype_summaryOnly );
199         pNaviSubRow->SwitchOn(sli_InterfacesSummary);
200     }
201 
202     // - supported properties: summary
203     dyn_ce_list dpProperties;
204     ServiceAttr::Get_Properties(dpProperties, i_ce);
205     if ( (*dpProperties).operator bool() )
206     {
207         produce_Members( *dpProperties,
208                          C_sList_Properties,
209                          C_sList_Properties_Label,
210                          C_sList_PropertiesDetails,
211                          C_sList_PropertiesDetails_Label,
212                          viewtype_summary );
213         pNaviSubRow->SwitchOn(sli_PropertiesSummary);
214     }
215 
216     // - included services: details
217     ServiceAttr::Get_IncludedServices(dpIncludedServices, i_ce);
218     if ( (*dpIncludedServices).operator bool() )
219     {
220         produce_CommentedRelations( i_ce, *dpIncludedServices,
221                          C_sList_IncludedServices_Heading,
222                          C_sList_IncludedServices_Label,
223                          C_sList_IncludedServicesDetails_Heading,
224                          C_sList_IncludedServicesDetails_Label,
225                          doctype_complete );
226         pNaviSubRow->SwitchOn(sli_IncludedServicesDetails);
227     }
228 
229     // - exported interfaces: details
230     ServiceAttr::Get_ExportedInterfaces(dpExportedInterfaces, i_ce);
231     if ( (*dpExportedInterfaces).operator bool() )
232     {
233         produce_CommentedRelations( i_ce, *dpExportedInterfaces,
234                          C_sList_ExportedInterfaces_Heading,
235                          C_sList_ExportedInterfaces_Label,
236                          C_sList_ExportedInterfacesDetails_Heading,
237                          C_sList_ExportedInterfacesDetails_Label,
238                          doctype_complete );
239         pNaviSubRow->SwitchOn(sli_InterfacesDetails);
240     }
241 
242     // supported properties: details
243     ServiceAttr::Get_Properties(dpProperties, i_ce);
244     if ( (*dpProperties).operator bool() )
245     {
246         produce_Members( *dpProperties,
247                          C_sList_Properties,
248                          C_sList_Properties_Label,
249                          C_sList_PropertiesDetails,
250                          C_sList_PropertiesDetails_Label,
251                          viewtype_details );
252         pNaviSubRow->SwitchOn(sli_PropertiesDetails);
253     }
254 
255     pNaviSubRow->Produce_Row();
256     CurOut() << new Xml::XmlCode("<br>&nbsp;");
257 }
258 
259 typedef ary::idl::ifc_property::attr    PropertyAttr;
260 
261 void
262 HF_IdlService::produce_SummaryDeclaration( Xml::Element &      o_row,
263 										   const client &      i_property ) const
264 {
265     // KORR_FUTURE
266     // Put this in to HF_IdlProperty!
267 
268     Xml::Element &
269         rCell = o_row
270                     >> *new Html::TableCell
271                         << new Html::ClassAttr( C_sCellStyle_SummaryLeft );
272 
273     if (PropertyAttr::HasAnyStereotype(i_property))
274     {
275         rCell << "[ ";
276         if (PropertyAttr::IsReadOnly(i_property))
277             rCell << "readonly ";
278         if (PropertyAttr::IsBound(i_property))
279             rCell << "bound ";
280         if (PropertyAttr::IsConstrained(i_property))
281             rCell << "constrained ";
282         if (PropertyAttr::IsMayBeAmbiguous(i_property))
283             rCell << "maybeambiguous ";
284         if (PropertyAttr::IsMayBeDefault(i_property))
285             rCell << "maybedefault ";
286         if (PropertyAttr::IsMayBeVoid(i_property))
287             rCell << "maybevoid ";
288         if (PropertyAttr::IsRemovable(i_property))
289             rCell << "removable ";
290         if (PropertyAttr::IsTransient(i_property))
291             rCell << "transient ";
292         rCell << "] ";
293     }   // end if
294 
295     HF_IdlTypeText
296         aType( Env(), rCell, true );
297     aType.Produce_byData( PropertyAttr::Type(i_property) );
298 
299     StreamLock aLocalLink(100);
300     aLocalLink() << "#" << i_property.LocalName();
301     rCell
302         << new Html::LineBreak
303         >> *new Html::Link( aLocalLink().c_str() )
304             << i_property.LocalName();
305 }
306 
307 DYN HF_NaviSubRow &
308 HF_IdlService::make_Navibar( const client & i_ce ) const
309 {
310     HF_IdlNavigationBar
311         aNaviBar(Env(), CurOut());
312     aNaviBar.Produce_CeMainRow(i_ce);
313 
314     DYN HF_NaviSubRow &
315         ret = aNaviBar.Add_SubRow();
316     ret.AddItem(C_sList_IncludedServices, C_sList_IncludedServices_Label, false);
317     ret.AddItem(C_sList_ExportedInterfaces, C_sList_ExportedInterfaces_Label, false);
318     ret.AddItem(C_sList_Properties, C_sList_Properties_Label, false);
319     ret.AddItem(C_sList_IncludedServicesDetails, C_sList_IncludedServicesDetails_Label, false);
320     ret.AddItem(C_sList_ExportedInterfacesDetails, C_sList_ExportedInterfacesDetails_Label, false);
321     ret.AddItem(C_sList_PropertiesDetails, C_sList_PropertiesDetails_Label, false);
322 
323     CurOut() << new Html::HorizontalLine();
324     return ret;
325 }
326 
327 void
328 HF_IdlService::produce_Link( Xml::Element &     o_row,
329                              type_id            i_type ) const
330 {
331     Xml::Element &
332         rCell = o_row
333                 >> *new Html::TableCell
334                     << new Html::ClassAttr(C_sCellStyle_SummaryLeft);
335     HF_IdlTypeText
336         aText(Env(), rCell, true);
337     aText.Produce_byData(i_type);
338 }
339 
340 void
341 HF_IdlService::produce_LinkSummary( const client &  i_ce,
342                                     Xml::Element &  o_row,
343                                     const comref &  i_commentedRef ) const
344 {
345     Xml::Element &
346         rCell = o_row
347                 >> *new Html::TableCell
348                     << new Html::ClassAttr(C_sCellStyle_SummaryRight);
349 
350     HF_IdlCommentedRelationElement::produce_LinkDoc( Env(), i_ce, rCell, i_commentedRef, doctype_summaryOnly );
351 }
352 
353 void
354 HF_IdlService::produce_MemberDetails( HF_SubTitleTable &  o_table,
355                                       const client &      i_ce ) const
356 {
357     HF_IdlProperty
358         aProperty( Env(), o_table);
359     aProperty.Produce_byData( i_ce );
360 }
361 
362 
363 
364