This is an automated email from the ASF dual-hosted git repository.
mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO42X by this push:
new 0a64c50 Fixed typos, removed whitespace
0a64c50 is described below
commit 0a64c505d880b8abd9e6dd5cff5ce19a53471399
Author: mseidel <[email protected]>
AuthorDate: Wed Nov 25 22:17:31 2020 +0100
Fixed typos, removed whitespace
(cherry picked from commit f3abe5945e37559acdd237ffd9fb82559c65fbe1)
---
.../com/sun/star/tooling/converter/Convert.java | 162 +++++++++++----------
.../com/sun/star/tooling/converter/Converter.java | 107 +++++++-------
2 files changed, 136 insertions(+), 133 deletions(-)
diff --git
a/main/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Convert.java
b/main/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Convert.java
index 14146fe..594ade0 100644
---
a/main/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Convert.java
+++
b/main/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Convert.java
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,22 +7,23 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
+
/*
* the main Class
- *
+ *
* Command Line arguments are reviewed
* and a Converter is constructed
*/
@@ -38,32 +39,32 @@ import com.sun.star.tooling.DirtyTags.DirtyTagWrapper;
/**
* The main class of the converter tool
- *
+ *
* The converter tool is command line based.
* Its classes allow the converting between the
* file formats sdf, gsi and <a
href="http://www.oasis-open.org/committees/xliff/documents/cs-xliff-core-1.1-20031031.htm">xliff</a>.
- *
+ *
* Those file formats are used in localization
- * of Star-Office and Open-Office.
- *
- * Information about the whole localization process can be found in
+ * of Star-Office and OpenOffice.
+ *
+ * Information about the whole localization process can be found in
* <a
href="http://ded-1.germany.sun.com/webcontent/guidelines/pdf/L10NSO8.pdf">http://ded-1.germany.sun.com/webcontent/guidelines/pdf/L10NSO8.pdf</a>
- *
+ *
* @author Christian Schmidt 2005
- *
+ *
*/
public class Convert {
private static Calendar cal;
-
+
private static final String EMPTY = "";
-
+
/**
* The name of the file containing the debug information
* that where found while converting (every output goes here too)
*/
private static String dbgName = EMPTY;
-
+
/**
* the character that separates the extension from the file name
*/
@@ -91,7 +92,7 @@ public class Convert {
private static File secondSource;
//private static final char pathSeperator = '\\';
-
+
/**
* The language that should be the source language
* that means the language to translate from
@@ -107,7 +108,7 @@ public class Convert {
* the type of the source file (sdf,xliff,...)
*/
private static String sourceType = EMPTY;
-
+
/**
* The time when converting started
*/
@@ -129,7 +130,7 @@ public class Convert {
private static String targetType = EMPTY;
/**
- * Store the current version ID and number of this tool
+ * Store the current version ID and number of this tool
*/
final static String version = " Prod.20050710:1255 ";
@@ -139,19 +140,19 @@ public class Convert {
private static String secondSourceName=EMPTY;
/**
* Indicate whether strings in xliff files should
- * be wrapped with ept/bpt or sub tags to enable translation tools
+ * be wrapped with ept/bpt or sub tags to enable translation tools
* to synchronize source language string with there translation
- *
+ *
* @see <a
href="http://ded-1.germany.sun.com/webcontent/guidelines/pdf/L10NSO8.pdf">http://ded-1.germany.sun.com/webcontent/guidelines/pdf/L10NSO8.pdf</a>
*/
private static boolean doWrap=true;
-
+
public static void main(String[] args) throws IOException,
Exception {
try{
-
- //go, parse and check the command line parameters
+
+ //go, parse and check the command line parameters
ParameterChecker.checkClParameters(args);
ParameterChecker.createContentOfClParameters();
//Initialize the tagWrapper
@@ -159,19 +160,19 @@ public class Convert {
//create an instance of converter
Converter conv = new Converter(sourceType, sourceName,
sourceLanguage,
targetType, targetName,
TargetLanguage,secondSourceName, overwrite);
- // get aktual time
+ // get actual time
cal = Calendar.getInstance();
startTime = cal.getTime().toString();
//show infos
printPreamble();
//do the job
conv.convert();
-
+
showStatistic();
-
+
//close log, debug...
OutputHandler.closeAll();
-
+
} catch(Exception e){
System.out.print("An EXCEPTION occurred, please check your
commad line settings \n"+e.getMessage());
System.exit(-1);
@@ -190,7 +191,7 @@ public class Convert {
final String ls = System.getProperty("line.separator");
System.out
.println(
-
+
"File Converting Tool 'converter' Version "
+ Convert.version
+ ls
@@ -211,18 +212,18 @@ public class Convert {
+ " Default is 'en-US' " + ls
+ "-t LanguageID the language code of the target
language (de, fr...)." + ls
+ " Default is first found Language
other than source language." + ls
- + "-l [LogPath] write a log file, you can name
the file." + ls
+ + "-l [LogPath] write a log file, you can name the
file." + ls
+ "-o overwrite existing files without
asking." + ls
+ "-nw disable the wrapping with ept/bpt
tags." + ls
+ ls
+ "The created files were stored in the SourceFile
Path if nothing else is given. " + ls
- + "The extension is '.xliff','.sdf' depending on the
source file and '.log' " + ls
+ + "The extension is '.xliff','.sdf' depending on the
source file and '.log' " + ls
+ "for the logfile." + ls);
}
/**
* show the parameters the converter starts with
- *
+ *
* @throws IOException
*/
final private static void printPreamble() throws IOException {
@@ -241,7 +242,7 @@ public class Convert {
/**
* show some statistic data
- *
+ *
* @throws IOException
*/
final private static void showStatistic() throws IOException {
@@ -259,11 +260,11 @@ public class Convert {
}
/**
- * Get the extensiion of a file name
+ * Get the extension of a file name
* (sdf,xliff,gsi)
- *
+ *
* @param sourceString the file name
- * @return the extension
+ * @return the extension
*/
static protected String extractExtension(String sourceString) {
String ext = sourceString.substring(sourceString
@@ -287,16 +288,16 @@ public class Convert {
// }
/**
- *
+ *
*/
public Convert() {
}
/**
- *
- * Verify a parameter array and create content useable by the programm
+ *
+ * Verify a parameter array and create content usable by the program
* from the switches and attributes set at command line
- *
+ *
* @author Christian Schmidt 2005
*/
private static class ParameterChecker {
@@ -312,19 +313,19 @@ public class Convert {
/**
* Create a new Instance of ParameterChecker
- *
- *
+ *
+ *
*/
public ParameterChecker(){};
/**
* Checks the command line parameters
- *
+ *
* @param args the parameters to check and to parse
* @throws IOException
*/
private static void checkClParameters(String[] args) throws
IOException {
try {
- //show help if no attrributes...
+ // show help if no attributes...
if (args.length == 0) {
printHelp();
System.exit(-1);
@@ -344,56 +345,56 @@ public class Convert {
File source = new File(sourceName);
//break if there is no source to convert
if (!source.exists())
- throw new IOException("ERROR:Can not find Source File '"
+ throw new IOException("ERROR: Can not find Source File '"
+ sourceName + "'. Aborting...");
-
+
// String name=source.getName();
// String parent=source.getParent();
// String path=source.getPath();
-
+
filePath =
(source.getParent()==null)?"":source.getParent()+File.separator;
//extractPath(sourceName);
fileName =
source.getName().substring(0,source.getName().lastIndexOf(extensionSeperator));
-
+
for (int i = 1; i < args.length; i++) {
-
-
+
+
if ("-s".equals(args[i])) {
if (args.length > i + 1) {
sourceLanguage = args[++i];
-
+
} else {
throw new ConverterException(
"missing argument for -s source
language");
}
continue;
}
-
+
if ("-S".equals(args[i])) {
if (args.length > i + 1) {
sourceType = args[++i];
if (args.length > i +1
&&!args[i+1].startsWith("-")) {
secondSourceName = args[++i];
}
-
+
} else {
throw new ConverterException(
"missing argument for -S source
type");
}
continue;
}
-
+
if ("-T".equals(args[i])) {
if (args.length > i + 1) {
targetType = args[++i];
-
-
+
+
} else {
throw new ConverterException(
"missing argument for -T target
type");
}
continue;
}
-
+
if ("-l".equals(args[i])) {
OutputHandler.doLog = true;
if (args.length > i + 1
@@ -404,27 +405,27 @@ public class Convert {
}
continue;
}
-
+
if ("-o".equals(args[i])) {
overwrite = true;
continue;
}
-
+
if ("-nw".equals(args[i])) {
doWrap = false;
continue;
}
-
+
if ("-h".equals(args[i])) {
printHelp();
System.exit(0);
}
-
+
if ("-dbg".equals(args[i])) {
OutputHandler.doDebug = true;
continue;
}
-
+
if ("-t".equals(args[i])) {
if (args.length > i + 1) {
TargetLanguage = args[++i];
@@ -434,33 +435,33 @@ public class Convert {
}
continue;
}
-
+
if (i == 1 && !args[i].startsWith("-")) { //target file
// found
targetName = args[i];
continue;
}
- //if we come here we
- //can not match the Attribute
+ // if we come here we
+ // can not match the attribute
throw new ConverterException("unknown Attribute: "
+ args[i]);
-
+
}//end for
} catch (ConverterException e) {
OutputHandler.out("ERROR: "+e.getMessage());
System.exit(-1);
} catch (Throwable t){
- System.out.print("An Error occurred while parsing the command
line,\n please check your commad line settings.\n "+t.getMessage());
+ System.out.print("An Error occurred while parsing the command
line,\nplease check your command line settings.\n "+t.getMessage());
System.exit(-1);
}
}//end checkClParameters
/**
- * Creates the appropriate content of what ever data
+ * Creates the appropriate content of whatever data
* we found in the command line
- *
+ *
* @throws IOException
*/
private static void createContentOfClParameters() throws IOException {
@@ -477,7 +478,7 @@ public class Convert {
}
if (OutputHandler.doLog) {// create a logfile?
- //given at command line?
+ // given at command line?
if (EMPTY.equals(logString) || logString == null) {
logString = new String(filePath + fileName + ".log");
}
@@ -494,20 +495,20 @@ public class Convert {
throw new ConverterException("Source type is missing");
}
}
-
+
if(sourceType.equalsIgnoreCase("gsi")){
-
+
if(EMPTY.equals(Convert.secondSourceName)){
Convert.secondSourceName=filePath+fileName+".sdf";
}
//secondSource=new File(Convert.secondSourceName);
-
+
}
-
+
if (EMPTY.equals(sourceName)) {
sourceName = filePath + fileName + "." + sourceType;
}
- //no target type given at command line?
+ // no target type given at command line?
if (EMPTY.equals(targetType) || targetType == null) {
if (!(EMPTY.equals(targetName) || targetName == null)) {
targetType = extractExtension(targetName);
@@ -516,7 +517,7 @@ public class Convert {
}
}
- //no target File specified at command line
+ // no target File specified at command line
if (EMPTY.equals(targetName) || targetName == null) {
targetName = filePath + fileName + "." + targetType;
if (targetName.equals(Convert.secondSourceName)){
@@ -533,14 +534,15 @@ public class Convert {
OutputHandler.out("ERROR: \nSource
'"+Convert.sourceName+"' and \nTarget'"+targetName+"' are the same");
System.exit(0);
}
-
-
+
+
} catch (ConverterException e) {
- OutputHandler.out(e.getMessage());
+ OutputHandler.out(e.getMessage());
}
-
+
}
}
-}
\ No newline at end of file
+}
+
diff --git
a/main/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Converter.java
b/main/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Converter.java
index 5bd57b2..90c1220 100644
---
a/main/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Converter.java
+++
b/main/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Converter.java
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,19 +7,20 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
+
/*
* Converter.java
*
@@ -48,21 +49,21 @@ import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
/**
- *
+ *
* This class handles the creating of the source to read from,
* the target to write to and the appropriate DataHandler
- *
- * @author Christian Schmidt 2005
+ *
+ * @author Christian Schmidt 2005
*/
public final class Converter {
/**
- * the used charset f.e. UTF-8
+ * the used charset i.e. UTF-8
*/
private final static String CHARSET = new String("UTF-8");
private static final String EMPTY = new String("");
-
+
/**
* The DataHandler use to connect reader and writer
*/
@@ -72,13 +73,13 @@ public final class Converter {
* Counting the lines written by a writer
*/
private static int lineCounter;
-
+
/**
* The target to write to
*/
private static DataWriter theTargetWriter;
-
-
+
+
/**
* Overwrite existing files
*/
@@ -92,17 +93,17 @@ public final class Converter {
*/
private String sourceString;
/**
- * the Type of the Source file(SDF,GSI,XLIFF)
+ * the Type of the Source file (SDF,GSI,XLIFF)
*/
private String sourceType;
/**
- * The name of the target fille
+ * The name of the target file
*/
private String targetString;
/**
- * the Type of the Target file(SDF,GSI,XLIFF)
+ * the Type of the Target file (SDF,GSI,XLIFF)
*/
- private String targetType;
+ private String targetType;
/**
* The writer that handles the output
*/
@@ -112,7 +113,7 @@ public final class Converter {
* The sourceLanguage
*/
String sourceLanguage = "en-US";
-
+
/**
* The targetLanguage
*/
@@ -141,7 +142,7 @@ public final class Converter {
/**
* Creates a new instance of Converter
- *
+ *
* @param sourceType the type of the sourceFile
* @param sourceString the name of the sourceFile
* @param SourceLanguage the ISO Id of the sourceLanguage
@@ -193,7 +194,7 @@ public final class Converter {
/**
* Do the converting from the source file format to the target file format
- *
+ *
* @throws IOException
*/
public final void convert() throws IOException {
@@ -210,12 +211,12 @@ public final class Converter {
}
}
-
+
/**
- *
+ *
* Encapsulate the reading from an GSI file
- *
+ *
* @author Christian Schmidt 2005
*
*/
@@ -223,7 +224,7 @@ public final class Converter {
DataReader theSourceReader;
/**
* Create a new Instance of GSISource
- *
+ *
* @throws IOException
* @throws Exception
*/
@@ -234,7 +235,7 @@ public final class Converter {
}
public void convertTo(Target t) {
-
+
try {
theTargetWriter = t.getWriter();
while (handler.fillDataFrom(theSourceReader)) {
@@ -253,19 +254,19 @@ public final class Converter {
}
/**
- *
+ *
* Encapsulate to write to a GSI file
- *
+ *
* @author Christian Schmidt 2005
*
*/
private class GSITarget implements Target {
File target;
-
+
/**
* Create a new Instance of GSITarget
- *
+ *
* @throws FileNotFoundException
* @throws IOException
*/
@@ -277,17 +278,17 @@ public final class Converter {
}
public DataWriter getWriter() {
-
+
return theTargetWriter;
}
}
/**
- *
+ *
* Encapsulate the reading from an SDF file
- *
+ *
* @author Christian Schmidt 2005
- *
+ *
*/
private final class SDFSource implements Source {
@@ -333,7 +334,7 @@ public final class Converter {
/**
* Create a new Instance of SDFTarget
- *
+ *
* @throws IOException
*/
public SDFTarget() throws IOException {
@@ -353,17 +354,17 @@ public final class Converter {
}
/**
- * The interface for all convertable sources
- *
+ * The interface for all convertible sources
+ *
* @author Christian Schmidt 2005
*
*/
private interface Source {
-
+
DataReader Source=null;
/**
* Convert this. to the designated target
- * @param target the target of the converting
+ * @param target the target of the converting
* @throws IOException
*/
abstract void convertTo(Target target) throws IOException;
@@ -371,7 +372,7 @@ public final class Converter {
/**
* The interface for all creatable targets
- *
+ *
* @author Christian Schmidt 2005
*
*/
@@ -384,8 +385,8 @@ public final class Converter {
/**
* Get the writer
* this target uses to write the
- * data in the correct format.
- *
+ * data in the correct format.
+ *
* @return the used DataWriter
*/
abstract DataWriter getWriter();
@@ -402,8 +403,8 @@ public final class Converter {
/**
* Create a new Instance of XLIFFSource
- *
- *
+ *
+ *
*/
public XLIFFSource() {
@@ -430,8 +431,8 @@ public final class Converter {
SAXParser parser=factory.newSAXParser();
XMLReader xliffreader=parser.getXMLReader();
-
-
+
+
// XMLReader xliffreader = XMLReaderFactory
//
.createXMLReader("org.apache.crimson.parser.XMLReaderImpl");
xliffreader.setErrorHandler(contentHandler);
@@ -441,23 +442,23 @@ public final class Converter {
xliffreader.setEntityResolver(res);
/*
* a second possibility to resolve an extern entity (DTD)
- *
+ *
*
xliffreader.setFeature("xml.org/sax/features/validation",true);
* xliffreader.setEntityResolver(new EntityResolver() {
* public InputSource resolveEntity(java.lang.String
* publicId, java.lang.String systemId) throws
SAXException,
* java.io.IOException { if (publicId.equals("-//XLIFF//DTD
- * XLIFF//EN")) // this deactivates the open office DTD
+ * XLIFF//EN")) // this deactivates the OpenOffice DTD
* return new InputSource(new ByteArrayInputStream( " <?xml
* version='1.0' encoding='UTF-8'?>" .getBytes())); else
* return null; } });
- *
+ *
*/
xliffreader.parse(sourceString);
} else {
- System.out.println("Datei existiert nicht");
+ System.out.println("File does not exist");
}
} catch (SAXParseException e) {
@@ -477,16 +478,16 @@ public final class Converter {
e1.printStackTrace();
}
- OutputHandler.out("PARSE EXCEPTION " + e.getMessage());
+ OutputHandler.out("PARSE EXCEPTION " + e.getMessage());
} catch (ParserConfigurationException e) {
- OutputHandler.out("PARSER Configuration failed\n " +
e.getMessage());
+ OutputHandler.out("PARSER Configuration failed\n " +
e.getMessage());
}
}
}
/**
* Encapsulate writing to a XLIFF file
- *
+ *
* @author Christian Schmidt 2005
*
*/
@@ -495,7 +496,7 @@ public final class Converter {
/**
* Create a new Instance of XLIFFTarget
- *
+ *
* @throws FileNotFoundException
* @throws IOException
*/
@@ -512,5 +513,5 @@ public final class Converter {
}
}
+}
-}
\ No newline at end of file