1*cdf0e10cSrcweir/************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir/* static char rot13_Id[]="@(#) StarCalc Rot13 AddIn (c) 1998-2000 Sun Microsystems, Inc."; */ 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir#include <string.h> 31*cdf0e10cSrcweir#include <stdio.h> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir#include <xlang.h> 34*cdf0e10cSrcweir#include <addin.h> 35*cdf0e10cSrcweir#include <rot13.hrc> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir/** 38*cdf0e10cSrcweir * the current language the Addin is using 39*cdf0e10cSrcweir */ 40*cdf0e10cSrcweirstatic USHORT _nLanguage=LANGUAGE_ENGLISH; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir/** 43*cdf0e10cSrcweir * StarCalc calls this function to set a new current Language for the Addin 44*cdf0e10cSrcweir * 45*cdf0e10cSrcweir * @param *nLanguage 46*cdf0e10cSrcweir * 47*cdf0e10cSrcweir */ 48*cdf0e10cSrcweirvoid CALLTYPE SetLanguage( USHORT* nLanguage ) 49*cdf0e10cSrcweir{ 50*cdf0e10cSrcweir _nLanguage = GetNeutralLanguage( *nLanguage ); 51*cdf0e10cSrcweir} 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir/** 55*cdf0e10cSrcweir * Tell StarCalc how many new functions this Addin provides. 56*cdf0e10cSrcweir * 57*cdf0e10cSrcweir * @param *nCount - returns the number of functions which are exported to StarCalc 58*cdf0e10cSrcweir * 59*cdf0e10cSrcweir */ 60*cdf0e10cSrcweirvoid CALLTYPE GetFunctionCount( USHORT *nCount ) 61*cdf0e10cSrcweir{ 62*cdf0e10cSrcweir *nCount = 1; 63*cdf0e10cSrcweir} 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir/** 66*cdf0e10cSrcweir * Provides neccessary data for each new function to StarCalc 67*cdf0e10cSrcweir * 68*cdf0e10cSrcweir * @param *nNo Input: Function number between 0 and nCount - 1 69*cdf0e10cSrcweir * @param *pFuncName Output: Functionname which should be called in the AddIn-DLL 70*cdf0e10cSrcweir * @param *nParamCount Output: Number of Parameter. Must be greater than 0, because there's always a return-Value. Maximum is 16. 71*cdf0e10cSrcweir * @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*cdf0e10cSrcweir * @param *pInternalName Output: Functionname as seen by the Spreadsheet user 73*cdf0e10cSrcweir * 74*cdf0e10cSrcweir * @see #GetFunctionCount, #GetParameterDescription 75*cdf0e10cSrcweir * 76*cdf0e10cSrcweir */ 77*cdf0e10cSrcweirvoid CALLTYPE GetFunctionData( USHORT * nNo, 78*cdf0e10cSrcweir char * pFuncName, 79*cdf0e10cSrcweir USHORT * nParamCount, 80*cdf0e10cSrcweir ParamType * peType, 81*cdf0e10cSrcweir char * pInternalName ) 82*cdf0e10cSrcweir{ 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir switch( *nNo ) { 85*cdf0e10cSrcweir case 0: 86*cdf0e10cSrcweir /* the function name is the same in all languages */ 87*cdf0e10cSrcweir SO_StringCopy( pInternalName, "Rot13" ); 88*cdf0e10cSrcweir SO_StringCopy( pFuncName, "Rot13" ); 89*cdf0e10cSrcweir peType[0] = PTR_STRING; 90*cdf0e10cSrcweir peType[1] = PTR_STRING; 91*cdf0e10cSrcweir *nParamCount=2; 92*cdf0e10cSrcweir break; 93*cdf0e10cSrcweir default: 94*cdf0e10cSrcweir *nParamCount = 0; 95*cdf0e10cSrcweir *pFuncName = 0; 96*cdf0e10cSrcweir *pInternalName = 0; 97*cdf0e10cSrcweir break; 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir} 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir/** 102*cdf0e10cSrcweir * Provides descriptions for each new function to StarCalc 103*cdf0e10cSrcweir * which are shown is the autopilot 104*cdf0e10cSrcweir * 105*cdf0e10cSrcweir * @param *nNo Input Parameter, Function number between 0 and nCount - 1 106*cdf0e10cSrcweir * @param *nParam Parameter Number 107*cdf0e10cSrcweir * @param *pName Output: Name of the parameter 108*cdf0e10cSrcweir * @param *pDesc Output: Description of the parameter 109*cdf0e10cSrcweir * 110*cdf0e10cSrcweir * @see #GetFunctionCount, #GetParameterDescription 111*cdf0e10cSrcweir */ 112*cdf0e10cSrcweirvoid CALLTYPE GetParameterDescription( USHORT* nNo, USHORT* nParam, 113*cdf0e10cSrcweirchar* pName, char* pDesc ) 114*cdf0e10cSrcweir{ 115*cdf0e10cSrcweir *pName = 0; 116*cdf0e10cSrcweir *pDesc = 0; 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir switch ( *nNo ) { 120*cdf0e10cSrcweir case 0: 121*cdf0e10cSrcweir switch ( *nParam ) { 122*cdf0e10cSrcweir case 0: 123*cdf0e10cSrcweir SO_StringCopy(pDesc,getText(ROT13_DESC)); 124*cdf0e10cSrcweir break; 125*cdf0e10cSrcweir case 1: 126*cdf0e10cSrcweir SO_StringCopy(pName,getText(ROT13_PAR1_NAME)); 127*cdf0e10cSrcweir SO_StringCopy(pDesc,getText(ROT13_PAR1_DESC)); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir} 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir/** 133*cdf0e10cSrcweir * ROT13 Algorithm, each alphabetical character of the text is rotated by 13 in the alphabet 134*cdf0e10cSrcweir * 135*cdf0e10cSrcweir * @param *ret 136*cdf0e10cSrcweir * @param *src 137*cdf0e10cSrcweir * 138*cdf0e10cSrcweir * ER: well, my personal favorite algorithm is 139*cdf0e10cSrcweir * main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);} 140*cdf0e10cSrcweir * but for clarification we do it somehow different here ;-) 141*cdf0e10cSrcweir */ 142*cdf0e10cSrcweirvoid CALLTYPE Rot13(char *ret, char *src) 143*cdf0e10cSrcweir{ 144*cdf0e10cSrcweir if ( ! ret ) return; 145*cdf0e10cSrcweir if ( ! src ) *ret='\0'; 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir for(;src && *src; src++ , ret++) { 148*cdf0e10cSrcweir *ret=*src; 149*cdf0e10cSrcweir if (*ret >= 'A' && *ret <= 'Z') { 150*cdf0e10cSrcweir if ( (*ret +=13) > 'Z' ) *ret-=26; 151*cdf0e10cSrcweir } else if (*ret >= 'a' && *ret < 'n') { 152*cdf0e10cSrcweir *ret +=13; 153*cdf0e10cSrcweir } else if (*ret >= 'n' && *ret <= 'z') { 154*cdf0e10cSrcweir *ret -=13; 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir *ret=*src; 158*cdf0e10cSrcweir} 159