merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / display / idl / hfi_method.cxx
blob4b2b4aaf3f55054ef76fbd2511d4a025d9ac5d71
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hfi_method.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <precomp.h>
32 #include "hfi_method.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/idl/i_exception.hxx>
37 #include <ary/idl/i_param.hxx>
38 #include <toolkit/hf_docentry.hxx>
39 #include <toolkit/hf_funcdecl.hxx>
40 #include "hfi_doc.hxx"
41 #include "hfi_globalindex.hxx"
42 #include "hfi_typetext.hxx"
48 HF_IdlMethod::HF_IdlMethod( Environment & io_rEnv,
49 Xml::Element & o_cell)
50 : HtmlFactory_Idl(io_rEnv,&o_cell)
55 HF_IdlMethod::~HF_IdlMethod()
60 void
61 HF_IdlMethod::Produce_byData( const String & i_sName,
62 type_id i_nReturnType,
63 param_list & i_rParams,
64 type_list & i_rExceptions,
65 bool i_bOneway,
66 bool i_bEllipse,
67 const client & i_ce ) const
69 CurOut()
70 >> *new Html::Label(i_sName)
71 << new Html::ClassAttr(C_sMemberTitle)
72 << i_sName;
73 enter_ContentCell();
74 write_Declaration( i_sName,
75 i_nReturnType,
76 i_rParams,
77 i_rExceptions,
78 i_bOneway,
79 i_bEllipse );
80 CurOut() << new Html::HorizontalLine;
81 write_Docu(CurOut(), i_ce);
82 leave_ContentCell();
85 #if 0 // old
86 void
87 HF_IdlMethod::write_Declaration( const String & i_sName,
88 type_id i_nReturnType,
89 param_list & i_rParams,
90 type_list & i_rExceptions,
91 bool i_bOneway,
92 bool i_bEllipse ) const
94 HF_FunctionDeclaration
95 aDecl(CurOut()) ;
96 Xml::Element &
97 front = aDecl.Add_ReturnLine();
99 // Front:
100 if (i_bOneway)
101 front << "[oneway] ";
102 if (i_nReturnType.IsValid())
103 { // Normal function, but not constructors:
104 HF_IdlTypeText
105 aReturn(Env(), front, true);
106 aReturn.Produce_byData(i_nReturnType);
107 front
108 << new Html::LineBreak;
111 front
112 >> *new Html::Bold
113 << i_sName;
115 // Main line:
116 Xml::Element &
117 types = aDecl.Types();
118 Xml::Element &
119 names = aDecl.Names();
120 bool bParams = i_rParams.operator bool();
121 if (bParams)
123 front
124 << "(";
125 HF_IdlTypeText
126 aType( Env(), types, true );
128 write_Param( aType, names, (*i_rParams) );
130 for (++i_rParams; i_rParams; ++i_rParams)
132 types
133 << new Html::LineBreak;
134 names
135 << ","
136 << new Html::LineBreak;
137 write_Param( aType, names, (*i_rParams) );
138 } // end for
140 if (i_bEllipse)
142 names
143 << " ...";
145 names
146 << " )";
148 else
149 front
150 << "()";
153 if ( i_rExceptions.operator bool() )
155 Xml::Element &
156 rExcOut = aDecl.Add_RaisesLine("raises", NOT bParams);
157 HF_IdlTypeText
158 aExc(Env(), rExcOut, true);
159 aExc.Produce_byData(*i_rExceptions);
161 for (++i_rExceptions; i_rExceptions; ++i_rExceptions)
163 rExcOut
164 << ","
165 << new Html::LineBreak;
166 aExc.Produce_byData(*i_rExceptions);
167 } // end for
169 rExcOut << " );";
171 else
173 if (bParams)
174 aDecl.Names() << ";";
175 else
176 aDecl.Front() << ";";
179 #endif // 0 old
181 void
182 HF_IdlMethod::write_Declaration( const String & i_sName,
183 type_id i_nReturnType,
184 param_list & i_rParams,
185 type_list & i_rExceptions,
186 bool i_bOneway,
187 bool i_bEllipse ) const
189 HF_FunctionDeclaration
190 aDecl(CurOut(), "raises") ;
191 Xml::Element &
192 rReturnLine = aDecl.ReturnCell();
194 // Return line:
195 if (i_bOneway)
196 rReturnLine << "[oneway] ";
197 if (i_nReturnType.IsValid())
198 { // Normal function, but not constructors:
199 HF_IdlTypeText
200 aReturn(Env(), rReturnLine, true);
201 aReturn.Produce_byData(i_nReturnType);
204 // Main line:
205 Xml::Element &
206 rNameCell = aDecl.NameCell();
207 rNameCell
208 >> *new Html::Bold
209 << i_sName;
211 Xml::Element *
212 pParamEnd = 0;
214 bool bParams = i_rParams.operator bool();
215 if (bParams)
217 rNameCell
218 << "(";
220 pParamEnd = write_Param( aDecl, *i_rParams );
221 for (++i_rParams; i_rParams; ++i_rParams)
223 *pParamEnd << ",";
224 pParamEnd = write_Param( aDecl, *i_rParams );
225 } // end for
227 if (i_bEllipse)
229 Xml::Element &
230 rParamType = aDecl.NewParamTypeCell();
231 rParamType
232 << " ...";
233 pParamEnd = &rParamType;
235 *pParamEnd
236 << " )";
238 else
240 rNameCell
241 << "()";
244 if ( i_rExceptions.operator bool() )
246 Xml::Element &
247 rExcOut = aDecl.ExceptionCell();
248 HF_IdlTypeText
249 aExc(Env(), rExcOut, true);
250 aExc.Produce_byData(*i_rExceptions);
252 for (++i_rExceptions; i_rExceptions; ++i_rExceptions)
254 rExcOut
255 << ","
256 << new Html::LineBreak;
257 aExc.Produce_byData(*i_rExceptions);
258 } // end for
260 rExcOut << " );";
262 else if (bParams)
264 *pParamEnd << ";";
266 else
268 rNameCell << ";";
272 #if 0 // old
273 void
274 HF_IdlMethod::write_Param( HF_IdlTypeText & o_type,
275 Xml::Element & o_names,
276 const ary::idl::Parameter & i_param ) const
278 switch ( i_param.Direction() )
280 case ary::idl::param_in:
281 o_type.CurOut() << "[in] ";
282 break;
283 case ary::idl::param_out:
284 o_type.CurOut() << "[out] ";
285 break;
286 case ary::idl::param_inout:
287 o_type.CurOut() << "[inout] ";
288 break;
289 } // end switch
291 o_type.Produce_byData( i_param.Type() );
292 o_names
293 << i_param.Name();
295 #endif // 0 old
297 Xml::Element *
298 HF_IdlMethod::write_Param( HF_FunctionDeclaration & o_decl,
299 const ary::idl::Parameter & i_param ) const
301 Xml::Element &
302 rTypeCell = o_decl.NewParamTypeCell();
303 Xml::Element &
304 rNameCell = o_decl.ParamNameCell();
306 switch ( i_param.Direction() )
308 case ary::idl::param_in:
309 rTypeCell << "[in] ";
310 break;
311 case ary::idl::param_out:
312 rTypeCell << "[out] ";
313 break;
314 case ary::idl::param_inout:
315 rTypeCell << "[inout] ";
316 break;
317 } // end switch
319 HF_IdlTypeText
320 aTypeWriter(Env(), rTypeCell, true);
321 aTypeWriter.Produce_byData( i_param.Type() );
323 rNameCell
324 << i_param.Name();
325 return &rNameCell;
328 const String sContentBorder("0");
329 const String sContentWidth("96%");
330 const String sContentPadding("5");
331 const String sContentSpacing("0");
333 const String sBgWhite("#ffffff");
334 const String sCenter("center");
336 void
337 HF_IdlMethod::enter_ContentCell() const
340 Xml::Element &
341 rContentCell = CurOut()
342 >> *new Html::Table( sContentBorder,
343 sContentWidth,
344 sContentPadding,
345 sContentSpacing )
346 << new Html::ClassAttr("table-in-method")
347 << new Html::BgColorAttr(sBgWhite)
348 << new Html::AlignAttr(sCenter)
349 >> *new Html::TableRow
350 >> *new Html::TableCell;
351 Out().Enter(rContentCell);
355 void
356 HF_IdlMethod::leave_ContentCell() const
358 Out().Leave();