summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-06-03 14:33:05 +0200
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-06-03 14:33:05 +0200
commit4d1c1eae73df67c115f532b7078deaf7caf4cde8 (patch)
tree4f78780804635ba19f984e6b1244b5abc94c1795 /l10ntools
parentc20d10ab416cb1abb4f1e6ed3f75c379355db8c8 (diff)
parentd21adcdca61a7c54b3bf1584d80746dc0d2d1fc0 (diff)
slidecopy: merged latest DEV300.m80 changes
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/inc/wrdtrans.hxx87
-rw-r--r--l10ntools/java/receditor/java/transex3/model/SdfString.java25
-rw-r--r--l10ntools/scripts/fast_merge.pl10
-rw-r--r--[-rwxr-xr-x]l10ntools/scripts/localize.pl38
-rw-r--r--[-rwxr-xr-x]l10ntools/scripts/localize_old.pl56
-rw-r--r--l10ntools/source/help/HelpIndexerTool.java30
-rw-r--r--l10ntools/source/help/makefile.mk2
-rw-r--r--l10ntools/source/wrdtrans.cxx245
8 files changed, 44 insertions, 449 deletions
diff --git a/l10ntools/inc/wrdtrans.hxx b/l10ntools/inc/wrdtrans.hxx
deleted file mode 100644
index b0b65526a2a2..000000000000
--- a/l10ntools/inc/wrdtrans.hxx
+++ /dev/null
@@ -1,87 +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.
- *
- ************************************************************************/
-/*
-
-// OBSOLETE //
-
-#ifndef TX3_WRDTRANS_HXX
-#define TX3_WRDTRANS_HXX
-
-// USED
- // Base Classes
- // Components
-class WordTransTree;
-class WordTrans_ErrorList;
- // Parameters
-#include <tools/string.hxx>
-
-class WordTransformer
-{
- public:
- enum E_Error
- {
- OK = 0,
- ERROR_NO_WORDLIST,
- ERROR_HOTKEY,
- ERROR_OUTPUTSTRING_TOO_LONG,
- OTHER_ERROR
- };
-
- // LIFECYCLE
- WordTransformer();
- ~WordTransformer();
- BOOL LoadWordlist( /// @return False, if file could not be read, or there is already a wordlist loaded.
- const ByteString & i_sWordlist_Filepath,
- CharSet i_nWorkingCharSet = RTL_TEXTENCODING_MS_1252,
- CharSet i_nFileCharSet = RTL_TEXTENCODING_MS_1252 );
-
- // OPERATIONS
- USHORT Transform( /// @return The number of errors during transforming.
- ByteString & io_sText);
-
- // INQUIRY
- USHORT NrOfErrors() const;
- E_Error GetError(
- USHORT i_nNr, /// [0 .. NrOfErrors()-1], other values return an empty error.
- ByteString * o_pErrorText = 0) const; /// If o_pErrorText != 0, the String is filled with the description of the error.
-
- private:
- // SERVICE FUNCTION
- void CreateError();
-
- // DATA
- WordTransTree * dpTransformer;
- WordTrans_ErrorList *
- dpErrors;
-};
-
-
-
-#endif
-
-
-*/
diff --git a/l10ntools/java/receditor/java/transex3/model/SdfString.java b/l10ntools/java/receditor/java/transex3/model/SdfString.java
index 7419aeb5578b..7eec2151b7c3 100644
--- a/l10ntools/java/receditor/java/transex3/model/SdfString.java
+++ b/l10ntools/java/receditor/java/transex3/model/SdfString.java
@@ -97,32 +97,7 @@ public class SdfString {
public void setModuleName(String modulename) {
this.modulename = modulename;
}
- /*
- public String getRealFileName(){
- //String srcroot = "U:\\cws01\\l10ncleanup\\SRC680\\src.m213";//java.lang.System.getProperty( "SOLARSRC");
- //String isWindows = "4nt";//java.lang.System.getProperty( "USE_SHELL");
- String srcroot = java.lang.System.getProperty( "SOLARSRC" );
- String isWindows = java.lang.System.getProperty( "USE_SHELL" );
- //System.out.println("srcroot="+srcroot+" isWindows="+isWindows );
- //if( true ) return;
- //String relpath = sourceString.getFileId().substring( sourceString.getFileId().lastIndexOf("\\")
- // , sourceString.getFileId().length() );
- String filename;
- if( isWindows != null && isWindows.compareTo( "4nt") == 0 )
- {
- filename = srcroot + "\\" + //sourceString.getProject() + "\\" +
- sourceString.getFileId() +".recommand";
- }
- else
- {
- String filepart = sourceString.getFileId();
- filepart = filepart.replaceAll( "\\\\" , "/" );
- filename = srcroot + "/" + //sourceString.getProject() + "//" +
- filepart +".recommand";
- }
- return filename;
- }*/
public String getRealFileName(){
String filepart = sourceString.getFileId();
filepart = filepart.replaceAll( "\\\\" , "_" );
diff --git a/l10ntools/scripts/fast_merge.pl b/l10ntools/scripts/fast_merge.pl
index e2980fafddda..5dc63cf95d79 100644
--- a/l10ntools/scripts/fast_merge.pl
+++ b/l10ntools/scripts/fast_merge.pl
@@ -45,12 +45,8 @@ my $last_localize_file;
my $first_run = "1";
my $sdf_filename;
my $merge_dir;
-my $WIN;
my $state = "none";
-if ( defined $ENV{USE_SHELL} && $ENV{USE_SHELL} eq '4nt' ) { $WIN = 'TRUE'; }
-else { $WIN = ''; }
-
$SIG{INT} = 'inthandler';
$SIG{QUIT} = 'quithandler';
@@ -67,7 +63,6 @@ struct ( sdf_obj =>
parse_options();
my $lock_file = $merge_dir."/lock.mk";
-$lock_file =~ s/\//\\/g , if ( $WIN ) ;
acquire_lock();
read_sdf_file_names();
init();
@@ -247,10 +242,9 @@ sub make_paths
{
my $localizeFile = $merge_dir."\\".$current[ 0 ]->module."\\".$current[ 0 ]->file;
my $path = getDir( $localizeFile );
- if ( !$WIN ) { $path =~ s/\\/\//g; }
+ $path =~ s/\\/\//g;
- $localizeFile = $path."\\localize.sdf";
- if ( !$WIN ) { $localizeFile =~ s/\\/\//g; }
+ $localizeFile = $path."/localize.sdf";
return ( $path , $localizeFile );
}
diff --git a/l10ntools/scripts/localize.pl b/l10ntools/scripts/localize.pl
index 8b6a8231ebce..82ef331a63d5 100755..100644
--- a/l10ntools/scripts/localize.pl
+++ b/l10ntools/scripts/localize.pl
@@ -70,14 +70,12 @@ my $no_gsicheck = '';
my $mode = '';
my $bVerbose = "0";
my $srcpath = '';
-my $WIN;
my $languages;
#my %sl_modules; # Contains all modules where en-US and de is source language
my $use_default_date = '0';
my $force_ooo_module = '0';
my %is_ooo_module;
my %is_so_module;
-my $DELIMITER;
# ( leftpart ) ( rightpart )
# prj file dummy type gid lid helpid pform width lang text helptext qhelptext title timestamp
@@ -91,23 +89,14 @@ my @sdfparticles;
parse_options();
check_modules_scm();
-if ( defined $ENV{USE_SHELL} && $ENV{USE_SHELL} eq '4nt' ) {
- $WIN = 'TRUE';
- $DELIMITER = "\\";
-}
- else {
- $WIN = '';
- $DELIMITER = "/";
-}
-
my $binpath = '';
if( defined $ENV{UPDMINOREXT} )
{
- $binpath = $ENV{SOLARVER}.$DELIMITER.$ENV{INPATH}.$DELIMITER."bin".$ENV{UPDMINOREXT}.$DELIMITER ;
+ $binpath = $ENV{SOLARVER}."/".$ENV{INPATH}."/bin".$ENV{UPDMINOREXT}."/" ;
}
else
{
- $binpath = $ENV{SOLARVER}.$DELIMITER.$ENV{INPATH}.$DELIMITER."bin".$DELIMITER ;
+ $binpath = $ENV{SOLARVER}."/".$ENV{INPATH}."/bin/" ;
}
#%sl_modules = fetch_sourcelanguage_dirlist();
@@ -187,9 +176,8 @@ sub splitfile{
exit( -1 );
}
my $src_root = $ENV{SRC_ROOT};
- #print $WIN eq "TRUE" ? $src_root."\\l10n_so\n" : $src_root."/l10n_so\n";
- my $so_l10n_path = $WIN eq "TRUE" ? $src_root."\\l10n_so\\source" : $src_root."/l10n_so/source";
- my $ooo_l10n_path = $WIN eq "TRUE" ? $src_root."\\l10n\\source" : $src_root."/l10n/source";
+ my $so_l10n_path = $src_root."/l10n_so/source";
+ my $ooo_l10n_path = $src_root."/l10n/source";
#print "$so_l10n_path\n";
#print "$ooo_l10n_path\n";
@@ -286,7 +274,7 @@ sub write_sdf
my @sdf_file;
# mkdir!!!!
- my $current_l10n_file = $WIN eq "TRUE" ? $l10n_file."\\$lang\\localize.sdf" : $l10n_file."/$lang/localize.sdf";
+ my $current_l10n_file = $l10n_file."/$lang/localize.sdf";
print "Writing '$current_l10n_file'\n";
if( open DESTFILE , "< $current_l10n_file" ){
@@ -430,17 +418,17 @@ sub add_paths
{
my $langhash_ref = shift;
my $root_dir = $ENV{ SRC_ROOT };
- my $ooo_l10n_dir = "$root_dir"."$DELIMITER"."l10n"."$DELIMITER"."source";
- my $so_l10n_dir = "$root_dir"."$DELIMITER"."l10n_so"."$DELIMITER"."source";
+ my $ooo_l10n_dir = "$root_dir/l10n/source";
+ my $so_l10n_dir = "$root_dir/l10n_so/source";
if( -e $ooo_l10n_dir )
{
foreach my $lang ( keys( %{ $langhash_ref } ) )
{
- my $loc_file = "$ooo_l10n_dir"."$DELIMITER"."$lang"."$DELIMITER"."localize.sdf";
+ my $loc_file = "$ooo_l10n_dir/$lang/localize.sdf";
if( -e $loc_file )
{
- push @sdfparticles , "$ooo_l10n_dir"."$DELIMITER"."$lang"."$DELIMITER"."localize.sdf";
+ push @sdfparticles , "$ooo_l10n_dir/$lang/localize.sdf";
}
else { print "WARNING: $loc_file not found ....\n"; }
}
@@ -450,10 +438,10 @@ sub add_paths
{
foreach my $lang ( keys( %{ $langhash_ref } ) )
{
- my $loc_file = "$so_l10n_dir"."$DELIMITER"."$lang"."$DELIMITER"."localize.sdf";
+ my $loc_file = "$so_l10n_dir/$lang/localize.sdf";
if( -e $loc_file )
{
- push @sdfparticles , "$ooo_l10n_dir"."$DELIMITER"."$lang"."$DELIMITER"."localize.sdf";
+ push @sdfparticles , "$ooo_l10n_dir/$lang/localize.sdf";
}
else { #print "WARNING: $loc_file not found ....\n";
}
@@ -530,10 +518,6 @@ sub collectfiles{
} #foreach
} # if
} # if
-# if ( !$bVerbose ){
-# if ( $WIN eq "TRUE" ) { $args .= " > $my_localize_log"; }
-# else { $args .= " >& $my_localize_log"; }
-# }
if ( $bVerbose ) { print STDOUT $command.$args."\n"; }
my $rc = system( $command.$args );
diff --git a/l10ntools/scripts/localize_old.pl b/l10ntools/scripts/localize_old.pl
index fe63ba9a93de..d6b66d6bb535 100755..100644
--- a/l10ntools/scripts/localize_old.pl
+++ b/l10ntools/scripts/localize_old.pl
@@ -63,7 +63,6 @@ my $outputfile = '';
my $mode = '';
my $bVerbose="0";
my $srcpath = '';
-my $WIN;
my $languages;
#my %sl_modules; # Contains all modules where en-US and de is source language
my $use_default_date = '0';
@@ -78,13 +77,6 @@ my $default_date = "2002-02-02 02:02:02";
#### main ####
parse_options();
-if ( defined $ENV{USE_SHELL} && $ENV{USE_SHELL} eq '4nt' ) {
- $WIN = 'TRUE';
-}
- else {
- $WIN = '';
-}
-
#%sl_modules = fetch_sourcelanguage_dirlist();
@@ -136,13 +128,11 @@ sub splitfile{
next if( $prj eq "binfilter" ); # Don't merge strings into binfilter module
chomp( $line );
$currentFile = $srcpath . '\\' . $prj . '\\' . $file;
- if ( $WIN ) { $currentFile =~ s/\//\\/g; }
- else { $currentFile =~ s/\\/\//g; }
+ $currentFile =~ s/\\/\//g;
$cur_sdffile = $currentFile;
#if( $cur_sdffile =~ /\.$file_types[\s]*$/ ){
- if( $WIN ) { $cur_sdffile =~ s/\\[^\\]*\.$file_types[\s]*$/\\localize.sdf/; }
- else { $cur_sdffile =~ s/\/[^\/]*\.$file_types[\s]*$/\/localize.sdf/; }
+ $cur_sdffile =~ s/\/[^\/]*\.$file_types[\s]*$/\/localize.sdf/;
#}
# Set default date
@@ -182,41 +172,6 @@ sub splitfile{
}
#########################################################
-#sub fetch_sourcelanguage_dirlist
-#{
-#
-# my $working_path = getcwd();
-# my %sl_dirlist;
-#
-# chdir $srcpath;
-# my @all_dirs = csh_glob( "*" );
-#
-# foreach my $file ( @all_dirs )
-# {
-# if( -d $file )
-# {
-# my $module = $file;
-# $file .= "/prj/l10n";
-# $file =~ s/\//\\/ , if( $WIN ) ;
-#
-# if( -f $file ) # Test file <module>/prj/l10n
-# {
-# $sl_dirlist{ $module } = 1;
-# if( $bVerbose eq "1" ) { print STDOUT "$module: de and en-US source language detected\n"; }
-# }
-# }
-# }
-#
-# chdir $working_path;
-#
-# return %sl_dirlist;
-#}
-
-#sub has_two_sourcelanguages
-#{
-# my $module = shift;
-# return defined $sl_modules{ $module } ;
-#}
sub writesdf{
my $lastFile = shift;
@@ -225,8 +180,7 @@ sub writesdf{
my %index=();
if( $localizeFile =~ /\.$file_types[\s]*$/ ){
- if( $WIN ) { $localizeFile =~ s/\\[^\\]*\.$file_types[\s]*$/\\localize.sdf/; }
- else { $localizeFile =~ s/\/[^\/]*\.$file_types[\s]*$/\/localize.sdf/; }
+ $localizeFile =~ s/\/[^\/]*\.$file_types[\s]*$/\/localize.sdf/;
}else {
print STDERR "Strange filetype found '$localizeFile'\n";
return;
@@ -471,10 +425,6 @@ sub collectfiles{
} #foreach
} # if
} # if
-# if ( !$bVerbose ){
-# if ( $WIN eq "TRUE" ) { $args .= " > $my_localize_log"; }
-# else { $args .= " >& $my_localize_log"; }
-# }
if ( $bVerbose ) { print STDOUT $command.$args."\n"; }
my $rc = system( $command.$args );
diff --git a/l10ntools/source/help/HelpIndexerTool.java b/l10ntools/source/help/HelpIndexerTool.java
index 1245247c3c9a..2a49f964d48f 100644
--- a/l10ntools/source/help/HelpIndexerTool.java
+++ b/l10ntools/source/help/HelpIndexerTool.java
@@ -69,6 +69,7 @@ public class HelpIndexerTool
String aModule = "";
String aTargetZipFileStr = "";
String aCfsName = "";
+ String aSegmentName = "";
// Scan arguments
boolean bLang = false;
@@ -77,6 +78,7 @@ public class HelpIndexerTool
boolean bSrcDir = false;
boolean bOutput = false;
boolean bCfsName = false;
+ boolean bSegmentName = false;
int nArgCount = args.length;
for( int i = 0 ; i < nArgCount ; i++ )
@@ -126,7 +128,7 @@ public class HelpIndexerTool
}
i++;
}
- else if( "-checkcfsname".equals(args[i]) )
+ else if( "-checkcfsandsegname".equals(args[i]) )
{
if( i + 1 < nArgCount )
{
@@ -134,6 +136,17 @@ public class HelpIndexerTool
bCfsName = true;
}
i++;
+ if( i + 1 < nArgCount )
+ {
+ aSegmentName = "segments" + args[i + 1];
+ bSegmentName = true;
+ }
+ i++;
+ if (!(bCfsName && bSegmentName))
+ {
+ System.out.println("Usage: HelpIndexer -checkcfsandsegname _0 _3 (2 arguments needed)");
+ System.exit( -1 );
+ }
}
}
@@ -173,12 +186,17 @@ public class HelpIndexerTool
writer.close();
boolean bCfsFileOk = true;
- if( bCfsName && !bExtensionMode && nRet != -1 )
+ boolean bSegmentFileOk = true;
+ if( bCfsName && bSegmentName && !bExtensionMode && nRet != -1 )
{
String aCompleteCfsFileName = aDirToZipStr + File.separator + aIndexDirName + File.separator + aCfsName;
+ String aCompleteSegmentFileName = aDirToZipStr + File.separator + aIndexDirName + File.separator + aSegmentName;
File aCfsFile = new File( aCompleteCfsFileName );
+ File aSegmentFile = new File( aCompleteSegmentFileName );
bCfsFileOk = aCfsFile.exists();
+ bSegmentFileOk = aSegmentFile.exists();
System.out.println( "Checking cfs file " + aCfsName+ ": " + (bCfsFileOk ? "Found" : "Not found") );
+ System.out.println( "Checking segment file " + aSegmentName+ ": " + (bSegmentFileOk ? "Found" : "Not found") );
}
if( bExtensionMode )
@@ -194,7 +212,7 @@ public class HelpIndexerTool
if( nRet == -1 )
deleteRecursively( aIndexDir );
- if( bCfsFileOk )
+ if( bCfsFileOk && bSegmentFileOk )
System.out.println( "Zipping ..." );
File aDirToZipFile = new File( aDirToZipStr );
createZipFile( aDirToZipFile, aTargetZipFileStr );
@@ -207,6 +225,12 @@ public class HelpIndexerTool
System.exit( -1 );
}
+ if( !bSegmentFileOk )
+ {
+ System.out.println( "segment file check failed, terminating..." );
+ System.exit( -1 );
+ }
+
Date end = new Date();
if( !bExtensionMode )
System.out.println(end.getTime() - start.getTime() + " total milliseconds");
diff --git a/l10ntools/source/help/makefile.mk b/l10ntools/source/help/makefile.mk
index 50351913fe55..b66077501a8d 100644
--- a/l10ntools/source/help/makefile.mk
+++ b/l10ntools/source/help/makefile.mk
@@ -101,7 +101,7 @@ JAVACLASSFILES = \
$(CLASSDIR)$/$(PACKAGE)$/HelpFileDocument.class
.IF "$(SYSTEM_LUCENE)" == "YES"
-CLASSPATH!:=$(CLASSPATH)$(PATH_SEPERATOR)$(LUCENE_CORE_JAR)$(PATH_SEPERATOR)$(LUCENE_ANALYZERS_JAR)
+EXTRAJARFILES += $(LUCENE_CORE_JAR) $(LUCENE_ANALYZERS_JAR)
.ELSE
JARFILES += lucene-core-2.3.jar lucene-analyzers-2.3.jar
.ENDIF
diff --git a/l10ntools/source/wrdtrans.cxx b/l10ntools/source/wrdtrans.cxx
deleted file mode 100644
index 10d6f472640f..000000000000
--- a/l10ntools/source/wrdtrans.cxx
+++ /dev/null
@@ -1,245 +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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_l10ntools.hxx"
-
-/*
-#include "wrdtrans.hxx"
-
-
-// NOT FULLY DECLARED SERVICES
-#include <vector>
-#include <vos/macros.hxx>
-
-
-#include <tools/stream.hxx>
-#include "wtratree.hxx"
-
-#include <tools/string.hxx>
-*/
-//************** Declaration WordTrans_ErrorList ******************//
-/*
-typedef NAMESPACE_STD(vector)<ByteString> Stl_ByteStringList;
-
-class WordTrans_ErrorList
-{
- public:
- // OPERATIONS
- void AddError(
- WordTransformer::E_Error
- i_eType,
- const char * i_sErrorDescription );
- void Clear(); /// Empties the list.
-
- // INQUIRY
- USHORT NrOfErrors() const;
- WordTransformer::E_Error
- GetError(
- USHORT i_nNr, /// [0 .. NrOfErrors()-1], other values return an empty error.
- ByteString * o_pErrorText ) const; /// If o_pErrorText != 0, the String is filled with the description of the error.
- private:
- // DATA
- Stl_ByteStringList aErrors;
-};
-
-*/
-
-//************** Implementation WordTransformer ******************//
-
-/*
-WordTransformer::WordTransformer()
- : dpTransformer(0),
- dpErrors(new WordTrans_ErrorList)
-{
-}
-
-WordTransformer::~WordTransformer()
-{
- if (dpTransformer != 0)
- delete dpTransformer;
- delete dpErrors;
-}
-
-BOOL
-WordTransformer::LoadWordlist( const ByteString & i_sWordlist_Filepath,
- CharSet i_nWorkingCharSet,
- CharSet i_nFileCharSet )
-{
- if (dpTransformer != 0)
- return FALSE;
-
- SvFileStream aFile(String(i_sWordlist_Filepath,RTL_TEXTENCODING_ASCII_US),STREAM_STD_READ);
- if (! aFile.IsOpen())
- return FALSE;
- aFile.SetStreamCharSet( i_nFileCharSet ) ;
-// aFile.SetTargetCharSet( i_nWorkingCharSet );
-
- dpTransformer = new WordTransTree;
-
- ByteString sTrans;
- while ( aFile.ReadLine(sTrans) )
- {
- dpTransformer->AddWordPair(sTrans.GetToken(0,';'),sTrans.GetToken(1,';'));
- }
-
- aFile.Close();
- return TRUE;
-}
-
-USHORT
-WordTransformer::Transform(ByteString & io_sText)
-{
- // Initialization and precondition testing:
- dpErrors->Clear();
- if (dpTransformer == 0)
- {
- dpErrors->AddError(ERROR_NO_WORDLIST,"Error: No wordlist was loaded.");
- return dpErrors->NrOfErrors();
- }
- else if (io_sText.Len() > 63 * 1024)
- {
- dpErrors->AddError(ERROR_OUTPUTSTRING_TOO_LONG,"Error: Inputstring was too long (bigger than 63 KB).");
- return dpErrors->NrOfErrors();
- }
- else if (io_sText.Len() == 0)
- {
- return 0;
- }
-
- // Transform:
- dpTransformer->InitTransformation(
- io_sText.GetBuffer(),
- io_sText.Len() );
-
- for ( ; !dpTransformer->TextEndReached(); )
- {
- if (dpTransformer->TransformNextToken() != WordTransTree::OK)
- {
- CreateError();
- }
- }
- io_sText = dpTransformer->Output();
- return dpErrors->NrOfErrors();
-}
-
-USHORT
-WordTransformer::NrOfErrors() const
-{
- return dpErrors->NrOfErrors();
-}
-
-WordTransformer::E_Error
-WordTransformer::GetError( USHORT i_nNr,
- ByteString * o_pErrorText) const
-{
- return dpErrors->GetError(i_nNr,o_pErrorText);
-}
-
-void
-WordTransformer::CreateError()
-{
- ByteString sErr;
-
- switch (dpTransformer->CurResult())
- {
- case WordTransTree::OK:
- break;
- case WordTransTree::HOTKEY_LOST:
- sErr = ByteString("Error: By replacement of string ");
- sErr += dpTransformer->CurReplacedString();
- sErr += " by ";
- sErr += dpTransformer->CurReplacingString();
- sErr += "the hotkey at char '";
- sErr += dpTransformer->CurHotkey();
- sErr += "' was lost.";
- dpErrors->AddError( ERROR_HOTKEY,sErr.GetBufferAccess());
- sErr.ReleaseBufferAccess();
- break;
- case WordTransTree::OUTPUT_OVERFLOW:
- dpErrors->AddError(ERROR_OUTPUTSTRING_TOO_LONG,"Error: Output buffer overflow.");
- break;
- default:
- dpErrors->AddError(OTHER_ERROR,"Error: Unknown error.");
- }
-}
-*/
-//************** Implementation WordTrans_ErrorList ******************//
-/*
-void
-WordTrans_ErrorList::AddError( WordTransformer::E_Error i_eType,
- const char * i_sErrorDescription )
-{
- ByteString sErrorType = "xxx";
- char * pErrorChars = sErrorType.GetBufferAccess();
- pErrorChars[0] = char(i_eType / 100 + '0');
- pErrorChars[1] = char( (i_eType % 100) / 10 + '0');
- pErrorChars[2] = char(i_eType % 10 + '0');
- sErrorType += i_sErrorDescription;
-
- aErrors.push_back(sErrorType);
- sErrorType.ReleaseBufferAccess();
-}
-
-void
-WordTrans_ErrorList::Clear()
-{
- aErrors.erase(aErrors.begin(),aErrors.end());
-}
-
-USHORT
-WordTrans_ErrorList::NrOfErrors() const
-{
- return aErrors.size();
-}
-
-WordTransformer::E_Error
-WordTrans_ErrorList::GetError( USHORT i_nNr,
- ByteString * o_pErrorText ) const
-{
- if ( i_nNr < aErrors.size() )
- {
- const ByteString & rError = aErrors[i_nNr];
- const char * pErrorChars = rError.GetBuffer();
-
- USHORT nError = USHORT( (pErrorChars[0] - '0') ) * 100
- + (pErrorChars[1] - '0') * 10
- + pErrorChars[2] - '0';
-
- if (o_pErrorText != 0)
- *o_pErrorText = pErrorChars+3;
-
- return WordTransformer::E_Error(nError);
- }
- else
- {
- if (o_pErrorText != 0)
- *o_pErrorText = "";
- return WordTransformer::OK;
- }
-}
-*/