LCOV - code coverage report
Current view: top level - libreoffice/autodoc/source/display/idl - hfi_method.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 84 88 95.5 %
Date: 2012-12-27 Functions: 9 10 90.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <precomp.h>
      21             : #include "hfi_method.hxx"
      22             : 
      23             : 
      24             : // NOT FULLY DEFINED SERVICES
      25             : #include <ary/idl/i_exception.hxx>
      26             : #include <ary/idl/i_param.hxx>
      27             : #include <toolkit/hf_docentry.hxx>
      28             : #include <toolkit/hf_funcdecl.hxx>
      29             : #include "hfi_doc.hxx"
      30             : #include "hfi_globalindex.hxx"
      31             : #include "hfi_typetext.hxx"
      32             : 
      33             : 
      34             : 
      35             : 
      36             : 
      37        5595 : HF_IdlMethod::HF_IdlMethod( Environment &           io_rEnv,
      38             :                             Xml::Element &          o_cell)
      39        5595 :     :   HtmlFactory_Idl(io_rEnv,&o_cell)
      40             : {
      41        5595 : }
      42             : 
      43             : 
      44        5595 : HF_IdlMethod::~HF_IdlMethod()
      45             : {
      46        5595 : }
      47             : 
      48             : 
      49             : void
      50        5595 : HF_IdlMethod::Produce_byData( const String &      i_sName,
      51             :                               type_id             i_nReturnType,
      52             :                               param_list &        i_rParams,
      53             :                               type_list &         i_rExceptions,
      54             :                               bool                i_bOneway,
      55             :                               bool                i_bEllipse,
      56             :                               const client &      i_ce ) const
      57             : {
      58        5595 :     CurOut()
      59       11190 :         >> *new Html::Label(i_sName)
      60       11190 :             << new Html::ClassAttr(C_sMemberTitle)
      61        5595 :             << i_sName;
      62        5595 :     enter_ContentCell();
      63             :     write_Declaration( i_sName,
      64             :                        i_nReturnType,
      65             :                        i_rParams,
      66             :                        i_rExceptions,
      67             :                        i_bOneway,
      68        5595 :                        i_bEllipse );
      69        5595 :     CurOut() << new Html::HorizontalLine;
      70        5595 :     write_Docu(CurOut(), i_ce);
      71        5595 :     leave_ContentCell();
      72        5595 : }
      73             : 
      74             : void
      75        5595 : HF_IdlMethod::write_Declaration( const String &      i_sName,
      76             :                                  type_id             i_nReturnType,
      77             :                                  param_list &        i_rParams,
      78             :                                  type_list &         i_rExceptions,
      79             :                                  bool                i_bOneway,
      80             :                                  bool                i_bEllipse ) const
      81             : {
      82             :     HF_FunctionDeclaration
      83        5595 :         aDecl(CurOut(), "raises") ;
      84             :     Xml::Element &
      85        5595 :         rReturnLine = aDecl.ReturnCell();
      86             : 
      87             :     // Return line:
      88        5595 :     if (i_bOneway)
      89           0 :         rReturnLine << "[oneway] ";
      90        5595 :     if (i_nReturnType.IsValid())
      91             :     {   // Normal function, but not constructors:
      92             :         HF_IdlTypeText
      93        5502 :             aReturn(Env(), rReturnLine);
      94        5502 :         aReturn.Produce_byData(i_nReturnType);
      95             :     }
      96             : 
      97             :     //  Main line:
      98             :     Xml::Element &
      99        5595 :         rNameCell = aDecl.NameCell();
     100             :     rNameCell
     101        5595 :         >> *new Html::Bold
     102        5595 :             << i_sName;
     103             : 
     104             :     Xml::Element *
     105        5595 :         pParamEnd  = 0;
     106             : 
     107        5595 :     bool bParams = i_rParams.operator bool();
     108        5595 :     if (bParams)
     109             :     {
     110             :         rNameCell
     111        3540 :             << "(";
     112             : 
     113        3540 :         pParamEnd  = write_Param( aDecl, *i_rParams );
     114        5658 :         for (++i_rParams; i_rParams; ++i_rParams)
     115             :         {
     116        2118 :             *pParamEnd << ",";
     117        2118 :             pParamEnd  = write_Param( aDecl, *i_rParams );
     118             :         }   // end for
     119             : 
     120        3540 :         if (i_bEllipse)
     121             :         {
     122             :             Xml::Element &
     123           0 :                 rParamType = aDecl.NewParamTypeCell();
     124             :             rParamType
     125           0 :                 << " ...";
     126           0 :             pParamEnd = &rParamType;
     127             :         }
     128             :         *pParamEnd
     129        3540 :             << " )";
     130             :     }
     131             :     else
     132             :     {
     133             :         rNameCell
     134        2055 :             << "()";
     135             :     }
     136             : 
     137        5595 :     if ( i_rExceptions.operator bool() )
     138             :     {
     139             :         Xml::Element &
     140        1848 :             rExcOut = aDecl.ExceptionCell();
     141             :         HF_IdlTypeText
     142        1848 :             aExc(Env(), rExcOut);
     143        1848 :         aExc.Produce_byData(*i_rExceptions);
     144             : 
     145        2673 :         for (++i_rExceptions; i_rExceptions; ++i_rExceptions)
     146             :         {
     147             :             rExcOut
     148         825 :                 << ","
     149        1650 :                 << new Html::LineBreak;
     150         825 :             aExc.Produce_byData(*i_rExceptions);
     151             :         }   // end for
     152             : 
     153        1848 :         rExcOut << " );";
     154             :     }
     155        3747 :     else if (bParams)
     156             :     {
     157        2087 :         *pParamEnd << ";";
     158             :     }
     159             :     else
     160             :     {
     161        1660 :         rNameCell << ";";
     162        5595 :     }
     163        5595 : }
     164             : 
     165             : Xml::Element *
     166        5658 : HF_IdlMethod::write_Param( HF_FunctionDeclaration &     o_decl,
     167             :                            const ary::idl::Parameter &  i_param ) const
     168             : {
     169             :     Xml::Element &
     170        5658 :         rTypeCell  = o_decl.NewParamTypeCell();
     171             :     Xml::Element &
     172        5658 :         rNameCell  = o_decl.ParamNameCell();
     173             : 
     174        5658 :     switch ( i_param.Direction() )
     175             :     {
     176             :         case ary::idl::param_in:
     177        5581 :                     rTypeCell << "[in] ";
     178        5581 :                     break;
     179             :         case ary::idl::param_out:
     180          59 :                     rTypeCell << "[out] ";
     181          59 :                     break;
     182             :         case ary::idl::param_inout:
     183          18 :                     rTypeCell << "[inout] ";
     184          18 :                     break;
     185             :     }   // end switch
     186             : 
     187             :     HF_IdlTypeText
     188        5658 :         aTypeWriter(Env(), rTypeCell);
     189        5658 :     aTypeWriter.Produce_byData( i_param.Type() );
     190             : 
     191             :     rNameCell
     192        5658 :         << i_param.Name();
     193        5658 :     return &rNameCell;
     194             : }
     195             : 
     196           1 : const String sContentBorder("0");
     197           1 : const String sContentWidth("96%");
     198           1 : const String sContentPadding("5");
     199           1 : const String sContentSpacing("0");
     200             : 
     201           1 : const String sBgWhite("#ffffff");
     202           1 : const String sCenter("center");
     203             : 
     204             : void
     205        5595 : HF_IdlMethod::enter_ContentCell() const
     206             : {
     207             : 
     208             :     Xml::Element &
     209        5595 :         rContentCell = CurOut()
     210             :                         >> *new Html::Table( sContentBorder,
     211             :                                              sContentWidth,
     212             :                                              sContentPadding,
     213       11190 :                                              sContentSpacing )
     214       16785 :                             << new Html::ClassAttr("table-in-method")
     215       11190 :                             << new Html::BgColorAttr(sBgWhite)
     216       11190 :                             << new Html::AlignAttr(sCenter)
     217       11190 :                             >> *new Html::TableRow
     218       11190 :                                 >> *new Html::TableCell;
     219        5595 :     Out().Enter(rContentCell);
     220        5595 : }
     221             : 
     222             : 
     223             : void
     224        5595 : HF_IdlMethod::leave_ContentCell() const
     225             : {
     226        5595 :     Out().Leave();
     227        5598 : }
     228             : 
     229             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10