diff options
Diffstat (limited to 'l10ntools')
29 files changed, 1436 insertions, 547 deletions
diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx index eeb0afd38373..222cd3bf5cb8 100644 --- a/l10ntools/inc/export.hxx +++ b/l10ntools/inc/export.hxx @@ -460,6 +460,8 @@ public: bTitleFirst[ nId ] = true; } BOOL GetText( ByteString &rReturn, USHORT nTyp, const ByteString &nLangIndex, BOOL bDel = FALSE ); + BOOL GetTransex3Text( ByteString &rReturn, USHORT nTyp, const ByteString &nLangIndex, BOOL bDel = FALSE ); + }; // 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/jpropex/build.xml b/l10ntools/java/jpropex/build.xml new file mode 100755 index 000000000000..d74fb3975d0f --- /dev/null +++ b/l10ntools/java/jpropex/build.xml @@ -0,0 +1,169 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project name="jpropex" default="main" basedir="."> + + <!-- ================================================================= --> + <!-- settings --> + <!-- ================================================================= --> + + <!-- name of this sub target used in recursive builds --> + <property name="target" value="jpropex"/> + + <!-- name of jar file created, without .jar extension --> + <property name="jarname" value="jpropex"/> + + <!-- relative path to project directory --> + <property name="prj" value="."/> + + <!-- build output directory --> + <property name="out" value="build"/> + + <!-- build directories --> + <property name="build.dir" value="${out}"/> + <property name="build.class" value="${build.dir}/class/jpropex"/> + <property name="build.misc" value="${build.dir}/misc/jpropex"/> + + <!-- start of java source code package structure --> + <property name="java.dir" value="java"/> + + <!-- define how to handle CLASSPATH environment --> + <property name="build.sysclasspath" value="ignore"/> + + <!-- classpath settings for compile and javadoc tasks --> + <path id="classpath"> + <pathelement location="."/> + <pathelement location="${build.class}"/> + </path> + + <!-- name to display in documentation --> + <!-- <property name="docname" value="l10n converter"/> --> + + <!-- set "modern" java compiler --> + <property name="build.compiler" value="modern"/> + + <!-- set wether we want to compile with debug information --> + <property name="debug" value="on"/> + + <!-- set wether we want to compile with optimisation --> + <property name="optimize" value="off"/> + + <!-- set wether we want to compile with or without deprecation --> + <property name="deprecation" value="on"/> + + <target name="info"> + <echo message="--------------------"/> + <echo message="${target}"/> + <echo message="--------------------"/> + </target> + + <!-- ================================================================= --> + <!-- custom targets --> + <!-- ================================================================= --> + + <!-- the main target, called in recursive builds --> + <target name="main" depends="info,prepare,compile,jar"/> + + <!-- prepare output directories --> + <target name="prepare"> + <mkdir dir="${build.dir}"/> + <mkdir dir="${build.class}"/> + <mkdir dir="${build.misc}"/> + </target> + + + <target name="res" depends="prepare"> + <copy todir="${build.class}"> + <fileset dir="${java.dir}"> + <include name="**/*.properties"/> + <include name="**/*.css"/> + <include name="**/*.dtd"/> + <include name="**/*.form"/> + <include name="**/*.gif "/> + <include name="**/*.htm"/> + <include name="**/*.html"/> + <include name="**/*.js"/> + <include name="**/*.mod"/> + <include name="**/*.sql"/> + <include name="**/*.xml"/> + <include name="**/*.xsl"/> + <include name="**/*.map"/> + + </fileset> + </copy> + </target> + + + <target name="compile" depends="prepare,res"> + <javac destdir="${build.class}" + debug="${debug}" + deprecation="${deprication}" + optimize="${optimize}" + classpathref="classpath"> + <src path="${java.dir}"/> + <include name="**/*.java"/> + </javac> + </target> + + <!-- clean up --> + <target name="clean" depends="prepare"> + <delete includeEmptyDirs="true"> + <fileset dir="${build.class}"> + <patternset> + <include name="${package}/**/*.class"/> + </patternset> + </fileset> + </delete> + </target> + + <!-- create jar file --> + <target name="jar" depends="prepare,compile" if="build.class"> + <jar jarfile="${build.class}/${jarname}.jar" + basedir="${build.class}" + manifest="${jarname}.MF"> + <include name="**/*.class"/> + <include name="**/*.properties"/> + <include name="**/*.css"/> + <include name="**/*.dtd"/> + <include name="**/*.form"/> + <include name="**/*.gif "/> + <include name="**/*.htm"/> + <include name="**/*.html"/> + <include name="**/*.js"/> + <include name="**/*.mod"/> + <include name="**/*.sql"/> + <include name="**/*.xml"/> + <include name="**/*.xsl"/> + <include name="**/*.map"/> + </jar> + </target> + + <target name="test" depends="prepare"> + </target> + +</project> + diff --git a/l10ntools/java/jpropex/java/JPropEx.java b/l10ntools/java/jpropex/java/JPropEx.java new file mode 100644 index 000000000000..224bed783cf6 --- /dev/null +++ b/l10ntools/java/jpropex/java/JPropEx.java @@ -0,0 +1,499 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + + +import java.util.*; +import java.io.*; + +public class JPropEx +{ + private String inputFileArg = ""; + private String outputFileArg = ""; + private String pathPrefixArg = ""; + private String pathPostfixArg = ""; + private String projectArg = ""; + private String rootArg = ""; + private Vector forcedLangsArg; + private Vector langsArg; + private String inputSdfFileArg = ""; + private boolean isQuiet = false; + private final String resourceType = "javaproperties"; + private final String sourceLanguage = "en-US"; + + static final int JAVA_TYPE = 0; + static final int JAVA_ENUS_TYPE = 1; + static final int EXTENSION_TYPE = 2; + + public JPropEx() + { + //data = new SdfData(); + } + + public JPropEx( String args[] ) + { + super(); + parseArguments( args ); + testCL(); + //testArguments(); + if( inputSdfFileArg != null && inputSdfFileArg.length() > 0 ) + merge(); + else + extract(); + } + + private String getSimpleArg( String[] args , int x ) + { + if( x < args.length ) x++; + else + { + System.err.println("ERROR: Missing arg for "+args[ x ]+"\n"); + help(); + } + return args[ x ]; + } + private Vector getComplexArg( String[] args , int x ) + { + if( x < args.length ) x++; + else + { + System.err.println("ERROR: Missing arg for "+args[ x ]+"\n"); + help(); + } + String value = args[ x ]; + Vector values = new Vector( Arrays.asList( value.split(",") ) ); + return values; + } + + private void testCL() + { + if( inputFileArg.length()>0 && ( ( pathPrefixArg.length()>0 && pathPostfixArg.length()>0 ) || outputFileArg.length()>0 ) && projectArg.length()>0 && rootArg.length()>0 && langsArg.size()>0 ) + if( ( inputSdfFileArg.length()>0 && ( outputFileArg.length()>0 || ( pathPrefixArg.length()>0 && pathPostfixArg.length()>0 ) ) ) || ( inputFileArg.length()>0 && outputFileArg.length()>0 ) ) + return; + System.out.println("ERROR: Strange parameters!"); + help(); + System.exit( -1 ); + } + private void help() + { + System.out.println("jpropex -> extract / merge java properties files"); + System.out.println("-p <project> -r <project_root> -i <input>|@<input> -o <output> -x <path1> -y <path2> -m <sdf_file> -l <lang>\n"); + System.out.println("Example:\ncd /data/cws/l10ntooling17/DEV300/ooo/reportbuilder/java/com/sun/star/report/function/metadata"); + System.out.println("Extract:\njpropex -p reportbuilder -r ../../../../../../.. -i Title-Function.properties -o new.sdf -l en-US"); + System.out.println("Merge: use either ( -x path -y more_path ) or ( -o ) and ( -i filename ) or ( -i @filename ). @filename contains a list with files"); + System.out.println("jpropex -p reportbuilder -r ../../../../../../.. -x ../../../../../../../unxlngx6.pro/class/com/sun/star/report/function/metadata -y ivo -i @abc -l all -lf en-US,de,fr,pt -m ../../../../../../../common.pro/misc/reportbuilder/java/com/sun/star/report/function/metadata/localize.sdf"); + System.out.println("jpropex -p reportbuilder -r ../../../../../../.. -x ../../../../../../../unxlngx6.pro/class/com/sun/star/report/function/metadata -y ivo -i @abc -l all -lf en-US,de,fr,pt -m ../../../../../../../common.pro/misc/reportbuilder/java/com/sun/star/report/function/metadata/localize.sdf"); + System.out.println("jpropex -p reportbuilder -r ../../../../../../.. -o ../../../../../../../unxlngx6.pro/class/com/sun/star/report/function/metadata/ -i Title-Function.properties -l all -lf en-US,de,fr,pt -m ../../../../../../../common.pro/misc/reportbuilder/java/com/sun/star/report/function/metadata/localize.sdf"); + System.out.println("jpropex -p reportbuilder -r ../../../../../../.. -x ../../../../../../../unxlngx6.pro/class/com/sun/star/report/function/metadata -y ivooo -i Title-Function.properties -l all -lf en-US,de,fr,pt -m ../../../../../../../common.pro/misc/reportbuilder/java/com/sun/star/report/function/metadata/localize.sdf"); + System.exit( -1 ); + } + + private void extract() + { + SdfData data = new SdfData(); + java.util.Properties prop = loadProp( inputFileArg ); + + // Get a prototype that already contains the most common settings + SdfEntity dolly = prepareSdfObj( inputFileArg ); + String key; + SdfEntity currentStr; + String value; + for( Enumeration e = prop.propertyNames() ; e.hasMoreElements() ; ) + { + key = (String) e.nextElement(); + currentStr = (SdfEntity) dolly.clone(); + // Set the new LID and the string text + currentStr.setLid( key ); + value = prop.getProperty( key , "" ); + //if( value.equals("") ) System.err.println("Warning: in file "+inputFileArg+" the string with the key "+key+" has a empty string!"); + currentStr.setText( (prop.getProperty( key )).replaceAll("\t" , " " ) ); // TODO: Quoting!!!! + data.add( currentStr ); + } + data.write( outputFileArg ); + } + + private SdfEntity prepareSdfObj( String filename ) + { + String path = makeAbs( filename ); + //String path = makeAbs( inputFileArg ); + path = path.replace( rootArg + "/" , "" ); + path = path.replace("/","\\"); + return new SdfEntity( projectArg , path , "" /* dummy1 */ , resourceType , "", "" , "" , "" , "" /* dummy2 */ , + sourceLanguage , "", "" , "" , "" , "2002-02-02 02:02:02" ); + } + + private void merge() + { + SdfData data = getSdfData(); + if( inputFileArg.startsWith("@") ) + { + // Read files + Vector fileList = readFileList( inputFileArg ); + for( Enumeration e = fileList.elements(); e.hasMoreElements(); ) + mergeFile( (String) e.nextElement() , data , false ); + } + else + { + // Single file + mergeFile( inputFileArg , data , true ); + } + } + + private Vector readFileList( String filename ) + { + Vector lines = new Vector(); + try + { + BufferedReader in = new BufferedReader( new FileReader( filename.substring( 1 ) ) ); + while( in.ready() ) + lines.add( in.readLine() ); + } + catch( IOException e ) + { + System.out.println("ERROR: Can't open file '"+filename.substring( 1 )+"'"); + System.exit( -1 ); + } + return lines; + } + + private void mergeFile( String filename , SdfData data , boolean isSingleFile ) + { + int type = detectFormat( filename ); + java.util.Properties sourceProp = loadProp( filename ); + Vector langs = getLanguages( data ); + HashMap props = new HashMap(); + // Create a properties object for every language + for( Enumeration e = langs.elements(); e.hasMoreElements();) + { + props.put( (String)e.nextElement() , new java.util.Properties() ); + } + // Get a prototype that already contains the most common settings + + SdfEntity dolly = prepareSdfObj( filename ); + String key; + String sourceString; + SdfEntity curStr; + SdfEntity curEntity; + SdfEntity mergedEntity; + String curLang; + for( Enumeration e = sourceProp.propertyNames() ; e.hasMoreElements() ; ) // For all property keys + { + key = (String) e.nextElement(); + sourceString = sourceProp.getProperty( key ); + curStr = (SdfEntity) dolly.clone(); + curStr.setLid( key ); + for( Enumeration lang = langs.elements(); lang.hasMoreElements(); ) // merge in every language + { + curEntity = (SdfEntity) curStr.clone(); + curLang = (String) lang.nextElement(); + curEntity.setLangid( curLang ); + mergedEntity = data.get( curEntity ); + if( mergedEntity == null ) + { + // in case there is no translation then fallback to the en-US source string + ( (java.util.Properties) props.get( curLang )).setProperty( curEntity.getLid() , sourceString ); + } + else + { + // Set the merged text from the sdf file + ( (java.util.Properties) props.get( curLang )).setProperty( mergedEntity.getLid() , mergedEntity.getText() ); // TODO: Quoting ??? + } + } + + } + // Now write them out + String lang; + for( Iterator i = props.keySet().iterator() ; i.hasNext() ; ) + { + lang = (String) i.next(); + writeSinglePropertiesFile( filename , (java.util.Properties) props.get( lang ) , lang , isSingleFile , type ); + } + } + private void writeSinglePropertiesFile( String filename , java.util.Properties prop , String lang , boolean isSingleFile , int type ) + { + // Prepare path to file + int filenameIdx = filename.lastIndexOf( "/" ) > 0 ? filename.lastIndexOf( "/" )+1 : 0 ; + String path = new String(); + String name = new String(); + String lcLang = lang.toLowerCase(); + // use of -x <path> -y <more_path> + // -> <path>/<lang>/<more_path> + if( pathPrefixArg != null && pathPrefixArg.length()>0 && pathPostfixArg != null && pathPostfixArg.length()>0 ) + { + path = new StringBuffer().append( pathPrefixArg ).append( "/" ).append( lcLang ).append( "/" ).append( pathPostfixArg ).append( "/" ).toString(); + name += formatFilename( filename , filenameIdx , lang , type ); + } + //use of -i <one_filename> + else if( !isSingleFile && outputFileArg != null && outputFileArg.length()>0 ) + { + //name = outputFileArg; + path = outputFileArg; + name += formatFilename( filename , filenameIdx , lang , type ); + } + //use of -i @<file_containing_many_filenames> + else if( isSingleFile && outputFileArg != null && outputFileArg.length()>0 ) + { + //name = outputFileArg; + path = outputFileArg; + name += formatFilename( filename , filenameIdx , lang , type ); + } + else + { + System.err.println("ERROR: No outputfile specified .. either -o or -x -y !"); + System.exit( -1 ); + } + + File dir = new File( path ); + try + { + if( !dir.exists() && path.length()>0 ) + { + if( !dir.mkdirs() ) + { + System.out.println("ERROR: Can't create directory '"+path+"' !!!"); + System.exit( -1 ); + } + } + } + catch( SecurityException e ) + { + System.out.println("ERROR: Can't create directory '"+path+"'!!!Wrong Permissions?"); + System.exit( -1 ); + } + path += name; + // Write the properties file + //System.out.println("DBG: Writing to "+path); + try{ + BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream( path ) ); + if( prop == null ) + System.out.println("DBG: prop == null!!!"); + prop.store( out , "" ); // Legal headers? + } + catch( IOException e ) + { + System.out.println("ERROR: Can't write file '"+path+"' !!!!"); + System.exit( -1 ); + } + } + + // we have different types of properties in the source code + // each needs a different file nameing scheme + private int detectFormat( String filename ) + { + if( filename.endsWith( "_en_US.properties" ) ) + return EXTENSION_TYPE; + else if( filename.endsWith("_en_us.properties" ) ) + return JAVA_ENUS_TYPE; + else if( filename.endsWith( ".properties" ) ) + return JAVA_TYPE; + + // Can not detect, exit + System.err.println("ERROR: Invalid file name. Only allowed (case sensitive!) *_en_US.properties , *_en_us.properties or *.properties\n"); + System.exit(-1); + return JAVA_TYPE; // dummy + } + + private String formatFilename( String filename , int filenameIdx , String lang , int type ) + { + + if( !lang.equals( "en-US" ) ) + { + // Parse iso code + int pos = lang.indexOf("-"); + String langpart1 = new String(); + String langpart2 = new String(); + if( pos == -1 ) + { + langpart1 = lang; + } + else if( pos > 0 ) + { + langpart1 = lang.substring( 0 , pos ); + langpart2 = lang.substring( pos+1 , lang.length() ); + } + // change filename according to the type + switch( type ) + { + // -> de_DE + case EXTENSION_TYPE: + lang = langpart1.toLowerCase(); + if( langpart2.length() > 0 ) // -> en_US + lang += "_" + langpart2.toUpperCase(); + else // -> de_DE + lang += "_" + langpart1.toUpperCase(); + return new StringBuffer().append( filename.substring( filenameIdx , filename.lastIndexOf( "_en_US.properties" ) ) ) + .append( "_" ).append( lang.replaceAll("-","_") ).append( ".properties" ).toString(); + // -> de + case JAVA_ENUS_TYPE: + lang = langpart1.toLowerCase(); + if( langpart2.length() > 0 ) + lang += "_" + langpart2.toLowerCase(); + return new StringBuffer().append( filename.substring( filenameIdx , filename.lastIndexOf( "_en_us.properties" ) ) ) + .append( "_" ).append( lang.replaceAll("-","_") ).append( ".properties" ).toString(); + // -> de + case JAVA_TYPE: + lang = langpart1.toLowerCase(); + if( langpart2.length() > 0 ) + lang += "_" + langpart2.toLowerCase(); + return new StringBuffer().append( filename.substring( filenameIdx , filename.lastIndexOf( ".properties" ) ) ) + .append( "_" ).append( lang.replaceAll("-","_") ).append( ".properties" ).toString(); + default: + System.err.println("ERROR: Something is really broken here, l10ntools/java/jprop/java/JPropEx.java :: formatFilename()"); + System.exit( -1 ); + break; + } + } + return filename; // don't change en-US source file name + } + private SdfData getSdfData() + { + SdfData data = new SdfData( inputSdfFileArg ); + data.read(); + return data; + } + private Vector getLanguages( SdfData data ) + { + Vector langs = new Vector(); + + if( ((String)langsArg.get( 0 )).equalsIgnoreCase( "all" ) ) // for "-l all" use all languages found in the -m sdf file + langs.addAll( data.getLanguages() ); + else + langs.addAll( langsArg ); // use the langs giving by -l + + if( forcedLangsArg != null ) + langs.addAll( forcedLangsArg ); + + return removeDupes( langs ); + } + private Vector removeDupes( Vector vec ) + { + Collection coll = new LinkedHashSet( vec ); + return new Vector( coll ); + } + private java.util.Properties loadProp( String filename ) + { + java.util.Properties prop = new java.util.Properties(); + try + { + prop.load( new BufferedInputStream( new NoLocalizeFilter( new FileInputStream( filename ) ) ) ); + } + catch( IOException e ) + { + System.err.println("ERROR: Can't read file '"+filename+"'!!!"); + } + return prop; + } + private void parseArguments( String[] args ) + { + + if( args.length == 0 ) + { + System.out.println("ERROR: No args???"); + help(); + System.exit( -1 ); + } + for( int x = 0; x < args.length ; x++ ) + { + if( args[ x ].equalsIgnoreCase("-i") ) + { + // Input resource file + inputFileArg = getSimpleArg( args , x ); + } + else if( args[ x ].equalsIgnoreCase("-o") ) + { + // Output sdf file + outputFileArg = getSimpleArg( args , x ); + } + else if( args[ x ].equalsIgnoreCase("-x") ) + { + // path prefix + pathPrefixArg = getSimpleArg( args , x ); + } + else if( args[ x ].equalsIgnoreCase("-y") ) + { + // path postfix + pathPostfixArg = getSimpleArg( args , x ); + } + else if( args[ x ].equalsIgnoreCase("-p") ) + { + // project + projectArg = getSimpleArg( args , x ); + } + else if( args[ x ].equalsIgnoreCase("-r") ) + { + // root + rootArg = getSimpleArg( args , x ); + rootArg = makeAbs( rootArg ); + } + else if( args[ x ].equalsIgnoreCase("-lf") ) + { + // forced langs + forcedLangsArg = getComplexArg( args , x ); + } + else if( args[ x ].equalsIgnoreCase("-l") ) + { + // langs + langsArg = getComplexArg( args , x ); + } + else if( args[ x ].equalsIgnoreCase("-m") ) + { + // input sdf file + inputSdfFileArg = getSimpleArg( args , x ); + } + else if( args[ x ].equalsIgnoreCase("-qq") ) + { + isQuiet = true; + } + } + } + private String makeAbs( String path ) + { + File file; + try + { + file = new File( path ); + return file.getCanonicalPath(); + }catch( IOException e ) + { + e.printStackTrace(); + System.exit( -1 ); + } + return null; + } +/* private boolean testArguments() + { + // nice merge + if( inputSdfFileArg != null && inputSdfFileArg.length()>0 ) + // nice merge + return projectArg != null && rootArg != null && inputFileArg != null && pathPrefixArg != null && pathPostfixArg != null && langsArg != null && + projectArg.length()>0 && rootArg.length()>0 && inputFileArg.length()>0 && pathPrefixArg.length()>0 && pathPostfixArg.length()>0 && langsArg.size()>0 ; + else + // nice extract + return projectArg != null && rootArg != null && inputFileArg != null && outputFileArg != null && langsArg != null && + projectArg.length()>0 && rootArg.length()>0 && inputFileArg.length()>0 && outputFileArg.length()>0 && langsArg.size()>0; + } +*/ +} diff --git a/l10ntools/java/jpropex/java/Main.java b/l10ntools/java/jpropex/java/Main.java new file mode 100644 index 000000000000..23dc477ddec3 --- /dev/null +++ b/l10ntools/java/jpropex/java/Main.java @@ -0,0 +1,38 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + + +class Main +{ + + public static void main( String args[] ) + { + JPropEx jpropex = new JPropEx( args ); + //jpropex.init(); + } +} + diff --git a/l10ntools/java/jpropex/java/NoLocalizeFilter.java b/l10ntools/java/jpropex/java/NoLocalizeFilter.java new file mode 100644 index 000000000000..989ee64bfc86 --- /dev/null +++ b/l10ntools/java/jpropex/java/NoLocalizeFilter.java @@ -0,0 +1,54 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + + +import java.io.*; +import java.util.regex.*; + +// exit if the sequence x-no-localize is found in stream! +public class NoLocalizeFilter extends FilterInputStream +{ + InputStream in; + Pattern p = Pattern.compile("#[\\s]*x-no-translate"); + + public NoLocalizeFilter( InputStream in ) { + super(in); + this.in = in; + } + public int read(byte[] b, int off, int len) throws IOException + { + String search = new String( b ); + Matcher m = p.matcher( search ); + if( m.find() ) + { + in.close(); + close(); + System.exit( 0 ); + } + return in.read( b , off , len ); + } +} diff --git a/l10ntools/java/jpropex/java/OrderedHashMap.java b/l10ntools/java/jpropex/java/OrderedHashMap.java new file mode 100644 index 000000000000..a462d598b307 --- /dev/null +++ b/l10ntools/java/jpropex/java/OrderedHashMap.java @@ -0,0 +1,96 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + + +import java.util.*; + +// LinkedHashMap implrementation +public class OrderedHashMap +{ + private HashMap hm = new HashMap(); + private LinkedList list = new LinkedList(); + + public Iterator iterator() { return list.iterator(); } + + public boolean isEmpty() { return hm.isEmpty(); } + public Object get( Object key ) { return hm.get( key ); } + public Object get( int index ) { return hm.get( list.get( index ) ); } + public Iterator keys() { return list.iterator(); } + public Object add( Object key , Object value ) + { + list.add( key ); + return hm.put( key, value ); + } + public Object add( int index , Object key , Object value ) + { + list.add( index , key ); + return hm.put( key, value ); + } + public Object remove( Object key ) + { + list.remove( list.indexOf( key ) ); + return hm.remove( key ); + } + public void move( int idxFrom , int idxTo ) + { + Object key = list.get( idxFrom ); + list.remove( idxFrom ); + list.add( idxTo , key ); + } + public void move( Object key , int idxTo ) + { + move( list.indexOf( key ) , idxTo ); + } + public int size() + { + return hm.size(); + } + public Enumeration elements() + { + return new OHMenum( this ); + } +} + +final class OHMenum implements Enumeration +{ + OrderedHashMap ohm; + int index = 0; + + private OHMenum(){}; + public OHMenum( OrderedHashMap ohm ){ + this.ohm = ohm ; + } + + public boolean hasMoreElements() + { + return index < ohm.size(); + } + public Object nextElement() + { + return ohm.get( index++ ); + } +} diff --git a/l10ntools/java/jpropex/java/SdfData.java b/l10ntools/java/jpropex/java/SdfData.java new file mode 100644 index 000000000000..6f79909df1b2 --- /dev/null +++ b/l10ntools/java/jpropex/java/SdfData.java @@ -0,0 +1,108 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + + +import java.util.*; +import java.io.*; + +public class SdfData +{ + private String filename; + private OrderedHashMap ohm; + private LinkedHashSet languagesFound; + + public SdfData() + { + languagesFound = new LinkedHashSet(); + ohm = new OrderedHashMap(); + languagesFound = new LinkedHashSet(); + } + public SdfData( String filename ) + { + this(); + this.filename = filename; + } + + public LinkedHashSet getLanguages() + { + return languagesFound; + } + public SdfEntity get( SdfEntity obj ) + { + return (SdfEntity) ohm.get( (String)obj.getId() ); + } + public SdfEntity get( String key ){ + return (SdfEntity) ohm.get( key ); + } + public void add( SdfEntity obj ) + { + ohm.add( obj.getId() , obj ); + } + + public void read() + { + BufferedReader in; + try + { + in = new BufferedReader( new FileReader( filename ) ); + SdfEntity entity; + while( in.ready() ) + { + String line = in.readLine(); + if( line.length() > 0 ) + { + entity = new SdfEntity( line ); + ohm.add( entity.getId() , entity ); // test if is valid + languagesFound.add( entity.getLangid() ); + } + } + in.close(); + } + catch( IOException e ) + { + System.out.println("Warning: can not read file " + filename); + } + } + public void write( String filename ) + { + FileWriter out; + try + { + out = new FileWriter( filename , true ); // Always append + for( Enumeration e = ohm.elements(); e.hasMoreElements(); ) + { + out.write( ( (SdfEntity) e.nextElement() ).toString() + "\n" ); + } + out.close(); + } + catch( IOException e ) + { + System.out.println("Error: Can't write to file " + filename); + System.exit( -1 ); + } + } +} diff --git a/l10ntools/java/jpropex/java/SdfEntity.java b/l10ntools/java/jpropex/java/SdfEntity.java new file mode 100644 index 000000000000..52dc61ca40ca --- /dev/null +++ b/l10ntools/java/jpropex/java/SdfEntity.java @@ -0,0 +1,254 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + + +public class SdfEntity implements Cloneable{ + private String project = new String(""); + private String source_file = new String(""); + private String dummy1 = new String(""); + private String resource_type= new String(""); + private String gid = new String(""); + private String lid = new String(""); + private String helpid = new String(""); + private String platform = new String(""); + private String dummy2 = new String(""); + private String langid = new String(""); + private String text = new String(""); + private String helptext = new String(""); + private String quickhelptext= new String(""); + private String title = new String(""); + private String date = new String(""); + + public static int PROJECT_POS = 0; + public static int SOURCE_FILE_POS = 1; + public static int DUMMY1_POS = 2; + public static int RESOURCE_TYPE_POS = 3; + public static int GID_POS = 4; + public static int LID_POS = 5; + public static int HELPID_POS = 6; + public static int PLATFORM_POS = 7; + public static int DUMMY2_POS = 8; + public static int LANGID_POS = 9; + public static int TEXT_POS = 10; + public static int HELPTEXT_POS = 11; + public static int QUICKHELPTEXT_POS = 12; + public static int TITLE_POS = 13; + public static int DATE_POS = 14; + + public Object clone() + { + try + { + return super.clone(); + } + catch( CloneNotSupportedException e ) + { + System.out.println("ERROR: Can not clone, something is broken here ...."); + System.exit( -1 ); + } + return null; // dummy + } + + public SdfEntity( String line ){ + // isValid? + setProperties( line ) ; + } + public SdfEntity(String project, String source_file, String dummy1, String resource_type, String gid, String lid, String helpid, String platform, String dummy2, String langid, String text, String helptext, String quickhelptext, String title , String date) { + super(); + this.project = project; + this.source_file = source_file; + this.dummy1 = dummy1; + this.resource_type = resource_type; + this.gid = gid; + this.lid = lid; + this.helpid = helpid; + this.platform = platform; + this.dummy2 = dummy2; + this.langid = langid; + this.text = text; + this.helptext = helptext; + this.quickhelptext = quickhelptext; + this.title = title; + this.date = date; + } + + public void setProperties( String line ){ + + String[] splitted = line.split("\t"); + + setProject( splitted[ SdfEntity.PROJECT_POS ] ); + setSource_file( splitted[ SdfEntity.SOURCE_FILE_POS ] ); + setDummy1( splitted[ SdfEntity.DUMMY1_POS ] ); + setResource_type( splitted[ SdfEntity.RESOURCE_TYPE_POS ] ); + setGid( splitted[ SdfEntity.GID_POS ] ); + setLid( splitted[ SdfEntity.LID_POS ] ); + setHelpid( splitted[ SdfEntity.HELPID_POS ] ); + setPlatform( splitted[ SdfEntity.PLATFORM_POS ] ); + setDummy2( splitted[ SdfEntity.DUMMY2_POS ] ); + setLangid( splitted[ SdfEntity.LANGID_POS ] ); + setText( splitted[ SdfEntity.TEXT_POS ] ); + setHelptext( splitted[ SdfEntity.HELPTEXT_POS ] ); + setQuickhelptext( splitted[ SdfEntity.QUICKHELPTEXT_POS ] ); + setTitle( splitted[ SdfEntity.TITLE_POS ] ); + setDate( splitted[ SdfEntity.DATE_POS ] ); + } + + public String getFileId(){ + return project+"\\"+source_file; + } + public String getResourcePath(){ + return source_file.substring(0 , source_file.lastIndexOf( "\\" )-1 ); + } + public String toString(){ + return new StringBuffer( project ).append( "\t" ).append( source_file ).append( "\t" ).append( dummy1 ).append( "\t" ).append( resource_type ).append( "\t" ).append( gid ).append( "\t" ) + .append( lid ).append( "\t" ).append( helpid ).append( "\t" ).append( platform ).append( "\t" ).append( dummy2 ).append( "\t" ).append( langid ).append( "\t" ) + .append( text ).append( "\t" ).append( helptext ).append( "\t" ).append( quickhelptext ).append( "\t" ).append( title ).append( "\t" ).append( date ).toString(); + } + public String getId(){ + return new StringBuffer( project ).append( gid ).append( lid ).append( source_file ).append( resource_type ).append( platform ).append( helpid ).append( langid ).toString(); + } + + public String getDummy1() { + return dummy1; + } + + public void setDummy1(String dummy1) { + this.dummy1 = dummy1; + } + + public String getPlatform() { + return platform; + } + + public void setPlatform(String platform) { + this.platform = platform; + } + + public String getDummy2() { + return dummy2; + } + + public void setDummy2(String dummy2) { + this.dummy2 = dummy2; + } + + public String getGid() { + return gid; + } + + public void setGid(String gid) { + this.gid = gid; + } + + public String getHelpid() { + return helpid; + } + + public void setHelpid(String helpid) { + this.helpid = helpid; + } + + public String getHelptext() { + return helptext; + } + + public void setHelptext(String helptext) { + this.helptext = helptext; + } + + public String getLangid() { + return langid; + } + + public void setLangid(String langid) { + this.langid = langid; + } + + public String getLid() { + return lid; + } + + public void setLid(String lid) { + this.lid = lid; + } + + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + public String getQuickhelptext() { + return quickhelptext; + } + + public void setQuickhelptext(String quickhelptext) { + this.quickhelptext = quickhelptext; + } + + public String getResource_type() { + return resource_type; + } + + public void setResource_type(String resource_type) { + this.resource_type = resource_type; + } + + public String getSource_file() { + return source_file; + } + + public void setSource_file(String source_file) { + this.source_file = source_file; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + public String getDate() { + return date; + } + public void setDate(String date) { + this.date = date; + } + + +} diff --git a/l10ntools/java/jpropex/jpropex b/l10ntools/java/jpropex/jpropex new file mode 100755 index 000000000000..2d62d13b093e --- /dev/null +++ b/l10ntools/java/jpropex/jpropex @@ -0,0 +1,10 @@ +#!/bin/sh +if [ x${SOLARENV}x = xx ]; then + echo No environment found, please use 'configure' or 'setsolar' + exit 1 +fi +if [ x${JAVA_HOME}x = xx ]; then + echo No Java found! + exit 1 +fi +exec java -DSOLARSRC=${SOLARSRC} -DWORK_STAMP=${WORK_STAMP} -DUSE_SHELL= -jar ${SOLARVER}/${INPATH}/bin${UPDMINOREXT}/jpropex.jar "$@" diff --git a/l10ntools/java/jpropex/jpropex.MF b/l10ntools/java/jpropex/jpropex.MF new file mode 100755 index 000000000000..3e22e7e9bfbf --- /dev/null +++ b/l10ntools/java/jpropex/jpropex.MF @@ -0,0 +1 @@ +Main-Class: Main diff --git a/l10ntools/java/jpropex/makefile.mk b/l10ntools/java/jpropex/makefile.mk new file mode 100755 index 000000000000..f86d2c830025 --- /dev/null +++ b/l10ntools/java/jpropex/makefile.mk @@ -0,0 +1,36 @@ +#************************************************************************* +# +# 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=transex3 +TARGET=jpropex + +.INCLUDE : ant.mk + +ALLTAR : ANTBUILD + 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/prj/build.lst b/l10ntools/prj/build.lst index ff961c096cbd..8387154897b3 100644 --- a/l10ntools/prj/build.lst +++ b/l10ntools/prj/build.lst @@ -3,8 +3,7 @@ tr l10ntools usr1 - all tr_mkout NULL tr l10ntools\inc nmake - all tr_inc NULL tr l10ntools\source nmake - all tr_src tr_inc NULL tr l10ntools\layout nmake - all rt_layout tr_src tr_inc NULL -#tr l10ntools\java\l10nconv nmake - all tr_conv NULL -#tr l10ntools\java\receditor nmake - all tr_rece NULL +tr l10ntools\java\jpropex nmake - all tr_blah NULL tr l10ntools\source\help nmake - all tr_bla_help NULL tr l10ntools\source\filter\utils nmake - all tr_bla_utils NULL tr l10ntools\source\filter\merge nmake - all tr_bla_merge tr_bla_utils NULL diff --git a/l10ntools/prj/d.lst b/l10ntools/prj/d.lst index f75c16b43764..0b6a43444613 100644 --- a/l10ntools/prj/d.lst +++ b/l10ntools/prj/d.lst @@ -29,6 +29,7 @@ mkdir: %_DEST%\bin%_EXT%\help\com\sun\star\help ..\%__SRC%\bin\ulfconv %_DEST%\bin%_EXT%\ulfconv ..\%__SRC%\class\FCFGMerge.jar %_DEST%\bin%_EXT%\FCFGMerge.jar ..\%__SRC%\class\HelpIndexerTool.jar %_DEST%\bin%_EXT%\HelpIndexerTool.jar +..\%__SRC%\class\jpropex\jpropex.jar %_DEST%\bin%_EXT%\jpropex.jar ..\%__SRC%\bin\HelpLinker %_DEST%\bin%_EXT%\HelpLinker ..\%__SRC%\bin\HelpCompiler %_DEST%\bin%_EXT%\HelpCompiler ..\%__SRC%\bin\HelpCompiler.exe %_DEST%\bin%_EXT%\HelpCompiler.exe @@ -40,6 +41,7 @@ mkdir: %_DEST%\bin%_EXT%\help\com\sun\star\help ..\%__SRC%\class\receditor\receditor.jar %_DEST%\bin%_EXT%\receditor.jar +..\java\jpropex\jpropex %_DEST%\bin%_EXT%\jpropex ..\scripts\localize.pl %_DEST%\bin%_EXT%\localize.pl ..\scripts\localize_old.pl %_DEST%\bin%_EXT%\localize_old.pl ..\scripts\localize %_DEST%\bin%_EXT%\localize @@ -50,6 +52,7 @@ mkdir: %_DEST%\bin%_EXT%\help\com\sun\star\help ..\inc\l10ntools\directory.hxx %_DEST%\inc%_EXT%\l10ntools\directory.hxx ..\inc\l10ntools\file.hxx %_DEST%\inc%_EXT%\l10ntools\file.hxx ..\inc\l10ntools\vosapp.hxx %_DEST%\inc%_EXT%\l10ntools\vosapp.hxx +..\source\filter\merge\FCFGMerge.cfg %_DEST%\inc%_EXT%\l10ntools\FCFGMerge.cfg ..\inc\utf8conv.hxx %_DEST%\inc%_EXT%\l10ntools\utf8conv.hxx ..\%__SRC%\lib\transex.lib %_DEST%\lib%_EXT%\transex.lib 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..4aea1d933992 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"; @@ -284,9 +272,11 @@ sub write_sdf foreach my $lang( keys( %{ $string_hash } ) ) { my @sdf_file; + next , if( $lang eq "en-US" ); + mkdir $l10n_file."/$lang"; # 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" ){ @@ -392,11 +382,9 @@ sub merge_gsicheck{ my ( $TMPHANDLE , $tmpfile ) = File::Temp::tempfile(); close ( $TMPHANDLE ); - if( $ENV{WRAPCMD} ){ - $command = "$ENV{WRAPCMD} gsicheck"; - }else{ - $command = "gsicheck"; - } + $command = "$ENV{WRAPCMD} " if( $ENV{WRAPCMD} ); + $command .= "$ENV{SOLARVER}/$ENV{INPATH}/bin/gsicheck"; + my $errfile = $sdffile.".err"; $command .= " -k -c -wcf $tmpfile -wef $errfile -l \"\" $sdffile"; #my $rc = system( $command ); @@ -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/export.cxx b/l10ntools/source/export.cxx index a3df11c2920b..59f29525eda4 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -2096,7 +2096,7 @@ BOOL Export::PrepareTextToMerge( ByteString &rText, USHORT nTyp, } ByteString sContent; - pEntrys->GetText( sContent, nTyp, nLangIndex ); + pEntrys->GetTransex3Text( sContent, nTyp, nLangIndex ); //if ( !sContent.Len() && ( ! nLangIndex.EqualsIgnoreCaseAscii("en-US") )) { if ( !sContent.Len() && ( ! Export::isSourceLanguage( nLangIndex ) )) { rText = sOrigText; @@ -2158,7 +2158,7 @@ void Export::MergeRest( ResData *pResData, USHORT nMode ) sCur = aLanguages[ n ]; ByteString sText; - BOOL bText = pEntry->GetText( sText, STRING_TYP_TEXT, sCur , TRUE ); + BOOL bText = pEntry->GetTransex3Text( sText, STRING_TYP_TEXT, sCur , TRUE ); if ( bText && sText.Len() && sText != "-" ) { ByteString sOutput; if ( bNextMustBeDefineEOL) { @@ -2211,7 +2211,7 @@ void Export::MergeRest( ResData *pResData, USHORT nMode ) sCur = aLanguages[ n ]; ByteString sText; - BOOL bText = pEntry->GetText( sText, STRING_TYP_QUICKHELPTEXT, sCur, TRUE ); + BOOL bText = pEntry->GetTransex3Text( sText, STRING_TYP_QUICKHELPTEXT, sCur, TRUE ); if ( bText && sText.Len() && sText != "-" ) { ByteString sOutput; if ( bNextMustBeDefineEOL) { @@ -2258,7 +2258,7 @@ void Export::MergeRest( ResData *pResData, USHORT nMode ) sCur = aLanguages[ n ]; ByteString sText; - BOOL bText = pEntry->GetText( sText, STRING_TYP_TITLE, sCur, TRUE ); + BOOL bText = pEntry->GetTransex3Text( sText, STRING_TYP_TITLE, sCur, TRUE ); if ( bText && sText.Len() && sText != "-" ) { ByteString sOutput; if ( bNextMustBeDefineEOL) { @@ -2343,9 +2343,9 @@ void Export::MergeRest( ResData *pResData, USHORT nMode ) //printf("Lang %s, List Index %d\n",sCur.GetBuffer(),(int)nLIndex); ByteString sText; BOOL bText; - bText = pEntrys->GetText( sText, STRING_TYP_TEXT, sCur, TRUE ); + bText = pEntrys->GetTransex3Text( sText, STRING_TYP_TEXT, sCur, TRUE ); if( !bText ) - bText = pEntrys->GetText( sText , STRING_TYP_TEXT, SOURCE_LANGUAGE , FALSE ); + bText = pEntrys->GetTransex3Text( sText , STRING_TYP_TEXT, SOURCE_LANGUAGE , FALSE ); // Use fallback, if data is missing in sdf file //if( !bText && pResData->sResTyp.Equals( "pairedlist" ) ){ diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx index 8a384b415b6f..fc8f823b7deb 100644 --- a/l10ntools/source/export2.cxx +++ b/l10ntools/source/export2.cxx @@ -703,11 +703,6 @@ void Export::getRandomName( ByteString& sRandStr ) DirEntry Export::GetTempFile() /*****************************************************************************/ { -#if defined(WNT) || defined(OS2) - String sTempDir( Export::GetEnv( "TEMP" ), RTL_TEXTENCODING_ASCII_US ); -#else - String sTempDir( String::CreateFromAscii( "/tmp" )); -#endif rtl::OUString* sTempFilename = new rtl::OUString(); // Create a temp file 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/HelpLinker.cxx b/l10ntools/source/help/HelpLinker.cxx index ae2b88bfc470..94139f89de1e 100644 --- a/l10ntools/source/help/HelpLinker.cxx +++ b/l10ntools/source/help/HelpLinker.cxx @@ -245,7 +245,11 @@ class HelpLinker { public: void main(std::vector<std::string> &args, - std::string* pExtensionPath = NULL, const rtl::OUString* pOfficeHelpPath = NULL ) +// std::string* pExtensionPath = NULL, const rtl::OUString* pOfficeHelpPath = NULL ) + std::string* pExtensionPath = NULL, + std::string* pDestination = NULL, + const rtl::OUString* pOfficeHelpPath = NULL ) + throw( HelpProcessingException ); HelpLinker() @@ -269,6 +273,7 @@ private: std::string lang; std::string hid; std::string extensionPath; + std::string extensionDestination; bool bExtensionMode; fs::path indexDirName; Stringtable hidlistTranslation; @@ -396,7 +401,8 @@ void HelpLinker::link() throw( HelpProcessingException ) if( bExtensionMode ) { - indexDirParentName = sourceRoot; + //indexDirParentName = sourceRoot; + indexDirParentName = extensionDestination; } else { @@ -752,8 +758,9 @@ void HelpLinker::link() throw( HelpProcessingException ) void HelpLinker::main( std::vector<std::string> &args, - std::string* pExtensionPath, const rtl::OUString* pOfficeHelpPath ) - throw( HelpProcessingException ) + std::string* pExtensionPath, std::string* pDestination, + const rtl::OUString* pOfficeHelpPath ) + throw( HelpProcessingException ) { rtl::OUString aOfficeHelpPath; @@ -764,7 +771,7 @@ void HelpLinker::main( std::vector<std::string> &args, bExtensionMode = true; extensionPath = *pExtensionPath; sourceRoot = fs::path(extensionPath); - + extensionDestination = *pDestination; aOfficeHelpPath = *pOfficeHelpPath; } if (args.size() > 0 && args[0][0] == '@') @@ -1069,6 +1076,7 @@ HELPLINKER_DLLPUBLIC bool compileExtensionHelp const rtl::OUString& aExtensionName, const rtl::OUString& aExtensionLanguageRoot, sal_Int32 nXhpFileCount, const rtl::OUString* pXhpFiles, + const rtl::OUString& aDestination, HelpProcessingErrorInfo& o_rHelpProcessingErrorInfo ) { @@ -1096,19 +1104,22 @@ HELPLINKER_DLLPUBLIC bool compileExtensionHelp args.push_back(std::string( argv[i]) ); for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) - delete argv[iXhp + 3]; + delete[] argv[iXhp + 3]; delete[] argv; rtl::OString aOExtensionLanguageRoot = rtl::OUStringToOString( aExtensionLanguageRoot, fs::getThreadTextEncoding() ); const char* pExtensionPath = aOExtensionLanguageRoot.getStr(); std::string aStdStrExtensionPath = pExtensionPath; + rtl::OString aODestination = rtl::OUStringToOString(aDestination, fs::getThreadTextEncoding()); + const char* pDestination = aODestination.getStr(); + std::string aStdStrDestination = pDestination; // Set error handler xmlSetStructuredErrorFunc( NULL, (xmlStructuredErrorFunc)StructuredXMLErrorFunction ); try { HelpLinker* pHelpLinker = new HelpLinker(); - pHelpLinker->main( args, &aStdStrExtensionPath, &aOfficeHelpPath ); + pHelpLinker->main( args, &aStdStrExtensionPath, &aStdStrDestination, &aOfficeHelpPath ); delete pHelpLinker; } catch( const HelpProcessingException& e ) diff --git a/l10ntools/source/help/compilehelp.hxx b/l10ntools/source/help/compilehelp.hxx index 472b15231639..9c59083bf038 100644 --- a/l10ntools/source/help/compilehelp.hxx +++ b/l10ntools/source/help/compilehelp.hxx @@ -72,6 +72,7 @@ HELPLINKER_DLLPUBLIC bool compileExtensionHelp const rtl::OUString& aExtensionName, const rtl::OUString& aExtensionLanguageRoot, sal_Int32 nXhpFileCount, const rtl::OUString* pXhpFiles, + const rtl::OUString& aDestination, HelpProcessingErrorInfo& o_rHelpProcessingErrorInfo ); 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/localize.cxx b/l10ntools/source/localize.cxx index b869098faed7..6cecb0972cb7 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -66,6 +66,7 @@ const char *ExeTable[][5] = { { "xcs", "cfgex", "-UTF8 -e -f", "negative", "iso" }, { "xrm", "xrmex", "-UTF8 -e", "negative", "iso" }, { "xhp", "helpex", " -e", "negative", "noiso" }, + { "properties", "jpropex", " -e", "negative", "noiso" }, { "NULL", "NULL", "NULL", "NULL", "NULL" } }; @@ -959,8 +960,16 @@ int _cdecl main( int argc, char *argv[] ) aIter.SetLanguageRestriction( sLanguages ); if ( bExport ){ if( bQuiet2 ){ /*printf("");*/fflush( stdout );} - aIter.Extract( sFileName ); - if( bQuiet2 ){ printf("\n %d files found!\n",aIter.GetFileCnt());} + if( *iter == "ooo" ) + aIter.Extract( sFileName ); + else + { + ByteString sFileNameWithExt( sFileName ); + sFileNameWithExt += ByteString( "." ); + sFileNameWithExt += ByteString( (*iter).c_str() ); + aIter.Extract( sFileNameWithExt ); + } + if( bQuiet2 ){ printf("\n%d files found!\n",aIter.GetFileCnt());} } } if( hasPwd ) @@ -973,7 +982,7 @@ int _cdecl main( int argc, char *argv[] ) if ( bExport ){ if( bQuiet2 ){ /*printf("");*/fflush( stdout );} aIter.Extract( sFileName ); - if( bQuiet2 ){ printf("\n %d files found!\n",aIter.GetFileCnt());} + if( bQuiet2 ){ printf("\n%d files found!\n",aIter.GetFileCnt());} } } diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx index 660247ce1f8a..8c06d5a28171 100644 --- a/l10ntools/source/merge.cxx +++ b/l10ntools/source/merge.cxx @@ -61,6 +61,23 @@ ByteString PFormEntrys::Dump() return sRet; } +BOOL PFormEntrys::GetTransex3Text( ByteString &rReturn, + USHORT nTyp, const ByteString &nLangIndex, BOOL bDel ) +{ + BOOL rc = GetText( rReturn , nTyp , nLangIndex , bDel ); + ByteString test( rReturn ); + for( USHORT idx = 0; idx < rReturn.Len(); idx++ ) + { + if( rReturn.GetChar( idx ) == '\"' && ( idx >= 1 ) && rReturn.GetChar( idx-1 ) == '\\' ) + { + rReturn.Erase( idx-1 , 1 ); + } + } + //if( !rReturn.Equals( test ) ) + // printf("*CHANGED******************\n%s\n%s\n",test.GetBuffer(),rReturn.GetBuffer()); + return rc; +} +/*****************************************************************************/ BOOL PFormEntrys::GetText( ByteString &rReturn, USHORT nTyp, const ByteString &nLangIndex, BOOL bDel ) { 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; - } -} -*/ diff --git a/l10ntools/source/xrmlex.l b/l10ntools/source/xrmlex.l index c28aede4c6c1..4770a851c741 100644 --- a/l10ntools/source/xrmlex.l +++ b/l10ntools/source/xrmlex.l @@ -55,54 +55,55 @@ int bText=0; %% -"<Readme"[^\>]*\> { - WorkOnTokenSet( XRM_README_START, yytext ); +"<p "[^\>]*xml:lang[^\>]*\> { + WorkOnTokenSet( XRM_TEXT_START , yytext ); } -"</Readme>" { - WorkOnTokenSet( XRM_README_END, yytext ); +"</p>" { + WorkOnTokenSet( XRM_TEXT_END, yytext ); } -"<apochelp"[^\>]*\> { - WorkOnTokenSet( XRM_README_START, yytext ); +"<h1 "[^\>]*xml:lang[^\>]*\> { + WorkOnTokenSet( XRM_TEXT_START , yytext ); } -"</apochelp>" { - WorkOnTokenSet( XRM_README_END, yytext ); +"</h1>" { + WorkOnTokenSet( XRM_TEXT_END, yytext ); } - -"<Section"[^\>]*\> { - WorkOnTokenSet( XRM_SECTION_START, yytext ); +"<h2 "[^\>]*xml:lang[^\>]*\> { + WorkOnTokenSet( XRM_TEXT_START , yytext ); } -"</Section>" { - WorkOnTokenSet( XRM_SECTION_END, yytext ); +"</h2>" { + WorkOnTokenSet( XRM_TEXT_END, yytext ); } - -"<Paragraph"[^\>]*\> { - WorkOnTokenSet( XRM_PARAGRAPH_START, yytext ); +"<h3 "[^\>]*xml:lang[^\>]*\> { + WorkOnTokenSet( XRM_TEXT_START , yytext ); } -"</Paragraph>" { - WorkOnTokenSet( XRM_PARAGRAPH_END, yytext ); +"</h3>" { + WorkOnTokenSet( XRM_TEXT_END, yytext ); } - -"<Text"[^\>]*\> { - WorkOnTokenSet( XRM_TEXT_START, yytext ); +"<h4 "[^\>]*xml:lang[^\>]*\> { + WorkOnTokenSet( XRM_TEXT_START , yytext ); } -"</Text>" { +"</h4>" { WorkOnTokenSet( XRM_TEXT_END, yytext ); } - -"<List"[^\>]*\> { - WorkOnTokenSet( XRM_LIST_START, yytext ); +"<h5 "[^\>]*xml:lang[^\>]*\> { + WorkOnTokenSet( XRM_TEXT_START , yytext ); } -"</List>" { - WorkOnTokenSet( XRM_LIST_END, yytext ); +"</h5>" { + WorkOnTokenSet( XRM_TEXT_END, yytext ); } + + + + + "<!--" { char c1 = 0, c2 = 0, c3 = input(); char pChar[2]; diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx index 149fd560fe3b..b77f75ea04e5 100644 --- a/l10ntools/source/xrmmerge.cxx +++ b/l10ntools/source/xrmmerge.cxx @@ -268,7 +268,7 @@ extern FILE *GetXrmFile() int WorkOnTokenSet( int nTyp, char *pTokenText ) /*****************************************************************************/ { -// printf("Typ = %d , text = '%s'\n",nTyp , pTokenText ); + //printf("Typ = %d , text = '%s'\n",nTyp , pTokenText ); pParser->Execute( nTyp, pTokenText ); return 1; @@ -346,10 +346,10 @@ int XRMResParser::Execute( int nToken, char * pToken ) sLID = ""; sGID += "."; sGID += GetAttribute( rToken, "id" ); - if ( GetAttribute( rToken, "localized" ) == "false" ) +// if ( GetAttribute( rToken, "localized" ) == "false" ) // sLocalized += "0"; - sLocalized = false; - else +// sLocalized = false; +// else // sLocalized += "1"; sLocalized = true; break; @@ -368,47 +368,32 @@ int XRMResParser::Execute( int nToken, char * pToken ) } break; - case XRM_TEXT_START: -// if ( sLocalized.GetChar( sLocalized.Len() - 1 ) == '1' ) { - if ( sLocalized ) { - + case XRM_TEXT_START:{ + //printf("->XRM_TEXT_START\n"); ByteString sNewLID = GetAttribute( rToken, "id" ); if ( sNewLID != sLID ) { - EndOfText( sCurrentOpenTag, sCurrentCloseTag ); + //EndOfText( sCurrentOpenTag, sCurrentCloseTag ); sLID = sNewLID; } bText = TRUE; sCurrentText = ""; sCurrentOpenTag = rToken; Output( rToken ); + //printf("<-XRM_TEXT_START\n"); } break; case XRM_TEXT_END: { -// if ( sLocalized.GetChar( sLocalized.Len() - 1 ) == '1' ) { - if( sLocalized ){ sCurrentCloseTag = rToken; - + //printf("->XRM_TEXT_END\n"); ByteString sLang = GetAttribute( sCurrentOpenTag, "xml:lang" ); - if( sLang.EqualsIgnoreCaseAscii("de") ){ - ULONG nLen = 0; - while ( sCurrentText.Len() != nLen ) - { - nLen = sCurrentText.Len(); - sCurrentText.SearchAndReplaceAll( "\n\t", "\n" ); - sCurrentText.SearchAndReplaceAll( "\n ", "\n" ); - } - sCurrentText.SearchAndReplaceAll( "\n", " " ); - sCurrentCloseTag = rToken; - } WorkOnText( sCurrentOpenTag, sCurrentText ); Output( sCurrentText ); - - //fprintf( stdout, "%s %s\n", sGID.GetBuffer(), sLID.GetBuffer()); - //fprintf( stdout, "%s\n\n", sCurrentText.GetBuffer()); - + EndOfText( sCurrentOpenTag, sCurrentCloseTag );// <--- bText = FALSE; - } + rToken = ByteString(""); + sCurrentText = ByteString(""); + //printf("<-XRM_TEXT_END"); } break; @@ -429,8 +414,9 @@ int XRMResParser::Execute( int nToken, char * pToken ) } if ( !bText ) + { Output( rToken ); - + } return 0; } @@ -598,15 +584,19 @@ void XRMResExport::EndOfText( sCur = aLanguages[ n ]; ByteString sAct = pResData->sText[ sCur ]; - Export::UnquotHTML( sAct ); + //Export::UnquotHTML( sAct ); sAct.EraseAllChars( 0x0A ); ByteString sOutput( sPrj ); sOutput += "\t"; sOutput += sPath; sOutput += "\t0\t"; sOutput += "readmeitem\t"; - sOutput += pResData->sGId; sOutput += "\t"; - sOutput += pResData->sId; sOutput += "\t\t\t0\t"; + sOutput += pResData->sId; + // USE LID AS GID OR MERGE DON'T WORK + //sOutput += pResData->sGId; + sOutput += "\t"; + sOutput += pResData->sId; + sOutput += "\t\t\t0\t"; sOutput += sCur; sOutput += "\t"; @@ -615,7 +605,8 @@ void XRMResExport::EndOfText( sOutput.SearchAndReplaceAll( sSearch, "_" ); //if( !sCur.EqualsIgnoreCaseAscii("de") ||( sCur.EqualsIgnoreCaseAscii("de") && !Export::isMergingGermanAllowed( sPrj ) ) ) - pOutputStream->WriteLine( sOutput ); + if( sAct.Len() > 1 ) + pOutputStream->WriteLine( sOutput ); } } delete pResData; @@ -666,12 +657,14 @@ void XRMResMerge::WorkOnText( if ( pMergeDataFile ) { if ( !pResData ) { ByteString sPlatform( "" ); - pResData = new ResData( sPlatform, GetGID() , sFilename ); +// pResData = new ResData( sPlatform, GetGID() , sFilename ); + pResData = new ResData( sPlatform, GetLID() , sFilename ); pResData->sId = GetLID(); + pResData->sResTyp = "readmeitem"; } - PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrys( pResData ); + PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrys( pResData ); if ( pEntrys ) { ByteString sContent; if ( Export::isAllowed( sLang ) && @@ -682,7 +675,7 @@ void XRMResMerge::WorkOnText( { rText = sContent; ConvertStringToXMLFormat( rText ); - Export::QuotHTMLXRM( rText ); + //Export::QuotHTMLXRM( rText ); } } } @@ -692,7 +685,8 @@ void XRMResMerge::WorkOnText( void XRMResMerge::Output( const ByteString& rOutput ) /*****************************************************************************/ { - if ( pOutputStream ) + //printf("W: %s\n",rOutput.GetBuffer()); + if ( pOutputStream && rOutput.Len() > 0 ) pOutputStream->Write( rOutput.GetBuffer(), rOutput.Len()); } @@ -703,6 +697,8 @@ void XRMResMerge::EndOfText( ) /*****************************************************************************/ { + + Output( rCloseTag ); if ( pMergeDataFile && pResData ) { PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrys( pResData ); if ( pEntrys ) { @@ -710,18 +706,13 @@ void XRMResMerge::EndOfText( for( unsigned int n = 0; n < aLanguages.size(); n++ ){ sCur = aLanguages[ n ]; ByteString sContent; -//<<<<<<< xrmmerge.cxx if ( !sCur.EqualsIgnoreCaseAscii("en-US") && - // ( !sCur.EqualsIgnoreCaseAscii("de") ||( sCur.EqualsIgnoreCaseAscii("de") && Export::isMergingGermanAllowed( sPrj ) )) && -//======= -// if ( Export::isAllowed( sCur ) && -//>>>>>>> 1.17 ( pEntrys->GetText( sContent, STRING_TYP_TEXT, sCur, TRUE )) && ( sContent != "-" ) && ( sContent.Len())) { ByteString sText( sContent ); - Export::QuotHTMLXRM( sText ); + //Export::QuotHTMLXRM( sText ); ByteString sAdditionalLine( "\t" ); sAdditionalLine += rOpenTag; |