1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 #include "addinhelpid.hxx" 32 #include "sc.hrc" 33 34 // ============================================================================ 35 36 // A struct containing the built-in function name and the built-in help ID. 37 struct ScUnoAddInHelpId 38 { 39 const sal_Char* pFuncName; 40 const sal_Char* sHelpId; 41 }; 42 43 44 // ---------------------------------------------------------------------------- 45 46 // Help IDs for Analysis AddIn. MUST BE SORTED for binary search. 47 const ScUnoAddInHelpId pAnalysisHelpIds[] = 48 { 49 { "getAccrint" , HID_AAI_FUNC_ACCRINT }, 50 { "getAccrintm" , HID_AAI_FUNC_ACCRINTM }, 51 { "getAmordegrc" , HID_AAI_FUNC_AMORDEGRC }, 52 { "getAmorlinc" , HID_AAI_FUNC_AMORLINC }, 53 { "getBesseli" , HID_AAI_FUNC_BESSELI }, 54 { "getBesselj" , HID_AAI_FUNC_BESSELJ }, 55 { "getBesselk" , HID_AAI_FUNC_BESSELK }, 56 { "getBessely" , HID_AAI_FUNC_BESSELY }, 57 { "getBin2Dec" , HID_AAI_FUNC_BIN2DEC }, 58 { "getBin2Hex" , HID_AAI_FUNC_BIN2HEX }, 59 { "getBin2Oct" , HID_AAI_FUNC_BIN2OCT }, 60 { "getComplex" , HID_AAI_FUNC_COMPLEX }, 61 { "getConvert" , HID_AAI_FUNC_CONVERT }, 62 { "getCoupdaybs" , HID_AAI_FUNC_COUPDAYBS }, 63 { "getCoupdays" , HID_AAI_FUNC_COUPDAYS }, 64 { "getCoupdaysnc" , HID_AAI_FUNC_COUPDAYSNC }, 65 { "getCoupncd" , HID_AAI_FUNC_COUPNCD }, 66 { "getCoupnum" , HID_AAI_FUNC_COUPNUM }, 67 { "getCouppcd" , HID_AAI_FUNC_COUPPCD }, 68 { "getCumipmt" , HID_AAI_FUNC_CUMIPMT }, 69 { "getCumprinc" , HID_AAI_FUNC_CUMPRINC }, 70 { "getDec2Bin" , HID_AAI_FUNC_DEC2BIN }, 71 { "getDec2Hex" , HID_AAI_FUNC_DEC2HEX }, 72 { "getDec2Oct" , HID_AAI_FUNC_DEC2OCT }, 73 { "getDelta" , HID_AAI_FUNC_DELTA }, 74 { "getDisc" , HID_AAI_FUNC_DISC }, 75 { "getDollarde" , HID_AAI_FUNC_DOLLARDE }, 76 { "getDollarfr" , HID_AAI_FUNC_DOLLARFR }, 77 { "getDuration" , HID_AAI_FUNC_DURATION }, 78 { "getEdate" , HID_AAI_FUNC_EDATE }, 79 { "getEffect" , HID_AAI_FUNC_EFFECT }, 80 { "getEomonth" , HID_AAI_FUNC_EOMONTH }, 81 { "getErf" , HID_AAI_FUNC_ERF }, 82 { "getErfc" , HID_AAI_FUNC_ERFC }, 83 { "getFactdouble" , HID_AAI_FUNC_FACTDOUBLE }, 84 { "getFvschedule" , HID_AAI_FUNC_FVSCHEDULE }, 85 { "getGcd" , HID_AAI_FUNC_GCD }, 86 { "getGestep" , HID_AAI_FUNC_GESTEP }, 87 { "getHex2Bin" , HID_AAI_FUNC_HEX2BIN }, 88 { "getHex2Dec" , HID_AAI_FUNC_HEX2DEC }, 89 { "getHex2Oct" , HID_AAI_FUNC_HEX2OCT }, 90 { "getImabs" , HID_AAI_FUNC_IMABS }, 91 { "getImaginary" , HID_AAI_FUNC_IMAGINARY }, 92 { "getImargument" , HID_AAI_FUNC_IMARGUMENT }, 93 { "getImconjugate" , HID_AAI_FUNC_IMCONJUGATE }, 94 { "getImcos" , HID_AAI_FUNC_IMCOS }, 95 { "getImdiv" , HID_AAI_FUNC_IMDIV }, 96 { "getImexp" , HID_AAI_FUNC_IMEXP }, 97 { "getImln" , HID_AAI_FUNC_IMLN }, 98 { "getImlog10" , HID_AAI_FUNC_IMLOG10 }, 99 { "getImlog2" , HID_AAI_FUNC_IMLOG2 }, 100 { "getImpower" , HID_AAI_FUNC_IMPOWER }, 101 { "getImproduct" , HID_AAI_FUNC_IMPRODUCT }, 102 { "getImreal" , HID_AAI_FUNC_IMREAL }, 103 { "getImsin" , HID_AAI_FUNC_IMSIN }, 104 { "getImsqrt" , HID_AAI_FUNC_IMSQRT }, 105 { "getImsub" , HID_AAI_FUNC_IMSUB }, 106 { "getImsum" , HID_AAI_FUNC_IMSUM }, 107 { "getIntrate" , HID_AAI_FUNC_INTRATE }, 108 { "getIseven" , HID_AAI_FUNC_ISEVEN }, 109 { "getIsodd" , HID_AAI_FUNC_ISODD }, 110 { "getLcm" , HID_AAI_FUNC_LCM }, 111 { "getMduration" , HID_AAI_FUNC_MDURATION }, 112 { "getMround" , HID_AAI_FUNC_MROUND }, 113 { "getMultinomial" , HID_AAI_FUNC_MULTINOMIAL }, 114 { "getNetworkdays" , HID_AAI_FUNC_NETWORKDAYS }, 115 { "getNominal" , HID_AAI_FUNC_NOMINAL }, 116 { "getOct2Bin" , HID_AAI_FUNC_OCT2BIN }, 117 { "getOct2Dec" , HID_AAI_FUNC_OCT2DEZ }, 118 { "getOct2Hex" , HID_AAI_FUNC_OCT2HEX }, 119 { "getOddfprice" , HID_AAI_FUNC_ODDFPRICE }, 120 { "getOddfyield" , HID_AAI_FUNC_ODDFYIELD }, 121 { "getOddlprice" , HID_AAI_FUNC_ODDLPRICE }, 122 { "getOddlyield" , HID_AAI_FUNC_ODDLYIELD }, 123 { "getPrice" , HID_AAI_FUNC_PRICE }, 124 { "getPricedisc" , HID_AAI_FUNC_PRICEDISC }, 125 { "getPricemat" , HID_AAI_FUNC_PRICEMAT }, 126 { "getQuotient" , HID_AAI_FUNC_QUOTIENT }, 127 { "getRandbetween" , HID_AAI_FUNC_RANDBETWEEN }, 128 { "getReceived" , HID_AAI_FUNC_RECEIVED }, 129 { "getSeriessum" , HID_AAI_FUNC_SERIESSUM }, 130 { "getSqrtpi" , HID_AAI_FUNC_SQRTPI }, 131 { "getTbilleq" , HID_AAI_FUNC_TBILLEQ }, 132 { "getTbillprice" , HID_AAI_FUNC_TBILLPRICE }, 133 { "getTbillyield" , HID_AAI_FUNC_TBILLYIELD }, 134 { "getWeeknum" , HID_AAI_FUNC_WEEKNUM }, 135 { "getWorkday" , HID_AAI_FUNC_WORKDAY }, 136 { "getXirr" , HID_AAI_FUNC_XIRR }, 137 { "getXnpv" , HID_AAI_FUNC_XNPV }, 138 { "getYearfrac" , HID_AAI_FUNC_YEARFRAC }, 139 { "getYield" , HID_AAI_FUNC_YIELD }, 140 { "getYielddisc" , HID_AAI_FUNC_YIELDDISC }, 141 { "getYieldmat" , HID_AAI_FUNC_YIELDMAT } 142 }; 143 144 145 // ---------------------------------------------------------------------------- 146 147 // Help IDs for DateFunc AddIn. MUST BE SORTED for binary search. 148 const ScUnoAddInHelpId pDateFuncHelpIds[] = 149 { 150 { "getDaysInMonth" , HID_DAI_FUNC_DAYSINMONTH }, 151 { "getDaysInYear" , HID_DAI_FUNC_DAYSINYEAR }, 152 { "getDiffMonths" , HID_DAI_FUNC_DIFFMONTHS }, 153 { "getDiffWeeks" , HID_DAI_FUNC_DIFFWEEKS }, 154 { "getDiffYears" , HID_DAI_FUNC_DIFFYEARS }, 155 { "getRot13" , HID_DAI_FUNC_ROT13 }, 156 { "getWeeksInYear" , HID_DAI_FUNC_WEEKSINYEAR } 157 }; 158 159 160 // ============================================================================ 161 162 //UNUSED2008-05 ScUnoAddInHelpIdGenerator::ScUnoAddInHelpIdGenerator() : 163 //UNUSED2008-05 pCurrHelpIds( NULL ), 164 //UNUSED2008-05 nArrayCount( 0 ) 165 //UNUSED2008-05 { 166 //UNUSED2008-05 } 167 168 ScUnoAddInHelpIdGenerator::ScUnoAddInHelpIdGenerator( const ::rtl::OUString& rServiceName ) 169 { 170 SetServiceName( rServiceName ); 171 } 172 173 void ScUnoAddInHelpIdGenerator::SetServiceName( const ::rtl::OUString& rServiceName ) 174 { 175 pCurrHelpIds = NULL; 176 sal_uInt32 nSize = 0; 177 178 if( rServiceName.equalsAscii( "com.sun.star.sheet.addin.Analysis" ) ) 179 { 180 pCurrHelpIds = pAnalysisHelpIds; 181 nSize = sizeof( pAnalysisHelpIds ); 182 } 183 else if( rServiceName.equalsAscii( "com.sun.star.sheet.addin.DateFunctions" ) ) 184 { 185 pCurrHelpIds = pDateFuncHelpIds; 186 nSize = sizeof( pDateFuncHelpIds ); 187 } 188 189 nArrayCount = nSize / sizeof( ScUnoAddInHelpId ); 190 } 191 192 rtl::OString ScUnoAddInHelpIdGenerator::GetHelpId( const ::rtl::OUString& rFuncName ) const 193 { 194 if( !pCurrHelpIds || !nArrayCount ) 195 return rtl::OString(); 196 197 const ScUnoAddInHelpId* pFirst = pCurrHelpIds; 198 const ScUnoAddInHelpId* pLast = pCurrHelpIds + nArrayCount - 1; 199 200 while( pFirst <= pLast ) 201 { 202 const ScUnoAddInHelpId* pMiddle = pFirst + (pLast - pFirst) / 2; 203 sal_Int32 nResult = rFuncName.compareToAscii( pMiddle->pFuncName ); 204 if( !nResult ) 205 return pMiddle->sHelpId; 206 else if( nResult < 0 ) 207 pLast = pMiddle - 1; 208 else 209 pFirst = pMiddle + 1; 210 } 211 212 return rtl::OString(); 213 } 214 215 216 // ============================================================================ 217 218