LibreOffice Module sc (master) 1
addinhelpid.cxx
Go to the documentation of this file.
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 <helpids.h>
22#include <o3tl/string_view.hxx>
23
24// A struct containing the built-in function name and the built-in help ID.
26{
27 const char* pFuncName;
28 OUString sHelpId;
29};
30
31// Help IDs for Analysis AddIn. MUST BE SORTED for binary search.
33{
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 }
135};
136
137// Help IDs for DateFunc AddIn. MUST BE SORTED for binary search.
139{
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 }
147};
148
149// Help IDs for Pricing AddIn. MUST BE SORTED for binary search.
151{
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 }
156};
157
159{
160 SetServiceName( rServiceName );
161}
162
163void ScUnoAddInHelpIdGenerator::SetServiceName( std::u16string_view rServiceName )
164{
165 pCurrHelpIds = nullptr;
166 sal_uInt32 nSize = 0;
167
168 if ( rServiceName == u"com.sun.star.sheet.addin.Analysis" )
169 {
171 nSize = sizeof( pAnalysisHelpIds );
172 }
173 else if ( rServiceName == u"com.sun.star.sheet.addin.DateFunctions" )
174 {
176 nSize = sizeof( pDateFuncHelpIds );
177 }
178 else if ( rServiceName == u"com.sun.star.sheet.addin.PricingFunctions")
179 {
181 nSize = sizeof( pPricingFuncHelpIds);
182 }
183
184 nArrayCount = nSize / sizeof( ScUnoAddInHelpId );
185}
186
187OUString ScUnoAddInHelpIdGenerator::GetHelpId( std::u16string_view rFuncName ) const
188{
189 if( !pCurrHelpIds || !nArrayCount )
190 return {};
191
192 const ScUnoAddInHelpId* pFirst = pCurrHelpIds;
193 const ScUnoAddInHelpId* pLast = pCurrHelpIds + nArrayCount - 1;
194
195 while( pFirst <= pLast )
196 {
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;
205 }
206
207 return {};
208}
209
210/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const ScUnoAddInHelpId pDateFuncHelpIds[]
const ScUnoAddInHelpId pAnalysisHelpIds[]
Definition: addinhelpid.cxx:32
const ScUnoAddInHelpId pPricingFuncHelpIds[]
void SetServiceName(std::u16string_view rServiceName)
Sets service name of the AddIn.
sal_uInt32 nArrayCount
Array of function names and help IDs.
Definition: addinhelpid.hxx:32
ScUnoAddInHelpIdGenerator()=delete
Count of array entries.
const ScUnoAddInHelpId * pCurrHelpIds
Definition: addinhelpid.hxx:31
OUString GetHelpId(std::u16string_view rFuncName) const
float u
constexpr OUStringLiteral HID_PAI_FUNC_OPT_PROB_HIT
Definition: helpids.h:188
constexpr OUStringLiteral HID_AAI_FUNC_BESSELJ
Definition: helpids.h:125
constexpr OUStringLiteral HID_AAI_FUNC_COUPDAYSNC
Definition: helpids.h:109
constexpr OUStringLiteral HID_AAI_FUNC_DOLLARDE
Definition: helpids.h:93
constexpr OUStringLiteral HID_AAI_FUNC_IMLN
Definition: helpids.h:149
constexpr OUStringLiteral HID_AAI_FUNC_HEX2DEC
Definition: helpids.h:139
constexpr OUStringLiteral HID_AAI_FUNC_PRICEDISC
Definition: helpids.h:88
constexpr OUStringLiteral HID_AAI_FUNC_SQRTPI
Definition: helpids.h:122
constexpr OUStringLiteral HID_AAI_FUNC_GESTEP
Definition: helpids.h:137
constexpr OUStringLiteral HID_AAI_FUNC_IMCOS
Definition: helpids.h:145
constexpr OUStringLiteral HID_AAI_FUNC_IMREAL
Definition: helpids.h:153
constexpr OUStringLiteral HID_AAI_FUNC_YEARFRAC
Definition: helpids.h:72
constexpr OUStringLiteral HID_AAI_FUNC_DOLLARFR
Definition: helpids.h:92
constexpr OUStringLiteral HID_DAI_FUNC_DIFFMONTHS
Definition: helpids.h:179
constexpr OUStringLiteral HID_AAI_FUNC_CUMPRINC
Definition: helpids.h:85
constexpr OUStringLiteral HID_AAI_FUNC_BESSELY
Definition: helpids.h:127
constexpr OUStringLiteral HID_AAI_FUNC_ISODD
Definition: helpids.h:115
constexpr OUStringLiteral HID_AAI_FUNC_MROUND
Definition: helpids.h:121
constexpr OUStringLiteral HID_PAI_FUNC_OPT_PROB_INMONEY
Definition: helpids.h:189
constexpr OUStringLiteral HID_AAI_FUNC_XIRR
Definition: helpids.h:104
constexpr OUStringLiteral HID_AAI_FUNC_EDATE
Definition: helpids.h:73
constexpr OUStringLiteral HID_AAI_FUNC_XNPV
Definition: helpids.h:105
constexpr OUStringLiteral HID_AAI_FUNC_ODDFPRICE
Definition: helpids.h:100
constexpr OUStringLiteral HID_DAI_FUNC_WEEKSINYEAR
Definition: helpids.h:178
constexpr OUStringLiteral HID_AAI_FUNC_DELTA
Definition: helpids.h:131
constexpr OUStringLiteral HID_AAI_FUNC_WORKDAY
Definition: helpids.h:71
constexpr OUStringLiteral HID_AAI_FUNC_CONVERT
Definition: helpids.h:162
constexpr OUStringLiteral HID_PAI_FUNC_OPT_TOUCH
Definition: helpids.h:187
constexpr OUStringLiteral HID_AAI_FUNC_DEC2BIN
Definition: helpids.h:132
constexpr OUStringLiteral HID_AAI_FUNC_IMDIV
Definition: helpids.h:146
constexpr OUStringLiteral HID_AAI_FUNC_BESSELK
Definition: helpids.h:126
constexpr OUStringLiteral HID_AAI_FUNC_IMEXP
Definition: helpids.h:147
constexpr OUStringLiteral HID_DAI_FUNC_DIFFYEARS
Definition: helpids.h:181
constexpr OUStringLiteral HID_AAI_FUNC_MULTINOMIAL
Definition: helpids.h:118
constexpr OUStringLiteral HID_DAI_FUNC_DAYSINMONTH
Definition: helpids.h:176
constexpr OUStringLiteral HID_AAI_FUNC_ACCRINT
Definition: helpids.h:79
constexpr OUStringLiteral HID_AAI_FUNC_IMTAN
Definition: helpids.h:164
constexpr OUStringLiteral HID_AAI_FUNC_SERIESSUM
Definition: helpids.h:119
constexpr OUStringLiteral HID_AAI_FUNC_ODDLPRICE
Definition: helpids.h:102
constexpr OUStringLiteral HID_DAI_FUNC_ROT13
Definition: helpids.h:182
constexpr OUStringLiteral HID_AAI_FUNC_EFFECT
Definition: helpids.h:84
constexpr OUStringLiteral HID_AAI_FUNC_PRICEMAT
Definition: helpids.h:89
constexpr OUStringLiteral HID_AAI_FUNC_IMLOG2
Definition: helpids.h:151
constexpr OUStringLiteral HID_AAI_FUNC_IMSECH
Definition: helpids.h:170
constexpr OUStringLiteral HID_AAI_FUNC_COUPDAYS
Definition: helpids.h:108
constexpr OUStringLiteral HID_AAI_FUNC_IMLOG10
Definition: helpids.h:150
constexpr OUStringLiteral HID_AAI_FUNC_ODDFYIELD
Definition: helpids.h:101
constexpr OUStringLiteral HID_AAI_FUNC_OCT2BIN
Definition: helpids.h:159
constexpr OUStringLiteral HID_AAI_FUNC_IMPOWER
Definition: helpids.h:143
constexpr OUStringLiteral HID_AAI_FUNC_PRICE
Definition: helpids.h:87
constexpr OUStringLiteral HID_AAI_FUNC_FACTDOUBLE
Definition: helpids.h:163
constexpr OUStringLiteral HID_AAI_FUNC_BIN2HEX
Definition: helpids.h:129
constexpr OUStringLiteral HID_AAI_FUNC_IMSUM
Definition: helpids.h:156
constexpr OUStringLiteral HID_AAI_FUNC_IMSQRT
Definition: helpids.h:157
constexpr OUStringLiteral HID_AAI_FUNC_IMARGUMENT
Definition: helpids.h:144
constexpr OUStringLiteral HID_AAI_FUNC_ERF
Definition: helpids.h:135
constexpr OUStringLiteral HID_DAI_FUNC_DAYSINYEAR
Definition: helpids.h:177
constexpr OUStringLiteral HID_AAI_FUNC_BESSELI
Definition: helpids.h:124
constexpr OUStringLiteral HID_AAI_FUNC_IMSINH
Definition: helpids.h:168
constexpr OUStringLiteral HID_AAI_FUNC_ERFC
Definition: helpids.h:136
constexpr OUStringLiteral HID_AAI_FUNC_BIN2DEC
Definition: helpids.h:128
constexpr OUStringLiteral HID_AAI_FUNC_IMSIN
Definition: helpids.h:154
constexpr OUStringLiteral HID_PAI_FUNC_OPT_BARRIER
Definition: helpids.h:186
constexpr OUStringLiteral HID_AAI_FUNC_NETWORKDAYS
Definition: helpids.h:76
constexpr OUStringLiteral HID_AAI_FUNC_RANDBETWEEN
Definition: helpids.h:123
constexpr OUStringLiteral HID_AAI_FUNC_MDURATION
Definition: helpids.h:90
constexpr OUStringLiteral HID_AAI_FUNC_COUPNCD
Definition: helpids.h:107
constexpr OUStringLiteral HID_AAI_FUNC_COMPLEX
Definition: helpids.h:158
constexpr OUStringLiteral HID_AAI_FUNC_IMSUB
Definition: helpids.h:155
constexpr OUStringLiteral HID_AAI_FUNC_INTRATE
Definition: helpids.h:106
constexpr OUStringLiteral HID_AAI_FUNC_HEX2OCT
Definition: helpids.h:140
constexpr OUStringLiteral HID_AAI_FUNC_IMCONJUGATE
Definition: helpids.h:148
constexpr OUStringLiteral HID_AAI_FUNC_IMPRODUCT
Definition: helpids.h:152
constexpr OUStringLiteral HID_AAI_FUNC_GCD
Definition: helpids.h:116
constexpr OUStringLiteral HID_AAI_FUNC_WEEKNUM
Definition: helpids.h:74
constexpr OUStringLiteral HID_AAI_FUNC_QUOTIENT
Definition: helpids.h:120
constexpr OUStringLiteral HID_AAI_FUNC_DEC2HEX
Definition: helpids.h:133
constexpr OUStringLiteral HID_AAI_FUNC_YIELDMAT
Definition: helpids.h:96
constexpr OUStringLiteral HID_AAI_FUNC_AMORDEGRC
Definition: helpids.h:77
constexpr OUStringLiteral HID_DAI_FUNC_DIFFWEEKS
Definition: helpids.h:180
constexpr OUStringLiteral HID_AAI_FUNC_HEX2BIN
Definition: helpids.h:138
constexpr OUStringLiteral HID_AAI_FUNC_IMCSC
Definition: helpids.h:166
constexpr OUStringLiteral HID_AAI_FUNC_OCT2DEZ
Definition: helpids.h:160
constexpr OUStringLiteral HID_AAI_FUNC_NOMINAL
Definition: helpids.h:91
constexpr OUStringLiteral HID_AAI_FUNC_AMORLINC
Definition: helpids.h:78
constexpr OUStringLiteral HID_AAI_FUNC_DEC2OCT
Definition: helpids.h:134
constexpr OUStringLiteral HID_AAI_FUNC_IMCOSH
Definition: helpids.h:169
constexpr OUStringLiteral HID_AAI_FUNC_IMABS
Definition: helpids.h:141
constexpr OUStringLiteral HID_AAI_FUNC_COUPNUM
Definition: helpids.h:112
constexpr OUStringLiteral HID_AAI_FUNC_ISEVEN
Definition: helpids.h:114
constexpr OUStringLiteral HID_AAI_FUNC_IMCOT
Definition: helpids.h:167
constexpr OUStringLiteral HID_AAI_FUNC_TBILLPRICE
Definition: helpids.h:98
constexpr OUStringLiteral HID_AAI_FUNC_DISC
Definition: helpids.h:82
constexpr OUStringLiteral HID_AAI_FUNC_TBILLEQ
Definition: helpids.h:97
constexpr OUStringLiteral HID_AAI_FUNC_COUPPCD
Definition: helpids.h:111
constexpr OUStringLiteral HID_AAI_FUNC_LCM
Definition: helpids.h:117
constexpr OUStringLiteral HID_AAI_FUNC_YIELDDISC
Definition: helpids.h:95
constexpr OUStringLiteral HID_AAI_FUNC_EOMONTH
Definition: helpids.h:75
constexpr OUStringLiteral HID_AAI_FUNC_OCT2HEX
Definition: helpids.h:161
constexpr OUStringLiteral HID_AAI_FUNC_RECEIVED
Definition: helpids.h:81
constexpr OUStringLiteral HID_AAI_FUNC_CUMIPMT
Definition: helpids.h:86
constexpr OUStringLiteral HID_AAI_FUNC_IMSEC
Definition: helpids.h:165
constexpr OUStringLiteral HID_AAI_FUNC_COUPDAYBS
Definition: helpids.h:110
constexpr OUStringLiteral HID_AAI_FUNC_DURATION
Definition: helpids.h:83
constexpr OUStringLiteral HID_AAI_FUNC_IMAGINARY
Definition: helpids.h:142
constexpr OUStringLiteral HID_AAI_FUNC_BIN2OCT
Definition: helpids.h:130
constexpr OUStringLiteral HID_AAI_FUNC_YIELD
Definition: helpids.h:94
constexpr OUStringLiteral HID_AAI_FUNC_ACCRINTM
Definition: helpids.h:80
constexpr OUStringLiteral HID_AAI_FUNC_TBILLYIELD
Definition: helpids.h:99
constexpr OUStringLiteral HID_AAI_FUNC_FVSCHEDULE
Definition: helpids.h:113
constexpr OUStringLiteral HID_AAI_FUNC_IMCSCH
Definition: helpids.h:171
constexpr OUStringLiteral HID_AAI_FUNC_ODDLYIELD
Definition: helpids.h:103
int compareToAscii(std::u16string_view s1, std::string_view s2)
const char * pFuncName
Definition: addinhelpid.cxx:27