xmlsecurity: fix --without-system-nss build
[LibreOffice.git] / sc / source / core / tool / addinhelpid.cxx
blob9c44e269d00eb24a6553dc959b49de61345509a2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <addinhelpid.hxx>
21 #include <helpids.h>
22 #include <o3tl/string_view.hxx>
24 // A struct containing the built-in function name and the built-in help ID.
25 struct ScUnoAddInHelpId
27 const char* pFuncName;
28 OUString sHelpId;
31 // Help IDs for Analysis AddIn. MUST BE SORTED for binary search.
32 const ScUnoAddInHelpId pAnalysisHelpIds[] =
34 { "getAccrint" , HID_AAI_FUNC_ACCRINT },
35 { "getAccrintm" , HID_AAI_FUNC_ACCRINTM },
36 { "getAmordegrc" , HID_AAI_FUNC_AMORDEGRC },
37 { "getAmorlinc" , HID_AAI_FUNC_AMORLINC },
38 { "getBesseli" , HID_AAI_FUNC_BESSELI },
39 { "getBesselj" , HID_AAI_FUNC_BESSELJ },
40 { "getBesselk" , HID_AAI_FUNC_BESSELK },
41 { "getBessely" , HID_AAI_FUNC_BESSELY },
42 { "getBin2Dec" , HID_AAI_FUNC_BIN2DEC },
43 { "getBin2Hex" , HID_AAI_FUNC_BIN2HEX },
44 { "getBin2Oct" , HID_AAI_FUNC_BIN2OCT },
45 { "getComplex" , HID_AAI_FUNC_COMPLEX },
46 { "getConvert" , HID_AAI_FUNC_CONVERT },
47 { "getCoupdaybs" , HID_AAI_FUNC_COUPDAYBS },
48 { "getCoupdays" , HID_AAI_FUNC_COUPDAYS },
49 { "getCoupdaysnc" , HID_AAI_FUNC_COUPDAYSNC },
50 { "getCoupncd" , HID_AAI_FUNC_COUPNCD },
51 { "getCoupnum" , HID_AAI_FUNC_COUPNUM },
52 { "getCouppcd" , HID_AAI_FUNC_COUPPCD },
53 { "getCumipmt" , HID_AAI_FUNC_CUMIPMT },
54 { "getCumprinc" , HID_AAI_FUNC_CUMPRINC },
55 { "getDec2Bin" , HID_AAI_FUNC_DEC2BIN },
56 { "getDec2Hex" , HID_AAI_FUNC_DEC2HEX },
57 { "getDec2Oct" , HID_AAI_FUNC_DEC2OCT },
58 { "getDelta" , HID_AAI_FUNC_DELTA },
59 { "getDisc" , HID_AAI_FUNC_DISC },
60 { "getDollarde" , HID_AAI_FUNC_DOLLARDE },
61 { "getDollarfr" , HID_AAI_FUNC_DOLLARFR },
62 { "getDuration" , HID_AAI_FUNC_DURATION },
63 { "getEdate" , HID_AAI_FUNC_EDATE },
64 { "getEffect" , HID_AAI_FUNC_EFFECT },
65 { "getEomonth" , HID_AAI_FUNC_EOMONTH },
66 { "getErf" , HID_AAI_FUNC_ERF },
67 { "getErfc" , HID_AAI_FUNC_ERFC },
68 { "getFactdouble" , HID_AAI_FUNC_FACTDOUBLE },
69 { "getFvschedule" , HID_AAI_FUNC_FVSCHEDULE },
70 { "getGcd" , HID_AAI_FUNC_GCD },
71 { "getGestep" , HID_AAI_FUNC_GESTEP },
72 { "getHex2Bin" , HID_AAI_FUNC_HEX2BIN },
73 { "getHex2Dec" , HID_AAI_FUNC_HEX2DEC },
74 { "getHex2Oct" , HID_AAI_FUNC_HEX2OCT },
75 { "getImabs" , HID_AAI_FUNC_IMABS },
76 { "getImaginary" , HID_AAI_FUNC_IMAGINARY },
77 { "getImargument" , HID_AAI_FUNC_IMARGUMENT },
78 { "getImconjugate" , HID_AAI_FUNC_IMCONJUGATE },
79 { "getImcos" , HID_AAI_FUNC_IMCOS },
80 { "getImcosh" , HID_AAI_FUNC_IMCOSH },
81 { "getImcot" , HID_AAI_FUNC_IMCOT },
82 { "getImcsc" , HID_AAI_FUNC_IMCSC },
83 { "getImcsch" , HID_AAI_FUNC_IMCSCH },
84 { "getImdiv" , HID_AAI_FUNC_IMDIV },
85 { "getImexp" , HID_AAI_FUNC_IMEXP },
86 { "getImln" , HID_AAI_FUNC_IMLN },
87 { "getImlog10" , HID_AAI_FUNC_IMLOG10 },
88 { "getImlog2" , HID_AAI_FUNC_IMLOG2 },
89 { "getImpower" , HID_AAI_FUNC_IMPOWER },
90 { "getImproduct" , HID_AAI_FUNC_IMPRODUCT },
91 { "getImreal" , HID_AAI_FUNC_IMREAL },
92 { "getImsec" , HID_AAI_FUNC_IMSEC },
93 { "getImsech" , HID_AAI_FUNC_IMSECH },
94 { "getImsin" , HID_AAI_FUNC_IMSIN },
95 { "getImsinh" , HID_AAI_FUNC_IMSINH },
96 { "getImsqrt" , HID_AAI_FUNC_IMSQRT },
97 { "getImsub" , HID_AAI_FUNC_IMSUB },
98 { "getImsum" , HID_AAI_FUNC_IMSUM },
99 { "getImtan" , HID_AAI_FUNC_IMTAN },
100 { "getIntrate" , HID_AAI_FUNC_INTRATE },
101 { "getIseven" , HID_AAI_FUNC_ISEVEN },
102 { "getIsodd" , HID_AAI_FUNC_ISODD },
103 { "getLcm" , HID_AAI_FUNC_LCM },
104 { "getMduration" , HID_AAI_FUNC_MDURATION },
105 { "getMround" , HID_AAI_FUNC_MROUND },
106 { "getMultinomial" , HID_AAI_FUNC_MULTINOMIAL },
107 { "getNetworkdays" , HID_AAI_FUNC_NETWORKDAYS },
108 { "getNominal" , HID_AAI_FUNC_NOMINAL },
109 { "getOct2Bin" , HID_AAI_FUNC_OCT2BIN },
110 { "getOct2Dec" , HID_AAI_FUNC_OCT2DEZ },
111 { "getOct2Hex" , HID_AAI_FUNC_OCT2HEX },
112 { "getOddfprice" , HID_AAI_FUNC_ODDFPRICE },
113 { "getOddfyield" , HID_AAI_FUNC_ODDFYIELD },
114 { "getOddlprice" , HID_AAI_FUNC_ODDLPRICE },
115 { "getOddlyield" , HID_AAI_FUNC_ODDLYIELD },
116 { "getPrice" , HID_AAI_FUNC_PRICE },
117 { "getPricedisc" , HID_AAI_FUNC_PRICEDISC },
118 { "getPricemat" , HID_AAI_FUNC_PRICEMAT },
119 { "getQuotient" , HID_AAI_FUNC_QUOTIENT },
120 { "getRandbetween" , HID_AAI_FUNC_RANDBETWEEN },
121 { "getReceived" , HID_AAI_FUNC_RECEIVED },
122 { "getSeriessum" , HID_AAI_FUNC_SERIESSUM },
123 { "getSqrtpi" , HID_AAI_FUNC_SQRTPI },
124 { "getTbilleq" , HID_AAI_FUNC_TBILLEQ },
125 { "getTbillprice" , HID_AAI_FUNC_TBILLPRICE },
126 { "getTbillyield" , HID_AAI_FUNC_TBILLYIELD },
127 { "getWeeknum" , HID_AAI_FUNC_WEEKNUM },
128 { "getWorkday" , HID_AAI_FUNC_WORKDAY },
129 { "getXirr" , HID_AAI_FUNC_XIRR },
130 { "getXnpv" , HID_AAI_FUNC_XNPV },
131 { "getYearfrac" , HID_AAI_FUNC_YEARFRAC },
132 { "getYield" , HID_AAI_FUNC_YIELD },
133 { "getYielddisc" , HID_AAI_FUNC_YIELDDISC },
134 { "getYieldmat" , HID_AAI_FUNC_YIELDMAT }
137 // Help IDs for DateFunc AddIn. MUST BE SORTED for binary search.
138 const ScUnoAddInHelpId pDateFuncHelpIds[] =
140 { "getDaysInMonth" , HID_DAI_FUNC_DAYSINMONTH },
141 { "getDaysInYear" , HID_DAI_FUNC_DAYSINYEAR },
142 { "getDiffMonths" , HID_DAI_FUNC_DIFFMONTHS },
143 { "getDiffWeeks" , HID_DAI_FUNC_DIFFWEEKS },
144 { "getDiffYears" , HID_DAI_FUNC_DIFFYEARS },
145 { "getRot13" , HID_DAI_FUNC_ROT13 },
146 { "getWeeksInYear" , HID_DAI_FUNC_WEEKSINYEAR }
149 // Help IDs for Pricing AddIn. MUST BE SORTED for binary search.
150 const ScUnoAddInHelpId pPricingFuncHelpIds[] =
152 { "getOptBarrier" , HID_PAI_FUNC_OPT_BARRIER },
153 { "getOptProbHit" , HID_PAI_FUNC_OPT_PROB_HIT },
154 { "getOptProbInMoney" , HID_PAI_FUNC_OPT_PROB_INMONEY },
155 { "getOptTouch" , HID_PAI_FUNC_OPT_TOUCH }
158 ScUnoAddInHelpIdGenerator::ScUnoAddInHelpIdGenerator( std::u16string_view rServiceName )
160 SetServiceName( rServiceName );
163 void ScUnoAddInHelpIdGenerator::SetServiceName( std::u16string_view rServiceName )
165 pCurrHelpIds = nullptr;
166 sal_uInt32 nSize = 0;
168 if ( rServiceName == u"com.sun.star.sheet.addin.Analysis" )
170 pCurrHelpIds = pAnalysisHelpIds;
171 nSize = sizeof( pAnalysisHelpIds );
173 else if ( rServiceName == u"com.sun.star.sheet.addin.DateFunctions" )
175 pCurrHelpIds = pDateFuncHelpIds;
176 nSize = sizeof( pDateFuncHelpIds );
178 else if ( rServiceName == u"com.sun.star.sheet.addin.PricingFunctions")
180 pCurrHelpIds = pPricingFuncHelpIds;
181 nSize = sizeof( pPricingFuncHelpIds);
184 nArrayCount = nSize / sizeof( ScUnoAddInHelpId );
187 OUString ScUnoAddInHelpIdGenerator::GetHelpId( std::u16string_view rFuncName ) const
189 if( !pCurrHelpIds || !nArrayCount )
190 return {};
192 const ScUnoAddInHelpId* pFirst = pCurrHelpIds;
193 const ScUnoAddInHelpId* pLast = pCurrHelpIds + nArrayCount - 1;
195 while( pFirst <= pLast )
197 const ScUnoAddInHelpId* pMiddle = pFirst + (pLast - pFirst) / 2;
198 sal_Int32 nResult = o3tl::compareToAscii( rFuncName, pMiddle->pFuncName );
199 if( !nResult )
200 return pMiddle->sHelpId;
201 else if( nResult < 0 )
202 pLast = pMiddle - 1;
203 else
204 pFirst = pMiddle + 1;
207 return {};
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */