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