1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright
2000, 2010 Oracle and
/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software
: you can redistribute it and
/or modify
12 * it under the terms of the GNU Lesser General Public License version
3
13 * only
, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful
,
16 * but WITHOUT ANY WARRANTY
; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version
3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code
).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version
3 along with OpenOffice.org. If not
, see
23 * <http
://www.openoffice.org
/license.html
>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 /* static char rot13_Id
[]="@(#) StarCalc Rot13 AddIn (c) 1998-2000 Sun Microsystems, Inc."; */
38 * the current language the Addin is using
40 static USHORT _nLanguage
=LANGUAGE_ENGLISH
;
43 * StarCalc calls this function to set a new current Language for the Addin
48 void CALLTYPE SetLanguage
( USHORT
* nLanguage
)
50 _nLanguage
= GetNeutralLanguage
( *nLanguage
);
55 * Tell StarCalc how many new functions this Addin provides.
57 * @param
*nCount - returns the number of functions which are exported to StarCalc
60 void CALLTYPE GetFunctionCount
( USHORT
*nCount
)
66 * Provides neccessary data for each new function to StarCalc
68 * @param
*nNo Input
: Function number between
0 and nCount -
1
69 * @param
*pFuncName Output
: Functionname which should be called in the AddIn-DLL
70 * @param
*nParamCount Output
: Number of Parameter. Must be greater than
0, because there
's always a return-Value. Maximum is
16.
71 * @param
*peType Output
: Pointer to arrray with exactly
16 variables of typ Paramtype. nParamCount Entries are set to the type of the corresponding Parameters.
72 * @param
*pInternalName Output
: Functionname as seen by the Spreadsheet user
74 * @see
#GetFunctionCount
, #GetParameterDescription
77 void CALLTYPE GetFunctionData
( USHORT
* nNo
,
81 char
* pInternalName
)
86 /* the function name is the same in all languages
*/
87 SO_StringCopy
( pInternalName
, "Rot13" );
88 SO_StringCopy
( pFuncName
, "Rot13" );
89 peType
[0] = PTR_STRING;
90 peType[1] = PTR_STRING;
102 * Provides descriptions for each new function to StarCalc
103 * which are shown is the autopilot
105 * @param *nNo Input Parameter, Function number between 0 and nCount - 1
106 * @param *nParam Parameter Number
107 * @param *pName Output: Name of the parameter
108 * @param *pDesc Output: Description of the parameter
110 * @see #GetFunctionCount, #GetParameterDescription
112 void CALLTYPE GetParameterDescription( USHORT* nNo, USHORT* nParam,
113 char* pName, char* pDesc )
123 SO_StringCopy(pDesc,getText(ROT13_DESC));
126 SO_StringCopy(pName,getText(ROT13_PAR1_NAME));
127 SO_StringCopy(pDesc,getText(ROT13_PAR1_DESC));
133 * ROT13 Algorithm, each alphabetical character of the text is rotated by 13 in the alphabet
138 * ER: well, my personal favorite algorithm is
139 * main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}
140 * but for clarification we do it somehow different here ;-)
142 void CALLTYPE Rot13(char *ret, char *src)
145 if ( ! src ) *ret='\0';
147 for(;src && *src; src++ , ret++) {
149 if (*ret >= 'A' && *ret <= 'Z') {
150 if ( (*ret +=13) > 'Z' ) *ret-=26;
151 } else if (*ret >= 'a' && *ret < 'n') {
153 } else if (*ret >= 'n' && *ret <= 'z') {