1*0841af79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*0841af79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*0841af79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*0841af79SAndrew Rist  * distributed with this work for additional information
6*0841af79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*0841af79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*0841af79SAndrew Rist  * "License"); you may not use this file except in compliance
9*0841af79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*0841af79SAndrew Rist  *
11*0841af79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*0841af79SAndrew Rist  *
13*0841af79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*0841af79SAndrew Rist  * software distributed under the License is distributed on an
15*0841af79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0841af79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*0841af79SAndrew Rist  * specific language governing permissions and limitations
18*0841af79SAndrew Rist  * under the License.
19*0841af79SAndrew Rist  *
20*0841af79SAndrew Rist  *************************************************************/
21cdf0e10cSrcweir 
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include "hfi_interface.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <ary/idl/i_ce.hxx>
28cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
29cdf0e10cSrcweir #include <ary/idl/ik_function.hxx>
30cdf0e10cSrcweir #include <ary/idl/ik_interface.hxx>
31cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
32cdf0e10cSrcweir #include <ary/idl/ip_type.hxx>
33cdf0e10cSrcweir #include <toolkit/hf_docentry.hxx>
34cdf0e10cSrcweir #include <toolkit/hf_linachain.hxx>
35cdf0e10cSrcweir #include <toolkit/hf_navi_sub.hxx>
36cdf0e10cSrcweir #include <toolkit/hf_title.hxx>
37cdf0e10cSrcweir #include "hfi_doc.hxx"
38cdf0e10cSrcweir #include "hfi_hierarchy.hxx"
39cdf0e10cSrcweir #include "hfi_method.hxx"
40cdf0e10cSrcweir #include "hfi_navibar.hxx"
41cdf0e10cSrcweir #include "hfi_property.hxx"
42cdf0e10cSrcweir #include "hfi_tag.hxx"
43cdf0e10cSrcweir #include "hfi_typetext.hxx"
44cdf0e10cSrcweir #include "hi_linkhelper.hxx"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir extern const String
48cdf0e10cSrcweir     C_sCePrefix_Interface("interface");
49cdf0e10cSrcweir 
50cdf0e10cSrcweir namespace
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 
53cdf0e10cSrcweir const String
54cdf0e10cSrcweir     C_sBaseInterface("Base Interfaces");
55cdf0e10cSrcweir const String
56cdf0e10cSrcweir     C_sList_BaseComments("Comments on Base Interfaces");
57cdf0e10cSrcweir const String
58cdf0e10cSrcweir     C_sList_Methods("Methods' Summary");
59cdf0e10cSrcweir const String
60cdf0e10cSrcweir     C_sList_Methods_Label("MethodsSummary");
61cdf0e10cSrcweir const String
62cdf0e10cSrcweir     C_sDetails_Methods("Methods' Details");
63cdf0e10cSrcweir const String
64cdf0e10cSrcweir     C_sDetails_Methods_Label("MethodsDetails");
65cdf0e10cSrcweir 
66cdf0e10cSrcweir const String
67cdf0e10cSrcweir     C_sList_Attributes("Attributes' Summary");
68cdf0e10cSrcweir const String
69cdf0e10cSrcweir     C_sList_Attributes_Label("AttributesSummary");
70cdf0e10cSrcweir const String
71cdf0e10cSrcweir     C_sList_AttributesDetails("Attributes' Details");
72cdf0e10cSrcweir const String
73cdf0e10cSrcweir     C_sList_AttributesDetails_Label("AttributesDetails");
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir enum E_SubListIndices
78cdf0e10cSrcweir {
79cdf0e10cSrcweir     sli_MethodsSummay = 0,
80cdf0e10cSrcweir     sli_AttributesSummary = 1,
81cdf0e10cSrcweir     sli_MethodDetails = 2,
82cdf0e10cSrcweir     sli_AttributesDetails = 3
83cdf0e10cSrcweir };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir } //anonymous namespace
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
HF_IdlInterface(Environment & io_rEnv,Xml::Element & o_rOut)90cdf0e10cSrcweir HF_IdlInterface::HF_IdlInterface( Environment &         io_rEnv,
91cdf0e10cSrcweir                                   Xml::Element &        o_rOut )
92cdf0e10cSrcweir     :   HtmlFactory_Idl(io_rEnv, &o_rOut),
93cdf0e10cSrcweir         eCurProducedMembers(mem_none)
94cdf0e10cSrcweir {
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
~HF_IdlInterface()97cdf0e10cSrcweir HF_IdlInterface::~HF_IdlInterface()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir void
Produce_byData(const client & i_ce) const102cdf0e10cSrcweir HF_IdlInterface::Produce_byData( const client & i_ce ) const
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     Dyn<HF_NaviSubRow>
105cdf0e10cSrcweir         pNaviSubRow( &make_Navibar(i_ce) );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     HF_TitleTable
108cdf0e10cSrcweir         aTitle(CurOut());
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     HF_LinkedNameChain
111cdf0e10cSrcweir         aNameChain(aTitle.Add_Row());
112cdf0e10cSrcweir     aNameChain.Produce_CompleteChain(Env().CurPosition(), nameChainLinker);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     produce_Title(aTitle, C_sCePrefix_Interface, i_ce);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     produce_BaseHierarchy( aTitle.Add_Row(),
117cdf0e10cSrcweir 						   i_ce,
118cdf0e10cSrcweir 						   C_sBaseInterface );
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     write_Docu(aTitle.Add_Row(), i_ce);
121cdf0e10cSrcweir     CurOut() << new Html::HorizontalLine();
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     dyn_ce_list dpFunctions;
124cdf0e10cSrcweir     ary::idl::ifc_interface::attr::Get_Functions(dpFunctions, i_ce);
125cdf0e10cSrcweir     if ( (*dpFunctions).operator bool() )
126cdf0e10cSrcweir     {
127cdf0e10cSrcweir         eCurProducedMembers = mem_Functions;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir         produce_Members( *dpFunctions,
130cdf0e10cSrcweir                          C_sList_Methods,
131cdf0e10cSrcweir                          C_sList_Methods_Label,
132cdf0e10cSrcweir                          C_sDetails_Methods,
133cdf0e10cSrcweir                          C_sDetails_Methods_Label,
134cdf0e10cSrcweir                          HtmlFactory_Idl::viewtype_summary );
135cdf0e10cSrcweir         pNaviSubRow->SwitchOn(sli_MethodsSummay);
136cdf0e10cSrcweir     }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     dyn_ce_list
139cdf0e10cSrcweir         dpAttributes;
140cdf0e10cSrcweir     ary::idl::ifc_interface::attr::Get_Attributes(dpAttributes, i_ce);
141cdf0e10cSrcweir     if ( (*dpAttributes).operator bool() )
142cdf0e10cSrcweir     {
143cdf0e10cSrcweir         eCurProducedMembers = mem_Attributes;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir         produce_Members( *dpAttributes,
146cdf0e10cSrcweir                          C_sList_Attributes,
147cdf0e10cSrcweir                          C_sList_Attributes_Label,
148cdf0e10cSrcweir                          C_sList_AttributesDetails,
149cdf0e10cSrcweir                          C_sList_AttributesDetails_Label,
150cdf0e10cSrcweir                          HtmlFactory_Idl::viewtype_summary );
151cdf0e10cSrcweir         pNaviSubRow->SwitchOn(sli_AttributesSummary);
152cdf0e10cSrcweir     }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     ary::idl::ifc_interface::attr::Get_Functions(dpFunctions, i_ce);
155cdf0e10cSrcweir     if ( (*dpFunctions).operator bool() )
156cdf0e10cSrcweir     {
157cdf0e10cSrcweir         eCurProducedMembers = mem_Functions;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir         produce_Members( *dpFunctions,
160cdf0e10cSrcweir                          C_sList_Methods,
161cdf0e10cSrcweir                          C_sList_Methods_Label,
162cdf0e10cSrcweir                          C_sDetails_Methods,
163cdf0e10cSrcweir                          C_sDetails_Methods_Label,
164cdf0e10cSrcweir                          HtmlFactory_Idl::viewtype_details );
165cdf0e10cSrcweir         pNaviSubRow->SwitchOn(sli_MethodDetails);
166cdf0e10cSrcweir     }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     ary::idl::ifc_interface::attr::Get_Attributes(dpAttributes, i_ce);
169cdf0e10cSrcweir     if ( (*dpAttributes).operator bool() )
170cdf0e10cSrcweir     {
171cdf0e10cSrcweir         eCurProducedMembers = mem_Attributes;
172cdf0e10cSrcweir 
173cdf0e10cSrcweir         produce_Members( *dpAttributes,
174cdf0e10cSrcweir                          C_sList_Attributes,
175cdf0e10cSrcweir                          C_sList_Attributes_Label,
176cdf0e10cSrcweir                          C_sList_AttributesDetails,
177cdf0e10cSrcweir                          C_sList_AttributesDetails_Label,
178cdf0e10cSrcweir                          HtmlFactory_Idl::viewtype_details );
179cdf0e10cSrcweir         pNaviSubRow->SwitchOn(sli_AttributesDetails);
180cdf0e10cSrcweir     }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     eCurProducedMembers = mem_none;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     pNaviSubRow->Produce_Row();
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir DYN HF_NaviSubRow &
make_Navibar(const client & i_ce) const188cdf0e10cSrcweir HF_IdlInterface::make_Navibar( const client & i_ce ) const
189cdf0e10cSrcweir {
190cdf0e10cSrcweir     HF_IdlNavigationBar
191cdf0e10cSrcweir         aNaviBar(Env(), CurOut());
192cdf0e10cSrcweir     aNaviBar.Produce_CeMainRow(i_ce);
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     DYN HF_NaviSubRow &
195cdf0e10cSrcweir         ret = aNaviBar.Add_SubRow();
196cdf0e10cSrcweir     ret.AddItem(C_sList_Methods, C_sList_Methods_Label, false);
197cdf0e10cSrcweir     ret.AddItem(C_sList_Attributes, C_sList_Attributes_Label, false);
198cdf0e10cSrcweir     ret.AddItem(C_sDetails_Methods, C_sDetails_Methods_Label, false);
199cdf0e10cSrcweir     ret.AddItem(C_sList_AttributesDetails, C_sList_AttributesDetails_Label, false);
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     CurOut() << new Html::HorizontalLine();
202cdf0e10cSrcweir     return ret;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir void
produce_MemberDetails(HF_SubTitleTable & o_table,const client & i_ce) const206cdf0e10cSrcweir HF_IdlInterface::produce_MemberDetails( HF_SubTitleTable &  o_table,
207cdf0e10cSrcweir                                         const client &      i_ce ) const
208cdf0e10cSrcweir {
209cdf0e10cSrcweir     switch (eCurProducedMembers)
210cdf0e10cSrcweir     {
211cdf0e10cSrcweir         case mem_Functions:
212cdf0e10cSrcweir                     break;
213cdf0e10cSrcweir         case mem_Attributes:
214cdf0e10cSrcweir         {
215cdf0e10cSrcweir                     HF_IdlAttribute
216cdf0e10cSrcweir                         aAttribute( Env(), o_table);
217cdf0e10cSrcweir                     aAttribute.Produce_byData( i_ce );
218cdf0e10cSrcweir                     return;
219cdf0e10cSrcweir         };
220cdf0e10cSrcweir         default:    //Won't happen.
221cdf0e10cSrcweir                     return;
222cdf0e10cSrcweir     }   // end switch
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     typedef ary::idl::ifc_function::attr    funcAttr;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     HF_IdlMethod
227cdf0e10cSrcweir         aFunction(  Env(),
228cdf0e10cSrcweir                     o_table.Add_Row()
229cdf0e10cSrcweir                         >> *new Html::TableCell
230cdf0e10cSrcweir                            << new Html::ClassAttr(C_sCellStyle_MDetail) );
231cdf0e10cSrcweir 
232cdf0e10cSrcweir     ary::Dyn_StdConstIterator<ary::idl::Parameter>
233cdf0e10cSrcweir         pParameters;
234cdf0e10cSrcweir     funcAttr::Get_Parameters(pParameters, i_ce);
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     ary::Dyn_StdConstIterator<ary::idl::Type_id>
237cdf0e10cSrcweir         pExceptions;
238cdf0e10cSrcweir     funcAttr::Get_Exceptions(pExceptions, i_ce);
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     aFunction.Produce_byData( i_ce.LocalName(),
241cdf0e10cSrcweir                               funcAttr::ReturnType(i_ce),
242cdf0e10cSrcweir                               *pParameters,
243cdf0e10cSrcweir                               *pExceptions,
244cdf0e10cSrcweir                               funcAttr::IsOneway(i_ce),
245cdf0e10cSrcweir                               funcAttr::HasEllipse(i_ce),
246cdf0e10cSrcweir                               i_ce );
247cdf0e10cSrcweir }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir void
produce_BaseHierarchy(Xml::Element & o_screen,const client & i_ce,const String & i_sLabel) const250cdf0e10cSrcweir HF_IdlInterface::produce_BaseHierarchy( Xml::Element &      o_screen,
251cdf0e10cSrcweir 										const client &      i_ce,
252cdf0e10cSrcweir 										const String &      i_sLabel ) const
253cdf0e10cSrcweir {
254cdf0e10cSrcweir     ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
255cdf0e10cSrcweir         pHelp;
256cdf0e10cSrcweir     ary::idl::ifc_interface::attr::Get_Bases(pHelp, i_ce);
257cdf0e10cSrcweir     if (NOT (*pHelp).operator bool())
258cdf0e10cSrcweir         return;
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     // Check for XInterface as only base:
261cdf0e10cSrcweir     ary::StdConstIterator<ary::idl::CommentedRelation> &
262cdf0e10cSrcweir         itTest = *pHelp;
263cdf0e10cSrcweir     ary::idl::Ce_id
264cdf0e10cSrcweir         nCe = Env().Gate().Types().Search_CeRelatedTo((*itTest).Type());
265cdf0e10cSrcweir     if (nCe.IsValid())
266cdf0e10cSrcweir     {
267cdf0e10cSrcweir         // KORR_FUTURE
268cdf0e10cSrcweir         //   Rather check for id(!) of com::sun::star::uno::XInterface.
269cdf0e10cSrcweir         if (Env().Gate().Ces().Find_Ce(nCe).LocalName() == "XInterface")
270cdf0e10cSrcweir         {
271cdf0e10cSrcweir             ++itTest;
272cdf0e10cSrcweir             if (NOT itTest.operator bool())
273cdf0e10cSrcweir                 return;
274cdf0e10cSrcweir         }
275cdf0e10cSrcweir     }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     // Write hierarchy:
278cdf0e10cSrcweir 
279cdf0e10cSrcweir     HF_DocEntryList
280cdf0e10cSrcweir         aDocList( o_screen );
281cdf0e10cSrcweir     aDocList.Produce_Term(i_sLabel);
282cdf0e10cSrcweir     Xml::Element &
283cdf0e10cSrcweir         rBaseList = aDocList.Produce_Definition();
284cdf0e10cSrcweir 
285cdf0e10cSrcweir // NEW
286cdf0e10cSrcweir     Write_BaseHierarchy(rBaseList, Env(), i_ce);
287cdf0e10cSrcweir 
288cdf0e10cSrcweir     // Write comments:
289cdf0e10cSrcweir         // KORR_FUTURE: Make sure, no empty table is constructed when comments list is empty.
290cdf0e10cSrcweir     HF_SubTitleTable
291cdf0e10cSrcweir         aBaseTable( aDocList.Produce_Definition(),
292cdf0e10cSrcweir                 "",
293cdf0e10cSrcweir                 C_sList_BaseComments,
294cdf0e10cSrcweir                 2,
295cdf0e10cSrcweir                 HF_SubTitleTable::sublevel_3 );
296cdf0e10cSrcweir 
297cdf0e10cSrcweir     ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
298cdf0e10cSrcweir         pBases;
299cdf0e10cSrcweir     ary::idl::ifc_interface::attr::Get_Bases(pBases, i_ce);
300cdf0e10cSrcweir     for ( ary::StdConstIterator<ary::idl::CommentedRelation> & it = *pBases;
301cdf0e10cSrcweir           it.operator bool();
302cdf0e10cSrcweir           ++it )
303cdf0e10cSrcweir     {
304cdf0e10cSrcweir         Xml::Element &
305cdf0e10cSrcweir             rRow = aBaseTable.Add_Row();
306cdf0e10cSrcweir 
307cdf0e10cSrcweir         Xml::Element &
308cdf0e10cSrcweir             rTerm = rRow
309cdf0e10cSrcweir                         >> *new Html::TableCell
310cdf0e10cSrcweir                             << new Html::ClassAttr(C_sCellStyle_SummaryLeft);
311cdf0e10cSrcweir         HF_IdlTypeText
312cdf0e10cSrcweir             aTypeDisplay( Env(), rTerm, false, 0);
313cdf0e10cSrcweir         aTypeDisplay.Produce_byData((*it).Type());
314cdf0e10cSrcweir 
315cdf0e10cSrcweir         Xml::Element &
316cdf0e10cSrcweir             rDocu = rRow
317cdf0e10cSrcweir                         >> *new Html::TableCell
318cdf0e10cSrcweir                             << new Html::ClassAttr(C_sCellStyle_SummaryRight);
319cdf0e10cSrcweir 
320cdf0e10cSrcweir         HF_DocEntryList
321cdf0e10cSrcweir             aDocuList(rDocu);
322cdf0e10cSrcweir 
323cdf0e10cSrcweir         if ((*it).Info() != 0)
324cdf0e10cSrcweir         {
325cdf0e10cSrcweir //          aDocuList.Produce_Term("Comment on Base Reference");
326cdf0e10cSrcweir 
327cdf0e10cSrcweir             HF_IdlDocu
328cdf0e10cSrcweir                 aDocuDisplay(Env(), aDocuList);
329cdf0e10cSrcweir             aDocuDisplay.Produce_fromReference(*(*it).Info(), i_ce);
330cdf0e10cSrcweir         }
331cdf0e10cSrcweir         else
332cdf0e10cSrcweir         {
333cdf0e10cSrcweir             const client *
334cdf0e10cSrcweir                 pCe = Env().Linker().Search_CeFromType((*it).Type());
335cdf0e10cSrcweir             const ce_info *
336cdf0e10cSrcweir                 pShort = pCe != 0
337cdf0e10cSrcweir                             ?   Get_IdlDocu(pCe->Docu())
338cdf0e10cSrcweir                             :   (const ce_info *)(0);
339cdf0e10cSrcweir             if ( pShort != 0 )
340cdf0e10cSrcweir             {
341cdf0e10cSrcweir                 aDocuList.Produce_NormalTerm("(referenced interface's summary:)");
342cdf0e10cSrcweir 
343cdf0e10cSrcweir                 Xml::Element &
344cdf0e10cSrcweir                     rDef = aDocuList.Produce_Definition();
345cdf0e10cSrcweir                 HF_IdlDocuTextDisplay
346cdf0e10cSrcweir                     aShortDisplay( Env(), &rDef, *pCe);
347cdf0e10cSrcweir                 pShort->Short().DisplayAt(aShortDisplay);
348cdf0e10cSrcweir             }   // end if (pShort != 0)
349cdf0e10cSrcweir         }   // endif ( (*i_commentedRef).Info() != 0 ) else
350cdf0e10cSrcweir     }   // end for
351cdf0e10cSrcweir }
352