Remove legacy Addin functions from calc
Removes legacy addin functions - seems to be sample code only. These functions are available through the newer scaddin module.
This commit is contained in:
parent
b0d0898672
commit
8032a423ab
14 changed files with 1 additions and 1945 deletions
|
@ -1,729 +0,0 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
/* static char datefunc_Id[]="@(#) StarCalc Datefunc AddIn (c) 1998-2000 Sun Microsystems, Inc."; */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <xlang.h>
|
||||
#include <addin.h>
|
||||
#include <dfa.hrc>
|
||||
|
||||
|
||||
/**
|
||||
* the current language the Addin is using
|
||||
*/
|
||||
static USHORT _nLanguage=LANGUAGE_ENGLISH;
|
||||
|
||||
/**
|
||||
* StarCalc calls this function to set a new current Language for the Addin
|
||||
*
|
||||
* @param *nLanguage
|
||||
*
|
||||
*/
|
||||
void CALLTYPE SetLanguage( USHORT* nLanguage )
|
||||
{
|
||||
_nLanguage = GetNeutralLanguage( *nLanguage );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Null Date, initialized in GetFunctionCount
|
||||
*
|
||||
* StarCalc uses a BaseDate 12/30/1899
|
||||
* If not specified otherwise in the Settings for the Spreedsheet Document.
|
||||
*
|
||||
* There's no way to get the Spreadsheet settings from whithin a simple addin,
|
||||
* so this Addin can only be used by documents using the default BaseDate setting.
|
||||
*
|
||||
* The functions in this Addin use a BaseDate 01/01/0001
|
||||
* The nNullDate Variable is the StarCalc BaseDate converted to
|
||||
* this internal date representation.
|
||||
*
|
||||
* @see #GetFunctionCount
|
||||
*
|
||||
*/
|
||||
|
||||
static ULONG nNullDate=0;
|
||||
|
||||
#define NULLDATE_Year 1899
|
||||
#define NULLDATE_Month 12
|
||||
#define NULLDATE_Day 30
|
||||
|
||||
|
||||
/**
|
||||
* Array holding values for month length, used in DaysInMonth() function
|
||||
*
|
||||
* @see #DaysInMonth
|
||||
*
|
||||
*/
|
||||
static USHORT aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30,
|
||||
31, 31, 30, 31, 30, 31 };
|
||||
|
||||
/**
|
||||
* Check if a year is a leap year in the Gregorian calendar
|
||||
*
|
||||
* @param nYear the year which should be checked
|
||||
* @return true if the year is a leap year, false otherwise.
|
||||
*
|
||||
* @see #DaysInMonth, #IsLeapYear,
|
||||
* @see #ScDate_DaysInMonth, #ScDate_IsLeapYear, #ScDate_WeeksInYear
|
||||
*
|
||||
*/
|
||||
static BOOL IsLeapYear( USHORT nYear )
|
||||
{
|
||||
return (BOOL)((((nYear % 4) == 0) && ((nYear % 100) != 0)) || ((nYear % 400) == 0));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of days in a specified month
|
||||
*
|
||||
* @param nMonth the number of the Month
|
||||
* @param nYear the year
|
||||
* @return number of days
|
||||
*
|
||||
*/
|
||||
static USHORT DaysInMonth( USHORT nMonth, USHORT nYear )
|
||||
{
|
||||
if ( nMonth != 2 )
|
||||
return aDaysInMonth[nMonth-1];
|
||||
else
|
||||
{
|
||||
if ( IsLeapYear(nYear) )
|
||||
return aDaysInMonth[nMonth-1] + 1;
|
||||
else
|
||||
return aDaysInMonth[nMonth-1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a date to a count of days starting from 01/01/0001
|
||||
*
|
||||
* The internal representation of a Date used in this Addin
|
||||
* is the number of days between 01/01/0001 and the date
|
||||
* this function converts a Day , Month, Year representation
|
||||
* to this internal Date value.
|
||||
*
|
||||
* @param nDay the day of the Month
|
||||
* @param nMonth the number of the Month
|
||||
* @param nYear the Year
|
||||
* @return count of days from 01/01/0001 to the date specified
|
||||
*
|
||||
*/
|
||||
static long DateToDays( USHORT nDay, USHORT nMonth, USHORT nYear )
|
||||
{
|
||||
long nDays;
|
||||
USHORT i;
|
||||
|
||||
nDays = ((ULONG)nYear-1) * 365;
|
||||
nDays += ((nYear-1) / 4) - ((nYear-1) / 100) + ((nYear-1) / 400);
|
||||
|
||||
for( i = 1; i < nMonth; i++ )
|
||||
nDays += DaysInMonth(i,nYear);
|
||||
nDays += nDay;
|
||||
|
||||
return nDays;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a count of days starting from 01/01/0001 to a date
|
||||
*
|
||||
* The internal representation of a Date used in this Addin
|
||||
* is the number of days between 01/01/0001 and the date
|
||||
* this function converts this internal Date value
|
||||
* to a Day , Month, Year representation of a Date.
|
||||
*
|
||||
* @param nDay count of days from 01/01/0001
|
||||
* @param *pDay pointer to a variable for the day of the month
|
||||
* @param *pMonth pointer to a variable for the month
|
||||
* @param *pYear pointer to a variable for the year
|
||||
*
|
||||
*/
|
||||
static void DaysToDate( long nDays,
|
||||
USHORT *pDay, USHORT *pMonth, USHORT *pYear )
|
||||
{
|
||||
long nTempDays;
|
||||
long i = 0;
|
||||
BOOL bCalc;
|
||||
|
||||
do
|
||||
{
|
||||
nTempDays = (long)nDays;
|
||||
*pYear = (USHORT)((nTempDays / 365) - i);
|
||||
nTempDays -= ((ULONG) *pYear -1) * 365;
|
||||
nTempDays -= (( *pYear -1) / 4) - (( *pYear -1) / 100) + ((*pYear -1) / 400);
|
||||
bCalc = FALSE;
|
||||
if ( nTempDays < 1 )
|
||||
{
|
||||
i++;
|
||||
bCalc = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( nTempDays > 365 )
|
||||
{
|
||||
if ( (nTempDays != 366) || !IsLeapYear( *pYear ) )
|
||||
{
|
||||
i--;
|
||||
bCalc = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while ( bCalc );
|
||||
|
||||
*pMonth = 1;
|
||||
while ( (ULONG)nTempDays > DaysInMonth( *pMonth, *pYear ) )
|
||||
{
|
||||
nTempDays -= DaysInMonth( *pMonth, *pYear );
|
||||
(*pMonth)++;
|
||||
}
|
||||
*pDay = (USHORT)nTempDays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get week difference between 2 dates
|
||||
*
|
||||
* new Weeks(date1,date2,mode) function for StarCalc
|
||||
*
|
||||
* Two modes of operation are provided.
|
||||
* The first is just a simple division by 7 calculation.
|
||||
*
|
||||
* The second calculates the diffence by week of year.
|
||||
*
|
||||
* The International Standard IS-8601 has decreed that Monday
|
||||
* shall be the first day of the week.
|
||||
*
|
||||
* A week that lies partly in one year and partly in annother
|
||||
* is assigned a number in the the year in which most of its days lie.
|
||||
*
|
||||
* That means that week 1 of any year is the week that contains the 4. January
|
||||
*
|
||||
* The internal representation of a Date used in the Addin is the number of days based on 01/01/0001
|
||||
*
|
||||
* A WeekDay can be then calculated by substracting 1 and calculating the rest of
|
||||
* a division by 7, which gives a 0 - 6 value for Monday - Sunday
|
||||
*
|
||||
* Using the 4. January rule explained above the formula
|
||||
*
|
||||
* nWeek1= ( nDays1 - nJan4 + ( (nJan4-1) % 7 ) ) / 7 + 1;
|
||||
*
|
||||
* calculates a number between 0-53 for each day which is in the same year as nJan4
|
||||
* where 0 means that this week belonged to the year before.
|
||||
*
|
||||
* If a day in the same or annother year is used in this formula this calculates
|
||||
* an calendar week offset from a given 4. January
|
||||
*
|
||||
* nWeek2 = ( nDays2 - nJan4 + ( (nJan4-1) % 7 ) ) / 7 + 1;
|
||||
*
|
||||
* The 4.January of first Date Argument can thus be used to calculate
|
||||
* the week difference by calendar weeks which is then nWeek = nWeek2 - nWeek1
|
||||
*
|
||||
* which can be optimized to
|
||||
*
|
||||
* nWeek = ( (nDays2-nJan4+((nJan4-1)%7))/7 ) - ( (nDays1-nJan4+((nJan4-1)%7))/7 )
|
||||
*
|
||||
* Note: All calculations are operating on the long integer data type
|
||||
* % is the modulo operator in C which calculates the rest of an Integer division
|
||||
*
|
||||
*
|
||||
* @param *r - return value for the StarCalc function
|
||||
* @param d1 - date value (in StarCalc representation based 12/30/1899), usually the older date
|
||||
* @param d2 - date value (in StarCalc representation based 12/30/1899), usually the younger date
|
||||
* @param dMode - mode of operation
|
||||
*
|
||||
* mode 0 is the interval between the dates in month, that is days / 7
|
||||
*
|
||||
* mode 1 is the difference by week of year
|
||||
*
|
||||
*/
|
||||
void CALLTYPE ScDate_GetDiffWeeks(double *r, double *d1, double *d2, double *dMode)
|
||||
{
|
||||
long nDays1=0;
|
||||
long nDays2=0;
|
||||
int nMode=0;
|
||||
|
||||
if ( d1 ) nDays1=(long)floor(*d1)+nNullDate;
|
||||
if ( d2 ) nDays2=(long)floor(*d2)+nNullDate;
|
||||
|
||||
|
||||
if ( dMode) nMode=(int)*dMode;
|
||||
|
||||
if ( nMode == 1 ) {
|
||||
|
||||
USHORT nDay,nMonth,nYear;
|
||||
long nJan4;
|
||||
|
||||
DaysToDate(nDays1,&nDay,&nMonth,&nYear);
|
||||
nJan4=DateToDays(4,1,nYear);
|
||||
|
||||
*r=(double) ( ( (nDays2-nJan4+((nJan4-1)%7))/7 ) - ( (nDays1-nJan4+((nJan4-1)%7))/7 ) );
|
||||
|
||||
} else {
|
||||
|
||||
*r= (double) ( (nDays2 - nDays1) / 7 ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get month difference between 2 dates
|
||||
* =Month(start, end, mode) Function for StarCalc
|
||||
*
|
||||
* two modes are provided
|
||||
*
|
||||
* @param *r - return value for the StarCalc function
|
||||
* @param d1 - date value, start date
|
||||
* @param d2 - date value, end date
|
||||
* @param dMode - mode of operation
|
||||
*
|
||||
* mode 0 is the interval between the dates in month
|
||||
*
|
||||
* mode 1 is the difference in calendar month
|
||||
*
|
||||
*/
|
||||
void CALLTYPE ScDate_GetDiffMonths(double *r, double *d1, double *d2, double *dMode)
|
||||
{
|
||||
USHORT nDay1,nMonth1,nYear1;
|
||||
USHORT nDay2,nMonth2,nYear2;
|
||||
long nDays1=0;
|
||||
long nDays2=0;
|
||||
int nMode=0;
|
||||
|
||||
if ( dMode) nMode=(int)*dMode;
|
||||
|
||||
if ( d1 ) nDays1=(long)floor(*d1)+nNullDate;
|
||||
if ( d2 ) nDays2=(long)floor(*d2)+nNullDate;
|
||||
|
||||
DaysToDate(nDays1,&nDay1,&nMonth1,&nYear1);
|
||||
DaysToDate(nDays2,&nDay2,&nMonth2,&nYear2);
|
||||
|
||||
*r=(double) ( nMonth2 - nMonth1 + (nYear2 - nYear1) * 12 );
|
||||
if ( nMode == 1 || nDays1 == nDays2 ) return;
|
||||
|
||||
if ( nDays1 < nDays2 ) {
|
||||
if ( nDay1 > nDay2 ) {
|
||||
*r -= 1;
|
||||
}
|
||||
} else {
|
||||
if ( nDay1 < nDay2 ) {
|
||||
*r += 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Year difference between 2 dates
|
||||
*
|
||||
* two modes are provided
|
||||
*
|
||||
* @param *r - return value for the StarCalc function
|
||||
* @param d1 - date value, start date
|
||||
* @param d2 - date value, end date
|
||||
* @param dMode - mode of operation
|
||||
*
|
||||
* mode 0 is the interval between the dates in years
|
||||
*
|
||||
* mode 1 is the difference in calendar years
|
||||
*
|
||||
*/
|
||||
void CALLTYPE ScDate_GetDiffYears(double *r, double *d1, double *d2, double *dMode)
|
||||
{
|
||||
USHORT nDay1,nMonth1,nYear1;
|
||||
USHORT nDay2,nMonth2,nYear2;
|
||||
long nDays1=0;
|
||||
long nDays2=0;
|
||||
int nMode=0;
|
||||
|
||||
if ( dMode) nMode=(int)*dMode;
|
||||
|
||||
if ( d1 ) nDays1=(long)floor(*d1)+nNullDate;
|
||||
if ( d2 ) nDays2=(long)floor(*d2)+nNullDate;
|
||||
|
||||
DaysToDate(nDays1,&nDay1,&nMonth1,&nYear1);
|
||||
DaysToDate(nDays2,&nDay2,&nMonth2,&nYear2);
|
||||
if ( nMode != 1 ) {
|
||||
ScDate_GetDiffMonths(r,d1,d2,dMode);
|
||||
*r= (double) ( ((int) *r) / 12 );
|
||||
} else {
|
||||
*r=(double) ( nYear2 - nYear1 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Date is in a leap year in the Gregorian calendar
|
||||
*
|
||||
* @param *r - return value for the StarCalc function
|
||||
* @param d - date value (in StarCalc representation based 12/30/1899)
|
||||
*
|
||||
*/
|
||||
void CALLTYPE ScDate_IsLeapYear(double *r, double *d)
|
||||
{
|
||||
ULONG nDays;
|
||||
USHORT nDay, nMonth, nYear;
|
||||
double v=0.0;
|
||||
|
||||
if ( d ) v=*d;
|
||||
nDays=(int) v + nNullDate;
|
||||
|
||||
DaysToDate(nDays,&nDay,&nMonth,&nYear);
|
||||
|
||||
*r=(double) ( IsLeapYear(nYear) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Number of Days in the month for a date
|
||||
*
|
||||
* @param *r - return value for the StarCalc function
|
||||
* @param d - date value (in StarCalc representation based 12/30/1899)
|
||||
*
|
||||
*/
|
||||
void CALLTYPE ScDate_DaysInMonth(double *r, double *d)
|
||||
{
|
||||
ULONG nDays;
|
||||
USHORT nDay, nMonth, nYear;
|
||||
double v=0.0;
|
||||
|
||||
if ( d ) v=*d;
|
||||
nDays=(int) v + nNullDate;
|
||||
|
||||
DaysToDate(nDays,&nDay,&nMonth,&nYear);
|
||||
*r=(double) ( DaysInMonth( nMonth, nYear) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get number of weeks in the year for a date
|
||||
*
|
||||
* Most years have 52 weeks, but years that start on a Thursday
|
||||
* and leep years that start on a Wednesday have 53 weeks
|
||||
*
|
||||
* The International Standard IS-8601 has decreed that Monday
|
||||
* shall be the first day of the week.
|
||||
*
|
||||
* A WeekDay can be calculated by substracting 1 and calculating the rest of
|
||||
* a division by 7 from the internal date represention
|
||||
* which gives a 0 - 6 value for Monday - Sunday
|
||||
*
|
||||
* @param *r - return value for the StarCalc function
|
||||
* @param d - date value (in StarCalc represantaion based 30.12.1899)
|
||||
*
|
||||
* @see #IsLeapYear #WeekNumber
|
||||
*
|
||||
*/
|
||||
void CALLTYPE ScDate_WeeksInYear(double *r, double *d)
|
||||
{
|
||||
ULONG nDays;
|
||||
USHORT nDay, nMonth, nYear;
|
||||
double v=0.0;
|
||||
long nJan1WeekDay;
|
||||
|
||||
if ( d ) v=*d;
|
||||
nDays=(int) v + nNullDate;
|
||||
|
||||
DaysToDate(nDays,&nDay,&nMonth,&nYear);
|
||||
|
||||
nJan1WeekDay= ( DateToDays(1,1,nYear) - 1) % 7;
|
||||
|
||||
if ( nJan1WeekDay == 3 ) { /* Thursday */
|
||||
*r=(double) 53;
|
||||
return;
|
||||
} else if ( nJan1WeekDay == 2 ) { /* Wednesday */
|
||||
*r= (double) ( IsLeapYear(nYear) ? 53 : 52 );
|
||||
} else {
|
||||
*r= (double) 52;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get number of days in the year of a date specified
|
||||
*
|
||||
* @param *r - return value for the StarCalc function
|
||||
* @param d - date value (in StarCalc represantaion based 30.12.1899)
|
||||
*
|
||||
*/
|
||||
void CALLTYPE ScDate_DaysInYear(double *r, double *d)
|
||||
{
|
||||
ULONG nDays;
|
||||
USHORT nDay, nMonth, nYear;
|
||||
double v=0.0;
|
||||
|
||||
if ( d ) v=*d;
|
||||
nDays=(int) v + nNullDate;
|
||||
|
||||
DaysToDate(nDays,&nDay,&nMonth,&nYear);
|
||||
*r=(double) ( IsLeapYear(nYear) ? 366 : 365 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tell StarCalc how many new functions this Addin provides.
|
||||
*
|
||||
* It's called before any of these new functions is actually
|
||||
* executed and is also used to initialize the NullDate here.
|
||||
*
|
||||
* StarCalc uses a Date Base 12/30/1899
|
||||
* If not specified otherwise in the Options for the Spreedsheet Document
|
||||
*
|
||||
*
|
||||
* @param *nCount - returns the number of functions which are exported to StarCalc
|
||||
*
|
||||
*/
|
||||
void CALLTYPE GetFunctionCount( USHORT *nCount )
|
||||
{
|
||||
|
||||
/* initialize nNullDate Value 0 is 12/30/1899 */
|
||||
nNullDate=DateToDays(NULLDATE_Day, NULLDATE_Month, NULLDATE_Year);
|
||||
|
||||
*nCount = 7;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides neccessary data for each new function to StarCalc
|
||||
*
|
||||
* @param *nNo Input: Function number between 0 and nCount - 1
|
||||
* @param *pFuncName Output: Functionname which should be called in the AddIn-DLL
|
||||
* @param *nParamCount Output: Number of Parameter. Must be greater than 0, because there's always a return-Value. Maximum is 16.
|
||||
* @param *peType Output: Pointer to arrray with exactly 16 variables of typ Paramtype. nParamCount Entries are set to the type of the corresponding Parameters.
|
||||
* @param *pInternalName Output: Functionname as seen by the Spreadsheet user
|
||||
*
|
||||
* @see #GetFunctionCount, #GetParameterDescription
|
||||
*
|
||||
*/
|
||||
void CALLTYPE GetFunctionData( USHORT * nNo,
|
||||
char * pFuncName,
|
||||
USHORT * nParamCount,
|
||||
ParamType * peType,
|
||||
char * pInternalName )
|
||||
{
|
||||
|
||||
|
||||
switch( *nNo ) {
|
||||
case 0:
|
||||
SO_StringCopy( pInternalName, getText(DFA_WEEK_NAME) );
|
||||
SO_StringCopy( pFuncName, "ScDate_GetDiffWeeks" );
|
||||
peType[0] = PTR_DOUBLE;
|
||||
peType[1] = PTR_DOUBLE;
|
||||
peType[2] = PTR_DOUBLE;
|
||||
peType[3] = PTR_DOUBLE;
|
||||
*nParamCount=4;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
SO_StringCopy( pInternalName, getText(DFA_MONTHS_NAME) );
|
||||
SO_StringCopy( pFuncName, "ScDate_GetDiffMonths" );
|
||||
peType[0] = PTR_DOUBLE;
|
||||
peType[1] = PTR_DOUBLE;
|
||||
peType[2] = PTR_DOUBLE;
|
||||
peType[3] = PTR_DOUBLE;
|
||||
*nParamCount=4;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
SO_StringCopy( pInternalName, getText(DFA_YEARS_NAME) );
|
||||
SO_StringCopy( pFuncName, "ScDate_GetDiffYears" );
|
||||
peType[0] = PTR_DOUBLE;
|
||||
peType[1] = PTR_DOUBLE;
|
||||
peType[2] = PTR_DOUBLE;
|
||||
peType[3] = PTR_DOUBLE;
|
||||
*nParamCount=4;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
SO_StringCopy( pInternalName, getText(DFA_ISLEAPYEAR_NAME) );
|
||||
SO_StringCopy( pFuncName, "ScDate_IsLeapYear" );
|
||||
peType[0] = PTR_DOUBLE;
|
||||
peType[1] = PTR_DOUBLE;
|
||||
*nParamCount=2;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
SO_StringCopy( pInternalName, getText(DFA_DAYSINMONTH_NAME) );
|
||||
SO_StringCopy( pFuncName, "ScDate_DaysInMonth" );
|
||||
peType[0] = PTR_DOUBLE;
|
||||
peType[1] = PTR_DOUBLE;
|
||||
*nParamCount=2;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
SO_StringCopy( pInternalName, getText(DFA_DAYSINYEAR_NAME) );
|
||||
SO_StringCopy( pFuncName, "ScDate_DaysInYear" );
|
||||
peType[0] = PTR_DOUBLE;
|
||||
peType[1] = PTR_DOUBLE;
|
||||
*nParamCount=2;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
SO_StringCopy( pInternalName, getText(DFA_WEEKSINYEAR_NAME) );
|
||||
SO_StringCopy( pFuncName, "ScDate_WeeksInYear" );
|
||||
peType[0] = PTR_DOUBLE;
|
||||
peType[1] = PTR_DOUBLE;
|
||||
*nParamCount=2;
|
||||
break;
|
||||
|
||||
default:
|
||||
*nParamCount = 0;
|
||||
*pFuncName = 0;
|
||||
*pInternalName = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides descriptions for each new function to StarCalc
|
||||
* which are shown is the autopilot
|
||||
*
|
||||
* @param *nNo Input Parameter, Function number between 0 and nCount - 1
|
||||
* @param *nParam Parameter Number
|
||||
* @param *pName Output: Name of the parameter
|
||||
* @param *pDesc Output: Description of the parameter
|
||||
*
|
||||
* @see #GetFunctionCount, #GetParameterDescription
|
||||
*/
|
||||
void CALLTYPE GetParameterDescription( USHORT* nNo, USHORT* nParam,
|
||||
char* pName, char* pDesc )
|
||||
{
|
||||
*pName = 0;
|
||||
*pDesc = 0;
|
||||
|
||||
switch ( *nNo ) {
|
||||
case 0: /* Weeks */
|
||||
switch ( *nParam ) {
|
||||
case 0:
|
||||
SO_StringCopy(pDesc,getText(DFA_WEEK_DESC));
|
||||
break;
|
||||
case 1:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_DATE1_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_WEEK_PAR1_DESC));
|
||||
break;
|
||||
case 2:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_DATE2_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_WEEK_PAR2_DESC));
|
||||
break;
|
||||
case 3:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_MODE_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_WEEK_PAR3_DESC));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1: /* Months */
|
||||
switch ( *nParam ) {
|
||||
case 0:
|
||||
SO_StringCopy(pDesc,getText(DFA_MONTHS_DESC));
|
||||
break;
|
||||
case 1:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_DATE1_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_MONTHS_PAR1_DESC));
|
||||
break;
|
||||
case 2:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_DATE2_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_MONTHS_PAR2_DESC));
|
||||
break;
|
||||
case 3:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_MODE_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_MONTHS_PAR3_DESC));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2: /* Years */
|
||||
switch ( *nParam ) {
|
||||
case 0:
|
||||
SO_StringCopy(pDesc,getText(DFA_YEARS_DESC));
|
||||
break;
|
||||
case 1:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_DATE1_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_YEARS_PAR1_DESC));
|
||||
break;
|
||||
case 2:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_DATE2_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_YEARS_PAR2_DESC));
|
||||
break;
|
||||
case 3:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_MODE_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_YEARS_PAR3_DESC));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3: /* IsLeapYear */
|
||||
switch ( *nParam ) {
|
||||
case 0:
|
||||
SO_StringCopy(pDesc,getText(DFA_ISLEAPYEAR_DESC));
|
||||
break;
|
||||
case 1:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_DATE_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_PAR_DATE_DESC)); /* StarCalc Value */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4: /* DaysInMonth */
|
||||
switch ( *nParam ) {
|
||||
case 0:
|
||||
SO_StringCopy(pDesc,getText(DFA_DAYSINMONTH_DESC));
|
||||
break;
|
||||
case 1:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_DATE_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_PAR_DATE_DESC)); /* StarCalc Value */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 5: /* DaysInYear */
|
||||
switch ( *nParam ) {
|
||||
case 0:
|
||||
SO_StringCopy(pDesc,getText(DFA_DAYSINYEAR_DESC));
|
||||
break;
|
||||
case 1:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_DATE_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_PAR_DATE_DESC)); /* StarCalc Value */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 6: /* WeeksInYear */
|
||||
switch ( *nParam ) {
|
||||
case 0:
|
||||
SO_StringCopy(pDesc,getText(DFA_WEEKSINYEAR_DESC));
|
||||
break;
|
||||
case 1:
|
||||
SO_StringCopy(pName,getText(DFA_PAR_DATE_NAME));
|
||||
SO_StringCopy(pDesc,getText(DFA_PAR_DATE_DESC)); /* StarCalc Value */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,178 +0,0 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
#include "sc.hrc" // Definition RID_XXX in StarCalc
|
||||
#include "dfa.hrc"
|
||||
|
||||
/* #i54546# The code belonging to this resource file is sample code for the
|
||||
* legacy AddIn interface. The interface is still supported, but deprecated.
|
||||
* The strings here were displayed in the function wizard. To prevent
|
||||
* duplicated and useless translation effort (functions and strings are also
|
||||
* part of the new scaddin module), the strings here are now layed out as fixed
|
||||
* untranslatable strings. The entire mechanism with the ../util/cl2c.pl perl
|
||||
* script merging the raw .cl and the .src during build time didn't work
|
||||
* anymore anyway, since we switched from MS-LCIDs / telephone area codes to
|
||||
* ISO codes for resources, and introduced localize.sdf files. Returned was
|
||||
* always an empty string. Now at least the fixed English string is returned.
|
||||
* */
|
||||
|
||||
Resource RID_SC_ADDIN_DFA
|
||||
{
|
||||
String DFA_PAR_DATE1_NAME // Name of Date1 Parameter
|
||||
{
|
||||
Text = "Date 1";
|
||||
};
|
||||
String DFA_PAR_DATE2_NAME // Name of Date2 Parameter
|
||||
{
|
||||
Text = "Date 2";
|
||||
};
|
||||
String DFA_PAR_MODE_NAME // Name of Mode Parameter
|
||||
{
|
||||
Text = "Mode";
|
||||
};
|
||||
|
||||
String DFA_PAR_DATE_NAME // Name of Date Parameter
|
||||
{
|
||||
Text = "Date";
|
||||
};
|
||||
|
||||
String DFA_PAR_DATE_DESC // Description of Date Parameter
|
||||
{
|
||||
Text = "Internal number of the date";
|
||||
};
|
||||
|
||||
/*-=======================================================================*/
|
||||
String DFA_WEEK_NAME // Name
|
||||
{
|
||||
Text = "Weeks";
|
||||
};
|
||||
String DFA_WEEK_DESC // Description
|
||||
{
|
||||
Text = "Returns the difference in weeks between two dates";
|
||||
};
|
||||
String DFA_WEEK_PAR1_DESC // Description of Parameter 1
|
||||
{
|
||||
Text = "The end date for calculating the difference in weeks";
|
||||
};
|
||||
String DFA_WEEK_PAR2_DESC // Description of Parameter 2
|
||||
{
|
||||
Text = "The start date for calculating the difference weeks";
|
||||
};
|
||||
String DFA_WEEK_PAR3_DESC // Description of Parameter 3
|
||||
{
|
||||
Text = "Type of difference calculation: mode=0 means the interval, mode=1 means calendar weeks";
|
||||
};
|
||||
|
||||
/*-=======================================================================*/
|
||||
|
||||
String DFA_MONTHS_NAME // Name
|
||||
{
|
||||
Text = "Months";
|
||||
};
|
||||
String DFA_MONTHS_DESC // Description
|
||||
{
|
||||
Text = "Determines the number of months between two dates";
|
||||
};
|
||||
String DFA_MONTHS_PAR1_DESC // Description of Parameter 1
|
||||
{
|
||||
Text = "The end date for calculating the difference in months";
|
||||
};
|
||||
String DFA_MONTHS_PAR2_DESC // Description of Parameter 2
|
||||
{
|
||||
Text = "The start date for calculating the difference in months";
|
||||
};
|
||||
String DFA_MONTHS_PAR3_DESC // Description of Parameter 2
|
||||
{
|
||||
Text = "Type of difference calculation: Mode = 0 means interval, mode = 1 means in calendar months";
|
||||
};
|
||||
|
||||
/*-=======================================================================*/
|
||||
|
||||
String DFA_YEARS_NAME // Name
|
||||
{
|
||||
Text = "Years";
|
||||
};
|
||||
String DFA_YEARS_DESC // Description
|
||||
{
|
||||
Text = "Returns the difference in years between two dates";
|
||||
};
|
||||
String DFA_YEARS_PAR1_DESC // Description of Parameter 1
|
||||
{
|
||||
Text = "The end date for calculating the difference in years";
|
||||
};
|
||||
String DFA_YEARS_PAR2_DESC // Description of Parameter 2
|
||||
{
|
||||
Text = "The start date for calculating the difference in years";
|
||||
};
|
||||
String DFA_YEARS_PAR3_DESC // Description of Parameter 2
|
||||
{
|
||||
Text = "Type of difference calculation: Mode=0 means interval, mode=1 means in calendar years.";
|
||||
};
|
||||
|
||||
/*-=======================================================================*/
|
||||
|
||||
String DFA_ISLEAPYEAR_NAME // Name
|
||||
{
|
||||
Text = "IsLeapYear";
|
||||
};
|
||||
String DFA_ISLEAPYEAR_DESC // Description
|
||||
{
|
||||
Text = "Returns 1 (TRUE) if a leap year is used, otherwise 0 (FALSE) is returned";
|
||||
};
|
||||
|
||||
/*-=======================================================================*/
|
||||
|
||||
String DFA_DAYSINMONTH_NAME // Name
|
||||
{
|
||||
Text = "DaysInMonth";
|
||||
};
|
||||
String DFA_DAYSINMONTH_DESC // Description
|
||||
{
|
||||
Text = "Returns the number of days in the month in relation to the date entered";
|
||||
};
|
||||
|
||||
/*-=======================================================================*/
|
||||
|
||||
String DFA_DAYSINYEAR_NAME // Name
|
||||
{
|
||||
Text = "DaysInYear";
|
||||
};
|
||||
String DFA_DAYSINYEAR_DESC // Description
|
||||
{
|
||||
Text = "Returns the number of days in a year in relation to the date entered";
|
||||
};
|
||||
|
||||
/*-=======================================================================*/
|
||||
|
||||
String DFA_WEEKSINYEAR_NAME // Name
|
||||
{
|
||||
Text = "WeeksInYear";
|
||||
};
|
||||
String DFA_WEEKSINYEAR_DESC // Description
|
||||
{
|
||||
Text = "Returns the number of weeks in the year in relation to a date";
|
||||
};
|
||||
};
|
|
@ -1,142 +0,0 @@
|
|||
#*************************************************************************
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
#
|
||||
# This file is part of OpenOffice.org.
|
||||
#
|
||||
# OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# only, as published by the Free Software Foundation.
|
||||
#
|
||||
# OpenOffice.org is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License version 3 for more details
|
||||
# (a copy is included in the LICENSE file that accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# version 3 along with OpenOffice.org. If not, see
|
||||
# <http://www.openoffice.org/license.html>
|
||||
# for a copy of the LGPLv3 License.
|
||||
#
|
||||
#*************************************************************************
|
||||
|
||||
PRJ=..$/..
|
||||
|
||||
PRJNAME=sc
|
||||
TARGET=dfa
|
||||
LIBTARGET=NO
|
||||
|
||||
# --- Settings -----------------------------------------------------
|
||||
|
||||
.INCLUDE: settings.mk
|
||||
|
||||
CL2C=+$(PERL) $(MISC)$/cl2c.pl
|
||||
CL2CRID=RID_SC_ADDIN_DFA
|
||||
CL2CSRC=$(TARGET).src
|
||||
|
||||
# --- Files --------------------------------------------------------
|
||||
|
||||
CFILES= $(MISC)$/x$(TARGET).c
|
||||
|
||||
SLOFILES= \
|
||||
$(SLO)$/x$(TARGET).obj
|
||||
|
||||
# ==========================================================================
|
||||
|
||||
SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
|
||||
SHL1IMPLIB= i$(TARGET)
|
||||
SHL1OBJS= $(SLO)$/x$(TARGET).obj
|
||||
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
|
||||
|
||||
.IF "$(GUI)" == "WNT"
|
||||
SHL1STDLIBS= $(GDI32LIB) $(ADVAPI32LIB) $(COMDLG32LIB) \
|
||||
$(UUIDLIB) $(OLE32LIB) $(SHELL32LIB) $(WINSPOOLLIB)
|
||||
.IF "$(GVER)" == "W40"
|
||||
SHL1STDLIBS= $(SHL1STDLIBS) $(COMCTL32LIB)
|
||||
.ENDIF
|
||||
.ENDIF
|
||||
|
||||
# --- Targets -------------------------------------------------------
|
||||
|
||||
ALLTAR: $(MISC)$/$(TARGET).lst
|
||||
|
||||
|
||||
.INCLUDE: target.mk
|
||||
|
||||
$(MISC)$/x$(TARGET).c: $(TARGET).cl $(CL2CSRC)
|
||||
$(CL2C) $(TARGET).cl $(MISC)$/x$(TARGET).c $(CL2CSRC) $(CL2CRID)
|
||||
|
||||
# copy file to include in package
|
||||
$(INCCOM)$/xlang.h : $(SOLARINCDIR)$/i18npool$/lang.h
|
||||
@$(COPY) $(SOLARINCDIR)$/i18npool$/lang.h $@
|
||||
|
||||
|
||||
$(SLOFILES) : $(INCCOM)$/xlang.h $(CFILES)
|
||||
|
||||
$(MISC)$/$(TARGET).lst : \
|
||||
$(MISC)$/x$(TARGET).c \
|
||||
$(INCCOM)$/xlang.h \
|
||||
..$/inc$/$(TARGET).hrc \
|
||||
..$/inc$/addin.h
|
||||
echo $< > $@
|
||||
|
||||
# --- Def-File ---
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Windows DEF File
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
.IF "$(GUI)"=="WNT"
|
||||
|
||||
$(MISC)$/$(SHL1TARGET).def: makefile.mk
|
||||
@echo ------------------------------
|
||||
@echo Making: $@
|
||||
@echo LIBRARY $(SHL1TARGET)>$@
|
||||
.IF "$(COM)"!="GCC"
|
||||
@echo DESCRIPTION 'DateF StarCalc Addin DLL'>>$@
|
||||
@echo DATA READ WRITE NONSHARED>>$@
|
||||
.ENDIF
|
||||
@echo EXPORTS>>$@
|
||||
@echo GetFunctionCount>>$@
|
||||
@echo GetFunctionData>>$@
|
||||
@echo GetParameterDescription>>$@
|
||||
@echo SetLanguage >>$@
|
||||
@echo ScDate_GetDiffWeeks>>$@
|
||||
@echo ScDate_GetDiffMonths>>$@
|
||||
@echo ScDate_GetDiffYears>>$@
|
||||
@echo ScDate_IsLeapYear>>$@
|
||||
@echo ScDate_DaysInMonth>>$@
|
||||
@echo ScDate_DaysInYear>>$@
|
||||
@echo ScDate_WeeksInYear>>$@
|
||||
|
||||
.ENDIF
|
||||
|
||||
.IF "$(GUI)"=="OS2"
|
||||
|
||||
$(MISC)$/$(SHL1TARGET).def: makefile.mk
|
||||
@echo ------------------------------
|
||||
@echo Making: $@
|
||||
@echo LIBRARY $(SHL1TARGET) INITINSTANCE TERMINSTANCE >$@
|
||||
@echo DESCRIPTION 'DateF StarCalc Addin DLL'>>$@
|
||||
@echo DATA MULTIPLE>>$@
|
||||
@echo EXPORTS>>$@
|
||||
@echo _GetFunctionCount>>$@
|
||||
@echo _GetFunctionData>>$@
|
||||
@echo _GetParameterDescription>>$@
|
||||
@echo _SetLanguage >>$@
|
||||
@echo _ScDate_GetDiffWeeks>>$@
|
||||
@echo _ScDate_GetDiffMonths>>$@
|
||||
@echo _ScDate_GetDiffYears>>$@
|
||||
@echo _ScDate_IsLeapYear>>$@
|
||||
@echo _ScDate_DaysInMonth>>$@
|
||||
@echo _ScDate_DaysInYear>>$@
|
||||
@echo _ScDate_WeeksInYear>>$@
|
||||
|
||||
.ENDIF
|
||||
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _ADDIN_H
|
||||
#define _ADDIN_H
|
||||
|
||||
#ifndef _SOLAR_H
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#undef NULL
|
||||
#define NULL 0
|
||||
|
||||
typedef unsigned char BOOL;
|
||||
typedef unsigned char BYTE;
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned long ULONG;
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef SUPD
|
||||
/* enable all new interface features */
|
||||
#define SUPD 9999
|
||||
#endif
|
||||
|
||||
/* all character string returns are limited to 255+1 chars */
|
||||
#define SO_CHARSTRING_MAX 256
|
||||
#define SO_StringCopy( dst, src ) \
|
||||
(strncpy( dst, src, SO_CHARSTRING_MAX ), dst[SO_CHARSTRING_MAX-1] = '\0')
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PTR_DOUBLE,
|
||||
PTR_STRING,
|
||||
PTR_DOUBLE_ARR,
|
||||
PTR_STRING_ARR,
|
||||
PTR_CELL_ARR,
|
||||
NONE
|
||||
} ParamType;
|
||||
|
||||
#ifndef WIN
|
||||
#ifdef WNT
|
||||
#define CALLTYPE __cdecl
|
||||
#else
|
||||
#define CALLTYPE
|
||||
#endif
|
||||
#else
|
||||
#define PASCAL _pascal
|
||||
#define FAR _far
|
||||
#define CALLTYPE FAR PASCAL
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
extern "C" {
|
||||
|
||||
typedef void (CALLTYPE* AdvData)( double& nHandle, void* pData );
|
||||
|
||||
extern void CALLTYPE GetFunctionCount( USHORT& nCount );
|
||||
|
||||
extern void CALLTYPE GetFunctionData( USHORT& nNo,
|
||||
char* pFuncName,
|
||||
USHORT& nParamCount,
|
||||
ParamType* peType,
|
||||
char* pInternalName );
|
||||
|
||||
extern void CALLTYPE IsAsync( USHORT& nNo, ParamType* peType );
|
||||
|
||||
extern void CALLTYPE Advice( USHORT& nNo, AdvData& pfCallback );
|
||||
|
||||
extern void CALLTYPE Unadvice( double& nHandle );
|
||||
|
||||
|
||||
/* new in StarOffice 5.0 */
|
||||
|
||||
extern void CALLTYPE GetParameterDescription( USHORT& nNo, USHORT& nParam,
|
||||
char* pName, char* pDesc );
|
||||
|
||||
/* new in StarOffice 5.1 */
|
||||
|
||||
extern void CALLTYPE SetLanguage( USHORT& nLanguage );
|
||||
|
||||
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
typedef void (CALLTYPE* AdvData)( double* nHandle, void* pData );
|
||||
|
||||
extern void CALLTYPE GetFunctionCount( USHORT * nCount );
|
||||
|
||||
extern void CALLTYPE GetFunctionData( USHORT * nNo,
|
||||
char * pFuncName,
|
||||
USHORT * nParamCount,
|
||||
ParamType * peType,
|
||||
char * pInternalName );
|
||||
|
||||
extern void CALLTYPE IsAsync( USHORT * nNo, ParamType * peType );
|
||||
|
||||
extern void CALLTYPE Advice( USHORT * nNo, AdvData * pfCallback );
|
||||
|
||||
extern void CALLTYPE Unadvice( double * nHandle );
|
||||
|
||||
/* new in StarOffice 5.0 */
|
||||
|
||||
extern void CALLTYPE GetParameterDescription( USHORT* nNo, USHORT* nParam,
|
||||
char* pName, char* pDesc );
|
||||
|
||||
|
||||
/* new in StarOffice 5.1 */
|
||||
|
||||
extern void CALLTYPE SetLanguage( USHORT* nLanguage );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -1,61 +0,0 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
#ifndef SC_ADDIN_DFA_HRC
|
||||
#define SC_ADDIN_DFA_HRC
|
||||
|
||||
#define DFA_PAR_DATE1_NAME 1 /* Name of Date1 Parameter */
|
||||
#define DFA_PAR_DATE2_NAME 2 /* Name of Date2 Parameter */
|
||||
#define DFA_PAR_MODE_NAME 3 /* Name of Mode Parameter */
|
||||
#define DFA_PAR_DATE_NAME 4 /* Name of Date Parameter */
|
||||
#define DFA_PAR_DATE_DESC 5 /* Description of Date Parameter 1 */
|
||||
|
||||
#define DFA_WEEK_NAME 6 /* Name */
|
||||
#define DFA_WEEK_DESC 7 /* Description */
|
||||
#define DFA_WEEK_PAR1_DESC 8 /* Description of Parameter 1 */
|
||||
#define DFA_WEEK_PAR2_DESC 9 /* Description of Parameter 2 */
|
||||
#define DFA_WEEK_PAR3_DESC 10 /* Description of Parameter 3 */
|
||||
#define DFA_MONTHS_NAME 11 /* Name */
|
||||
#define DFA_MONTHS_DESC 12 /* Description */
|
||||
#define DFA_MONTHS_PAR1_DESC 13 /* Description of Parameter 1 */
|
||||
#define DFA_MONTHS_PAR2_DESC 14 /* Description of Parameter 2 */
|
||||
#define DFA_MONTHS_PAR3_DESC 15 /* Description of Parameter 2 */
|
||||
#define DFA_YEARS_NAME 16 /* Name */
|
||||
#define DFA_YEARS_DESC 17 /* Description */
|
||||
#define DFA_YEARS_PAR1_DESC 18 /* Description of Parameter 1 */
|
||||
#define DFA_YEARS_PAR2_DESC 19 /* Description of Parameter 2 */
|
||||
#define DFA_YEARS_PAR3_DESC 20 /* Description of Parameter 2 */
|
||||
#define DFA_ISLEAPYEAR_NAME 21 /* Name */
|
||||
#define DFA_ISLEAPYEAR_DESC 22 /* Description */
|
||||
#define DFA_DAYSINMONTH_NAME 23 /* Name */
|
||||
#define DFA_DAYSINMONTH_DESC 24 /* Description */
|
||||
#define DFA_DAYSINYEAR_NAME 25 /* Name */
|
||||
#define DFA_DAYSINYEAR_DESC 26 /* Description */
|
||||
#define DFA_WEEKSINYEAR_NAME 27 /* Name */
|
||||
#define DFA_WEEKSINYEAR_DESC 28 /* Description */
|
||||
|
||||
#endif
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
#ifndef SC_ADDIN_ROT13_HRC
|
||||
#define SC_ADDIN_ROT13_HRC
|
||||
|
||||
#define ROT13_DESC 1
|
||||
#define ROT13_PAR1_NAME 2
|
||||
#define ROT13_PAR1_DESC 3
|
||||
|
||||
#endif
|
|
@ -1,45 +0,0 @@
|
|||
#*************************************************************************
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
#
|
||||
# This file is part of OpenOffice.org.
|
||||
#
|
||||
# OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# only, as published by the Free Software Foundation.
|
||||
#
|
||||
# OpenOffice.org is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License version 3 for more details
|
||||
# (a copy is included in the LICENSE file that accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# version 3 along with OpenOffice.org. If not, see
|
||||
# <http://www.openoffice.org/license.html>
|
||||
# for a copy of the LGPLv3 License.
|
||||
#
|
||||
#*************************************************************************
|
||||
|
||||
PRJ=..
|
||||
|
||||
PRJNAME=sc
|
||||
TARGET=addin
|
||||
|
||||
# --- Settings -----------------------------------------------------
|
||||
|
||||
.INCLUDE: settings.mk
|
||||
|
||||
# --- Targets -------------------------------------------------------
|
||||
|
||||
.INCLUDE: target.mk
|
||||
|
||||
ALLTAR: $(MISC)$/cl2c.pl
|
||||
|
||||
$(MISC)$/cl2c.pl: util/cl2c.pl
|
||||
tr -d "\015" < util$/cl2c.pl > $@
|
||||
chmod +rw $@
|
|
@ -1,11 +0,0 @@
|
|||
UDK_3_0_0 {
|
||||
global:
|
||||
GetFunctionCount;
|
||||
GetFunctionData;
|
||||
GetParameterDescription;
|
||||
SetLanguage;
|
||||
Rot13;
|
||||
|
||||
local:
|
||||
*;
|
||||
};
|
|
@ -1,88 +0,0 @@
|
|||
#*************************************************************************
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
#
|
||||
# This file is part of OpenOffice.org.
|
||||
#
|
||||
# OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# only, as published by the Free Software Foundation.
|
||||
#
|
||||
# OpenOffice.org is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License version 3 for more details
|
||||
# (a copy is included in the LICENSE file that accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# version 3 along with OpenOffice.org. If not, see
|
||||
# <http://www.openoffice.org/license.html>
|
||||
# for a copy of the LGPLv3 License.
|
||||
#
|
||||
#*************************************************************************
|
||||
|
||||
PRJ=..$/..
|
||||
|
||||
PRJNAME=sc
|
||||
TARGET=rot
|
||||
LIBTARGET=NO
|
||||
|
||||
|
||||
# --- Settings -----------------------------------------------------
|
||||
|
||||
.INCLUDE: settings.mk
|
||||
|
||||
CL2C=+$(PERL) $(MISC)$/cl2c.pl
|
||||
CL2CRID=RID_SC_ADDIN_ROT13
|
||||
CL2CSRC=$(TARGET)13.src
|
||||
|
||||
# --- Files --------------------------------------------------------
|
||||
|
||||
CFILES= $(MISC)$/x$(TARGET).c
|
||||
|
||||
SLOFILES= \
|
||||
$(SLO)$/x$(TARGET).obj
|
||||
|
||||
# ==========================================================================
|
||||
|
||||
SHL1TARGET= rot$(DLLPOSTFIX)
|
||||
SHL1IMPLIB= irot
|
||||
SHL1OBJS= $(SLO)$/x$(TARGET).obj
|
||||
|
||||
SHL1VERSIONMAP=exports.map
|
||||
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
|
||||
DEF1NAME=$(SHL1TARGET)
|
||||
|
||||
.IF "$(GUI)" == "WNT"
|
||||
SHL1STDLIBS= $(GDI32LIB) $(ADVAPI32LIB) $(COMDLG32LIB) \
|
||||
$(UUIDLIB) $(OLE32LIB) $(SHELL32LIB) $(WINSPOOLLIB)
|
||||
.IF "$(GVER)" == "W40"
|
||||
SHL1STDLIBS= $(SHL1STDLIBS) $(COMCTL32LIB)
|
||||
.ENDIF # W40
|
||||
.ENDIF # WNT
|
||||
|
||||
# --- Targets -------------------------------------------------------
|
||||
|
||||
ALLTAR: $(MISC)$/rot.lst
|
||||
|
||||
.INCLUDE: target.mk
|
||||
|
||||
$(MISC)$/x$(TARGET).c: $(TARGET)13.cl $(CL2CSRC) $(MISC)$/cl2c.pl
|
||||
$(CL2C) $(TARGET)13.cl $(MISC)$/x$(TARGET).c $(CL2CSRC) $(CL2CRID)
|
||||
|
||||
# copy file to include in package
|
||||
$(INCCOM)$/xlang.h : $(SOLARINCDIR)$/i18npool$/lang.h
|
||||
@$(COPY) $(SOLARINCDIR)$/i18npool$/lang.h $@
|
||||
|
||||
$(SLOFILES) : $(INCCOM)$/xlang.h $(CFILES)
|
||||
|
||||
$(MISC)$/rot.lst : \
|
||||
$(MISC)$/x$(TARGET).c \
|
||||
$(INCCOM)$/xlang.h \
|
||||
..$/inc$/rot13.hrc \
|
||||
..$/inc$/addin.h
|
||||
@echo $< > $@
|
|
@ -1,158 +0,0 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
/* static char rot13_Id[]="@(#) StarCalc Rot13 AddIn (c) 1998-2000 Sun Microsystems, Inc."; */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <xlang.h>
|
||||
#include <addin.h>
|
||||
#include <rot13.hrc>
|
||||
|
||||
/**
|
||||
* the current language the Addin is using
|
||||
*/
|
||||
static USHORT _nLanguage=LANGUAGE_ENGLISH;
|
||||
|
||||
/**
|
||||
* StarCalc calls this function to set a new current Language for the Addin
|
||||
*
|
||||
* @param *nLanguage
|
||||
*
|
||||
*/
|
||||
void CALLTYPE SetLanguage( USHORT* nLanguage )
|
||||
{
|
||||
_nLanguage = GetNeutralLanguage( *nLanguage );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tell StarCalc how many new functions this Addin provides.
|
||||
*
|
||||
* @param *nCount - returns the number of functions which are exported to StarCalc
|
||||
*
|
||||
*/
|
||||
void CALLTYPE GetFunctionCount( USHORT *nCount )
|
||||
{
|
||||
*nCount = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides neccessary data for each new function to StarCalc
|
||||
*
|
||||
* @param *nNo Input: Function number between 0 and nCount - 1
|
||||
* @param *pFuncName Output: Functionname which should be called in the AddIn-DLL
|
||||
* @param *nParamCount Output: Number of Parameter. Must be greater than 0, because there's always a return-Value. Maximum is 16.
|
||||
* @param *peType Output: Pointer to arrray with exactly 16 variables of typ Paramtype. nParamCount Entries are set to the type of the corresponding Parameters.
|
||||
* @param *pInternalName Output: Functionname as seen by the Spreadsheet user
|
||||
*
|
||||
* @see #GetFunctionCount, #GetParameterDescription
|
||||
*
|
||||
*/
|
||||
void CALLTYPE GetFunctionData( USHORT * nNo,
|
||||
char * pFuncName,
|
||||
USHORT * nParamCount,
|
||||
ParamType * peType,
|
||||
char * pInternalName )
|
||||
{
|
||||
|
||||
switch( *nNo ) {
|
||||
case 0:
|
||||
/* the function name is the same in all languages */
|
||||
SO_StringCopy( pInternalName, "Rot13" );
|
||||
SO_StringCopy( pFuncName, "Rot13" );
|
||||
peType[0] = PTR_STRING;
|
||||
peType[1] = PTR_STRING;
|
||||
*nParamCount=2;
|
||||
break;
|
||||
default:
|
||||
*nParamCount = 0;
|
||||
*pFuncName = 0;
|
||||
*pInternalName = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides descriptions for each new function to StarCalc
|
||||
* which are shown is the autopilot
|
||||
*
|
||||
* @param *nNo Input Parameter, Function number between 0 and nCount - 1
|
||||
* @param *nParam Parameter Number
|
||||
* @param *pName Output: Name of the parameter
|
||||
* @param *pDesc Output: Description of the parameter
|
||||
*
|
||||
* @see #GetFunctionCount, #GetParameterDescription
|
||||
*/
|
||||
void CALLTYPE GetParameterDescription( USHORT* nNo, USHORT* nParam,
|
||||
char* pName, char* pDesc )
|
||||
{
|
||||
*pName = 0;
|
||||
*pDesc = 0;
|
||||
|
||||
|
||||
switch ( *nNo ) {
|
||||
case 0:
|
||||
switch ( *nParam ) {
|
||||
case 0:
|
||||
SO_StringCopy(pDesc,getText(ROT13_DESC));
|
||||
break;
|
||||
case 1:
|
||||
SO_StringCopy(pName,getText(ROT13_PAR1_NAME));
|
||||
SO_StringCopy(pDesc,getText(ROT13_PAR1_DESC));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ROT13 Algorithm, each alphabetical character of the text is rotated by 13 in the alphabet
|
||||
*
|
||||
* @param *ret
|
||||
* @param *src
|
||||
*
|
||||
* ER: well, my personal favorite algorithm is
|
||||
* main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}
|
||||
* but for clarification we do it somehow different here ;-)
|
||||
*/
|
||||
void CALLTYPE Rot13(char *ret, char *src)
|
||||
{
|
||||
if ( ! ret ) return;
|
||||
if ( ! src ) *ret='\0';
|
||||
|
||||
for(;src && *src; src++ , ret++) {
|
||||
*ret=*src;
|
||||
if (*ret >= 'A' && *ret <= 'Z') {
|
||||
if ( (*ret +=13) > 'Z' ) *ret-=26;
|
||||
} else if (*ret >= 'a' && *ret < 'n') {
|
||||
*ret +=13;
|
||||
} else if (*ret >= 'n' && *ret <= 'z') {
|
||||
*ret -=13;
|
||||
}
|
||||
}
|
||||
*ret=*src;
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
#include "sc.hrc" // Definition RID_XXX in StarCalc
|
||||
#include "rot13.hrc"
|
||||
|
||||
/* #i54546# The code belonging to this resource file is sample code for the
|
||||
* legacy AddIn interface. The interface is still supported, but deprecated.
|
||||
* The strings here were displayed in the function wizard. To prevent
|
||||
* duplicated and useless translation effort (functions and strings are also
|
||||
* part of the new scaddin module), the strings here are now layed out as fixed
|
||||
* untranslatable strings. The entire mechanism with the ../util/cl2c.pl perl
|
||||
* script merging the raw .cl and the .src during build time didn't work
|
||||
* anymore anyway, since we switched from MS-LCIDs / telephone area codes to
|
||||
* ISO codes for resources, and introduced localize.sdf files. Returned was
|
||||
* always an empty string. Now at least the fixed English string is returned.
|
||||
* */
|
||||
|
||||
Resource RID_SC_ADDIN_ROT13
|
||||
{
|
||||
String ROT13_DESC // Description
|
||||
{
|
||||
Text = "ROT13 Algorithm, each alphabetical character of the text is rotated by 13 in the alphabet";
|
||||
};
|
||||
|
||||
String ROT13_PAR1_NAME // Name of Parameter 1
|
||||
{
|
||||
Text = "Text";
|
||||
};
|
||||
|
||||
String ROT13_PAR1_DESC // Description of Parameter 1
|
||||
{
|
||||
Text = "The text that is to be rotated";
|
||||
};
|
||||
};
|
|
@ -1,238 +0,0 @@
|
|||
#!/usr/solar/bin/perl
|
||||
|
||||
##########################################################################
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
#
|
||||
# This file is part of OpenOffice.org.
|
||||
#
|
||||
# OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# only, as published by the Free Software Foundation.
|
||||
#
|
||||
# OpenOffice.org is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License version 3 for more details
|
||||
# (a copy is included in the LICENSE file that accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# version 3 along with OpenOffice.org. If not, see
|
||||
# <http://www.openoffice.org/license.html>
|
||||
# for a copy of the LGPLv3 License.
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
if ( $#ARGV != 3 ) {
|
||||
print STDERR "usage: cl2c.pl <file.cl> <file.c> <file.src> <resname>\n";
|
||||
exit -1;
|
||||
}
|
||||
|
||||
$CL=$ARGV[0];
|
||||
$C=$ARGV[1];
|
||||
$SRC=$ARGV[2];
|
||||
$RNAME=$ARGV[3];
|
||||
|
||||
sub sconv
|
||||
{
|
||||
local($s)=@_[0];
|
||||
local($o,$c);
|
||||
$_="";
|
||||
foreach $o ( unpack("C*",$s) ) {
|
||||
$c=chr($o);
|
||||
if ( $o >= 32 && $o < 127 ) {
|
||||
$_ .= $c;
|
||||
} else {
|
||||
$_ .= sprintf("\\%o", $o);
|
||||
}
|
||||
}
|
||||
return $_;
|
||||
}
|
||||
|
||||
|
||||
sub makeneutral {
|
||||
|
||||
print COUT "\n\n/**\n";
|
||||
print COUT " * Get neutral language for specific language.\n";
|
||||
print COUT " * This simplifies the getText switch cases and allows to handle\n";
|
||||
print COUT " * previously unknown language derivates due to foreign installations.\n";
|
||||
print COUT " * If you want to distinguish between some dialects change this function\n";
|
||||
print COUT " * to return the desired nLang before doing the bit masking stuff.\n";
|
||||
print COUT " * See xlang.h for defined LANGUAGE_*\n";
|
||||
print COUT " */\n";
|
||||
|
||||
# taken from tools/source/intntl/intn.cxx International::GetNeutralLanguage
|
||||
print COUT "static USHORT GetNeutralLanguage( USHORT nLang )\n";
|
||||
print COUT "{\n";
|
||||
print COUT "\tUSHORT nPrimLang;\n";
|
||||
print COUT "\n";
|
||||
print COUT "\t/* ignore LANGUAGE_USER* */\n";
|
||||
print COUT "\tif ( (nLang & 0x03FF) >= 0x0200 )\n";
|
||||
print COUT "\t return nLang;\n";
|
||||
print COUT "\n";
|
||||
print COUT "\tnLang &= 0x03FF;\n";
|
||||
print COUT "\n";
|
||||
print COUT "\tnPrimLang = nLang | 0x0400;\n";
|
||||
print COUT "\n";
|
||||
print COUT "\tswitch ( nPrimLang )\n";
|
||||
print COUT "\t{\n";
|
||||
print COUT "\t\tcase LANGUAGE_CHINESE_TRADITIONAL:\n";
|
||||
print COUT "\t\t\tnLang = LANGUAGE_CHINESE;\n";
|
||||
print COUT "\t\t\tbreak;\n";
|
||||
print COUT "\t\tcase LANGUAGE_ENGLISH_US:\n";
|
||||
print COUT "\t\t\tnLang = LANGUAGE_ENGLISH;\n";
|
||||
print COUT "\t\t\tbreak;\n";
|
||||
print COUT "\t\tcase LANGUAGE_NORWEGIAN_BOKMAL:\n";
|
||||
print COUT "\t\t\tnLang = LANGUAGE_NORWEGIAN;\n";
|
||||
print COUT "\t\t\tbreak;\n";
|
||||
print COUT "\t\tcase LANGUAGE_PORTUGUESE_BRAZILIAN:\n";
|
||||
print COUT "\t\t\tnLang = LANGUAGE_PORTUGUESE;\n";
|
||||
print COUT "\t\t\tbreak;\n";
|
||||
print COUT "\n";
|
||||
print COUT "\t\tdefault:\n";
|
||||
print COUT "\t\t\tnLang = nPrimLang;\n";
|
||||
print COUT "\t\t\tbreak;\n";
|
||||
print COUT "\t}\n";
|
||||
print COUT "\n";
|
||||
print COUT "\treturn nLang;\n";
|
||||
print COUT "}\n";
|
||||
print COUT "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub maketext {
|
||||
|
||||
print COUT "\n\n/**\n";
|
||||
print COUT " * Get text resource for current language.\n";
|
||||
print COUT " * Remember that 8-bit characters are shown in\n";
|
||||
print COUT " * system dependend code pages!\n";
|
||||
print COUT " * To get correct results you will have to distuinguish\n";
|
||||
print COUT " * for example between UNIX and WIN and OS2 target systems.\n";
|
||||
print COUT " */\n";
|
||||
|
||||
print COUT "static char* getText( int nResource )\n{\n";
|
||||
print COUT "\tswitch( nResource ) {\n";
|
||||
|
||||
$resflag=0;
|
||||
$strname="";
|
||||
$cnt=0;
|
||||
$text_english="";
|
||||
|
||||
while (<SRCIN>) {
|
||||
$resflag=1 if ( /Resource\s$RNAME/ );
|
||||
|
||||
if ( /\{/ ) {
|
||||
if ( ++$cnt == 2 ) {
|
||||
# start language
|
||||
$text_english="";
|
||||
print COUT "\t\t\tswitch( _nLanguage ) {\n";
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
if ( /\}/ ) {
|
||||
if ( --$cnt == 1 ) {
|
||||
# end language
|
||||
|
||||
if ( $text_english ne "" ) {
|
||||
print COUT "\t\t\t\tcase LANGUAGE_ENGLISH:\n\t\t\t\tdefault:\n";
|
||||
print COUT "\t\t\t\treturn(" . $text_english . ")\;\n";
|
||||
}
|
||||
|
||||
print COUT "\t\t\t}\n\t\t\tbreak;\n";
|
||||
next;
|
||||
} elsif ( $cnt == 0 ) {
|
||||
# end of resource
|
||||
$resflag=0;
|
||||
print COUT "\t\tdefault:\n\t\t\tbreak;\n";
|
||||
print COUT "\t}\n\treturn(\"\");\n}\n";
|
||||
next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $resflag && $cnt == 1) {
|
||||
if ( /\sString\s(([A-Z]|\_|[0-9]|[a-z])*)/ ) {
|
||||
$strname=$1;
|
||||
print COUT "\t\tcase " . $strname . ":\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ( $cnt == 2 && /^\s*Text/ ) {
|
||||
$langname="german";
|
||||
($textdef,@textx)=split(/=/);
|
||||
$text=join("=",@textx);
|
||||
if ( $textdef =~ /\[\s+(.*)\s+\]/ ) {
|
||||
$langname=$1;
|
||||
}
|
||||
else {
|
||||
$langname="ENGLISH_US"; # no [...] => not to be translated
|
||||
}
|
||||
|
||||
$langname="LANGUAGE_" . uc($langname);
|
||||
|
||||
chop($text) while ( $text=~/(\r|\n|\;)$/ );
|
||||
$text=sconv($text);
|
||||
# english_us, not english because it's developer's pigeon
|
||||
if ( $langname eq "LANGUAGE_ENGLISH_US" ) {
|
||||
$text_english=$text;
|
||||
}
|
||||
# ISO coded, obtain at least the default
|
||||
elsif ( $langname =~ /^LANGUAGE_EN-US$/ ) {
|
||||
$text_english=$text;
|
||||
}
|
||||
# we don't know about USER languages, ENGLISH will be appended later
|
||||
elsif ( ! ( $langname =~ /LANGUAGE_USER/ || $langname =~ /^LANGUAGE_ENGLISH$/ ) ) {
|
||||
# ER 28.04.99: for the moment only German and English are
|
||||
# exported, because we have a problem with non-existing
|
||||
# character code tables for systems other than Windoze.
|
||||
# => Chinese would be definitely mixed up and we don't
|
||||
# want to insult anybody.. others like Spanish would look
|
||||
# very ugly, but we'll have to live with bad German Umlauts.
|
||||
if ( $langname =~ /LANGUAGE_(GERMAN|ENGLISH)/ ) {
|
||||
print COUT "\t\t\t\tcase " . $langname . ":\n";
|
||||
print COUT "\t\t\t\treturn(" . $text . ")\;\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
makeneutral();
|
||||
|
||||
}
|
||||
|
||||
open(CLIN,"<$CL") || die "can not open $CL\n";
|
||||
open(SRCIN,"<$SRC") || die "can not open $CL\n";
|
||||
open(COUT,">$C") || die "can not open $CL\n";
|
||||
|
||||
$ccnt=0;
|
||||
$incomment=0;
|
||||
while(<CLIN>) {
|
||||
if ( /^\/\*--(-*)/ ) {
|
||||
$incomment=1;
|
||||
$ccnt++;
|
||||
}
|
||||
|
||||
print COUT $_ if ( $incomment==0 || $ccnt==1 );
|
||||
|
||||
&maketext() if ( /^static USHORT _nLanguage=/ );
|
||||
|
||||
if ( /(-*)--\*\/$/ ) {
|
||||
$incomment=0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close(CLIN);
|
||||
close(SRCIN);
|
||||
close(COUT);
|
||||
|
||||
exit 0;
|
||||
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#*************************************************************************
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
#
|
||||
# This file is part of OpenOffice.org.
|
||||
#
|
||||
# OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# only, as published by the Free Software Foundation.
|
||||
#
|
||||
# OpenOffice.org is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License version 3 for more details
|
||||
# (a copy is included in the LICENSE file that accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# version 3 along with OpenOffice.org. If not, see
|
||||
# <http://www.openoffice.org/license.html>
|
||||
# for a copy of the LGPLv3 License.
|
||||
#
|
||||
#*************************************************************************
|
||||
PRJ=..$/..
|
||||
|
||||
PRJNAME=sc
|
||||
TARGET=autil
|
||||
|
||||
|
||||
# --- Settings -----------------------------------------------------
|
||||
|
||||
.INCLUDE: settings.mk
|
||||
|
||||
$(BIN)$/addin.zip : \
|
||||
$(MISC)$/rot.lst \
|
||||
$(MISC)$/dfa.lst
|
||||
$(TYPE) $(MISC)$/rot.lst | tr -s " " "\n" | zip -@ -u -j -ll $(BIN)$/addin.zip $(CHECKZIPRESULT)
|
||||
$(TYPE) $(MISC)$/dfa.lst | tr -s " " "\n" | zip -@ -u -j -ll $(BIN)$/addin.zip $(CHECKZIPRESULT)
|
||||
chmod +rw $(BIN)$/addin.zip
|
||||
|
||||
.INCLUDE: target.mk
|
||||
|
||||
ALLTAR: $(BIN)$/addin.zip
|
||||
|
|
@ -9,7 +9,6 @@ sc sc\res\imglst\apptbx get - all sc_resap NULL
|
|||
sc sc\source\core\inc get - all sc_coinc NULL
|
||||
sc sc\source\ui\inc get - all sc_uiinc NULL
|
||||
sc sc\source\filter\inc get - all sc_fiinc NULL
|
||||
sc sc\addin\inc get - all sc_adinc NULL
|
||||
sc sc\sdi nmake - all sc_sdi sc_inc NULL
|
||||
sc sc\source\core\data nmake - all sc_data sc_sdi sc_inc NULL
|
||||
sc sc\source\core\src nmake - all sc_cosrc sc_sdi sc_inc NULL
|
||||
|
@ -43,9 +42,5 @@ sc sc\source\filter\rtf nmake - all sc_rtf sc_sdi sc_inc NULL
|
|||
sc sc\source\filter\html nmake - all sc_html sc_sdi sc_inc NULL
|
||||
sc sc\source\filter\xml nmake - all sc_xml sc_sdi sc_inc NULL
|
||||
sc sc\source\filter\xcl97 nmake - all sc_xcl97 sc_sdi sc_inc NULL
|
||||
sc sc\addin nmake - all sc_add sc_sdi sc_inc NULL
|
||||
sc sc\addin\datefunc nmake - all sc_addfu sc_add sc_sdi sc_inc NULL
|
||||
sc sc\addin\rot13 nmake - all sc_adrot sc_add sc_sdi sc_inc NULL
|
||||
sc sc\addin\util nmake - all sc_adutil sc_addfu sc_adrot sc_sdi sc_inc NULL
|
||||
sc sc\util nmake - all sc_util sc_addfu sc_adrot sc_adutil sc_app sc_attr sc_cctrl sc_cosrc sc_data sc_dbgui sc_dif sc_docsh sc_drfnc sc_excel sc_form sc_html sc_lotus sc_qpro sc_misc sc_name sc_nvipi sc_opt sc_page sc_rtf sc_scalc sc_style sc_tool sc_uisrc sc_undo sc_unobj sc_view sc_xcl97 sc_xml sc_acc sc_ftools sc_inc sc_vba NULL
|
||||
sc sc\util nmake - all sc_util sc_app sc_attr sc_cctrl sc_cosrc sc_data sc_dbgui sc_dif sc_docsh sc_drfnc sc_excel sc_form sc_html sc_lotus sc_qpro sc_misc sc_name sc_nvipi sc_opt sc_page sc_rtf sc_scalc sc_style sc_tool sc_uisrc sc_undo sc_unobj sc_view sc_xcl97 sc_xml sc_acc sc_ftools sc_inc sc_vba NULL
|
||||
sc sc\qa\unit nmake - all sc_qa_cppunit sc_util NULL
|
||||
|
|
Loading…
Reference in a new issue