LCOV - code coverage report
Current view: top level - sc/source/core/tool - addinhelpid.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 28 0.0 %
Date: 2014-04-14 Functions: 0 3 0.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 "addinhelpid.hxx"
      21             : #include "sc.hrc"
      22             : 
      23             : // A struct containing the built-in function name and the built-in help ID.
      24             : struct ScUnoAddInHelpId
      25             : {
      26             :     const sal_Char*             pFuncName;
      27             :     const sal_Char*             sHelpId;
      28             : };
      29             : 
      30             : // Help IDs for Analysis AddIn. MUST BE SORTED for binary search.
      31             : const ScUnoAddInHelpId pAnalysisHelpIds[] =
      32             : {
      33             :     { "getAccrint"                  , HID_AAI_FUNC_ACCRINT          },
      34             :     { "getAccrintm"                 , HID_AAI_FUNC_ACCRINTM         },
      35             :     { "getAmordegrc"                , HID_AAI_FUNC_AMORDEGRC        },
      36             :     { "getAmorlinc"                 , HID_AAI_FUNC_AMORLINC         },
      37             :     { "getBesseli"                  , HID_AAI_FUNC_BESSELI          },
      38             :     { "getBesselj"                  , HID_AAI_FUNC_BESSELJ          },
      39             :     { "getBesselk"                  , HID_AAI_FUNC_BESSELK          },
      40             :     { "getBessely"                  , HID_AAI_FUNC_BESSELY          },
      41             :     { "getBin2Dec"                  , HID_AAI_FUNC_BIN2DEC          },
      42             :     { "getBin2Hex"                  , HID_AAI_FUNC_BIN2HEX          },
      43             :     { "getBin2Oct"                  , HID_AAI_FUNC_BIN2OCT          },
      44             :     { "getComplex"                  , HID_AAI_FUNC_COMPLEX          },
      45             :     { "getConvert"                  , HID_AAI_FUNC_CONVERT          },
      46             :     { "getCoupdaybs"                , HID_AAI_FUNC_COUPDAYBS        },
      47             :     { "getCoupdays"                 , HID_AAI_FUNC_COUPDAYS         },
      48             :     { "getCoupdaysnc"               , HID_AAI_FUNC_COUPDAYSNC       },
      49             :     { "getCoupncd"                  , HID_AAI_FUNC_COUPNCD          },
      50             :     { "getCoupnum"                  , HID_AAI_FUNC_COUPNUM          },
      51             :     { "getCouppcd"                  , HID_AAI_FUNC_COUPPCD          },
      52             :     { "getCumipmt"                  , HID_AAI_FUNC_CUMIPMT          },
      53             :     { "getCumprinc"                 , HID_AAI_FUNC_CUMPRINC         },
      54             :     { "getDec2Bin"                  , HID_AAI_FUNC_DEC2BIN          },
      55             :     { "getDec2Hex"                  , HID_AAI_FUNC_DEC2HEX          },
      56             :     { "getDec2Oct"                  , HID_AAI_FUNC_DEC2OCT          },
      57             :     { "getDelta"                    , HID_AAI_FUNC_DELTA            },
      58             :     { "getDisc"                     , HID_AAI_FUNC_DISC             },
      59             :     { "getDollarde"                 , HID_AAI_FUNC_DOLLARDE         },
      60             :     { "getDollarfr"                 , HID_AAI_FUNC_DOLLARFR         },
      61             :     { "getDuration"                 , HID_AAI_FUNC_DURATION         },
      62             :     { "getEdate"                    , HID_AAI_FUNC_EDATE            },
      63             :     { "getEffect"                   , HID_AAI_FUNC_EFFECT           },
      64             :     { "getEomonth"                  , HID_AAI_FUNC_EOMONTH          },
      65             :     { "getErf"                      , HID_AAI_FUNC_ERF              },
      66             :     { "getErfc"                     , HID_AAI_FUNC_ERFC             },
      67             :     { "getFactdouble"               , HID_AAI_FUNC_FACTDOUBLE       },
      68             :     { "getFvschedule"               , HID_AAI_FUNC_FVSCHEDULE       },
      69             :     { "getGcd"                      , HID_AAI_FUNC_GCD              },
      70             :     { "getGestep"                   , HID_AAI_FUNC_GESTEP           },
      71             :     { "getHex2Bin"                  , HID_AAI_FUNC_HEX2BIN          },
      72             :     { "getHex2Dec"                  , HID_AAI_FUNC_HEX2DEC          },
      73             :     { "getHex2Oct"                  , HID_AAI_FUNC_HEX2OCT          },
      74             :     { "getImabs"                    , HID_AAI_FUNC_IMABS            },
      75             :     { "getImaginary"                , HID_AAI_FUNC_IMAGINARY        },
      76             :     { "getImargument"               , HID_AAI_FUNC_IMARGUMENT       },
      77             :     { "getImconjugate"              , HID_AAI_FUNC_IMCONJUGATE      },
      78             :     { "getImcos"                    , HID_AAI_FUNC_IMCOS            },
      79             :     { "getImcosh"                   , HID_AAI_FUNC_IMCOSH           },
      80             :     { "getImcot"                    , HID_AAI_FUNC_IMCOT            },
      81             :     { "getImcsc"                    , HID_AAI_FUNC_IMCSC            },
      82             :     { "getImcsch"                   , HID_AAI_FUNC_IMCSCH           },
      83             :     { "getImdiv"                    , HID_AAI_FUNC_IMDIV            },
      84             :     { "getImexp"                    , HID_AAI_FUNC_IMEXP            },
      85             :     { "getImln"                     , HID_AAI_FUNC_IMLN             },
      86             :     { "getImlog10"                  , HID_AAI_FUNC_IMLOG10          },
      87             :     { "getImlog2"                   , HID_AAI_FUNC_IMLOG2           },
      88             :     { "getImpower"                  , HID_AAI_FUNC_IMPOWER          },
      89             :     { "getImproduct"                , HID_AAI_FUNC_IMPRODUCT        },
      90             :     { "getImreal"                   , HID_AAI_FUNC_IMREAL           },
      91             :     { "getImsec"                    , HID_AAI_FUNC_IMSEC            },
      92             :     { "getImsech"                   , HID_AAI_FUNC_IMSECH           },
      93             :     { "getImsin"                    , HID_AAI_FUNC_IMSIN            },
      94             :     { "getImsinh"                   , HID_AAI_FUNC_IMSINH           },
      95             :     { "getImsqrt"                   , HID_AAI_FUNC_IMSQRT           },
      96             :     { "getImsub"                    , HID_AAI_FUNC_IMSUB            },
      97             :     { "getImsum"                    , HID_AAI_FUNC_IMSUM            },
      98             :     { "getImtan"                    , HID_AAI_FUNC_IMTAN            },
      99             :     { "getIntrate"                  , HID_AAI_FUNC_INTRATE          },
     100             :     { "getIseven"                   , HID_AAI_FUNC_ISEVEN           },
     101             :     { "getIsodd"                    , HID_AAI_FUNC_ISODD            },
     102             :     { "getLcm"                      , HID_AAI_FUNC_LCM              },
     103             :     { "getMduration"                , HID_AAI_FUNC_MDURATION        },
     104             :     { "getMround"                   , HID_AAI_FUNC_MROUND           },
     105             :     { "getMultinomial"              , HID_AAI_FUNC_MULTINOMIAL      },
     106             :     { "getNetworkdays"              , HID_AAI_FUNC_NETWORKDAYS      },
     107             :     { "getNominal"                  , HID_AAI_FUNC_NOMINAL          },
     108             :     { "getOct2Bin"                  , HID_AAI_FUNC_OCT2BIN          },
     109             :     { "getOct2Dec"                  , HID_AAI_FUNC_OCT2DEZ          },
     110             :     { "getOct2Hex"                  , HID_AAI_FUNC_OCT2HEX          },
     111             :     { "getOddfprice"                , HID_AAI_FUNC_ODDFPRICE        },
     112             :     { "getOddfyield"                , HID_AAI_FUNC_ODDFYIELD        },
     113             :     { "getOddlprice"                , HID_AAI_FUNC_ODDLPRICE        },
     114             :     { "getOddlyield"                , HID_AAI_FUNC_ODDLYIELD        },
     115             :     { "getPrice"                    , HID_AAI_FUNC_PRICE            },
     116             :     { "getPricedisc"                , HID_AAI_FUNC_PRICEDISC        },
     117             :     { "getPricemat"                 , HID_AAI_FUNC_PRICEMAT         },
     118             :     { "getQuotient"                 , HID_AAI_FUNC_QUOTIENT         },
     119             :     { "getRandbetween"              , HID_AAI_FUNC_RANDBETWEEN      },
     120             :     { "getReceived"                 , HID_AAI_FUNC_RECEIVED         },
     121             :     { "getSeriessum"                , HID_AAI_FUNC_SERIESSUM        },
     122             :     { "getSqrtpi"                   , HID_AAI_FUNC_SQRTPI           },
     123             :     { "getTbilleq"                  , HID_AAI_FUNC_TBILLEQ          },
     124             :     { "getTbillprice"               , HID_AAI_FUNC_TBILLPRICE       },
     125             :     { "getTbillyield"               , HID_AAI_FUNC_TBILLYIELD       },
     126             :     { "getWeeknum"                  , HID_AAI_FUNC_WEEKNUM          },
     127             :     { "getWorkday"                  , HID_AAI_FUNC_WORKDAY          },
     128             :     { "getXirr"                     , HID_AAI_FUNC_XIRR             },
     129             :     { "getXnpv"                     , HID_AAI_FUNC_XNPV             },
     130             :     { "getYearfrac"                 , HID_AAI_FUNC_YEARFRAC         },
     131             :     { "getYield"                    , HID_AAI_FUNC_YIELD            },
     132             :     { "getYielddisc"                , HID_AAI_FUNC_YIELDDISC        },
     133             :     { "getYieldmat"                 , HID_AAI_FUNC_YIELDMAT         }
     134             : };
     135             : 
     136             : // Help IDs for DateFunc AddIn. MUST BE SORTED for binary search.
     137             : const ScUnoAddInHelpId pDateFuncHelpIds[] =
     138             : {
     139             :     { "getDaysInMonth"              , HID_DAI_FUNC_DAYSINMONTH      },
     140             :     { "getDaysInYear"               , HID_DAI_FUNC_DAYSINYEAR       },
     141             :     { "getDiffMonths"               , HID_DAI_FUNC_DIFFMONTHS       },
     142             :     { "getDiffWeeks"                , HID_DAI_FUNC_DIFFWEEKS        },
     143             :     { "getDiffYears"                , HID_DAI_FUNC_DIFFYEARS        },
     144             :     { "getRot13"                    , HID_DAI_FUNC_ROT13            },
     145             :     { "getWeeksInYear"              , HID_DAI_FUNC_WEEKSINYEAR      }
     146             : };
     147             : 
     148           0 : ScUnoAddInHelpIdGenerator::ScUnoAddInHelpIdGenerator( const OUString& rServiceName )
     149             : {
     150           0 :     SetServiceName( rServiceName );
     151           0 : }
     152             : 
     153           0 : void ScUnoAddInHelpIdGenerator::SetServiceName( const OUString& rServiceName )
     154             : {
     155           0 :     pCurrHelpIds = NULL;
     156           0 :     sal_uInt32 nSize = 0;
     157             : 
     158           0 :     if ( rServiceName == "com.sun.star.sheet.addin.Analysis" )
     159             :     {
     160           0 :         pCurrHelpIds = pAnalysisHelpIds;
     161           0 :         nSize = sizeof( pAnalysisHelpIds );
     162             :     }
     163           0 :     else if ( rServiceName == "com.sun.star.sheet.addin.DateFunctions" )
     164             :     {
     165           0 :         pCurrHelpIds = pDateFuncHelpIds;
     166           0 :         nSize = sizeof( pDateFuncHelpIds );
     167             :     }
     168             : 
     169           0 :     nArrayCount = nSize / sizeof( ScUnoAddInHelpId );
     170           0 : }
     171             : 
     172           0 : OString ScUnoAddInHelpIdGenerator::GetHelpId( const OUString& rFuncName ) const
     173             : {
     174           0 :     if( !pCurrHelpIds || !nArrayCount )
     175           0 :         return OString();
     176             : 
     177           0 :     const ScUnoAddInHelpId* pFirst = pCurrHelpIds;
     178           0 :     const ScUnoAddInHelpId* pLast = pCurrHelpIds + nArrayCount - 1;
     179             : 
     180           0 :     while( pFirst <= pLast )
     181             :     {
     182           0 :         const ScUnoAddInHelpId* pMiddle = pFirst + (pLast - pFirst) / 2;
     183           0 :         sal_Int32 nResult = rFuncName.compareToAscii( pMiddle->pFuncName );
     184           0 :         if( !nResult )
     185           0 :             return pMiddle->sHelpId;
     186           0 :         else if( nResult < 0 )
     187           0 :             pLast = pMiddle - 1;
     188             :         else
     189           0 :             pFirst = pMiddle + 1;
     190             :     }
     191             : 
     192           0 :     return OString();
     193             : }
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10