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