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