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
: rot13.cl
,v $
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 /* static char rot13_Id
[]="@(#) StarCalc Rot13 AddIn (c) 1998-2000 Sun Microsystems, Inc."; */
41 * the current language the Addin is using
43 static USHORT _nLanguage
=LANGUAGE_ENGLISH
;
46 * StarCalc calls this function to set a new current Language for the Addin
51 void CALLTYPE SetLanguage
( USHORT
* nLanguage
)
53 _nLanguage
= GetNeutralLanguage
( *nLanguage
);
58 * Tell StarCalc how many new functions this Addin provides.
60 * @param
*nCount - returns the number of functions which are exported to StarCalc
63 void CALLTYPE GetFunctionCount
( USHORT
*nCount
)
69 * Provides neccessary data for each new function to StarCalc
71 * @param
*nNo Input
: Function number between
0 and nCount -
1
72 * @param
*pFuncName Output
: Functionname which should be called in the AddIn-DLL
73 * @param
*nParamCount Output
: Number of Parameter. Must be greater than
0, because there
's always a return-Value. Maximum is
16.
74 * @param
*peType Output
: Pointer to arrray with exactly
16 variables of typ Paramtype. nParamCount Entries are set to the type of the corresponding Parameters.
75 * @param
*pInternalName Output
: Functionname as seen by the Spreadsheet user
77 * @see
#GetFunctionCount
, #GetParameterDescription
80 void CALLTYPE GetFunctionData
( USHORT
* nNo
,
84 char
* pInternalName
)
89 /* the function name is the same in all languages
*/
90 SO_StringCopy
( pInternalName
, "Rot13" );
91 SO_StringCopy
( pFuncName
, "Rot13" );
92 peType
[0] = PTR_STRING;
93 peType[1] = PTR_STRING;
105 * Provides descriptions for each new function to StarCalc
106 * which are shown is the autopilot
108 * @param *nNo Input Parameter, Function number between 0 and nCount - 1
109 * @param *nParam Parameter Number
110 * @param *pName Output: Name of the parameter
111 * @param *pDesc Output: Description of the parameter
113 * @see #GetFunctionCount, #GetParameterDescription
115 void CALLTYPE GetParameterDescription( USHORT* nNo, USHORT* nParam,
116 char* pName, char* pDesc )
126 SO_StringCopy(pDesc,getText(ROT13_DESC));
129 SO_StringCopy(pName,getText(ROT13_PAR1_NAME));
130 SO_StringCopy(pDesc,getText(ROT13_PAR1_DESC));
136 * ROT13 Algorithm, each alphabetical character of the text is rotated by 13 in the alphabet
141 * ER: well, my personal favorite algorithm is
142 * main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}
143 * but for clarification we do it somehow different here ;-)
145 void CALLTYPE Rot13(char *ret, char *src)
148 if ( ! src ) *ret='\0';
150 for(;src && *src; src++ , ret++) {
152 if (*ret >= 'A' && *ret <= 'Z') {
153 if ( (*ret +=13) > 'Z' ) *ret-=26;
154 } else if (*ret >= 'a' && *ret < 'n') {
156 } else if (*ret >= 'n' && *ret <= 'z') {