Bump for 3.6-28
[LibreOffice.git] / autodoc / source / display / idl / hfi_method.cxx
blobb5d1aa9d3d8c33e7550330f4163c58b8be101466
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <precomp.h>
30 #include "hfi_method.hxx"
33 // NOT FULLY DEFINED SERVICES
34 #include <ary/idl/i_exception.hxx>
35 #include <ary/idl/i_param.hxx>
36 #include <toolkit/hf_docentry.hxx>
37 #include <toolkit/hf_funcdecl.hxx>
38 #include "hfi_doc.hxx"
39 #include "hfi_globalindex.hxx"
40 #include "hfi_typetext.hxx"
46 HF_IdlMethod::HF_IdlMethod( Environment & io_rEnv,
47 Xml::Element & o_cell)
48 : HtmlFactory_Idl(io_rEnv,&o_cell)
53 HF_IdlMethod::~HF_IdlMethod()
58 void
59 HF_IdlMethod::Produce_byData( const String & i_sName,
60 type_id i_nReturnType,
61 param_list & i_rParams,
62 type_list & i_rExceptions,
63 bool i_bOneway,
64 bool i_bEllipse,
65 const client & i_ce ) const
67 CurOut()
68 >> *new Html::Label(i_sName)
69 << new Html::ClassAttr(C_sMemberTitle)
70 << i_sName;
71 enter_ContentCell();
72 write_Declaration( i_sName,
73 i_nReturnType,
74 i_rParams,
75 i_rExceptions,
76 i_bOneway,
77 i_bEllipse );
78 CurOut() << new Html::HorizontalLine;
79 write_Docu(CurOut(), i_ce);
80 leave_ContentCell();
83 void
84 HF_IdlMethod::write_Declaration( const String & i_sName,
85 type_id i_nReturnType,
86 param_list & i_rParams,
87 type_list & i_rExceptions,
88 bool i_bOneway,
89 bool i_bEllipse ) const
91 HF_FunctionDeclaration
92 aDecl(CurOut(), "raises") ;
93 Xml::Element &
94 rReturnLine = aDecl.ReturnCell();
96 // Return line:
97 if (i_bOneway)
98 rReturnLine << "[oneway] ";
99 if (i_nReturnType.IsValid())
100 { // Normal function, but not constructors:
101 HF_IdlTypeText
102 aReturn(Env(), rReturnLine, true);
103 aReturn.Produce_byData(i_nReturnType);
106 // Main line:
107 Xml::Element &
108 rNameCell = aDecl.NameCell();
109 rNameCell
110 >> *new Html::Bold
111 << i_sName;
113 Xml::Element *
114 pParamEnd = 0;
116 bool bParams = i_rParams.operator bool();
117 if (bParams)
119 rNameCell
120 << "(";
122 pParamEnd = write_Param( aDecl, *i_rParams );
123 for (++i_rParams; i_rParams; ++i_rParams)
125 *pParamEnd << ",";
126 pParamEnd = write_Param( aDecl, *i_rParams );
127 } // end for
129 if (i_bEllipse)
131 Xml::Element &
132 rParamType = aDecl.NewParamTypeCell();
133 rParamType
134 << " ...";
135 pParamEnd = &rParamType;
137 *pParamEnd
138 << " )";
140 else
142 rNameCell
143 << "()";
146 if ( i_rExceptions.operator bool() )
148 Xml::Element &
149 rExcOut = aDecl.ExceptionCell();
150 HF_IdlTypeText
151 aExc(Env(), rExcOut, true);
152 aExc.Produce_byData(*i_rExceptions);
154 for (++i_rExceptions; i_rExceptions; ++i_rExceptions)
156 rExcOut
157 << ","
158 << new Html::LineBreak;
159 aExc.Produce_byData(*i_rExceptions);
160 } // end for
162 rExcOut << " );";
164 else if (bParams)
166 *pParamEnd << ";";
168 else
170 rNameCell << ";";
174 Xml::Element *
175 HF_IdlMethod::write_Param( HF_FunctionDeclaration & o_decl,
176 const ary::idl::Parameter & i_param ) const
178 Xml::Element &
179 rTypeCell = o_decl.NewParamTypeCell();
180 Xml::Element &
181 rNameCell = o_decl.ParamNameCell();
183 switch ( i_param.Direction() )
185 case ary::idl::param_in:
186 rTypeCell << "[in] ";
187 break;
188 case ary::idl::param_out:
189 rTypeCell << "[out] ";
190 break;
191 case ary::idl::param_inout:
192 rTypeCell << "[inout] ";
193 break;
194 } // end switch
196 HF_IdlTypeText
197 aTypeWriter(Env(), rTypeCell, true);
198 aTypeWriter.Produce_byData( i_param.Type() );
200 rNameCell
201 << i_param.Name();
202 return &rNameCell;
205 const String sContentBorder("0");
206 const String sContentWidth("96%");
207 const String sContentPadding("5");
208 const String sContentSpacing("0");
210 const String sBgWhite("#ffffff");
211 const String sCenter("center");
213 void
214 HF_IdlMethod::enter_ContentCell() const
217 Xml::Element &
218 rContentCell = CurOut()
219 >> *new Html::Table( sContentBorder,
220 sContentWidth,
221 sContentPadding,
222 sContentSpacing )
223 << new Html::ClassAttr("table-in-method")
224 << new Html::BgColorAttr(sBgWhite)
225 << new Html::AlignAttr(sCenter)
226 >> *new Html::TableRow
227 >> *new Html::TableCell;
228 Out().Enter(rContentCell);
232 void
233 HF_IdlMethod::leave_ContentCell() const
235 Out().Leave();
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */