diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
commit | 9ae5a91f7955e44d3b24a3f7741f9bca02ac7f24 (patch) | |
tree | 13c111a6380728f470fa177e679b80089a01efc4 /sc/addin/util |
initial import
Diffstat (limited to 'sc/addin/util')
-rw-r--r-- | sc/addin/util/cl2c.pl | 217 | ||||
-rw-r--r-- | sc/addin/util/makefile.mk | 89 |
2 files changed, 306 insertions, 0 deletions
diff --git a/sc/addin/util/cl2c.pl b/sc/addin/util/cl2c.pl new file mode 100644 index 000000000000..d0731a28d437 --- /dev/null +++ b/sc/addin/util/cl2c.pl @@ -0,0 +1,217 @@ +#!/usr/solar/bin/perl + +#------------------------------------------------------------------------ +# +# $Workfile: CL2C.PL $ +# +# $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sc/addin/util/cl2c.pl,v 1.1.1.1 2000-09-18 16:44:47 hr Exp $ +# +# Description: StarCalc AddIn Helper Create .c File from .cl and .src file +# +# (c) Copyright 1998 - 2000, Sun Microsystems, Inc. +# +# +#------------------------------------------------------------------------ + +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; + } + + $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; + } + # 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; + + diff --git a/sc/addin/util/makefile.mk b/sc/addin/util/makefile.mk new file mode 100644 index 000000000000..6600bae5bbd2 --- /dev/null +++ b/sc/addin/util/makefile.mk @@ -0,0 +1,89 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:44:47 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME=sc +TARGET=autil + + +# --- Settings ----------------------------------------------------- + +.INCLUDE: settings.mk + +$(BIN)$/addin.zip : \ + $(MISC)$/rot.lst \ + $(MISC)$/dfa.lst +.IF "$(GUI)"=="UNX" +# +$(TYPE) $(MISC)$/rot.lst | zip -@ -ll -j -u $(BIN)$/addin.zip + +$(TYPE) $(MISC)$/rot.lst | tr -s " " "\n" | zip -@ -u -j -ll $(BIN)$/addin.zip + +$(TYPE) $(MISC)$/dfa.lst | tr -s " " "\n" | zip -@ -u -j -ll $(BIN)$/addin.zip + +chmod +rw $(BIN)$/addin.zip +.ELSE + +$(TYPE) $< | zip -@ -u -j $(BIN)$/addin.zip +.ENDIF + +ALL: \ + $(BIN)$/addin.zip \ + ALLTAR + +.INCLUDE: target.mk + |